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
|
---|---|---|---|---|---|---|---|---|---|---|
4,807 | RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
{
RockerSwitch *rocker = g_malloc0(sizeof(*rocker));
Rocker *r;
r = rocker_find(name);
if (!r) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"rocker %s not found", name);
return NULL;
}
rocker->name = g_strdup(r->name);
rocker->id = r->switch_id;
rocker->ports = r->fp_ports;
return rocker;
}
| true | qemu | ec50dd4634ae06091e61f42b7ba975f9ed510ad0 | RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
{
RockerSwitch *rocker = g_malloc0(sizeof(*rocker));
Rocker *r;
r = rocker_find(name);
if (!r) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"rocker %s not found", name);
return NULL;
}
rocker->name = g_strdup(r->name);
rocker->id = r->switch_id;
rocker->ports = r->fp_ports;
return rocker;
}
| {
"code": [
" RockerSwitch *rocker = g_malloc0(sizeof(*rocker));"
],
"line_no": [
5
]
} | RockerSwitch *FUNC_0(const char *name, Error **errp)
{
RockerSwitch *rocker = g_malloc0(sizeof(*rocker));
Rocker *r;
r = rocker_find(name);
if (!r) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"rocker %s not found", name);
return NULL;
}
rocker->name = g_strdup(r->name);
rocker->id = r->switch_id;
rocker->ports = r->fp_ports;
return rocker;
}
| [
"RockerSwitch *FUNC_0(const char *name, Error **errp)\n{",
"RockerSwitch *rocker = g_malloc0(sizeof(*rocker));",
"Rocker *r;",
"r = rocker_find(name);",
"if (!r) {",
"error_set(errp, ERROR_CLASS_GENERIC_ERROR,\n\"rocker %s not found\", name);",
"return NULL;",
"}",
"rocker->name = g_strdup(r->name);",
"rocker->id = r->switch_id;",
"rocker->ports = r->fp_ports;",
"return rocker;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
4,808 | static int init_dimensions(H264Context *h)
{
int width = h->width - (h->sps.crop_right + h->sps.crop_left);
int height = h->height - (h->sps.crop_top + h->sps.crop_bottom);
/* handle container cropping */
if (FFALIGN(h->avctx->width, 16) == FFALIGN(width, 16) &&
FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16)) {
width = h->avctx->width;
height = h->avctx->height;
}
if (width <= 0 || height <= 0) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid cropped dimensions: %dx%d.\n",
width, height);
if (h->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
av_log(h->avctx, AV_LOG_WARNING, "Ignoring cropping information.\n");
h->sps.crop_bottom =
h->sps.crop_top =
h->sps.crop_right =
h->sps.crop_left =
h->sps.crop = 0;
width = h->width;
height = h->height;
}
h->avctx->coded_width = h->width;
h->avctx->coded_height = h->height;
h->avctx->width = width;
h->avctx->height = height;
return 0;
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static int init_dimensions(H264Context *h)
{
int width = h->width - (h->sps.crop_right + h->sps.crop_left);
int height = h->height - (h->sps.crop_top + h->sps.crop_bottom);
if (FFALIGN(h->avctx->width, 16) == FFALIGN(width, 16) &&
FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16)) {
width = h->avctx->width;
height = h->avctx->height;
}
if (width <= 0 || height <= 0) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid cropped dimensions: %dx%d.\n",
width, height);
if (h->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
av_log(h->avctx, AV_LOG_WARNING, "Ignoring cropping information.\n");
h->sps.crop_bottom =
h->sps.crop_top =
h->sps.crop_right =
h->sps.crop_left =
h->sps.crop = 0;
width = h->width;
height = h->height;
}
h->avctx->coded_width = h->width;
h->avctx->coded_height = h->height;
h->avctx->width = width;
h->avctx->height = height;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0)
{
int VAR_1 = VAR_0->VAR_1 - (VAR_0->sps.crop_right + VAR_0->sps.crop_left);
int VAR_2 = VAR_0->VAR_2 - (VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);
if (FFALIGN(VAR_0->avctx->VAR_1, 16) == FFALIGN(VAR_1, 16) &&
FFALIGN(VAR_0->avctx->VAR_2, 16) == FFALIGN(VAR_2, 16)) {
VAR_1 = VAR_0->avctx->VAR_1;
VAR_2 = VAR_0->avctx->VAR_2;
}
if (VAR_1 <= 0 || VAR_2 <= 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid cropped dimensions: %dx%d.\n",
VAR_1, VAR_2);
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
av_log(VAR_0->avctx, AV_LOG_WARNING, "Ignoring cropping information.\n");
VAR_0->sps.crop_bottom =
VAR_0->sps.crop_top =
VAR_0->sps.crop_right =
VAR_0->sps.crop_left =
VAR_0->sps.crop = 0;
VAR_1 = VAR_0->VAR_1;
VAR_2 = VAR_0->VAR_2;
}
VAR_0->avctx->coded_width = VAR_0->VAR_1;
VAR_0->avctx->coded_height = VAR_0->VAR_2;
VAR_0->avctx->VAR_1 = VAR_1;
VAR_0->avctx->VAR_2 = VAR_2;
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0)\n{",
"int VAR_1 = VAR_0->VAR_1 - (VAR_0->sps.crop_right + VAR_0->sps.crop_left);",
"int VAR_2 = VAR_0->VAR_2 - (VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);",
"if (FFALIGN(VAR_0->avctx->VAR_1, 16) == FFALIGN(VAR_1, 16) &&\nFFALIGN(VAR_0->avctx->VAR_2, 16) == FFALIGN(VAR_2, 16)) {",
"VAR_1 = VAR_0->avctx->VAR_1;",
"VAR_2 = VAR_0->avctx->VAR_2;",
"}",
"if (VAR_1 <= 0 || VAR_2 <= 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid cropped dimensions: %dx%d.\\n\",\nVAR_1, VAR_2);",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Ignoring cropping information.\\n\");",
"VAR_0->sps.crop_bottom =\nVAR_0->sps.crop_top =\nVAR_0->sps.crop_right =\nVAR_0->sps.crop_left =\nVAR_0->sps.crop = 0;",
"VAR_1 = VAR_0->VAR_1;",
"VAR_2 = VAR_0->VAR_2;",
"}",
"VAR_0->avctx->coded_width = VAR_0->VAR_1;",
"VAR_0->avctx->coded_height = VAR_0->VAR_2;",
"VAR_0->avctx->VAR_1 = VAR_1;",
"VAR_0->avctx->VAR_2 = VAR_2;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
37
],
[
39,
41,
43,
45,
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
]
] |
4,809 | static inline CopyRet copy_frame(AVCodecContext *avctx,
BC_DTS_PROC_OUT *output,
void *data, int *data_size,
uint8_t second_field)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
uint8_t is_paff;
uint8_t next_frame_same;
uint8_t interlaced;
CHDContext *priv = avctx->priv_data;
int64_t pkt_pts = AV_NOPTS_VALUE;
uint8_t pic_type = 0;
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
VDEC_FLAG_BOTTOMFIELD;
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
int width = output->PicInfo.width;
int height = output->PicInfo.height;
int bwidth;
uint8_t *src = output->Ybuff;
int sStride;
uint8_t *dst;
int dStride;
if (output->PicInfo.timeStamp != 0) {
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
if (node) {
pkt_pts = node->reordered_opaque;
pic_type = node->pic_type;
av_free(node);
} else {
/*
* We will encounter a situation where a timestamp cannot be
* popped if a second field is being returned. In this case,
* each field has the same timestamp and the first one will
* cause it to be popped. To keep subsequent calculations
* simple, pic_type should be set a FIELD value - doesn't
* matter which, but I chose BOTTOM.
*/
pic_type = PICT_BOTTOM_FIELD;
}
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
output->PicInfo.timeStamp);
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
pic_type);
}
ret = DtsGetDriverStatus(priv->dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: GetDriverStatus failed: %u\n", ret);
return RET_ERROR;
}
is_paff = ASSUME_PAFF_OVER_MBAFF ||
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC);
next_frame_same = output->PicInfo.picture_number ==
(decoder_status.picNumFlags & ~0x40000000);
interlaced = ((output->PicInfo.flags &
VDEC_FLAG_INTERLACED_SRC) && is_paff) ||
next_frame_same || bottom_field || second_field;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: next_frame_same: %u | %u | %u\n",
next_frame_same, output->PicInfo.picture_number,
decoder_status.picNumFlags & ~0x40000000);
if (priv->pic.data[0] && !priv->need_second_field)
avctx->release_buffer(avctx, &priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE;
if (!priv->pic.data[0]) {
if (avctx->get_buffer(avctx, &priv->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return RET_ERROR;
}
}
bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0);
if (priv->is_70012) {
int pStride;
if (width <= 720)
pStride = 720;
else if (width <= 1280)
pStride = 1280;
else if (width <= 1080)
pStride = 1080;
sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0);
} else {
sStride = bwidth;
}
dStride = priv->pic.linesize[0];
dst = priv->pic.data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
if (interlaced) {
int dY = 0;
int sY = 0;
height /= 2;
if (bottom_field) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
dY = 1;
} else {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
dY = 0;
}
for (sY = 0; sY < height; dY++, sY++) {
memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth);
dY++;
}
} else {
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
priv->pic.interlaced_frame = interlaced;
if (interlaced)
priv->pic.top_field_first = !bottom_first;
priv->pic.pkt_pts = pkt_pts;
if (!priv->need_second_field) {
*data_size = sizeof(AVFrame);
*(AVFrame *)data = priv->pic;
}
if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&
output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
return RET_SKIP_NEXT_COPY;
}
/*
* Testing has shown that in all cases where we don't want to return the
* full frame immediately, VDEC_FLAG_UNKNOWN_SRC is set.
*/
return priv->need_second_field &&
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ?
RET_COPY_NEXT_FIELD : RET_OK;
}
| true | FFmpeg | ae7a4a1594e3624f7c844dec44266d2dc74a6be2 | static inline CopyRet copy_frame(AVCodecContext *avctx,
BC_DTS_PROC_OUT *output,
void *data, int *data_size,
uint8_t second_field)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
uint8_t is_paff;
uint8_t next_frame_same;
uint8_t interlaced;
CHDContext *priv = avctx->priv_data;
int64_t pkt_pts = AV_NOPTS_VALUE;
uint8_t pic_type = 0;
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
VDEC_FLAG_BOTTOMFIELD;
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
int width = output->PicInfo.width;
int height = output->PicInfo.height;
int bwidth;
uint8_t *src = output->Ybuff;
int sStride;
uint8_t *dst;
int dStride;
if (output->PicInfo.timeStamp != 0) {
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
if (node) {
pkt_pts = node->reordered_opaque;
pic_type = node->pic_type;
av_free(node);
} else {
pic_type = PICT_BOTTOM_FIELD;
}
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
output->PicInfo.timeStamp);
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
pic_type);
}
ret = DtsGetDriverStatus(priv->dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: GetDriverStatus failed: %u\n", ret);
return RET_ERROR;
}
is_paff = ASSUME_PAFF_OVER_MBAFF ||
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC);
next_frame_same = output->PicInfo.picture_number ==
(decoder_status.picNumFlags & ~0x40000000);
interlaced = ((output->PicInfo.flags &
VDEC_FLAG_INTERLACED_SRC) && is_paff) ||
next_frame_same || bottom_field || second_field;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: next_frame_same: %u | %u | %u\n",
next_frame_same, output->PicInfo.picture_number,
decoder_status.picNumFlags & ~0x40000000);
if (priv->pic.data[0] && !priv->need_second_field)
avctx->release_buffer(avctx, &priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE;
if (!priv->pic.data[0]) {
if (avctx->get_buffer(avctx, &priv->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return RET_ERROR;
}
}
bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0);
if (priv->is_70012) {
int pStride;
if (width <= 720)
pStride = 720;
else if (width <= 1280)
pStride = 1280;
else if (width <= 1080)
pStride = 1080;
sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0);
} else {
sStride = bwidth;
}
dStride = priv->pic.linesize[0];
dst = priv->pic.data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
if (interlaced) {
int dY = 0;
int sY = 0;
height /= 2;
if (bottom_field) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
dY = 1;
} else {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
dY = 0;
}
for (sY = 0; sY < height; dY++, sY++) {
memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth);
dY++;
}
} else {
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
priv->pic.interlaced_frame = interlaced;
if (interlaced)
priv->pic.top_field_first = !bottom_first;
priv->pic.pkt_pts = pkt_pts;
if (!priv->need_second_field) {
*data_size = sizeof(AVFrame);
*(AVFrame *)data = priv->pic;
}
if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&
output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
return RET_SKIP_NEXT_COPY;
}
return priv->need_second_field &&
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ?
RET_COPY_NEXT_FIELD : RET_OK;
}
| {
"code": [
" void *data, int *data_size,",
" uint8_t second_field)",
" uint8_t is_paff;",
" uint8_t next_frame_same;",
" is_paff = ASSUME_PAFF_OVER_MBAFF ||",
" !(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC);",
" next_frame_same = output->PicInfo.picture_number ==",
" (decoder_status.picNumFlags & ~0x40000000);",
" interlaced = ((output->PicInfo.flags &",
" VDEC_FLAG_INTERLACED_SRC) && is_paff) ||",
" next_frame_same || bottom_field || second_field;",
" av_log(avctx, AV_LOG_VERBOSE, \"CrystalHD: next_frame_same: %u | %u | %u\\n\",",
" next_frame_same, output->PicInfo.picture_number,",
" decoder_status.picNumFlags & ~0x40000000);",
" if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&",
" output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) {"
],
"line_no": [
5,
7,
15,
17,
115,
117,
119,
121,
123,
125,
127,
131,
133,
135,
271,
273
]
} | static inline CopyRet FUNC_0(AVCodecContext *avctx,
BC_DTS_PROC_OUT *output,
void *data, int *data_size,
uint8_t second_field)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
uint8_t is_paff;
uint8_t next_frame_same;
uint8_t interlaced;
CHDContext *priv = avctx->priv_data;
int64_t pkt_pts = AV_NOPTS_VALUE;
uint8_t pic_type = 0;
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
VDEC_FLAG_BOTTOMFIELD;
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
int VAR_0 = output->PicInfo.VAR_0;
int VAR_1 = output->PicInfo.VAR_1;
int VAR_2;
uint8_t *src = output->Ybuff;
int VAR_3;
uint8_t *dst;
int VAR_4;
if (output->PicInfo.timeStamp != 0) {
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
if (node) {
pkt_pts = node->reordered_opaque;
pic_type = node->pic_type;
av_free(node);
} else {
pic_type = PICT_BOTTOM_FIELD;
}
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
output->PicInfo.timeStamp);
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
pic_type);
}
ret = DtsGetDriverStatus(priv->dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: GetDriverStatus failed: %u\n", ret);
return RET_ERROR;
}
is_paff = ASSUME_PAFF_OVER_MBAFF ||
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC);
next_frame_same = output->PicInfo.picture_number ==
(decoder_status.picNumFlags & ~0x40000000);
interlaced = ((output->PicInfo.flags &
VDEC_FLAG_INTERLACED_SRC) && is_paff) ||
next_frame_same || bottom_field || second_field;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: next_frame_same: %u | %u | %u\n",
next_frame_same, output->PicInfo.picture_number,
decoder_status.picNumFlags & ~0x40000000);
if (priv->pic.data[0] && !priv->need_second_field)
avctx->release_buffer(avctx, &priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE;
if (!priv->pic.data[0]) {
if (avctx->get_buffer(avctx, &priv->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return RET_ERROR;
}
}
VAR_2 = av_image_get_linesize(avctx->pix_fmt, VAR_0, 0);
if (priv->is_70012) {
int VAR_5;
if (VAR_0 <= 720)
VAR_5 = 720;
else if (VAR_0 <= 1280)
VAR_5 = 1280;
else if (VAR_0 <= 1080)
VAR_5 = 1080;
VAR_3 = av_image_get_linesize(avctx->pix_fmt, VAR_5, 0);
} else {
VAR_3 = VAR_2;
}
VAR_4 = priv->pic.linesize[0];
dst = priv->pic.data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
if (interlaced) {
int VAR_6 = 0;
int VAR_7 = 0;
VAR_1 /= 2;
if (bottom_field) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
VAR_6 = 1;
} else {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
VAR_6 = 0;
}
for (VAR_7 = 0; VAR_7 < VAR_1; VAR_6++, VAR_7++) {
memcpy(&(dst[VAR_6 * VAR_4]), &(src[VAR_7 * VAR_3]), VAR_2);
VAR_6++;
}
} else {
av_image_copy_plane(dst, VAR_4, src, VAR_3, VAR_2, VAR_1);
}
priv->pic.interlaced_frame = interlaced;
if (interlaced)
priv->pic.top_field_first = !bottom_first;
priv->pic.pkt_pts = pkt_pts;
if (!priv->need_second_field) {
*data_size = sizeof(AVFrame);
*(AVFrame *)data = priv->pic;
}
if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&
output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
return RET_SKIP_NEXT_COPY;
}
return priv->need_second_field &&
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ?
RET_COPY_NEXT_FIELD : RET_OK;
}
| [
"static inline CopyRet FUNC_0(AVCodecContext *avctx,\nBC_DTS_PROC_OUT *output,\nvoid *data, int *data_size,\nuint8_t second_field)\n{",
"BC_STATUS ret;",
"BC_DTS_STATUS decoder_status;",
"uint8_t is_paff;",
"uint8_t next_frame_same;",
"uint8_t interlaced;",
"CHDContext *priv = avctx->priv_data;",
"int64_t pkt_pts = AV_NOPTS_VALUE;",
"uint8_t pic_type = 0;",
"uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==\nVDEC_FLAG_BOTTOMFIELD;",
"uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);",
"int VAR_0 = output->PicInfo.VAR_0;",
"int VAR_1 = output->PicInfo.VAR_1;",
"int VAR_2;",
"uint8_t *src = output->Ybuff;",
"int VAR_3;",
"uint8_t *dst;",
"int VAR_4;",
"if (output->PicInfo.timeStamp != 0) {",
"OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);",
"if (node) {",
"pkt_pts = node->reordered_opaque;",
"pic_type = node->pic_type;",
"av_free(node);",
"} else {",
"pic_type = PICT_BOTTOM_FIELD;",
"}",
"av_log(avctx, AV_LOG_VERBOSE, \"output \\\"pts\\\": %\"PRIu64\"\\n\",\noutput->PicInfo.timeStamp);",
"av_log(avctx, AV_LOG_VERBOSE, \"output picture type %d\\n\",\npic_type);",
"}",
"ret = DtsGetDriverStatus(priv->dev, &decoder_status);",
"if (ret != BC_STS_SUCCESS) {",
"av_log(avctx, AV_LOG_ERROR,\n\"CrystalHD: GetDriverStatus failed: %u\\n\", ret);",
"return RET_ERROR;",
"}",
"is_paff = ASSUME_PAFF_OVER_MBAFF ||\n!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC);",
"next_frame_same = output->PicInfo.picture_number ==\n(decoder_status.picNumFlags & ~0x40000000);",
"interlaced = ((output->PicInfo.flags &\nVDEC_FLAG_INTERLACED_SRC) && is_paff) ||\nnext_frame_same || bottom_field || second_field;",
"av_log(avctx, AV_LOG_VERBOSE, \"CrystalHD: next_frame_same: %u | %u | %u\\n\",\nnext_frame_same, output->PicInfo.picture_number,\ndecoder_status.picNumFlags & ~0x40000000);",
"if (priv->pic.data[0] && !priv->need_second_field)\navctx->release_buffer(avctx, &priv->pic);",
"priv->need_second_field = interlaced && !priv->need_second_field;",
"priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |\nFF_BUFFER_HINTS_REUSABLE;",
"if (!priv->pic.data[0]) {",
"if (avctx->get_buffer(avctx, &priv->pic) < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return RET_ERROR;",
"}",
"}",
"VAR_2 = av_image_get_linesize(avctx->pix_fmt, VAR_0, 0);",
"if (priv->is_70012) {",
"int VAR_5;",
"if (VAR_0 <= 720)\nVAR_5 = 720;",
"else if (VAR_0 <= 1280)\nVAR_5 = 1280;",
"else if (VAR_0 <= 1080)\nVAR_5 = 1080;",
"VAR_3 = av_image_get_linesize(avctx->pix_fmt, VAR_5, 0);",
"} else {",
"VAR_3 = VAR_2;",
"}",
"VAR_4 = priv->pic.linesize[0];",
"dst = priv->pic.data[0];",
"av_log(priv->avctx, AV_LOG_VERBOSE, \"CrystalHD: Copying out frame\\n\");",
"if (interlaced) {",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"VAR_1 /= 2;",
"if (bottom_field) {",
"av_log(priv->avctx, AV_LOG_VERBOSE, \"Interlaced: bottom field\\n\");",
"VAR_6 = 1;",
"} else {",
"av_log(priv->avctx, AV_LOG_VERBOSE, \"Interlaced: top field\\n\");",
"VAR_6 = 0;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_1; VAR_6++, VAR_7++) {",
"memcpy(&(dst[VAR_6 * VAR_4]), &(src[VAR_7 * VAR_3]), VAR_2);",
"VAR_6++;",
"}",
"} else {",
"av_image_copy_plane(dst, VAR_4, src, VAR_3, VAR_2, VAR_1);",
"}",
"priv->pic.interlaced_frame = interlaced;",
"if (interlaced)\npriv->pic.top_field_first = !bottom_first;",
"priv->pic.pkt_pts = pkt_pts;",
"if (!priv->need_second_field) {",
"*data_size = sizeof(AVFrame);",
"*(AVFrame *)data = priv->pic;",
"}",
"if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&\noutput->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) {",
"av_log(priv->avctx, AV_LOG_VERBOSE, \"Fieldpair from two packets.\\n\");",
"return RET_SKIP_NEXT_COPY;",
"}",
"return priv->need_second_field &&\n!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ?\nRET_COPY_NEXT_FIELD : RET_OK;",
"}"
] | [
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
115,
117
],
[
119,
121
],
[
123,
125,
127
],
[
131,
133,
135
],
[
139,
141
],
[
145
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251,
253
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271,
273
],
[
275
],
[
277
],
[
279
],
[
291,
293,
295
],
[
297
]
] |
4,810 | static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
{
X11GrabContext *s = s1->priv_data;
Display *dpy = s->dpy;
XImage *image = s->image;
int x_off = s->x_off;
int y_off = s->y_off;
int follow_mouse = s->follow_mouse;
int screen;
Window root;
int64_t curtime, delay;
struct timespec ts;
/* Calculate the time of the next frame */
s->time_frame += INT64_C(1000000);
/* wait based on the frame rate */
for (;;) {
curtime = av_gettime();
delay = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
s->time_frame += INT64_C(1000000);
break;
}
ts.tv_sec = delay / 1000000;
ts.tv_nsec = (delay % 1000000) * 1000;
nanosleep(&ts, NULL);
}
av_init_packet(pkt);
pkt->data = image->data;
pkt->size = s->frame_size;
pkt->pts = curtime;
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
if (follow_mouse) {
int screen_w, screen_h;
int pointer_x, pointer_y, _;
Window w;
screen_w = DisplayWidth(dpy, screen);
screen_h = DisplayHeight(dpy, screen);
XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
if (follow_mouse == -1) {
// follow the mouse, put it at center of grabbing region
x_off += pointer_x - s->width / 2 - x_off;
y_off += pointer_y - s->height / 2 - y_off;
} else {
// follow the mouse, but only move the grabbing region when mouse
// reaches within certain pixels to the edge.
if (pointer_x > x_off + s->width - follow_mouse)
x_off += pointer_x - (x_off + s->width - follow_mouse);
else if (pointer_x < x_off + follow_mouse)
x_off -= (x_off + follow_mouse) - pointer_x;
if (pointer_y > y_off + s->height - follow_mouse)
y_off += pointer_y - (y_off + s->height - follow_mouse);
else if (pointer_y < y_off + follow_mouse)
y_off -= (y_off + follow_mouse) - pointer_y;
}
// adjust grabbing region position if it goes out of screen.
s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
if (s->show_region && s->region_win)
XMoveWindow(dpy, s->region_win,
s->x_off - REGION_WIN_BORDER,
s->y_off - REGION_WIN_BORDER);
}
if (s->show_region) {
if (s->region_win) {
XEvent evt = { .type = NoEventMask };
// Clean up the events, and do the initial draw or redraw.
while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,
&evt))
;
if (evt.type)
x11grab_draw_region_win(s);
} else {
x11grab_region_win_init(s);
}
}
if (s->use_shm) {
if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes))
av_log(s1, AV_LOG_INFO, "XShmGetImage() failed\n");
} else {
if (!xget_zpixmap(dpy, root, image, x_off, y_off))
av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
}
if (s->draw_mouse)
paint_mouse_pointer(image, s);
return s->frame_size;
}
| false | FFmpeg | 2a5ac99e6e06078713f684fee2466c91f677b303 | static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
{
X11GrabContext *s = s1->priv_data;
Display *dpy = s->dpy;
XImage *image = s->image;
int x_off = s->x_off;
int y_off = s->y_off;
int follow_mouse = s->follow_mouse;
int screen;
Window root;
int64_t curtime, delay;
struct timespec ts;
s->time_frame += INT64_C(1000000);
for (;;) {
curtime = av_gettime();
delay = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
s->time_frame += INT64_C(1000000);
break;
}
ts.tv_sec = delay / 1000000;
ts.tv_nsec = (delay % 1000000) * 1000;
nanosleep(&ts, NULL);
}
av_init_packet(pkt);
pkt->data = image->data;
pkt->size = s->frame_size;
pkt->pts = curtime;
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
if (follow_mouse) {
int screen_w, screen_h;
int pointer_x, pointer_y, _;
Window w;
screen_w = DisplayWidth(dpy, screen);
screen_h = DisplayHeight(dpy, screen);
XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
if (follow_mouse == -1) {
x_off += pointer_x - s->width / 2 - x_off;
y_off += pointer_y - s->height / 2 - y_off;
} else {
if (pointer_x > x_off + s->width - follow_mouse)
x_off += pointer_x - (x_off + s->width - follow_mouse);
else if (pointer_x < x_off + follow_mouse)
x_off -= (x_off + follow_mouse) - pointer_x;
if (pointer_y > y_off + s->height - follow_mouse)
y_off += pointer_y - (y_off + s->height - follow_mouse);
else if (pointer_y < y_off + follow_mouse)
y_off -= (y_off + follow_mouse) - pointer_y;
}
s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
if (s->show_region && s->region_win)
XMoveWindow(dpy, s->region_win,
s->x_off - REGION_WIN_BORDER,
s->y_off - REGION_WIN_BORDER);
}
if (s->show_region) {
if (s->region_win) {
XEvent evt = { .type = NoEventMask };
while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,
&evt))
;
if (evt.type)
x11grab_draw_region_win(s);
} else {
x11grab_region_win_init(s);
}
}
if (s->use_shm) {
if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes))
av_log(s1, AV_LOG_INFO, "XShmGetImage() failed\n");
} else {
if (!xget_zpixmap(dpy, root, image, x_off, y_off))
av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
}
if (s->draw_mouse)
paint_mouse_pointer(image, s);
return s->frame_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
X11GrabContext *s = VAR_0->priv_data;
Display *dpy = s->dpy;
XImage *image = s->image;
int VAR_2 = s->VAR_2;
int VAR_3 = s->VAR_3;
int VAR_4 = s->VAR_4;
int VAR_5;
Window root;
int64_t curtime, delay;
struct timespec VAR_6;
s->time_frame += INT64_C(1000000);
for (;;) {
curtime = av_gettime();
delay = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
s->time_frame += INT64_C(1000000);
break;
}
VAR_6.tv_sec = delay / 1000000;
VAR_6.tv_nsec = (delay % 1000000) * 1000;
nanosleep(&VAR_6, NULL);
}
av_init_packet(VAR_1);
VAR_1->data = image->data;
VAR_1->size = s->frame_size;
VAR_1->pts = curtime;
VAR_5 = DefaultScreen(dpy);
root = RootWindow(dpy, VAR_5);
if (VAR_4) {
int VAR_7, VAR_8;
int VAR_9, VAR_10, VAR_11;
Window w;
VAR_7 = DisplayWidth(dpy, VAR_5);
VAR_8 = DisplayHeight(dpy, VAR_5);
XQueryPointer(dpy, root, &w, &w, &VAR_9, &VAR_10, &VAR_11, &VAR_11, &VAR_11);
if (VAR_4 == -1) {
VAR_2 += VAR_9 - s->width / 2 - VAR_2;
VAR_3 += VAR_10 - s->height / 2 - VAR_3;
} else {
if (VAR_9 > VAR_2 + s->width - VAR_4)
VAR_2 += VAR_9 - (VAR_2 + s->width - VAR_4);
else if (VAR_9 < VAR_2 + VAR_4)
VAR_2 -= (VAR_2 + VAR_4) - VAR_9;
if (VAR_10 > VAR_3 + s->height - VAR_4)
VAR_3 += VAR_10 - (VAR_3 + s->height - VAR_4);
else if (VAR_10 < VAR_3 + VAR_4)
VAR_3 -= (VAR_3 + VAR_4) - VAR_10;
}
s->VAR_2 = VAR_2 = FFMIN(FFMAX(VAR_2, 0), VAR_7 - s->width);
s->VAR_3 = VAR_3 = FFMIN(FFMAX(VAR_3, 0), VAR_8 - s->height);
if (s->show_region && s->region_win)
XMoveWindow(dpy, s->region_win,
s->VAR_2 - REGION_WIN_BORDER,
s->VAR_3 - REGION_WIN_BORDER);
}
if (s->show_region) {
if (s->region_win) {
XEvent evt = { .type = NoEventMask };
while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,
&evt))
;
if (evt.type)
x11grab_draw_region_win(s);
} else {
x11grab_region_win_init(s);
}
}
if (s->use_shm) {
if (!XShmGetImage(dpy, root, image, VAR_2, VAR_3, AllPlanes))
av_log(VAR_0, AV_LOG_INFO, "XShmGetImage() failed\n");
} else {
if (!xget_zpixmap(dpy, root, image, VAR_2, VAR_3))
av_log(VAR_0, AV_LOG_INFO, "XGetZPixmap() failed\n");
}
if (s->draw_mouse)
paint_mouse_pointer(image, s);
return s->frame_size;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"X11GrabContext *s = VAR_0->priv_data;",
"Display *dpy = s->dpy;",
"XImage *image = s->image;",
"int VAR_2 = s->VAR_2;",
"int VAR_3 = s->VAR_3;",
"int VAR_4 = s->VAR_4;",
"int VAR_5;",
"Window root;",
"int64_t curtime, delay;",
"struct timespec VAR_6;",
"s->time_frame += INT64_C(1000000);",
"for (;;) {",
"curtime = av_gettime();",
"delay = s->time_frame * av_q2d(s->time_base) - curtime;",
"if (delay <= 0) {",
"if (delay < INT64_C(-1000000) * av_q2d(s->time_base))\ns->time_frame += INT64_C(1000000);",
"break;",
"}",
"VAR_6.tv_sec = delay / 1000000;",
"VAR_6.tv_nsec = (delay % 1000000) * 1000;",
"nanosleep(&VAR_6, NULL);",
"}",
"av_init_packet(VAR_1);",
"VAR_1->data = image->data;",
"VAR_1->size = s->frame_size;",
"VAR_1->pts = curtime;",
"VAR_5 = DefaultScreen(dpy);",
"root = RootWindow(dpy, VAR_5);",
"if (VAR_4) {",
"int VAR_7, VAR_8;",
"int VAR_9, VAR_10, VAR_11;",
"Window w;",
"VAR_7 = DisplayWidth(dpy, VAR_5);",
"VAR_8 = DisplayHeight(dpy, VAR_5);",
"XQueryPointer(dpy, root, &w, &w, &VAR_9, &VAR_10, &VAR_11, &VAR_11, &VAR_11);",
"if (VAR_4 == -1) {",
"VAR_2 += VAR_9 - s->width / 2 - VAR_2;",
"VAR_3 += VAR_10 - s->height / 2 - VAR_3;",
"} else {",
"if (VAR_9 > VAR_2 + s->width - VAR_4)\nVAR_2 += VAR_9 - (VAR_2 + s->width - VAR_4);",
"else if (VAR_9 < VAR_2 + VAR_4)\nVAR_2 -= (VAR_2 + VAR_4) - VAR_9;",
"if (VAR_10 > VAR_3 + s->height - VAR_4)\nVAR_3 += VAR_10 - (VAR_3 + s->height - VAR_4);",
"else if (VAR_10 < VAR_3 + VAR_4)\nVAR_3 -= (VAR_3 + VAR_4) - VAR_10;",
"}",
"s->VAR_2 = VAR_2 = FFMIN(FFMAX(VAR_2, 0), VAR_7 - s->width);",
"s->VAR_3 = VAR_3 = FFMIN(FFMAX(VAR_3, 0), VAR_8 - s->height);",
"if (s->show_region && s->region_win)\nXMoveWindow(dpy, s->region_win,\ns->VAR_2 - REGION_WIN_BORDER,\ns->VAR_3 - REGION_WIN_BORDER);",
"}",
"if (s->show_region) {",
"if (s->region_win) {",
"XEvent evt = { .type = NoEventMask };",
"while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,\n&evt))\n;",
"if (evt.type)\nx11grab_draw_region_win(s);",
"} else {",
"x11grab_region_win_init(s);",
"}",
"}",
"if (s->use_shm) {",
"if (!XShmGetImage(dpy, root, image, VAR_2, VAR_3, AllPlanes))\nav_log(VAR_0, AV_LOG_INFO, \"XShmGetImage() failed\\n\");",
"} else {",
"if (!xget_zpixmap(dpy, root, image, VAR_2, VAR_3))\nav_log(VAR_0, AV_LOG_INFO, \"XGetZPixmap() failed\\n\");",
"}",
"if (s->draw_mouse)\npaint_mouse_pointer(image, s);",
"return s->frame_size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
131,
133,
135,
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
151,
153,
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173,
175
],
[
177
],
[
179,
181
],
[
183
],
[
187,
189
],
[
193
],
[
195
]
] |
4,811 | void usb_ep_combine_input_packets(USBEndpoint *ep)
{
USBPacket *p, *u, *next, *prev = NULL, *first = NULL;
USBPort *port = ep->dev->port;
int ret;
assert(ep->pipeline);
assert(ep->pid == USB_TOKEN_IN);
QTAILQ_FOREACH_SAFE(p, &ep->queue, queue, next) {
/* Empty the queue on a halt */
if (ep->halted) {
p->result = USB_RET_REMOVE_FROM_QUEUE;
port->ops->complete(port, p);
continue;
}
/* Skip packets already submitted to the device */
if (p->state == USB_PACKET_ASYNC) {
prev = p;
continue;
}
usb_packet_check_state(p, USB_PACKET_QUEUED);
/*
* If the previous (combined) packet has the short_not_ok flag set
* stop, as we must not submit packets to the device after a transfer
* ending with short_not_ok packet.
*/
if (prev && prev->short_not_ok) {
break;
}
if (first) {
if (first->combined == NULL) {
USBCombinedPacket *combined = g_new0(USBCombinedPacket, 1);
combined->first = first;
QTAILQ_INIT(&combined->packets);
qemu_iovec_init(&combined->iov, 2);
usb_combined_packet_add(combined, first);
}
usb_combined_packet_add(first->combined, p);
} else {
first = p;
}
/* Is this packet the last one of a (combined) transfer? */
if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
next == NULL) {
ret = usb_device_handle_data(ep->dev, first);
assert(ret == USB_RET_ASYNC);
if (first->combined) {
QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) {
usb_packet_set_state(u, USB_PACKET_ASYNC);
}
} else {
usb_packet_set_state(first, USB_PACKET_ASYNC);
}
first = NULL;
prev = p;
}
}
}
| true | qemu | 579967bea69bf1b32faee13ff76b19ba641a2618 | void usb_ep_combine_input_packets(USBEndpoint *ep)
{
USBPacket *p, *u, *next, *prev = NULL, *first = NULL;
USBPort *port = ep->dev->port;
int ret;
assert(ep->pipeline);
assert(ep->pid == USB_TOKEN_IN);
QTAILQ_FOREACH_SAFE(p, &ep->queue, queue, next) {
if (ep->halted) {
p->result = USB_RET_REMOVE_FROM_QUEUE;
port->ops->complete(port, p);
continue;
}
if (p->state == USB_PACKET_ASYNC) {
prev = p;
continue;
}
usb_packet_check_state(p, USB_PACKET_QUEUED);
if (prev && prev->short_not_ok) {
break;
}
if (first) {
if (first->combined == NULL) {
USBCombinedPacket *combined = g_new0(USBCombinedPacket, 1);
combined->first = first;
QTAILQ_INIT(&combined->packets);
qemu_iovec_init(&combined->iov, 2);
usb_combined_packet_add(combined, first);
}
usb_combined_packet_add(first->combined, p);
} else {
first = p;
}
if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
next == NULL) {
ret = usb_device_handle_data(ep->dev, first);
assert(ret == USB_RET_ASYNC);
if (first->combined) {
QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) {
usb_packet_set_state(u, USB_PACKET_ASYNC);
}
} else {
usb_packet_set_state(first, USB_PACKET_ASYNC);
}
first = NULL;
prev = p;
}
}
}
| {
"code": [
" int ret;",
" next == NULL) {"
],
"line_no": [
9,
99
]
} | void FUNC_0(USBEndpoint *VAR_0)
{
USBPacket *p, *u, *next, *prev = NULL, *first = NULL;
USBPort *port = VAR_0->dev->port;
int VAR_1;
assert(VAR_0->pipeline);
assert(VAR_0->pid == USB_TOKEN_IN);
QTAILQ_FOREACH_SAFE(p, &VAR_0->queue, queue, next) {
if (VAR_0->halted) {
p->result = USB_RET_REMOVE_FROM_QUEUE;
port->ops->complete(port, p);
continue;
}
if (p->state == USB_PACKET_ASYNC) {
prev = p;
continue;
}
usb_packet_check_state(p, USB_PACKET_QUEUED);
if (prev && prev->short_not_ok) {
break;
}
if (first) {
if (first->combined == NULL) {
USBCombinedPacket *combined = g_new0(USBCombinedPacket, 1);
combined->first = first;
QTAILQ_INIT(&combined->packets);
qemu_iovec_init(&combined->iov, 2);
usb_combined_packet_add(combined, first);
}
usb_combined_packet_add(first->combined, p);
} else {
first = p;
}
if ((p->iov.size % VAR_0->max_packet_size) != 0 || !p->short_not_ok ||
next == NULL) {
VAR_1 = usb_device_handle_data(VAR_0->dev, first);
assert(VAR_1 == USB_RET_ASYNC);
if (first->combined) {
QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) {
usb_packet_set_state(u, USB_PACKET_ASYNC);
}
} else {
usb_packet_set_state(first, USB_PACKET_ASYNC);
}
first = NULL;
prev = p;
}
}
}
| [
"void FUNC_0(USBEndpoint *VAR_0)\n{",
"USBPacket *p, *u, *next, *prev = NULL, *first = NULL;",
"USBPort *port = VAR_0->dev->port;",
"int VAR_1;",
"assert(VAR_0->pipeline);",
"assert(VAR_0->pid == USB_TOKEN_IN);",
"QTAILQ_FOREACH_SAFE(p, &VAR_0->queue, queue, next) {",
"if (VAR_0->halted) {",
"p->result = USB_RET_REMOVE_FROM_QUEUE;",
"port->ops->complete(port, p);",
"continue;",
"}",
"if (p->state == USB_PACKET_ASYNC) {",
"prev = p;",
"continue;",
"}",
"usb_packet_check_state(p, USB_PACKET_QUEUED);",
"if (prev && prev->short_not_ok) {",
"break;",
"}",
"if (first) {",
"if (first->combined == NULL) {",
"USBCombinedPacket *combined = g_new0(USBCombinedPacket, 1);",
"combined->first = first;",
"QTAILQ_INIT(&combined->packets);",
"qemu_iovec_init(&combined->iov, 2);",
"usb_combined_packet_add(combined, first);",
"}",
"usb_combined_packet_add(first->combined, p);",
"} else {",
"first = p;",
"}",
"if ((p->iov.size % VAR_0->max_packet_size) != 0 || !p->short_not_ok ||\nnext == NULL) {",
"VAR_1 = usb_device_handle_data(VAR_0->dev, first);",
"assert(VAR_1 == USB_RET_ASYNC);",
"if (first->combined) {",
"QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) {",
"usb_packet_set_state(u, USB_PACKET_ASYNC);",
"}",
"} else {",
"usb_packet_set_state(first, USB_PACKET_ASYNC);",
"}",
"first = NULL;",
"prev = p;",
"}",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
]
] |
4,812 | static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d,
hwaddr addr,
bool resolve_subpage)
{
MemoryRegionSection *section = atomic_read(&d->mru_section);
subpage_t *subpage;
bool update;
if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] &&
section_covers_addr(section, addr)) {
update = false;
} else {
section = phys_page_find(d, addr);
update = true;
}
if (resolve_subpage && section->mr->subpage) {
subpage = container_of(section->mr, subpage_t, iomem);
section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];
}
if (update) {
atomic_set(&d->mru_section, section);
}
return section;
}
| true | qemu | 07c114bbf389c09c99fd451b0b0fddf88962f512 | static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d,
hwaddr addr,
bool resolve_subpage)
{
MemoryRegionSection *section = atomic_read(&d->mru_section);
subpage_t *subpage;
bool update;
if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] &&
section_covers_addr(section, addr)) {
update = false;
} else {
section = phys_page_find(d, addr);
update = true;
}
if (resolve_subpage && section->mr->subpage) {
subpage = container_of(section->mr, subpage_t, iomem);
section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];
}
if (update) {
atomic_set(&d->mru_section, section);
}
return section;
}
| {
"code": [
" bool update;",
" if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] &&",
" section_covers_addr(section, addr)) {",
" update = false;",
" } else {",
" update = true;",
" if (update) {",
" atomic_set(&d->mru_section, section);"
],
"line_no": [
13,
17,
19,
21,
23,
27,
39,
41
]
} | static MemoryRegionSection *FUNC_0(AddressSpaceDispatch *d,
hwaddr addr,
bool resolve_subpage)
{
MemoryRegionSection *section = atomic_read(&d->mru_section);
subpage_t *subpage;
bool update;
if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] &&
section_covers_addr(section, addr)) {
update = false;
} else {
section = phys_page_find(d, addr);
update = true;
}
if (resolve_subpage && section->mr->subpage) {
subpage = container_of(section->mr, subpage_t, iomem);
section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];
}
if (update) {
atomic_set(&d->mru_section, section);
}
return section;
}
| [
"static MemoryRegionSection *FUNC_0(AddressSpaceDispatch *d,\nhwaddr addr,\nbool resolve_subpage)\n{",
"MemoryRegionSection *section = atomic_read(&d->mru_section);",
"subpage_t *subpage;",
"bool update;",
"if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] &&\nsection_covers_addr(section, addr)) {",
"update = false;",
"} else {",
"section = phys_page_find(d, addr);",
"update = true;",
"}",
"if (resolve_subpage && section->mr->subpage) {",
"subpage = container_of(section->mr, subpage_t, iomem);",
"section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];",
"}",
"if (update) {",
"atomic_set(&d->mru_section, section);",
"}",
"return section;",
"}"
] | [
0,
0,
0,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
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
]
] |
4,813 | static int asf_read_generic_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,
int type, AVDictionary **met)
{
AVIOContext *pb = s->pb;
uint64_t value;
char buf[32];
switch (type) {
case ASF_BOOL:
value = avio_rl32(pb);
break;
case ASF_DWORD:
value = avio_rl32(pb);
break;
case ASF_QWORD:
value = avio_rl64(pb);
break;
case ASF_WORD:
value = avio_rl16(pb);
break;
default:
av_freep(&name);
return AVERROR_INVALIDDATA;
}
snprintf(buf, sizeof(buf), "%"PRIu64, value);
if (av_dict_set(met, name, buf, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
return 0;
}
| true | FFmpeg | fdbc544d29176ba69d67dd879df4696f0a19052e | static int asf_read_generic_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,
int type, AVDictionary **met)
{
AVIOContext *pb = s->pb;
uint64_t value;
char buf[32];
switch (type) {
case ASF_BOOL:
value = avio_rl32(pb);
break;
case ASF_DWORD:
value = avio_rl32(pb);
break;
case ASF_QWORD:
value = avio_rl64(pb);
break;
case ASF_WORD:
value = avio_rl16(pb);
break;
default:
av_freep(&name);
return AVERROR_INVALIDDATA;
}
snprintf(buf, sizeof(buf), "%"PRIu64, value);
if (av_dict_set(met, name, buf, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
return 0;
}
| {
"code": [
"static int asf_read_generic_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,",
" int type, AVDictionary **met)",
" av_freep(&name);"
],
"line_no": [
1,
3,
43
]
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, uint16_t VAR_2,
int VAR_3, AVDictionary **VAR_4)
{
AVIOContext *pb = VAR_0->pb;
uint64_t value;
char VAR_5[32];
switch (VAR_3) {
case ASF_BOOL:
value = avio_rl32(pb);
break;
case ASF_DWORD:
value = avio_rl32(pb);
break;
case ASF_QWORD:
value = avio_rl64(pb);
break;
case ASF_WORD:
value = avio_rl16(pb);
break;
default:
av_freep(&VAR_1);
return AVERROR_INVALIDDATA;
}
snprintf(VAR_5, sizeof(VAR_5), "%"PRIu64, value);
if (av_dict_set(VAR_4, VAR_1, VAR_5, 0) < 0)
av_log(VAR_0, AV_LOG_WARNING, "av_dict_set failed.\n");
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, uint16_t VAR_2,\nint VAR_3, AVDictionary **VAR_4)\n{",
"AVIOContext *pb = VAR_0->pb;",
"uint64_t value;",
"char VAR_5[32];",
"switch (VAR_3) {",
"case ASF_BOOL:\nvalue = avio_rl32(pb);",
"break;",
"case ASF_DWORD:\nvalue = avio_rl32(pb);",
"break;",
"case ASF_QWORD:\nvalue = avio_rl64(pb);",
"break;",
"case ASF_WORD:\nvalue = avio_rl16(pb);",
"break;",
"default:\nav_freep(&VAR_1);",
"return AVERROR_INVALIDDATA;",
"}",
"snprintf(VAR_5, sizeof(VAR_5), \"%\"PRIu64, value);",
"if (av_dict_set(VAR_4, VAR_1, VAR_5, 0) < 0)\nav_log(VAR_0, AV_LOG_WARNING, \"av_dict_set failed.\\n\");",
"return 0;",
"}"
] | [
1,
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
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
57
],
[
59
]
] |
4,814 | int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
QemuOpts *opts;
int res;
opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
if (!opts) {
return -1;
res = net_client_init(mon, opts, 1);
return res; | true | qemu | 410cbafebc7168a278a23c856b4f5ff276ef1c85 | int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
QemuOpts *opts;
int res;
opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
if (!opts) {
return -1;
res = net_client_init(mon, opts, 1);
return res; | {
"code": [],
"line_no": []
} | int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{
QemuOpts *opts;
int VAR_3;
opts = qemu_opts_from_qdict(&qemu_netdev_opts, VAR_1);
if (!opts) {
return -1;
VAR_3 = net_client_init(VAR_0, opts, 1);
return VAR_3; | [
"int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{",
"QemuOpts *opts;",
"int VAR_3;",
"opts = qemu_opts_from_qdict(&qemu_netdev_opts, VAR_1);",
"if (!opts) {",
"return -1;",
"VAR_3 = net_client_init(VAR_0, opts, 1);",
"return VAR_3;"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
]
] |
4,817 | static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
uint8_t *p)
{
int pages = -1;
if (is_zero_range(p, TARGET_PAGE_SIZE)) {
rs->zero_pages++;
rs->bytes_transferred +=
save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(rs->f, 0);
rs->bytes_transferred += 1;
pages = 1;
}
return pages;
}
| true | qemu | 2bf3aa85f08186b8162b76e7e8efe5b5a44306a6 | static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
uint8_t *p)
{
int pages = -1;
if (is_zero_range(p, TARGET_PAGE_SIZE)) {
rs->zero_pages++;
rs->bytes_transferred +=
save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(rs->f, 0);
rs->bytes_transferred += 1;
pages = 1;
}
return pages;
}
| {
"code": [
" save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS);"
],
"line_no": [
17
]
} | static int FUNC_0(RAMState *VAR_0, RAMBlock *VAR_1, ram_addr_t VAR_2,
uint8_t *VAR_3)
{
int VAR_4 = -1;
if (is_zero_range(VAR_3, TARGET_PAGE_SIZE)) {
VAR_0->zero_pages++;
VAR_0->bytes_transferred +=
save_page_header(VAR_0, VAR_1, VAR_2 | RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(VAR_0->f, 0);
VAR_0->bytes_transferred += 1;
VAR_4 = 1;
}
return VAR_4;
}
| [
"static int FUNC_0(RAMState *VAR_0, RAMBlock *VAR_1, ram_addr_t VAR_2,\nuint8_t *VAR_3)\n{",
"int VAR_4 = -1;",
"if (is_zero_range(VAR_3, TARGET_PAGE_SIZE)) {",
"VAR_0->zero_pages++;",
"VAR_0->bytes_transferred +=\nsave_page_header(VAR_0, VAR_1, VAR_2 | RAM_SAVE_FLAG_COMPRESS);",
"qemu_put_byte(VAR_0->f, 0);",
"VAR_0->bytes_transferred += 1;",
"VAR_4 = 1;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
4,819 | static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
{
MovieContext *movie = ctx->priv;
AVPacket *pkt = &movie->pkt;
enum AVMediaType frame_type;
MovieStream *st;
int ret, got_frame = 0, pkt_out_id;
AVFilterLink *outlink;
AVFrame *frame;
if (!pkt->size) {
if (movie->eof) {
if (movie->st[out_id].done) {
if (movie->loop_count != 1) {
ret = rewind_file(ctx);
if (ret < 0)
return ret;
movie->loop_count -= movie->loop_count > 1;
av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
return 0; /* retry */
}
return AVERROR_EOF;
}
pkt->stream_index = movie->st[out_id].st->index;
/* packet is already ready for flushing */
} else {
ret = av_read_frame(movie->format_ctx, &movie->pkt0);
if (ret < 0) {
av_init_packet(&movie->pkt0); /* ready for flushing */
*pkt = movie->pkt0;
if (ret == AVERROR_EOF) {
movie->eof = 1;
return 0; /* start flushing */
}
return ret;
}
*pkt = movie->pkt0;
}
}
pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
movie->out_index[pkt->stream_index];
if (pkt_out_id < 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0; /* ready for next run */
pkt->data = NULL;
return 0;
}
st = &movie->st[pkt_out_id];
outlink = ctx->outputs[pkt_out_id];
frame = av_frame_alloc();
if (!frame)
return AVERROR(ENOMEM);
frame_type = st->st->codec->codec_type;
switch (frame_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->st->codec, frame, &got_frame, pkt);
break;
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->st->codec, frame, &got_frame, pkt);
break;
default:
ret = AVERROR(ENOSYS);
break;
}
if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
av_frame_free(&frame);
av_free_packet(&movie->pkt0);
movie->pkt.size = 0;
movie->pkt.data = NULL;
return 0;
}
if (!ret || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
ret = pkt->size;
pkt->data += ret;
pkt->size -= ret;
if (pkt->size <= 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0; /* ready for next run */
pkt->data = NULL;
}
if (!got_frame) {
if (!ret)
st->done = 1;
av_frame_free(&frame);
return 0;
}
frame->pts = av_frame_get_best_effort_timestamp(frame);
av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
describe_frame_to_str((char[1024]){0}, 1024, frame, frame_type, outlink));
if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (frame->format != outlink->format) {
av_log(ctx, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n",
av_get_pix_fmt_name(outlink->format),
av_get_pix_fmt_name(frame->format)
);
av_frame_free(&frame);
return 0;
}
}
ret = ff_filter_frame(outlink, frame);
if (ret < 0)
return ret;
return pkt_out_id == out_id;
}
| false | FFmpeg | 229843aa359ae0c9519977d7fa952688db63f559 | static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
{
MovieContext *movie = ctx->priv;
AVPacket *pkt = &movie->pkt;
enum AVMediaType frame_type;
MovieStream *st;
int ret, got_frame = 0, pkt_out_id;
AVFilterLink *outlink;
AVFrame *frame;
if (!pkt->size) {
if (movie->eof) {
if (movie->st[out_id].done) {
if (movie->loop_count != 1) {
ret = rewind_file(ctx);
if (ret < 0)
return ret;
movie->loop_count -= movie->loop_count > 1;
av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
return 0;
}
return AVERROR_EOF;
}
pkt->stream_index = movie->st[out_id].st->index;
} else {
ret = av_read_frame(movie->format_ctx, &movie->pkt0);
if (ret < 0) {
av_init_packet(&movie->pkt0);
*pkt = movie->pkt0;
if (ret == AVERROR_EOF) {
movie->eof = 1;
return 0;
}
return ret;
}
*pkt = movie->pkt0;
}
}
pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
movie->out_index[pkt->stream_index];
if (pkt_out_id < 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
return 0;
}
st = &movie->st[pkt_out_id];
outlink = ctx->outputs[pkt_out_id];
frame = av_frame_alloc();
if (!frame)
return AVERROR(ENOMEM);
frame_type = st->st->codec->codec_type;
switch (frame_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->st->codec, frame, &got_frame, pkt);
break;
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->st->codec, frame, &got_frame, pkt);
break;
default:
ret = AVERROR(ENOSYS);
break;
}
if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
av_frame_free(&frame);
av_free_packet(&movie->pkt0);
movie->pkt.size = 0;
movie->pkt.data = NULL;
return 0;
}
if (!ret || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
ret = pkt->size;
pkt->data += ret;
pkt->size -= ret;
if (pkt->size <= 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
}
if (!got_frame) {
if (!ret)
st->done = 1;
av_frame_free(&frame);
return 0;
}
frame->pts = av_frame_get_best_effort_timestamp(frame);
av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
describe_frame_to_str((char[1024]){0}, 1024, frame, frame_type, outlink));
if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (frame->format != outlink->format) {
av_log(ctx, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n",
av_get_pix_fmt_name(outlink->format),
av_get_pix_fmt_name(frame->format)
);
av_frame_free(&frame);
return 0;
}
}
ret = ff_filter_frame(outlink, frame);
if (ret < 0)
return ret;
return pkt_out_id == out_id;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0, unsigned VAR_1)
{
MovieContext *movie = VAR_0->priv;
AVPacket *pkt = &movie->pkt;
enum AVMediaType VAR_2;
MovieStream *st;
int VAR_3, VAR_4 = 0, VAR_5;
AVFilterLink *outlink;
AVFrame *frame;
if (!pkt->size) {
if (movie->eof) {
if (movie->st[VAR_1].done) {
if (movie->loop_count != 1) {
VAR_3 = rewind_file(VAR_0);
if (VAR_3 < 0)
return VAR_3;
movie->loop_count -= movie->loop_count > 1;
av_log(VAR_0, AV_LOG_VERBOSE, "Stream finished, looping.\n");
return 0;
}
return AVERROR_EOF;
}
pkt->stream_index = movie->st[VAR_1].st->index;
} else {
VAR_3 = av_read_frame(movie->format_ctx, &movie->pkt0);
if (VAR_3 < 0) {
av_init_packet(&movie->pkt0);
*pkt = movie->pkt0;
if (VAR_3 == AVERROR_EOF) {
movie->eof = 1;
return 0;
}
return VAR_3;
}
*pkt = movie->pkt0;
}
}
VAR_5 = pkt->stream_index > movie->max_stream_index ? -1 :
movie->out_index[pkt->stream_index];
if (VAR_5 < 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
return 0;
}
st = &movie->st[VAR_5];
outlink = VAR_0->outputs[VAR_5];
frame = av_frame_alloc();
if (!frame)
return AVERROR(ENOMEM);
VAR_2 = st->st->codec->codec_type;
switch (VAR_2) {
case AVMEDIA_TYPE_VIDEO:
VAR_3 = avcodec_decode_video2(st->st->codec, frame, &VAR_4, pkt);
break;
case AVMEDIA_TYPE_AUDIO:
VAR_3 = avcodec_decode_audio4(st->st->codec, frame, &VAR_4, pkt);
break;
default:
VAR_3 = AVERROR(ENOSYS);
break;
}
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(VAR_3));
av_frame_free(&frame);
av_free_packet(&movie->pkt0);
movie->pkt.size = 0;
movie->pkt.data = NULL;
return 0;
}
if (!VAR_3 || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
VAR_3 = pkt->size;
pkt->data += VAR_3;
pkt->size -= VAR_3;
if (pkt->size <= 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
}
if (!VAR_4) {
if (!VAR_3)
st->done = 1;
av_frame_free(&frame);
return 0;
}
frame->pts = av_frame_get_best_effort_timestamp(frame);
av_dlog(VAR_0, "FUNC_0(): file:'%s' %s\n", movie->file_name,
describe_frame_to_str((char[1024]){0}, 1024, frame, VAR_2, outlink));
if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (frame->format != outlink->format) {
av_log(VAR_0, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n",
av_get_pix_fmt_name(outlink->format),
av_get_pix_fmt_name(frame->format)
);
av_frame_free(&frame);
return 0;
}
}
VAR_3 = ff_filter_frame(outlink, frame);
if (VAR_3 < 0)
return VAR_3;
return VAR_5 == VAR_1;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, unsigned VAR_1)\n{",
"MovieContext *movie = VAR_0->priv;",
"AVPacket *pkt = &movie->pkt;",
"enum AVMediaType VAR_2;",
"MovieStream *st;",
"int VAR_3, VAR_4 = 0, VAR_5;",
"AVFilterLink *outlink;",
"AVFrame *frame;",
"if (!pkt->size) {",
"if (movie->eof) {",
"if (movie->st[VAR_1].done) {",
"if (movie->loop_count != 1) {",
"VAR_3 = rewind_file(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"movie->loop_count -= movie->loop_count > 1;",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Stream finished, looping.\\n\");",
"return 0;",
"}",
"return AVERROR_EOF;",
"}",
"pkt->stream_index = movie->st[VAR_1].st->index;",
"} else {",
"VAR_3 = av_read_frame(movie->format_ctx, &movie->pkt0);",
"if (VAR_3 < 0) {",
"av_init_packet(&movie->pkt0);",
"*pkt = movie->pkt0;",
"if (VAR_3 == AVERROR_EOF) {",
"movie->eof = 1;",
"return 0;",
"}",
"return VAR_3;",
"}",
"*pkt = movie->pkt0;",
"}",
"}",
"VAR_5 = pkt->stream_index > movie->max_stream_index ? -1 :\nmovie->out_index[pkt->stream_index];",
"if (VAR_5 < 0) {",
"av_free_packet(&movie->pkt0);",
"pkt->size = 0;",
"pkt->data = NULL;",
"return 0;",
"}",
"st = &movie->st[VAR_5];",
"outlink = VAR_0->outputs[VAR_5];",
"frame = av_frame_alloc();",
"if (!frame)\nreturn AVERROR(ENOMEM);",
"VAR_2 = st->st->codec->codec_type;",
"switch (VAR_2) {",
"case AVMEDIA_TYPE_VIDEO:\nVAR_3 = avcodec_decode_video2(st->st->codec, frame, &VAR_4, pkt);",
"break;",
"case AVMEDIA_TYPE_AUDIO:\nVAR_3 = avcodec_decode_audio4(st->st->codec, frame, &VAR_4, pkt);",
"break;",
"default:\nVAR_3 = AVERROR(ENOSYS);",
"break;",
"}",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Decode error: %s\\n\", av_err2str(VAR_3));",
"av_frame_free(&frame);",
"av_free_packet(&movie->pkt0);",
"movie->pkt.size = 0;",
"movie->pkt.data = NULL;",
"return 0;",
"}",
"if (!VAR_3 || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)\nVAR_3 = pkt->size;",
"pkt->data += VAR_3;",
"pkt->size -= VAR_3;",
"if (pkt->size <= 0) {",
"av_free_packet(&movie->pkt0);",
"pkt->size = 0;",
"pkt->data = NULL;",
"}",
"if (!VAR_4) {",
"if (!VAR_3)\nst->done = 1;",
"av_frame_free(&frame);",
"return 0;",
"}",
"frame->pts = av_frame_get_best_effort_timestamp(frame);",
"av_dlog(VAR_0, \"FUNC_0(): file:'%s' %s\\n\", movie->file_name,\ndescribe_frame_to_str((char[1024]){0}, 1024, frame, VAR_2, outlink));",
"if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (frame->format != outlink->format) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Format changed %s -> %s, discarding frame\\n\",\nav_get_pix_fmt_name(outlink->format),\nav_get_pix_fmt_name(frame->format)\n);",
"av_frame_free(&frame);",
"return 0;",
"}",
"}",
"VAR_3 = ff_filter_frame(outlink, frame);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"return VAR_5 == VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105,
107
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187,
189
],
[
193
],
[
195
],
[
197,
199,
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217,
219
],
[
221
],
[
223
]
] |
4,820 | static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
const uint8_t *mm_end;
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 15;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movd %1, %%mm0 \n\t"
"movd 3%1, %%mm3 \n\t"
"punpckldq 6%1, %%mm0 \n\t"
"punpckldq 9%1, %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"psllq $7, %%mm0 \n\t"
"psllq $7, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm3 \n\t"
"psrlq $6, %%mm1 \n\t"
"psrlq $6, %%mm4 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"psrlq $19, %%mm2 \n\t"
"psrlq $19, %%mm5 \n\t"
"pand %2, %%mm2 \n\t"
"pand %2, %%mm5 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm5, %%mm3 \n\t"
"psllq $16, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 12;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
const int r = *s++;
const int g = *s++;
const int b = *s++;
*d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
}
}
| true | FFmpeg | 90540c2d5ace46a1e9789c75fde0b1f7dbb12a9b | static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
const uint8_t *mm_end;
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 15;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movd %1, %%mm0 \n\t"
"movd 3%1, %%mm3 \n\t"
"punpckldq 6%1, %%mm0 \n\t"
"punpckldq 9%1, %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"psllq $7, %%mm0 \n\t"
"psllq $7, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm3 \n\t"
"psrlq $6, %%mm1 \n\t"
"psrlq $6, %%mm4 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"psrlq $19, %%mm2 \n\t"
"psrlq $19, %%mm5 \n\t"
"pand %2, %%mm2 \n\t"
"pand %2, %%mm5 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm5, %%mm3 \n\t"
"psllq $16, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 12;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
const int r = *s++;
const int g = *s++;
const int b = *s++;
*d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
}
}
| {
"code": [
" :\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
" :\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movd %1, %%mm0 \\n\\t\"",
" \"movd 3%1, %%mm3 \\n\\t\"",
" \"punpckldq 6%1, %%mm0 \\n\\t\"",
" \"punpckldq 9%1, %%mm3 \\n\\t\"",
" MOVNTQ\" %%mm0, %0 \\n\\t\"",
" :\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");"
],
"line_no": [
87,
87,
31,
33,
35,
37,
39,
85,
87
]
} | static inline void FUNC_0(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
const uint8_t *VAR_2;
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
::"m"(red_15mask),"m"(green_15mask));
VAR_2 = VAR_1 - 15;
while (VAR_0 < VAR_2) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movd %1, %%mm0 \n\t"
"movd 3%1, %%mm3 \n\t"
"punpckldq 6%1, %%mm0 \n\t"
"punpckldq 9%1, %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"psllq $7, %%mm0 \n\t"
"psllq $7, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm3 \n\t"
"psrlq $6, %%mm1 \n\t"
"psrlq $6, %%mm4 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"psrlq $19, %%mm2 \n\t"
"psrlq $19, %%mm5 \n\t"
"pand %2, %%mm2 \n\t"
"pand %2, %%mm5 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm5, %%mm3 \n\t"
"psllq $16, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_15mask):"memory");
d += 4;
VAR_0 += 12;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (VAR_0 < VAR_1) {
const int VAR_3 = *VAR_0++;
const int VAR_4 = *VAR_0++;
const int VAR_5 = *VAR_0++;
*d++ = (VAR_5>>3) | ((VAR_4&0xF8)<<2) | ((VAR_3&0xF8)<<7);
}
}
| [
"static inline void FUNC_0(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"const uint8_t *VAR_2;",
"uint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"__asm__ volatile(PREFETCH\" %0\"::\"m\"(*src):\"memory\");",
"__asm__ volatile(\n\"movq %0, %%mm7 \\n\\t\"\n\"movq %1, %%mm6 \\n\\t\"\n::\"m\"(red_15mask),\"m\"(green_15mask));",
"VAR_2 = VAR_1 - 15;",
"while (VAR_0 < VAR_2) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movd %1, %%mm0 \\n\\t\"\n\"movd 3%1, %%mm3 \\n\\t\"\n\"punpckldq 6%1, %%mm0 \\n\\t\"\n\"punpckldq 9%1, %%mm3 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm3, %%mm4 \\n\\t\"\n\"movq %%mm3, %%mm5 \\n\\t\"\n\"psllq $7, %%mm0 \\n\\t\"\n\"psllq $7, %%mm3 \\n\\t\"\n\"pand %%mm7, %%mm0 \\n\\t\"\n\"pand %%mm7, %%mm3 \\n\\t\"\n\"psrlq $6, %%mm1 \\n\\t\"\n\"psrlq $6, %%mm4 \\n\\t\"\n\"pand %%mm6, %%mm1 \\n\\t\"\n\"pand %%mm6, %%mm4 \\n\\t\"\n\"psrlq $19, %%mm2 \\n\\t\"\n\"psrlq $19, %%mm5 \\n\\t\"\n\"pand %2, %%mm2 \\n\\t\"\n\"pand %2, %%mm5 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n\"psllq $16, %%mm3 \\n\\t\"\n\"por %%mm3, %%mm0 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_15mask):\"memory\");",
"d += 4;",
"VAR_0 += 12;",
"}",
"__asm__ volatile(SFENCE:::\"memory\");",
"__asm__ volatile(EMMS:::\"memory\");",
"while (VAR_0 < VAR_1) {",
"const int VAR_3 = *VAR_0++;",
"const int VAR_4 = *VAR_0++;",
"const int VAR_5 = *VAR_0++;",
"*d++ = (VAR_5>>3) | ((VAR_4&0xF8)<<2) | ((VAR_3&0xF8)<<7);",
"}",
"}"
] | [
0,
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,
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
]
] |
4,821 | static int decode_picture_timing(H264Context *h)
{
if (h->sps.nal_hrd_parameters_present_flag ||
h->sps.vcl_hrd_parameters_present_flag) {
h->sei_cpb_removal_delay = get_bits(&h->gb,
h->sps.cpb_removal_delay_length);
h->sei_dpb_output_delay = get_bits(&h->gb,
h->sps.dpb_output_delay_length);
}
if (h->sps.pic_struct_present_flag) {
unsigned int i, num_clock_ts;
h->sei_pic_struct = get_bits(&h->gb, 4);
h->sei_ct_type = 0;
if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
return AVERROR_INVALIDDATA;
num_clock_ts = sei_num_clock_ts_table[h->sei_pic_struct];
for (i = 0; i < num_clock_ts; i++) {
if (get_bits(&h->gb, 1)) { /* clock_timestamp_flag */
unsigned int full_timestamp_flag;
h->sei_ct_type |= 1 << get_bits(&h->gb, 2);
skip_bits(&h->gb, 1); /* nuit_field_based_flag */
skip_bits(&h->gb, 5); /* counting_type */
full_timestamp_flag = get_bits(&h->gb, 1);
skip_bits(&h->gb, 1); /* discontinuity_flag */
skip_bits(&h->gb, 1); /* cnt_dropped_flag */
skip_bits(&h->gb, 8); /* n_frames */
if (full_timestamp_flag) {
skip_bits(&h->gb, 6); /* seconds_value 0..59 */
skip_bits(&h->gb, 6); /* minutes_value 0..59 */
skip_bits(&h->gb, 5); /* hours_value 0..23 */
} else {
if (get_bits(&h->gb, 1)) { /* seconds_flag */
skip_bits(&h->gb, 6); /* seconds_value range 0..59 */
if (get_bits(&h->gb, 1)) { /* minutes_flag */
skip_bits(&h->gb, 6); /* minutes_value 0..59 */
if (get_bits(&h->gb, 1)) /* hours_flag */
skip_bits(&h->gb, 5); /* hours_value 0..23 */
}
}
}
if (h->sps.time_offset_length > 0)
skip_bits(&h->gb,
h->sps.time_offset_length); /* time_offset */
}
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(h->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n",
h->sei_ct_type, h->sei_pic_struct);
}
return 0;
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static int decode_picture_timing(H264Context *h)
{
if (h->sps.nal_hrd_parameters_present_flag ||
h->sps.vcl_hrd_parameters_present_flag) {
h->sei_cpb_removal_delay = get_bits(&h->gb,
h->sps.cpb_removal_delay_length);
h->sei_dpb_output_delay = get_bits(&h->gb,
h->sps.dpb_output_delay_length);
}
if (h->sps.pic_struct_present_flag) {
unsigned int i, num_clock_ts;
h->sei_pic_struct = get_bits(&h->gb, 4);
h->sei_ct_type = 0;
if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
return AVERROR_INVALIDDATA;
num_clock_ts = sei_num_clock_ts_table[h->sei_pic_struct];
for (i = 0; i < num_clock_ts; i++) {
if (get_bits(&h->gb, 1)) {
unsigned int full_timestamp_flag;
h->sei_ct_type |= 1 << get_bits(&h->gb, 2);
skip_bits(&h->gb, 1);
skip_bits(&h->gb, 5);
full_timestamp_flag = get_bits(&h->gb, 1);
skip_bits(&h->gb, 1);
skip_bits(&h->gb, 1);
skip_bits(&h->gb, 8);
if (full_timestamp_flag) {
skip_bits(&h->gb, 6);
skip_bits(&h->gb, 6);
skip_bits(&h->gb, 5);
} else {
if (get_bits(&h->gb, 1)) {
skip_bits(&h->gb, 6);
if (get_bits(&h->gb, 1)) {
skip_bits(&h->gb, 6);
if (get_bits(&h->gb, 1))
skip_bits(&h->gb, 5);
}
}
}
if (h->sps.time_offset_length > 0)
skip_bits(&h->gb,
h->sps.time_offset_length);
}
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(h->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n",
h->sei_ct_type, h->sei_pic_struct);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0)
{
if (VAR_0->sps.nal_hrd_parameters_present_flag ||
VAR_0->sps.vcl_hrd_parameters_present_flag) {
VAR_0->sei_cpb_removal_delay = get_bits(&VAR_0->gb,
VAR_0->sps.cpb_removal_delay_length);
VAR_0->sei_dpb_output_delay = get_bits(&VAR_0->gb,
VAR_0->sps.dpb_output_delay_length);
}
if (VAR_0->sps.pic_struct_present_flag) {
unsigned int VAR_1, VAR_2;
VAR_0->sei_pic_struct = get_bits(&VAR_0->gb, 4);
VAR_0->sei_ct_type = 0;
if (VAR_0->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
return AVERROR_INVALIDDATA;
VAR_2 = sei_num_clock_ts_table[VAR_0->sei_pic_struct];
for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {
if (get_bits(&VAR_0->gb, 1)) {
unsigned int VAR_3;
VAR_0->sei_ct_type |= 1 << get_bits(&VAR_0->gb, 2);
skip_bits(&VAR_0->gb, 1);
skip_bits(&VAR_0->gb, 5);
VAR_3 = get_bits(&VAR_0->gb, 1);
skip_bits(&VAR_0->gb, 1);
skip_bits(&VAR_0->gb, 1);
skip_bits(&VAR_0->gb, 8);
if (VAR_3) {
skip_bits(&VAR_0->gb, 6);
skip_bits(&VAR_0->gb, 6);
skip_bits(&VAR_0->gb, 5);
} else {
if (get_bits(&VAR_0->gb, 1)) {
skip_bits(&VAR_0->gb, 6);
if (get_bits(&VAR_0->gb, 1)) {
skip_bits(&VAR_0->gb, 6);
if (get_bits(&VAR_0->gb, 1))
skip_bits(&VAR_0->gb, 5);
}
}
}
if (VAR_0->sps.time_offset_length > 0)
skip_bits(&VAR_0->gb,
VAR_0->sps.time_offset_length);
}
}
if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n",
VAR_0->sei_ct_type, VAR_0->sei_pic_struct);
}
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0)\n{",
"if (VAR_0->sps.nal_hrd_parameters_present_flag ||\nVAR_0->sps.vcl_hrd_parameters_present_flag) {",
"VAR_0->sei_cpb_removal_delay = get_bits(&VAR_0->gb,\nVAR_0->sps.cpb_removal_delay_length);",
"VAR_0->sei_dpb_output_delay = get_bits(&VAR_0->gb,\nVAR_0->sps.dpb_output_delay_length);",
"}",
"if (VAR_0->sps.pic_struct_present_flag) {",
"unsigned int VAR_1, VAR_2;",
"VAR_0->sei_pic_struct = get_bits(&VAR_0->gb, 4);",
"VAR_0->sei_ct_type = 0;",
"if (VAR_0->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)\nreturn AVERROR_INVALIDDATA;",
"VAR_2 = sei_num_clock_ts_table[VAR_0->sei_pic_struct];",
"for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {",
"if (get_bits(&VAR_0->gb, 1)) {",
"unsigned int VAR_3;",
"VAR_0->sei_ct_type |= 1 << get_bits(&VAR_0->gb, 2);",
"skip_bits(&VAR_0->gb, 1);",
"skip_bits(&VAR_0->gb, 5);",
"VAR_3 = get_bits(&VAR_0->gb, 1);",
"skip_bits(&VAR_0->gb, 1);",
"skip_bits(&VAR_0->gb, 1);",
"skip_bits(&VAR_0->gb, 8);",
"if (VAR_3) {",
"skip_bits(&VAR_0->gb, 6);",
"skip_bits(&VAR_0->gb, 6);",
"skip_bits(&VAR_0->gb, 5);",
"} else {",
"if (get_bits(&VAR_0->gb, 1)) {",
"skip_bits(&VAR_0->gb, 6);",
"if (get_bits(&VAR_0->gb, 1)) {",
"skip_bits(&VAR_0->gb, 6);",
"if (get_bits(&VAR_0->gb, 1))\nskip_bits(&VAR_0->gb, 5);",
"}",
"}",
"}",
"if (VAR_0->sps.time_offset_length > 0)\nskip_bits(&VAR_0->gb,\nVAR_0->sps.time_offset_length);",
"}",
"}",
"if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"ct_type:%X pic_struct:%d\\n\",\nVAR_0->sei_ct_type, VAR_0->sei_pic_struct);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31,
33
],
[
37
],
[
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
],
[
103,
105,
107
],
[
109
],
[
111
],
[
113
]
] |
4,822 | static int ftp_close(URLContext *h)
{
FTPContext *s = h->priv_data;
av_dlog(h, "ftp protocol close\n");
ftp_close_both_connections(s);
av_freep(&s->user);
av_freep(&s->password);
av_freep(&s->hostname);
av_freep(&s->path);
av_freep(&s->features);
return 0;
}
| false | FFmpeg | 229843aa359ae0c9519977d7fa952688db63f559 | static int ftp_close(URLContext *h)
{
FTPContext *s = h->priv_data;
av_dlog(h, "ftp protocol close\n");
ftp_close_both_connections(s);
av_freep(&s->user);
av_freep(&s->password);
av_freep(&s->hostname);
av_freep(&s->path);
av_freep(&s->features);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0)
{
FTPContext *s = VAR_0->priv_data;
av_dlog(VAR_0, "ftp protocol close\n");
ftp_close_both_connections(s);
av_freep(&s->user);
av_freep(&s->password);
av_freep(&s->hostname);
av_freep(&s->path);
av_freep(&s->features);
return 0;
}
| [
"static int FUNC_0(URLContext *VAR_0)\n{",
"FTPContext *s = VAR_0->priv_data;",
"av_dlog(VAR_0, \"ftp protocol close\\n\");",
"ftp_close_both_connections(s);",
"av_freep(&s->user);",
"av_freep(&s->password);",
"av_freep(&s->hostname);",
"av_freep(&s->path);",
"av_freep(&s->features);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
4,823 | int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap)
{
AVFormatContext *ic = NULL;
int err;
char buf[PROBE_BUF_SIZE];
AVProbeData probe_data, *pd = &probe_data;
ic = av_mallocz(sizeof(AVFormatContext));
if (!ic) {
err = AVERROR_NOMEM;
goto fail;
}
pstrcpy(ic->filename, sizeof(ic->filename), filename);
pd->filename = ic->filename;
pd->buf = buf;
pd->buf_size = 0;
if (!fmt) {
/* guess format if no file can be opened */
fmt = probe_input_format(pd, 0);
}
/* if no file needed do not try to open one */
if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
if (url_fopen(&ic->pb, filename, URL_RDONLY) < 0) {
err = AVERROR_IO;
goto fail;
}
if (buf_size > 0) {
url_setbufsize(&ic->pb, buf_size);
}
/* read probe data */
pd->buf_size = get_buffer(&ic->pb, buf, PROBE_BUF_SIZE);
url_fseek(&ic->pb, 0, SEEK_SET);
}
/* guess file format */
if (!fmt) {
fmt = probe_input_format(pd, 1);
}
/* if still no format found, error */
if (!fmt) {
err = AVERROR_NOFMT;
goto fail;
}
ic->iformat = fmt;
/* allocate private data */
ic->priv_data = av_mallocz(fmt->priv_data_size);
if (!ic->priv_data) {
err = AVERROR_NOMEM;
goto fail;
}
/* check filename in case of an image number is expected */
if (ic->iformat->flags & AVFMT_NEEDNUMBER) {
if (filename_number_test(ic->filename) < 0) {
err = AVERROR_NUMEXPECTED;
goto fail1;
}
}
err = ic->iformat->read_header(ic, ap);
if (err < 0)
goto fail1;
*ic_ptr = ic;
return 0;
fail1:
if (!(fmt->flags & AVFMT_NOFILE)) {
url_fclose(&ic->pb);
}
fail:
if (ic) {
av_free(ic->priv_data);
}
av_free(ic);
*ic_ptr = NULL;
return err;
}
| false | FFmpeg | a8dbe9514f865f6a8efb304a720025cb1ef9ae3f | int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap)
{
AVFormatContext *ic = NULL;
int err;
char buf[PROBE_BUF_SIZE];
AVProbeData probe_data, *pd = &probe_data;
ic = av_mallocz(sizeof(AVFormatContext));
if (!ic) {
err = AVERROR_NOMEM;
goto fail;
}
pstrcpy(ic->filename, sizeof(ic->filename), filename);
pd->filename = ic->filename;
pd->buf = buf;
pd->buf_size = 0;
if (!fmt) {
fmt = probe_input_format(pd, 0);
}
if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
if (url_fopen(&ic->pb, filename, URL_RDONLY) < 0) {
err = AVERROR_IO;
goto fail;
}
if (buf_size > 0) {
url_setbufsize(&ic->pb, buf_size);
}
pd->buf_size = get_buffer(&ic->pb, buf, PROBE_BUF_SIZE);
url_fseek(&ic->pb, 0, SEEK_SET);
}
if (!fmt) {
fmt = probe_input_format(pd, 1);
}
if (!fmt) {
err = AVERROR_NOFMT;
goto fail;
}
ic->iformat = fmt;
ic->priv_data = av_mallocz(fmt->priv_data_size);
if (!ic->priv_data) {
err = AVERROR_NOMEM;
goto fail;
}
if (ic->iformat->flags & AVFMT_NEEDNUMBER) {
if (filename_number_test(ic->filename) < 0) {
err = AVERROR_NUMEXPECTED;
goto fail1;
}
}
err = ic->iformat->read_header(ic, ap);
if (err < 0)
goto fail1;
*ic_ptr = ic;
return 0;
fail1:
if (!(fmt->flags & AVFMT_NOFILE)) {
url_fclose(&ic->pb);
}
fail:
if (ic) {
av_free(ic->priv_data);
}
av_free(ic);
*ic_ptr = NULL;
return err;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext **VAR_0, const char *VAR_1,
AVInputFormat *VAR_2,
int VAR_3,
AVFormatParameters *VAR_4)
{
AVFormatContext *ic = NULL;
int VAR_5;
char VAR_6[PROBE_BUF_SIZE];
AVProbeData probe_data, *pd = &probe_data;
ic = av_mallocz(sizeof(AVFormatContext));
if (!ic) {
VAR_5 = AVERROR_NOMEM;
goto fail;
}
pstrcpy(ic->VAR_1, sizeof(ic->VAR_1), VAR_1);
pd->VAR_1 = ic->VAR_1;
pd->VAR_6 = VAR_6;
pd->VAR_3 = 0;
if (!VAR_2) {
VAR_2 = probe_input_format(pd, 0);
}
if (!VAR_2 || !(VAR_2->flags & AVFMT_NOFILE)) {
if (url_fopen(&ic->pb, VAR_1, URL_RDONLY) < 0) {
VAR_5 = AVERROR_IO;
goto fail;
}
if (VAR_3 > 0) {
url_setbufsize(&ic->pb, VAR_3);
}
pd->VAR_3 = get_buffer(&ic->pb, VAR_6, PROBE_BUF_SIZE);
url_fseek(&ic->pb, 0, SEEK_SET);
}
if (!VAR_2) {
VAR_2 = probe_input_format(pd, 1);
}
if (!VAR_2) {
VAR_5 = AVERROR_NOFMT;
goto fail;
}
ic->iformat = VAR_2;
ic->priv_data = av_mallocz(VAR_2->priv_data_size);
if (!ic->priv_data) {
VAR_5 = AVERROR_NOMEM;
goto fail;
}
if (ic->iformat->flags & AVFMT_NEEDNUMBER) {
if (filename_number_test(ic->VAR_1) < 0) {
VAR_5 = AVERROR_NUMEXPECTED;
goto fail1;
}
}
VAR_5 = ic->iformat->read_header(ic, VAR_4);
if (VAR_5 < 0)
goto fail1;
*VAR_0 = ic;
return 0;
fail1:
if (!(VAR_2->flags & AVFMT_NOFILE)) {
url_fclose(&ic->pb);
}
fail:
if (ic) {
av_free(ic->priv_data);
}
av_free(ic);
*VAR_0 = NULL;
return VAR_5;
}
| [
"int FUNC_0(AVFormatContext **VAR_0, const char *VAR_1,\nAVInputFormat *VAR_2,\nint VAR_3,\nAVFormatParameters *VAR_4)\n{",
"AVFormatContext *ic = NULL;",
"int VAR_5;",
"char VAR_6[PROBE_BUF_SIZE];",
"AVProbeData probe_data, *pd = &probe_data;",
"ic = av_mallocz(sizeof(AVFormatContext));",
"if (!ic) {",
"VAR_5 = AVERROR_NOMEM;",
"goto fail;",
"}",
"pstrcpy(ic->VAR_1, sizeof(ic->VAR_1), VAR_1);",
"pd->VAR_1 = ic->VAR_1;",
"pd->VAR_6 = VAR_6;",
"pd->VAR_3 = 0;",
"if (!VAR_2) {",
"VAR_2 = probe_input_format(pd, 0);",
"}",
"if (!VAR_2 || !(VAR_2->flags & AVFMT_NOFILE)) {",
"if (url_fopen(&ic->pb, VAR_1, URL_RDONLY) < 0) {",
"VAR_5 = AVERROR_IO;",
"goto fail;",
"}",
"if (VAR_3 > 0) {",
"url_setbufsize(&ic->pb, VAR_3);",
"}",
"pd->VAR_3 = get_buffer(&ic->pb, VAR_6, PROBE_BUF_SIZE);",
"url_fseek(&ic->pb, 0, SEEK_SET);",
"}",
"if (!VAR_2) {",
"VAR_2 = probe_input_format(pd, 1);",
"}",
"if (!VAR_2) {",
"VAR_5 = AVERROR_NOFMT;",
"goto fail;",
"}",
"ic->iformat = VAR_2;",
"ic->priv_data = av_mallocz(VAR_2->priv_data_size);",
"if (!ic->priv_data) {",
"VAR_5 = AVERROR_NOMEM;",
"goto fail;",
"}",
"if (ic->iformat->flags & AVFMT_NEEDNUMBER) {",
"if (filename_number_test(ic->VAR_1) < 0) {",
"VAR_5 = AVERROR_NUMEXPECTED;",
"goto fail1;",
"}",
"}",
"VAR_5 = ic->iformat->read_header(ic, VAR_4);",
"if (VAR_5 < 0)\ngoto fail1;",
"*VAR_0 = ic;",
"return 0;",
"fail1:\nif (!(VAR_2->flags & AVFMT_NOFILE)) {",
"url_fclose(&ic->pb);",
"}",
"fail:\nif (ic) {",
"av_free(ic->priv_data);",
"}",
"av_free(ic);",
"*VAR_0 = NULL;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
]
] |
4,824 | static int dec_21154_pci_host_init(PCIDevice *d)
{
/* PCI2PCI bridge same values as PearPC - check this */
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154);
pci_set_byte(d->config + PCI_REVISION_ID, 0x02);
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
return 0;
}
| false | qemu | e7b9bc3e89152f14f426fa4d150d2a6ca02583c1 | static int dec_21154_pci_host_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154);
pci_set_byte(d->config + PCI_REVISION_ID, 0x02);
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_DEC);
pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_DEC_21154);
pci_set_byte(VAR_0->config + PCI_REVISION_ID, 0x02);
pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_PCI);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_DEC);",
"pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_DEC_21154);",
"pci_set_byte(VAR_0->config + PCI_REVISION_ID, 0x02);",
"pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_PCI);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,825 | static void guess_mv(MpegEncContext *s)
{
uint8_t *fixed = av_malloc(s->mb_stride * s->mb_height);
#define MV_FROZEN 3
#define MV_CHANGED 2
#define MV_UNCHANGED 1
const int mb_stride = s->mb_stride;
const int mb_width = s->mb_width;
const int mb_height = s->mb_height;
int i, depth, num_avail;
int mb_x, mb_y, mot_step, mot_stride;
set_mv_strides(s, &mot_step, &mot_stride);
num_avail = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int f = 0;
int error = s->error_status_table[mb_xy];
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
f = MV_FROZEN; // intra // FIXME check
if (!(error & ER_MV_ERROR))
f = MV_FROZEN; // inter with undamaged MV
fixed[mb_xy] = f;
if (f == MV_FROZEN)
num_avail++;
else if(s->last_picture.f.data[0] && s->last_picture.f.motion_val[0]){
const int mb_y= mb_xy / s->mb_stride;
const int mb_x= mb_xy % s->mb_stride;
const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
s->current_picture.f.motion_val[0][mot_index][0]= s->last_picture.f.motion_val[0][mot_index][0];
s->current_picture.f.motion_val[0][mot_index][1]= s->last_picture.f.motion_val[0][mot_index][1];
s->current_picture.f.ref_index[0][4*mb_xy] = s->last_picture.f.ref_index[0][4*mb_xy];
}
}
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
num_avail <= mb_width / 2) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
s->mb_x = 0;
s->mb_y = mb_y;
ff_init_block_index(s);
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
ff_update_block_index(s);
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
continue;
if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
continue;
s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD
: MV_DIR_BACKWARD;
s->mb_intra = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_skipped = 0;
s->dsp.clear_blocks(s->block[0]);
s->mb_x = mb_x;
s->mb_y = mb_y;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
decode_mb(s, 0);
}
}
goto end;
}
for (depth = 0; ; depth++) {
int changed, pass, none_left;
none_left = 1;
changed = 1;
for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
int mb_x, mb_y;
int score_sum = 0;
changed = 0;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
s->mb_x = 0;
s->mb_y = mb_y;
ff_init_block_index(s);
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
int mv_predictor[8][2] = { { 0 } };
int ref[8] = { 0 };
int pred_count = 0;
int j;
int best_score = 256 * 256 * 256 * 64;
int best_pred = 0;
const int mot_index = (mb_x + mb_y * mot_stride) * mot_step;
int prev_x, prev_y, prev_ref;
ff_update_block_index(s);
if ((mb_x ^ mb_y ^ pass) & 1)
continue;
if (fixed[mb_xy] == MV_FROZEN)
continue;
assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN)
j = 1;
if (j == 0)
continue;
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED)
j = 1;
if (j == 0 && pass > 1)
continue;
none_left = 0;
if (mb_x > 0 && fixed[mb_xy - 1]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index - mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index - mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy - 1)];
pred_count++;
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index + mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index + mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy + 1)];
pred_count++;
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy - s->mb_stride)];
pred_count++;
}
if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy + s->mb_stride)];
pred_count++;
}
if (pred_count == 0)
continue;
if (pred_count > 1) {
int sum_x = 0, sum_y = 0, sum_r = 0;
int max_x, max_y, min_x, min_y, max_r, min_r;
for (j = 0; j < pred_count; j++) {
sum_x += mv_predictor[j][0];
sum_y += mv_predictor[j][1];
sum_r += ref[j];
if (j && ref[j] != ref[j - 1])
goto skip_mean_and_median;
}
/* mean */
mv_predictor[pred_count][0] = sum_x / j;
mv_predictor[pred_count][1] = sum_y / j;
ref[pred_count] = sum_r / j;
/* median */
if (pred_count >= 3) {
min_y = min_x = min_r = 99999;
max_y = max_x = max_r = -99999;
} else {
min_x = min_y = max_x = max_y = min_r = max_r = 0;
}
for (j = 0; j < pred_count; j++) {
max_x = FFMAX(max_x, mv_predictor[j][0]);
max_y = FFMAX(max_y, mv_predictor[j][1]);
max_r = FFMAX(max_r, ref[j]);
min_x = FFMIN(min_x, mv_predictor[j][0]);
min_y = FFMIN(min_y, mv_predictor[j][1]);
min_r = FFMIN(min_r, ref[j]);
}
mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
ref[pred_count + 1] = sum_r - max_r - min_r;
if (pred_count == 4) {
mv_predictor[pred_count + 1][0] /= 2;
mv_predictor[pred_count + 1][1] /= 2;
ref[pred_count + 1] /= 2;
}
pred_count += 2;
}
skip_mean_and_median:
/* zero MV */
pred_count++;
if (!fixed[mb_xy] && 0) {
if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME
} else {
ff_thread_await_progress(&s->last_picture_ptr->f,
mb_y, 0);
}
if (!s->last_picture.f.motion_val[0] ||
!s->last_picture.f.ref_index[0])
goto skip_last_mv;
prev_x = s->last_picture.f.motion_val[0][mot_index][0];
prev_y = s->last_picture.f.motion_val[0][mot_index][1];
prev_ref = s->last_picture.f.ref_index[0][4 * mb_xy];
} else {
prev_x = s->current_picture.f.motion_val[0][mot_index][0];
prev_y = s->current_picture.f.motion_val[0][mot_index][1];
prev_ref = s->current_picture.f.ref_index[0][4 * mb_xy];
}
/* last MV */
mv_predictor[pred_count][0] = prev_x;
mv_predictor[pred_count][1] = prev_y;
ref[pred_count] = prev_ref;
pred_count++;
skip_last_mv:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_skipped = 0;
s->dsp.clear_blocks(s->block[0]);
s->mb_x = mb_x;
s->mb_y = mb_y;
for (j = 0; j < pred_count; j++) {
int score = 0;
uint8_t *src = s->current_picture.f.data[0] +
mb_x * 16 + mb_y * 16 * s->linesize;
s->current_picture.f.motion_val[0][mot_index][0] =
s->mv[0][0][0] = mv_predictor[j][0];
s->current_picture.f.motion_val[0][mot_index][1] =
s->mv[0][0][1] = mv_predictor[j][1];
// predictor intra or otherwise not available
if (ref[j] < 0)
continue;
decode_mb(s, ref[j]);
if (mb_x > 0 && fixed[mb_xy - 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * s->linesize - 1] -
src[k * s->linesize]);
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * s->linesize + 15] -
src[k * s->linesize + 16]);
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k - s->linesize] - src[k]);
}
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k + s->linesize * 15] -
src[k + s->linesize * 16]);
}
if (score <= best_score) { // <= will favor the last MV
best_score = score;
best_pred = j;
}
}
score_sum += best_score;
s->mv[0][0][0] = mv_predictor[best_pred][0];
s->mv[0][0][1] = mv_predictor[best_pred][1];
for (i = 0; i < mot_step; i++)
for (j = 0; j < mot_step; j++) {
s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
}
decode_mb(s, ref[best_pred]);
if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) {
fixed[mb_xy] = MV_CHANGED;
changed++;
} else
fixed[mb_xy] = MV_UNCHANGED;
}
}
// printf(".%d/%d", changed, score_sum); fflush(stdout);
}
if (none_left)
goto end;
for (i = 0; i < s->mb_num; i++) {
int mb_xy = s->mb_index2xy[i];
if (fixed[mb_xy])
fixed[mb_xy] = MV_FROZEN;
}
// printf(":"); fflush(stdout);
}
end:
av_free(fixed);
}
| false | FFmpeg | eff2399f240db76b713b694508cdc8be175ab9fd | static void guess_mv(MpegEncContext *s)
{
uint8_t *fixed = av_malloc(s->mb_stride * s->mb_height);
#define MV_FROZEN 3
#define MV_CHANGED 2
#define MV_UNCHANGED 1
const int mb_stride = s->mb_stride;
const int mb_width = s->mb_width;
const int mb_height = s->mb_height;
int i, depth, num_avail;
int mb_x, mb_y, mot_step, mot_stride;
set_mv_strides(s, &mot_step, &mot_stride);
num_avail = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int f = 0;
int error = s->error_status_table[mb_xy];
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
f = MV_FROZEN;
if (!(error & ER_MV_ERROR))
f = MV_FROZEN;
fixed[mb_xy] = f;
if (f == MV_FROZEN)
num_avail++;
else if(s->last_picture.f.data[0] && s->last_picture.f.motion_val[0]){
const int mb_y= mb_xy / s->mb_stride;
const int mb_x= mb_xy % s->mb_stride;
const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
s->current_picture.f.motion_val[0][mot_index][0]= s->last_picture.f.motion_val[0][mot_index][0];
s->current_picture.f.motion_val[0][mot_index][1]= s->last_picture.f.motion_val[0][mot_index][1];
s->current_picture.f.ref_index[0][4*mb_xy] = s->last_picture.f.ref_index[0][4*mb_xy];
}
}
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
num_avail <= mb_width / 2) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
s->mb_x = 0;
s->mb_y = mb_y;
ff_init_block_index(s);
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
ff_update_block_index(s);
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
continue;
if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
continue;
s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD
: MV_DIR_BACKWARD;
s->mb_intra = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_skipped = 0;
s->dsp.clear_blocks(s->block[0]);
s->mb_x = mb_x;
s->mb_y = mb_y;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
decode_mb(s, 0);
}
}
goto end;
}
for (depth = 0; ; depth++) {
int changed, pass, none_left;
none_left = 1;
changed = 1;
for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
int mb_x, mb_y;
int score_sum = 0;
changed = 0;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
s->mb_x = 0;
s->mb_y = mb_y;
ff_init_block_index(s);
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
int mv_predictor[8][2] = { { 0 } };
int ref[8] = { 0 };
int pred_count = 0;
int j;
int best_score = 256 * 256 * 256 * 64;
int best_pred = 0;
const int mot_index = (mb_x + mb_y * mot_stride) * mot_step;
int prev_x, prev_y, prev_ref;
ff_update_block_index(s);
if ((mb_x ^ mb_y ^ pass) & 1)
continue;
if (fixed[mb_xy] == MV_FROZEN)
continue;
assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN)
j = 1;
if (j == 0)
continue;
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED)
j = 1;
if (j == 0 && pass > 1)
continue;
none_left = 0;
if (mb_x > 0 && fixed[mb_xy - 1]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index - mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index - mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy - 1)];
pred_count++;
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index + mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index + mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy + 1)];
pred_count++;
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy - s->mb_stride)];
pred_count++;
}
if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
mv_predictor[pred_count][0] =
s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][1];
ref[pred_count] =
s->current_picture.f.ref_index[0][4 * (mb_xy + s->mb_stride)];
pred_count++;
}
if (pred_count == 0)
continue;
if (pred_count > 1) {
int sum_x = 0, sum_y = 0, sum_r = 0;
int max_x, max_y, min_x, min_y, max_r, min_r;
for (j = 0; j < pred_count; j++) {
sum_x += mv_predictor[j][0];
sum_y += mv_predictor[j][1];
sum_r += ref[j];
if (j && ref[j] != ref[j - 1])
goto skip_mean_and_median;
}
mv_predictor[pred_count][0] = sum_x / j;
mv_predictor[pred_count][1] = sum_y / j;
ref[pred_count] = sum_r / j;
if (pred_count >= 3) {
min_y = min_x = min_r = 99999;
max_y = max_x = max_r = -99999;
} else {
min_x = min_y = max_x = max_y = min_r = max_r = 0;
}
for (j = 0; j < pred_count; j++) {
max_x = FFMAX(max_x, mv_predictor[j][0]);
max_y = FFMAX(max_y, mv_predictor[j][1]);
max_r = FFMAX(max_r, ref[j]);
min_x = FFMIN(min_x, mv_predictor[j][0]);
min_y = FFMIN(min_y, mv_predictor[j][1]);
min_r = FFMIN(min_r, ref[j]);
}
mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
ref[pred_count + 1] = sum_r - max_r - min_r;
if (pred_count == 4) {
mv_predictor[pred_count + 1][0] /= 2;
mv_predictor[pred_count + 1][1] /= 2;
ref[pred_count + 1] /= 2;
}
pred_count += 2;
}
skip_mean_and_median:
pred_count++;
if (!fixed[mb_xy] && 0) {
if (s->avctx->codec_id == CODEC_ID_H264) {
} else {
ff_thread_await_progress(&s->last_picture_ptr->f,
mb_y, 0);
}
if (!s->last_picture.f.motion_val[0] ||
!s->last_picture.f.ref_index[0])
goto skip_last_mv;
prev_x = s->last_picture.f.motion_val[0][mot_index][0];
prev_y = s->last_picture.f.motion_val[0][mot_index][1];
prev_ref = s->last_picture.f.ref_index[0][4 * mb_xy];
} else {
prev_x = s->current_picture.f.motion_val[0][mot_index][0];
prev_y = s->current_picture.f.motion_val[0][mot_index][1];
prev_ref = s->current_picture.f.ref_index[0][4 * mb_xy];
}
mv_predictor[pred_count][0] = prev_x;
mv_predictor[pred_count][1] = prev_y;
ref[pred_count] = prev_ref;
pred_count++;
skip_last_mv:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_skipped = 0;
s->dsp.clear_blocks(s->block[0]);
s->mb_x = mb_x;
s->mb_y = mb_y;
for (j = 0; j < pred_count; j++) {
int score = 0;
uint8_t *src = s->current_picture.f.data[0] +
mb_x * 16 + mb_y * 16 * s->linesize;
s->current_picture.f.motion_val[0][mot_index][0] =
s->mv[0][0][0] = mv_predictor[j][0];
s->current_picture.f.motion_val[0][mot_index][1] =
s->mv[0][0][1] = mv_predictor[j][1];
if (ref[j] < 0)
continue;
decode_mb(s, ref[j]);
if (mb_x > 0 && fixed[mb_xy - 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * s->linesize - 1] -
src[k * s->linesize]);
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * s->linesize + 15] -
src[k * s->linesize + 16]);
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k - s->linesize] - src[k]);
}
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k + s->linesize * 15] -
src[k + s->linesize * 16]);
}
if (score <= best_score) {
best_score = score;
best_pred = j;
}
}
score_sum += best_score;
s->mv[0][0][0] = mv_predictor[best_pred][0];
s->mv[0][0][1] = mv_predictor[best_pred][1];
for (i = 0; i < mot_step; i++)
for (j = 0; j < mot_step; j++) {
s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
}
decode_mb(s, ref[best_pred]);
if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) {
fixed[mb_xy] = MV_CHANGED;
changed++;
} else
fixed[mb_xy] = MV_UNCHANGED;
}
}
}
if (none_left)
goto end;
for (i = 0; i < s->mb_num; i++) {
int mb_xy = s->mb_index2xy[i];
if (fixed[mb_xy])
fixed[mb_xy] = MV_FROZEN;
}
}
end:
av_free(fixed);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MpegEncContext *VAR_0)
{
uint8_t *fixed = av_malloc(VAR_0->VAR_1 * VAR_0->VAR_3);
#define MV_FROZEN 3
#define MV_CHANGED 2
#define MV_UNCHANGED 1
const int VAR_1 = VAR_0->VAR_1;
const int VAR_2 = VAR_0->VAR_2;
const int VAR_3 = VAR_0->VAR_3;
int VAR_4, VAR_5, VAR_6;
int VAR_14, VAR_14, VAR_9, VAR_10;
set_mv_strides(VAR_0, &VAR_9, &VAR_10);
VAR_6 = 0;
for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {
const int mb_xy = VAR_0->mb_index2xy[VAR_4];
int f = 0;
int error = VAR_0->error_status_table[mb_xy];
if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))
f = MV_FROZEN;
if (!(error & ER_MV_ERROR))
f = MV_FROZEN;
fixed[mb_xy] = f;
if (f == MV_FROZEN)
VAR_6++;
else if(VAR_0->last_picture.f.data[0] && VAR_0->last_picture.f.motion_val[0]){
const int VAR_14= mb_xy / VAR_0->VAR_1;
const int VAR_14= mb_xy % VAR_0->VAR_1;
const int mot_index= (VAR_14 + VAR_14*VAR_10) * VAR_9;
VAR_0->current_picture.f.motion_val[0][mot_index][0]= VAR_0->last_picture.f.motion_val[0][mot_index][0];
VAR_0->current_picture.f.motion_val[0][mot_index][1]= VAR_0->last_picture.f.motion_val[0][mot_index][1];
VAR_0->current_picture.f.ref_index[0][4*mb_xy] = VAR_0->last_picture.f.ref_index[0][4*mb_xy];
}
}
if ((!(VAR_0->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
VAR_6 <= VAR_2 / 2) {
for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {
VAR_0->VAR_14 = 0;
VAR_0->VAR_14 = VAR_14;
ff_init_block_index(VAR_0);
for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {
const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;
ff_update_block_index(VAR_0);
if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))
continue;
if (!(VAR_0->error_status_table[mb_xy] & ER_MV_ERROR))
continue;
VAR_0->mv_dir = VAR_0->last_picture.f.data[0] ? MV_DIR_FORWARD
: MV_DIR_BACKWARD;
VAR_0->mb_intra = 0;
VAR_0->mv_type = MV_TYPE_16X16;
VAR_0->mb_skipped = 0;
VAR_0->dsp.clear_blocks(VAR_0->block[0]);
VAR_0->VAR_14 = VAR_14;
VAR_0->VAR_14 = VAR_14;
VAR_0->mv[0][0][0] = 0;
VAR_0->mv[0][0][1] = 0;
decode_mb(VAR_0, 0);
}
}
goto end;
}
for (VAR_5 = 0; ; VAR_5++) {
int VAR_11, VAR_12, VAR_13;
VAR_13 = 1;
VAR_11 = 1;
for (VAR_12 = 0; (VAR_11 || VAR_12 < 2) && VAR_12 < 10; VAR_12++) {
int VAR_14, VAR_14;
int VAR_14 = 0;
VAR_11 = 0;
for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {
VAR_0->VAR_14 = 0;
VAR_0->VAR_14 = VAR_14;
ff_init_block_index(VAR_0);
for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {
const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;
int mv_predictor[8][2] = { { 0 } };
int ref[8] = { 0 };
int pred_count = 0;
int j;
int best_score = 256 * 256 * 256 * 64;
int best_pred = 0;
const int mot_index = (VAR_14 + VAR_14 * VAR_10) * VAR_9;
int prev_x, prev_y, prev_ref;
ff_update_block_index(VAR_0);
if ((VAR_14 ^ VAR_14 ^ VAR_12) & 1)
continue;
if (fixed[mb_xy] == MV_FROZEN)
continue;
assert(!IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]));
assert(VAR_0->last_picture_ptr && VAR_0->last_picture_ptr->f.data[0]);
j = 0;
if (VAR_14 > 0 && fixed[mb_xy - 1] == MV_FROZEN)
j = 1;
if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1] == MV_FROZEN)
j = 1;
if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_FROZEN)
j = 1;
if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_FROZEN)
j = 1;
if (j == 0)
continue;
j = 0;
if (VAR_14 > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)
j = 1;
if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1 ] == MV_CHANGED)
j = 1;
if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_CHANGED)
j = 1;
if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_CHANGED)
j = 1;
if (j == 0 && VAR_12 > 1)
continue;
VAR_13 = 0;
if (VAR_14 > 0 && fixed[mb_xy - 1]) {
mv_predictor[pred_count][0] =
VAR_0->current_picture.f.motion_val[0][mot_index - VAR_9][0];
mv_predictor[pred_count][1] =
VAR_0->current_picture.f.motion_val[0][mot_index - VAR_9][1];
ref[pred_count] =
VAR_0->current_picture.f.ref_index[0][4 * (mb_xy - 1)];
pred_count++;
}
if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {
mv_predictor[pred_count][0] =
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_9][0];
mv_predictor[pred_count][1] =
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_9][1];
ref[pred_count] =
VAR_0->current_picture.f.ref_index[0][4 * (mb_xy + 1)];
pred_count++;
}
if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {
mv_predictor[pred_count][0] =
VAR_0->current_picture.f.motion_val[0][mot_index - VAR_10 * VAR_9][0];
mv_predictor[pred_count][1] =
VAR_0->current_picture.f.motion_val[0][mot_index - VAR_10 * VAR_9][1];
ref[pred_count] =
VAR_0->current_picture.f.ref_index[0][4 * (mb_xy - VAR_0->VAR_1)];
pred_count++;
}
if (VAR_14 + 1<VAR_3 && fixed[mb_xy + VAR_1]) {
mv_predictor[pred_count][0] =
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_10 * VAR_9][0];
mv_predictor[pred_count][1] =
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_10 * VAR_9][1];
ref[pred_count] =
VAR_0->current_picture.f.ref_index[0][4 * (mb_xy + VAR_0->VAR_1)];
pred_count++;
}
if (pred_count == 0)
continue;
if (pred_count > 1) {
int sum_x = 0, sum_y = 0, sum_r = 0;
int max_x, max_y, min_x, min_y, max_r, min_r;
for (j = 0; j < pred_count; j++) {
sum_x += mv_predictor[j][0];
sum_y += mv_predictor[j][1];
sum_r += ref[j];
if (j && ref[j] != ref[j - 1])
goto skip_mean_and_median;
}
mv_predictor[pred_count][0] = sum_x / j;
mv_predictor[pred_count][1] = sum_y / j;
ref[pred_count] = sum_r / j;
if (pred_count >= 3) {
min_y = min_x = min_r = 99999;
max_y = max_x = max_r = -99999;
} else {
min_x = min_y = max_x = max_y = min_r = max_r = 0;
}
for (j = 0; j < pred_count; j++) {
max_x = FFMAX(max_x, mv_predictor[j][0]);
max_y = FFMAX(max_y, mv_predictor[j][1]);
max_r = FFMAX(max_r, ref[j]);
min_x = FFMIN(min_x, mv_predictor[j][0]);
min_y = FFMIN(min_y, mv_predictor[j][1]);
min_r = FFMIN(min_r, ref[j]);
}
mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
ref[pred_count + 1] = sum_r - max_r - min_r;
if (pred_count == 4) {
mv_predictor[pred_count + 1][0] /= 2;
mv_predictor[pred_count + 1][1] /= 2;
ref[pred_count + 1] /= 2;
}
pred_count += 2;
}
skip_mean_and_median:
pred_count++;
if (!fixed[mb_xy] && 0) {
if (VAR_0->avctx->codec_id == CODEC_ID_H264) {
} else {
ff_thread_await_progress(&VAR_0->last_picture_ptr->f,
VAR_14, 0);
}
if (!VAR_0->last_picture.f.motion_val[0] ||
!VAR_0->last_picture.f.ref_index[0])
goto skip_last_mv;
prev_x = VAR_0->last_picture.f.motion_val[0][mot_index][0];
prev_y = VAR_0->last_picture.f.motion_val[0][mot_index][1];
prev_ref = VAR_0->last_picture.f.ref_index[0][4 * mb_xy];
} else {
prev_x = VAR_0->current_picture.f.motion_val[0][mot_index][0];
prev_y = VAR_0->current_picture.f.motion_val[0][mot_index][1];
prev_ref = VAR_0->current_picture.f.ref_index[0][4 * mb_xy];
}
mv_predictor[pred_count][0] = prev_x;
mv_predictor[pred_count][1] = prev_y;
ref[pred_count] = prev_ref;
pred_count++;
skip_last_mv:
VAR_0->mv_dir = MV_DIR_FORWARD;
VAR_0->mb_intra = 0;
VAR_0->mv_type = MV_TYPE_16X16;
VAR_0->mb_skipped = 0;
VAR_0->dsp.clear_blocks(VAR_0->block[0]);
VAR_0->VAR_14 = VAR_14;
VAR_0->VAR_14 = VAR_14;
for (j = 0; j < pred_count; j++) {
int score = 0;
uint8_t *src = VAR_0->current_picture.f.data[0] +
VAR_14 * 16 + VAR_14 * 16 * VAR_0->linesize;
VAR_0->current_picture.f.motion_val[0][mot_index][0] =
VAR_0->mv[0][0][0] = mv_predictor[j][0];
VAR_0->current_picture.f.motion_val[0][mot_index][1] =
VAR_0->mv[0][0][1] = mv_predictor[j][1];
if (ref[j] < 0)
continue;
decode_mb(VAR_0, ref[j]);
if (VAR_14 > 0 && fixed[mb_xy - 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * VAR_0->linesize - 1] -
src[k * VAR_0->linesize]);
}
if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * VAR_0->linesize + 15] -
src[k * VAR_0->linesize + 16]);
}
if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k - VAR_0->linesize] - src[k]);
}
if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k + VAR_0->linesize * 15] -
src[k + VAR_0->linesize * 16]);
}
if (score <= best_score) {
best_score = score;
best_pred = j;
}
}
VAR_14 += best_score;
VAR_0->mv[0][0][0] = mv_predictor[best_pred][0];
VAR_0->mv[0][0][1] = mv_predictor[best_pred][1];
for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++)
for (j = 0; j < VAR_9; j++) {
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_4 + j * VAR_10][0] = VAR_0->mv[0][0][0];
VAR_0->current_picture.f.motion_val[0][mot_index + VAR_4 + j * VAR_10][1] = VAR_0->mv[0][0][1];
}
decode_mb(VAR_0, ref[best_pred]);
if (VAR_0->mv[0][0][0] != prev_x || VAR_0->mv[0][0][1] != prev_y) {
fixed[mb_xy] = MV_CHANGED;
VAR_11++;
} else
fixed[mb_xy] = MV_UNCHANGED;
}
}
}
if (VAR_13)
goto end;
for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {
int mb_xy = VAR_0->mb_index2xy[VAR_4];
if (fixed[mb_xy])
fixed[mb_xy] = MV_FROZEN;
}
}
end:
av_free(fixed);
}
| [
"static void FUNC_0(MpegEncContext *VAR_0)\n{",
"uint8_t *fixed = av_malloc(VAR_0->VAR_1 * VAR_0->VAR_3);",
"#define MV_FROZEN 3\n#define MV_CHANGED 2\n#define MV_UNCHANGED 1\nconst int VAR_1 = VAR_0->VAR_1;",
"const int VAR_2 = VAR_0->VAR_2;",
"const int VAR_3 = VAR_0->VAR_3;",
"int VAR_4, VAR_5, VAR_6;",
"int VAR_14, VAR_14, VAR_9, VAR_10;",
"set_mv_strides(VAR_0, &VAR_9, &VAR_10);",
"VAR_6 = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {",
"const int mb_xy = VAR_0->mb_index2xy[VAR_4];",
"int f = 0;",
"int error = VAR_0->error_status_table[mb_xy];",
"if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))\nf = MV_FROZEN;",
"if (!(error & ER_MV_ERROR))\nf = MV_FROZEN;",
"fixed[mb_xy] = f;",
"if (f == MV_FROZEN)\nVAR_6++;",
"else if(VAR_0->last_picture.f.data[0] && VAR_0->last_picture.f.motion_val[0]){",
"const int VAR_14= mb_xy / VAR_0->VAR_1;",
"const int VAR_14= mb_xy % VAR_0->VAR_1;",
"const int mot_index= (VAR_14 + VAR_14*VAR_10) * VAR_9;",
"VAR_0->current_picture.f.motion_val[0][mot_index][0]= VAR_0->last_picture.f.motion_val[0][mot_index][0];",
"VAR_0->current_picture.f.motion_val[0][mot_index][1]= VAR_0->last_picture.f.motion_val[0][mot_index][1];",
"VAR_0->current_picture.f.ref_index[0][4*mb_xy] = VAR_0->last_picture.f.ref_index[0][4*mb_xy];",
"}",
"}",
"if ((!(VAR_0->avctx->error_concealment&FF_EC_GUESS_MVS)) ||\nVAR_6 <= VAR_2 / 2) {",
"for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {",
"VAR_0->VAR_14 = 0;",
"VAR_0->VAR_14 = VAR_14;",
"ff_init_block_index(VAR_0);",
"for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {",
"const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;",
"ff_update_block_index(VAR_0);",
"if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))\ncontinue;",
"if (!(VAR_0->error_status_table[mb_xy] & ER_MV_ERROR))\ncontinue;",
"VAR_0->mv_dir = VAR_0->last_picture.f.data[0] ? MV_DIR_FORWARD\n: MV_DIR_BACKWARD;",
"VAR_0->mb_intra = 0;",
"VAR_0->mv_type = MV_TYPE_16X16;",
"VAR_0->mb_skipped = 0;",
"VAR_0->dsp.clear_blocks(VAR_0->block[0]);",
"VAR_0->VAR_14 = VAR_14;",
"VAR_0->VAR_14 = VAR_14;",
"VAR_0->mv[0][0][0] = 0;",
"VAR_0->mv[0][0][1] = 0;",
"decode_mb(VAR_0, 0);",
"}",
"}",
"goto end;",
"}",
"for (VAR_5 = 0; ; VAR_5++) {",
"int VAR_11, VAR_12, VAR_13;",
"VAR_13 = 1;",
"VAR_11 = 1;",
"for (VAR_12 = 0; (VAR_11 || VAR_12 < 2) && VAR_12 < 10; VAR_12++) {",
"int VAR_14, VAR_14;",
"int VAR_14 = 0;",
"VAR_11 = 0;",
"for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {",
"VAR_0->VAR_14 = 0;",
"VAR_0->VAR_14 = VAR_14;",
"ff_init_block_index(VAR_0);",
"for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {",
"const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;",
"int mv_predictor[8][2] = { { 0 } };",
"int ref[8] = { 0 };",
"int pred_count = 0;",
"int j;",
"int best_score = 256 * 256 * 256 * 64;",
"int best_pred = 0;",
"const int mot_index = (VAR_14 + VAR_14 * VAR_10) * VAR_9;",
"int prev_x, prev_y, prev_ref;",
"ff_update_block_index(VAR_0);",
"if ((VAR_14 ^ VAR_14 ^ VAR_12) & 1)\ncontinue;",
"if (fixed[mb_xy] == MV_FROZEN)\ncontinue;",
"assert(!IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]));",
"assert(VAR_0->last_picture_ptr && VAR_0->last_picture_ptr->f.data[0]);",
"j = 0;",
"if (VAR_14 > 0 && fixed[mb_xy - 1] == MV_FROZEN)\nj = 1;",
"if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1] == MV_FROZEN)\nj = 1;",
"if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_FROZEN)\nj = 1;",
"if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_FROZEN)\nj = 1;",
"if (j == 0)\ncontinue;",
"j = 0;",
"if (VAR_14 > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)\nj = 1;",
"if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1 ] == MV_CHANGED)\nj = 1;",
"if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_CHANGED)\nj = 1;",
"if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_CHANGED)\nj = 1;",
"if (j == 0 && VAR_12 > 1)\ncontinue;",
"VAR_13 = 0;",
"if (VAR_14 > 0 && fixed[mb_xy - 1]) {",
"mv_predictor[pred_count][0] =\nVAR_0->current_picture.f.motion_val[0][mot_index - VAR_9][0];",
"mv_predictor[pred_count][1] =\nVAR_0->current_picture.f.motion_val[0][mot_index - VAR_9][1];",
"ref[pred_count] =\nVAR_0->current_picture.f.ref_index[0][4 * (mb_xy - 1)];",
"pred_count++;",
"}",
"if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {",
"mv_predictor[pred_count][0] =\nVAR_0->current_picture.f.motion_val[0][mot_index + VAR_9][0];",
"mv_predictor[pred_count][1] =\nVAR_0->current_picture.f.motion_val[0][mot_index + VAR_9][1];",
"ref[pred_count] =\nVAR_0->current_picture.f.ref_index[0][4 * (mb_xy + 1)];",
"pred_count++;",
"}",
"if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {",
"mv_predictor[pred_count][0] =\nVAR_0->current_picture.f.motion_val[0][mot_index - VAR_10 * VAR_9][0];",
"mv_predictor[pred_count][1] =\nVAR_0->current_picture.f.motion_val[0][mot_index - VAR_10 * VAR_9][1];",
"ref[pred_count] =\nVAR_0->current_picture.f.ref_index[0][4 * (mb_xy - VAR_0->VAR_1)];",
"pred_count++;",
"}",
"if (VAR_14 + 1<VAR_3 && fixed[mb_xy + VAR_1]) {",
"mv_predictor[pred_count][0] =\nVAR_0->current_picture.f.motion_val[0][mot_index + VAR_10 * VAR_9][0];",
"mv_predictor[pred_count][1] =\nVAR_0->current_picture.f.motion_val[0][mot_index + VAR_10 * VAR_9][1];",
"ref[pred_count] =\nVAR_0->current_picture.f.ref_index[0][4 * (mb_xy + VAR_0->VAR_1)];",
"pred_count++;",
"}",
"if (pred_count == 0)\ncontinue;",
"if (pred_count > 1) {",
"int sum_x = 0, sum_y = 0, sum_r = 0;",
"int max_x, max_y, min_x, min_y, max_r, min_r;",
"for (j = 0; j < pred_count; j++) {",
"sum_x += mv_predictor[j][0];",
"sum_y += mv_predictor[j][1];",
"sum_r += ref[j];",
"if (j && ref[j] != ref[j - 1])\ngoto skip_mean_and_median;",
"}",
"mv_predictor[pred_count][0] = sum_x / j;",
"mv_predictor[pred_count][1] = sum_y / j;",
"ref[pred_count] = sum_r / j;",
"if (pred_count >= 3) {",
"min_y = min_x = min_r = 99999;",
"max_y = max_x = max_r = -99999;",
"} else {",
"min_x = min_y = max_x = max_y = min_r = max_r = 0;",
"}",
"for (j = 0; j < pred_count; j++) {",
"max_x = FFMAX(max_x, mv_predictor[j][0]);",
"max_y = FFMAX(max_y, mv_predictor[j][1]);",
"max_r = FFMAX(max_r, ref[j]);",
"min_x = FFMIN(min_x, mv_predictor[j][0]);",
"min_y = FFMIN(min_y, mv_predictor[j][1]);",
"min_r = FFMIN(min_r, ref[j]);",
"}",
"mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;",
"mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;",
"ref[pred_count + 1] = sum_r - max_r - min_r;",
"if (pred_count == 4) {",
"mv_predictor[pred_count + 1][0] /= 2;",
"mv_predictor[pred_count + 1][1] /= 2;",
"ref[pred_count + 1] /= 2;",
"}",
"pred_count += 2;",
"}",
"skip_mean_and_median:\npred_count++;",
"if (!fixed[mb_xy] && 0) {",
"if (VAR_0->avctx->codec_id == CODEC_ID_H264) {",
"} else {",
"ff_thread_await_progress(&VAR_0->last_picture_ptr->f,\nVAR_14, 0);",
"}",
"if (!VAR_0->last_picture.f.motion_val[0] ||\n!VAR_0->last_picture.f.ref_index[0])\ngoto skip_last_mv;",
"prev_x = VAR_0->last_picture.f.motion_val[0][mot_index][0];",
"prev_y = VAR_0->last_picture.f.motion_val[0][mot_index][1];",
"prev_ref = VAR_0->last_picture.f.ref_index[0][4 * mb_xy];",
"} else {",
"prev_x = VAR_0->current_picture.f.motion_val[0][mot_index][0];",
"prev_y = VAR_0->current_picture.f.motion_val[0][mot_index][1];",
"prev_ref = VAR_0->current_picture.f.ref_index[0][4 * mb_xy];",
"}",
"mv_predictor[pred_count][0] = prev_x;",
"mv_predictor[pred_count][1] = prev_y;",
"ref[pred_count] = prev_ref;",
"pred_count++;",
"skip_last_mv:\nVAR_0->mv_dir = MV_DIR_FORWARD;",
"VAR_0->mb_intra = 0;",
"VAR_0->mv_type = MV_TYPE_16X16;",
"VAR_0->mb_skipped = 0;",
"VAR_0->dsp.clear_blocks(VAR_0->block[0]);",
"VAR_0->VAR_14 = VAR_14;",
"VAR_0->VAR_14 = VAR_14;",
"for (j = 0; j < pred_count; j++) {",
"int score = 0;",
"uint8_t *src = VAR_0->current_picture.f.data[0] +\nVAR_14 * 16 + VAR_14 * 16 * VAR_0->linesize;",
"VAR_0->current_picture.f.motion_val[0][mot_index][0] =\nVAR_0->mv[0][0][0] = mv_predictor[j][0];",
"VAR_0->current_picture.f.motion_val[0][mot_index][1] =\nVAR_0->mv[0][0][1] = mv_predictor[j][1];",
"if (ref[j] < 0)\ncontinue;",
"decode_mb(VAR_0, ref[j]);",
"if (VAR_14 > 0 && fixed[mb_xy - 1]) {",
"int k;",
"for (k = 0; k < 16; k++)",
"score += FFABS(src[k * VAR_0->linesize - 1] -\nsrc[k * VAR_0->linesize]);",
"}",
"if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {",
"int k;",
"for (k = 0; k < 16; k++)",
"score += FFABS(src[k * VAR_0->linesize + 15] -\nsrc[k * VAR_0->linesize + 16]);",
"}",
"if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {",
"int k;",
"for (k = 0; k < 16; k++)",
"score += FFABS(src[k - VAR_0->linesize] - src[k]);",
"}",
"if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1]) {",
"int k;",
"for (k = 0; k < 16; k++)",
"score += FFABS(src[k + VAR_0->linesize * 15] -\nsrc[k + VAR_0->linesize * 16]);",
"}",
"if (score <= best_score) {",
"best_score = score;",
"best_pred = j;",
"}",
"}",
"VAR_14 += best_score;",
"VAR_0->mv[0][0][0] = mv_predictor[best_pred][0];",
"VAR_0->mv[0][0][1] = mv_predictor[best_pred][1];",
"for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++)",
"for (j = 0; j < VAR_9; j++) {",
"VAR_0->current_picture.f.motion_val[0][mot_index + VAR_4 + j * VAR_10][0] = VAR_0->mv[0][0][0];",
"VAR_0->current_picture.f.motion_val[0][mot_index + VAR_4 + j * VAR_10][1] = VAR_0->mv[0][0][1];",
"}",
"decode_mb(VAR_0, ref[best_pred]);",
"if (VAR_0->mv[0][0][0] != prev_x || VAR_0->mv[0][0][1] != prev_y) {",
"fixed[mb_xy] = MV_CHANGED;",
"VAR_11++;",
"} else",
"fixed[mb_xy] = MV_UNCHANGED;",
"}",
"}",
"}",
"if (VAR_13)\ngoto end;",
"for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {",
"int mb_xy = VAR_0->mb_index2xy[VAR_4];",
"if (fixed[mb_xy])\nfixed[mb_xy] = MV_FROZEN;",
"}",
"}",
"end:\nav_free(fixed);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45,
47
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99,
101
],
[
103,
105
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
199,
201
],
[
205,
207
],
[
209
],
[
211
],
[
215
],
[
217,
219
],
[
221,
223
],
[
225,
227
],
[
229,
231
],
[
233,
235
],
[
239
],
[
241,
243
],
[
245,
247
],
[
249,
251
],
[
253,
255
],
[
257,
259
],
[
263
],
[
267
],
[
269,
271
],
[
273,
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287,
289
],
[
291,
293
],
[
295,
297
],
[
299
],
[
301
],
[
303
],
[
305,
307
],
[
309,
311
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327,
329
],
[
331,
333
],
[
335
],
[
337
],
[
339,
341
],
[
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
371
],
[
373
],
[
375
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
433,
437
],
[
441
],
[
443
],
[
447
],
[
449,
451
],
[
453
],
[
455,
457,
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
481
],
[
483
],
[
485
],
[
487
],
[
491,
493
],
[
495
],
[
497
],
[
499
],
[
503
],
[
507
],
[
509
],
[
513
],
[
515
],
[
517,
519
],
[
523,
525
],
[
527,
529
],
[
535,
537
],
[
541
],
[
545
],
[
547
],
[
549
],
[
551,
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563,
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585,
587
],
[
589
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
623
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
647
],
[
651,
653
],
[
657
],
[
659
],
[
661,
663
],
[
665
],
[
669
],
[
671,
673
],
[
675
]
] |
4,826 | static void audio_reset_timer (AudioState *s)
{
if (audio_is_timer_needed ()) {
timer_mod (s->ts,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
}
else {
timer_del (s->ts);
}
}
| false | qemu | 1ffc266539d443f83d5eb487593be50ef496f09e | static void audio_reset_timer (AudioState *s)
{
if (audio_is_timer_needed ()) {
timer_mod (s->ts,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
}
else {
timer_del (s->ts);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (AudioState *VAR_0)
{
if (audio_is_timer_needed ()) {
timer_mod (VAR_0->ts,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
}
else {
timer_del (VAR_0->ts);
}
}
| [
"static void FUNC_0 (AudioState *VAR_0)\n{",
"if (audio_is_timer_needed ()) {",
"timer_mod (VAR_0->ts,\nqemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);",
"}",
"else {",
"timer_del (VAR_0->ts);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
4,827 | int bdrv_get_translation_hint(BlockDriverState *bs)
{
return bs->translation;
}
| false | qemu | 2b584959ed300ddff4acba0d7554becad5f274fd | int bdrv_get_translation_hint(BlockDriverState *bs)
{
return bs->translation;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0)
{
return VAR_0->translation;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"return VAR_0->translation;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
4,828 | static int omap_validate_emifs_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return range_covers_byte(OMAP_EMIFS_BASE, OMAP_EMIFF_BASE - OMAP_EMIFS_BASE,
addr);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static int omap_validate_emifs_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return range_covers_byte(OMAP_EMIFS_BASE, OMAP_EMIFF_BASE - OMAP_EMIFS_BASE,
addr);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct omap_mpu_state_s *VAR_0,
target_phys_addr_t VAR_1)
{
return range_covers_byte(OMAP_EMIFS_BASE, OMAP_EMIFF_BASE - OMAP_EMIFS_BASE,
VAR_1);
}
| [
"static int FUNC_0(struct omap_mpu_state_s *VAR_0,\ntarget_phys_addr_t VAR_1)\n{",
"return range_covers_byte(OMAP_EMIFS_BASE, OMAP_EMIFF_BASE - OMAP_EMIFS_BASE,\nVAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
4,829 | StringOutputVisitor *string_output_visitor_new(bool human)
{
StringOutputVisitor *v;
v = g_malloc0(sizeof(*v));
v->string = g_string_new(NULL);
v->human = human;
v->visitor.type = VISITOR_OUTPUT;
v->visitor.type_int64 = print_type_int64;
v->visitor.type_uint64 = print_type_uint64;
v->visitor.type_size = print_type_size;
v->visitor.type_bool = print_type_bool;
v->visitor.type_str = print_type_str;
v->visitor.type_number = print_type_number;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
v->visitor.free = string_output_free;
return v;
}
| false | qemu | 3b098d56979d2f7fd707c5be85555d114353a28d | StringOutputVisitor *string_output_visitor_new(bool human)
{
StringOutputVisitor *v;
v = g_malloc0(sizeof(*v));
v->string = g_string_new(NULL);
v->human = human;
v->visitor.type = VISITOR_OUTPUT;
v->visitor.type_int64 = print_type_int64;
v->visitor.type_uint64 = print_type_uint64;
v->visitor.type_size = print_type_size;
v->visitor.type_bool = print_type_bool;
v->visitor.type_str = print_type_str;
v->visitor.type_number = print_type_number;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
v->visitor.free = string_output_free;
return v;
}
| {
"code": [],
"line_no": []
} | StringOutputVisitor *FUNC_0(bool human)
{
StringOutputVisitor *v;
v = g_malloc0(sizeof(*v));
v->string = g_string_new(NULL);
v->human = human;
v->visitor.type = VISITOR_OUTPUT;
v->visitor.type_int64 = print_type_int64;
v->visitor.type_uint64 = print_type_uint64;
v->visitor.type_size = print_type_size;
v->visitor.type_bool = print_type_bool;
v->visitor.type_str = print_type_str;
v->visitor.type_number = print_type_number;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
v->visitor.free = string_output_free;
return v;
}
| [
"StringOutputVisitor *FUNC_0(bool human)\n{",
"StringOutputVisitor *v;",
"v = g_malloc0(sizeof(*v));",
"v->string = g_string_new(NULL);",
"v->human = human;",
"v->visitor.type = VISITOR_OUTPUT;",
"v->visitor.type_int64 = print_type_int64;",
"v->visitor.type_uint64 = print_type_uint64;",
"v->visitor.type_size = print_type_size;",
"v->visitor.type_bool = print_type_bool;",
"v->visitor.type_str = print_type_str;",
"v->visitor.type_number = print_type_number;",
"v->visitor.start_list = start_list;",
"v->visitor.next_list = next_list;",
"v->visitor.end_list = end_list;",
"v->visitor.free = string_output_free;",
"return v;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
4,831 | int qemu_input_key_value_to_number(const KeyValue *value)
{
if (value->kind == KEY_VALUE_KIND_QCODE) {
return qcode_to_number[value->qcode];
} else {
assert(value->kind == KEY_VALUE_KIND_NUMBER);
return value->number;
}
}
| false | qemu | 568c73a4783cd981e9aa6de4f15dcda7829643ad | int qemu_input_key_value_to_number(const KeyValue *value)
{
if (value->kind == KEY_VALUE_KIND_QCODE) {
return qcode_to_number[value->qcode];
} else {
assert(value->kind == KEY_VALUE_KIND_NUMBER);
return value->number;
}
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const KeyValue *VAR_0)
{
if (VAR_0->kind == KEY_VALUE_KIND_QCODE) {
return qcode_to_number[VAR_0->qcode];
} else {
assert(VAR_0->kind == KEY_VALUE_KIND_NUMBER);
return VAR_0->number;
}
}
| [
"int FUNC_0(const KeyValue *VAR_0)\n{",
"if (VAR_0->kind == KEY_VALUE_KIND_QCODE) {",
"return qcode_to_number[VAR_0->qcode];",
"} else {",
"assert(VAR_0->kind == KEY_VALUE_KIND_NUMBER);",
"return VAR_0->number;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,833 | uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,
uint64_t new_lo, uint64_t new_hi)
{
uintptr_t ra = GETPC();
Int128 oldv, cmpv, newv;
bool success;
cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
newv = int128_make128(new_lo, new_hi);
if (parallel_cpus) {
#ifndef CONFIG_ATOMIC128
cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);
#else
int mem_idx = cpu_mmu_index(env, false);
TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx);
oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra);
success = int128_eq(oldv, cmpv);
#endif
} else {
uint64_t o0, o1;
#ifdef CONFIG_USER_ONLY
/* ??? Enforce alignment. */
uint64_t *haddr = g2h(addr);
o1 = ldq_be_p(haddr + 0);
o0 = ldq_be_p(haddr + 1);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
stq_be_p(haddr + 0, int128_gethi(newv));
stq_be_p(haddr + 1, int128_getlo(newv));
}
#else
int mem_idx = cpu_mmu_index(env, false);
TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx);
TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx);
o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);
o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra);
helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra);
}
#endif
}
return !success;
}
| false | qemu | 2399d4e7cec22ecf1c51062d2ebfd45220dbaace | uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,
uint64_t new_lo, uint64_t new_hi)
{
uintptr_t ra = GETPC();
Int128 oldv, cmpv, newv;
bool success;
cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
newv = int128_make128(new_lo, new_hi);
if (parallel_cpus) {
#ifndef CONFIG_ATOMIC128
cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);
#else
int mem_idx = cpu_mmu_index(env, false);
TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx);
oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra);
success = int128_eq(oldv, cmpv);
#endif
} else {
uint64_t o0, o1;
#ifdef CONFIG_USER_ONLY
uint64_t *haddr = g2h(addr);
o1 = ldq_be_p(haddr + 0);
o0 = ldq_be_p(haddr + 1);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
stq_be_p(haddr + 0, int128_gethi(newv));
stq_be_p(haddr + 1, int128_getlo(newv));
}
#else
int mem_idx = cpu_mmu_index(env, false);
TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx);
TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx);
o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);
o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra);
helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra);
}
#endif
}
return !success;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,
uint64_t new_lo, uint64_t new_hi)
{
uintptr_t ra = GETPC();
Int128 oldv, cmpv, newv;
bool success;
cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
newv = int128_make128(new_lo, new_hi);
if (parallel_cpus) {
#ifndef CONFIG_ATOMIC128
cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);
#else
int VAR_0 = cpu_mmu_index(env, false);
TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, VAR_0);
oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra);
success = int128_eq(oldv, cmpv);
#endif
} else {
uint64_t o0, o1;
#ifdef CONFIG_USER_ONLY
uint64_t *haddr = g2h(addr);
o1 = ldq_be_p(haddr + 0);
o0 = ldq_be_p(haddr + 1);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
stq_be_p(haddr + 0, int128_gethi(newv));
stq_be_p(haddr + 1, int128_getlo(newv));
}
#else
int VAR_0 = cpu_mmu_index(env, false);
TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, VAR_0);
TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, VAR_0);
o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);
o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);
oldv = int128_make128(o0, o1);
success = int128_eq(oldv, cmpv);
if (success) {
helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra);
helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra);
}
#endif
}
return !success;
}
| [
"uint64_t FUNC_0(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,\nuint64_t new_lo, uint64_t new_hi)\n{",
"uintptr_t ra = GETPC();",
"Int128 oldv, cmpv, newv;",
"bool success;",
"cmpv = int128_make128(env->exclusive_val, env->exclusive_high);",
"newv = int128_make128(new_lo, new_hi);",
"if (parallel_cpus) {",
"#ifndef CONFIG_ATOMIC128\ncpu_loop_exit_atomic(ENV_GET_CPU(env), ra);",
"#else\nint VAR_0 = cpu_mmu_index(env, false);",
"TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, VAR_0);",
"oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra);",
"success = int128_eq(oldv, cmpv);",
"#endif\n} else {",
"uint64_t o0, o1;",
"#ifdef CONFIG_USER_ONLY\nuint64_t *haddr = g2h(addr);",
"o1 = ldq_be_p(haddr + 0);",
"o0 = ldq_be_p(haddr + 1);",
"oldv = int128_make128(o0, o1);",
"success = int128_eq(oldv, cmpv);",
"if (success) {",
"stq_be_p(haddr + 0, int128_gethi(newv));",
"stq_be_p(haddr + 1, int128_getlo(newv));",
"}",
"#else\nint VAR_0 = cpu_mmu_index(env, false);",
"TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, VAR_0);",
"TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, VAR_0);",
"o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);",
"o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);",
"oldv = int128_make128(o0, o1);",
"success = int128_eq(oldv, cmpv);",
"if (success) {",
"helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra);",
"helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra);",
"}",
"#endif\n}",
"return !success;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
45,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
103
],
[
105
]
] |
4,834 | void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload)
{
/*
* Artificially limit timeout rate to something
* achievable under QEMU. Otherwise, QEMU spends all
* its time generating timer interrupts, and there
* is no forward progress.
* About ten microseconds is the fastest that really works
* on the current generation of host machines.
*/
if (!use_icount && limit * s->period < 10000 && s->period) {
limit = 10000 / s->period;
}
s->limit = limit;
if (reload)
s->delta = limit;
if (s->enabled && reload) {
s->next_event = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ptimer_reload(s);
}
}
| false | qemu | e91171e30235ae99ab8060988aa3c9536692bba8 | void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload)
{
if (!use_icount && limit * s->period < 10000 && s->period) {
limit = 10000 / s->period;
}
s->limit = limit;
if (reload)
s->delta = limit;
if (s->enabled && reload) {
s->next_event = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ptimer_reload(s);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ptimer_state *VAR_0, uint64_t VAR_1, int VAR_2)
{
if (!use_icount && VAR_1 * VAR_0->period < 10000 && VAR_0->period) {
VAR_1 = 10000 / VAR_0->period;
}
VAR_0->VAR_1 = VAR_1;
if (VAR_2)
VAR_0->delta = VAR_1;
if (VAR_0->enabled && VAR_2) {
VAR_0->next_event = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ptimer_reload(VAR_0);
}
}
| [
"void FUNC_0(ptimer_state *VAR_0, uint64_t VAR_1, int VAR_2)\n{",
"if (!use_icount && VAR_1 * VAR_0->period < 10000 && VAR_0->period) {",
"VAR_1 = 10000 / VAR_0->period;",
"}",
"VAR_0->VAR_1 = VAR_1;",
"if (VAR_2)\nVAR_0->delta = VAR_1;",
"if (VAR_0->enabled && VAR_2) {",
"VAR_0->next_event = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);",
"ptimer_reload(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
4,836 | static inline void conv_to_int32(int32_t *loc, float *samples, int num, float norm)
{
int i;
for (i = 0; i < num; i++)
loc[i] = ceilf((samples[i]/norm)*INT32_MAX);
}
| false | FFmpeg | f20b67173ca6a05b8c3dee02dad3b7243b96292b | static inline void conv_to_int32(int32_t *loc, float *samples, int num, float norm)
{
int i;
for (i = 0; i < num; i++)
loc[i] = ceilf((samples[i]/norm)*INT32_MAX);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int32_t *VAR_0, float *VAR_1, int VAR_2, float VAR_3)
{
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
VAR_0[VAR_4] = ceilf((VAR_1[VAR_4]/VAR_3)*INT32_MAX);
}
| [
"static inline void FUNC_0(int32_t *VAR_0, float *VAR_1, int VAR_2, float VAR_3)\n{",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"VAR_0[VAR_4] = ceilf((VAR_1[VAR_4]/VAR_3)*INT32_MAX);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
4,837 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \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"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %1, %%"REG_D" \n\t" // buf1
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2)
#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--) {
//printf("%d %d %d\n", dstWidth, i, srcW);
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif /* COMPILE_TEMPLATE_MMX2 */
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
x86_reg dstWidth_reg = dstWidth;
__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"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"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 $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
/* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC 4.0. */
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"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]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif /* ARCH_X86 */
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \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"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2)
#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] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg xInc_shr16 = (x86_reg) (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"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"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]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int VAR_0;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \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"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2)
#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] = src1[srcW-1]*128;
dst[VAR_0+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg xInc_shr16 = (x86_reg) (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"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"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]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[VAR_0+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
VAR_1+=xInc;
}
#endif
}
| [
"static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst,\nlong dstWidth, const uint8_t *src1,\nconst uint8_t *src2, int srcW, int xInc)\n{",
"#if ARCH_X86\n#if COMPILE_TEMPLATE_MMX2\nint32_t *filterPos = c->hChrFilterPos;",
"int16_t *filter = c->hChrFilter;",
"int canMMX2BeUsed = c->canMMX2BeUsed;",
"void *mmx2FilterCode= c->chrMmx2FilterCode;",
"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\", %6 \\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\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"mov %5, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"add $\"AV_STRINGIFY(VOF)\", %%\"REG_D\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n#if defined(PIC)\n\"mov %6, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src1), \"m\" (dst), \"m\" (filter), \"m\" (filterPos),\n\"m\" (mmx2FilterCode), \"m\" (src2)\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] = src1[srcW-1]*128;",
"dst[VAR_0+VOFW] = src2[srcW-1]*128;",
"}",
"} else {",
"#endif\nx86_reg xInc_shr16 = (x86_reg) (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\"mov %0, %%\"REG_S\" \\n\\t\"\n\"movzbl (%%\"REG_S\", %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%%\"REG_S\", %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"movzbl (%5, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%5, %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, \"AV_STRINGIFY(VOF)\"(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"add $1, %%\"REG_a\" \\n\\t\"\n\"cmp %2, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)\n:: \"m\" (src1), \"m\" (dst), \"g\" (dstWidth_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" (dstWidth_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#endif\n\"r\" (src2)\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]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);",
"dst[VAR_0+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*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,
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,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
83,
85,
87,
89,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
163,
165,
167,
169,
173,
175,
177,
179,
181,
189,
191,
193,
195,
197,
199,
201,
203
],
[
205,
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
235
],
[
237
],
[
239,
241
]
] |
4,838 | static void ga_channel_listen_close(GAChannel *c)
{
g_assert(c->method == GA_CHANNEL_UNIX_LISTEN);
g_assert(c->listen_channel);
g_io_channel_shutdown(c->listen_channel, true, NULL);
g_io_channel_unref(c->listen_channel);
c->listen_channel = NULL;
}
| false | qemu | f06b2031a31cdd3acf6f61a977e505b8c6b58f73 | static void ga_channel_listen_close(GAChannel *c)
{
g_assert(c->method == GA_CHANNEL_UNIX_LISTEN);
g_assert(c->listen_channel);
g_io_channel_shutdown(c->listen_channel, true, NULL);
g_io_channel_unref(c->listen_channel);
c->listen_channel = NULL;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GAChannel *VAR_0)
{
g_assert(VAR_0->method == GA_CHANNEL_UNIX_LISTEN);
g_assert(VAR_0->listen_channel);
g_io_channel_shutdown(VAR_0->listen_channel, true, NULL);
g_io_channel_unref(VAR_0->listen_channel);
VAR_0->listen_channel = NULL;
}
| [
"static void FUNC_0(GAChannel *VAR_0)\n{",
"g_assert(VAR_0->method == GA_CHANNEL_UNIX_LISTEN);",
"g_assert(VAR_0->listen_channel);",
"g_io_channel_shutdown(VAR_0->listen_channel, true, NULL);",
"g_io_channel_unref(VAR_0->listen_channel);",
"VAR_0->listen_channel = NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
4,839 | static int v9fs_do_setuid(V9fsState *s, uid_t uid)
{
return s->ops->setuid(&s->ctx, uid);
}
| false | qemu | 758e8e38eb582e3dc87fd55a1d234c25108a7b7f | static int v9fs_do_setuid(V9fsState *s, uid_t uid)
{
return s->ops->setuid(&s->ctx, uid);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(V9fsState *VAR_0, uid_t VAR_1)
{
return VAR_0->ops->setuid(&VAR_0->ctx, VAR_1);
}
| [
"static int FUNC_0(V9fsState *VAR_0, uid_t VAR_1)\n{",
"return VAR_0->ops->setuid(&VAR_0->ctx, VAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
4,840 | static void vgafb_update_display(void *opaque)
{
MilkymistVgafbState *s = opaque;
SysBusDevice *sbd;
DisplaySurface *surface = qemu_console_surface(s->con);
int first = 0;
int last = 0;
drawfn fn;
if (!vgafb_enabled(s)) {
return;
}
sbd = SYS_BUS_DEVICE(s);
int dest_width = s->regs[R_HRES];
switch (surface_bits_per_pixel(surface)) {
case 0:
return;
case 8:
fn = draw_line_8;
break;
case 15:
fn = draw_line_15;
dest_width *= 2;
break;
case 16:
fn = draw_line_16;
dest_width *= 2;
break;
case 24:
fn = draw_line_24;
dest_width *= 3;
break;
case 32:
fn = draw_line_32;
dest_width *= 4;
break;
default:
hw_error("milkymist_vgafb: bad color depth\n");
break;
}
framebuffer_update_display(surface, sysbus_address_space(sbd),
s->regs[R_BASEADDRESS] + s->fb_offset,
s->regs[R_HRES],
s->regs[R_VRES],
s->regs[R_HRES] * 2,
dest_width,
0,
s->invalidate,
fn,
NULL,
&first, &last);
if (first >= 0) {
dpy_gfx_update(s->con, 0, first, s->regs[R_HRES], last - first + 1);
}
s->invalidate = 0;
}
| false | qemu | c1076c3e13a86140cc2ba29866512df8460cc7c2 | static void vgafb_update_display(void *opaque)
{
MilkymistVgafbState *s = opaque;
SysBusDevice *sbd;
DisplaySurface *surface = qemu_console_surface(s->con);
int first = 0;
int last = 0;
drawfn fn;
if (!vgafb_enabled(s)) {
return;
}
sbd = SYS_BUS_DEVICE(s);
int dest_width = s->regs[R_HRES];
switch (surface_bits_per_pixel(surface)) {
case 0:
return;
case 8:
fn = draw_line_8;
break;
case 15:
fn = draw_line_15;
dest_width *= 2;
break;
case 16:
fn = draw_line_16;
dest_width *= 2;
break;
case 24:
fn = draw_line_24;
dest_width *= 3;
break;
case 32:
fn = draw_line_32;
dest_width *= 4;
break;
default:
hw_error("milkymist_vgafb: bad color depth\n");
break;
}
framebuffer_update_display(surface, sysbus_address_space(sbd),
s->regs[R_BASEADDRESS] + s->fb_offset,
s->regs[R_HRES],
s->regs[R_VRES],
s->regs[R_HRES] * 2,
dest_width,
0,
s->invalidate,
fn,
NULL,
&first, &last);
if (first >= 0) {
dpy_gfx_update(s->con, 0, first, s->regs[R_HRES], last - first + 1);
}
s->invalidate = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
MilkymistVgafbState *s = VAR_0;
SysBusDevice *sbd;
DisplaySurface *surface = qemu_console_surface(s->con);
int VAR_1 = 0;
int VAR_2 = 0;
drawfn fn;
if (!vgafb_enabled(s)) {
return;
}
sbd = SYS_BUS_DEVICE(s);
int VAR_3 = s->regs[R_HRES];
switch (surface_bits_per_pixel(surface)) {
case 0:
return;
case 8:
fn = draw_line_8;
break;
case 15:
fn = draw_line_15;
VAR_3 *= 2;
break;
case 16:
fn = draw_line_16;
VAR_3 *= 2;
break;
case 24:
fn = draw_line_24;
VAR_3 *= 3;
break;
case 32:
fn = draw_line_32;
VAR_3 *= 4;
break;
default:
hw_error("milkymist_vgafb: bad color depth\n");
break;
}
framebuffer_update_display(surface, sysbus_address_space(sbd),
s->regs[R_BASEADDRESS] + s->fb_offset,
s->regs[R_HRES],
s->regs[R_VRES],
s->regs[R_HRES] * 2,
VAR_3,
0,
s->invalidate,
fn,
NULL,
&VAR_1, &VAR_2);
if (VAR_1 >= 0) {
dpy_gfx_update(s->con, 0, VAR_1, s->regs[R_HRES], VAR_2 - VAR_1 + 1);
}
s->invalidate = 0;
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"MilkymistVgafbState *s = VAR_0;",
"SysBusDevice *sbd;",
"DisplaySurface *surface = qemu_console_surface(s->con);",
"int VAR_1 = 0;",
"int VAR_2 = 0;",
"drawfn fn;",
"if (!vgafb_enabled(s)) {",
"return;",
"}",
"sbd = SYS_BUS_DEVICE(s);",
"int VAR_3 = s->regs[R_HRES];",
"switch (surface_bits_per_pixel(surface)) {",
"case 0:\nreturn;",
"case 8:\nfn = draw_line_8;",
"break;",
"case 15:\nfn = draw_line_15;",
"VAR_3 *= 2;",
"break;",
"case 16:\nfn = draw_line_16;",
"VAR_3 *= 2;",
"break;",
"case 24:\nfn = draw_line_24;",
"VAR_3 *= 3;",
"break;",
"case 32:\nfn = draw_line_32;",
"VAR_3 *= 4;",
"break;",
"default:\nhw_error(\"milkymist_vgafb: bad color depth\\n\");",
"break;",
"}",
"framebuffer_update_display(surface, sysbus_address_space(sbd),\ns->regs[R_BASEADDRESS] + s->fb_offset,\ns->regs[R_HRES],\ns->regs[R_VRES],\ns->regs[R_HRES] * 2,\nVAR_3,\n0,\ns->invalidate,\nfn,\nNULL,\n&VAR_1, &VAR_2);",
"if (VAR_1 >= 0) {",
"dpy_gfx_update(s->con, 0, VAR_1, s->regs[R_HRES], VAR_2 - VAR_1 + 1);",
"}",
"s->invalidate = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
]
] |
4,841 | static void mainstone_common_init(int ram_size, int vga_ram_size,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, enum mainstone_model_e model, int arm_id)
{
uint32_t mainstone_ram = 0x04000000;
uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *cpu;
qemu_irq *mst_irq;
int index;
if (!cpu_model)
cpu_model = "pxa270-c5";
/* Setup CPU & memory */
if (ram_size < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
exit(1);
}
cpu = pxa270_init(mainstone_ram, ds, cpu_model);
cpu_register_physical_memory(0, mainstone_rom,
qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
/* Setup initial (reset) machine state */
cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
/* There are two 32MiB flash devices on the board */
index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
index = drive_get_index(IF_PFLASH, 0, 1);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
/* MMC/SD host */
pxa2xx_mmci_handlers(cpu->mmc, mst_irq[MMC_IRQ], mst_irq[MMC_IRQ]);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
arm_load_kernel(cpu->env, mainstone_ram, kernel_filename, kernel_cmdline,
initrd_filename, arm_id, PXA2XX_SDRAM_BASE);
}
| false | qemu | 8543243c29a60f102d7a3d98027b46bc8cdac421 | static void mainstone_common_init(int ram_size, int vga_ram_size,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, enum mainstone_model_e model, int arm_id)
{
uint32_t mainstone_ram = 0x04000000;
uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *cpu;
qemu_irq *mst_irq;
int index;
if (!cpu_model)
cpu_model = "pxa270-c5";
if (ram_size < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
exit(1);
}
cpu = pxa270_init(mainstone_ram, ds, cpu_model);
cpu_register_physical_memory(0, mainstone_rom,
qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
index = drive_get_index(IF_PFLASH, 0, 1);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
pxa2xx_mmci_handlers(cpu->mmc, mst_irq[MMC_IRQ], mst_irq[MMC_IRQ]);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
arm_load_kernel(cpu->env, mainstone_ram, kernel_filename, kernel_cmdline,
initrd_filename, arm_id, PXA2XX_SDRAM_BASE);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1,
DisplayState *VAR_2, const char *VAR_3,
const char *VAR_4, const char *VAR_5,
const char *VAR_6, enum mainstone_model_e VAR_7, int VAR_8)
{
uint32_t mainstone_ram = 0x04000000;
uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *VAR_9;
qemu_irq *mst_irq;
int VAR_10;
if (!VAR_6)
VAR_6 = "pxa270-c5";
if (VAR_0 < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
exit(1);
}
VAR_9 = pxa270_init(mainstone_ram, VAR_2, VAR_6);
cpu_register_physical_memory(0, mainstone_rom,
qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
VAR_9->env->regs[15] = PXA2XX_SDRAM_BASE;
VAR_10 = drive_get_index(IF_PFLASH, 0, 0);
if (VAR_10 == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[VAR_10].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
VAR_10 = drive_get_index(IF_PFLASH, 0, 1);
if (VAR_10 == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[VAR_10].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
mst_irq = mst_irq_init(VAR_9, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
pxa2xx_mmci_handlers(VAR_9->mmc, mst_irq[MMC_IRQ], mst_irq[MMC_IRQ]);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
arm_load_kernel(VAR_9->env, mainstone_ram, VAR_3, VAR_4,
VAR_5, VAR_8, PXA2XX_SDRAM_BASE);
}
| [
"static void FUNC_0(int VAR_0, int VAR_1,\nDisplayState *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5,\nconst char *VAR_6, enum mainstone_model_e VAR_7, int VAR_8)\n{",
"uint32_t mainstone_ram = 0x04000000;",
"uint32_t mainstone_rom = 0x00800000;",
"struct pxa2xx_state_s *VAR_9;",
"qemu_irq *mst_irq;",
"int VAR_10;",
"if (!VAR_6)\nVAR_6 = \"pxa270-c5\";",
"if (VAR_0 < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {",
"fprintf(stderr, \"This platform requires %i bytes of memory\\n\",\nmainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);",
"exit(1);",
"}",
"VAR_9 = pxa270_init(mainstone_ram, VAR_2, VAR_6);",
"cpu_register_physical_memory(0, mainstone_rom,\nqemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);",
"VAR_9->env->regs[15] = PXA2XX_SDRAM_BASE;",
"VAR_10 = drive_get_index(IF_PFLASH, 0, 0);",
"if (VAR_10 == -1) {",
"fprintf(stderr, \"Two flash images must be given with the \"\n\"'pflash' parameter\\n\");",
"exit(1);",
"}",
"if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,\ndrives_table[VAR_10].bdrv,\n256 * 1024, 128, 4, 0, 0, 0, 0)) {",
"fprintf(stderr, \"qemu: Error registering flash memory.\\n\");",
"exit(1);",
"}",
"VAR_10 = drive_get_index(IF_PFLASH, 0, 1);",
"if (VAR_10 == -1) {",
"fprintf(stderr, \"Two flash images must be given with the \"\n\"'pflash' parameter\\n\");",
"exit(1);",
"}",
"if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,\ndrives_table[VAR_10].bdrv,\n256 * 1024, 128, 4, 0, 0, 0, 0)) {",
"fprintf(stderr, \"qemu: Error registering flash memory.\\n\");",
"exit(1);",
"}",
"mst_irq = mst_irq_init(VAR_9, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);",
"pxa2xx_mmci_handlers(VAR_9->mmc, mst_irq[MMC_IRQ], mst_irq[MMC_IRQ]);",
"smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);",
"arm_load_kernel(VAR_9->env, mainstone_ram, VAR_3, VAR_4,\nVAR_5, VAR_8, PXA2XX_SDRAM_BASE);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
53
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
117
],
[
121
],
[
125,
127
],
[
129
]
] |
4,843 | uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src)
{
int i;
unsigned char x;
uint32_t cc = 0;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src);
#ifndef CONFIG_USER_ONLY
/* xor with itself is the same as memset(0) */
if ((l > 32) && (src == dest) &&
(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK)) {
mvc_fast_memset(env, l + 1, dest, 0);
return 0;
}
#else
if (src == dest) {
memset(g2h(dest), 0, l + 1);
return 0;
}
#endif
for (i = 0; i <= l; i++) {
x = cpu_ldub_data(env, dest + i) ^ cpu_ldub_data(env, src + i);
if (x) {
cc = 1;
}
cpu_stb_data(env, dest + i, x);
}
return cc;
}
| false | qemu | fc89efe693278c79273f3bbf6b581e8a749c85b0 | uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src)
{
int i;
unsigned char x;
uint32_t cc = 0;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src);
#ifndef CONFIG_USER_ONLY
if ((l > 32) && (src == dest) &&
(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK)) {
mvc_fast_memset(env, l + 1, dest, 0);
return 0;
}
#else
if (src == dest) {
memset(g2h(dest), 0, l + 1);
return 0;
}
#endif
for (i = 0; i <= l; i++) {
x = cpu_ldub_data(env, dest + i) ^ cpu_ldub_data(env, src + i);
if (x) {
cc = 1;
}
cpu_stb_data(env, dest + i, x);
}
return cc;
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src)
{
int VAR_0;
unsigned char VAR_1;
uint32_t cc = 0;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src);
#ifndef CONFIG_USER_ONLY
if ((l > 32) && (src == dest) &&
(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK)) {
mvc_fast_memset(env, l + 1, dest, 0);
return 0;
}
#else
if (src == dest) {
memset(g2h(dest), 0, l + 1);
return 0;
}
#endif
for (VAR_0 = 0; VAR_0 <= l; VAR_0++) {
VAR_1 = cpu_ldub_data(env, dest + VAR_0) ^ cpu_ldub_data(env, src + VAR_0);
if (VAR_1) {
cc = 1;
}
cpu_stb_data(env, dest + VAR_0, VAR_1);
}
return cc;
}
| [
"uint32_t FUNC_0(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,\nuint64_t src)\n{",
"int VAR_0;",
"unsigned char VAR_1;",
"uint32_t cc = 0;",
"HELPER_LOG(\"%s l %d dest %\" PRIx64 \" src %\" PRIx64 \"\\n\",\n__func__, l, dest, src);",
"#ifndef CONFIG_USER_ONLY\nif ((l > 32) && (src == dest) &&\n(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK)) {",
"mvc_fast_memset(env, l + 1, dest, 0);",
"return 0;",
"}",
"#else\nif (src == dest) {",
"memset(g2h(dest), 0, l + 1);",
"return 0;",
"}",
"#endif\nfor (VAR_0 = 0; VAR_0 <= l; VAR_0++) {",
"VAR_1 = cpu_ldub_data(env, dest + VAR_0) ^ cpu_ldub_data(env, src + VAR_0);",
"if (VAR_1) {",
"cc = 1;",
"}",
"cpu_stb_data(env, dest + VAR_0, VAR_1);",
"}",
"return cc;",
"}"
] | [
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
]
] |
4,844 | static int xen_pt_pci_config_access_check(PCIDevice *d, uint32_t addr, int len)
{
/* check offset range */
if (addr >= 0xFF) {
XEN_PT_ERR(d, "Failed to access register with offset exceeding 0xFF. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
/* check read size */
if ((len != 1) && (len != 2) && (len != 4)) {
XEN_PT_ERR(d, "Failed to access register with invalid access length. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
/* check offset alignment */
if (addr & (len - 1)) {
XEN_PT_ERR(d, "Failed to access register with invalid access size "
"alignment. (addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
return 0;
}
| false | qemu | 4daf62594d13dfca2ce3a74dd3bddee5f54d7127 | static int xen_pt_pci_config_access_check(PCIDevice *d, uint32_t addr, int len)
{
if (addr >= 0xFF) {
XEN_PT_ERR(d, "Failed to access register with offset exceeding 0xFF. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
if ((len != 1) && (len != 2) && (len != 4)) {
XEN_PT_ERR(d, "Failed to access register with invalid access length. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
if (addr & (len - 1)) {
XEN_PT_ERR(d, "Failed to access register with invalid access size "
"alignment. (addr: 0x%02x, len: %d)\n", addr, len);
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1, int VAR_2)
{
if (VAR_1 >= 0xFF) {
XEN_PT_ERR(VAR_0, "Failed to access register with offset exceeding 0xFF. "
"(VAR_1: 0x%02x, VAR_2: %VAR_0)\n", VAR_1, VAR_2);
return -1;
}
if ((VAR_2 != 1) && (VAR_2 != 2) && (VAR_2 != 4)) {
XEN_PT_ERR(VAR_0, "Failed to access register with invalid access length. "
"(VAR_1: 0x%02x, VAR_2: %VAR_0)\n", VAR_1, VAR_2);
return -1;
}
if (VAR_1 & (VAR_2 - 1)) {
XEN_PT_ERR(VAR_0, "Failed to access register with invalid access size "
"alignment. (VAR_1: 0x%02x, VAR_2: %VAR_0)\n", VAR_1, VAR_2);
return -1;
}
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1, int VAR_2)\n{",
"if (VAR_1 >= 0xFF) {",
"XEN_PT_ERR(VAR_0, \"Failed to access register with offset exceeding 0xFF. \"\n\"(VAR_1: 0x%02x, VAR_2: %VAR_0)\\n\", VAR_1, VAR_2);",
"return -1;",
"}",
"if ((VAR_2 != 1) && (VAR_2 != 2) && (VAR_2 != 4)) {",
"XEN_PT_ERR(VAR_0, \"Failed to access register with invalid access length. \"\n\"(VAR_1: 0x%02x, VAR_2: %VAR_0)\\n\", VAR_1, VAR_2);",
"return -1;",
"}",
"if (VAR_1 & (VAR_2 - 1)) {",
"XEN_PT_ERR(VAR_0, \"Failed to access register with invalid access size \"\n\"alignment. (VAR_1: 0x%02x, VAR_2: %VAR_0)\\n\", VAR_1, VAR_2);",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
4,845 | static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
{
BDRVDMGState *s = bs->opaque;
if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {
int ret;
uint32_t chunk = search_chunk(s,sector_num);
if(chunk>=s->n_chunks)
return -1;
s->current_chunk = s->n_chunks;
switch(s->types[chunk]) {
case 0x80000005: { /* zlib compressed */
int i;
/* we need to buffer, because only the chunk as whole can be
* inflated. */
i=0;
do {
ret = bdrv_pread(bs->file, s->offsets[chunk] + i,
s->compressed_chunk+i, s->lengths[chunk]-i);
if(ret<0 && errno==EINTR)
ret=0;
i+=ret;
} while(ret>=0 && ret+i<s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
s->zstream.next_in = s->compressed_chunk;
s->zstream.avail_in = s->lengths[chunk];
s->zstream.next_out = s->uncompressed_chunk;
s->zstream.avail_out = 512*s->sectorcounts[chunk];
ret = inflateReset(&s->zstream);
if(ret != Z_OK)
return -1;
ret = inflate(&s->zstream, Z_FINISH);
if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])
return -1;
break; }
case 1: /* copy */
ret = bdrv_pread(bs->file, s->offsets[chunk],
s->uncompressed_chunk, s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
break;
case 2: /* zero */
memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);
break;
}
s->current_chunk = chunk;
}
return 0;
}
| false | qemu | 2c1885adcf0312da80c7317b09f9adad97fa0fc6 | static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
{
BDRVDMGState *s = bs->opaque;
if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {
int ret;
uint32_t chunk = search_chunk(s,sector_num);
if(chunk>=s->n_chunks)
return -1;
s->current_chunk = s->n_chunks;
switch(s->types[chunk]) {
case 0x80000005: {
int i;
i=0;
do {
ret = bdrv_pread(bs->file, s->offsets[chunk] + i,
s->compressed_chunk+i, s->lengths[chunk]-i);
if(ret<0 && errno==EINTR)
ret=0;
i+=ret;
} while(ret>=0 && ret+i<s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
s->zstream.next_in = s->compressed_chunk;
s->zstream.avail_in = s->lengths[chunk];
s->zstream.next_out = s->uncompressed_chunk;
s->zstream.avail_out = 512*s->sectorcounts[chunk];
ret = inflateReset(&s->zstream);
if(ret != Z_OK)
return -1;
ret = inflate(&s->zstream, Z_FINISH);
if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])
return -1;
break; }
case 1:
ret = bdrv_pread(bs->file, s->offsets[chunk],
s->uncompressed_chunk, s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
break;
case 2:
memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);
break;
}
s->current_chunk = chunk;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{
BDRVDMGState *s = VAR_0->opaque;
if(!is_sector_in_chunk(s,s->current_chunk,VAR_1)) {
int VAR_2;
uint32_t chunk = search_chunk(s,VAR_1);
if(chunk>=s->n_chunks)
return -1;
s->current_chunk = s->n_chunks;
switch(s->types[chunk]) {
case 0x80000005: {
int VAR_3;
VAR_3=0;
do {
VAR_2 = bdrv_pread(VAR_0->file, s->offsets[chunk] + VAR_3,
s->compressed_chunk+VAR_3, s->lengths[chunk]-VAR_3);
if(VAR_2<0 && errno==EINTR)
VAR_2=0;
VAR_3+=VAR_2;
} while(VAR_2>=0 && VAR_2+VAR_3<s->lengths[chunk]);
if (VAR_2 != s->lengths[chunk])
return -1;
s->zstream.next_in = s->compressed_chunk;
s->zstream.avail_in = s->lengths[chunk];
s->zstream.next_out = s->uncompressed_chunk;
s->zstream.avail_out = 512*s->sectorcounts[chunk];
VAR_2 = inflateReset(&s->zstream);
if(VAR_2 != Z_OK)
return -1;
VAR_2 = inflate(&s->zstream, Z_FINISH);
if(VAR_2 != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])
return -1;
break; }
case 1:
VAR_2 = bdrv_pread(VAR_0->file, s->offsets[chunk],
s->uncompressed_chunk, s->lengths[chunk]);
if (VAR_2 != s->lengths[chunk])
return -1;
break;
case 2:
memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);
break;
}
s->current_chunk = chunk;
}
return 0;
}
| [
"static inline int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{",
"BDRVDMGState *s = VAR_0->opaque;",
"if(!is_sector_in_chunk(s,s->current_chunk,VAR_1)) {",
"int VAR_2;",
"uint32_t chunk = search_chunk(s,VAR_1);",
"if(chunk>=s->n_chunks)\nreturn -1;",
"s->current_chunk = s->n_chunks;",
"switch(s->types[chunk]) {",
"case 0x80000005: {",
"int VAR_3;",
"VAR_3=0;",
"do {",
"VAR_2 = bdrv_pread(VAR_0->file, s->offsets[chunk] + VAR_3,\ns->compressed_chunk+VAR_3, s->lengths[chunk]-VAR_3);",
"if(VAR_2<0 && errno==EINTR)\nVAR_2=0;",
"VAR_3+=VAR_2;",
"} while(VAR_2>=0 && VAR_2+VAR_3<s->lengths[chunk]);",
"if (VAR_2 != s->lengths[chunk])\nreturn -1;",
"s->zstream.next_in = s->compressed_chunk;",
"s->zstream.avail_in = s->lengths[chunk];",
"s->zstream.next_out = s->uncompressed_chunk;",
"s->zstream.avail_out = 512*s->sectorcounts[chunk];",
"VAR_2 = inflateReset(&s->zstream);",
"if(VAR_2 != Z_OK)\nreturn -1;",
"VAR_2 = inflate(&s->zstream, Z_FINISH);",
"if(VAR_2 != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])\nreturn -1;",
"break; }",
"case 1:\nVAR_2 = bdrv_pread(VAR_0->file, s->offsets[chunk],\ns->uncompressed_chunk, s->lengths[chunk]);",
"if (VAR_2 != s->lengths[chunk])\nreturn -1;",
"break;",
"case 2:\nmemset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);",
"break;",
"}",
"s->current_chunk = chunk;",
"}",
"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,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
55,
57
],
[
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
]
] |
4,846 | void object_property_add_child(Object *obj, const char *name,
Object *child, Error **errp)
{
Error *local_err = NULL;
gchar *type;
type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
object_property_add(obj, name, type, object_get_child_property, NULL,
object_finalize_child_property, child, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
object_ref(child);
g_assert(child->parent == NULL);
child->parent = obj;
out:
g_free(type);
}
| false | qemu | 64607d088132abdb25bf30d93e97d0c8df7b364c | void object_property_add_child(Object *obj, const char *name,
Object *child, Error **errp)
{
Error *local_err = NULL;
gchar *type;
type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
object_property_add(obj, name, type, object_get_child_property, NULL,
object_finalize_child_property, child, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
object_ref(child);
g_assert(child->parent == NULL);
child->parent = obj;
out:
g_free(type);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Object *VAR_0, const char *VAR_1,
Object *VAR_2, Error **VAR_3)
{
Error *local_err = NULL;
gchar *type;
type = g_strdup_printf("VAR_2<%s>", object_get_typename(OBJECT(VAR_2)));
object_property_add(VAR_0, VAR_1, type, object_get_child_property, NULL,
object_finalize_child_property, VAR_2, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
goto out;
}
object_ref(VAR_2);
g_assert(VAR_2->parent == NULL);
VAR_2->parent = VAR_0;
out:
g_free(type);
}
| [
"void FUNC_0(Object *VAR_0, const char *VAR_1,\nObject *VAR_2, Error **VAR_3)\n{",
"Error *local_err = NULL;",
"gchar *type;",
"type = g_strdup_printf(\"VAR_2<%s>\", object_get_typename(OBJECT(VAR_2)));",
"object_property_add(VAR_0, VAR_1, type, object_get_child_property, NULL,\nobject_finalize_child_property, VAR_2, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"goto out;",
"}",
"object_ref(VAR_2);",
"g_assert(VAR_2->parent == NULL);",
"VAR_2->parent = VAR_0;",
"out:\ng_free(type);",
"}"
] | [
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
41
]
] |
4,850 | void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr)
{
bool ret;
uint32_t fsr = 0;
ARMMMUFaultInfo fi = {};
ret = arm_tlb_fill(cs, addr, access_type, mmu_idx, &fsr, &fi);
if (unlikely(ret)) {
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t syn, exc;
unsigned int target_el;
bool same_el;
if (retaddr) {
/* now we have a real cpu fault */
cpu_restore_state(cs, retaddr);
}
target_el = exception_target_el(env);
if (fi.stage2) {
target_el = 2;
env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;
}
same_el = arm_current_el(env) == target_el;
/* AArch64 syndrome does not have an LPAE bit */
syn = fsr & ~(1 << 9);
/* For insn and data aborts we assume there is no instruction syndrome
* information; this is always true for exceptions reported to EL1.
*/
if (access_type == MMU_INST_FETCH) {
syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);
exc = EXCP_PREFETCH_ABORT;
} else {
syn = merge_syn_data_abort(env->exception.syndrome, target_el,
same_el, fi.s1ptw,
access_type == MMU_DATA_STORE, syn);
if (access_type == MMU_DATA_STORE
&& arm_feature(env, ARM_FEATURE_V6)) {
fsr |= (1 << 11);
}
exc = EXCP_DATA_ABORT;
}
env->exception.vaddress = addr;
env->exception.fsr = fsr;
raise_exception(env, exc, syn, target_el);
}
}
| true | qemu | 65ed2ed90d9d81fd4b639029be850ea5651f919f | void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr)
{
bool ret;
uint32_t fsr = 0;
ARMMMUFaultInfo fi = {};
ret = arm_tlb_fill(cs, addr, access_type, mmu_idx, &fsr, &fi);
if (unlikely(ret)) {
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t syn, exc;
unsigned int target_el;
bool same_el;
if (retaddr) {
cpu_restore_state(cs, retaddr);
}
target_el = exception_target_el(env);
if (fi.stage2) {
target_el = 2;
env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;
}
same_el = arm_current_el(env) == target_el;
syn = fsr & ~(1 << 9);
if (access_type == MMU_INST_FETCH) {
syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);
exc = EXCP_PREFETCH_ABORT;
} else {
syn = merge_syn_data_abort(env->exception.syndrome, target_el,
same_el, fi.s1ptw,
access_type == MMU_DATA_STORE, syn);
if (access_type == MMU_DATA_STORE
&& arm_feature(env, ARM_FEATURE_V6)) {
fsr |= (1 << 11);
}
exc = EXCP_DATA_ABORT;
}
env->exception.vaddress = addr;
env->exception.fsr = fsr;
raise_exception(env, exc, syn, target_el);
}
}
| {
"code": [
" uint32_t syn, exc;",
" syn = fsr & ~(1 << 9);",
" syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);",
" access_type == MMU_DATA_STORE, syn);"
],
"line_no": [
23,
55,
67,
77
]
} | void FUNC_0(CPUState *VAR_0, target_ulong VAR_1, MMUAccessType VAR_2,
int VAR_3, uintptr_t VAR_4)
{
bool ret;
uint32_t fsr = 0;
ARMMMUFaultInfo fi = {};
ret = arm_tlb_fill(VAR_0, VAR_1, VAR_2, VAR_3, &fsr, &fi);
if (unlikely(ret)) {
ARMCPU *cpu = ARM_CPU(VAR_0);
CPUARMState *env = &cpu->env;
uint32_t syn, exc;
unsigned int VAR_5;
bool same_el;
if (VAR_4) {
cpu_restore_state(VAR_0, VAR_4);
}
VAR_5 = exception_target_el(env);
if (fi.stage2) {
VAR_5 = 2;
env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;
}
same_el = arm_current_el(env) == VAR_5;
syn = fsr & ~(1 << 9);
if (VAR_2 == MMU_INST_FETCH) {
syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);
exc = EXCP_PREFETCH_ABORT;
} else {
syn = merge_syn_data_abort(env->exception.syndrome, VAR_5,
same_el, fi.s1ptw,
VAR_2 == MMU_DATA_STORE, syn);
if (VAR_2 == MMU_DATA_STORE
&& arm_feature(env, ARM_FEATURE_V6)) {
fsr |= (1 << 11);
}
exc = EXCP_DATA_ABORT;
}
env->exception.vaddress = VAR_1;
env->exception.fsr = fsr;
raise_exception(env, exc, syn, VAR_5);
}
}
| [
"void FUNC_0(CPUState *VAR_0, target_ulong VAR_1, MMUAccessType VAR_2,\nint VAR_3, uintptr_t VAR_4)\n{",
"bool ret;",
"uint32_t fsr = 0;",
"ARMMMUFaultInfo fi = {};",
"ret = arm_tlb_fill(VAR_0, VAR_1, VAR_2, VAR_3, &fsr, &fi);",
"if (unlikely(ret)) {",
"ARMCPU *cpu = ARM_CPU(VAR_0);",
"CPUARMState *env = &cpu->env;",
"uint32_t syn, exc;",
"unsigned int VAR_5;",
"bool same_el;",
"if (VAR_4) {",
"cpu_restore_state(VAR_0, VAR_4);",
"}",
"VAR_5 = exception_target_el(env);",
"if (fi.stage2) {",
"VAR_5 = 2;",
"env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;",
"}",
"same_el = arm_current_el(env) == VAR_5;",
"syn = fsr & ~(1 << 9);",
"if (VAR_2 == MMU_INST_FETCH) {",
"syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);",
"exc = EXCP_PREFETCH_ABORT;",
"} else {",
"syn = merge_syn_data_abort(env->exception.syndrome, VAR_5,\nsame_el, fi.s1ptw,\nVAR_2 == MMU_DATA_STORE, syn);",
"if (VAR_2 == MMU_DATA_STORE\n&& arm_feature(env, ARM_FEATURE_V6)) {",
"fsr |= (1 << 11);",
"}",
"exc = EXCP_DATA_ABORT;",
"}",
"env->exception.vaddress = VAR_1;",
"env->exception.fsr = fsr;",
"raise_exception(env, exc, syn, VAR_5);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
4,851 | static inline FFAMediaCodec *codec_create(int method, const char *arg)
{
int ret = -1;
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring jarg = NULL;
jobject object = NULL;
jmethodID create_id = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
jarg = ff_jni_utf_chars_to_jstring(env, arg, codec);
if (!jarg) {
goto fail;
switch (method) {
case CREATE_CODEC_BY_NAME: create_id = codec->jfields.create_by_codec_name_id; break;
case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break;
case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break;
default:
av_assert0(0);
object = (*env)->CallStaticObjectMethod(env,
codec->jfields.mediacodec_class,
create_id,
jarg);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
codec->object = (*env)->NewGlobalRef(env, object);
if (!codec->object) {
goto fail;
if (codec_init_static_fields(codec) < 0) {
goto fail;
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
ret = 0;
fail:
if (jarg) {
(*env)->DeleteLocalRef(env, jarg);
if (object) {
(*env)->DeleteLocalRef(env, object);
if (ret < 0) {
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
av_freep(&codec);
return codec;
| true | FFmpeg | 1f1207145a0f2d26e5e3525bea6cc417a3ec39cf | static inline FFAMediaCodec *codec_create(int method, const char *arg)
{
int ret = -1;
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring jarg = NULL;
jobject object = NULL;
jmethodID create_id = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
jarg = ff_jni_utf_chars_to_jstring(env, arg, codec);
if (!jarg) {
goto fail;
switch (method) {
case CREATE_CODEC_BY_NAME: create_id = codec->jfields.create_by_codec_name_id; break;
case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break;
case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break;
default:
av_assert0(0);
object = (*env)->CallStaticObjectMethod(env,
codec->jfields.mediacodec_class,
create_id,
jarg);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
codec->object = (*env)->NewGlobalRef(env, object);
if (!codec->object) {
goto fail;
if (codec_init_static_fields(codec) < 0) {
goto fail;
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
ret = 0;
fail:
if (jarg) {
(*env)->DeleteLocalRef(env, jarg);
if (object) {
(*env)->DeleteLocalRef(env, object);
if (ret < 0) {
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
av_freep(&codec);
return codec;
| {
"code": [],
"line_no": []
} | static inline FFAMediaCodec *FUNC_0(int method, const char *arg)
{
int VAR_0 = -1;
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring jarg = NULL;
jobject object = NULL;
jmethodID create_id = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
jarg = ff_jni_utf_chars_to_jstring(env, arg, codec);
if (!jarg) {
goto fail;
switch (method) {
case CREATE_CODEC_BY_NAME: create_id = codec->jfields.create_by_codec_name_id; break;
case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break;
case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break;
default:
av_assert0(0);
object = (*env)->CallStaticObjectMethod(env,
codec->jfields.mediacodec_class,
create_id,
jarg);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
codec->object = (*env)->NewGlobalRef(env, object);
if (!codec->object) {
goto fail;
if (codec_init_static_fields(codec) < 0) {
goto fail;
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
VAR_0 = 0;
fail:
if (jarg) {
(*env)->DeleteLocalRef(env, jarg);
if (object) {
(*env)->DeleteLocalRef(env, object);
if (VAR_0 < 0) {
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
av_freep(&codec);
return codec;
| [
"static inline FFAMediaCodec *FUNC_0(int method, const char *arg)\n{",
"int VAR_0 = -1;",
"JNIEnv *env = NULL;",
"FFAMediaCodec *codec = NULL;",
"jstring jarg = NULL;",
"jobject object = NULL;",
"jmethodID create_id = NULL;",
"codec = av_mallocz(sizeof(FFAMediaCodec));",
"if (!codec) {",
"return NULL;",
"codec->class = &amediacodec_class;",
"env = ff_jni_get_env(codec);",
"if (!env) {",
"av_freep(&codec);",
"return NULL;",
"if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {",
"goto fail;",
"jarg = ff_jni_utf_chars_to_jstring(env, arg, codec);",
"if (!jarg) {",
"goto fail;",
"switch (method) {",
"case CREATE_CODEC_BY_NAME: create_id = codec->jfields.create_by_codec_name_id; break;",
"case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break;",
"case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break;",
"default:\nav_assert0(0);",
"object = (*env)->CallStaticObjectMethod(env,\ncodec->jfields.mediacodec_class,\ncreate_id,\njarg);",
"if (ff_jni_exception_check(env, 1, codec) < 0) {",
"goto fail;",
"codec->object = (*env)->NewGlobalRef(env, object);",
"if (!codec->object) {",
"goto fail;",
"if (codec_init_static_fields(codec) < 0) {",
"goto fail;",
"if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {",
"codec->has_get_i_o_buffer = 1;",
"VAR_0 = 0;",
"fail:\nif (jarg) {",
"(*env)->DeleteLocalRef(env, jarg);",
"if (object) {",
"(*env)->DeleteLocalRef(env, object);",
"if (VAR_0 < 0) {",
"ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);",
"av_freep(&codec);",
"return codec;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
26
],
[
30
],
[
32
],
[
34
],
[
36
],
[
41
],
[
43
],
[
48
],
[
50
],
[
52
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
72,
74,
76,
78
],
[
80
],
[
82
],
[
87
],
[
89
],
[
91
],
[
96
],
[
98
],
[
103
],
[
105
],
[
110
],
[
112,
114
],
[
116
],
[
121
],
[
123
],
[
128
],
[
133
],
[
135
],
[
140
]
] |
4,852 | static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size)
{
if (buf_size < 13)
return AVERROR_INVALIDDATA;
if (memcmp(buf, "FLV", 3))
return AVERROR_INVALIDDATA;
buf += 13;
buf_size -= 13;
while (buf_size >= 11 + 4) {
int type = buf[0];
int size = AV_RB24(&buf[1]) + 11 + 4;
if (size > buf_size)
return AVERROR_INVALIDDATA;
if (type == 8 || type == 9) {
if (os->nb_extra_packets > FF_ARRAY_ELEMS(os->extra_packets))
return AVERROR_INVALIDDATA;
os->extra_packet_sizes[os->nb_extra_packets] = size;
os->extra_packets[os->nb_extra_packets] = av_malloc(size);
if (!os->extra_packets[os->nb_extra_packets])
return AVERROR(ENOMEM);
memcpy(os->extra_packets[os->nb_extra_packets], buf, size);
os->nb_extra_packets++;
} else if (type == 0x12) {
if (os->metadata)
return AVERROR_INVALIDDATA;
os->metadata_size = size - 11 - 4;
os->metadata = av_malloc(os->metadata_size);
if (!os->metadata)
return AVERROR(ENOMEM);
memcpy(os->metadata, buf + 11, os->metadata_size);
}
buf += size;
buf_size -= size;
}
if (!os->metadata)
return AVERROR_INVALIDDATA;
return 0;
}
| true | FFmpeg | b8ed15d6378f00e158c72c526fa0fce17da77361 | static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size)
{
if (buf_size < 13)
return AVERROR_INVALIDDATA;
if (memcmp(buf, "FLV", 3))
return AVERROR_INVALIDDATA;
buf += 13;
buf_size -= 13;
while (buf_size >= 11 + 4) {
int type = buf[0];
int size = AV_RB24(&buf[1]) + 11 + 4;
if (size > buf_size)
return AVERROR_INVALIDDATA;
if (type == 8 || type == 9) {
if (os->nb_extra_packets > FF_ARRAY_ELEMS(os->extra_packets))
return AVERROR_INVALIDDATA;
os->extra_packet_sizes[os->nb_extra_packets] = size;
os->extra_packets[os->nb_extra_packets] = av_malloc(size);
if (!os->extra_packets[os->nb_extra_packets])
return AVERROR(ENOMEM);
memcpy(os->extra_packets[os->nb_extra_packets], buf, size);
os->nb_extra_packets++;
} else if (type == 0x12) {
if (os->metadata)
return AVERROR_INVALIDDATA;
os->metadata_size = size - 11 - 4;
os->metadata = av_malloc(os->metadata_size);
if (!os->metadata)
return AVERROR(ENOMEM);
memcpy(os->metadata, buf + 11, os->metadata_size);
}
buf += size;
buf_size -= size;
}
if (!os->metadata)
return AVERROR_INVALIDDATA;
return 0;
}
| {
"code": [
" if (os->nb_extra_packets > FF_ARRAY_ELEMS(os->extra_packets))"
],
"line_no": [
29
]
} | static int FUNC_0(OutputStream *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
if (VAR_2 < 13)
return AVERROR_INVALIDDATA;
if (memcmp(VAR_1, "FLV", 3))
return AVERROR_INVALIDDATA;
VAR_1 += 13;
VAR_2 -= 13;
while (VAR_2 >= 11 + 4) {
int VAR_3 = VAR_1[0];
int VAR_4 = AV_RB24(&VAR_1[1]) + 11 + 4;
if (VAR_4 > VAR_2)
return AVERROR_INVALIDDATA;
if (VAR_3 == 8 || VAR_3 == 9) {
if (VAR_0->nb_extra_packets > FF_ARRAY_ELEMS(VAR_0->extra_packets))
return AVERROR_INVALIDDATA;
VAR_0->extra_packet_sizes[VAR_0->nb_extra_packets] = VAR_4;
VAR_0->extra_packets[VAR_0->nb_extra_packets] = av_malloc(VAR_4);
if (!VAR_0->extra_packets[VAR_0->nb_extra_packets])
return AVERROR(ENOMEM);
memcpy(VAR_0->extra_packets[VAR_0->nb_extra_packets], VAR_1, VAR_4);
VAR_0->nb_extra_packets++;
} else if (VAR_3 == 0x12) {
if (VAR_0->metadata)
return AVERROR_INVALIDDATA;
VAR_0->metadata_size = VAR_4 - 11 - 4;
VAR_0->metadata = av_malloc(VAR_0->metadata_size);
if (!VAR_0->metadata)
return AVERROR(ENOMEM);
memcpy(VAR_0->metadata, VAR_1 + 11, VAR_0->metadata_size);
}
VAR_1 += VAR_4;
VAR_2 -= VAR_4;
}
if (!VAR_0->metadata)
return AVERROR_INVALIDDATA;
return 0;
}
| [
"static int FUNC_0(OutputStream *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"if (VAR_2 < 13)\nreturn AVERROR_INVALIDDATA;",
"if (memcmp(VAR_1, \"FLV\", 3))\nreturn AVERROR_INVALIDDATA;",
"VAR_1 += 13;",
"VAR_2 -= 13;",
"while (VAR_2 >= 11 + 4) {",
"int VAR_3 = VAR_1[0];",
"int VAR_4 = AV_RB24(&VAR_1[1]) + 11 + 4;",
"if (VAR_4 > VAR_2)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_3 == 8 || VAR_3 == 9) {",
"if (VAR_0->nb_extra_packets > FF_ARRAY_ELEMS(VAR_0->extra_packets))\nreturn AVERROR_INVALIDDATA;",
"VAR_0->extra_packet_sizes[VAR_0->nb_extra_packets] = VAR_4;",
"VAR_0->extra_packets[VAR_0->nb_extra_packets] = av_malloc(VAR_4);",
"if (!VAR_0->extra_packets[VAR_0->nb_extra_packets])\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_0->extra_packets[VAR_0->nb_extra_packets], VAR_1, VAR_4);",
"VAR_0->nb_extra_packets++;",
"} else if (VAR_3 == 0x12) {",
"if (VAR_0->metadata)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->metadata_size = VAR_4 - 11 - 4;",
"VAR_0->metadata = av_malloc(VAR_0->metadata_size);",
"if (!VAR_0->metadata)\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_0->metadata, VAR_1 + 11, VAR_0->metadata_size);",
"}",
"VAR_1 += VAR_4;",
"VAR_2 -= VAR_4;",
"}",
"if (!VAR_0->metadata)\nreturn AVERROR_INVALIDDATA;",
"return 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
] | [
[
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
]
] |
4,853 | static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr,
const uint8_t *buf, uint16_t len)
{
OMAPI2C *s = (OMAPI2C *)i2c;
uint16_t data;
omap_i2c_set_slave_addr(s, addr);
data = len;
memwrite(s->addr + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_TRX |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->addr + OMAP_I2C_CON, &data, 2);
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) != 0);
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
while (len > 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 2);
buf = (uint8_t *)buf + 2;
len -= 2;
}
if (len == 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 1);
}
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| true | qemu | d0bce760e04b1658a3b4ac95be2839ae20fd86db | static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr,
const uint8_t *buf, uint16_t len)
{
OMAPI2C *s = (OMAPI2C *)i2c;
uint16_t data;
omap_i2c_set_slave_addr(s, addr);
data = len;
memwrite(s->addr + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_TRX |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->addr + OMAP_I2C_CON, &data, 2);
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) != 0);
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
while (len > 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 2);
buf = (uint8_t *)buf + 2;
len -= 2;
}
if (len == 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 1);
}
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| {
"code": [
" memwrite(s->addr + OMAP_I2C_CNT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_DATA, buf, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_DATA, buf, 1);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CNT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);"
],
"line_no": [
19,
33,
35,
41,
49,
55,
49,
71,
35,
19,
33,
35,
41,
49,
35
]
} | static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,
const uint8_t *VAR_2, uint16_t VAR_3)
{
OMAPI2C *s = (OMAPI2C *)VAR_0;
uint16_t data;
omap_i2c_set_slave_addr(s, VAR_1);
data = VAR_3;
memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_TRX |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2);
memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) != 0);
memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
while (VAR_3 > 1) {
memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 2);
VAR_2 = (uint8_t *)VAR_2 + 2;
VAR_3 -= 2;
}
if (VAR_3 == 1) {
memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 1);
}
memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| [
"static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,\nconst uint8_t *VAR_2, uint16_t VAR_3)\n{",
"OMAPI2C *s = (OMAPI2C *)VAR_0;",
"uint16_t data;",
"omap_i2c_set_slave_addr(s, VAR_1);",
"data = VAR_3;",
"memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2);",
"data = OMAP_I2C_CON_I2C_EN |\nOMAP_I2C_CON_TRX |\nOMAP_I2C_CON_MST |\nOMAP_I2C_CON_STT |\nOMAP_I2C_CON_STP;",
"memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"g_assert((data & OMAP_I2C_CON_STP) != 0);",
"memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);",
"g_assert((data & OMAP_I2C_STAT_NACK) == 0);",
"while (VAR_3 > 1) {",
"memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);",
"g_assert((data & OMAP_I2C_STAT_XRDY) != 0);",
"memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 2);",
"VAR_2 = (uint8_t *)VAR_2 + 2;",
"VAR_3 -= 2;",
"}",
"if (VAR_3 == 1) {",
"memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);",
"g_assert((data & OMAP_I2C_STAT_XRDY) != 0);",
"memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 1);",
"}",
"memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"g_assert((data & OMAP_I2C_CON_STP) == 0);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23,
25,
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
]
] |
4,854 | static void mps2_common_init(MachineState *machine)
{
MPS2MachineState *mms = MPS2_MACHINE(machine);
MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
MemoryRegion *system_memory = get_system_memory();
DeviceState *armv7m, *sccdev;
if (!machine->cpu_model) {
machine->cpu_model = mmc->cpu_model;
}
if (strcmp(machine->cpu_model, mmc->cpu_model) != 0) {
error_report("This board can only be used with CPU %s", mmc->cpu_model);
exit(1);
}
/* The FPGA images have an odd combination of different RAMs,
* because in hardware they are different implementations and
* connected to different buses, giving varying performance/size
* tradeoffs. For QEMU they're all just RAM, though. We arbitrarily
* call the 16MB our "system memory", as it's the largest lump.
*
* Common to both boards:
* 0x21000000..0x21ffffff : PSRAM (16MB)
* AN385 only:
* 0x00000000 .. 0x003fffff : ZBT SSRAM1
* 0x00400000 .. 0x007fffff : mirror of ZBT SSRAM1
* 0x20000000 .. 0x203fffff : ZBT SSRAM 2&3
* 0x20400000 .. 0x207fffff : mirror of ZBT SSRAM 2&3
* 0x01000000 .. 0x01003fff : block RAM (16K)
* 0x01004000 .. 0x01007fff : mirror of above
* 0x01008000 .. 0x0100bfff : mirror of above
* 0x0100c000 .. 0x0100ffff : mirror of above
* AN511 only:
* 0x00000000 .. 0x0003ffff : FPGA block RAM
* 0x00400000 .. 0x007fffff : ZBT SSRAM1
* 0x20000000 .. 0x2001ffff : SRAM
* 0x20400000 .. 0x207fffff : ZBT SSRAM 2&3
*
* The AN385 has a feature where the lowest 16K can be mapped
* either to the bottom of the ZBT SSRAM1 or to the block RAM.
* This is of no use for QEMU so we don't implement it (as if
* zbt_boot_ctrl is always zero).
*/
memory_region_allocate_system_memory(&mms->psram,
NULL, "mps.ram", 0x1000000);
memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
switch (mmc->fpga_type) {
case FPGA_AN385:
make_ram(&mms->ssram1, "mps.ssram1", 0x0, 0x400000);
make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x400000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20000000, 0x400000);
make_ram_alias(&mms->ssram23_m, "mps.ssram23_m",
&mms->ssram23, 0x20400000);
make_ram(&mms->blockram, "mps.blockram", 0x01000000, 0x4000);
make_ram_alias(&mms->blockram_m1, "mps.blockram_m1",
&mms->blockram, 0x01004000);
make_ram_alias(&mms->blockram_m2, "mps.blockram_m2",
&mms->blockram, 0x01008000);
make_ram_alias(&mms->blockram_m3, "mps.blockram_m3",
&mms->blockram, 0x0100c000);
break;
case FPGA_AN511:
make_ram(&mms->blockram, "mps.blockram", 0x0, 0x40000);
make_ram(&mms->ssram1, "mps.ssram1", 0x00400000, 0x00800000);
make_ram(&mms->sram, "mps.sram", 0x20000000, 0x20000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20400000, 0x400000);
break;
default:
g_assert_not_reached();
}
object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);
armv7m = DEVICE(&mms->armv7m);
qdev_set_parent_bus(armv7m, sysbus_get_default());
switch (mmc->fpga_type) {
case FPGA_AN385:
qdev_prop_set_uint32(armv7m, "num-irq", 32);
break;
case FPGA_AN511:
qdev_prop_set_uint32(armv7m, "num-irq", 64);
break;
default:
g_assert_not_reached();
}
qdev_prop_set_string(armv7m, "cpu-model", machine->cpu_model);
object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
"memory", &error_abort);
object_property_set_bool(OBJECT(&mms->armv7m), true, "realized",
&error_fatal);
create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
create_unimplemented_device("RESERVED 1", 0x00800000, 0x00800000);
create_unimplemented_device("Block RAM", 0x01000000, 0x00010000);
create_unimplemented_device("RESERVED 2", 0x01010000, 0x1EFF0000);
create_unimplemented_device("RESERVED 3", 0x20800000, 0x00800000);
create_unimplemented_device("PSRAM", 0x21000000, 0x01000000);
/* These three ranges all cover multiple devices; we may implement
* some of them below (in which case the real device takes precedence
* over the unimplemented-region mapping).
*/
create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
0x40000000, 0x00010000);
create_unimplemented_device("CMSDK peripheral region @0x40010000",
0x40010000, 0x00010000);
create_unimplemented_device("Extra peripheral region @0x40020000",
0x40020000, 0x00010000);
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
switch (mmc->fpga_type) {
case FPGA_AN385:
{
/* The overflow IRQs for UARTs 0, 1 and 2 are ORed together.
* Overflow for UARTs 4 and 5 doesn't trigger any interrupt.
*/
Object *orgate;
DeviceState *orgate_dev;
int i;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 6, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (i = 0; i < 5; i++) {
static const hwaddr uartbase[] = {0x40004000, 0x40005000,
0x40006000, 0x40007000,
0x40009000};
Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
/* RX irq number; TX irq is always one greater */
static const int uartirq[] = {0, 2, 4, 18, 20};
qemu_irq txovrint = NULL, rxovrint = NULL;
if (i < 3) {
txovrint = qdev_get_gpio_in(orgate_dev, i * 2);
rxovrint = qdev_get_gpio_in(orgate_dev, i * 2 + 1);
}
cmsdk_apb_uart_create(uartbase[i],
qdev_get_gpio_in(armv7m, uartirq[i] + 1),
qdev_get_gpio_in(armv7m, uartirq[i]),
txovrint, rxovrint,
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
case FPGA_AN511:
{
/* The overflow IRQs for all UARTs are ORed together.
* Tx and Rx IRQs for each UART are ORed together.
*/
Object *orgate;
DeviceState *orgate_dev;
int i;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 10, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (i = 0; i < 5; i++) {
/* system irq numbers for the combined tx/rx for each UART */
static const int uart_txrx_irqno[] = {0, 2, 45, 46, 56};
static const hwaddr uartbase[] = {0x40004000, 0x40005000,
0x4002c000, 0x4002d000,
0x4002e000};
Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
Object *txrx_orgate;
DeviceState *txrx_orgate_dev;
txrx_orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
object_property_set_bool(txrx_orgate, true, "realized",
&error_fatal);
txrx_orgate_dev = DEVICE(txrx_orgate);
qdev_connect_gpio_out(txrx_orgate_dev, 0,
qdev_get_gpio_in(armv7m, uart_txrx_irqno[i]));
cmsdk_apb_uart_create(uartbase[i],
qdev_get_gpio_in(txrx_orgate_dev, 0),
qdev_get_gpio_in(txrx_orgate_dev, 1),
qdev_get_gpio_in(orgate_dev, 0),
qdev_get_gpio_in(orgate_dev, 1),
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
default:
g_assert_not_reached();
}
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
sccdev = DEVICE(&mms->scc);
qdev_set_parent_bus(sccdev, sysbus_get_default());
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
object_property_set_bool(OBJECT(&mms->scc), true, "realized",
&error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
/* In hardware this is a LAN9220; the LAN9118 is software compatible
* except that it doesn't support the checksum-offload feature.
*/
lan9118_init(&nd_table[0], 0x40200000,
qdev_get_gpio_in(armv7m,
mmc->fpga_type == FPGA_AN385 ? 13 : 47));
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
0x400000);
}
| true | qemu | ce3bc112cdb1d462e2d52eaa17a7314e7f3af504 | static void mps2_common_init(MachineState *machine)
{
MPS2MachineState *mms = MPS2_MACHINE(machine);
MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
MemoryRegion *system_memory = get_system_memory();
DeviceState *armv7m, *sccdev;
if (!machine->cpu_model) {
machine->cpu_model = mmc->cpu_model;
}
if (strcmp(machine->cpu_model, mmc->cpu_model) != 0) {
error_report("This board can only be used with CPU %s", mmc->cpu_model);
exit(1);
}
memory_region_allocate_system_memory(&mms->psram,
NULL, "mps.ram", 0x1000000);
memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
switch (mmc->fpga_type) {
case FPGA_AN385:
make_ram(&mms->ssram1, "mps.ssram1", 0x0, 0x400000);
make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x400000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20000000, 0x400000);
make_ram_alias(&mms->ssram23_m, "mps.ssram23_m",
&mms->ssram23, 0x20400000);
make_ram(&mms->blockram, "mps.blockram", 0x01000000, 0x4000);
make_ram_alias(&mms->blockram_m1, "mps.blockram_m1",
&mms->blockram, 0x01004000);
make_ram_alias(&mms->blockram_m2, "mps.blockram_m2",
&mms->blockram, 0x01008000);
make_ram_alias(&mms->blockram_m3, "mps.blockram_m3",
&mms->blockram, 0x0100c000);
break;
case FPGA_AN511:
make_ram(&mms->blockram, "mps.blockram", 0x0, 0x40000);
make_ram(&mms->ssram1, "mps.ssram1", 0x00400000, 0x00800000);
make_ram(&mms->sram, "mps.sram", 0x20000000, 0x20000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20400000, 0x400000);
break;
default:
g_assert_not_reached();
}
object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);
armv7m = DEVICE(&mms->armv7m);
qdev_set_parent_bus(armv7m, sysbus_get_default());
switch (mmc->fpga_type) {
case FPGA_AN385:
qdev_prop_set_uint32(armv7m, "num-irq", 32);
break;
case FPGA_AN511:
qdev_prop_set_uint32(armv7m, "num-irq", 64);
break;
default:
g_assert_not_reached();
}
qdev_prop_set_string(armv7m, "cpu-model", machine->cpu_model);
object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
"memory", &error_abort);
object_property_set_bool(OBJECT(&mms->armv7m), true, "realized",
&error_fatal);
create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
create_unimplemented_device("RESERVED 1", 0x00800000, 0x00800000);
create_unimplemented_device("Block RAM", 0x01000000, 0x00010000);
create_unimplemented_device("RESERVED 2", 0x01010000, 0x1EFF0000);
create_unimplemented_device("RESERVED 3", 0x20800000, 0x00800000);
create_unimplemented_device("PSRAM", 0x21000000, 0x01000000);
create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
0x40000000, 0x00010000);
create_unimplemented_device("CMSDK peripheral region @0x40010000",
0x40010000, 0x00010000);
create_unimplemented_device("Extra peripheral region @0x40020000",
0x40020000, 0x00010000);
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
switch (mmc->fpga_type) {
case FPGA_AN385:
{
Object *orgate;
DeviceState *orgate_dev;
int i;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 6, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (i = 0; i < 5; i++) {
static const hwaddr uartbase[] = {0x40004000, 0x40005000,
0x40006000, 0x40007000,
0x40009000};
Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
static const int uartirq[] = {0, 2, 4, 18, 20};
qemu_irq txovrint = NULL, rxovrint = NULL;
if (i < 3) {
txovrint = qdev_get_gpio_in(orgate_dev, i * 2);
rxovrint = qdev_get_gpio_in(orgate_dev, i * 2 + 1);
}
cmsdk_apb_uart_create(uartbase[i],
qdev_get_gpio_in(armv7m, uartirq[i] + 1),
qdev_get_gpio_in(armv7m, uartirq[i]),
txovrint, rxovrint,
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
case FPGA_AN511:
{
Object *orgate;
DeviceState *orgate_dev;
int i;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 10, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (i = 0; i < 5; i++) {
static const int uart_txrx_irqno[] = {0, 2, 45, 46, 56};
static const hwaddr uartbase[] = {0x40004000, 0x40005000,
0x4002c000, 0x4002d000,
0x4002e000};
Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
Object *txrx_orgate;
DeviceState *txrx_orgate_dev;
txrx_orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
object_property_set_bool(txrx_orgate, true, "realized",
&error_fatal);
txrx_orgate_dev = DEVICE(txrx_orgate);
qdev_connect_gpio_out(txrx_orgate_dev, 0,
qdev_get_gpio_in(armv7m, uart_txrx_irqno[i]));
cmsdk_apb_uart_create(uartbase[i],
qdev_get_gpio_in(txrx_orgate_dev, 0),
qdev_get_gpio_in(txrx_orgate_dev, 1),
qdev_get_gpio_in(orgate_dev, 0),
qdev_get_gpio_in(orgate_dev, 1),
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
default:
g_assert_not_reached();
}
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
sccdev = DEVICE(&mms->scc);
qdev_set_parent_bus(sccdev, sysbus_get_default());
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
object_property_set_bool(OBJECT(&mms->scc), true, "realized",
&error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
lan9118_init(&nd_table[0], 0x40200000,
qdev_get_gpio_in(armv7m,
mmc->fpga_type == FPGA_AN385 ? 13 : 47));
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
0x400000);
}
| {
"code": [
" qdev_get_gpio_in(orgate_dev, 0),",
" qdev_get_gpio_in(orgate_dev, 1),"
],
"line_no": [
371,
373
]
} | static void FUNC_0(MachineState *VAR_0)
{
MPS2MachineState *mms = MPS2_MACHINE(VAR_0);
MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(VAR_0);
MemoryRegion *system_memory = get_system_memory();
DeviceState *armv7m, *sccdev;
if (!VAR_0->cpu_model) {
VAR_0->cpu_model = mmc->cpu_model;
}
if (strcmp(VAR_0->cpu_model, mmc->cpu_model) != 0) {
error_report("This board can only be used with CPU %s", mmc->cpu_model);
exit(1);
}
memory_region_allocate_system_memory(&mms->psram,
NULL, "mps.ram", 0x1000000);
memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
switch (mmc->fpga_type) {
case FPGA_AN385:
make_ram(&mms->ssram1, "mps.ssram1", 0x0, 0x400000);
make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x400000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20000000, 0x400000);
make_ram_alias(&mms->ssram23_m, "mps.ssram23_m",
&mms->ssram23, 0x20400000);
make_ram(&mms->blockram, "mps.blockram", 0x01000000, 0x4000);
make_ram_alias(&mms->blockram_m1, "mps.blockram_m1",
&mms->blockram, 0x01004000);
make_ram_alias(&mms->blockram_m2, "mps.blockram_m2",
&mms->blockram, 0x01008000);
make_ram_alias(&mms->blockram_m3, "mps.blockram_m3",
&mms->blockram, 0x0100c000);
break;
case FPGA_AN511:
make_ram(&mms->blockram, "mps.blockram", 0x0, 0x40000);
make_ram(&mms->ssram1, "mps.ssram1", 0x00400000, 0x00800000);
make_ram(&mms->sram, "mps.sram", 0x20000000, 0x20000);
make_ram(&mms->ssram23, "mps.ssram23", 0x20400000, 0x400000);
break;
default:
g_assert_not_reached();
}
object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);
armv7m = DEVICE(&mms->armv7m);
qdev_set_parent_bus(armv7m, sysbus_get_default());
switch (mmc->fpga_type) {
case FPGA_AN385:
qdev_prop_set_uint32(armv7m, "num-irq", 32);
break;
case FPGA_AN511:
qdev_prop_set_uint32(armv7m, "num-irq", 64);
break;
default:
g_assert_not_reached();
}
qdev_prop_set_string(armv7m, "cpu-model", VAR_0->cpu_model);
object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
"memory", &error_abort);
object_property_set_bool(OBJECT(&mms->armv7m), true, "realized",
&error_fatal);
create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
create_unimplemented_device("RESERVED 1", 0x00800000, 0x00800000);
create_unimplemented_device("Block RAM", 0x01000000, 0x00010000);
create_unimplemented_device("RESERVED 2", 0x01010000, 0x1EFF0000);
create_unimplemented_device("RESERVED 3", 0x20800000, 0x00800000);
create_unimplemented_device("PSRAM", 0x21000000, 0x01000000);
create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
0x40000000, 0x00010000);
create_unimplemented_device("CMSDK peripheral region @0x40010000",
0x40010000, 0x00010000);
create_unimplemented_device("Extra peripheral region @0x40020000",
0x40020000, 0x00010000);
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
switch (mmc->fpga_type) {
case FPGA_AN385:
{
Object *orgate;
DeviceState *orgate_dev;
int VAR_4;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 6, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (VAR_4 = 0; VAR_4 < 5; VAR_4++) {
static const hwaddr VAR_5[] = {0x40004000, 0x40005000,
0x40006000, 0x40007000,
0x40009000};
Chardev *uartchr = VAR_4 < MAX_SERIAL_PORTS ? serial_hds[VAR_4] : NULL;
static const int VAR_3[] = {0, 2, 4, 18, 20};
qemu_irq txovrint = NULL, rxovrint = NULL;
if (VAR_4 < 3) {
txovrint = qdev_get_gpio_in(orgate_dev, VAR_4 * 2);
rxovrint = qdev_get_gpio_in(orgate_dev, VAR_4 * 2 + 1);
}
cmsdk_apb_uart_create(VAR_5[VAR_4],
qdev_get_gpio_in(armv7m, VAR_3[VAR_4] + 1),
qdev_get_gpio_in(armv7m, VAR_3[VAR_4]),
txovrint, rxovrint,
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
case FPGA_AN511:
{
Object *orgate;
DeviceState *orgate_dev;
int VAR_4;
orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(orgate, 10, "num-lines", &error_fatal);
object_property_set_bool(orgate, true, "realized", &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
for (VAR_4 = 0; VAR_4 < 5; VAR_4++) {
static const int VAR_4[] = {0, 2, 45, 46, 56};
static const hwaddr VAR_5[] = {0x40004000, 0x40005000,
0x4002c000, 0x4002d000,
0x4002e000};
Chardev *uartchr = VAR_4 < MAX_SERIAL_PORTS ? serial_hds[VAR_4] : NULL;
Object *txrx_orgate;
DeviceState *txrx_orgate_dev;
txrx_orgate = object_new(TYPE_OR_IRQ);
object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
object_property_set_bool(txrx_orgate, true, "realized",
&error_fatal);
txrx_orgate_dev = DEVICE(txrx_orgate);
qdev_connect_gpio_out(txrx_orgate_dev, 0,
qdev_get_gpio_in(armv7m, VAR_4[VAR_4]));
cmsdk_apb_uart_create(VAR_5[VAR_4],
qdev_get_gpio_in(txrx_orgate_dev, 0),
qdev_get_gpio_in(txrx_orgate_dev, 1),
qdev_get_gpio_in(orgate_dev, 0),
qdev_get_gpio_in(orgate_dev, 1),
NULL,
uartchr, SYSCLK_FRQ);
}
break;
}
default:
g_assert_not_reached();
}
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
sccdev = DEVICE(&mms->scc);
qdev_set_parent_bus(sccdev, sysbus_get_default());
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
object_property_set_bool(OBJECT(&mms->scc), true, "realized",
&error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
lan9118_init(&nd_table[0], 0x40200000,
qdev_get_gpio_in(armv7m,
mmc->fpga_type == FPGA_AN385 ? 13 : 47));
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
armv7m_load_kernel(ARM_CPU(first_cpu), VAR_0->kernel_filename,
0x400000);
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"MPS2MachineState *mms = MPS2_MACHINE(VAR_0);",
"MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(VAR_0);",
"MemoryRegion *system_memory = get_system_memory();",
"DeviceState *armv7m, *sccdev;",
"if (!VAR_0->cpu_model) {",
"VAR_0->cpu_model = mmc->cpu_model;",
"}",
"if (strcmp(VAR_0->cpu_model, mmc->cpu_model) != 0) {",
"error_report(\"This board can only be used with CPU %s\", mmc->cpu_model);",
"exit(1);",
"}",
"memory_region_allocate_system_memory(&mms->psram,\nNULL, \"mps.ram\", 0x1000000);",
"memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);",
"switch (mmc->fpga_type) {",
"case FPGA_AN385:\nmake_ram(&mms->ssram1, \"mps.ssram1\", 0x0, 0x400000);",
"make_ram_alias(&mms->ssram1_m, \"mps.ssram1_m\", &mms->ssram1, 0x400000);",
"make_ram(&mms->ssram23, \"mps.ssram23\", 0x20000000, 0x400000);",
"make_ram_alias(&mms->ssram23_m, \"mps.ssram23_m\",\n&mms->ssram23, 0x20400000);",
"make_ram(&mms->blockram, \"mps.blockram\", 0x01000000, 0x4000);",
"make_ram_alias(&mms->blockram_m1, \"mps.blockram_m1\",\n&mms->blockram, 0x01004000);",
"make_ram_alias(&mms->blockram_m2, \"mps.blockram_m2\",\n&mms->blockram, 0x01008000);",
"make_ram_alias(&mms->blockram_m3, \"mps.blockram_m3\",\n&mms->blockram, 0x0100c000);",
"break;",
"case FPGA_AN511:\nmake_ram(&mms->blockram, \"mps.blockram\", 0x0, 0x40000);",
"make_ram(&mms->ssram1, \"mps.ssram1\", 0x00400000, 0x00800000);",
"make_ram(&mms->sram, \"mps.sram\", 0x20000000, 0x20000);",
"make_ram(&mms->ssram23, \"mps.ssram23\", 0x20400000, 0x400000);",
"break;",
"default:\ng_assert_not_reached();",
"}",
"object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);",
"armv7m = DEVICE(&mms->armv7m);",
"qdev_set_parent_bus(armv7m, sysbus_get_default());",
"switch (mmc->fpga_type) {",
"case FPGA_AN385:\nqdev_prop_set_uint32(armv7m, \"num-irq\", 32);",
"break;",
"case FPGA_AN511:\nqdev_prop_set_uint32(armv7m, \"num-irq\", 64);",
"break;",
"default:\ng_assert_not_reached();",
"}",
"qdev_prop_set_string(armv7m, \"cpu-model\", VAR_0->cpu_model);",
"object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),\n\"memory\", &error_abort);",
"object_property_set_bool(OBJECT(&mms->armv7m), true, \"realized\",\n&error_fatal);",
"create_unimplemented_device(\"zbtsmram mirror\", 0x00400000, 0x00400000);",
"create_unimplemented_device(\"RESERVED 1\", 0x00800000, 0x00800000);",
"create_unimplemented_device(\"Block RAM\", 0x01000000, 0x00010000);",
"create_unimplemented_device(\"RESERVED 2\", 0x01010000, 0x1EFF0000);",
"create_unimplemented_device(\"RESERVED 3\", 0x20800000, 0x00800000);",
"create_unimplemented_device(\"PSRAM\", 0x21000000, 0x01000000);",
"create_unimplemented_device(\"CMSDK APB peripheral region @0x40000000\",\n0x40000000, 0x00010000);",
"create_unimplemented_device(\"CMSDK peripheral region @0x40010000\",\n0x40010000, 0x00010000);",
"create_unimplemented_device(\"Extra peripheral region @0x40020000\",\n0x40020000, 0x00010000);",
"create_unimplemented_device(\"RESERVED 4\", 0x40030000, 0x001D0000);",
"create_unimplemented_device(\"VGA\", 0x41000000, 0x0200000);",
"switch (mmc->fpga_type) {",
"case FPGA_AN385:\n{",
"Object *orgate;",
"DeviceState *orgate_dev;",
"int VAR_4;",
"orgate = object_new(TYPE_OR_IRQ);",
"object_property_set_int(orgate, 6, \"num-lines\", &error_fatal);",
"object_property_set_bool(orgate, true, \"realized\", &error_fatal);",
"orgate_dev = DEVICE(orgate);",
"qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));",
"for (VAR_4 = 0; VAR_4 < 5; VAR_4++) {",
"static const hwaddr VAR_5[] = {0x40004000, 0x40005000,",
"0x40006000, 0x40007000,\n0x40009000};",
"Chardev *uartchr = VAR_4 < MAX_SERIAL_PORTS ? serial_hds[VAR_4] : NULL;",
"static const int VAR_3[] = {0, 2, 4, 18, 20};",
"qemu_irq txovrint = NULL, rxovrint = NULL;",
"if (VAR_4 < 3) {",
"txovrint = qdev_get_gpio_in(orgate_dev, VAR_4 * 2);",
"rxovrint = qdev_get_gpio_in(orgate_dev, VAR_4 * 2 + 1);",
"}",
"cmsdk_apb_uart_create(VAR_5[VAR_4],\nqdev_get_gpio_in(armv7m, VAR_3[VAR_4] + 1),\nqdev_get_gpio_in(armv7m, VAR_3[VAR_4]),\ntxovrint, rxovrint,\nNULL,\nuartchr, SYSCLK_FRQ);",
"}",
"break;",
"}",
"case FPGA_AN511:\n{",
"Object *orgate;",
"DeviceState *orgate_dev;",
"int VAR_4;",
"orgate = object_new(TYPE_OR_IRQ);",
"object_property_set_int(orgate, 10, \"num-lines\", &error_fatal);",
"object_property_set_bool(orgate, true, \"realized\", &error_fatal);",
"orgate_dev = DEVICE(orgate);",
"qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));",
"for (VAR_4 = 0; VAR_4 < 5; VAR_4++) {",
"static const int VAR_4[] = {0, 2, 45, 46, 56};",
"static const hwaddr VAR_5[] = {0x40004000, 0x40005000,",
"0x4002c000, 0x4002d000,\n0x4002e000};",
"Chardev *uartchr = VAR_4 < MAX_SERIAL_PORTS ? serial_hds[VAR_4] : NULL;",
"Object *txrx_orgate;",
"DeviceState *txrx_orgate_dev;",
"txrx_orgate = object_new(TYPE_OR_IRQ);",
"object_property_set_int(txrx_orgate, 2, \"num-lines\", &error_fatal);",
"object_property_set_bool(txrx_orgate, true, \"realized\",\n&error_fatal);",
"txrx_orgate_dev = DEVICE(txrx_orgate);",
"qdev_connect_gpio_out(txrx_orgate_dev, 0,\nqdev_get_gpio_in(armv7m, VAR_4[VAR_4]));",
"cmsdk_apb_uart_create(VAR_5[VAR_4],\nqdev_get_gpio_in(txrx_orgate_dev, 0),\nqdev_get_gpio_in(txrx_orgate_dev, 1),\nqdev_get_gpio_in(orgate_dev, 0),\nqdev_get_gpio_in(orgate_dev, 1),\nNULL,\nuartchr, SYSCLK_FRQ);",
"}",
"break;",
"}",
"default:\ng_assert_not_reached();",
"}",
"cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);",
"cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);",
"object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);",
"sccdev = DEVICE(&mms->scc);",
"qdev_set_parent_bus(sccdev, sysbus_get_default());",
"qdev_prop_set_uint32(sccdev, \"scc-cfg4\", 0x2);",
"qdev_prop_set_uint32(sccdev, \"scc-aid\", 0x02000008);",
"qdev_prop_set_uint32(sccdev, \"scc-id\", mmc->scc_id);",
"object_property_set_bool(OBJECT(&mms->scc), true, \"realized\",\n&error_fatal);",
"sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);",
"lan9118_init(&nd_table[0], 0x40200000,\nqdev_get_gpio_in(armv7m,\nmmc->fpga_type == FPGA_AN385 ? 13 : 47));",
"system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;",
"armv7m_load_kernel(ARM_CPU(first_cpu), VAR_0->kernel_filename,\n0x400000);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
89,
91
],
[
93
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179,
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
205,
207
],
[
209,
211
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225,
227
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283,
285,
287,
289,
291,
293
],
[
295
],
[
297
],
[
299
],
[
301,
303
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
331
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353
],
[
355,
357
],
[
359
],
[
361,
363
],
[
365,
367,
369,
371,
373,
375,
377
],
[
379
],
[
381
],
[
383
],
[
385,
387
],
[
389
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411,
413
],
[
415
],
[
425,
427,
429
],
[
433
],
[
437,
439
],
[
441
]
] |
4,855 | static int xbm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
AVFrame *p = data;
const uint8_t *end, *ptr = avpkt->data;
uint8_t *dst;
int ret, linesize, i, j;
end = avpkt->data + avpkt->size;
while (!avctx->width || !avctx->height) {
char name[256];
int number, len;
ptr += strcspn(ptr, "#");
if (sscanf(ptr, "#define %256s %u", name, &number) != 2) {
av_log(avctx, AV_LOG_ERROR, "Unexpected preprocessor directive\n");
return AVERROR_INVALIDDATA;
}
len = strlen(name);
if ((len > 6) && !avctx->height && !memcmp(name + len - 7, "_height", 7)) {
avctx->height = number;
} else if ((len > 5) && !avctx->width && !memcmp(name + len - 6, "_width", 6)) {
avctx->width = number;
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown define '%s'\n", name);
return AVERROR_INVALIDDATA;
}
ptr += strcspn(ptr, "\n\r") + 1;
}
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
// goto start of image data
ptr += strcspn(ptr, "{") + 1;
linesize = (avctx->width + 7) / 8;
for (i = 0; i < avctx->height; i++) {
dst = p->data[0] + i * p->linesize[0];
for (j = 0; j < linesize; j++) {
uint8_t val;
ptr += strcspn(ptr, "x") + 1;
if (ptr < end && av_isxdigit(*ptr)) {
val = convert(*ptr);
ptr++;
if (av_isxdigit(*ptr))
val = (val << 4) + convert(*ptr);
*dst++ = ff_reverse[val];
} else {
av_log(avctx, AV_LOG_ERROR, "Unexpected data at '%.8s'\n", ptr);
return AVERROR_INVALIDDATA;
}
}
}
p->key_frame = 1;
p->pict_type = AV_PICTURE_TYPE_I;
*got_frame = 1;
return avpkt->size;
}
| true | FFmpeg | 369a12082635bb6655412dd4407759caf48d48c9 | static int xbm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
AVFrame *p = data;
const uint8_t *end, *ptr = avpkt->data;
uint8_t *dst;
int ret, linesize, i, j;
end = avpkt->data + avpkt->size;
while (!avctx->width || !avctx->height) {
char name[256];
int number, len;
ptr += strcspn(ptr, "#");
if (sscanf(ptr, "#define %256s %u", name, &number) != 2) {
av_log(avctx, AV_LOG_ERROR, "Unexpected preprocessor directive\n");
return AVERROR_INVALIDDATA;
}
len = strlen(name);
if ((len > 6) && !avctx->height && !memcmp(name + len - 7, "_height", 7)) {
avctx->height = number;
} else if ((len > 5) && !avctx->width && !memcmp(name + len - 6, "_width", 6)) {
avctx->width = number;
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown define '%s'\n", name);
return AVERROR_INVALIDDATA;
}
ptr += strcspn(ptr, "\n\r") + 1;
}
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
ptr += strcspn(ptr, "{") + 1;
linesize = (avctx->width + 7) / 8;
for (i = 0; i < avctx->height; i++) {
dst = p->data[0] + i * p->linesize[0];
for (j = 0; j < linesize; j++) {
uint8_t val;
ptr += strcspn(ptr, "x") + 1;
if (ptr < end && av_isxdigit(*ptr)) {
val = convert(*ptr);
ptr++;
if (av_isxdigit(*ptr))
val = (val << 4) + convert(*ptr);
*dst++ = ff_reverse[val];
} else {
av_log(avctx, AV_LOG_ERROR, "Unexpected data at '%.8s'\n", ptr);
return AVERROR_INVALIDDATA;
}
}
}
p->key_frame = 1;
p->pict_type = AV_PICTURE_TYPE_I;
*got_frame = 1;
return avpkt->size;
}
| {
"code": [
" if (sscanf(ptr, \"#define %256s %u\", name, &number) != 2) {"
],
"line_no": [
29
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVFrame *p = VAR_1;
const uint8_t *VAR_4, *ptr = VAR_3->VAR_1;
uint8_t *dst;
int VAR_5, VAR_6, VAR_7, VAR_8;
VAR_4 = VAR_3->VAR_1 + VAR_3->size;
while (!VAR_0->width || !VAR_0->height) {
char VAR_9[256];
int VAR_10, VAR_11;
ptr += strcspn(ptr, "#");
if (sscanf(ptr, "#define %256s %u", VAR_9, &VAR_10) != 2) {
av_log(VAR_0, AV_LOG_ERROR, "Unexpected preprocessor directive\n");
return AVERROR_INVALIDDATA;
}
VAR_11 = strlen(VAR_9);
if ((VAR_11 > 6) && !VAR_0->height && !memcmp(VAR_9 + VAR_11 - 7, "_height", 7)) {
VAR_0->height = VAR_10;
} else if ((VAR_11 > 5) && !VAR_0->width && !memcmp(VAR_9 + VAR_11 - 6, "_width", 6)) {
VAR_0->width = VAR_10;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unknown define '%s'\n", VAR_9);
return AVERROR_INVALIDDATA;
}
ptr += strcspn(ptr, "\n\r") + 1;
}
if ((VAR_5 = ff_get_buffer(VAR_0, p, 0)) < 0)
return VAR_5;
ptr += strcspn(ptr, "{") + 1;
VAR_6 = (VAR_0->width + 7) / 8;
for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {
dst = p->VAR_1[0] + VAR_7 * p->VAR_6[0];
for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) {
uint8_t val;
ptr += strcspn(ptr, "x") + 1;
if (ptr < VAR_4 && av_isxdigit(*ptr)) {
val = convert(*ptr);
ptr++;
if (av_isxdigit(*ptr))
val = (val << 4) + convert(*ptr);
*dst++ = ff_reverse[val];
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unexpected VAR_1 at '%.8s'\n", ptr);
return AVERROR_INVALIDDATA;
}
}
}
p->key_frame = 1;
p->pict_type = AV_PICTURE_TYPE_I;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *p = VAR_1;",
"const uint8_t *VAR_4, *ptr = VAR_3->VAR_1;",
"uint8_t *dst;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"VAR_4 = VAR_3->VAR_1 + VAR_3->size;",
"while (!VAR_0->width || !VAR_0->height) {",
"char VAR_9[256];",
"int VAR_10, VAR_11;",
"ptr += strcspn(ptr, \"#\");",
"if (sscanf(ptr, \"#define %256s %u\", VAR_9, &VAR_10) != 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unexpected preprocessor directive\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = strlen(VAR_9);",
"if ((VAR_11 > 6) && !VAR_0->height && !memcmp(VAR_9 + VAR_11 - 7, \"_height\", 7)) {",
"VAR_0->height = VAR_10;",
"} else if ((VAR_11 > 5) && !VAR_0->width && !memcmp(VAR_9 + VAR_11 - 6, \"_width\", 6)) {",
"VAR_0->width = VAR_10;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown define '%s'\\n\", VAR_9);",
"return AVERROR_INVALIDDATA;",
"}",
"ptr += strcspn(ptr, \"\\n\\r\") + 1;",
"}",
"if ((VAR_5 = ff_get_buffer(VAR_0, p, 0)) < 0)\nreturn VAR_5;",
"ptr += strcspn(ptr, \"{\") + 1;",
"VAR_6 = (VAR_0->width + 7) / 8;",
"for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {",
"dst = p->VAR_1[0] + VAR_7 * p->VAR_6[0];",
"for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) {",
"uint8_t val;",
"ptr += strcspn(ptr, \"x\") + 1;",
"if (ptr < VAR_4 && av_isxdigit(*ptr)) {",
"val = convert(*ptr);",
"ptr++;",
"if (av_isxdigit(*ptr))\nval = (val << 4) + convert(*ptr);",
"*dst++ = ff_reverse[val];",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unexpected VAR_1 at '%.8s'\\n\", ptr);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"p->key_frame = 1;",
"p->pict_type = AV_PICTURE_TYPE_I;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
]
] |
4,856 | int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
target_ulong tmp;
tmp = ldtul_p(mem_buf);
if (n < 32) {
env->active_tc.gpr[n] = tmp;
return sizeof(target_ulong);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)
&& n >= 38 && n < 73) {
if (n < 70) {
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[n - 38].d = tmp;
} else {
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX] = tmp;
}
}
switch (n) {
case 70:
env->active_fpu.fcr31 = tmp & 0xFF83FFFF;
/* set rounding mode */
RESTORE_ROUNDING_MODE;
break;
case 71:
env->active_fpu.fcr0 = tmp;
break;
}
return sizeof(target_ulong);
}
switch (n) {
case 32:
env->CP0_Status = tmp;
break;
case 33:
env->active_tc.LO[0] = tmp;
break;
case 34:
env->active_tc.HI[0] = tmp;
break;
case 35:
env->CP0_BadVAddr = tmp;
break;
case 36:
env->CP0_Cause = tmp;
break;
case 37:
env->active_tc.PC = tmp & ~(target_ulong)1;
if (tmp & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
break;
case 72: /* fp, ignored */
break;
default:
if (n > 89) {
return 0;
}
/* Other registers are readonly. Ignore writes. */
break;
}
return sizeof(target_ulong);
}
| true | qemu | 800675f11742b6080e40d17b8d5f35d3a5fc5724 | int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
target_ulong tmp;
tmp = ldtul_p(mem_buf);
if (n < 32) {
env->active_tc.gpr[n] = tmp;
return sizeof(target_ulong);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)
&& n >= 38 && n < 73) {
if (n < 70) {
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[n - 38].d = tmp;
} else {
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX] = tmp;
}
}
switch (n) {
case 70:
env->active_fpu.fcr31 = tmp & 0xFF83FFFF;
RESTORE_ROUNDING_MODE;
break;
case 71:
env->active_fpu.fcr0 = tmp;
break;
}
return sizeof(target_ulong);
}
switch (n) {
case 32:
env->CP0_Status = tmp;
break;
case 33:
env->active_tc.LO[0] = tmp;
break;
case 34:
env->active_tc.HI[0] = tmp;
break;
case 35:
env->CP0_BadVAddr = tmp;
break;
case 36:
env->CP0_Cause = tmp;
break;
case 37:
env->active_tc.PC = tmp & ~(target_ulong)1;
if (tmp & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
break;
case 72:
break;
default:
if (n > 89) {
return 0;
}
break;
}
return sizeof(target_ulong);
}
| {
"code": [
" && n >= 38 && n < 73) {"
],
"line_no": [
27
]
} | int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)
{
MIPSCPU *cpu = MIPS_CPU(VAR_0);
CPUMIPSState *env = &cpu->env;
target_ulong tmp;
tmp = ldtul_p(VAR_1);
if (VAR_2 < 32) {
env->active_tc.gpr[VAR_2] = tmp;
return sizeof(target_ulong);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)
&& VAR_2 >= 38 && VAR_2 < 73) {
if (VAR_2 < 70) {
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[VAR_2 - 38].d = tmp;
} else {
env->active_fpu.fpr[VAR_2 - 38].w[FP_ENDIAN_IDX] = tmp;
}
}
switch (VAR_2) {
case 70:
env->active_fpu.fcr31 = tmp & 0xFF83FFFF;
RESTORE_ROUNDING_MODE;
break;
case 71:
env->active_fpu.fcr0 = tmp;
break;
}
return sizeof(target_ulong);
}
switch (VAR_2) {
case 32:
env->CP0_Status = tmp;
break;
case 33:
env->active_tc.LO[0] = tmp;
break;
case 34:
env->active_tc.HI[0] = tmp;
break;
case 35:
env->CP0_BadVAddr = tmp;
break;
case 36:
env->CP0_Cause = tmp;
break;
case 37:
env->active_tc.PC = tmp & ~(target_ulong)1;
if (tmp & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
break;
case 72:
break;
default:
if (VAR_2 > 89) {
return 0;
}
break;
}
return sizeof(target_ulong);
}
| [
"int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"MIPSCPU *cpu = MIPS_CPU(VAR_0);",
"CPUMIPSState *env = &cpu->env;",
"target_ulong tmp;",
"tmp = ldtul_p(VAR_1);",
"if (VAR_2 < 32) {",
"env->active_tc.gpr[VAR_2] = tmp;",
"return sizeof(target_ulong);",
"}",
"if (env->CP0_Config1 & (1 << CP0C1_FP)\n&& VAR_2 >= 38 && VAR_2 < 73) {",
"if (VAR_2 < 70) {",
"if (env->CP0_Status & (1 << CP0St_FR)) {",
"env->active_fpu.fpr[VAR_2 - 38].d = tmp;",
"} else {",
"env->active_fpu.fpr[VAR_2 - 38].w[FP_ENDIAN_IDX] = tmp;",
"}",
"}",
"switch (VAR_2) {",
"case 70:\nenv->active_fpu.fcr31 = tmp & 0xFF83FFFF;",
"RESTORE_ROUNDING_MODE;",
"break;",
"case 71:\nenv->active_fpu.fcr0 = tmp;",
"break;",
"}",
"return sizeof(target_ulong);",
"}",
"switch (VAR_2) {",
"case 32:\nenv->CP0_Status = tmp;",
"break;",
"case 33:\nenv->active_tc.LO[0] = tmp;",
"break;",
"case 34:\nenv->active_tc.HI[0] = tmp;",
"break;",
"case 35:\nenv->CP0_BadVAddr = tmp;",
"break;",
"case 36:\nenv->CP0_Cause = tmp;",
"break;",
"case 37:\nenv->active_tc.PC = tmp & ~(target_ulong)1;",
"if (tmp & 1) {",
"env->hflags |= MIPS_HFLAG_M16;",
"} else {",
"env->hflags &= ~(MIPS_HFLAG_M16);",
"}",
"break;",
"case 72:\nbreak;",
"default:\nif (VAR_2 > 89) {",
"return 0;",
"}",
"break;",
"}",
"return sizeof(target_ulong);",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
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
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
137
]
] |
4,857 | static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int i;
char header[MAX_FRAME_HEADER+1];
int ret;
int64_t off = avio_tell(s->pb);
for (i = 0; i < MAX_FRAME_HEADER; i++) {
header[i] = avio_r8(s->pb);
if (header[i] == '\n') {
header[i + 1] = 0;
break;
}
}
if (s->pb->error)
return s->pb->error;
else if (s->pb->eof_reached)
return AVERROR_EOF;
else if (i == MAX_FRAME_HEADER)
return AVERROR_INVALIDDATA;
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
return AVERROR_INVALIDDATA;
ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);
if (ret < 0)
return ret;
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
pkt->stream_index = 0;
pkt->pts = (off - s->internal->data_offset) / s->packet_size;
pkt->duration = 1;
return 0;
}
| true | FFmpeg | e3694478a98bc2cd702b3b3f0bfb19a100da737e | static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int i;
char header[MAX_FRAME_HEADER+1];
int ret;
int64_t off = avio_tell(s->pb);
for (i = 0; i < MAX_FRAME_HEADER; i++) {
header[i] = avio_r8(s->pb);
if (header[i] == '\n') {
header[i + 1] = 0;
break;
}
}
if (s->pb->error)
return s->pb->error;
else if (s->pb->eof_reached)
return AVERROR_EOF;
else if (i == MAX_FRAME_HEADER)
return AVERROR_INVALIDDATA;
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
return AVERROR_INVALIDDATA;
ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);
if (ret < 0)
return ret;
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
pkt->stream_index = 0;
pkt->pts = (off - s->internal->data_offset) / s->packet_size;
pkt->duration = 1;
return 0;
}
| {
"code": [
" else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)"
],
"line_no": [
55
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2;
char VAR_3[MAX_FRAME_HEADER+1];
int VAR_4;
int64_t off = avio_tell(VAR_0->pb);
for (VAR_2 = 0; VAR_2 < MAX_FRAME_HEADER; VAR_2++) {
VAR_3[VAR_2] = avio_r8(VAR_0->pb);
if (VAR_3[VAR_2] == '\n') {
VAR_3[VAR_2 + 1] = 0;
break;
}
}
if (VAR_0->pb->error)
return VAR_0->pb->error;
else if (VAR_0->pb->eof_reached)
return AVERROR_EOF;
else if (VAR_2 == MAX_FRAME_HEADER)
return AVERROR_INVALIDDATA;
if (strncmp(VAR_3, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
return AVERROR_INVALIDDATA;
VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN);
if (VAR_4 < 0)
return VAR_4;
else if (VAR_4 != VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN)
return VAR_0->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
VAR_1->stream_index = 0;
VAR_1->pts = (off - VAR_0->internal->data_offset) / VAR_0->packet_size;
VAR_1->duration = 1;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2;",
"char VAR_3[MAX_FRAME_HEADER+1];",
"int VAR_4;",
"int64_t off = avio_tell(VAR_0->pb);",
"for (VAR_2 = 0; VAR_2 < MAX_FRAME_HEADER; VAR_2++) {",
"VAR_3[VAR_2] = avio_r8(VAR_0->pb);",
"if (VAR_3[VAR_2] == '\\n') {",
"VAR_3[VAR_2 + 1] = 0;",
"break;",
"}",
"}",
"if (VAR_0->pb->error)\nreturn VAR_0->pb->error;",
"else if (VAR_0->pb->eof_reached)\nreturn AVERROR_EOF;",
"else if (VAR_2 == MAX_FRAME_HEADER)\nreturn AVERROR_INVALIDDATA;",
"if (strncmp(VAR_3, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"else if (VAR_4 != VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN)\nreturn VAR_0->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);",
"VAR_1->stream_index = 0;",
"VAR_1->pts = (off - VAR_0->internal->data_offset) / VAR_0->packet_size;",
"VAR_1->duration = 1;",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
43,
45
],
[
49
],
[
51,
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
4,858 | uint64_t HELPER(neon_add_saturate_u64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 + src2;
if (res < src1) {
env->QF = 1;
res = ~(uint64_t)0;
}
return res;
}
| true | qemu | 72902672dc2ed6281cdb205259c1d52ecf01f6b2 | uint64_t HELPER(neon_add_saturate_u64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 + src2;
if (res < src1) {
env->QF = 1;
res = ~(uint64_t)0;
}
return res;
}
| {
"code": [
" uint64_t res;",
" res = src1 + src2;",
" env->QF = 1;",
" return res;",
"uint64_t HELPER(neon_add_saturate_u64)(uint64_t src1, uint64_t src2)",
" uint64_t res;",
" res = src1 + src2;",
" if (res < src1) {",
" env->QF = 1;",
" res = ~(uint64_t)0;",
" return res;",
" uint64_t res;",
" env->QF = 1;",
" return res;",
" uint64_t res;",
" env->QF = 1;",
" return res;"
],
"line_no": [
5,
9,
13,
19,
1,
5,
9,
11,
13,
15,
19,
5,
13,
19,
5,
13,
19
]
} | uint64_t FUNC_0(neon_add_saturate_u64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 + src2;
if (res < src1) {
env->QF = 1;
res = ~(uint64_t)0;
}
return res;
}
| [
"uint64_t FUNC_0(neon_add_saturate_u64)(uint64_t src1, uint64_t src2)\n{",
"uint64_t res;",
"res = src1 + src2;",
"if (res < src1) {",
"env->QF = 1;",
"res = ~(uint64_t)0;",
"}",
"return res;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
4,859 | static void load_linux(PCMachineState *pcms,
FWCfgState *fw_cfg)
{
uint16_t protocol;
int setup_size, kernel_size, initrd_size = 0, cmdline_size;
uint32_t initrd_max;
uint8_t header[8192], *setup, *kernel, *initrd_data;
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
FILE *f;
char *vmode;
MachineState *machine = MACHINE(pcms);
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
/* Align to 16 bytes as a paranoia measure */
cmdline_size = (strlen(kernel_cmdline)+16) & ~15;
/* load the kernel header */
f = fopen(kernel_filename, "rb");
if (!f || !(kernel_size = get_file_size(f)) ||
fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
MIN(ARRAY_SIZE(header), kernel_size)) {
fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
kernel_filename, strerror(errno));
/* kernel protocol version */
#if 0
fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
#endif
if (ldl_p(header+0x202) == 0x53726448) {
protocol = lduw_p(header+0x206);
} else {
/* This looks like a multiboot kernel. If it is, let's stop
treating it like a Linux kernel. */
if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
kernel_cmdline, kernel_size, header)) {
return;
protocol = 0;
if (protocol < 0x200 || !(header[0x211] & 0x01)) {
/* Low kernel */
real_addr = 0x90000;
cmdline_addr = 0x9a000 - cmdline_size;
prot_addr = 0x10000;
} else if (protocol < 0x202) {
/* High but ancient kernel */
real_addr = 0x90000;
cmdline_addr = 0x9a000 - cmdline_size;
prot_addr = 0x100000;
} else {
/* High and recent kernel */
real_addr = 0x10000;
cmdline_addr = 0x20000;
prot_addr = 0x100000;
#if 0
fprintf(stderr,
"qemu: real_addr = 0x" TARGET_FMT_plx "\n"
"qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n"
"qemu: prot_addr = 0x" TARGET_FMT_plx "\n",
real_addr,
cmdline_addr,
prot_addr);
#endif
/* highest address for loading the initrd */
if (protocol >= 0x203) {
initrd_max = ldl_p(header+0x22c);
} else {
initrd_max = 0x37ffffff;
if (initrd_max >= pcms->below_4g_mem_size - acpi_data_size) {
initrd_max = pcms->below_4g_mem_size - acpi_data_size - 1;
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
if (protocol >= 0x202) {
stl_p(header+0x228, cmdline_addr);
} else {
stw_p(header+0x20, 0xA33F);
stw_p(header+0x22, cmdline_addr-real_addr);
/* handle vga= parameter */
vmode = strstr(kernel_cmdline, "vga=");
if (vmode) {
unsigned int video_mode;
/* skip "vga=" */
vmode += 4;
if (!strncmp(vmode, "normal", 6)) {
video_mode = 0xffff;
} else if (!strncmp(vmode, "ext", 3)) {
video_mode = 0xfffe;
} else if (!strncmp(vmode, "ask", 3)) {
video_mode = 0xfffd;
} else {
video_mode = strtol(vmode, NULL, 0);
stw_p(header+0x1fa, video_mode);
/* loader type */
/* High nybble = B reserved for QEMU; low nybble is revision number.
If this code is substantially changed, you may want to consider
incrementing the revision. */
if (protocol >= 0x200) {
header[0x210] = 0xB0;
/* heap */
if (protocol >= 0x201) {
header[0x211] |= 0x80; /* CAN_USE_HEAP */
stw_p(header+0x224, cmdline_addr-real_addr-0x200);
/* load initrd */
if (initrd_filename) {
if (protocol < 0x200) {
fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n");
initrd_size = get_image_size(initrd_filename);
if (initrd_size < 0) {
fprintf(stderr, "qemu: error reading initrd %s: %s\n",
initrd_filename, strerror(errno));
initrd_addr = (initrd_max-initrd_size) & ~4095;
initrd_data = g_malloc(initrd_size);
load_image(initrd_filename, initrd_data);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size);
stl_p(header+0x218, initrd_addr);
stl_p(header+0x21c, initrd_size);
/* load kernel and setup */
setup_size = header[0x1f1];
if (setup_size == 0) {
setup_size = 4;
setup_size = (setup_size+1)*512;
kernel_size -= setup_size;
setup = g_malloc(setup_size);
kernel = g_malloc(kernel_size);
fseek(f, 0, SEEK_SET);
if (fread(setup, 1, setup_size, f) != setup_size) {
fprintf(stderr, "fread() failed\n");
if (fread(kernel, 1, kernel_size, f) != kernel_size) {
fprintf(stderr, "fread() failed\n");
fclose(f);
memcpy(setup, header, MIN(sizeof(header), setup_size));
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
option_rom[nb_option_roms].name = "linuxboot.bin";
option_rom[nb_option_roms].bootindex = 0;
nb_option_roms++;
| true | qemu | ec5fd402645fd4f03d89dcd5840b0e8542549e82 | static void load_linux(PCMachineState *pcms,
FWCfgState *fw_cfg)
{
uint16_t protocol;
int setup_size, kernel_size, initrd_size = 0, cmdline_size;
uint32_t initrd_max;
uint8_t header[8192], *setup, *kernel, *initrd_data;
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
FILE *f;
char *vmode;
MachineState *machine = MACHINE(pcms);
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
cmdline_size = (strlen(kernel_cmdline)+16) & ~15;
f = fopen(kernel_filename, "rb");
if (!f || !(kernel_size = get_file_size(f)) ||
fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
MIN(ARRAY_SIZE(header), kernel_size)) {
fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
kernel_filename, strerror(errno));
#if 0
fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
#endif
if (ldl_p(header+0x202) == 0x53726448) {
protocol = lduw_p(header+0x206);
} else {
if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
kernel_cmdline, kernel_size, header)) {
return;
protocol = 0;
if (protocol < 0x200 || !(header[0x211] & 0x01)) {
real_addr = 0x90000;
cmdline_addr = 0x9a000 - cmdline_size;
prot_addr = 0x10000;
} else if (protocol < 0x202) {
real_addr = 0x90000;
cmdline_addr = 0x9a000 - cmdline_size;
prot_addr = 0x100000;
} else {
real_addr = 0x10000;
cmdline_addr = 0x20000;
prot_addr = 0x100000;
#if 0
fprintf(stderr,
"qemu: real_addr = 0x" TARGET_FMT_plx "\n"
"qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n"
"qemu: prot_addr = 0x" TARGET_FMT_plx "\n",
real_addr,
cmdline_addr,
prot_addr);
#endif
if (protocol >= 0x203) {
initrd_max = ldl_p(header+0x22c);
} else {
initrd_max = 0x37ffffff;
if (initrd_max >= pcms->below_4g_mem_size - acpi_data_size) {
initrd_max = pcms->below_4g_mem_size - acpi_data_size - 1;
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
if (protocol >= 0x202) {
stl_p(header+0x228, cmdline_addr);
} else {
stw_p(header+0x20, 0xA33F);
stw_p(header+0x22, cmdline_addr-real_addr);
vmode = strstr(kernel_cmdline, "vga=");
if (vmode) {
unsigned int video_mode;
vmode += 4;
if (!strncmp(vmode, "normal", 6)) {
video_mode = 0xffff;
} else if (!strncmp(vmode, "ext", 3)) {
video_mode = 0xfffe;
} else if (!strncmp(vmode, "ask", 3)) {
video_mode = 0xfffd;
} else {
video_mode = strtol(vmode, NULL, 0);
stw_p(header+0x1fa, video_mode);
if (protocol >= 0x200) {
header[0x210] = 0xB0;
if (protocol >= 0x201) {
header[0x211] |= 0x80;
stw_p(header+0x224, cmdline_addr-real_addr-0x200);
if (initrd_filename) {
if (protocol < 0x200) {
fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n");
initrd_size = get_image_size(initrd_filename);
if (initrd_size < 0) {
fprintf(stderr, "qemu: error reading initrd %s: %s\n",
initrd_filename, strerror(errno));
initrd_addr = (initrd_max-initrd_size) & ~4095;
initrd_data = g_malloc(initrd_size);
load_image(initrd_filename, initrd_data);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size);
stl_p(header+0x218, initrd_addr);
stl_p(header+0x21c, initrd_size);
setup_size = header[0x1f1];
if (setup_size == 0) {
setup_size = 4;
setup_size = (setup_size+1)*512;
kernel_size -= setup_size;
setup = g_malloc(setup_size);
kernel = g_malloc(kernel_size);
fseek(f, 0, SEEK_SET);
if (fread(setup, 1, setup_size, f) != setup_size) {
fprintf(stderr, "fread() failed\n");
if (fread(kernel, 1, kernel_size, f) != kernel_size) {
fprintf(stderr, "fread() failed\n");
fclose(f);
memcpy(setup, header, MIN(sizeof(header), setup_size));
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
option_rom[nb_option_roms].name = "linuxboot.bin";
option_rom[nb_option_roms].bootindex = 0;
nb_option_roms++;
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCMachineState *VAR_0,
FWCfgState *VAR_1)
{
uint16_t protocol;
int VAR_2, VAR_3, VAR_4 = 0, VAR_5;
uint32_t initrd_max;
uint8_t header[8192], *setup, *kernel, *initrd_data;
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
FILE *f;
char *VAR_6;
MachineState *machine = MACHINE(VAR_0);
const char *VAR_7 = machine->VAR_7;
const char *VAR_8 = machine->VAR_8;
const char *VAR_9 = machine->VAR_9;
VAR_5 = (strlen(VAR_9)+16) & ~15;
f = fopen(VAR_7, "rb");
if (!f || !(VAR_3 = get_file_size(f)) ||
fread(header, 1, MIN(ARRAY_SIZE(header), VAR_3), f) !=
MIN(ARRAY_SIZE(header), VAR_3)) {
fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
VAR_7, strerror(errno));
#if 0
fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
#endif
if (ldl_p(header+0x202) == 0x53726448) {
protocol = lduw_p(header+0x206);
} else {
if (load_multiboot(VAR_1, f, VAR_7, VAR_8,
VAR_9, VAR_3, header)) {
return;
protocol = 0;
if (protocol < 0x200 || !(header[0x211] & 0x01)) {
real_addr = 0x90000;
cmdline_addr = 0x9a000 - VAR_5;
prot_addr = 0x10000;
} else if (protocol < 0x202) {
real_addr = 0x90000;
cmdline_addr = 0x9a000 - VAR_5;
prot_addr = 0x100000;
} else {
real_addr = 0x10000;
cmdline_addr = 0x20000;
prot_addr = 0x100000;
#if 0
fprintf(stderr,
"qemu: real_addr = 0x" TARGET_FMT_plx "\n"
"qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n"
"qemu: prot_addr = 0x" TARGET_FMT_plx "\n",
real_addr,
cmdline_addr,
prot_addr);
#endif
if (protocol >= 0x203) {
initrd_max = ldl_p(header+0x22c);
} else {
initrd_max = 0x37ffffff;
if (initrd_max >= VAR_0->below_4g_mem_size - acpi_data_size) {
initrd_max = VAR_0->below_4g_mem_size - acpi_data_size - 1;
fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_ADDR, cmdline_addr);
fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_SIZE, strlen(VAR_9)+1);
fw_cfg_add_string(VAR_1, FW_CFG_CMDLINE_DATA, VAR_9);
if (protocol >= 0x202) {
stl_p(header+0x228, cmdline_addr);
} else {
stw_p(header+0x20, 0xA33F);
stw_p(header+0x22, cmdline_addr-real_addr);
VAR_6 = strstr(VAR_9, "vga=");
if (VAR_6) {
unsigned int VAR_10;
VAR_6 += 4;
if (!strncmp(VAR_6, "normal", 6)) {
VAR_10 = 0xffff;
} else if (!strncmp(VAR_6, "ext", 3)) {
VAR_10 = 0xfffe;
} else if (!strncmp(VAR_6, "ask", 3)) {
VAR_10 = 0xfffd;
} else {
VAR_10 = strtol(VAR_6, NULL, 0);
stw_p(header+0x1fa, VAR_10);
if (protocol >= 0x200) {
header[0x210] = 0xB0;
if (protocol >= 0x201) {
header[0x211] |= 0x80;
stw_p(header+0x224, cmdline_addr-real_addr-0x200);
if (VAR_8) {
if (protocol < 0x200) {
fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n");
VAR_4 = get_image_size(VAR_8);
if (VAR_4 < 0) {
fprintf(stderr, "qemu: error reading initrd %s: %s\n",
VAR_8, strerror(errno));
initrd_addr = (initrd_max-VAR_4) & ~4095;
initrd_data = g_malloc(VAR_4);
load_image(VAR_8, initrd_data);
fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_ADDR, initrd_addr);
fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_SIZE, VAR_4);
fw_cfg_add_bytes(VAR_1, FW_CFG_INITRD_DATA, initrd_data, VAR_4);
stl_p(header+0x218, initrd_addr);
stl_p(header+0x21c, VAR_4);
VAR_2 = header[0x1f1];
if (VAR_2 == 0) {
VAR_2 = 4;
VAR_2 = (VAR_2+1)*512;
VAR_3 -= VAR_2;
setup = g_malloc(VAR_2);
kernel = g_malloc(VAR_3);
fseek(f, 0, SEEK_SET);
if (fread(setup, 1, VAR_2, f) != VAR_2) {
fprintf(stderr, "fread() failed\n");
if (fread(kernel, 1, VAR_3, f) != VAR_3) {
fprintf(stderr, "fread() failed\n");
fclose(f);
memcpy(setup, header, MIN(sizeof(header), VAR_2));
fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_ADDR, prot_addr);
fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_SIZE, VAR_3);
fw_cfg_add_bytes(VAR_1, FW_CFG_KERNEL_DATA, kernel, VAR_3);
fw_cfg_add_i32(VAR_1, FW_CFG_SETUP_ADDR, real_addr);
fw_cfg_add_i32(VAR_1, FW_CFG_SETUP_SIZE, VAR_2);
fw_cfg_add_bytes(VAR_1, FW_CFG_SETUP_DATA, setup, VAR_2);
option_rom[nb_option_roms].name = "linuxboot.bin";
option_rom[nb_option_roms].bootindex = 0;
nb_option_roms++;
| [
"static void FUNC_0(PCMachineState *VAR_0,\nFWCfgState *VAR_1)\n{",
"uint16_t protocol;",
"int VAR_2, VAR_3, VAR_4 = 0, VAR_5;",
"uint32_t initrd_max;",
"uint8_t header[8192], *setup, *kernel, *initrd_data;",
"hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;",
"FILE *f;",
"char *VAR_6;",
"MachineState *machine = MACHINE(VAR_0);",
"const char *VAR_7 = machine->VAR_7;",
"const char *VAR_8 = machine->VAR_8;",
"const char *VAR_9 = machine->VAR_9;",
"VAR_5 = (strlen(VAR_9)+16) & ~15;",
"f = fopen(VAR_7, \"rb\");",
"if (!f || !(VAR_3 = get_file_size(f)) ||\nfread(header, 1, MIN(ARRAY_SIZE(header), VAR_3), f) !=\nMIN(ARRAY_SIZE(header), VAR_3)) {",
"fprintf(stderr, \"qemu: could not load kernel '%s': %s\\n\",\nVAR_7, strerror(errno));",
"#if 0\nfprintf(stderr, \"header magic: %#x\\n\", ldl_p(header+0x202));",
"#endif\nif (ldl_p(header+0x202) == 0x53726448) {",
"protocol = lduw_p(header+0x206);",
"} else {",
"if (load_multiboot(VAR_1, f, VAR_7, VAR_8,\nVAR_9, VAR_3, header)) {",
"return;",
"protocol = 0;",
"if (protocol < 0x200 || !(header[0x211] & 0x01)) {",
"real_addr = 0x90000;",
"cmdline_addr = 0x9a000 - VAR_5;",
"prot_addr = 0x10000;",
"} else if (protocol < 0x202) {",
"real_addr = 0x90000;",
"cmdline_addr = 0x9a000 - VAR_5;",
"prot_addr = 0x100000;",
"} else {",
"real_addr = 0x10000;",
"cmdline_addr = 0x20000;",
"prot_addr = 0x100000;",
"#if 0\nfprintf(stderr,\n\"qemu: real_addr = 0x\" TARGET_FMT_plx \"\\n\"\n\"qemu: cmdline_addr = 0x\" TARGET_FMT_plx \"\\n\"\n\"qemu: prot_addr = 0x\" TARGET_FMT_plx \"\\n\",\nreal_addr,\ncmdline_addr,\nprot_addr);",
"#endif\nif (protocol >= 0x203) {",
"initrd_max = ldl_p(header+0x22c);",
"} else {",
"initrd_max = 0x37ffffff;",
"if (initrd_max >= VAR_0->below_4g_mem_size - acpi_data_size) {",
"initrd_max = VAR_0->below_4g_mem_size - acpi_data_size - 1;",
"fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_ADDR, cmdline_addr);",
"fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_SIZE, strlen(VAR_9)+1);",
"fw_cfg_add_string(VAR_1, FW_CFG_CMDLINE_DATA, VAR_9);",
"if (protocol >= 0x202) {",
"stl_p(header+0x228, cmdline_addr);",
"} else {",
"stw_p(header+0x20, 0xA33F);",
"stw_p(header+0x22, cmdline_addr-real_addr);",
"VAR_6 = strstr(VAR_9, \"vga=\");",
"if (VAR_6) {",
"unsigned int VAR_10;",
"VAR_6 += 4;",
"if (!strncmp(VAR_6, \"normal\", 6)) {",
"VAR_10 = 0xffff;",
"} else if (!strncmp(VAR_6, \"ext\", 3)) {",
"VAR_10 = 0xfffe;",
"} else if (!strncmp(VAR_6, \"ask\", 3)) {",
"VAR_10 = 0xfffd;",
"} else {",
"VAR_10 = strtol(VAR_6, NULL, 0);",
"stw_p(header+0x1fa, VAR_10);",
"if (protocol >= 0x200) {",
"header[0x210] = 0xB0;",
"if (protocol >= 0x201) {",
"header[0x211] |= 0x80;",
"stw_p(header+0x224, cmdline_addr-real_addr-0x200);",
"if (VAR_8) {",
"if (protocol < 0x200) {",
"fprintf(stderr, \"qemu: linux kernel too old to load a ram disk\\n\");",
"VAR_4 = get_image_size(VAR_8);",
"if (VAR_4 < 0) {",
"fprintf(stderr, \"qemu: error reading initrd %s: %s\\n\",\nVAR_8, strerror(errno));",
"initrd_addr = (initrd_max-VAR_4) & ~4095;",
"initrd_data = g_malloc(VAR_4);",
"load_image(VAR_8, initrd_data);",
"fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_ADDR, initrd_addr);",
"fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_SIZE, VAR_4);",
"fw_cfg_add_bytes(VAR_1, FW_CFG_INITRD_DATA, initrd_data, VAR_4);",
"stl_p(header+0x218, initrd_addr);",
"stl_p(header+0x21c, VAR_4);",
"VAR_2 = header[0x1f1];",
"if (VAR_2 == 0) {",
"VAR_2 = 4;",
"VAR_2 = (VAR_2+1)*512;",
"VAR_3 -= VAR_2;",
"setup = g_malloc(VAR_2);",
"kernel = g_malloc(VAR_3);",
"fseek(f, 0, SEEK_SET);",
"if (fread(setup, 1, VAR_2, f) != VAR_2) {",
"fprintf(stderr, \"fread() failed\\n\");",
"if (fread(kernel, 1, VAR_3, f) != VAR_3) {",
"fprintf(stderr, \"fread() failed\\n\");",
"fclose(f);",
"memcpy(setup, header, MIN(sizeof(header), VAR_2));",
"fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_ADDR, prot_addr);",
"fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_SIZE, VAR_3);",
"fw_cfg_add_bytes(VAR_1, FW_CFG_KERNEL_DATA, kernel, VAR_3);",
"fw_cfg_add_i32(VAR_1, FW_CFG_SETUP_ADDR, real_addr);",
"fw_cfg_add_i32(VAR_1, FW_CFG_SETUP_SIZE, VAR_2);",
"fw_cfg_add_bytes(VAR_1, FW_CFG_SETUP_DATA, setup, VAR_2);",
"option_rom[nb_option_roms].name = \"linuxboot.bin\";",
"option_rom[nb_option_roms].bootindex = 0;",
"nb_option_roms++;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
39
],
[
41,
43,
45
],
[
47,
49
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67
],
[
73,
75
],
[
77
],
[
80
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
118,
120,
122,
124,
126,
128,
130,
132
],
[
134,
140
],
[
142
],
[
144
],
[
146
],
[
151
],
[
153
],
[
158
],
[
160
],
[
162
],
[
166
],
[
168
],
[
170
],
[
172
],
[
174
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
208
],
[
221
],
[
223
],
[
228
],
[
230
],
[
232
],
[
239
],
[
241
],
[
243
],
[
249
],
[
251
],
[
253,
255
],
[
261
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
288
],
[
290
],
[
292
],
[
295
],
[
301
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
319
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
],
[
349
]
] |
4,860 | void ga_command_state_add(GACommandState *cs,
void (*init)(void),
void (*cleanup)(void))
{
GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));
cg->init = init;
cg->cleanup = cleanup;
cs->groups = g_slist_append(cs->groups, cg);
}
| true | qemu | f3a06403b82c7f036564e4caf18b52ce6885fcfb | void ga_command_state_add(GACommandState *cs,
void (*init)(void),
void (*cleanup)(void))
{
GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));
cg->init = init;
cg->cleanup = cleanup;
cs->groups = g_slist_append(cs->groups, cg);
}
| {
"code": [
" GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));"
],
"line_no": [
9
]
} | void FUNC_0(GACommandState *VAR_0,
void (*VAR_1)(void),
void (*VAR_2)(void))
{
GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));
cg->VAR_1 = VAR_1;
cg->VAR_2 = VAR_2;
VAR_0->groups = g_slist_append(VAR_0->groups, cg);
}
| [
"void FUNC_0(GACommandState *VAR_0,\nvoid (*VAR_1)(void),\nvoid (*VAR_2)(void))\n{",
"GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));",
"cg->VAR_1 = VAR_1;",
"cg->VAR_2 = VAR_2;",
"VAR_0->groups = g_slist_append(VAR_0->groups, cg);",
"}"
] | [
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,862 | static void new_pes_packet(PESContext *pes, AVPacket *pkt)
{
av_init_packet(pkt);
pkt->destruct = av_destruct_packet;
pkt->data = pes->buffer;
pkt->size = pes->data_index;
memset(pkt->data+pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
// Separate out the AC3 substream from an HDMV combined TrueHD/AC3 PID
if (pes->sub_st && pes->stream_type == 0x83 && pes->extended_stream_id == 0x76)
pkt->stream_index = pes->sub_st->index;
else
pkt->stream_index = pes->st->index;
pkt->pts = pes->pts;
pkt->dts = pes->dts;
/* store position of first TS packet of this PES packet */
pkt->pos = pes->ts_packet_pos;
/* reset pts values */
pes->pts = AV_NOPTS_VALUE;
pes->dts = AV_NOPTS_VALUE;
pes->buffer = NULL;
pes->data_index = 0;
} | true | FFmpeg | ce9e31655e5b8f8db3bb4f13f436fc836062a514 | static void new_pes_packet(PESContext *pes, AVPacket *pkt)
{
av_init_packet(pkt);
pkt->destruct = av_destruct_packet;
pkt->data = pes->buffer;
pkt->size = pes->data_index;
memset(pkt->data+pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if (pes->sub_st && pes->stream_type == 0x83 && pes->extended_stream_id == 0x76)
pkt->stream_index = pes->sub_st->index;
else
pkt->stream_index = pes->st->index;
pkt->pts = pes->pts;
pkt->dts = pes->dts;
pkt->pos = pes->ts_packet_pos;
pes->pts = AV_NOPTS_VALUE;
pes->dts = AV_NOPTS_VALUE;
pes->buffer = NULL;
pes->data_index = 0;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(PESContext *VAR_0, AVPacket *VAR_1)
{
av_init_packet(VAR_1);
VAR_1->destruct = av_destruct_packet;
VAR_1->data = VAR_0->buffer;
VAR_1->size = VAR_0->data_index;
memset(VAR_1->data+VAR_1->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if (VAR_0->sub_st && VAR_0->stream_type == 0x83 && VAR_0->extended_stream_id == 0x76)
VAR_1->stream_index = VAR_0->sub_st->index;
else
VAR_1->stream_index = VAR_0->st->index;
VAR_1->pts = VAR_0->pts;
VAR_1->dts = VAR_0->dts;
VAR_1->pos = VAR_0->ts_packet_pos;
VAR_0->pts = AV_NOPTS_VALUE;
VAR_0->dts = AV_NOPTS_VALUE;
VAR_0->buffer = NULL;
VAR_0->data_index = 0;
} | [
"static void FUNC_0(PESContext *VAR_0, AVPacket *VAR_1)\n{",
"av_init_packet(VAR_1);",
"VAR_1->destruct = av_destruct_packet;",
"VAR_1->data = VAR_0->buffer;",
"VAR_1->size = VAR_0->data_index;",
"memset(VAR_1->data+VAR_1->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);",
"if (VAR_0->sub_st && VAR_0->stream_type == 0x83 && VAR_0->extended_stream_id == 0x76)\nVAR_1->stream_index = VAR_0->sub_st->index;",
"else\nVAR_1->stream_index = VAR_0->st->index;",
"VAR_1->pts = VAR_0->pts;",
"VAR_1->dts = VAR_0->dts;",
"VAR_1->pos = VAR_0->ts_packet_pos;",
"VAR_0->pts = AV_NOPTS_VALUE;",
"VAR_0->dts = AV_NOPTS_VALUE;",
"VAR_0->buffer = NULL;",
"VAR_0->data_index = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
42
],
[
44
],
[
46
],
[
48
],
[
51
]
] |
4,863 | static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
{
const unsigned char *data_end = data + data_size;
GetBitContext gb;
int flags, i, j, x, y, op;
unsigned char c[3];
unsigned char *dst;
uint32_t *palette;
flags = *data++;
if (flags & 1) {
palette = (uint32_t *)seq->frame.data[1];
if (data_end - data < 256 * 3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++, data++)
c[j] = (*data << 2) | (*data >> 4);
palette[i] = 0xFF << 24 | AV_RB24(c);
}
seq->frame.palette_has_changed = 1;
}
if (flags & 2) {
if (data_end - data < 128)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, data, 128 * 8); data += 128;
for (y = 0; y < 128; y += 8)
for (x = 0; x < 256; x += 8) {
dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];
op = get_bits(&gb, 2);
switch (op) {
case 1:
data = seq_decode_op1(seq, data, data_end, dst);
break;
case 2:
data = seq_decode_op2(seq, data, data_end, dst);
break;
case 3:
data = seq_decode_op3(seq, data, data_end, dst);
break;
}
if (!data)
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| true | FFmpeg | b12d92efd6c0d48665383a9baecc13e7ebbd8a22 | static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
{
const unsigned char *data_end = data + data_size;
GetBitContext gb;
int flags, i, j, x, y, op;
unsigned char c[3];
unsigned char *dst;
uint32_t *palette;
flags = *data++;
if (flags & 1) {
palette = (uint32_t *)seq->frame.data[1];
if (data_end - data < 256 * 3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++, data++)
c[j] = (*data << 2) | (*data >> 4);
palette[i] = 0xFF << 24 | AV_RB24(c);
}
seq->frame.palette_has_changed = 1;
}
if (flags & 2) {
if (data_end - data < 128)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, data, 128 * 8); data += 128;
for (y = 0; y < 128; y += 8)
for (x = 0; x < 256; x += 8) {
dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];
op = get_bits(&gb, 2);
switch (op) {
case 1:
data = seq_decode_op1(seq, data, data_end, dst);
break;
case 2:
data = seq_decode_op2(seq, data, data_end, dst);
break;
case 3:
data = seq_decode_op3(seq, data, data_end, dst);
break;
}
if (!data)
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| {
"code": [
" palette[i] = 0xFF << 24 | AV_RB24(c);"
],
"line_no": [
37
]
} | static int FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2)
{
const unsigned char *VAR_3 = VAR_1 + VAR_2;
GetBitContext gb;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
unsigned char VAR_10[3];
unsigned char *VAR_11;
uint32_t *palette;
VAR_4 = *VAR_1++;
if (VAR_4 & 1) {
palette = (uint32_t *)VAR_0->frame.VAR_1[1];
if (VAR_3 - VAR_1 < 256 * 3)
return AVERROR_INVALIDDATA;
for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {
for (VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_1++)
VAR_10[VAR_6] = (*VAR_1 << 2) | (*VAR_1 >> 4);
palette[VAR_5] = 0xFF << 24 | AV_RB24(VAR_10);
}
VAR_0->frame.palette_has_changed = 1;
}
if (VAR_4 & 2) {
if (VAR_3 - VAR_1 < 128)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128;
for (VAR_8 = 0; VAR_8 < 128; VAR_8 += 8)
for (VAR_7 = 0; VAR_7 < 256; VAR_7 += 8) {
VAR_11 = &VAR_0->frame.VAR_1[0][VAR_8 * VAR_0->frame.linesize[0] + VAR_7];
VAR_9 = get_bits(&gb, 2);
switch (VAR_9) {
case 1:
VAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_3, VAR_11);
break;
case 2:
VAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_3, VAR_11);
break;
case 3:
VAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_3, VAR_11);
break;
}
if (!VAR_1)
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| [
"static int FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2)\n{",
"const unsigned char *VAR_3 = VAR_1 + VAR_2;",
"GetBitContext gb;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"unsigned char VAR_10[3];",
"unsigned char *VAR_11;",
"uint32_t *palette;",
"VAR_4 = *VAR_1++;",
"if (VAR_4 & 1) {",
"palette = (uint32_t *)VAR_0->frame.VAR_1[1];",
"if (VAR_3 - VAR_1 < 256 * 3)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_1++)",
"VAR_10[VAR_6] = (*VAR_1 << 2) | (*VAR_1 >> 4);",
"palette[VAR_5] = 0xFF << 24 | AV_RB24(VAR_10);",
"}",
"VAR_0->frame.palette_has_changed = 1;",
"}",
"if (VAR_4 & 2) {",
"if (VAR_3 - VAR_1 < 128)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128;",
"for (VAR_8 = 0; VAR_8 < 128; VAR_8 += 8)",
"for (VAR_7 = 0; VAR_7 < 256; VAR_7 += 8) {",
"VAR_11 = &VAR_0->frame.VAR_1[0][VAR_8 * VAR_0->frame.linesize[0] + VAR_7];",
"VAR_9 = get_bits(&gb, 2);",
"switch (VAR_9) {",
"case 1:\nVAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_3, VAR_11);",
"break;",
"case 2:\nVAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_3, VAR_11);",
"break;",
"case 3:\nVAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_3, VAR_11);",
"break;",
"}",
"if (!VAR_1)\nreturn AVERROR_INVALIDDATA;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
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
]
] |
4,864 | QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
{
QTestState *s;
int sock, qmpsock, i;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *qemu_binary;
qemu_binary = getenv("QTEST_QEMU_BINARY");
g_assert(qemu_binary != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
sock = init_socket(socket_path);
qmpsock = init_socket(qmp_socket_path);
qtest_add_abrt_handler(kill_qemu_hook_func, s);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
setenv("QEMU_AUDIO_DRV", "none", true);
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log %s "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", qemu_binary, socket_path,
getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(sock);
if (s->fd >= 0) {
s->qmp_fd = socket_accept(qmpsock);
}
g_free(socket_path);
g_free(qmp_socket_path);
g_assert(s->fd >= 0 && s->qmp_fd >= 0);
s->rx = g_string_new("");
for (i = 0; i < MAX_IRQ; i++) {
s->irq_level[i] = false;
}
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
/* ask endianness of the target */
s->big_endian = qtest_query_target_endianness(s);
return s;
} | true | qemu | d9123d09f711bf1b855de2b5a907d4c85f46d6c3 | QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
{
QTestState *s;
int sock, qmpsock, i;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *qemu_binary;
qemu_binary = getenv("QTEST_QEMU_BINARY");
g_assert(qemu_binary != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
sock = init_socket(socket_path);
qmpsock = init_socket(qmp_socket_path);
qtest_add_abrt_handler(kill_qemu_hook_func, s);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
setenv("QEMU_AUDIO_DRV", "none", true);
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log %s "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", qemu_binary, socket_path,
getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(sock);
if (s->fd >= 0) {
s->qmp_fd = socket_accept(qmpsock);
}
g_free(socket_path);
g_free(qmp_socket_path);
g_assert(s->fd >= 0 && s->qmp_fd >= 0);
s->rx = g_string_new("");
for (i = 0; i < MAX_IRQ; i++) {
s->irq_level[i] = false;
}
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
s->big_endian = qtest_query_target_endianness(s);
return s;
} | {
"code": [],
"line_no": []
} | QTestState *FUNC_0(const char *extra_args)
{
QTestState *s;
int VAR_0, VAR_1, VAR_2;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *VAR_3;
VAR_3 = getenv("QTEST_QEMU_BINARY");
g_assert(VAR_3 != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.VAR_0", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
VAR_0 = init_socket(socket_path);
VAR_1 = init_socket(qmp_socket_path);
qtest_add_abrt_handler(kill_qemu_hook_func, s);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
setenv("QEMU_AUDIO_DRV", "none", true);
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log %s "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", VAR_3, socket_path,
getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(VAR_0);
if (s->fd >= 0) {
s->qmp_fd = socket_accept(VAR_1);
}
g_free(socket_path);
g_free(qmp_socket_path);
g_assert(s->fd >= 0 && s->qmp_fd >= 0);
s->rx = g_string_new("");
for (VAR_2 = 0; VAR_2 < MAX_IRQ; VAR_2++) {
s->irq_level[VAR_2] = false;
}
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
s->big_endian = qtest_query_target_endianness(s);
return s;
} | [
"QTestState *FUNC_0(const char *extra_args)\n{",
"QTestState *s;",
"int VAR_0, VAR_1, VAR_2;",
"gchar *socket_path;",
"gchar *qmp_socket_path;",
"gchar *command;",
"const char *VAR_3;",
"VAR_3 = getenv(\"QTEST_QEMU_BINARY\");",
"g_assert(VAR_3 != NULL);",
"s = g_malloc(sizeof(*s));",
"socket_path = g_strdup_printf(\"/tmp/qtest-%d.VAR_0\", getpid());",
"qmp_socket_path = g_strdup_printf(\"/tmp/qtest-%d.qmp\", getpid());",
"VAR_0 = init_socket(socket_path);",
"VAR_1 = init_socket(qmp_socket_path);",
"qtest_add_abrt_handler(kill_qemu_hook_func, s);",
"s->qemu_pid = fork();",
"if (s->qemu_pid == 0) {",
"setenv(\"QEMU_AUDIO_DRV\", \"none\", true);",
"command = g_strdup_printf(\"exec %s \"\n\"-qtest unix:%s,nowait \"\n\"-qtest-log %s \"\n\"-qmp unix:%s,nowait \"\n\"-machine accel=qtest \"\n\"-display none \"\n\"%s\", VAR_3, socket_path,\ngetenv(\"QTEST_LOG\") ? \"/dev/fd/2\" : \"/dev/null\",\nqmp_socket_path,\nextra_args ?: \"\");",
"execlp(\"/bin/sh\", \"sh\", \"-c\", command, NULL);",
"exit(1);",
"}",
"s->fd = socket_accept(VAR_0);",
"if (s->fd >= 0) {",
"s->qmp_fd = socket_accept(VAR_1);",
"}",
"g_free(socket_path);",
"g_free(qmp_socket_path);",
"g_assert(s->fd >= 0 && s->qmp_fd >= 0);",
"s->rx = g_string_new(\"\");",
"for (VAR_2 = 0; VAR_2 < MAX_IRQ; VAR_2++) {",
"s->irq_level[VAR_2] = false;",
"}",
"if (getenv(\"QTEST_STOP\")) {",
"kill(s->qemu_pid, SIGSTOP);",
"}",
"s->big_endian = qtest_query_target_endianness(s);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
48
],
[
49
],
[
50
]
] |
4,865 | static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
{
int yalpha1=yalpha^4095;
int uvalpha1=uvalpha^4095;
int i;
#if 0 //isn't used
if(flags&SWS_FULL_CHR_H_INT)
{
switch(dstFormat)
{
#ifdef HAVE_MMX
case PIX_FMT_RGB32:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
"punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
"punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
MOVNTQ(%%mm3, (%4, %%REGa, 4))
MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" ((long)dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR24:
asm volatile(
FULL_YSCALEYUV2RGB
// lsb ... msb
"punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
"punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
"punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
"movq %%mm3, %%mm2 \n\t" // BGR0BGR0
"psrlq $8, %%mm3 \n\t" // GR0BGR00
"pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000
"pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00
"por %%mm2, %%mm3 \n\t" // BGRBGR00
"movq %%mm1, %%mm2 \n\t"
"psllq $48, %%mm1 \n\t" // 000000BG
"por %%mm1, %%mm3 \n\t" // BGRBGRBG
"movq %%mm2, %%mm1 \n\t" // BGR0BGR0
"psrld $16, %%mm2 \n\t" // R000R000
"psrlq $24, %%mm1 \n\t" // 0BGR0000
"por %%mm2, %%mm1 \n\t" // RBGRR000
"mov %4, %%"REG_b" \n\t"
"add %%"REG_a", %%"REG_b" \n\t"
#ifdef HAVE_MMX2
//FIXME Alignment
"movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
"movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
#else
"movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
"psrlq $32, %%mm3 \n\t"
"movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
"movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
#endif
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a, "%"REG_b
);
break;
case PIX_FMT_BGR555:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g5Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
"punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
"punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
"psrlw $3, %%mm3 \n\t"
"psllw $2, %%mm1 \n\t"
"psllw $7, %%mm0 \n\t"
"pand "MANGLE(g15Mask)", %%mm1 \n\t"
"pand "MANGLE(r15Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR565:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g6Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
"punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
"punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
"psrlw $3, %%mm3 \n\t"
"psllw $3, %%mm1 \n\t"
"psllw $8, %%mm0 \n\t"
"pand "MANGLE(g16Mask)", %%mm1 \n\t"
"pand "MANGLE(r16Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
#endif
case PIX_FMT_BGR32:
#ifndef HAVE_MMX
case PIX_FMT_RGB32:
#endif
if(dstFormat==PIX_FMT_RGB32)
{
int i;
#ifdef WORDS_BIGENDIAN
dest++;
#endif
for(i=0;i<dstW;i++){
// vertical linear interpolation && yuv2rgb in a single step:
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 4;
}
}
else if(dstFormat==PIX_FMT_BGR24)
{
int i;
for(i=0;i<dstW;i++){
// vertical linear interpolation && yuv2rgb in a single step:
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 3;
}
}
else if(dstFormat==PIX_FMT_BGR565)
{
int i;
for(i=0;i<dstW;i++){
// vertical linear interpolation && yuv2rgb in a single step:
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table16r[(Y + yuvtab_3343[V]) >>13];
}
}
else if(dstFormat==PIX_FMT_BGR555)
{
int i;
for(i=0;i<dstW;i++){
// vertical linear interpolation && yuv2rgb in a single step:
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table15r[(Y + yuvtab_3343[V]) >>13];
}
}
}//FULL_UV_IPOL
else
{
#endif // if 0
#ifdef HAVE_MMX
switch(c->dstFormat)
{
//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
case PIX_FMT_RGB32:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR24:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR555:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR565:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_YUYV422:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2PACKED(%%REGBP, %5)
WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
default: break;
}
#endif //HAVE_MMX
YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
{
int yalpha1=yalpha^4095;
int uvalpha1=uvalpha^4095;
int i;
#if 0
if(flags&SWS_FULL_CHR_H_INT)
{
switch(dstFormat)
{
#ifdef HAVE_MMX
case PIX_FMT_RGB32:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
MOVNTQ(%%mm3, (%4, %%REGa, 4))
MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" ((long)dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR24:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm2 \n\t"
"psrlq $8, %%mm3 \n\t"
"pand "MANGLE(bm00000111)", %%mm2\n\t"
"pand "MANGLE(bm11111000)", %%mm3\n\t"
"por %%mm2, %%mm3 \n\t"
"movq %%mm1, %%mm2 \n\t"
"psllq $48, %%mm1 \n\t"
"por %%mm1, %%mm3 \n\t"
"movq %%mm2, %%mm1 \n\t"
"psrld $16, %%mm2 \n\t"
"psrlq $24, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
"mov %4, %%"REG_b" \n\t"
"add %%"REG_a", %%"REG_b" \n\t"
#ifdef HAVE_MMX2
"movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
"movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
#else
"movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
"psrlq $32, %%mm3 \n\t"
"movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
"movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
#endif
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a, "%"REG_b
);
break;
case PIX_FMT_BGR555:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g5Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $2, %%mm1 \n\t"
"psllw $7, %%mm0 \n\t"
"pand "MANGLE(g15Mask)", %%mm1 \n\t"
"pand "MANGLE(r15Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR565:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g6Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $3, %%mm1 \n\t"
"psllw $8, %%mm0 \n\t"
"pand "MANGLE(g16Mask)", %%mm1 \n\t"
"pand "MANGLE(r16Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
#endif
case PIX_FMT_BGR32:
#ifndef HAVE_MMX
case PIX_FMT_RGB32:
#endif
if(dstFormat==PIX_FMT_RGB32)
{
int i;
#ifdef WORDS_BIGENDIAN
dest++;
#endif
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 4;
}
}
else if(dstFormat==PIX_FMT_BGR24)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 3;
}
}
else if(dstFormat==PIX_FMT_BGR565)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table16r[(Y + yuvtab_3343[V]) >>13];
}
}
else if(dstFormat==PIX_FMT_BGR555)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table15r[(Y + yuvtab_3343[V]) >>13];
}
}
}
else
{
#endif
#ifdef HAVE_MMX
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR24:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR555:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR565:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_YUYV422:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2PACKED(%%REGBP, %5)
WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
default: break;
}
#endif
YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
}
| {
"code": [
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t);",
"\t\t\t);",
"\tint i;",
"\t\t\t);",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\tswitch(c->dstFormat)",
"\tcase PIX_FMT_RGB32:",
"\tcase PIX_FMT_BGR24:",
"\t\t\t);",
"\tcase PIX_FMT_BGR555:",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\tcase PIX_FMT_BGR565:",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\tcase PIX_FMT_YUYV422:",
"#endif",
"\t\t\t uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)",
"\tint yalpha1=yalpha^4095;",
"\tint uvalpha1=uvalpha^4095;",
"\tint i;",
"\tif(flags&SWS_FULL_CHR_H_INT)",
"\t\tswitch(dstFormat)",
"\t\tcase PIX_FMT_RGB32:",
"\t\t\tasm volatile(",
"\t\t\t\"movq %%mm3, %%mm1\t\t\\n\\t\"",
"\t\t\tMOVNTQ(%%mm3, (%4, %%REGa, 4))",
"\t\t\tMOVNTQ(%%mm1, 8(%4, %%REGa, 4))",
"\t\t\t\"add $4, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" ((long)dstW),",
"\t\t\t\"m\" (yalpha1), \"m\" (uvalpha1)",
"\t\t\t: \"%\"REG_a",
"\t\t\t);",
"\t\t\tbreak;",
"\t\tcase PIX_FMT_BGR24:",
"\t\t\tasm volatile(",
"\t\t\t\"movq %%mm3, %%mm1\t\t\\n\\t\"",
"\t\t\t\"movq %%mm1, %%mm2\t\t\\n\\t\"",
"\t\t\t\"mov %4, %%\"REG_b\"\t\t\\n\\t\"",
"\t\t\t\"add %%\"REG_a\", %%\"REG_b\"\t\\n\\t\"",
"\t\t\t\"movntq %%mm3, (%%\"REG_b\", %%\"REG_a\", 2)\\n\\t\"",
"\t\t\t\"movntq %%mm1, 8(%%\"REG_b\", %%\"REG_a\", 2)\\n\\t\"",
"\t\t\t\"movd %%mm3, (%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"",
"\t\t\t\"psrlq $32, %%mm3\t\t\\n\\t\"",
"\t\t\t\"movd %%mm3, 4(%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"",
"\t\t\t\"movd %%mm1, 8(%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"",
"#endif",
"\t\t\t\"add $4, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"m\" (dest), \"m\" (dstW),",
"\t\t\t\"m\" (yalpha1), \"m\" (uvalpha1)",
"\t\t\t: \"%\"REG_a, \"%\"REG_b",
"\t\t\t);",
"\t\t\tbreak;",
"\t\tcase PIX_FMT_BGR555:",
"\t\t\tasm volatile(",
"\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm1\\n\\t\"",
"\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm0\\n\\t\"",
"\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm3\\n\\t\"",
"\t\t\t\"psrlw $3, %%mm3\t\t\\n\\t\"",
"\t\t\t\"psllw $2, %%mm1\t\t\\n\\t\"",
"\t\t\t\"psllw $7, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pand \"MANGLE(g15Mask)\", %%mm1\t\\n\\t\"",
"\t\t\t\"pand \"MANGLE(r15Mask)\", %%mm0\t\\n\\t\"",
"\t\t\t\"por %%mm3, %%mm1\t\t\\n\\t\"",
"\t\t\t\"por %%mm1, %%mm0\t\t\\n\\t\"",
"\t\t\tMOVNTQ(%%mm0, (%4, %%REGa, 2))",
"\t\t\t\"add $4, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" (dstW),",
"\t\t\t\"m\" (yalpha1), \"m\" (uvalpha1)",
"\t\t\t: \"%\"REG_a",
"\t\t\t);",
"\t\t\tbreak;",
"\t\tcase PIX_FMT_BGR565:",
"\t\t\tasm volatile(",
"\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm1\\n\\t\"",
"\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm0\\n\\t\"",
"\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm3\\n\\t\"",
"\t\t\t\"psrlw $3, %%mm3\t\t\\n\\t\"",
"\t\t\t\"psllw $3, %%mm1\t\t\\n\\t\"",
"\t\t\t\"psllw $8, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pand \"MANGLE(g16Mask)\", %%mm1\t\\n\\t\"",
"\t\t\t\"pand \"MANGLE(r16Mask)\", %%mm0\t\\n\\t\"",
"\t\t\t\"por %%mm3, %%mm1\t\t\\n\\t\"",
"\t\t\t\"por %%mm1, %%mm0\t\t\\n\\t\"",
"\t\t\tMOVNTQ(%%mm0, (%4, %%REGa, 2))",
"\t\t\t\"add $4, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" (dstW),",
"\t\t\t\"m\" (yalpha1), \"m\" (uvalpha1)",
"\t\t\t: \"%\"REG_a",
"\t\t\t);",
"\t\tbreak;",
"\t\tcase PIX_FMT_BGR32:",
"\t\tcase PIX_FMT_RGB32:",
"\t\tif(dstFormat==PIX_FMT_RGB32)",
"\t\t\tint i;",
"\t\t\tdest++;",
"#endif",
"\t\t\tfor(i=0;i<dstW;i++){",
"\t\t\t\tint Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];",
"\t\t\t\tint U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);",
"\t\t\t\tint V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);",
"\t\t\t\tdest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];",
"\t\t\t\tdest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];",
"\t\t\t\tdest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];",
"\t\t\t\tdest+= 4;",
"\t\telse if(dstFormat==PIX_FMT_BGR24)",
"\t\t\tint i;",
"\t\t\tfor(i=0;i<dstW;i++){",
"\t\t\t\tint Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];",
"\t\t\t\tint U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);",
"\t\t\t\tint V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);",
"\t\t\t\tdest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];",
"\t\t\t\tdest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];",
"\t\t\t\tdest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];",
"\t\t\t\tdest+= 3;",
"\t\telse if(dstFormat==PIX_FMT_BGR565)",
"\t\t\tint i;",
"\t\t\tfor(i=0;i<dstW;i++){",
"\t\t\t\tint Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];",
"\t\t\t\tint U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);",
"\t\t\t\tint V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);",
"\t\t\t\t((uint16_t*)dest)[i] =",
"\t\t\t\t\tclip_table16b[(Y + yuvtab_40cf[U]) >>13] |",
"\t\t\t\t\tclip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |",
"\t\t\t\t\tclip_table16r[(Y + yuvtab_3343[V]) >>13];",
"\t\telse if(dstFormat==PIX_FMT_BGR555)",
"\t\t\tint i;",
"\t\t\tfor(i=0;i<dstW;i++){",
"\t\t\t\tint Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];",
"\t\t\t\tint U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);",
"\t\t\t\tint V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);",
"\t\t\t\t((uint16_t*)dest)[i] =",
"\t\t\t\t\tclip_table15b[(Y + yuvtab_40cf[U]) >>13] |",
"\t\t\t\t\tclip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |",
"\t\t\t\t\tclip_table15r[(Y + yuvtab_3343[V]) >>13];",
"\tswitch(c->dstFormat)",
"\tcase PIX_FMT_RGB32:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tYSCALEYUV2RGB(%%REGBP, %5)",
"\t\t\t\tWRITEBGR32(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\tcase PIX_FMT_BGR24:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tYSCALEYUV2RGB(%%REGBP, %5)",
"\t\t\t\tWRITEBGR24(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\tcase PIX_FMT_BGR555:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tYSCALEYUV2RGB(%%REGBP, %5)",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR15(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\tcase PIX_FMT_BGR565:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tYSCALEYUV2RGB(%%REGBP, %5)",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR16(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\tcase PIX_FMT_YUYV422:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tYSCALEYUV2PACKED(%%REGBP, %5)",
"\t\t\t\tWRITEYUY2(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\tdefault: break;",
"\tint i;",
"\tif(flags&SWS_FULL_CHR_H_INT)",
"\t\tswitch(dstFormat)",
"\t\tcase PIX_FMT_RGB32:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEBGR32(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR24:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEBGR24(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR555:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR15(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR565:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR16(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEYUY2(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tswitch(dstFormat)",
"\t\tcase PIX_FMT_RGB32:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEBGR32(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR24:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEBGR24(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR555:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR15(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\tcase PIX_FMT_BGR565:",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR16(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"\t\t\tasm volatile(",
"\t\t\t\t\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"",
"\t\t\t\t\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"",
" \"push %%\"REG_BP\" \\n\\t\"",
"\t\t\t\tWRITEYUY2(%%REGb, 8280(%5), %%REGBP)",
" \"pop %%\"REG_BP\" \\n\\t\"",
"\t\t\t\t\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"",
"\t\t\t:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),",
"\t\t\t\"a\" (&c->redDither)",
"\t\t\t);",
"#endif",
"\tint i;",
"\tint i;",
"#endif",
"\tint i;",
"\tint i;",
"#endif",
"\tint i;",
"\tint i;",
"#endif",
"#endif",
"\tint i;",
"#endif",
"#endif",
"#endif",
"#endif",
"\tint i;",
"#endif",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"#endif",
"#endif",
"#endif",
"#endif",
"\tint i;",
"\tint i;",
"#endif",
"#endif",
"#endif",
"\tint i;",
"\tint i;",
"#endif",
"#endif",
"#endif",
"\tint i;",
"#endif"
],
"line_no": [
61,
61,
61,
61,
61,
61,
61,
73,
73,
11,
73,
525,
527,
529,
155,
525,
569,
529,
155,
449,
455,
483,
73,
509,
525,
527,
529,
155,
551,
525,
569,
529,
155,
591,
155,
3,
7,
9,
11,
17,
21,
27,
29,
43,
51,
53,
57,
59,
61,
67,
69,
71,
73,
75,
77,
29,
43,
113,
131,
133,
141,
143,
147,
149,
151,
153,
155,
57,
59,
61,
165,
69,
169,
73,
75,
175,
29,
185,
187,
189,
201,
203,
205,
207,
209,
213,
215,
219,
57,
59,
61,
231,
69,
71,
73,
75,
241,
29,
251,
187,
189,
201,
269,
271,
273,
275,
213,
215,
219,
57,
59,
61,
231,
69,
71,
73,
305,
309,
27,
317,
321,
325,
155,
329,
333,
335,
337,
339,
341,
343,
345,
351,
321,
329,
333,
335,
337,
339,
341,
343,
373,
379,
321,
329,
333,
335,
337,
397,
399,
401,
403,
409,
321,
329,
333,
335,
337,
397,
429,
431,
433,
449,
455,
29,
459,
461,
463,
465,
467,
469,
471,
475,
477,
73,
483,
29,
459,
461,
463,
465,
495,
469,
471,
475,
477,
73,
509,
29,
459,
461,
463,
465,
525,
527,
529,
155,
535,
469,
471,
475,
477,
73,
551,
29,
459,
461,
463,
465,
525,
569,
529,
155,
577,
469,
471,
475,
477,
73,
591,
29,
459,
461,
463,
601,
603,
469,
471,
475,
477,
73,
617,
11,
17,
21,
27,
29,
459,
461,
463,
467,
469,
471,
475,
477,
73,
77,
29,
459,
461,
463,
495,
469,
471,
475,
477,
73,
175,
29,
459,
461,
463,
525,
527,
529,
155,
535,
469,
471,
475,
477,
73,
241,
29,
459,
461,
463,
525,
569,
529,
155,
577,
469,
471,
475,
477,
73,
29,
459,
461,
463,
603,
469,
471,
475,
477,
73,
21,
27,
29,
459,
461,
463,
467,
469,
471,
475,
477,
73,
77,
29,
459,
461,
463,
495,
469,
471,
475,
477,
73,
175,
29,
459,
461,
463,
525,
527,
529,
155,
535,
469,
471,
475,
477,
73,
241,
29,
459,
461,
463,
525,
569,
529,
155,
577,
469,
471,
475,
477,
73,
29,
459,
461,
463,
603,
469,
471,
475,
477,
73,
155,
11,
11,
155,
11,
11,
155,
11,
11,
155,
155,
11,
155,
155,
155,
155,
11,
155,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
155,
155,
155,
155,
11,
11,
155,
155,
155,
11,
11,
155,
155,
155,
11,
155
]
} | static inline void FUNC_0(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
{
int VAR_0=yalpha^4095;
int VAR_1=uvalpha^4095;
int VAR_2;
#if 0
if(flags&SWS_FULL_CHR_H_INT)
{
switch(dstFormat)
{
#ifdef HAVE_MMX
case PIX_FMT_RGB32:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
MOVNTQ(%%mm3, (%4, %%REGa, 4))
MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" ((long)dstW),
"m" (VAR_0), "m" (VAR_1)
: "%"REG_a
);
break;
case PIX_FMT_BGR24:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm2 \n\t"
"psrlq $8, %%mm3 \n\t"
"pand "MANGLE(bm00000111)", %%mm2\n\t"
"pand "MANGLE(bm11111000)", %%mm3\n\t"
"por %%mm2, %%mm3 \n\t"
"movq %%mm1, %%mm2 \n\t"
"psllq $48, %%mm1 \n\t"
"por %%mm1, %%mm3 \n\t"
"movq %%mm2, %%mm1 \n\t"
"psrld $16, %%mm2 \n\t"
"psrlq $24, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
"mov %4, %%"REG_b" \n\t"
"add %%"REG_a", %%"REG_b" \n\t"
#ifdef HAVE_MMX2
"movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
"movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
#else
"movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
"psrlq $32, %%mm3 \n\t"
"movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
"movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
#endif
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (VAR_0), "m" (VAR_1)
: "%"REG_a, "%"REG_b
);
break;
case PIX_FMT_BGR555:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g5Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $2, %%mm1 \n\t"
"psllw $7, %%mm0 \n\t"
"pand "MANGLE(g15Mask)", %%mm1 \n\t"
"pand "MANGLE(r15Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (VAR_0), "m" (VAR_1)
: "%"REG_a
);
break;
case PIX_FMT_BGR565:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g6Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $3, %%mm1 \n\t"
"psllw $8, %%mm0 \n\t"
"pand "MANGLE(g16Mask)", %%mm1 \n\t"
"pand "MANGLE(r16Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (VAR_0), "m" (VAR_1)
: "%"REG_a
);
break;
#endif
case PIX_FMT_BGR32:
#ifndef HAVE_MMX
case PIX_FMT_RGB32:
#endif
if(dstFormat==PIX_FMT_RGB32)
{
int VAR_2;
#ifdef WORDS_BIGENDIAN
dest++;
#endif
for(VAR_2=0;VAR_2<dstW;VAR_2++){
int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];
int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);
int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 4;
}
}
else if(dstFormat==PIX_FMT_BGR24)
{
int VAR_2;
for(VAR_2=0;VAR_2<dstW;VAR_2++){
int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];
int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);
int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 3;
}
}
else if(dstFormat==PIX_FMT_BGR565)
{
int VAR_2;
for(VAR_2=0;VAR_2<dstW;VAR_2++){
int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];
int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);
int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);
((uint16_t*)dest)[VAR_2] =
clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table16r[(Y + yuvtab_3343[V]) >>13];
}
}
else if(dstFormat==PIX_FMT_BGR555)
{
int VAR_2;
for(VAR_2=0;VAR_2<dstW;VAR_2++){
int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];
int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);
int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);
((uint16_t*)dest)[VAR_2] =
clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table15r[(Y + yuvtab_3343[V]) >>13];
}
}
}
else
{
#endif
#ifdef HAVE_MMX
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR24:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR555:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR565:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_YUYV422:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2PACKED(%%REGBP, %5)
WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
default: break;
}
#endif
YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
}
| [
"static inline void FUNC_0(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,\nuint8_t *dest, int dstW, int yalpha, int uvalpha, int y)\n{",
"int VAR_0=yalpha^4095;",
"int VAR_1=uvalpha^4095;",
"int VAR_2;",
"#if 0\nif(flags&SWS_FULL_CHR_H_INT)\n{",
"switch(dstFormat)\n{",
"#ifdef HAVE_MMX\ncase PIX_FMT_RGB32:\nasm volatile(\nFULL_YSCALEYUV2RGB\n\"punpcklbw %%mm1, %%mm3\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"movq %%mm3, %%mm1\t\t\\n\\t\"\n\"punpcklwd %%mm0, %%mm3\t\t\\n\\t\"\n\"punpckhwd %%mm0, %%mm1\t\t\\n\\t\"\nMOVNTQ(%%mm3, (%4, %%REGa, 4))\nMOVNTQ(%%mm1, 8(%4, %%REGa, 4))\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" ((long)dstW),\n\"m\" (VAR_0), \"m\" (VAR_1)\n: \"%\"REG_a\n);",
"break;",
"case PIX_FMT_BGR24:\nasm volatile(\nFULL_YSCALEYUV2RGB\n\"punpcklbw %%mm1, %%mm3\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"movq %%mm3, %%mm1\t\t\\n\\t\"\n\"punpcklwd %%mm0, %%mm3\t\t\\n\\t\"\n\"punpckhwd %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm3, %%mm2\t\t\\n\\t\"\n\"psrlq $8, %%mm3\t\t\\n\\t\"\n\"pand \"MANGLE(bm00000111)\", %%mm2\\n\\t\"\n\"pand \"MANGLE(bm11111000)\", %%mm3\\n\\t\"\n\"por %%mm2, %%mm3\t\t\\n\\t\"\n\"movq %%mm1, %%mm2\t\t\\n\\t\"\n\"psllq $48, %%mm1\t\t\\n\\t\"\n\"por %%mm1, %%mm3\t\t\\n\\t\"\n\"movq %%mm2, %%mm1\t\t\\n\\t\"\n\"psrld $16, %%mm2\t\t\\n\\t\"\n\"psrlq $24, %%mm1\t\t\\n\\t\"\n\"por %%mm2, %%mm1\t\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\\n\\t\"\n\"add %%\"REG_a\", %%\"REG_b\"\t\\n\\t\"\n#ifdef HAVE_MMX2\n\"movntq %%mm3, (%%\"REG_b\", %%\"REG_a\", 2)\\n\\t\"\n\"movntq %%mm1, 8(%%\"REG_b\", %%\"REG_a\", 2)\\n\\t\"\n#else\n\"movd %%mm3, (%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"\n\"psrlq $32, %%mm3\t\t\\n\\t\"\n\"movd %%mm3, 4(%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"\n\"movd %%mm1, 8(%%\"REG_b\", %%\"REG_a\", 2)\t\\n\\t\"\n#endif\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"m\" (dest), \"m\" (dstW),\n\"m\" (VAR_0), \"m\" (VAR_1)\n: \"%\"REG_a, \"%\"REG_b\n);",
"break;",
"case PIX_FMT_BGR555:\nasm volatile(\nFULL_YSCALEYUV2RGB\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(g5Dither)\", %%mm1\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm0\\n\\t\"\n\"paddusb \"MANGLE(b5Dither)\", %%mm3\\n\\t\"\n#endif\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"psrlw $3, %%mm3\t\t\\n\\t\"\n\"psllw $2, %%mm1\t\t\\n\\t\"\n\"psllw $7, %%mm0\t\t\\n\\t\"\n\"pand \"MANGLE(g15Mask)\", %%mm1\t\\n\\t\"\n\"pand \"MANGLE(r15Mask)\", %%mm0\t\\n\\t\"\n\"por %%mm3, %%mm1\t\t\\n\\t\"\n\"por %%mm1, %%mm0\t\t\\n\\t\"\nMOVNTQ(%%mm0, (%4, %%REGa, 2))\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" (dstW),\n\"m\" (VAR_0), \"m\" (VAR_1)\n: \"%\"REG_a\n);",
"break;",
"case PIX_FMT_BGR565:\nasm volatile(\nFULL_YSCALEYUV2RGB\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(g6Dither)\", %%mm1\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm0\\n\\t\"\n\"paddusb \"MANGLE(b5Dither)\", %%mm3\\n\\t\"\n#endif\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"psrlw $3, %%mm3\t\t\\n\\t\"\n\"psllw $3, %%mm1\t\t\\n\\t\"\n\"psllw $8, %%mm0\t\t\\n\\t\"\n\"pand \"MANGLE(g16Mask)\", %%mm1\t\\n\\t\"\n\"pand \"MANGLE(r16Mask)\", %%mm0\t\\n\\t\"\n\"por %%mm3, %%mm1\t\t\\n\\t\"\n\"por %%mm1, %%mm0\t\t\\n\\t\"\nMOVNTQ(%%mm0, (%4, %%REGa, 2))\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %5, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (buf0), \"r\" (buf1), \"r\" (uvbuf0), \"r\" (uvbuf1), \"r\" (dest), \"m\" (dstW),\n\"m\" (VAR_0), \"m\" (VAR_1)\n: \"%\"REG_a\n);",
"break;",
"#endif\ncase PIX_FMT_BGR32:\n#ifndef HAVE_MMX\ncase PIX_FMT_RGB32:\n#endif\nif(dstFormat==PIX_FMT_RGB32)\n{",
"int VAR_2;",
"#ifdef WORDS_BIGENDIAN\ndest++;",
"#endif\nfor(VAR_2=0;VAR_2<dstW;VAR_2++){",
"int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];",
"int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);",
"int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);",
"dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];",
"dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];",
"dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];",
"dest+= 4;",
"}",
"}",
"else if(dstFormat==PIX_FMT_BGR24)\n{",
"int VAR_2;",
"for(VAR_2=0;VAR_2<dstW;VAR_2++){",
"int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];",
"int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);",
"int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);",
"dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];",
"dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];",
"dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];",
"dest+= 3;",
"}",
"}",
"else if(dstFormat==PIX_FMT_BGR565)\n{",
"int VAR_2;",
"for(VAR_2=0;VAR_2<dstW;VAR_2++){",
"int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];",
"int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);",
"int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);",
"((uint16_t*)dest)[VAR_2] =\nclip_table16b[(Y + yuvtab_40cf[U]) >>13] |\nclip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |\nclip_table16r[(Y + yuvtab_3343[V]) >>13];",
"}",
"}",
"else if(dstFormat==PIX_FMT_BGR555)\n{",
"int VAR_2;",
"for(VAR_2=0;VAR_2<dstW;VAR_2++){",
"int Y=yuvtab_2568[((buf0[VAR_2]*VAR_0+buf1[VAR_2]*yalpha)>>19)];",
"int U=((uvbuf0[VAR_2]*VAR_1+uvbuf1[VAR_2]*uvalpha)>>19);",
"int V=((uvbuf0[VAR_2+2048]*VAR_1+uvbuf1[VAR_2+2048]*uvalpha)>>19);",
"((uint16_t*)dest)[VAR_2] =\nclip_table15b[(Y + yuvtab_40cf[U]) >>13] |\nclip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |\nclip_table15r[(Y + yuvtab_3343[V]) >>13];",
"}",
"}",
"}",
"else\n{",
"#endif\n#ifdef HAVE_MMX\nswitch(c->dstFormat)\n{",
"case PIX_FMT_RGB32:\nasm volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5)\nWRITEBGR32(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"return;",
"case PIX_FMT_BGR24:\nasm volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5)\nWRITEBGR24(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"return;",
"case PIX_FMT_BGR555:\nasm volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5)\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR15(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"return;",
"case PIX_FMT_BGR565:\nasm volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5)\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR16(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"return;",
"case PIX_FMT_YUYV422:\nasm volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)\t\\n\\t\"\n\"mov %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2PACKED(%%REGBP, %5)\nWRITEYUY2(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"\t\\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (uvbuf0), \"D\" (uvbuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"return;",
"default: break;",
"}",
"#endif\nYSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
21,
23
],
[
25,
27,
29,
35,
37,
39,
43,
45,
47,
51,
53,
57,
59,
61,
67,
69,
71,
73
],
[
75
],
[
77,
79,
83,
89,
91,
95,
97,
99,
103,
105,
107,
109,
111,
113,
115,
117,
121,
123,
125,
127,
131,
133,
137,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
165,
167,
169,
171
],
[
173
],
[
175,
177,
181,
183,
185,
187,
189,
191,
193,
195,
197,
201,
203,
205,
207,
209,
213,
215,
219,
223,
225,
227,
231,
233,
235,
237
],
[
239
],
[
241,
243,
247,
249,
251,
253,
255,
257,
259,
261,
263,
267,
269,
271,
273,
275,
279,
281,
285,
289,
291,
293,
297,
299,
301,
303
],
[
305
],
[
307,
309,
311,
313,
315,
317,
319
],
[
321
],
[
323,
325
],
[
327,
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351,
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
397,
399,
401,
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415
],
[
419
],
[
421
],
[
423
],
[
427,
429,
431,
433
],
[
435
],
[
437
],
[
439
],
[
441,
443
],
[
445,
447,
449,
451
],
[
455,
457,
459,
461,
463,
465,
467,
469,
471,
475,
477,
479
],
[
481
],
[
483,
485,
487,
489,
491,
493,
495,
497,
499,
501,
503,
505
],
[
507
],
[
509,
511,
513,
515,
517,
519,
523,
525,
527,
529,
531,
535,
537,
539,
543,
545,
547
],
[
549
],
[
551,
553,
555,
557,
559,
561,
565,
567,
569,
571,
573,
577,
579,
581,
583,
585,
587
],
[
589
],
[
591,
593,
595,
597,
599,
601,
603,
605,
607,
609,
611,
613
],
[
615
],
[
617
],
[
619
],
[
621,
623,
625
]
] |
4,866 | static int http_parse_request(HTTPContext *c)
{
const char *p;
char *p1;
enum RedirType redir_type;
char cmd[32];
char info[1024], filename[1024];
char url[1024], *q;
char protocol[32];
char msg[1024];
const char *mime_type;
FFServerStream *stream;
int i;
char ratebuf[32];
const char *useragent = 0;
p = c->buffer;
get_word(cmd, sizeof(cmd), &p);
av_strlcpy(c->method, cmd, sizeof(c->method));
if (!strcmp(cmd, "GET"))
c->post = 0;
else if (!strcmp(cmd, "POST"))
c->post = 1;
else
return -1;
get_word(url, sizeof(url), &p);
av_strlcpy(c->url, url, sizeof(c->url));
get_word(protocol, sizeof(protocol), (const char **)&p);
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1"))
return -1;
av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
if (config.debug)
http_log("%s - - New connection: %s %s\n", inet_ntoa(c->from_addr.sin_addr), cmd, url);
/* find the filename and the optional info string in the request */
p1 = strchr(url, '?');
if (p1) {
av_strlcpy(info, p1, sizeof(info));
*p1 = '\0';
} else
info[0] = '\0';
av_strlcpy(filename, url + ((*url == '/') ? 1 : 0), sizeof(filename)-1);
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "User-Agent:", 11) == 0) {
useragent = p + 11;
if (*useragent && *useragent != '\n' && av_isspace(*useragent))
useragent++;
break;
}
p = strchr(p, '\n');
if (!p)
break;
p++;
}
redir_type = REDIR_NONE;
if (av_match_ext(filename, "asx")) {
redir_type = REDIR_ASX;
filename[strlen(filename)-1] = 'f';
} else if (av_match_ext(filename, "asf") &&
(!useragent || av_strncasecmp(useragent, "NSPlayer", 8) != 0)) {
/* if this isn't WMP or lookalike, return the redirector file */
redir_type = REDIR_ASF;
} else if (av_match_ext(filename, "rpm,ram")) {
redir_type = REDIR_RAM;
strcpy(filename + strlen(filename)-2, "m");
} else if (av_match_ext(filename, "rtsp")) {
redir_type = REDIR_RTSP;
compute_real_filename(filename, sizeof(filename) - 1);
} else if (av_match_ext(filename, "sdp")) {
redir_type = REDIR_SDP;
compute_real_filename(filename, sizeof(filename) - 1);
}
// "redirect" / request to index.html
if (!strlen(filename))
av_strlcpy(filename, "index.html", sizeof(filename) - 1);
stream = config.first_stream;
while (stream) {
if (!strcmp(stream->filename, filename) && validate_acl(stream, c))
break;
stream = stream->next;
}
if (!stream) {
snprintf(msg, sizeof(msg), "File '%s' not found", url);
http_log("File '%s' not found\n", url);
goto send_error;
}
c->stream = stream;
memcpy(c->feed_streams, stream->feed_streams, sizeof(c->feed_streams));
memset(c->switch_feed_streams, -1, sizeof(c->switch_feed_streams));
if (stream->stream_type == STREAM_TYPE_REDIRECT) {
c->http_error = 301;
q = c->buffer;
snprintf(q, c->buffer_size,
"HTTP/1.0 301 Moved\r\n"
"Location: %s\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Moved</title></head><body>\r\n"
"You should be <a href=\"%s\">redirected</a>.\r\n"
"</body></html>\r\n", stream->feed_filename, stream->feed_filename);
q += strlen(q);
/* prepare output buffer */
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
/* If this is WMP, get the rate information */
if (extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) {
if (modify_current_stream(c, ratebuf)) {
for (i = 0; i < FF_ARRAY_ELEMS(c->feed_streams); i++) {
if (c->switch_feed_streams[i] >= 0)
c->switch_feed_streams[i] = -1;
}
}
}
if (c->post == 0 && stream->stream_type == STREAM_TYPE_LIVE)
current_bandwidth += stream->bandwidth;
/* If already streaming this feed, do not let start another feeder. */
if (stream->feed_opened) {
snprintf(msg, sizeof(msg), "This feed is already being received.");
http_log("Feed '%s' already being received\n", stream->feed_filename);
goto send_error;
}
if (c->post == 0 && config.max_bandwidth < current_bandwidth) {
c->http_error = 503;
q = c->buffer;
snprintf(q, c->buffer_size,
"HTTP/1.0 503 Server too busy\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Too busy</title></head><body>\r\n"
"<p>The server is too busy to serve your request at this time.</p>\r\n"
"<p>The bandwidth being served (including your stream) is %"PRIu64"kbit/sec, "
"and this exceeds the limit of %"PRIu64"kbit/sec.</p>\r\n"
"</body></html>\r\n", current_bandwidth, config.max_bandwidth);
q += strlen(q);
/* prepare output buffer */
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
if (redir_type != REDIR_NONE) {
const char *hostinfo = 0;
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "Host:", 5) == 0) {
hostinfo = p + 5;
break;
}
p = strchr(p, '\n');
if (!p)
break;
p++;
}
if (hostinfo) {
char *eoh;
char hostbuf[260];
while (av_isspace(*hostinfo))
hostinfo++;
eoh = strchr(hostinfo, '\n');
if (eoh) {
if (eoh[-1] == '\r')
eoh--;
if (eoh - hostinfo < sizeof(hostbuf) - 1) {
memcpy(hostbuf, hostinfo, eoh - hostinfo);
hostbuf[eoh - hostinfo] = 0;
c->http_error = 200;
q = c->buffer;
switch(redir_type) {
case REDIR_ASX:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 ASX Follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"<ASX Version=\"3\">\r\n"
//"<!-- Autogenerated by ffserver -->\r\n"
"<ENTRY><REF HREF=\"http://%s/%s%s\"/></ENTRY>\r\n"
"</ASX>\r\n", hostbuf, filename, info);
q += strlen(q);
break;
case REDIR_RAM:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 RAM Follows\r\n"
"Content-type: audio/x-pn-realaudio\r\n"
"\r\n"
"# Autogenerated by ffserver\r\n"
"http://%s/%s%s\r\n", hostbuf, filename, info);
q += strlen(q);
break;
case REDIR_ASF:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 ASF Redirect follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"[Reference]\r\n"
"Ref1=http://%s/%s%s\r\n", hostbuf, filename, info);
q += strlen(q);
break;
case REDIR_RTSP:
{
char hostname[256], *p;
/* extract only hostname */
av_strlcpy(hostname, hostbuf, sizeof(hostname));
p = strrchr(hostname, ':');
if (p)
*p = '\0';
snprintf(q, c->buffer_size,
"HTTP/1.0 200 RTSP Redirect follows\r\n"
/* XXX: incorrect MIME type ? */
"Content-type: application/x-rtsp\r\n"
"\r\n"
"rtsp://%s:%d/%s\r\n", hostname, ntohs(config.rtsp_addr.sin_port), filename);
q += strlen(q);
}
break;
case REDIR_SDP:
{
uint8_t *sdp_data;
int sdp_data_size;
socklen_t len;
struct sockaddr_in my_addr;
snprintf(q, c->buffer_size,
"HTTP/1.0 200 OK\r\n"
"Content-type: application/sdp\r\n"
"\r\n");
q += strlen(q);
len = sizeof(my_addr);
/* XXX: Should probably fail? */
if (getsockname(c->fd, (struct sockaddr *)&my_addr, &len))
http_log("getsockname() failed\n");
/* XXX: should use a dynamic buffer */
sdp_data_size = prepare_sdp_description(stream,
&sdp_data,
my_addr.sin_addr);
if (sdp_data_size > 0) {
memcpy(q, sdp_data, sdp_data_size);
q += sdp_data_size;
*q = '\0';
av_free(sdp_data);
}
}
break;
default:
abort();
break;
}
/* prepare output buffer */
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
}
}
snprintf(msg, sizeof(msg), "ASX/RAM file not handled");
goto send_error;
}
stream->conns_served++;
/* XXX: add there authenticate and IP match */
if (c->post) {
/* if post, it means a feed is being sent */
if (!stream->is_feed) {
/* However it might be a status report from WMP! Let us log the
* data as it might come handy one day. */
const char *logline = 0;
int client_id = 0;
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "Pragma: log-line=", 17) == 0) {
logline = p;
break;
}
if (av_strncasecmp(p, "Pragma: client-id=", 18) == 0)
client_id = strtol(p + 18, 0, 10);
p = strchr(p, '\n');
if (!p)
break;
p++;
}
if (logline) {
char *eol = strchr(logline, '\n');
logline += 17;
if (eol) {
if (eol[-1] == '\r')
eol--;
http_log("%.*s\n", (int) (eol - logline), logline);
c->suppress_log = 1;
}
}
#ifdef DEBUG
http_log("\nGot request:\n%s\n", c->buffer);
#endif
if (client_id && extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) {
HTTPContext *wmpc;
/* Now we have to find the client_id */
for (wmpc = first_http_ctx; wmpc; wmpc = wmpc->next) {
if (wmpc->wmp_client_id == client_id)
break;
}
if (wmpc && modify_current_stream(wmpc, ratebuf))
wmpc->switch_pending = 1;
}
snprintf(msg, sizeof(msg), "POST command not handled");
c->stream = 0;
goto send_error;
}
if (http_start_receive_data(c) < 0) {
snprintf(msg, sizeof(msg), "could not open feed");
goto send_error;
}
c->http_error = 0;
c->state = HTTPSTATE_RECEIVE_DATA;
return 0;
}
#ifdef DEBUG
if (strcmp(stream->filename + strlen(stream->filename) - 4, ".asf") == 0)
http_log("\nGot request:\n%s\n", c->buffer);
#endif
if (c->stream->stream_type == STREAM_TYPE_STATUS)
goto send_status;
/* open input stream */
if (open_input_stream(c, info) < 0) {
snprintf(msg, sizeof(msg), "Input stream corresponding to '%s' not found", url);
goto send_error;
}
/* prepare HTTP header */
c->buffer[0] = 0;
av_strlcatf(c->buffer, c->buffer_size, "HTTP/1.0 200 OK\r\n");
mime_type = c->stream->fmt->mime_type;
if (!mime_type)
mime_type = "application/x-octet-stream";
av_strlcatf(c->buffer, c->buffer_size, "Pragma: no-cache\r\n");
/* for asf, we need extra headers */
if (!strcmp(c->stream->fmt->name,"asf_stream")) {
/* Need to allocate a client id */
c->wmp_client_id = av_lfg_get(&random_state);
av_strlcatf(c->buffer, c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id);
}
av_strlcatf(c->buffer, c->buffer_size, "Content-Type: %s\r\n", mime_type);
av_strlcatf(c->buffer, c->buffer_size, "\r\n");
q = c->buffer + strlen(c->buffer);
/* prepare output buffer */
c->http_error = 0;
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
send_error:
c->http_error = 404;
q = c->buffer;
htmlstrip(msg);
snprintf(q, c->buffer_size,
"HTTP/1.0 404 Not Found\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html>\n"
"<head><title>404 Not Found</title></head>\n"
"<body>%s</body>\n"
"</html>\n", msg);
q += strlen(q);
/* prepare output buffer */
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
send_status:
compute_status(c);
c->http_error = 200; /* horrible : we use this value to avoid
going to the send data state */
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
| false | FFmpeg | 33d6f90e3e0241939ea0be9ca9e1f335942081c8 | static int http_parse_request(HTTPContext *c)
{
const char *p;
char *p1;
enum RedirType redir_type;
char cmd[32];
char info[1024], filename[1024];
char url[1024], *q;
char protocol[32];
char msg[1024];
const char *mime_type;
FFServerStream *stream;
int i;
char ratebuf[32];
const char *useragent = 0;
p = c->buffer;
get_word(cmd, sizeof(cmd), &p);
av_strlcpy(c->method, cmd, sizeof(c->method));
if (!strcmp(cmd, "GET"))
c->post = 0;
else if (!strcmp(cmd, "POST"))
c->post = 1;
else
return -1;
get_word(url, sizeof(url), &p);
av_strlcpy(c->url, url, sizeof(c->url));
get_word(protocol, sizeof(protocol), (const char **)&p);
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1"))
return -1;
av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
if (config.debug)
http_log("%s - - New connection: %s %s\n", inet_ntoa(c->from_addr.sin_addr), cmd, url);
p1 = strchr(url, '?');
if (p1) {
av_strlcpy(info, p1, sizeof(info));
*p1 = '\0';
} else
info[0] = '\0';
av_strlcpy(filename, url + ((*url == '/') ? 1 : 0), sizeof(filename)-1);
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "User-Agent:", 11) == 0) {
useragent = p + 11;
if (*useragent && *useragent != '\n' && av_isspace(*useragent))
useragent++;
break;
}
p = strchr(p, '\n');
if (!p)
break;
p++;
}
redir_type = REDIR_NONE;
if (av_match_ext(filename, "asx")) {
redir_type = REDIR_ASX;
filename[strlen(filename)-1] = 'f';
} else if (av_match_ext(filename, "asf") &&
(!useragent || av_strncasecmp(useragent, "NSPlayer", 8) != 0)) {
redir_type = REDIR_ASF;
} else if (av_match_ext(filename, "rpm,ram")) {
redir_type = REDIR_RAM;
strcpy(filename + strlen(filename)-2, "m");
} else if (av_match_ext(filename, "rtsp")) {
redir_type = REDIR_RTSP;
compute_real_filename(filename, sizeof(filename) - 1);
} else if (av_match_ext(filename, "sdp")) {
redir_type = REDIR_SDP;
compute_real_filename(filename, sizeof(filename) - 1);
}
if (!strlen(filename))
av_strlcpy(filename, "index.html", sizeof(filename) - 1);
stream = config.first_stream;
while (stream) {
if (!strcmp(stream->filename, filename) && validate_acl(stream, c))
break;
stream = stream->next;
}
if (!stream) {
snprintf(msg, sizeof(msg), "File '%s' not found", url);
http_log("File '%s' not found\n", url);
goto send_error;
}
c->stream = stream;
memcpy(c->feed_streams, stream->feed_streams, sizeof(c->feed_streams));
memset(c->switch_feed_streams, -1, sizeof(c->switch_feed_streams));
if (stream->stream_type == STREAM_TYPE_REDIRECT) {
c->http_error = 301;
q = c->buffer;
snprintf(q, c->buffer_size,
"HTTP/1.0 301 Moved\r\n"
"Location: %s\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Moved</title></head><body>\r\n"
"You should be <a href=\"%s\">redirected</a>.\r\n"
"</body></html>\r\n", stream->feed_filename, stream->feed_filename);
q += strlen(q);
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
if (extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) {
if (modify_current_stream(c, ratebuf)) {
for (i = 0; i < FF_ARRAY_ELEMS(c->feed_streams); i++) {
if (c->switch_feed_streams[i] >= 0)
c->switch_feed_streams[i] = -1;
}
}
}
if (c->post == 0 && stream->stream_type == STREAM_TYPE_LIVE)
current_bandwidth += stream->bandwidth;
if (stream->feed_opened) {
snprintf(msg, sizeof(msg), "This feed is already being received.");
http_log("Feed '%s' already being received\n", stream->feed_filename);
goto send_error;
}
if (c->post == 0 && config.max_bandwidth < current_bandwidth) {
c->http_error = 503;
q = c->buffer;
snprintf(q, c->buffer_size,
"HTTP/1.0 503 Server too busy\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Too busy</title></head><body>\r\n"
"<p>The server is too busy to serve your request at this time.</p>\r\n"
"<p>The bandwidth being served (including your stream) is %"PRIu64"kbit/sec, "
"and this exceeds the limit of %"PRIu64"kbit/sec.</p>\r\n"
"</body></html>\r\n", current_bandwidth, config.max_bandwidth);
q += strlen(q);
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
if (redir_type != REDIR_NONE) {
const char *hostinfo = 0;
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "Host:", 5) == 0) {
hostinfo = p + 5;
break;
}
p = strchr(p, '\n');
if (!p)
break;
p++;
}
if (hostinfo) {
char *eoh;
char hostbuf[260];
while (av_isspace(*hostinfo))
hostinfo++;
eoh = strchr(hostinfo, '\n');
if (eoh) {
if (eoh[-1] == '\r')
eoh--;
if (eoh - hostinfo < sizeof(hostbuf) - 1) {
memcpy(hostbuf, hostinfo, eoh - hostinfo);
hostbuf[eoh - hostinfo] = 0;
c->http_error = 200;
q = c->buffer;
switch(redir_type) {
case REDIR_ASX:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 ASX Follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"<ASX Version=\"3\">\r\n"
"<ENTRY><REF HREF=\"http:
"</ASX>\r\n", hostbuf, filename, info);
q += strlen(q);
break;
case REDIR_RAM:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 RAM Follows\r\n"
"Content-type: audio/x-pn-realaudio\r\n"
"\r\n"
"# Autogenerated by ffserver\r\n"
"http:
q += strlen(q);
break;
case REDIR_ASF:
snprintf(q, c->buffer_size,
"HTTP/1.0 200 ASF Redirect follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"[Reference]\r\n"
"Ref1=http:
q += strlen(q);
break;
case REDIR_RTSP:
{
char hostname[256], *p;
av_strlcpy(hostname, hostbuf, sizeof(hostname));
p = strrchr(hostname, ':');
if (p)
*p = '\0';
snprintf(q, c->buffer_size,
"HTTP/1.0 200 RTSP Redirect follows\r\n"
"Content-type: application/x-rtsp\r\n"
"\r\n"
"rtsp:
q += strlen(q);
}
break;
case REDIR_SDP:
{
uint8_t *sdp_data;
int sdp_data_size;
socklen_t len;
struct sockaddr_in my_addr;
snprintf(q, c->buffer_size,
"HTTP/1.0 200 OK\r\n"
"Content-type: application/sdp\r\n"
"\r\n");
q += strlen(q);
len = sizeof(my_addr);
if (getsockname(c->fd, (struct sockaddr *)&my_addr, &len))
http_log("getsockname() failed\n");
sdp_data_size = prepare_sdp_description(stream,
&sdp_data,
my_addr.sin_addr);
if (sdp_data_size > 0) {
memcpy(q, sdp_data, sdp_data_size);
q += sdp_data_size;
*q = '\0';
av_free(sdp_data);
}
}
break;
default:
abort();
break;
}
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
}
}
snprintf(msg, sizeof(msg), "ASX/RAM file not handled");
goto send_error;
}
stream->conns_served++;
if (c->post) {
if (!stream->is_feed) {
const char *logline = 0;
int client_id = 0;
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (av_strncasecmp(p, "Pragma: log-line=", 17) == 0) {
logline = p;
break;
}
if (av_strncasecmp(p, "Pragma: client-id=", 18) == 0)
client_id = strtol(p + 18, 0, 10);
p = strchr(p, '\n');
if (!p)
break;
p++;
}
if (logline) {
char *eol = strchr(logline, '\n');
logline += 17;
if (eol) {
if (eol[-1] == '\r')
eol--;
http_log("%.*s\n", (int) (eol - logline), logline);
c->suppress_log = 1;
}
}
#ifdef DEBUG
http_log("\nGot request:\n%s\n", c->buffer);
#endif
if (client_id && extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) {
HTTPContext *wmpc;
for (wmpc = first_http_ctx; wmpc; wmpc = wmpc->next) {
if (wmpc->wmp_client_id == client_id)
break;
}
if (wmpc && modify_current_stream(wmpc, ratebuf))
wmpc->switch_pending = 1;
}
snprintf(msg, sizeof(msg), "POST command not handled");
c->stream = 0;
goto send_error;
}
if (http_start_receive_data(c) < 0) {
snprintf(msg, sizeof(msg), "could not open feed");
goto send_error;
}
c->http_error = 0;
c->state = HTTPSTATE_RECEIVE_DATA;
return 0;
}
#ifdef DEBUG
if (strcmp(stream->filename + strlen(stream->filename) - 4, ".asf") == 0)
http_log("\nGot request:\n%s\n", c->buffer);
#endif
if (c->stream->stream_type == STREAM_TYPE_STATUS)
goto send_status;
if (open_input_stream(c, info) < 0) {
snprintf(msg, sizeof(msg), "Input stream corresponding to '%s' not found", url);
goto send_error;
}
c->buffer[0] = 0;
av_strlcatf(c->buffer, c->buffer_size, "HTTP/1.0 200 OK\r\n");
mime_type = c->stream->fmt->mime_type;
if (!mime_type)
mime_type = "application/x-octet-stream";
av_strlcatf(c->buffer, c->buffer_size, "Pragma: no-cache\r\n");
if (!strcmp(c->stream->fmt->name,"asf_stream")) {
c->wmp_client_id = av_lfg_get(&random_state);
av_strlcatf(c->buffer, c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id);
}
av_strlcatf(c->buffer, c->buffer_size, "Content-Type: %s\r\n", mime_type);
av_strlcatf(c->buffer, c->buffer_size, "\r\n");
q = c->buffer + strlen(c->buffer);
c->http_error = 0;
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
send_error:
c->http_error = 404;
q = c->buffer;
htmlstrip(msg);
snprintf(q, c->buffer_size,
"HTTP/1.0 404 Not Found\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html>\n"
"<head><title>404 Not Found</title></head>\n"
"<body>%s</body>\n"
"</html>\n", msg);
q += strlen(q);
c->buffer_ptr = c->buffer;
c->buffer_end = q;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
send_status:
compute_status(c);
c->http_error = 200;
c->state = HTTPSTATE_SEND_HEADER;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HTTPContext *VAR_0)
{
const char *VAR_19;
char *VAR_2;
enum RedirType VAR_3;
char VAR_4[32];
char VAR_5[1024], VAR_6[1024];
char VAR_7[1024], *VAR_8;
char VAR_9[32];
char VAR_10[1024];
const char *VAR_11;
FFServerStream *stream;
int VAR_12;
char VAR_13[32];
const char *VAR_14 = 0;
VAR_19 = VAR_0->buffer;
get_word(VAR_4, sizeof(VAR_4), &VAR_19);
av_strlcpy(VAR_0->method, VAR_4, sizeof(VAR_0->method));
if (!strcmp(VAR_4, "GET"))
VAR_0->post = 0;
else if (!strcmp(VAR_4, "POST"))
VAR_0->post = 1;
else
return -1;
get_word(VAR_7, sizeof(VAR_7), &VAR_19);
av_strlcpy(VAR_0->VAR_7, VAR_7, sizeof(VAR_0->VAR_7));
get_word(VAR_9, sizeof(VAR_9), (const char **)&VAR_19);
if (strcmp(VAR_9, "HTTP/1.0") && strcmp(VAR_9, "HTTP/1.1"))
return -1;
av_strlcpy(VAR_0->VAR_9, VAR_9, sizeof(VAR_0->VAR_9));
if (config.debug)
http_log("%s - - New connection: %s %s\n", inet_ntoa(VAR_0->from_addr.sin_addr), VAR_4, VAR_7);
VAR_2 = strchr(VAR_7, '?');
if (VAR_2) {
av_strlcpy(VAR_5, VAR_2, sizeof(VAR_5));
*VAR_2 = '\0';
} else
VAR_5[0] = '\0';
av_strlcpy(VAR_6, VAR_7 + ((*VAR_7 == '/') ? 1 : 0), sizeof(VAR_6)-1);
for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\r' && *VAR_19 != '\n'; ) {
if (av_strncasecmp(VAR_19, "User-Agent:", 11) == 0) {
VAR_14 = VAR_19 + 11;
if (*VAR_14 && *VAR_14 != '\n' && av_isspace(*VAR_14))
VAR_14++;
break;
}
VAR_19 = strchr(VAR_19, '\n');
if (!VAR_19)
break;
VAR_19++;
}
VAR_3 = REDIR_NONE;
if (av_match_ext(VAR_6, "asx")) {
VAR_3 = REDIR_ASX;
VAR_6[strlen(VAR_6)-1] = 'f';
} else if (av_match_ext(VAR_6, "asf") &&
(!VAR_14 || av_strncasecmp(VAR_14, "NSPlayer", 8) != 0)) {
VAR_3 = REDIR_ASF;
} else if (av_match_ext(VAR_6, "rpm,ram")) {
VAR_3 = REDIR_RAM;
strcpy(VAR_6 + strlen(VAR_6)-2, "m");
} else if (av_match_ext(VAR_6, "rtsp")) {
VAR_3 = REDIR_RTSP;
compute_real_filename(VAR_6, sizeof(VAR_6) - 1);
} else if (av_match_ext(VAR_6, "sdp")) {
VAR_3 = REDIR_SDP;
compute_real_filename(VAR_6, sizeof(VAR_6) - 1);
}
if (!strlen(VAR_6))
av_strlcpy(VAR_6, "index.html", sizeof(VAR_6) - 1);
stream = config.first_stream;
while (stream) {
if (!strcmp(stream->VAR_6, VAR_6) && validate_acl(stream, VAR_0))
break;
stream = stream->next;
}
if (!stream) {
snprintf(VAR_10, sizeof(VAR_10), "File '%s' not found", VAR_7);
http_log("File '%s' not found\n", VAR_7);
goto send_error;
}
VAR_0->stream = stream;
memcpy(VAR_0->feed_streams, stream->feed_streams, sizeof(VAR_0->feed_streams));
memset(VAR_0->switch_feed_streams, -1, sizeof(VAR_0->switch_feed_streams));
if (stream->stream_type == STREAM_TYPE_REDIRECT) {
VAR_0->http_error = 301;
VAR_8 = VAR_0->buffer;
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 301 Moved\r\n"
"Location: %s\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Moved</title></head><body>\r\n"
"You should be <a href=\"%s\">redirected</a>.\r\n"
"</body></html>\r\n", stream->feed_filename, stream->feed_filename);
VAR_8 += strlen(VAR_8);
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_8;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
}
if (extract_rates(VAR_13, sizeof(VAR_13), VAR_0->buffer)) {
if (modify_current_stream(VAR_0, VAR_13)) {
for (VAR_12 = 0; VAR_12 < FF_ARRAY_ELEMS(VAR_0->feed_streams); VAR_12++) {
if (VAR_0->switch_feed_streams[VAR_12] >= 0)
VAR_0->switch_feed_streams[VAR_12] = -1;
}
}
}
if (VAR_0->post == 0 && stream->stream_type == STREAM_TYPE_LIVE)
current_bandwidth += stream->bandwidth;
if (stream->feed_opened) {
snprintf(VAR_10, sizeof(VAR_10), "This feed is already being received.");
http_log("Feed '%s' already being received\n", stream->feed_filename);
goto send_error;
}
if (VAR_0->post == 0 && config.max_bandwidth < current_bandwidth) {
VAR_0->http_error = 503;
VAR_8 = VAR_0->buffer;
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 503 Server too busy\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html><head><title>Too busy</title></head><body>\r\n"
"<VAR_19>The server is too busy to serve your request at this time.</VAR_19>\r\n"
"<VAR_19>The bandwidth being served (including your stream) is %"PRIu64"kbit/sec, "
"and this exceeds the limit of %"PRIu64"kbit/sec.</VAR_19>\r\n"
"</body></html>\r\n", current_bandwidth, config.max_bandwidth);
VAR_8 += strlen(VAR_8);
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_8;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
}
if (VAR_3 != REDIR_NONE) {
const char *VAR_15 = 0;
for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\r' && *VAR_19 != '\n'; ) {
if (av_strncasecmp(VAR_19, "Host:", 5) == 0) {
VAR_15 = VAR_19 + 5;
break;
}
VAR_19 = strchr(VAR_19, '\n');
if (!VAR_19)
break;
VAR_19++;
}
if (VAR_15) {
char *VAR_16;
char VAR_17[260];
while (av_isspace(*VAR_15))
VAR_15++;
VAR_16 = strchr(VAR_15, '\n');
if (VAR_16) {
if (VAR_16[-1] == '\r')
VAR_16--;
if (VAR_16 - VAR_15 < sizeof(VAR_17) - 1) {
memcpy(VAR_17, VAR_15, VAR_16 - VAR_15);
VAR_17[VAR_16 - VAR_15] = 0;
VAR_0->http_error = 200;
VAR_8 = VAR_0->buffer;
switch(VAR_3) {
case REDIR_ASX:
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 200 ASX Follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"<ASX Version=\"3\">\r\n"
"<ENTRY><REF HREF=\"http:
"</ASX>\r\n", VAR_17, VAR_6, VAR_5);
VAR_8 += strlen(VAR_8);
break;
case REDIR_RAM:
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 200 RAM Follows\r\n"
"Content-type: audio/x-pn-realaudio\r\n"
"\r\n"
"# Autogenerated by ffserver\r\n"
"http:
VAR_8 += strlen(VAR_8);
break;
case REDIR_ASF:
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 200 ASF Redirect follows\r\n"
"Content-type: video/x-ms-asf\r\n"
"\r\n"
"[Reference]\r\n"
"Ref1=http:
VAR_8 += strlen(VAR_8);
break;
case REDIR_RTSP:
{
char VAR_18[256], *VAR_19;
av_strlcpy(VAR_18, VAR_17, sizeof(VAR_18));
VAR_19 = strrchr(VAR_18, ':');
if (VAR_19)
*VAR_19 = '\0';
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 200 RTSP Redirect follows\r\n"
"Content-type: application/x-rtsp\r\n"
"\r\n"
"rtsp:
VAR_8 += strlen(VAR_8);
}
break;
case REDIR_SDP:
{
uint8_t *sdp_data;
int VAR_19;
socklen_t len;
struct sockaddr_in VAR_20;
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 200 OK\r\n"
"Content-type: application/sdp\r\n"
"\r\n");
VAR_8 += strlen(VAR_8);
len = sizeof(VAR_20);
if (getsockname(VAR_0->fd, (struct sockaddr *)&VAR_20, &len))
http_log("getsockname() failed\n");
VAR_19 = prepare_sdp_description(stream,
&sdp_data,
VAR_20.sin_addr);
if (VAR_19 > 0) {
memcpy(VAR_8, sdp_data, VAR_19);
VAR_8 += VAR_19;
*VAR_8 = '\0';
av_free(sdp_data);
}
}
break;
default:
abort();
break;
}
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_8;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
}
}
}
snprintf(VAR_10, sizeof(VAR_10), "ASX/RAM file not handled");
goto send_error;
}
stream->conns_served++;
if (VAR_0->post) {
if (!stream->is_feed) {
const char *VAR_21 = 0;
int VAR_22 = 0;
for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\r' && *VAR_19 != '\n'; ) {
if (av_strncasecmp(VAR_19, "Pragma: log-line=", 17) == 0) {
VAR_21 = VAR_19;
break;
}
if (av_strncasecmp(VAR_19, "Pragma: client-id=", 18) == 0)
VAR_22 = strtol(VAR_19 + 18, 0, 10);
VAR_19 = strchr(VAR_19, '\n');
if (!VAR_19)
break;
VAR_19++;
}
if (VAR_21) {
char *VAR_23 = strchr(VAR_21, '\n');
VAR_21 += 17;
if (VAR_23) {
if (VAR_23[-1] == '\r')
VAR_23--;
http_log("%.*s\n", (int) (VAR_23 - VAR_21), VAR_21);
VAR_0->suppress_log = 1;
}
}
#ifdef DEBUG
http_log("\nGot request:\n%s\n", VAR_0->buffer);
#endif
if (VAR_22 && extract_rates(VAR_13, sizeof(VAR_13), VAR_0->buffer)) {
HTTPContext *wmpc;
for (wmpc = first_http_ctx; wmpc; wmpc = wmpc->next) {
if (wmpc->wmp_client_id == VAR_22)
break;
}
if (wmpc && modify_current_stream(wmpc, VAR_13))
wmpc->switch_pending = 1;
}
snprintf(VAR_10, sizeof(VAR_10), "POST command not handled");
VAR_0->stream = 0;
goto send_error;
}
if (http_start_receive_data(VAR_0) < 0) {
snprintf(VAR_10, sizeof(VAR_10), "could not open feed");
goto send_error;
}
VAR_0->http_error = 0;
VAR_0->state = HTTPSTATE_RECEIVE_DATA;
return 0;
}
#ifdef DEBUG
if (strcmp(stream->VAR_6 + strlen(stream->VAR_6) - 4, ".asf") == 0)
http_log("\nGot request:\n%s\n", VAR_0->buffer);
#endif
if (VAR_0->stream->stream_type == STREAM_TYPE_STATUS)
goto send_status;
if (open_input_stream(VAR_0, VAR_5) < 0) {
snprintf(VAR_10, sizeof(VAR_10), "Input stream corresponding to '%s' not found", VAR_7);
goto send_error;
}
VAR_0->buffer[0] = 0;
av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, "HTTP/1.0 200 OK\r\n");
VAR_11 = VAR_0->stream->fmt->VAR_11;
if (!VAR_11)
VAR_11 = "application/x-octet-stream";
av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, "Pragma: no-cache\r\n");
if (!strcmp(VAR_0->stream->fmt->name,"asf_stream")) {
VAR_0->wmp_client_id = av_lfg_get(&random_state);
av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", VAR_0->wmp_client_id);
}
av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, "Content-Type: %s\r\n", VAR_11);
av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, "\r\n");
VAR_8 = VAR_0->buffer + strlen(VAR_0->buffer);
VAR_0->http_error = 0;
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_8;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
send_error:
VAR_0->http_error = 404;
VAR_8 = VAR_0->buffer;
htmlstrip(VAR_10);
snprintf(VAR_8, VAR_0->buffer_size,
"HTTP/1.0 404 Not Found\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<html>\n"
"<head><title>404 Not Found</title></head>\n"
"<body>%s</body>\n"
"</html>\n", VAR_10);
VAR_8 += strlen(VAR_8);
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_8;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
send_status:
compute_status(VAR_0);
VAR_0->http_error = 200;
VAR_0->state = HTTPSTATE_SEND_HEADER;
return 0;
}
| [
"static int FUNC_0(HTTPContext *VAR_0)\n{",
"const char *VAR_19;",
"char *VAR_2;",
"enum RedirType VAR_3;",
"char VAR_4[32];",
"char VAR_5[1024], VAR_6[1024];",
"char VAR_7[1024], *VAR_8;",
"char VAR_9[32];",
"char VAR_10[1024];",
"const char *VAR_11;",
"FFServerStream *stream;",
"int VAR_12;",
"char VAR_13[32];",
"const char *VAR_14 = 0;",
"VAR_19 = VAR_0->buffer;",
"get_word(VAR_4, sizeof(VAR_4), &VAR_19);",
"av_strlcpy(VAR_0->method, VAR_4, sizeof(VAR_0->method));",
"if (!strcmp(VAR_4, \"GET\"))\nVAR_0->post = 0;",
"else if (!strcmp(VAR_4, \"POST\"))\nVAR_0->post = 1;",
"else\nreturn -1;",
"get_word(VAR_7, sizeof(VAR_7), &VAR_19);",
"av_strlcpy(VAR_0->VAR_7, VAR_7, sizeof(VAR_0->VAR_7));",
"get_word(VAR_9, sizeof(VAR_9), (const char **)&VAR_19);",
"if (strcmp(VAR_9, \"HTTP/1.0\") && strcmp(VAR_9, \"HTTP/1.1\"))\nreturn -1;",
"av_strlcpy(VAR_0->VAR_9, VAR_9, sizeof(VAR_0->VAR_9));",
"if (config.debug)\nhttp_log(\"%s - - New connection: %s %s\\n\", inet_ntoa(VAR_0->from_addr.sin_addr), VAR_4, VAR_7);",
"VAR_2 = strchr(VAR_7, '?');",
"if (VAR_2) {",
"av_strlcpy(VAR_5, VAR_2, sizeof(VAR_5));",
"*VAR_2 = '\\0';",
"} else",
"VAR_5[0] = '\\0';",
"av_strlcpy(VAR_6, VAR_7 + ((*VAR_7 == '/') ? 1 : 0), sizeof(VAR_6)-1);",
"for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\\r' && *VAR_19 != '\\n'; ) {",
"if (av_strncasecmp(VAR_19, \"User-Agent:\", 11) == 0) {",
"VAR_14 = VAR_19 + 11;",
"if (*VAR_14 && *VAR_14 != '\\n' && av_isspace(*VAR_14))\nVAR_14++;",
"break;",
"}",
"VAR_19 = strchr(VAR_19, '\\n');",
"if (!VAR_19)\nbreak;",
"VAR_19++;",
"}",
"VAR_3 = REDIR_NONE;",
"if (av_match_ext(VAR_6, \"asx\")) {",
"VAR_3 = REDIR_ASX;",
"VAR_6[strlen(VAR_6)-1] = 'f';",
"} else if (av_match_ext(VAR_6, \"asf\") &&",
"(!VAR_14 || av_strncasecmp(VAR_14, \"NSPlayer\", 8) != 0)) {",
"VAR_3 = REDIR_ASF;",
"} else if (av_match_ext(VAR_6, \"rpm,ram\")) {",
"VAR_3 = REDIR_RAM;",
"strcpy(VAR_6 + strlen(VAR_6)-2, \"m\");",
"} else if (av_match_ext(VAR_6, \"rtsp\")) {",
"VAR_3 = REDIR_RTSP;",
"compute_real_filename(VAR_6, sizeof(VAR_6) - 1);",
"} else if (av_match_ext(VAR_6, \"sdp\")) {",
"VAR_3 = REDIR_SDP;",
"compute_real_filename(VAR_6, sizeof(VAR_6) - 1);",
"}",
"if (!strlen(VAR_6))\nav_strlcpy(VAR_6, \"index.html\", sizeof(VAR_6) - 1);",
"stream = config.first_stream;",
"while (stream) {",
"if (!strcmp(stream->VAR_6, VAR_6) && validate_acl(stream, VAR_0))\nbreak;",
"stream = stream->next;",
"}",
"if (!stream) {",
"snprintf(VAR_10, sizeof(VAR_10), \"File '%s' not found\", VAR_7);",
"http_log(\"File '%s' not found\\n\", VAR_7);",
"goto send_error;",
"}",
"VAR_0->stream = stream;",
"memcpy(VAR_0->feed_streams, stream->feed_streams, sizeof(VAR_0->feed_streams));",
"memset(VAR_0->switch_feed_streams, -1, sizeof(VAR_0->switch_feed_streams));",
"if (stream->stream_type == STREAM_TYPE_REDIRECT) {",
"VAR_0->http_error = 301;",
"VAR_8 = VAR_0->buffer;",
"snprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 301 Moved\\r\\n\"\n\"Location: %s\\r\\n\"\n\"Content-type: text/html\\r\\n\"\n\"\\r\\n\"\n\"<html><head><title>Moved</title></head><body>\\r\\n\"\n\"You should be <a href=\\\"%s\\\">redirected</a>.\\r\\n\"\n\"</body></html>\\r\\n\", stream->feed_filename, stream->feed_filename);",
"VAR_8 += strlen(VAR_8);",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_8;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"}",
"if (extract_rates(VAR_13, sizeof(VAR_13), VAR_0->buffer)) {",
"if (modify_current_stream(VAR_0, VAR_13)) {",
"for (VAR_12 = 0; VAR_12 < FF_ARRAY_ELEMS(VAR_0->feed_streams); VAR_12++) {",
"if (VAR_0->switch_feed_streams[VAR_12] >= 0)\nVAR_0->switch_feed_streams[VAR_12] = -1;",
"}",
"}",
"}",
"if (VAR_0->post == 0 && stream->stream_type == STREAM_TYPE_LIVE)\ncurrent_bandwidth += stream->bandwidth;",
"if (stream->feed_opened) {",
"snprintf(VAR_10, sizeof(VAR_10), \"This feed is already being received.\");",
"http_log(\"Feed '%s' already being received\\n\", stream->feed_filename);",
"goto send_error;",
"}",
"if (VAR_0->post == 0 && config.max_bandwidth < current_bandwidth) {",
"VAR_0->http_error = 503;",
"VAR_8 = VAR_0->buffer;",
"snprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 503 Server too busy\\r\\n\"\n\"Content-type: text/html\\r\\n\"\n\"\\r\\n\"\n\"<html><head><title>Too busy</title></head><body>\\r\\n\"\n\"<VAR_19>The server is too busy to serve your request at this time.</VAR_19>\\r\\n\"\n\"<VAR_19>The bandwidth being served (including your stream) is %\"PRIu64\"kbit/sec, \"\n\"and this exceeds the limit of %\"PRIu64\"kbit/sec.</VAR_19>\\r\\n\"\n\"</body></html>\\r\\n\", current_bandwidth, config.max_bandwidth);",
"VAR_8 += strlen(VAR_8);",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_8;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"}",
"if (VAR_3 != REDIR_NONE) {",
"const char *VAR_15 = 0;",
"for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\\r' && *VAR_19 != '\\n'; ) {",
"if (av_strncasecmp(VAR_19, \"Host:\", 5) == 0) {",
"VAR_15 = VAR_19 + 5;",
"break;",
"}",
"VAR_19 = strchr(VAR_19, '\\n');",
"if (!VAR_19)\nbreak;",
"VAR_19++;",
"}",
"if (VAR_15) {",
"char *VAR_16;",
"char VAR_17[260];",
"while (av_isspace(*VAR_15))\nVAR_15++;",
"VAR_16 = strchr(VAR_15, '\\n');",
"if (VAR_16) {",
"if (VAR_16[-1] == '\\r')\nVAR_16--;",
"if (VAR_16 - VAR_15 < sizeof(VAR_17) - 1) {",
"memcpy(VAR_17, VAR_15, VAR_16 - VAR_15);",
"VAR_17[VAR_16 - VAR_15] = 0;",
"VAR_0->http_error = 200;",
"VAR_8 = VAR_0->buffer;",
"switch(VAR_3) {",
"case REDIR_ASX:\nsnprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 200 ASX Follows\\r\\n\"\n\"Content-type: video/x-ms-asf\\r\\n\"\n\"\\r\\n\"\n\"<ASX Version=\\\"3\\\">\\r\\n\"\n\"<ENTRY><REF HREF=\\\"http:\n\"</ASX>\\r\\n\", VAR_17, VAR_6, VAR_5);",
"VAR_8 += strlen(VAR_8);",
"break;",
"case REDIR_RAM:\nsnprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 200 RAM Follows\\r\\n\"\n\"Content-type: audio/x-pn-realaudio\\r\\n\"\n\"\\r\\n\"\n\"# Autogenerated by ffserver\\r\\n\"\n\"http:\nVAR_8 += strlen(VAR_8);",
"break;",
"case REDIR_ASF:\nsnprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 200 ASF Redirect follows\\r\\n\"\n\"Content-type: video/x-ms-asf\\r\\n\"\n\"\\r\\n\"\n\"[Reference]\\r\\n\"\n\"Ref1=http:\nVAR_8 += strlen(VAR_8);",
"break;",
"case REDIR_RTSP:\n{",
"char VAR_18[256], *VAR_19;",
"av_strlcpy(VAR_18, VAR_17, sizeof(VAR_18));",
"VAR_19 = strrchr(VAR_18, ':');",
"if (VAR_19)\n*VAR_19 = '\\0';",
"snprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 200 RTSP Redirect follows\\r\\n\"\n\"Content-type: application/x-rtsp\\r\\n\"\n\"\\r\\n\"\n\"rtsp:\nVAR_8 += strlen(VAR_8);",
"}",
"break;",
"case REDIR_SDP:\n{",
"uint8_t *sdp_data;",
"int VAR_19;",
"socklen_t len;",
"struct sockaddr_in VAR_20;",
"snprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 200 OK\\r\\n\"\n\"Content-type: application/sdp\\r\\n\"\n\"\\r\\n\");",
"VAR_8 += strlen(VAR_8);",
"len = sizeof(VAR_20);",
"if (getsockname(VAR_0->fd, (struct sockaddr *)&VAR_20, &len))\nhttp_log(\"getsockname() failed\\n\");",
"VAR_19 = prepare_sdp_description(stream,\n&sdp_data,\nVAR_20.sin_addr);",
"if (VAR_19 > 0) {",
"memcpy(VAR_8, sdp_data, VAR_19);",
"VAR_8 += VAR_19;",
"*VAR_8 = '\\0';",
"av_free(sdp_data);",
"}",
"}",
"break;",
"default:\nabort();",
"break;",
"}",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_8;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"}",
"}",
"}",
"snprintf(VAR_10, sizeof(VAR_10), \"ASX/RAM file not handled\");",
"goto send_error;",
"}",
"stream->conns_served++;",
"if (VAR_0->post) {",
"if (!stream->is_feed) {",
"const char *VAR_21 = 0;",
"int VAR_22 = 0;",
"for (VAR_19 = VAR_0->buffer; *VAR_19 && *VAR_19 != '\\r' && *VAR_19 != '\\n'; ) {",
"if (av_strncasecmp(VAR_19, \"Pragma: log-line=\", 17) == 0) {",
"VAR_21 = VAR_19;",
"break;",
"}",
"if (av_strncasecmp(VAR_19, \"Pragma: client-id=\", 18) == 0)\nVAR_22 = strtol(VAR_19 + 18, 0, 10);",
"VAR_19 = strchr(VAR_19, '\\n');",
"if (!VAR_19)\nbreak;",
"VAR_19++;",
"}",
"if (VAR_21) {",
"char *VAR_23 = strchr(VAR_21, '\\n');",
"VAR_21 += 17;",
"if (VAR_23) {",
"if (VAR_23[-1] == '\\r')\nVAR_23--;",
"http_log(\"%.*s\\n\", (int) (VAR_23 - VAR_21), VAR_21);",
"VAR_0->suppress_log = 1;",
"}",
"}",
"#ifdef DEBUG\nhttp_log(\"\\nGot request:\\n%s\\n\", VAR_0->buffer);",
"#endif\nif (VAR_22 && extract_rates(VAR_13, sizeof(VAR_13), VAR_0->buffer)) {",
"HTTPContext *wmpc;",
"for (wmpc = first_http_ctx; wmpc; wmpc = wmpc->next) {",
"if (wmpc->wmp_client_id == VAR_22)\nbreak;",
"}",
"if (wmpc && modify_current_stream(wmpc, VAR_13))\nwmpc->switch_pending = 1;",
"}",
"snprintf(VAR_10, sizeof(VAR_10), \"POST command not handled\");",
"VAR_0->stream = 0;",
"goto send_error;",
"}",
"if (http_start_receive_data(VAR_0) < 0) {",
"snprintf(VAR_10, sizeof(VAR_10), \"could not open feed\");",
"goto send_error;",
"}",
"VAR_0->http_error = 0;",
"VAR_0->state = HTTPSTATE_RECEIVE_DATA;",
"return 0;",
"}",
"#ifdef DEBUG\nif (strcmp(stream->VAR_6 + strlen(stream->VAR_6) - 4, \".asf\") == 0)\nhttp_log(\"\\nGot request:\\n%s\\n\", VAR_0->buffer);",
"#endif\nif (VAR_0->stream->stream_type == STREAM_TYPE_STATUS)\ngoto send_status;",
"if (open_input_stream(VAR_0, VAR_5) < 0) {",
"snprintf(VAR_10, sizeof(VAR_10), \"Input stream corresponding to '%s' not found\", VAR_7);",
"goto send_error;",
"}",
"VAR_0->buffer[0] = 0;",
"av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, \"HTTP/1.0 200 OK\\r\\n\");",
"VAR_11 = VAR_0->stream->fmt->VAR_11;",
"if (!VAR_11)\nVAR_11 = \"application/x-octet-stream\";",
"av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, \"Pragma: no-cache\\r\\n\");",
"if (!strcmp(VAR_0->stream->fmt->name,\"asf_stream\")) {",
"VAR_0->wmp_client_id = av_lfg_get(&random_state);",
"av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, \"Server: Cougar 4.1.0.3923\\r\\nCache-Control: no-cache\\r\\nPragma: client-id=%d\\r\\nPragma: features=\\\"broadcast\\\"\\r\\n\", VAR_0->wmp_client_id);",
"}",
"av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, \"Content-Type: %s\\r\\n\", VAR_11);",
"av_strlcatf(VAR_0->buffer, VAR_0->buffer_size, \"\\r\\n\");",
"VAR_8 = VAR_0->buffer + strlen(VAR_0->buffer);",
"VAR_0->http_error = 0;",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_8;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"send_error:\nVAR_0->http_error = 404;",
"VAR_8 = VAR_0->buffer;",
"htmlstrip(VAR_10);",
"snprintf(VAR_8, VAR_0->buffer_size,\n\"HTTP/1.0 404 Not Found\\r\\n\"\n\"Content-type: text/html\\r\\n\"\n\"\\r\\n\"\n\"<html>\\n\"\n\"<head><title>404 Not Found</title></head>\\n\"\n\"<body>%s</body>\\n\"\n\"</html>\\n\", VAR_10);",
"VAR_8 += strlen(VAR_8);",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_8;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"send_status:\ncompute_status(VAR_0);",
"VAR_0->http_error = 200;",
"VAR_0->state = HTTPSTATE_SEND_HEADER;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
69
],
[
73,
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
167,
169
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211,
213,
215,
217,
219,
221,
223,
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
263,
265
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283
],
[
285
],
[
287
],
[
289,
291,
293,
295,
297,
299,
301,
303,
305
],
[
307
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
361,
363
],
[
367
],
[
369
],
[
371,
373
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
389
],
[
391,
393,
395,
397,
399,
401,
405,
407
],
[
409
],
[
411
],
[
413,
415,
417,
419,
421,
423,
425,
427
],
[
429
],
[
431,
433,
435,
437,
439,
441,
443,
445
],
[
447
],
[
449,
451
],
[
453
],
[
457
],
[
459
],
[
461,
463
],
[
465,
467,
471,
473,
475,
477
],
[
479
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497,
499,
501,
503
],
[
505
],
[
509
],
[
515,
517
],
[
523,
525,
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545,
547
],
[
549
],
[
551
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
573
],
[
575
],
[
577
],
[
581
],
[
589
],
[
593
],
[
599
],
[
601
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615,
617
],
[
619
],
[
621,
623
],
[
627
],
[
629
],
[
633
],
[
635
],
[
639
],
[
643
],
[
645,
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
659,
661
],
[
663,
667
],
[
669
],
[
675
],
[
677,
679
],
[
681
],
[
685,
687
],
[
689
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
719,
721,
723
],
[
725,
729,
731
],
[
737
],
[
739
],
[
741
],
[
743
],
[
749
],
[
751
],
[
753
],
[
755,
757
],
[
759
],
[
765
],
[
771
],
[
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799,
801
],
[
803
],
[
805
],
[
807,
809,
811,
813,
815,
817,
819,
821
],
[
823
],
[
827
],
[
829
],
[
831
],
[
833
],
[
835,
837
],
[
839
],
[
843
],
[
845
],
[
847
]
] |
4,867 | static int get_bitmap(QEMUFile *f, void *pv, size_t size)
{
unsigned long *bmp = pv;
int i, idx = 0;
for (i = 0; i < BITS_TO_U64S(size); i++) {
uint64_t w = qemu_get_be64(f);
bmp[idx++] = w;
if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
bmp[idx++] = w >> 32;
}
}
return 0;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int get_bitmap(QEMUFile *f, void *pv, size_t size)
{
unsigned long *bmp = pv;
int i, idx = 0;
for (i = 0; i < BITS_TO_U64S(size); i++) {
uint64_t w = qemu_get_be64(f);
bmp[idx++] = w;
if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
bmp[idx++] = w >> 32;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
unsigned long *VAR_3 = VAR_1;
int VAR_4, VAR_5 = 0;
for (VAR_4 = 0; VAR_4 < BITS_TO_U64S(VAR_2); VAR_4++) {
uint64_t w = qemu_get_be64(VAR_0);
VAR_3[VAR_5++] = w;
if (sizeof(unsigned long) == 4 && VAR_5 < BITS_TO_LONGS(VAR_2)) {
VAR_3[VAR_5++] = w >> 32;
}
}
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"unsigned long *VAR_3 = VAR_1;",
"int VAR_4, VAR_5 = 0;",
"for (VAR_4 = 0; VAR_4 < BITS_TO_U64S(VAR_2); VAR_4++) {",
"uint64_t w = qemu_get_be64(VAR_0);",
"VAR_3[VAR_5++] = w;",
"if (sizeof(unsigned long) == 4 && VAR_5 < BITS_TO_LONGS(VAR_2)) {",
"VAR_3[VAR_5++] = w >> 32;",
"}",
"}",
"return 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
]
] |
4,868 | long do_sigreturn(CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr = env->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
int d0, i;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
/* set blocked signals */
if (__get_user(target_set.sig[0], &frame->sc.sc_mask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
/* restore registers */
if (restore_sigcontext(env, &frame->sc, &d0))
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return d0;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| true | qemu | 016d2e1dfa21b64a524d3629fdd317d4c25bc3b8 | long do_sigreturn(CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr = env->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
int d0, i;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
if (__get_user(target_set.sig[0], &frame->sc.sc_mask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->sc, &d0))
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return d0;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [
" goto badframe;",
" goto badframe;",
" goto badframe;",
" if (restore_sigcontext(env, &frame->sc, &d0))",
" goto badframe;",
" goto badframe;",
" goto badframe;"
],
"line_no": [
19,
19,
19,
53,
19,
19,
19
]
} | long FUNC_0(CPUM68KState *VAR_0)
{
struct target_sigframe *VAR_1;
abi_ulong frame_addr = VAR_0->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
int VAR_2, VAR_3;
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
if (__get_user(target_set.sig[0], &VAR_1->sc.sc_mask))
goto badframe;
for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) {
if (__get_user(target_set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1]))
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->sc, &VAR_2))
goto badframe;
unlock_user_struct(VAR_1, frame_addr, 0);
return VAR_2;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUM68KState *VAR_0)\n{",
"struct target_sigframe *VAR_1;",
"abi_ulong frame_addr = VAR_0->aregs[7] - 4;",
"target_sigset_t target_set;",
"sigset_t set;",
"int VAR_2, VAR_3;",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"if (__get_user(target_set.sig[0], &VAR_1->sc.sc_mask))\ngoto badframe;",
"for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) {",
"if (__get_user(target_set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1]))\ngoto badframe;",
"}",
"target_to_host_sigset_internal(&set, &target_set);",
"do_sigprocmask(SIG_SETMASK, &set, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->sc, &VAR_2))\ngoto badframe;",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return VAR_2;",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
27,
29
],
[
33
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
53,
55
],
[
59
],
[
61
],
[
65,
67
],
[
69
],
[
71
],
[
73
]
] |
4,869 | static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req)
{
struct viosrp_adapter_info *sinfo;
struct mad_adapter_info_data info;
int rc;
sinfo = &req->iu.mad.adapter_info;
#if 0 /* What for ? */
rc = spapr_tce_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer),
&info, be16_to_cpu(sinfo->common.length));
if (rc) {
fprintf(stderr, "vscsi_send_adapter_info: DMA read failure !\n");
}
#endif
memset(&info, 0, sizeof(info));
strcpy(info.srp_version, SRP_VERSION);
strncpy(info.partition_name, "qemu", sizeof("qemu"));
info.partition_number = cpu_to_be32(0);
info.mad_version = cpu_to_be32(1);
info.os_type = cpu_to_be32(2);
info.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9);
rc = spapr_tce_dma_write(&s->vdev, be64_to_cpu(sinfo->buffer),
&info, be16_to_cpu(sinfo->common.length));
if (rc) {
fprintf(stderr, "vscsi_send_adapter_info: DMA write failure !\n");
}
sinfo->common.status = rc ? cpu_to_be32(1) : 0;
return vscsi_send_iu(s, req, sizeof(*sinfo), VIOSRP_MAD_FORMAT);
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req)
{
struct viosrp_adapter_info *sinfo;
struct mad_adapter_info_data info;
int rc;
sinfo = &req->iu.mad.adapter_info;
#if 0
rc = spapr_tce_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer),
&info, be16_to_cpu(sinfo->common.length));
if (rc) {
fprintf(stderr, "vscsi_send_adapter_info: DMA read failure !\n");
}
#endif
memset(&info, 0, sizeof(info));
strcpy(info.srp_version, SRP_VERSION);
strncpy(info.partition_name, "qemu", sizeof("qemu"));
info.partition_number = cpu_to_be32(0);
info.mad_version = cpu_to_be32(1);
info.os_type = cpu_to_be32(2);
info.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9);
rc = spapr_tce_dma_write(&s->vdev, be64_to_cpu(sinfo->buffer),
&info, be16_to_cpu(sinfo->common.length));
if (rc) {
fprintf(stderr, "vscsi_send_adapter_info: DMA write failure !\n");
}
sinfo->common.status = rc ? cpu_to_be32(1) : 0;
return vscsi_send_iu(s, req, sizeof(*sinfo), VIOSRP_MAD_FORMAT);
}
| {
"code": [
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
" rc = spapr_tce_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer),",
" rc = spapr_tce_dma_write(&s->vdev, be64_to_cpu(sinfo->buffer),"
],
"line_no": [
29,
29,
29,
29,
29,
29,
29,
29,
29,
19,
47
]
} | static int FUNC_0(VSCSIState *VAR_0, vscsi_req *VAR_1)
{
struct viosrp_adapter_info *VAR_2;
struct mad_adapter_info_data VAR_3;
int VAR_4;
VAR_2 = &VAR_1->iu.mad.adapter_info;
#if 0
VAR_4 = spapr_tce_dma_read(&VAR_0->vdev, be64_to_cpu(VAR_2->buffer),
&VAR_3, be16_to_cpu(VAR_2->common.length));
if (VAR_4) {
fprintf(stderr, "FUNC_0: DMA read failure !\n");
}
#endif
memset(&VAR_3, 0, sizeof(VAR_3));
strcpy(VAR_3.srp_version, SRP_VERSION);
strncpy(VAR_3.partition_name, "qemu", sizeof("qemu"));
VAR_3.partition_number = cpu_to_be32(0);
VAR_3.mad_version = cpu_to_be32(1);
VAR_3.os_type = cpu_to_be32(2);
VAR_3.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9);
VAR_4 = spapr_tce_dma_write(&VAR_0->vdev, be64_to_cpu(VAR_2->buffer),
&VAR_3, be16_to_cpu(VAR_2->common.length));
if (VAR_4) {
fprintf(stderr, "FUNC_0: DMA write failure !\n");
}
VAR_2->common.status = VAR_4 ? cpu_to_be32(1) : 0;
return vscsi_send_iu(VAR_0, VAR_1, sizeof(*VAR_2), VIOSRP_MAD_FORMAT);
}
| [
"static int FUNC_0(VSCSIState *VAR_0, vscsi_req *VAR_1)\n{",
"struct viosrp_adapter_info *VAR_2;",
"struct mad_adapter_info_data VAR_3;",
"int VAR_4;",
"VAR_2 = &VAR_1->iu.mad.adapter_info;",
"#if 0\nVAR_4 = spapr_tce_dma_read(&VAR_0->vdev, be64_to_cpu(VAR_2->buffer),\n&VAR_3, be16_to_cpu(VAR_2->common.length));",
"if (VAR_4) {",
"fprintf(stderr, \"FUNC_0: DMA read failure !\\n\");",
"}",
"#endif\nmemset(&VAR_3, 0, sizeof(VAR_3));",
"strcpy(VAR_3.srp_version, SRP_VERSION);",
"strncpy(VAR_3.partition_name, \"qemu\", sizeof(\"qemu\"));",
"VAR_3.partition_number = cpu_to_be32(0);",
"VAR_3.mad_version = cpu_to_be32(1);",
"VAR_3.os_type = cpu_to_be32(2);",
"VAR_3.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9);",
"VAR_4 = spapr_tce_dma_write(&VAR_0->vdev, be64_to_cpu(VAR_2->buffer),\n&VAR_3, be16_to_cpu(VAR_2->common.length));",
"if (VAR_4) {",
"fprintf(stderr, \"FUNC_0: DMA write failure !\\n\");",
"}",
"VAR_2->common.status = VAR_4 ? cpu_to_be32(1) : 0;",
"return vscsi_send_iu(VAR_0, VAR_1, sizeof(*VAR_2), VIOSRP_MAD_FORMAT);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
]
] |
4,870 | static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"null"); | true | qemu | c489780203f9b22aca5539ec7589b7140bdc951f | static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"null"); | {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, Error **VAR_2)
{
QmpInputVisitor *qiv = to_qiv(VAR_0);
QObject *qobj = qmp_input_get_object(qiv, VAR_1, true);
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null",
"null"); | [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"QmpInputVisitor *qiv = to_qiv(VAR_0);",
"QObject *qobj = qmp_input_get_object(qiv, VAR_1, true);",
"if (qobject_type(qobj) != QTYPE_QNULL) {",
"error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"null\");"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6,
7
]
] |
4,871 | static void gen_spr_970_lpar(CPUPPCState *env)
{
/* Logical partitionning */
/* PPC970: HID4 is effectively the LPCR */
spr_register(env, SPR_970_HID4, "HID4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| true | qemu | 4b3fc37788fe5a9c6ec0c43863c78604db40cbb3 | static void gen_spr_970_lpar(CPUPPCState *env)
{
spr_register(env, SPR_970_HID4, "HID4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| {
"code": [
"static void gen_spr_970_lpar(CPUPPCState *env)",
" spr_register(env, SPR_970_HID4, \"HID4\",",
" SPR_NOACCESS, SPR_NOACCESS,",
" &spr_read_generic, &spr_write_generic,",
" 0x00000000);"
],
"line_no": [
1,
9,
11,
13,
15
]
} | static void FUNC_0(CPUPPCState *VAR_0)
{
spr_register(VAR_0, SPR_970_HID4, "HID4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| [
"static void FUNC_0(CPUPPCState *VAR_0)\n{",
"spr_register(VAR_0, SPR_970_HID4, \"HID4\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
9,
11,
13,
15
],
[
17
]
] |
4,872 | static inline void *alloc_code_gen_buffer(void)
{
void *buf = static_code_gen_buffer;
#ifdef __mips__
if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) {
buf = split_cross_256mb(buf, tcg_ctx.code_gen_buffer_size);
}
#endif
map_exec(buf, tcg_ctx.code_gen_buffer_size);
return buf;
}
| true | qemu | f293709c6af7a65a9bcec09cdba7a60183657a3e | static inline void *alloc_code_gen_buffer(void)
{
void *buf = static_code_gen_buffer;
#ifdef __mips__
if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) {
buf = split_cross_256mb(buf, tcg_ctx.code_gen_buffer_size);
}
#endif
map_exec(buf, tcg_ctx.code_gen_buffer_size);
return buf;
}
| {
"code": [
"#endif",
"#endif",
" if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) {",
" buf = split_cross_256mb(buf, tcg_ctx.code_gen_buffer_size);",
" map_exec(buf, tcg_ctx.code_gen_buffer_size);",
" if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) {",
" return buf;",
"static inline void *alloc_code_gen_buffer(void)",
"#ifdef __mips__",
" if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) {",
"#endif",
" map_exec(buf, tcg_ctx.code_gen_buffer_size);"
],
"line_no": [
15,
15,
9,
11,
17,
9,
19,
1,
7,
9,
15,
17
]
} | static inline void *FUNC_0(void)
{
void *VAR_0 = static_code_gen_buffer;
#ifdef __mips__
if (cross_256mb(VAR_0, tcg_ctx.code_gen_buffer_size)) {
VAR_0 = split_cross_256mb(VAR_0, tcg_ctx.code_gen_buffer_size);
}
#endif
map_exec(VAR_0, tcg_ctx.code_gen_buffer_size);
return VAR_0;
}
| [
"static inline void *FUNC_0(void)\n{",
"void *VAR_0 = static_code_gen_buffer;",
"#ifdef __mips__\nif (cross_256mb(VAR_0, tcg_ctx.code_gen_buffer_size)) {",
"VAR_0 = split_cross_256mb(VAR_0, tcg_ctx.code_gen_buffer_size);",
"}",
"#endif\nmap_exec(VAR_0, tcg_ctx.code_gen_buffer_size);",
"return VAR_0;",
"}"
] | [
1,
0,
1,
1,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
]
] |
4,875 | static void intel_hda_update_int_sts(IntelHDAState *d)
{
uint32_t sts = 0;
uint32_t i;
/* update controller status */
if (d->rirb_sts & ICH6_RBSTS_IRQ) {
sts |= (1 << 30);
}
if (d->rirb_sts & ICH6_RBSTS_OVERRUN) {
sts |= (1 << 30);
}
if (d->state_sts & d->wake_en) {
sts |= (1 << 30);
}
/* update stream status */
for (i = 0; i < 8; i++) {
/* buffer completion interrupt */
if (d->st[i].ctl & (1 << 26)) {
sts |= (1 << i);
}
}
/* update global status */
if (sts & d->int_ctl) {
sts |= (1 << 31);
}
d->int_sts = sts;
}
| true | qemu | b1fe60cd3525871a4c593ad8c2b39b89c19c00d0 | static void intel_hda_update_int_sts(IntelHDAState *d)
{
uint32_t sts = 0;
uint32_t i;
if (d->rirb_sts & ICH6_RBSTS_IRQ) {
sts |= (1 << 30);
}
if (d->rirb_sts & ICH6_RBSTS_OVERRUN) {
sts |= (1 << 30);
}
if (d->state_sts & d->wake_en) {
sts |= (1 << 30);
}
for (i = 0; i < 8; i++) {
if (d->st[i].ctl & (1 << 26)) {
sts |= (1 << i);
}
}
if (sts & d->int_ctl) {
sts |= (1 << 31);
}
d->int_sts = sts;
}
| {
"code": [
" sts |= (1 << 31);"
],
"line_no": [
53
]
} | static void FUNC_0(IntelHDAState *VAR_0)
{
uint32_t sts = 0;
uint32_t i;
if (VAR_0->rirb_sts & ICH6_RBSTS_IRQ) {
sts |= (1 << 30);
}
if (VAR_0->rirb_sts & ICH6_RBSTS_OVERRUN) {
sts |= (1 << 30);
}
if (VAR_0->state_sts & VAR_0->wake_en) {
sts |= (1 << 30);
}
for (i = 0; i < 8; i++) {
if (VAR_0->st[i].ctl & (1 << 26)) {
sts |= (1 << i);
}
}
if (sts & VAR_0->int_ctl) {
sts |= (1 << 31);
}
VAR_0->int_sts = sts;
}
| [
"static void FUNC_0(IntelHDAState *VAR_0)\n{",
"uint32_t sts = 0;",
"uint32_t i;",
"if (VAR_0->rirb_sts & ICH6_RBSTS_IRQ) {",
"sts |= (1 << 30);",
"}",
"if (VAR_0->rirb_sts & ICH6_RBSTS_OVERRUN) {",
"sts |= (1 << 30);",
"}",
"if (VAR_0->state_sts & VAR_0->wake_en) {",
"sts |= (1 << 30);",
"}",
"for (i = 0; i < 8; i++) {",
"if (VAR_0->st[i].ctl & (1 << 26)) {",
"sts |= (1 << i);",
"}",
"}",
"if (sts & VAR_0->int_ctl) {",
"sts |= (1 << 31);",
"}",
"VAR_0->int_sts = sts;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
4,877 | static void do_loadvm(Monitor *mon, const QDict *qdict)
{
int saved_vm_running = vm_running;
const char *name = qdict_get_str(qdict, "name");
vm_stop(0);
if (load_vmstate(name) >= 0 && saved_vm_running)
vm_start();
}
| true | qemu | f0aa7a8b2d518c54430e4382309281b93e51981a | static void do_loadvm(Monitor *mon, const QDict *qdict)
{
int saved_vm_running = vm_running;
const char *name = qdict_get_str(qdict, "name");
vm_stop(0);
if (load_vmstate(name) >= 0 && saved_vm_running)
vm_start();
}
| {
"code": [
" if (load_vmstate(name) >= 0 && saved_vm_running)"
],
"line_no": [
15
]
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
int VAR_2 = vm_running;
const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");
vm_stop(0);
if (load_vmstate(VAR_3) >= 0 && VAR_2)
vm_start();
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"int VAR_2 = vm_running;",
"const char *VAR_3 = qdict_get_str(VAR_1, \"VAR_3\");",
"vm_stop(0);",
"if (load_vmstate(VAR_3) >= 0 && VAR_2)\nvm_start();",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
19
]
] |
4,878 | static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst_u, uint8_t *dst_v,
ptrdiff_t dst_stride,
const uint8_t *ref_u, ptrdiff_t src_stride_u,
const uint8_t *ref_v, ptrdiff_t src_stride_v,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_chroma_unscaled(s, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
ref_v, src_stride_v, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
int mx, my;
int refbw_m1, refbh_m1;
int th;
VP56mv mv;
if (s->ss_h) {
// BUG https://code.google.com/p/webm/issues/detail?id=820
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 16, (s->cols * 4 - x + px + 3) * 16);
mx = scale_mv(mv.x, 0) + (scale_mv(x * 16, 0) & ~15) + (scale_mv(x * 32, 0) & 15);
} else {
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
mx = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
}
if (s->ss_v) {
// BUG https://code.google.com/p/webm/issues/detail?id=820
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 16, (s->rows * 4 - y + py + 3) * 16);
my = scale_mv(mv.y, 1) + (scale_mv(y * 16, 1) & ~15) + (scale_mv(y * 32, 1) & 15);
} else {
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
my = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
}
#undef scale_mv
y = my >> 4;
x = mx >> 4;
ref_u += y * src_stride_u + x * bytesperpixel;
ref_v += y * src_stride_v + x * bytesperpixel;
mx &= 15;
my &= 15;
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
// FIXME bilinear filter only needs 0/1 pixels, not 3/4
// we use +7 because the last 7 pixels of each sbrow can be changed in
// the longest loopfilter of the next sbrow
th = (y + refbh_m1 + 4 + 7) >> (6 - s->ss_v);
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_u - 3 * src_stride_u - 3 * bytesperpixel,
288, src_stride_u,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_u = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_v - 3 * src_stride_v - 3 * bytesperpixel,
288, src_stride_v,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_v = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
} else {
smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
}
}
}
| true | FFmpeg | 68caef9d48c4f1540b1b3181ebe7062a3417c62a | static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst_u, uint8_t *dst_v,
ptrdiff_t dst_stride,
const uint8_t *ref_u, ptrdiff_t src_stride_u,
const uint8_t *ref_v, ptrdiff_t src_stride_v,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_chroma_unscaled(s, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
ref_v, src_stride_v, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
int mx, my;
int refbw_m1, refbh_m1;
int th;
VP56mv mv;
if (s->ss_h) {
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 16, (s->cols * 4 - x + px + 3) * 16);
mx = scale_mv(mv.x, 0) + (scale_mv(x * 16, 0) & ~15) + (scale_mv(x * 32, 0) & 15);
} else {
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
mx = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
}
if (s->ss_v) {
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 16, (s->rows * 4 - y + py + 3) * 16);
my = scale_mv(mv.y, 1) + (scale_mv(y * 16, 1) & ~15) + (scale_mv(y * 32, 1) & 15);
} else {
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
my = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
}
#undef scale_mv
y = my >> 4;
x = mx >> 4;
ref_u += y * src_stride_u + x * bytesperpixel;
ref_v += y * src_stride_v + x * bytesperpixel;
mx &= 15;
my &= 15;
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
th = (y + refbh_m1 + 4 + 7) >> (6 - s->ss_v);
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_u - 3 * src_stride_u - 3 * bytesperpixel,
288, src_stride_u,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_u = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_v - 3 * src_stride_v - 3 * bytesperpixel,
288, src_stride_v,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_v = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
} else {
smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
}
}
}
| {
"code": [
" if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {",
" if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {"
],
"line_no": [
107,
107
]
} | static av_always_inline void FUNC_0(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst_u, uint8_t *dst_v,
ptrdiff_t dst_stride,
const uint8_t *ref_u, ptrdiff_t src_stride_u,
const uint8_t *ref_v, ptrdiff_t src_stride_v,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_chroma_unscaled(s, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
ref_v, src_stride_v, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
int VAR_0, VAR_1;
int VAR_2, VAR_3;
int VAR_4;
VP56mv mv;
if (s->ss_h) {
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 16, (s->cols * 4 - x + px + 3) * 16);
VAR_0 = scale_mv(mv.x, 0) + (scale_mv(x * 16, 0) & ~15) + (scale_mv(x * 32, 0) & 15);
} else {
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
VAR_0 = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
}
if (s->ss_v) {
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 16, (s->rows * 4 - y + py + 3) * 16);
VAR_1 = scale_mv(mv.y, 1) + (scale_mv(y * 16, 1) & ~15) + (scale_mv(y * 32, 1) & 15);
} else {
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
VAR_1 = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
}
#undef scale_mv
y = VAR_1 >> 4;
x = VAR_0 >> 4;
ref_u += y * src_stride_u + x * bytesperpixel;
ref_v += y * src_stride_v + x * bytesperpixel;
VAR_0 &= 15;
VAR_1 &= 15;
VAR_2 = ((bw - 1) * step[0] + VAR_0) >> 4;
VAR_3 = ((bh - 1) * step[1] + VAR_1) >> 4;
VAR_4 = (y + VAR_3 + 4 + 7) >> (6 - s->ss_v);
ff_thread_await_progress(ref_frame, FFMAX(VAR_4, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - VAR_2 || y + 4 >= h - VAR_3) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_u - 3 * src_stride_u - 3 * bytesperpixel,
288, src_stride_u,
VAR_2 + 8, VAR_3 + 8,
x - 3, y - 3, w, h);
ref_u = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_u, dst_stride, ref_u, 288, bh, VAR_0, VAR_1, step[0], step[1]);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref_v - 3 * src_stride_v - 3 * bytesperpixel,
288, src_stride_v,
VAR_2 + 8, VAR_3 + 8,
x - 3, y - 3, w, h);
ref_v = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_v, dst_stride, ref_v, 288, bh, VAR_0, VAR_1, step[0], step[1]);
} else {
smc(dst_u, dst_stride, ref_u, src_stride_u, bh, VAR_0, VAR_1, step[0], step[1]);
smc(dst_v, dst_stride, ref_v, src_stride_v, bh, VAR_0, VAR_1, step[0], step[1]);
}
}
}
| [
"static av_always_inline void FUNC_0(VP9Context *s, vp9_scaled_mc_func smc,\nvp9_mc_func (*mc)[2],\nuint8_t *dst_u, uint8_t *dst_v,\nptrdiff_t dst_stride,\nconst uint8_t *ref_u, ptrdiff_t src_stride_u,\nconst uint8_t *ref_v, ptrdiff_t src_stride_v,\nThreadFrame *ref_frame,\nptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,\nint px, int py, int pw, int ph,\nint bw, int bh, int w, int h, int bytesperpixel,\nconst uint16_t *scale, const uint8_t *step)\n{",
"if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&\ns->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {",
"mc_chroma_unscaled(s, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,\nref_v, src_stride_v, ref_frame,\ny, x, in_mv, bw, bh, w, h, bytesperpixel);",
"} else {",
"int VAR_0, VAR_1;",
"int VAR_2, VAR_3;",
"int VAR_4;",
"VP56mv mv;",
"if (s->ss_h) {",
"mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 16, (s->cols * 4 - x + px + 3) * 16);",
"VAR_0 = scale_mv(mv.x, 0) + (scale_mv(x * 16, 0) & ~15) + (scale_mv(x * 32, 0) & 15);",
"} else {",
"mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);",
"VAR_0 = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);",
"}",
"if (s->ss_v) {",
"mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 16, (s->rows * 4 - y + py + 3) * 16);",
"VAR_1 = scale_mv(mv.y, 1) + (scale_mv(y * 16, 1) & ~15) + (scale_mv(y * 32, 1) & 15);",
"} else {",
"mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);",
"VAR_1 = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);",
"}",
"#undef scale_mv\ny = VAR_1 >> 4;",
"x = VAR_0 >> 4;",
"ref_u += y * src_stride_u + x * bytesperpixel;",
"ref_v += y * src_stride_v + x * bytesperpixel;",
"VAR_0 &= 15;",
"VAR_1 &= 15;",
"VAR_2 = ((bw - 1) * step[0] + VAR_0) >> 4;",
"VAR_3 = ((bh - 1) * step[1] + VAR_1) >> 4;",
"VAR_4 = (y + VAR_3 + 4 + 7) >> (6 - s->ss_v);",
"ff_thread_await_progress(ref_frame, FFMAX(VAR_4, 0), 0);",
"if (x < 3 || y < 3 || x + 4 >= w - VAR_2 || y + 4 >= h - VAR_3) {",
"s->vdsp.emulated_edge_mc(s->edge_emu_buffer,\nref_u - 3 * src_stride_u - 3 * bytesperpixel,\n288, src_stride_u,\nVAR_2 + 8, VAR_3 + 8,\nx - 3, y - 3, w, h);",
"ref_u = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;",
"smc(dst_u, dst_stride, ref_u, 288, bh, VAR_0, VAR_1, step[0], step[1]);",
"s->vdsp.emulated_edge_mc(s->edge_emu_buffer,\nref_v - 3 * src_stride_v - 3 * bytesperpixel,\n288, src_stride_v,\nVAR_2 + 8, VAR_3 + 8,\nx - 3, y - 3, w, h);",
"ref_v = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;",
"smc(dst_v, dst_stride, ref_v, 288, bh, VAR_0, VAR_1, step[0], step[1]);",
"} else {",
"smc(dst_u, dst_stride, ref_u, src_stride_u, bh, VAR_0, VAR_1, step[0], step[1]);",
"smc(dst_v, dst_stride, ref_v, src_stride_v, bh, VAR_0, VAR_1, step[0], step[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,
1,
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
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
105
],
[
107
],
[
109,
111,
113,
115,
117
],
[
119
],
[
121
],
[
125,
127,
129,
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
]
] |
4,880 | static void gen_add_carry(TCGv dest, TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_add_i32(dest, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(dest, dest, tmp);
dead_tmp(tmp);
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static void gen_add_carry(TCGv dest, TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_add_i32(dest, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(dest, dest, tmp);
dead_tmp(tmp);
}
| {
"code": [
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)
{
TCGv tmp;
tcg_gen_add_i32(VAR_0, VAR_1, VAR_2);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(VAR_0, VAR_0, tmp);
dead_tmp(tmp);
}
| [
"static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"TCGv tmp;",
"tcg_gen_add_i32(VAR_0, VAR_1, VAR_2);",
"tmp = load_cpu_field(CF);",
"tcg_gen_add_i32(VAR_0, VAR_0, tmp);",
"dead_tmp(tmp);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
4,881 | static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
int *got_frame, AVPacket *pkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
av_assert0(avci->compat_decode_consumed == 0);
*got_frame = 0;
avci->compat_decode = 1;
if (avci->compat_decode_partial_size > 0 &&
avci->compat_decode_partial_size != pkt->size) {
av_log(avctx, AV_LOG_ERROR,
"Got unexpected packet size after a partial decode\n");
ret = AVERROR(EINVAL);
goto finish;
}
if (!avci->compat_decode_partial_size) {
ret = avcodec_send_packet(avctx, pkt);
if (ret == AVERROR_EOF)
ret = 0;
else if (ret == AVERROR(EAGAIN)) {
/* we fully drain all the output in each decode call, so this should not
* ever happen */
ret = AVERROR_BUG;
goto finish;
} else if (ret < 0)
goto finish;
}
while (ret >= 0) {
ret = avcodec_receive_frame(avctx, frame);
if (ret < 0) {
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
goto finish;
}
if (frame != avci->compat_decode_frame) {
if (!avctx->refcounted_frames) {
ret = unrefcount_frame(avci, frame);
if (ret < 0)
goto finish;
}
*got_frame = 1;
frame = avci->compat_decode_frame;
} else {
if (!avci->compat_decode_warned) {
av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* "
"API cannot return all the frames for this decoder. "
"Some frames will be dropped. Update your code to the "
"new decoding API to fix this.\n");
avci->compat_decode_warned = 1;
}
}
if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))
break;
}
finish:
if (ret == 0) {
/* if there are any bsfs then assume full packet is always consumed */
if (avctx->codec->bsfs)
ret = pkt->size;
else
ret = FFMIN(avci->compat_decode_consumed, pkt->size);
}
avci->compat_decode_consumed = 0;
avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;
return ret;
}
| true | FFmpeg | efddf2c09aed7400c73ecf327f86a4d0452b94b5 | static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
int *got_frame, AVPacket *pkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
av_assert0(avci->compat_decode_consumed == 0);
*got_frame = 0;
avci->compat_decode = 1;
if (avci->compat_decode_partial_size > 0 &&
avci->compat_decode_partial_size != pkt->size) {
av_log(avctx, AV_LOG_ERROR,
"Got unexpected packet size after a partial decode\n");
ret = AVERROR(EINVAL);
goto finish;
}
if (!avci->compat_decode_partial_size) {
ret = avcodec_send_packet(avctx, pkt);
if (ret == AVERROR_EOF)
ret = 0;
else if (ret == AVERROR(EAGAIN)) {
ret = AVERROR_BUG;
goto finish;
} else if (ret < 0)
goto finish;
}
while (ret >= 0) {
ret = avcodec_receive_frame(avctx, frame);
if (ret < 0) {
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
goto finish;
}
if (frame != avci->compat_decode_frame) {
if (!avctx->refcounted_frames) {
ret = unrefcount_frame(avci, frame);
if (ret < 0)
goto finish;
}
*got_frame = 1;
frame = avci->compat_decode_frame;
} else {
if (!avci->compat_decode_warned) {
av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* "
"API cannot return all the frames for this decoder. "
"Some frames will be dropped. Update your code to the "
"new decoding API to fix this.\n");
avci->compat_decode_warned = 1;
}
}
if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))
break;
}
finish:
if (ret == 0) {
if (avctx->codec->bsfs)
ret = pkt->size;
else
ret = FFMIN(avci->compat_decode_consumed, pkt->size);
}
avci->compat_decode_consumed = 0;
avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;
return ret;
}
| {
"code": [
" int ret;"
],
"line_no": [
9
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVCodecInternal *avci = VAR_0->internal;
int VAR_4;
av_assert0(avci->compat_decode_consumed == 0);
*VAR_2 = 0;
avci->FUNC_0 = 1;
if (avci->compat_decode_partial_size > 0 &&
avci->compat_decode_partial_size != VAR_3->size) {
av_log(VAR_0, AV_LOG_ERROR,
"Got unexpected packet size after a partial decode\n");
VAR_4 = AVERROR(EINVAL);
goto finish;
}
if (!avci->compat_decode_partial_size) {
VAR_4 = avcodec_send_packet(VAR_0, VAR_3);
if (VAR_4 == AVERROR_EOF)
VAR_4 = 0;
else if (VAR_4 == AVERROR(EAGAIN)) {
VAR_4 = AVERROR_BUG;
goto finish;
} else if (VAR_4 < 0)
goto finish;
}
while (VAR_4 >= 0) {
VAR_4 = avcodec_receive_frame(VAR_0, VAR_1);
if (VAR_4 < 0) {
if (VAR_4 == AVERROR(EAGAIN) || VAR_4 == AVERROR_EOF)
VAR_4 = 0;
goto finish;
}
if (VAR_1 != avci->compat_decode_frame) {
if (!VAR_0->refcounted_frames) {
VAR_4 = unrefcount_frame(avci, VAR_1);
if (VAR_4 < 0)
goto finish;
}
*VAR_2 = 1;
VAR_1 = avci->compat_decode_frame;
} else {
if (!avci->compat_decode_warned) {
av_log(VAR_0, AV_LOG_WARNING, "The deprecated avcodec_decode_* "
"API cannot return all the frames for this decoder. "
"Some frames will be dropped. Update your code to the "
"new decoding API to fix this.\n");
avci->compat_decode_warned = 1;
}
}
if (avci->draining || (!VAR_0->codec->bsfs && avci->compat_decode_consumed < VAR_3->size))
break;
}
finish:
if (VAR_4 == 0) {
if (VAR_0->codec->bsfs)
VAR_4 = VAR_3->size;
else
VAR_4 = FFMIN(avci->compat_decode_consumed, VAR_3->size);
}
avci->compat_decode_consumed = 0;
avci->compat_decode_partial_size = (VAR_4 >= 0) ? VAR_3->size - VAR_4 : 0;
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVCodecInternal *avci = VAR_0->internal;",
"int VAR_4;",
"av_assert0(avci->compat_decode_consumed == 0);",
"*VAR_2 = 0;",
"avci->FUNC_0 = 1;",
"if (avci->compat_decode_partial_size > 0 &&\navci->compat_decode_partial_size != VAR_3->size) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Got unexpected packet size after a partial decode\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto finish;",
"}",
"if (!avci->compat_decode_partial_size) {",
"VAR_4 = avcodec_send_packet(VAR_0, VAR_3);",
"if (VAR_4 == AVERROR_EOF)\nVAR_4 = 0;",
"else if (VAR_4 == AVERROR(EAGAIN)) {",
"VAR_4 = AVERROR_BUG;",
"goto finish;",
"} else if (VAR_4 < 0)",
"goto finish;",
"}",
"while (VAR_4 >= 0) {",
"VAR_4 = avcodec_receive_frame(VAR_0, VAR_1);",
"if (VAR_4 < 0) {",
"if (VAR_4 == AVERROR(EAGAIN) || VAR_4 == AVERROR_EOF)\nVAR_4 = 0;",
"goto finish;",
"}",
"if (VAR_1 != avci->compat_decode_frame) {",
"if (!VAR_0->refcounted_frames) {",
"VAR_4 = unrefcount_frame(avci, VAR_1);",
"if (VAR_4 < 0)\ngoto finish;",
"}",
"*VAR_2 = 1;",
"VAR_1 = avci->compat_decode_frame;",
"} else {",
"if (!avci->compat_decode_warned) {",
"av_log(VAR_0, AV_LOG_WARNING, \"The deprecated avcodec_decode_* \"\n\"API cannot return all the frames for this decoder. \"\n\"Some frames will be dropped. Update your code to the \"\n\"new decoding API to fix this.\\n\");",
"avci->compat_decode_warned = 1;",
"}",
"}",
"if (avci->draining || (!VAR_0->codec->bsfs && avci->compat_decode_consumed < VAR_3->size))\nbreak;",
"}",
"finish:\nif (VAR_4 == 0) {",
"if (VAR_0->codec->bsfs)\nVAR_4 = VAR_3->size;",
"else\nVAR_4 = FFMIN(avci->compat_decode_consumed, VAR_3->size);",
"}",
"avci->compat_decode_consumed = 0;",
"avci->compat_decode_partial_size = (VAR_4 >= 0) ? VAR_3->size - VAR_4 : 0;",
"return VAR_4;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
119,
121
],
[
123
],
[
127,
129
],
[
133,
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
]
] |
4,882 | static void gen_wsr_debugcause(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
}
| true | qemu | 53593e90d13264dc88b3281ddf75ceaa641df05a | static void gen_wsr_debugcause(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
}
| {
"code": [
"static void gen_wsr_debugcause(DisasContext *dc, uint32_t sr, TCGv_i32 v)"
],
"line_no": [
1
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, TCGv_i32 VAR_2)
{
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, TCGv_i32 VAR_2)\n{",
"}"
] | [
1,
0
] | [
[
1,
3
],
[
5
]
] |
4,883 | static int jp2_find_codestream(Jpeg2000DecoderContext *s)
{
uint32_t atom_size, atom, atom_end;
int search_range = 10;
while (search_range
&&
bytestream2_get_bytes_left(&s->g) >= 8) {
atom_size = bytestream2_get_be32u(&s->g);
atom = bytestream2_get_be32u(&s->g);
atom_end = bytestream2_tell(&s->g) + atom_size - 8;
if (atom == JP2_CODESTREAM)
return 1;
if (bytestream2_get_bytes_left(&s->g) < atom_size || atom_end < atom_size)
return 0;
if (atom == JP2_HEADER &&
atom_size >= 16) {
uint32_t atom2_size, atom2, atom2_end;
do {
atom2_size = bytestream2_get_be32u(&s->g);
atom2 = bytestream2_get_be32u(&s->g);
atom2_end = bytestream2_tell(&s->g) + atom2_size - 8;
if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
break;
atom2_size -= 8;
if (atom2 == JP2_CODESTREAM) {
return 1;
} else if (atom2 == MKBETAG('c','o','l','r') && atom2_size >= 7) {
int method = bytestream2_get_byteu(&s->g);
bytestream2_skipu(&s->g, 2);
if (method == 1) {
s->colour_space = bytestream2_get_be32u(&s->g);
} else if (atom2 == MKBETAG('p','c','l','r') && atom2_size >= 6) {
int i, size, colour_count, colour_channels, colour_depth[3];
uint32_t r, g, b;
colour_count = bytestream2_get_be16u(&s->g);
colour_channels = bytestream2_get_byteu(&s->g);
// FIXME: Do not ignore channel_sign
colour_depth[0] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
colour_depth[1] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
colour_depth[2] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
size = (colour_depth[0] + 7 >> 3) * colour_count +
(colour_depth[1] + 7 >> 3) * colour_count +
(colour_depth[2] + 7 >> 3) * colour_count;
if (colour_count > 256 ||
colour_channels != 3 ||
colour_depth[0] > 16 ||
colour_depth[1] > 16 ||
colour_depth[2] > 16 ||
atom2_size < size) {
avpriv_request_sample(s->avctx, "Unknown palette");
s->pal8 = 1;
for (i = 0; i < colour_count; i++) {
if (colour_depth[0] <= 8) {
r = bytestream2_get_byteu(&s->g) << 8 - colour_depth[0];
r |= r >> colour_depth[0];
} else {
r = bytestream2_get_be16u(&s->g) >> colour_depth[0] - 8;
if (colour_depth[1] <= 8) {
g = bytestream2_get_byteu(&s->g) << 8 - colour_depth[1];
r |= r >> colour_depth[1];
} else {
g = bytestream2_get_be16u(&s->g) >> colour_depth[1] - 8;
if (colour_depth[2] <= 8) {
b = bytestream2_get_byteu(&s->g) << 8 - colour_depth[2];
r |= r >> colour_depth[2];
} else {
b = bytestream2_get_be16u(&s->g) >> colour_depth[2] - 8;
s->palette[i] = 0xffu << 24 | r << 16 | g << 8 | b;
} else if (atom2 == MKBETAG('c','d','e','f') && atom2_size >= 2) {
int n = bytestream2_get_be16u(&s->g);
for (; n>0; n--) {
int cn = bytestream2_get_be16(&s->g);
int av_unused typ = bytestream2_get_be16(&s->g);
int asoc = bytestream2_get_be16(&s->g);
if (cn < 4 && asoc < 4)
s->cdef[cn] = asoc;
} else if (atom2 == MKBETAG('r','e','s',' ') && atom2_size >= 18) {
int64_t vnum, vden, hnum, hden, vexp, hexp;
uint32_t resx;
bytestream2_skip(&s->g, 4);
resx = bytestream2_get_be32u(&s->g);
if (resx != MKBETAG('r','e','s','c') && resx != MKBETAG('r','e','s','d')) {
vnum = bytestream2_get_be16u(&s->g);
vden = bytestream2_get_be16u(&s->g);
hnum = bytestream2_get_be16u(&s->g);
hden = bytestream2_get_be16u(&s->g);
vexp = bytestream2_get_byteu(&s->g);
hexp = bytestream2_get_byteu(&s->g);
if (vexp > hexp) {
vexp -= hexp;
hexp = 0;
} else {
hexp -= vexp;
vexp = 0;
if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
&& INT64_MAX / (vnum * hden) > pow(10, vexp))
av_reduce(&s->sar.den, &s->sar.num,
hnum * vden * pow(10, hexp),
vnum * hden * pow(10, vexp),
INT32_MAX);
} while (atom_end - atom2_end >= 8);
} else {
search_range--;
bytestream2_seek(&s->g, atom_end, SEEK_SET);
return 0;
| true | FFmpeg | 1b00600319506a9bd81b114d2b374051dc1a29a6 | static int jp2_find_codestream(Jpeg2000DecoderContext *s)
{
uint32_t atom_size, atom, atom_end;
int search_range = 10;
while (search_range
&&
bytestream2_get_bytes_left(&s->g) >= 8) {
atom_size = bytestream2_get_be32u(&s->g);
atom = bytestream2_get_be32u(&s->g);
atom_end = bytestream2_tell(&s->g) + atom_size - 8;
if (atom == JP2_CODESTREAM)
return 1;
if (bytestream2_get_bytes_left(&s->g) < atom_size || atom_end < atom_size)
return 0;
if (atom == JP2_HEADER &&
atom_size >= 16) {
uint32_t atom2_size, atom2, atom2_end;
do {
atom2_size = bytestream2_get_be32u(&s->g);
atom2 = bytestream2_get_be32u(&s->g);
atom2_end = bytestream2_tell(&s->g) + atom2_size - 8;
if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
break;
atom2_size -= 8;
if (atom2 == JP2_CODESTREAM) {
return 1;
} else if (atom2 == MKBETAG('c','o','l','r') && atom2_size >= 7) {
int method = bytestream2_get_byteu(&s->g);
bytestream2_skipu(&s->g, 2);
if (method == 1) {
s->colour_space = bytestream2_get_be32u(&s->g);
} else if (atom2 == MKBETAG('p','c','l','r') && atom2_size >= 6) {
int i, size, colour_count, colour_channels, colour_depth[3];
uint32_t r, g, b;
colour_count = bytestream2_get_be16u(&s->g);
colour_channels = bytestream2_get_byteu(&s->g);
colour_depth[0] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
colour_depth[1] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
colour_depth[2] = (bytestream2_get_byteu(&s->g) & 0x7f) + 1;
size = (colour_depth[0] + 7 >> 3) * colour_count +
(colour_depth[1] + 7 >> 3) * colour_count +
(colour_depth[2] + 7 >> 3) * colour_count;
if (colour_count > 256 ||
colour_channels != 3 ||
colour_depth[0] > 16 ||
colour_depth[1] > 16 ||
colour_depth[2] > 16 ||
atom2_size < size) {
avpriv_request_sample(s->avctx, "Unknown palette");
s->pal8 = 1;
for (i = 0; i < colour_count; i++) {
if (colour_depth[0] <= 8) {
r = bytestream2_get_byteu(&s->g) << 8 - colour_depth[0];
r |= r >> colour_depth[0];
} else {
r = bytestream2_get_be16u(&s->g) >> colour_depth[0] - 8;
if (colour_depth[1] <= 8) {
g = bytestream2_get_byteu(&s->g) << 8 - colour_depth[1];
r |= r >> colour_depth[1];
} else {
g = bytestream2_get_be16u(&s->g) >> colour_depth[1] - 8;
if (colour_depth[2] <= 8) {
b = bytestream2_get_byteu(&s->g) << 8 - colour_depth[2];
r |= r >> colour_depth[2];
} else {
b = bytestream2_get_be16u(&s->g) >> colour_depth[2] - 8;
s->palette[i] = 0xffu << 24 | r << 16 | g << 8 | b;
} else if (atom2 == MKBETAG('c','d','e','f') && atom2_size >= 2) {
int n = bytestream2_get_be16u(&s->g);
for (; n>0; n--) {
int cn = bytestream2_get_be16(&s->g);
int av_unused typ = bytestream2_get_be16(&s->g);
int asoc = bytestream2_get_be16(&s->g);
if (cn < 4 && asoc < 4)
s->cdef[cn] = asoc;
} else if (atom2 == MKBETAG('r','e','s',' ') && atom2_size >= 18) {
int64_t vnum, vden, hnum, hden, vexp, hexp;
uint32_t resx;
bytestream2_skip(&s->g, 4);
resx = bytestream2_get_be32u(&s->g);
if (resx != MKBETAG('r','e','s','c') && resx != MKBETAG('r','e','s','d')) {
vnum = bytestream2_get_be16u(&s->g);
vden = bytestream2_get_be16u(&s->g);
hnum = bytestream2_get_be16u(&s->g);
hden = bytestream2_get_be16u(&s->g);
vexp = bytestream2_get_byteu(&s->g);
hexp = bytestream2_get_byteu(&s->g);
if (vexp > hexp) {
vexp -= hexp;
hexp = 0;
} else {
hexp -= vexp;
vexp = 0;
if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
&& INT64_MAX / (vnum * hden) > pow(10, vexp))
av_reduce(&s->sar.den, &s->sar.num,
hnum * vden * pow(10, hexp),
vnum * hden * pow(10, vexp),
INT32_MAX);
} while (atom_end - atom2_end >= 8);
} else {
search_range--;
bytestream2_seek(&s->g, atom_end, SEEK_SET);
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(Jpeg2000DecoderContext *VAR_0)
{
uint32_t atom_size, atom, atom_end;
int VAR_1 = 10;
while (VAR_1
&&
bytestream2_get_bytes_left(&VAR_0->g) >= 8) {
atom_size = bytestream2_get_be32u(&VAR_0->g);
atom = bytestream2_get_be32u(&VAR_0->g);
atom_end = bytestream2_tell(&VAR_0->g) + atom_size - 8;
if (atom == JP2_CODESTREAM)
return 1;
if (bytestream2_get_bytes_left(&VAR_0->g) < atom_size || atom_end < atom_size)
return 0;
if (atom == JP2_HEADER &&
atom_size >= 16) {
uint32_t atom2_size, atom2, atom2_end;
do {
atom2_size = bytestream2_get_be32u(&VAR_0->g);
atom2 = bytestream2_get_be32u(&VAR_0->g);
atom2_end = bytestream2_tell(&VAR_0->g) + atom2_size - 8;
if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
break;
atom2_size -= 8;
if (atom2 == JP2_CODESTREAM) {
return 1;
} else if (atom2 == MKBETAG('c','o','l','r') && atom2_size >= 7) {
int method = bytestream2_get_byteu(&VAR_0->g);
bytestream2_skipu(&VAR_0->g, 2);
if (method == 1) {
VAR_0->colour_space = bytestream2_get_be32u(&VAR_0->g);
} else if (atom2 == MKBETAG('p','c','l','r') && atom2_size >= 6) {
int i, size, colour_count, colour_channels, colour_depth[3];
uint32_t r, g, b;
colour_count = bytestream2_get_be16u(&VAR_0->g);
colour_channels = bytestream2_get_byteu(&VAR_0->g);
colour_depth[0] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;
colour_depth[1] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;
colour_depth[2] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;
size = (colour_depth[0] + 7 >> 3) * colour_count +
(colour_depth[1] + 7 >> 3) * colour_count +
(colour_depth[2] + 7 >> 3) * colour_count;
if (colour_count > 256 ||
colour_channels != 3 ||
colour_depth[0] > 16 ||
colour_depth[1] > 16 ||
colour_depth[2] > 16 ||
atom2_size < size) {
avpriv_request_sample(VAR_0->avctx, "Unknown palette");
VAR_0->pal8 = 1;
for (i = 0; i < colour_count; i++) {
if (colour_depth[0] <= 8) {
r = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[0];
r |= r >> colour_depth[0];
} else {
r = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[0] - 8;
if (colour_depth[1] <= 8) {
g = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[1];
r |= r >> colour_depth[1];
} else {
g = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[1] - 8;
if (colour_depth[2] <= 8) {
b = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[2];
r |= r >> colour_depth[2];
} else {
b = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[2] - 8;
VAR_0->palette[i] = 0xffu << 24 | r << 16 | g << 8 | b;
} else if (atom2 == MKBETAG('c','d','e','f') && atom2_size >= 2) {
int n = bytestream2_get_be16u(&VAR_0->g);
for (; n>0; n--) {
int cn = bytestream2_get_be16(&VAR_0->g);
int av_unused typ = bytestream2_get_be16(&VAR_0->g);
int asoc = bytestream2_get_be16(&VAR_0->g);
if (cn < 4 && asoc < 4)
VAR_0->cdef[cn] = asoc;
} else if (atom2 == MKBETAG('r','e','VAR_0',' ') && atom2_size >= 18) {
int64_t vnum, vden, hnum, hden, vexp, hexp;
uint32_t resx;
bytestream2_skip(&VAR_0->g, 4);
resx = bytestream2_get_be32u(&VAR_0->g);
if (resx != MKBETAG('r','e','VAR_0','c') && resx != MKBETAG('r','e','VAR_0','d')) {
vnum = bytestream2_get_be16u(&VAR_0->g);
vden = bytestream2_get_be16u(&VAR_0->g);
hnum = bytestream2_get_be16u(&VAR_0->g);
hden = bytestream2_get_be16u(&VAR_0->g);
vexp = bytestream2_get_byteu(&VAR_0->g);
hexp = bytestream2_get_byteu(&VAR_0->g);
if (vexp > hexp) {
vexp -= hexp;
hexp = 0;
} else {
hexp -= vexp;
vexp = 0;
if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
&& INT64_MAX / (vnum * hden) > pow(10, vexp))
av_reduce(&VAR_0->sar.den, &VAR_0->sar.num,
hnum * vden * pow(10, hexp),
vnum * hden * pow(10, vexp),
INT32_MAX);
} while (atom_end - atom2_end >= 8);
} else {
VAR_1--;
bytestream2_seek(&VAR_0->g, atom_end, SEEK_SET);
return 0;
| [
"static int FUNC_0(Jpeg2000DecoderContext *VAR_0)\n{",
"uint32_t atom_size, atom, atom_end;",
"int VAR_1 = 10;",
"while (VAR_1\n&&\nbytestream2_get_bytes_left(&VAR_0->g) >= 8) {",
"atom_size = bytestream2_get_be32u(&VAR_0->g);",
"atom = bytestream2_get_be32u(&VAR_0->g);",
"atom_end = bytestream2_tell(&VAR_0->g) + atom_size - 8;",
"if (atom == JP2_CODESTREAM)\nreturn 1;",
"if (bytestream2_get_bytes_left(&VAR_0->g) < atom_size || atom_end < atom_size)\nreturn 0;",
"if (atom == JP2_HEADER &&\natom_size >= 16) {",
"uint32_t atom2_size, atom2, atom2_end;",
"do {",
"atom2_size = bytestream2_get_be32u(&VAR_0->g);",
"atom2 = bytestream2_get_be32u(&VAR_0->g);",
"atom2_end = bytestream2_tell(&VAR_0->g) + atom2_size - 8;",
"if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)\nbreak;",
"atom2_size -= 8;",
"if (atom2 == JP2_CODESTREAM) {",
"return 1;",
"} else if (atom2 == MKBETAG('c','o','l','r') && atom2_size >= 7) {",
"int method = bytestream2_get_byteu(&VAR_0->g);",
"bytestream2_skipu(&VAR_0->g, 2);",
"if (method == 1) {",
"VAR_0->colour_space = bytestream2_get_be32u(&VAR_0->g);",
"} else if (atom2 == MKBETAG('p','c','l','r') && atom2_size >= 6) {",
"int i, size, colour_count, colour_channels, colour_depth[3];",
"uint32_t r, g, b;",
"colour_count = bytestream2_get_be16u(&VAR_0->g);",
"colour_channels = bytestream2_get_byteu(&VAR_0->g);",
"colour_depth[0] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;",
"colour_depth[1] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;",
"colour_depth[2] = (bytestream2_get_byteu(&VAR_0->g) & 0x7f) + 1;",
"size = (colour_depth[0] + 7 >> 3) * colour_count +\n(colour_depth[1] + 7 >> 3) * colour_count +\n(colour_depth[2] + 7 >> 3) * colour_count;",
"if (colour_count > 256 ||\ncolour_channels != 3 ||\ncolour_depth[0] > 16 ||\ncolour_depth[1] > 16 ||\ncolour_depth[2] > 16 ||\natom2_size < size) {",
"avpriv_request_sample(VAR_0->avctx, \"Unknown palette\");",
"VAR_0->pal8 = 1;",
"for (i = 0; i < colour_count; i++) {",
"if (colour_depth[0] <= 8) {",
"r = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[0];",
"r |= r >> colour_depth[0];",
"} else {",
"r = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[0] - 8;",
"if (colour_depth[1] <= 8) {",
"g = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[1];",
"r |= r >> colour_depth[1];",
"} else {",
"g = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[1] - 8;",
"if (colour_depth[2] <= 8) {",
"b = bytestream2_get_byteu(&VAR_0->g) << 8 - colour_depth[2];",
"r |= r >> colour_depth[2];",
"} else {",
"b = bytestream2_get_be16u(&VAR_0->g) >> colour_depth[2] - 8;",
"VAR_0->palette[i] = 0xffu << 24 | r << 16 | g << 8 | b;",
"} else if (atom2 == MKBETAG('c','d','e','f') && atom2_size >= 2) {",
"int n = bytestream2_get_be16u(&VAR_0->g);",
"for (; n>0; n--) {",
"int cn = bytestream2_get_be16(&VAR_0->g);",
"int av_unused typ = bytestream2_get_be16(&VAR_0->g);",
"int asoc = bytestream2_get_be16(&VAR_0->g);",
"if (cn < 4 && asoc < 4)\nVAR_0->cdef[cn] = asoc;",
"} else if (atom2 == MKBETAG('r','e','VAR_0',' ') && atom2_size >= 18) {",
"int64_t vnum, vden, hnum, hden, vexp, hexp;",
"uint32_t resx;",
"bytestream2_skip(&VAR_0->g, 4);",
"resx = bytestream2_get_be32u(&VAR_0->g);",
"if (resx != MKBETAG('r','e','VAR_0','c') && resx != MKBETAG('r','e','VAR_0','d')) {",
"vnum = bytestream2_get_be16u(&VAR_0->g);",
"vden = bytestream2_get_be16u(&VAR_0->g);",
"hnum = bytestream2_get_be16u(&VAR_0->g);",
"hden = bytestream2_get_be16u(&VAR_0->g);",
"vexp = bytestream2_get_byteu(&VAR_0->g);",
"hexp = bytestream2_get_byteu(&VAR_0->g);",
"if (vexp > hexp) {",
"vexp -= hexp;",
"hexp = 0;",
"} else {",
"hexp -= vexp;",
"vexp = 0;",
"if ( INT64_MAX / (hnum * vden) > pow(10, hexp)\n&& INT64_MAX / (vnum * hden) > pow(10, vexp))\nav_reduce(&VAR_0->sar.den, &VAR_0->sar.num,\nhnum * vden * pow(10, hexp),\nvnum * hden * pow(10, vexp),\nINT32_MAX);",
"} while (atom_end - atom2_end >= 8);",
"} else {",
"VAR_1--;",
"bytestream2_seek(&VAR_0->g, atom_end, SEEK_SET);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
31,
33
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
72
],
[
74
],
[
76
],
[
78
],
[
80
],
[
84
],
[
86
],
[
88
],
[
90,
92,
94
],
[
96,
98,
100,
102,
104,
106
],
[
108
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
128
],
[
130
],
[
132
],
[
134
],
[
136
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
150
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
170
],
[
172
],
[
174
],
[
176
],
[
178
],
[
180
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
202
],
[
204
],
[
206
],
[
208
],
[
210
],
[
212
],
[
215,
217,
219,
221,
223,
225
],
[
229
],
[
231
],
[
233
],
[
236
],
[
241
]
] |
4,884 | static void i440fx_realize(PCIDevice *dev, Error **errp)
{
dev->config[I440FX_SMRAM] = 0x02;
if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
error_report("warning: i440fx doesn't support emulated iommu");
}
}
| false | qemu | 3dc6f8693694a649a9c83f1e2746565b47683923 | static void i440fx_realize(PCIDevice *dev, Error **errp)
{
dev->config[I440FX_SMRAM] = 0x02;
if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
error_report("warning: i440fx doesn't support emulated iommu");
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)
{
VAR_0->config[I440FX_SMRAM] = 0x02;
if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
error_report("warning: i440fx doesn't support emulated iommu");
}
}
| [
"static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{",
"VAR_0->config[I440FX_SMRAM] = 0x02;",
"if (object_property_get_bool(qdev_get_machine(), \"iommu\", NULL)) {",
"error_report(\"warning: i440fx doesn't support emulated iommu\");",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
4,885 | static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
{
return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
}
| false | FFmpeg | 7e7e59409294af9caa63808e56c5cc824c98b4fc | static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
{
return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
}
| {
"code": [],
"line_no": []
} | static inline unsigned char FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint8_t VAR_2)
{
return ((((VAR_0)/47)%6)*6*6+(((VAR_1)/47)%6)*6+(((VAR_2)/47)%6));
}
| [
"static inline unsigned char FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint8_t VAR_2)\n{",
"return ((((VAR_0)/47)%6)*6*6+(((VAR_1)/47)%6)*6+(((VAR_2)/47)%6));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
4,887 | static void coroutine_fn bdrv_co_do_rw(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
if (!acb->is_write) {
acb->req.error = bdrv_co_do_readv(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
} else {
acb->req.error = bdrv_co_do_writev(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
}
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| false | qemu | 0b5a24454fc551f0294fe93821e8c643214a55f5 | static void coroutine_fn bdrv_co_do_rw(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
if (!acb->is_write) {
acb->req.error = bdrv_co_do_readv(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
} else {
acb->req.error = bdrv_co_do_writev(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
}
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 bdrv_co_do_rw(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
if (!acb->is_write) {
acb->req.error = bdrv_co_do_readv(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
} else {
acb->req.error = bdrv_co_do_writev(bs, acb->req.sector,
acb->req.nb_sectors, acb->req.qiov, acb->req.flags);
}
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| [
"static void VAR_0 bdrv_co_do_rw(void *opaque)\n{",
"BlockAIOCBCoroutine *acb = opaque;",
"BlockDriverState *bs = acb->common.bs;",
"if (!acb->is_write) {",
"acb->req.error = bdrv_co_do_readv(bs, acb->req.sector,\nacb->req.nb_sectors, acb->req.qiov, acb->req.flags);",
"} else {",
"acb->req.error = bdrv_co_do_writev(bs, acb->req.sector,\nacb->req.nb_sectors, acb->req.qiov, acb->req.flags);",
"}",
"acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);",
"qemu_bh_schedule(acb->bh);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
4,888 | static int xen_add_to_physmap(XenIOState *state,
hwaddr start_addr,
ram_addr_t size,
MemoryRegion *mr,
hwaddr offset_within_region)
{
unsigned long i = 0;
int rc = 0;
XenPhysmap *physmap = NULL;
hwaddr pfn, start_gpfn;
hwaddr phys_offset = memory_region_get_ram_addr(mr);
char path[80], value[17];
const char *mr_name;
if (get_physmapping(state, start_addr, size)) {
return 0;
}
if (size <= 0) {
return -1;
}
/* Xen can only handle a single dirty log region for now and we want
* the linear framebuffer to be that region.
* Avoid tracking any regions that is not videoram and avoid tracking
* the legacy vga region. */
if (mr == framebuffer && start_addr > 0xbffff) {
goto go_physmap;
}
return -1;
go_physmap:
DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n",
start_addr, start_addr + size);
pfn = phys_offset >> TARGET_PAGE_BITS;
start_gpfn = start_addr >> TARGET_PAGE_BITS;
for (i = 0; i < size >> TARGET_PAGE_BITS; i++) {
unsigned long idx = pfn + i;
xen_pfn_t gpfn = start_gpfn + i;
rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
if (rc) {
DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
return -rc;
}
}
mr_name = memory_region_name(mr);
physmap = g_malloc(sizeof (XenPhysmap));
physmap->start_addr = start_addr;
physmap->size = size;
physmap->name = mr_name;
physmap->phys_offset = phys_offset;
QLIST_INSERT_HEAD(&state->physmap, physmap, list);
xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,
start_addr >> TARGET_PAGE_BITS,
(start_addr + size - 1) >> TARGET_PAGE_BITS,
XEN_DOMCTL_MEM_CACHEATTR_WB);
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr",
xen_domid, (uint64_t)phys_offset);
snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)start_addr);
if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
return -1;
}
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/size",
xen_domid, (uint64_t)phys_offset);
snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)size);
if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
return -1;
}
if (mr_name) {
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/name",
xen_domid, (uint64_t)phys_offset);
if (!xs_write(state->xenstore, 0, path, mr_name, strlen(mr_name))) {
return -1;
}
}
return 0;
}
| false | qemu | 20a544c7dc2428e8816ed4a87af732884e885f2d | static int xen_add_to_physmap(XenIOState *state,
hwaddr start_addr,
ram_addr_t size,
MemoryRegion *mr,
hwaddr offset_within_region)
{
unsigned long i = 0;
int rc = 0;
XenPhysmap *physmap = NULL;
hwaddr pfn, start_gpfn;
hwaddr phys_offset = memory_region_get_ram_addr(mr);
char path[80], value[17];
const char *mr_name;
if (get_physmapping(state, start_addr, size)) {
return 0;
}
if (size <= 0) {
return -1;
}
if (mr == framebuffer && start_addr > 0xbffff) {
goto go_physmap;
}
return -1;
go_physmap:
DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n",
start_addr, start_addr + size);
pfn = phys_offset >> TARGET_PAGE_BITS;
start_gpfn = start_addr >> TARGET_PAGE_BITS;
for (i = 0; i < size >> TARGET_PAGE_BITS; i++) {
unsigned long idx = pfn + i;
xen_pfn_t gpfn = start_gpfn + i;
rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
if (rc) {
DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
return -rc;
}
}
mr_name = memory_region_name(mr);
physmap = g_malloc(sizeof (XenPhysmap));
physmap->start_addr = start_addr;
physmap->size = size;
physmap->name = mr_name;
physmap->phys_offset = phys_offset;
QLIST_INSERT_HEAD(&state->physmap, physmap, list);
xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,
start_addr >> TARGET_PAGE_BITS,
(start_addr + size - 1) >> TARGET_PAGE_BITS,
XEN_DOMCTL_MEM_CACHEATTR_WB);
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr",
xen_domid, (uint64_t)phys_offset);
snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)start_addr);
if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
return -1;
}
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/size",
xen_domid, (uint64_t)phys_offset);
snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)size);
if (!xs_write(state->xenstore, 0, path, value, strlen(value))) {
return -1;
}
if (mr_name) {
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/name",
xen_domid, (uint64_t)phys_offset);
if (!xs_write(state->xenstore, 0, path, mr_name, strlen(mr_name))) {
return -1;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(XenIOState *VAR_0,
hwaddr VAR_1,
ram_addr_t VAR_2,
MemoryRegion *VAR_3,
hwaddr VAR_4)
{
unsigned long VAR_5 = 0;
int VAR_6 = 0;
XenPhysmap *physmap = NULL;
hwaddr pfn, start_gpfn;
hwaddr phys_offset = memory_region_get_ram_addr(VAR_3);
char VAR_7[80], VAR_8[17];
const char *VAR_9;
if (get_physmapping(VAR_0, VAR_1, VAR_2)) {
return 0;
}
if (VAR_2 <= 0) {
return -1;
}
if (VAR_3 == framebuffer && VAR_1 > 0xbffff) {
goto go_physmap;
}
return -1;
go_physmap:
DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n",
VAR_1, VAR_1 + VAR_2);
pfn = phys_offset >> TARGET_PAGE_BITS;
start_gpfn = VAR_1 >> TARGET_PAGE_BITS;
for (VAR_5 = 0; VAR_5 < VAR_2 >> TARGET_PAGE_BITS; VAR_5++) {
unsigned long idx = pfn + VAR_5;
xen_pfn_t gpfn = start_gpfn + VAR_5;
VAR_6 = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
if (VAR_6) {
DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, VAR_6, errno);
return -VAR_6;
}
}
VAR_9 = memory_region_name(VAR_3);
physmap = g_malloc(sizeof (XenPhysmap));
physmap->VAR_1 = VAR_1;
physmap->VAR_2 = VAR_2;
physmap->name = VAR_9;
physmap->phys_offset = phys_offset;
QLIST_INSERT_HEAD(&VAR_0->physmap, physmap, list);
xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,
VAR_1 >> TARGET_PAGE_BITS,
(VAR_1 + VAR_2 - 1) >> TARGET_PAGE_BITS,
XEN_DOMCTL_MEM_CACHEATTR_WB);
snprintf(VAR_7, sizeof(VAR_7),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/VAR_1",
xen_domid, (uint64_t)phys_offset);
snprintf(VAR_8, sizeof(VAR_8), "%"PRIx64, (uint64_t)VAR_1);
if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_8, strlen(VAR_8))) {
return -1;
}
snprintf(VAR_7, sizeof(VAR_7),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/VAR_2",
xen_domid, (uint64_t)phys_offset);
snprintf(VAR_8, sizeof(VAR_8), "%"PRIx64, (uint64_t)VAR_2);
if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_8, strlen(VAR_8))) {
return -1;
}
if (VAR_9) {
snprintf(VAR_7, sizeof(VAR_7),
"/local/domain/0/device-model/%d/physmap/%"PRIx64"/name",
xen_domid, (uint64_t)phys_offset);
if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_9, strlen(VAR_9))) {
return -1;
}
}
return 0;
}
| [
"static int FUNC_0(XenIOState *VAR_0,\nhwaddr VAR_1,\nram_addr_t VAR_2,\nMemoryRegion *VAR_3,\nhwaddr VAR_4)\n{",
"unsigned long VAR_5 = 0;",
"int VAR_6 = 0;",
"XenPhysmap *physmap = NULL;",
"hwaddr pfn, start_gpfn;",
"hwaddr phys_offset = memory_region_get_ram_addr(VAR_3);",
"char VAR_7[80], VAR_8[17];",
"const char *VAR_9;",
"if (get_physmapping(VAR_0, VAR_1, VAR_2)) {",
"return 0;",
"}",
"if (VAR_2 <= 0) {",
"return -1;",
"}",
"if (VAR_3 == framebuffer && VAR_1 > 0xbffff) {",
"goto go_physmap;",
"}",
"return -1;",
"go_physmap:\nDPRINTF(\"mapping vram to %\"HWADDR_PRIx\" - %\"HWADDR_PRIx\"\\n\",\nVAR_1, VAR_1 + VAR_2);",
"pfn = phys_offset >> TARGET_PAGE_BITS;",
"start_gpfn = VAR_1 >> TARGET_PAGE_BITS;",
"for (VAR_5 = 0; VAR_5 < VAR_2 >> TARGET_PAGE_BITS; VAR_5++) {",
"unsigned long idx = pfn + VAR_5;",
"xen_pfn_t gpfn = start_gpfn + VAR_5;",
"VAR_6 = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);",
"if (VAR_6) {",
"DPRINTF(\"add_to_physmap MFN %\"PRI_xen_pfn\" to PFN %\"\nPRI_xen_pfn\" failed: %d (errno: %d)\\n\", idx, gpfn, VAR_6, errno);",
"return -VAR_6;",
"}",
"}",
"VAR_9 = memory_region_name(VAR_3);",
"physmap = g_malloc(sizeof (XenPhysmap));",
"physmap->VAR_1 = VAR_1;",
"physmap->VAR_2 = VAR_2;",
"physmap->name = VAR_9;",
"physmap->phys_offset = phys_offset;",
"QLIST_INSERT_HEAD(&VAR_0->physmap, physmap, list);",
"xc_domain_pin_memory_cacheattr(xen_xc, xen_domid,\nVAR_1 >> TARGET_PAGE_BITS,\n(VAR_1 + VAR_2 - 1) >> TARGET_PAGE_BITS,\nXEN_DOMCTL_MEM_CACHEATTR_WB);",
"snprintf(VAR_7, sizeof(VAR_7),\n\"/local/domain/0/device-model/%d/physmap/%\"PRIx64\"/VAR_1\",\nxen_domid, (uint64_t)phys_offset);",
"snprintf(VAR_8, sizeof(VAR_8), \"%\"PRIx64, (uint64_t)VAR_1);",
"if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_8, strlen(VAR_8))) {",
"return -1;",
"}",
"snprintf(VAR_7, sizeof(VAR_7),\n\"/local/domain/0/device-model/%d/physmap/%\"PRIx64\"/VAR_2\",\nxen_domid, (uint64_t)phys_offset);",
"snprintf(VAR_8, sizeof(VAR_8), \"%\"PRIx64, (uint64_t)VAR_2);",
"if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_8, strlen(VAR_8))) {",
"return -1;",
"}",
"if (VAR_9) {",
"snprintf(VAR_7, sizeof(VAR_7),\n\"/local/domain/0/device-model/%d/physmap/%\"PRIx64\"/name\",\nxen_domid, (uint64_t)phys_offset);",
"if (!xs_write(VAR_0->xenstore, 0, VAR_7, VAR_9, strlen(VAR_9))) {",
"return -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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119,
121,
123,
125
],
[
129,
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143,
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
]
] |
4,889 | static int fmod_init_in (HWVoiceIn *hw, audsettings_t *as)
{
int bits16, mode;
FMODVoiceIn *fmd = (FMODVoiceIn *) hw;
audsettings_t obt_as = *as;
if (conf.broken_adc) {
return -1;
}
mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);
fmd->fmod_sample = FSOUND_Sample_Alloc (
FSOUND_FREE, /* index */
conf.nb_samples, /* length */
mode, /* mode */
as->freq, /* freq */
255, /* volume */
128, /* pan */
255 /* priority */
);
if (!fmd->fmod_sample) {
fmod_logerr2 ("ADC", "Failed to allocate FMOD sample\n");
return -1;
}
/* FMOD always operates on little endian frames? */
obt_as.endianness = 0;
audio_pcm_init_info (&hw->info, &obt_as);
bits16 = (mode & FSOUND_16BITS) != 0;
hw->samples = conf.nb_samples;
return 0;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static int fmod_init_in (HWVoiceIn *hw, audsettings_t *as)
{
int bits16, mode;
FMODVoiceIn *fmd = (FMODVoiceIn *) hw;
audsettings_t obt_as = *as;
if (conf.broken_adc) {
return -1;
}
mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);
fmd->fmod_sample = FSOUND_Sample_Alloc (
FSOUND_FREE,
conf.nb_samples,
mode,
as->freq,
255,
128,
255
);
if (!fmd->fmod_sample) {
fmod_logerr2 ("ADC", "Failed to allocate FMOD sample\n");
return -1;
}
obt_as.endianness = 0;
audio_pcm_init_info (&hw->info, &obt_as);
bits16 = (mode & FSOUND_16BITS) != 0;
hw->samples = conf.nb_samples;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)
{
int VAR_2, VAR_3;
FMODVoiceIn *fmd = (FMODVoiceIn *) VAR_0;
audsettings_t obt_as = *VAR_1;
if (conf.broken_adc) {
return -1;
}
VAR_3 = aud_to_fmodfmt (VAR_1->fmt, VAR_1->nchannels == 2 ? 1 : 0);
fmd->fmod_sample = FSOUND_Sample_Alloc (
FSOUND_FREE,
conf.nb_samples,
VAR_3,
VAR_1->freq,
255,
128,
255
);
if (!fmd->fmod_sample) {
fmod_logerr2 ("ADC", "Failed to allocate FMOD sample\n");
return -1;
}
obt_as.endianness = 0;
audio_pcm_init_info (&VAR_0->info, &obt_as);
VAR_2 = (VAR_3 & FSOUND_16BITS) != 0;
VAR_0->samples = conf.nb_samples;
return 0;
}
| [
"static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)\n{",
"int VAR_2, VAR_3;",
"FMODVoiceIn *fmd = (FMODVoiceIn *) VAR_0;",
"audsettings_t obt_as = *VAR_1;",
"if (conf.broken_adc) {",
"return -1;",
"}",
"VAR_3 = aud_to_fmodfmt (VAR_1->fmt, VAR_1->nchannels == 2 ? 1 : 0);",
"fmd->fmod_sample = FSOUND_Sample_Alloc (\nFSOUND_FREE,\nconf.nb_samples,\nVAR_3,\nVAR_1->freq,\n255,\n128,\n255\n);",
"if (!fmd->fmod_sample) {",
"fmod_logerr2 (\"ADC\", \"Failed to allocate FMOD sample\\n\");",
"return -1;",
"}",
"obt_as.endianness = 0;",
"audio_pcm_init_info (&VAR_0->info, &obt_as);",
"VAR_2 = (VAR_3 & FSOUND_16BITS) != 0;",
"VAR_0->samples = conf.nb_samples;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
4,890 | static void monitor_control_event(void *opaque, int event)
{
if (event == CHR_EVENT_OPENED) {
QObject *data;
Monitor *mon = opaque;
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
data = qobject_from_jsonf("{ 'QMP': { 'capabilities': [] } }");
assert(data != NULL);
monitor_json_emitter(mon, data);
qobject_decref(data);
}
}
| false | qemu | ca9567e23454ca94e3911710da4e953ad049b40f | static void monitor_control_event(void *opaque, int event)
{
if (event == CHR_EVENT_OPENED) {
QObject *data;
Monitor *mon = opaque;
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
data = qobject_from_jsonf("{ 'QMP': { 'capabilities': [] } }");
assert(data != NULL);
monitor_json_emitter(mon, data);
qobject_decref(data);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
if (VAR_1 == CHR_EVENT_OPENED) {
QObject *data;
Monitor *mon = VAR_0;
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
data = qobject_from_jsonf("{ 'QMP': { 'capabilities': [] } }");
assert(data != NULL);
monitor_json_emitter(mon, data);
qobject_decref(data);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"if (VAR_1 == CHR_EVENT_OPENED) {",
"QObject *data;",
"Monitor *mon = VAR_0;",
"json_message_parser_init(&mon->mc->parser, handle_qmp_command);",
"data = qobject_from_jsonf(\"{ 'QMP': { 'capabilities': [] } }\");",
"assert(data != NULL);",
"monitor_json_emitter(mon, data);",
"qobject_decref(data);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
4,894 | static void pmac_ide_transfer_cb(void *opaque, int ret)
{
DBDMA_io *io = opaque;
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);
int n = 0;
int64_t sector_num;
int unaligned;
if (ret < 0) {
MACIO_DPRINTF("DMA error\n");
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
ide_dma_error(s);
io->remainder_len = 0;
goto done;
}
if (!m->dma_active) {
MACIO_DPRINTF("waiting for data (%#x - %#x - %x)\n",
s->nsector, io->len, s->status);
/* data not ready yet, wait for the channel to get restarted */
io->processing = false;
return;
}
sector_num = ide_get_sector(s);
MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size);
if (s->io_buffer_size > 0) {
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
n = (s->io_buffer_size + 0x1ff) >> 9;
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
}
MACIO_DPRINTF("remainder: %d io->len: %d nsector: %d "
"sector_num: %" PRId64 "\n",
io->remainder_len, io->len, s->nsector, sector_num);
if (io->remainder_len && io->len) {
/* guest wants the rest of its previous transfer */
int remainder_len = MIN(io->remainder_len, io->len);
uint8_t *p = &io->remainder[0x200 - remainder_len];
MACIO_DPRINTF("copying remainder %d bytes at %#" HWADDR_PRIx "\n",
remainder_len, io->addr);
switch (s->dma_cmd) {
case IDE_DMA_READ:
cpu_physical_memory_write(io->addr, p, remainder_len);
break;
case IDE_DMA_WRITE:
cpu_physical_memory_read(io->addr, p, remainder_len);
bdrv_write(s->bs, sector_num - 1, io->remainder, 1);
break;
case IDE_DMA_TRIM:
break;
}
io->addr += remainder_len;
io->len -= remainder_len;
io->remainder_len -= remainder_len;
}
if (s->nsector == 0 && !io->remainder_len) {
MACIO_DPRINTF("end of transfer\n");
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
m->dma_active = false;
}
if (io->len == 0) {
MACIO_DPRINTF("end of DMA\n");
goto done;
}
/* launch next transfer */
s->io_buffer_index = 0;
s->io_buffer_size = MIN(io->len, s->nsector * 512);
/* handle unaligned accesses first, get them over with and only do the
remaining bulk transfer using our async DMA helpers */
unaligned = io->len & 0x1ff;
if (unaligned) {
int nsector = io->len >> 9;
MACIO_DPRINTF("precopying unaligned %d bytes to %#" HWADDR_PRIx "\n",
unaligned, io->addr + io->len - unaligned);
switch (s->dma_cmd) {
case IDE_DMA_READ:
bdrv_read(s->bs, sector_num + nsector, io->remainder, 1);
cpu_physical_memory_write(io->addr + io->len - unaligned,
io->remainder, unaligned);
break;
case IDE_DMA_WRITE:
/* cache the contents in our io struct */
cpu_physical_memory_read(io->addr + io->len - unaligned,
io->remainder, unaligned);
break;
case IDE_DMA_TRIM:
break;
}
io->len -= unaligned;
}
MACIO_DPRINTF("io->len = %#x\n", io->len);
qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,
&address_space_memory);
qemu_sglist_add(&s->sg, io->addr, io->len);
io->addr += io->len + unaligned;
io->remainder_len = (0x200 - unaligned) & 0x1ff;
MACIO_DPRINTF("set remainder to: %d\n", io->remainder_len);
/* We would read no data from the block layer, thus not get a callback.
Just fake completion manually. */
if (!io->len) {
pmac_ide_transfer_cb(opaque, 0);
return;
}
io->len = 0;
MACIO_DPRINTF("sector_num=%" PRId64 " n=%d, nsector=%d, cmd_cmd=%d\n",
sector_num, n, s->nsector, s->dma_cmd);
switch (s->dma_cmd) {
case IDE_DMA_READ:
m->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
pmac_ide_transfer_cb, io);
break;
case IDE_DMA_WRITE:
m->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
pmac_ide_transfer_cb, io);
break;
case IDE_DMA_TRIM:
m->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
ide_issue_trim, pmac_ide_transfer_cb, io,
DMA_DIRECTION_TO_DEVICE);
break;
}
return;
done:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
bdrv_acct_done(s->bs, &s->acct);
}
io->dma_end(io);
}
| false | qemu | 3e300fa6ad4ee19b16339c25773dec8df0bfb982 | static void pmac_ide_transfer_cb(void *opaque, int ret)
{
DBDMA_io *io = opaque;
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);
int n = 0;
int64_t sector_num;
int unaligned;
if (ret < 0) {
MACIO_DPRINTF("DMA error\n");
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
ide_dma_error(s);
io->remainder_len = 0;
goto done;
}
if (!m->dma_active) {
MACIO_DPRINTF("waiting for data (%#x - %#x - %x)\n",
s->nsector, io->len, s->status);
io->processing = false;
return;
}
sector_num = ide_get_sector(s);
MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size);
if (s->io_buffer_size > 0) {
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
n = (s->io_buffer_size + 0x1ff) >> 9;
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
}
MACIO_DPRINTF("remainder: %d io->len: %d nsector: %d "
"sector_num: %" PRId64 "\n",
io->remainder_len, io->len, s->nsector, sector_num);
if (io->remainder_len && io->len) {
int remainder_len = MIN(io->remainder_len, io->len);
uint8_t *p = &io->remainder[0x200 - remainder_len];
MACIO_DPRINTF("copying remainder %d bytes at %#" HWADDR_PRIx "\n",
remainder_len, io->addr);
switch (s->dma_cmd) {
case IDE_DMA_READ:
cpu_physical_memory_write(io->addr, p, remainder_len);
break;
case IDE_DMA_WRITE:
cpu_physical_memory_read(io->addr, p, remainder_len);
bdrv_write(s->bs, sector_num - 1, io->remainder, 1);
break;
case IDE_DMA_TRIM:
break;
}
io->addr += remainder_len;
io->len -= remainder_len;
io->remainder_len -= remainder_len;
}
if (s->nsector == 0 && !io->remainder_len) {
MACIO_DPRINTF("end of transfer\n");
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
m->dma_active = false;
}
if (io->len == 0) {
MACIO_DPRINTF("end of DMA\n");
goto done;
}
s->io_buffer_index = 0;
s->io_buffer_size = MIN(io->len, s->nsector * 512);
unaligned = io->len & 0x1ff;
if (unaligned) {
int nsector = io->len >> 9;
MACIO_DPRINTF("precopying unaligned %d bytes to %#" HWADDR_PRIx "\n",
unaligned, io->addr + io->len - unaligned);
switch (s->dma_cmd) {
case IDE_DMA_READ:
bdrv_read(s->bs, sector_num + nsector, io->remainder, 1);
cpu_physical_memory_write(io->addr + io->len - unaligned,
io->remainder, unaligned);
break;
case IDE_DMA_WRITE:
cpu_physical_memory_read(io->addr + io->len - unaligned,
io->remainder, unaligned);
break;
case IDE_DMA_TRIM:
break;
}
io->len -= unaligned;
}
MACIO_DPRINTF("io->len = %#x\n", io->len);
qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,
&address_space_memory);
qemu_sglist_add(&s->sg, io->addr, io->len);
io->addr += io->len + unaligned;
io->remainder_len = (0x200 - unaligned) & 0x1ff;
MACIO_DPRINTF("set remainder to: %d\n", io->remainder_len);
if (!io->len) {
pmac_ide_transfer_cb(opaque, 0);
return;
}
io->len = 0;
MACIO_DPRINTF("sector_num=%" PRId64 " n=%d, nsector=%d, cmd_cmd=%d\n",
sector_num, n, s->nsector, s->dma_cmd);
switch (s->dma_cmd) {
case IDE_DMA_READ:
m->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
pmac_ide_transfer_cb, io);
break;
case IDE_DMA_WRITE:
m->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
pmac_ide_transfer_cb, io);
break;
case IDE_DMA_TRIM:
m->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
ide_issue_trim, pmac_ide_transfer_cb, io,
DMA_DIRECTION_TO_DEVICE);
break;
}
return;
done:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
bdrv_acct_done(s->bs, &s->acct);
}
io->dma_end(io);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
DBDMA_io *io = VAR_0;
MACIOIDEState *m = io->VAR_0;
IDEState *s = idebus_active_if(&m->bus);
int VAR_2 = 0;
int64_t sector_num;
int VAR_3;
if (VAR_1 < 0) {
MACIO_DPRINTF("DMA error\VAR_2");
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
ide_dma_error(s);
io->VAR_4 = 0;
goto done;
}
if (!m->dma_active) {
MACIO_DPRINTF("waiting for data (%#x - %#x - %x)\VAR_2",
s->VAR_5, io->len, s->status);
io->processing = false;
return;
}
sector_num = ide_get_sector(s);
MACIO_DPRINTF("io_buffer_size = %#x\VAR_2", s->io_buffer_size);
if (s->io_buffer_size > 0) {
m->aiocb = NULL;
qemu_sglist_destroy(&s->sg);
VAR_2 = (s->io_buffer_size + 0x1ff) >> 9;
sector_num += VAR_2;
ide_set_sector(s, sector_num);
s->VAR_5 -= VAR_2;
}
MACIO_DPRINTF("remainder: %d io->len: %d VAR_5: %d "
"sector_num: %" PRId64 "\VAR_2",
io->VAR_4, io->len, s->VAR_5, sector_num);
if (io->VAR_4 && io->len) {
int VAR_4 = MIN(io->VAR_4, io->len);
uint8_t *p = &io->remainder[0x200 - VAR_4];
MACIO_DPRINTF("copying remainder %d bytes at %#" HWADDR_PRIx "\VAR_2",
VAR_4, io->addr);
switch (s->dma_cmd) {
case IDE_DMA_READ:
cpu_physical_memory_write(io->addr, p, VAR_4);
break;
case IDE_DMA_WRITE:
cpu_physical_memory_read(io->addr, p, VAR_4);
bdrv_write(s->bs, sector_num - 1, io->remainder, 1);
break;
case IDE_DMA_TRIM:
break;
}
io->addr += VAR_4;
io->len -= VAR_4;
io->VAR_4 -= VAR_4;
}
if (s->VAR_5 == 0 && !io->VAR_4) {
MACIO_DPRINTF("end of transfer\VAR_2");
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
m->dma_active = false;
}
if (io->len == 0) {
MACIO_DPRINTF("end of DMA\VAR_2");
goto done;
}
s->io_buffer_index = 0;
s->io_buffer_size = MIN(io->len, s->VAR_5 * 512);
VAR_3 = io->len & 0x1ff;
if (VAR_3) {
int VAR_5 = io->len >> 9;
MACIO_DPRINTF("precopying VAR_3 %d bytes to %#" HWADDR_PRIx "\VAR_2",
VAR_3, io->addr + io->len - VAR_3);
switch (s->dma_cmd) {
case IDE_DMA_READ:
bdrv_read(s->bs, sector_num + VAR_5, io->remainder, 1);
cpu_physical_memory_write(io->addr + io->len - VAR_3,
io->remainder, VAR_3);
break;
case IDE_DMA_WRITE:
cpu_physical_memory_read(io->addr + io->len - VAR_3,
io->remainder, VAR_3);
break;
case IDE_DMA_TRIM:
break;
}
io->len -= VAR_3;
}
MACIO_DPRINTF("io->len = %#x\VAR_2", io->len);
qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,
&address_space_memory);
qemu_sglist_add(&s->sg, io->addr, io->len);
io->addr += io->len + VAR_3;
io->VAR_4 = (0x200 - VAR_3) & 0x1ff;
MACIO_DPRINTF("set remainder to: %d\VAR_2", io->VAR_4);
if (!io->len) {
FUNC_0(VAR_0, 0);
return;
}
io->len = 0;
MACIO_DPRINTF("sector_num=%" PRId64 " VAR_2=%d, VAR_5=%d, cmd_cmd=%d\VAR_2",
sector_num, VAR_2, s->VAR_5, s->dma_cmd);
switch (s->dma_cmd) {
case IDE_DMA_READ:
m->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
FUNC_0, io);
break;
case IDE_DMA_WRITE:
m->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
FUNC_0, io);
break;
case IDE_DMA_TRIM:
m->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
ide_issue_trim, FUNC_0, io,
DMA_DIRECTION_TO_DEVICE);
break;
}
return;
done:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
bdrv_acct_done(s->bs, &s->acct);
}
io->dma_end(io);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"DBDMA_io *io = VAR_0;",
"MACIOIDEState *m = io->VAR_0;",
"IDEState *s = idebus_active_if(&m->bus);",
"int VAR_2 = 0;",
"int64_t sector_num;",
"int VAR_3;",
"if (VAR_1 < 0) {",
"MACIO_DPRINTF(\"DMA error\\VAR_2\");",
"m->aiocb = NULL;",
"qemu_sglist_destroy(&s->sg);",
"ide_dma_error(s);",
"io->VAR_4 = 0;",
"goto done;",
"}",
"if (!m->dma_active) {",
"MACIO_DPRINTF(\"waiting for data (%#x - %#x - %x)\\VAR_2\",\ns->VAR_5, io->len, s->status);",
"io->processing = false;",
"return;",
"}",
"sector_num = ide_get_sector(s);",
"MACIO_DPRINTF(\"io_buffer_size = %#x\\VAR_2\", s->io_buffer_size);",
"if (s->io_buffer_size > 0) {",
"m->aiocb = NULL;",
"qemu_sglist_destroy(&s->sg);",
"VAR_2 = (s->io_buffer_size + 0x1ff) >> 9;",
"sector_num += VAR_2;",
"ide_set_sector(s, sector_num);",
"s->VAR_5 -= VAR_2;",
"}",
"MACIO_DPRINTF(\"remainder: %d io->len: %d VAR_5: %d \"\n\"sector_num: %\" PRId64 \"\\VAR_2\",\nio->VAR_4, io->len, s->VAR_5, sector_num);",
"if (io->VAR_4 && io->len) {",
"int VAR_4 = MIN(io->VAR_4, io->len);",
"uint8_t *p = &io->remainder[0x200 - VAR_4];",
"MACIO_DPRINTF(\"copying remainder %d bytes at %#\" HWADDR_PRIx \"\\VAR_2\",\nVAR_4, io->addr);",
"switch (s->dma_cmd) {",
"case IDE_DMA_READ:\ncpu_physical_memory_write(io->addr, p, VAR_4);",
"break;",
"case IDE_DMA_WRITE:\ncpu_physical_memory_read(io->addr, p, VAR_4);",
"bdrv_write(s->bs, sector_num - 1, io->remainder, 1);",
"break;",
"case IDE_DMA_TRIM:\nbreak;",
"}",
"io->addr += VAR_4;",
"io->len -= VAR_4;",
"io->VAR_4 -= VAR_4;",
"}",
"if (s->VAR_5 == 0 && !io->VAR_4) {",
"MACIO_DPRINTF(\"end of transfer\\VAR_2\");",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->bus);",
"m->dma_active = false;",
"}",
"if (io->len == 0) {",
"MACIO_DPRINTF(\"end of DMA\\VAR_2\");",
"goto done;",
"}",
"s->io_buffer_index = 0;",
"s->io_buffer_size = MIN(io->len, s->VAR_5 * 512);",
"VAR_3 = io->len & 0x1ff;",
"if (VAR_3) {",
"int VAR_5 = io->len >> 9;",
"MACIO_DPRINTF(\"precopying VAR_3 %d bytes to %#\" HWADDR_PRIx \"\\VAR_2\",\nVAR_3, io->addr + io->len - VAR_3);",
"switch (s->dma_cmd) {",
"case IDE_DMA_READ:\nbdrv_read(s->bs, sector_num + VAR_5, io->remainder, 1);",
"cpu_physical_memory_write(io->addr + io->len - VAR_3,\nio->remainder, VAR_3);",
"break;",
"case IDE_DMA_WRITE:\ncpu_physical_memory_read(io->addr + io->len - VAR_3,\nio->remainder, VAR_3);",
"break;",
"case IDE_DMA_TRIM:\nbreak;",
"}",
"io->len -= VAR_3;",
"}",
"MACIO_DPRINTF(\"io->len = %#x\\VAR_2\", io->len);",
"qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,\n&address_space_memory);",
"qemu_sglist_add(&s->sg, io->addr, io->len);",
"io->addr += io->len + VAR_3;",
"io->VAR_4 = (0x200 - VAR_3) & 0x1ff;",
"MACIO_DPRINTF(\"set remainder to: %d\\VAR_2\", io->VAR_4);",
"if (!io->len) {",
"FUNC_0(VAR_0, 0);",
"return;",
"}",
"io->len = 0;",
"MACIO_DPRINTF(\"sector_num=%\" PRId64 \" VAR_2=%d, VAR_5=%d, cmd_cmd=%d\\VAR_2\",\nsector_num, VAR_2, s->VAR_5, s->dma_cmd);",
"switch (s->dma_cmd) {",
"case IDE_DMA_READ:\nm->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,\nFUNC_0, io);",
"break;",
"case IDE_DMA_WRITE:\nm->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,\nFUNC_0, io);",
"break;",
"case IDE_DMA_TRIM:\nm->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,\nide_issue_trim, FUNC_0, io,\nDMA_DIRECTION_TO_DEVICE);",
"break;",
"}",
"return;",
"done:\nif (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {",
"bdrv_acct_done(s->bs, &s->acct);",
"}",
"io->dma_end(io);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77,
79
],
[
81
],
[
85
],
[
87
],
[
91,
93
],
[
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
157
],
[
159
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
181
],
[
183,
185
],
[
187,
189
],
[
191
],
[
193,
197,
199
],
[
201
],
[
203,
205
],
[
207
],
[
211
],
[
213
],
[
217
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
253,
255
],
[
259
],
[
261,
263,
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
277,
279,
281,
283
],
[
285
],
[
287
],
[
289
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
]
] |
4,895 | static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
BMDMAState *bm = opaque;
PCIIDEState *pci_dev = bm->pci_dev;
uint32_t val;
if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3) {
case 0:
val = bm->cmd;
break;
case 1:
val = pci_dev->dev.config[MRDMODE];
break;
case 2:
val = bm->status;
break;
case 3:
if (bm == &pci_dev->bmdma[0]) {
val = pci_dev->dev.config[UDIDETCR0];
} else {
val = pci_dev->dev.config[UDIDETCR1];
}
break;
default:
val = 0xff;
break;
}
#ifdef DEBUG_IDE
printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
#endif
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
BMDMAState *bm = opaque;
PCIIDEState *pci_dev = bm->pci_dev;
uint32_t val;
if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3) {
case 0:
val = bm->cmd;
break;
case 1:
val = pci_dev->dev.config[MRDMODE];
break;
case 2:
val = bm->status;
break;
case 3:
if (bm == &pci_dev->bmdma[0]) {
val = pci_dev->dev.config[UDIDETCR0];
} else {
val = pci_dev->dev.config[UDIDETCR1];
}
break;
default:
val = 0xff;
break;
}
#ifdef DEBUG_IDE
printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
#endif
return val;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
BMDMAState *bm = opaque;
PCIIDEState *pci_dev = bm->pci_dev;
uint32_t val;
if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3) {
case 0:
val = bm->cmd;
break;
case 1:
val = pci_dev->dev.config[MRDMODE];
break;
case 2:
val = bm->status;
break;
case 3:
if (bm == &pci_dev->bmdma[0]) {
val = pci_dev->dev.config[UDIDETCR0];
} else {
val = pci_dev->dev.config[UDIDETCR1];
}
break;
default:
val = 0xff;
break;
}
#ifdef DEBUG_IDE
printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
#endif
return val;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"BMDMAState *bm = opaque;",
"PCIIDEState *pci_dev = bm->pci_dev;",
"uint32_t val;",
"if (size != 1) {",
"return ((uint64_t)1 << (size * 8)) - 1;",
"}",
"switch(addr & 3) {",
"case 0:\nval = bm->cmd;",
"break;",
"case 1:\nval = pci_dev->dev.config[MRDMODE];",
"break;",
"case 2:\nval = bm->status;",
"break;",
"case 3:\nif (bm == &pci_dev->bmdma[0]) {",
"val = pci_dev->dev.config[UDIDETCR0];",
"} else {",
"val = pci_dev->dev.config[UDIDETCR1];",
"}",
"break;",
"default:\nval = 0xff;",
"break;",
"}",
"#ifdef DEBUG_IDE\nprintf(\"bmdma: readb 0x%02x : 0x%02x\\n\", addr, val);",
"#endif\nreturn val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
]
] |
4,897 | static void hash32_bat_size(CPUPPCState *env, target_ulong *blp, int *validp,
target_ulong batu, target_ulong batl)
{
target_ulong bl;
int valid;
bl = (batu & BATU32_BL) << 15;
valid = 0;
if (((msr_pr == 0) && (batu & BATU32_VS)) ||
((msr_pr != 0) && (batu & BATU32_VP))) {
valid = 1;
}
*blp = bl;
*validp = valid;
}
| false | qemu | 6fc76aa9adc1c8896a97059f12a1e5e6c1820c64 | static void hash32_bat_size(CPUPPCState *env, target_ulong *blp, int *validp,
target_ulong batu, target_ulong batl)
{
target_ulong bl;
int valid;
bl = (batu & BATU32_BL) << 15;
valid = 0;
if (((msr_pr == 0) && (batu & BATU32_VS)) ||
((msr_pr != 0) && (batu & BATU32_VP))) {
valid = 1;
}
*blp = bl;
*validp = valid;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUPPCState *VAR_0, target_ulong *VAR_1, int *VAR_2,
target_ulong VAR_3, target_ulong VAR_4)
{
target_ulong bl;
int VAR_5;
bl = (VAR_3 & BATU32_BL) << 15;
VAR_5 = 0;
if (((msr_pr == 0) && (VAR_3 & BATU32_VS)) ||
((msr_pr != 0) && (VAR_3 & BATU32_VP))) {
VAR_5 = 1;
}
*VAR_1 = bl;
*VAR_2 = VAR_5;
}
| [
"static void FUNC_0(CPUPPCState *VAR_0, target_ulong *VAR_1, int *VAR_2,\ntarget_ulong VAR_3, target_ulong VAR_4)\n{",
"target_ulong bl;",
"int VAR_5;",
"bl = (VAR_3 & BATU32_BL) << 15;",
"VAR_5 = 0;",
"if (((msr_pr == 0) && (VAR_3 & BATU32_VS)) ||\n((msr_pr != 0) && (VAR_3 & BATU32_VP))) {",
"VAR_5 = 1;",
"}",
"*VAR_1 = bl;",
"*VAR_2 = VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
4,898 | static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
abi_ulong parent_tidptr, target_ulong newtls,
abi_ulong child_tidptr)
{
CPUState *cpu = ENV_GET_CPU(env);
int ret;
TaskState *ts;
CPUState *new_cpu;
CPUArchState *new_env;
unsigned int nptl_flags;
sigset_t sigmask;
/* Emulate vfork() with fork() */
if (flags & CLONE_VFORK)
flags &= ~(CLONE_VFORK | CLONE_VM);
if (flags & CLONE_VM) {
TaskState *parent_ts = (TaskState *)cpu->opaque;
new_thread_info info;
pthread_attr_t attr;
ts = g_new0(TaskState, 1);
init_task_state(ts);
/* we create a new CPU instance. */
new_env = cpu_copy(env);
/* Init regs that differ from the parent. */
cpu_clone_regs(new_env, newsp);
new_cpu = ENV_GET_CPU(new_env);
new_cpu->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
ts->signal_mask = parent_ts->signal_mask;
nptl_flags = flags;
flags &= ~CLONE_NPTL_FLAGS2;
if (nptl_flags & CLONE_CHILD_CLEARTID) {
ts->child_tidptr = child_tidptr;
}
if (nptl_flags & CLONE_SETTLS)
cpu_set_tls (new_env, newtls);
/* Grab a mutex so that thread setup appears atomic. */
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.env = new_env;
if (nptl_flags & CLONE_CHILD_SETTID)
info.child_tidptr = child_tidptr;
if (nptl_flags & CLONE_PARENT_SETTID)
info.parent_tidptr = parent_tidptr;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE);
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* It is not safe to deliver signals until the child has finished
initializing, so temporarily block all signals. */
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
ret = pthread_create(&info.thread, &attr, clone_func, &info);
/* TODO: Free new CPU state if thread creation failed. */
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (ret == 0) {
/* Wait for the child to initialize. */
pthread_cond_wait(&info.cond, &info.mutex);
ret = info.tid;
if (flags & CLONE_PARENT_SETTID)
put_user_u32(ret, parent_tidptr);
} else {
ret = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
} else {
/* if no CLONE_VM, we consider it is a fork */
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) {
return -TARGET_EINVAL;
}
if (block_signals()) {
return -TARGET_ERESTARTSYS;
}
fork_start();
ret = fork();
if (ret == 0) {
/* Child Process. */
rcu_after_fork();
cpu_clone_regs(env, newsp);
fork_end(1);
/* There is a race condition here. The parent process could
theoretically read the TID in the child process before the child
tid is set. This would require using either ptrace
(not implemented) or having *_tidptr to point at a shared memory
mapping. We can't repeat the spinlock hack used above because
the child process gets its own copy of the lock. */
if (flags & CLONE_CHILD_SETTID)
put_user_u32(gettid(), child_tidptr);
if (flags & CLONE_PARENT_SETTID)
put_user_u32(gettid(), parent_tidptr);
ts = (TaskState *)cpu->opaque;
if (flags & CLONE_SETTLS)
cpu_set_tls (env, newtls);
if (flags & CLONE_CHILD_CLEARTID)
ts->child_tidptr = child_tidptr;
} else {
fork_end(0);
}
}
return ret;
}
| false | qemu | 7cfbd386b92e93fbfae033b9ac89a20d1fe72573 | static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
abi_ulong parent_tidptr, target_ulong newtls,
abi_ulong child_tidptr)
{
CPUState *cpu = ENV_GET_CPU(env);
int ret;
TaskState *ts;
CPUState *new_cpu;
CPUArchState *new_env;
unsigned int nptl_flags;
sigset_t sigmask;
if (flags & CLONE_VFORK)
flags &= ~(CLONE_VFORK | CLONE_VM);
if (flags & CLONE_VM) {
TaskState *parent_ts = (TaskState *)cpu->opaque;
new_thread_info info;
pthread_attr_t attr;
ts = g_new0(TaskState, 1);
init_task_state(ts);
new_env = cpu_copy(env);
cpu_clone_regs(new_env, newsp);
new_cpu = ENV_GET_CPU(new_env);
new_cpu->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
ts->signal_mask = parent_ts->signal_mask;
nptl_flags = flags;
flags &= ~CLONE_NPTL_FLAGS2;
if (nptl_flags & CLONE_CHILD_CLEARTID) {
ts->child_tidptr = child_tidptr;
}
if (nptl_flags & CLONE_SETTLS)
cpu_set_tls (new_env, newtls);
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.env = new_env;
if (nptl_flags & CLONE_CHILD_SETTID)
info.child_tidptr = child_tidptr;
if (nptl_flags & CLONE_PARENT_SETTID)
info.parent_tidptr = parent_tidptr;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE);
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
ret = pthread_create(&info.thread, &attr, clone_func, &info);
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (ret == 0) {
pthread_cond_wait(&info.cond, &info.mutex);
ret = info.tid;
if (flags & CLONE_PARENT_SETTID)
put_user_u32(ret, parent_tidptr);
} else {
ret = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
} else {
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) {
return -TARGET_EINVAL;
}
if (block_signals()) {
return -TARGET_ERESTARTSYS;
}
fork_start();
ret = fork();
if (ret == 0) {
rcu_after_fork();
cpu_clone_regs(env, newsp);
fork_end(1);
if (flags & CLONE_CHILD_SETTID)
put_user_u32(gettid(), child_tidptr);
if (flags & CLONE_PARENT_SETTID)
put_user_u32(gettid(), parent_tidptr);
ts = (TaskState *)cpu->opaque;
if (flags & CLONE_SETTLS)
cpu_set_tls (env, newtls);
if (flags & CLONE_CHILD_CLEARTID)
ts->child_tidptr = child_tidptr;
} else {
fork_end(0);
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUArchState *VAR_0, unsigned int VAR_1, abi_ulong VAR_2,
abi_ulong VAR_3, target_ulong VAR_4,
abi_ulong VAR_5)
{
CPUState *cpu = ENV_GET_CPU(VAR_0);
int VAR_6;
TaskState *ts;
CPUState *new_cpu;
CPUArchState *new_env;
unsigned int VAR_7;
sigset_t sigmask;
if (VAR_1 & CLONE_VFORK)
VAR_1 &= ~(CLONE_VFORK | CLONE_VM);
if (VAR_1 & CLONE_VM) {
TaskState *parent_ts = (TaskState *)cpu->opaque;
new_thread_info info;
pthread_attr_t attr;
ts = g_new0(TaskState, 1);
init_task_state(ts);
new_env = cpu_copy(VAR_0);
cpu_clone_regs(new_env, VAR_2);
new_cpu = ENV_GET_CPU(new_env);
new_cpu->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
ts->signal_mask = parent_ts->signal_mask;
VAR_7 = VAR_1;
VAR_1 &= ~CLONE_NPTL_FLAGS2;
if (VAR_7 & CLONE_CHILD_CLEARTID) {
ts->VAR_5 = VAR_5;
}
if (VAR_7 & CLONE_SETTLS)
cpu_set_tls (new_env, VAR_4);
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.VAR_0 = new_env;
if (VAR_7 & CLONE_CHILD_SETTID)
info.VAR_5 = VAR_5;
if (VAR_7 & CLONE_PARENT_SETTID)
info.VAR_3 = VAR_3;
VAR_6 = pthread_attr_init(&attr);
VAR_6 = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE);
VAR_6 = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
VAR_6 = pthread_create(&info.thread, &attr, clone_func, &info);
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (VAR_6 == 0) {
pthread_cond_wait(&info.cond, &info.mutex);
VAR_6 = info.tid;
if (VAR_1 & CLONE_PARENT_SETTID)
put_user_u32(VAR_6, VAR_3);
} else {
VAR_6 = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
} else {
if ((VAR_1 & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) {
return -TARGET_EINVAL;
}
if (block_signals()) {
return -TARGET_ERESTARTSYS;
}
fork_start();
VAR_6 = fork();
if (VAR_6 == 0) {
rcu_after_fork();
cpu_clone_regs(VAR_0, VAR_2);
fork_end(1);
if (VAR_1 & CLONE_CHILD_SETTID)
put_user_u32(gettid(), VAR_5);
if (VAR_1 & CLONE_PARENT_SETTID)
put_user_u32(gettid(), VAR_3);
ts = (TaskState *)cpu->opaque;
if (VAR_1 & CLONE_SETTLS)
cpu_set_tls (VAR_0, VAR_4);
if (VAR_1 & CLONE_CHILD_CLEARTID)
ts->VAR_5 = VAR_5;
} else {
fork_end(0);
}
}
return VAR_6;
}
| [
"static int FUNC_0(CPUArchState *VAR_0, unsigned int VAR_1, abi_ulong VAR_2,\nabi_ulong VAR_3, target_ulong VAR_4,\nabi_ulong VAR_5)\n{",
"CPUState *cpu = ENV_GET_CPU(VAR_0);",
"int VAR_6;",
"TaskState *ts;",
"CPUState *new_cpu;",
"CPUArchState *new_env;",
"unsigned int VAR_7;",
"sigset_t sigmask;",
"if (VAR_1 & CLONE_VFORK)\nVAR_1 &= ~(CLONE_VFORK | CLONE_VM);",
"if (VAR_1 & CLONE_VM) {",
"TaskState *parent_ts = (TaskState *)cpu->opaque;",
"new_thread_info info;",
"pthread_attr_t attr;",
"ts = g_new0(TaskState, 1);",
"init_task_state(ts);",
"new_env = cpu_copy(VAR_0);",
"cpu_clone_regs(new_env, VAR_2);",
"new_cpu = ENV_GET_CPU(new_env);",
"new_cpu->opaque = ts;",
"ts->bprm = parent_ts->bprm;",
"ts->info = parent_ts->info;",
"ts->signal_mask = parent_ts->signal_mask;",
"VAR_7 = VAR_1;",
"VAR_1 &= ~CLONE_NPTL_FLAGS2;",
"if (VAR_7 & CLONE_CHILD_CLEARTID) {",
"ts->VAR_5 = VAR_5;",
"}",
"if (VAR_7 & CLONE_SETTLS)\ncpu_set_tls (new_env, VAR_4);",
"pthread_mutex_lock(&clone_lock);",
"memset(&info, 0, sizeof(info));",
"pthread_mutex_init(&info.mutex, NULL);",
"pthread_mutex_lock(&info.mutex);",
"pthread_cond_init(&info.cond, NULL);",
"info.VAR_0 = new_env;",
"if (VAR_7 & CLONE_CHILD_SETTID)\ninfo.VAR_5 = VAR_5;",
"if (VAR_7 & CLONE_PARENT_SETTID)\ninfo.VAR_3 = VAR_3;",
"VAR_6 = pthread_attr_init(&attr);",
"VAR_6 = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE);",
"VAR_6 = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);",
"sigfillset(&sigmask);",
"sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);",
"VAR_6 = pthread_create(&info.thread, &attr, clone_func, &info);",
"sigprocmask(SIG_SETMASK, &info.sigmask, NULL);",
"pthread_attr_destroy(&attr);",
"if (VAR_6 == 0) {",
"pthread_cond_wait(&info.cond, &info.mutex);",
"VAR_6 = info.tid;",
"if (VAR_1 & CLONE_PARENT_SETTID)\nput_user_u32(VAR_6, VAR_3);",
"} else {",
"VAR_6 = -1;",
"}",
"pthread_mutex_unlock(&info.mutex);",
"pthread_cond_destroy(&info.cond);",
"pthread_mutex_destroy(&info.mutex);",
"pthread_mutex_unlock(&clone_lock);",
"} else {",
"if ((VAR_1 & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) {",
"return -TARGET_EINVAL;",
"}",
"if (block_signals()) {",
"return -TARGET_ERESTARTSYS;",
"}",
"fork_start();",
"VAR_6 = fork();",
"if (VAR_6 == 0) {",
"rcu_after_fork();",
"cpu_clone_regs(VAR_0, VAR_2);",
"fork_end(1);",
"if (VAR_1 & CLONE_CHILD_SETTID)\nput_user_u32(gettid(), VAR_5);",
"if (VAR_1 & CLONE_PARENT_SETTID)\nput_user_u32(gettid(), VAR_3);",
"ts = (TaskState *)cpu->opaque;",
"if (VAR_1 & CLONE_SETTLS)\ncpu_set_tls (VAR_0, VAR_4);",
"if (VAR_1 & CLONE_CHILD_CLEARTID)\nts->VAR_5 = VAR_5;",
"} else {",
"fork_end(0);",
"}",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105,
107
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
127
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
209,
211
],
[
213,
215
],
[
217
],
[
219,
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
]
] |
4,900 | static void test_hash_digest(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
size_t digestsize;
digestsize = qcrypto_hash_digest_len(i);
g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i]));
ret = qcrypto_hash_digest(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs[i]));
g_free(digest);
}
}
| false | qemu | 0c16c056a4f9dec18fdd56feec82a5db9ff3c15e | static void test_hash_digest(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
size_t digestsize;
digestsize = qcrypto_hash_digest_len(i);
g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i]));
ret = qcrypto_hash_digest(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs[i]));
g_free(digest);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
size_t digestsize;
digestsize = qcrypto_hash_digest_len(i);
g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i]));
ret = qcrypto_hash_digest(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs[i]));
g_free(digest);
}
}
| [
"static void FUNC_0(void)\n{",
"size_t i;",
"g_assert(qcrypto_init(NULL) == 0);",
"for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {",
"int ret;",
"char *digest;",
"size_t digestsize;",
"digestsize = qcrypto_hash_digest_len(i);",
"g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i]));",
"ret = qcrypto_hash_digest(i,\nINPUT_TEXT,\nstrlen(INPUT_TEXT),\n&digest,\nNULL);",
"g_assert(ret == 0);",
"g_assert(g_str_equal(digest, expected_outputs[i]));",
"g_free(digest);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
31,
33,
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
4,901 | static uint32_t pci_apb_ioreadw (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = bswap16(cpu_inw(addr & IOPORTS_MASK));
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t pci_apb_ioreadw (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = bswap16(cpu_inw(addr & IOPORTS_MASK));
return val;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = bswap16(cpu_inw(addr & IOPORTS_MASK));
return val;
}
| [
"static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)\n{",
"uint32_t val;",
"val = bswap16(cpu_inw(addr & IOPORTS_MASK));",
"return val;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
4,902 | static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level)
{
unsigned i;
PhysPageEntry *p = lp->u.node;
if (!p) {
return;
}
for (i = 0; i < L2_SIZE; ++i) {
if (level > 0) {
destroy_l2_mapping(&p[i], level - 1);
} else {
destroy_page_desc(p[i].u.leaf);
}
}
g_free(p);
lp->u.node = NULL;
}
| false | qemu | d6f2ea22a05b429ba83248b80a625b6fe1d927f3 | static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level)
{
unsigned i;
PhysPageEntry *p = lp->u.node;
if (!p) {
return;
}
for (i = 0; i < L2_SIZE; ++i) {
if (level > 0) {
destroy_l2_mapping(&p[i], level - 1);
} else {
destroy_page_desc(p[i].u.leaf);
}
}
g_free(p);
lp->u.node = NULL;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PhysPageEntry *VAR_0, unsigned VAR_1)
{
unsigned VAR_2;
PhysPageEntry *p = VAR_0->u.node;
if (!p) {
return;
}
for (VAR_2 = 0; VAR_2 < L2_SIZE; ++VAR_2) {
if (VAR_1 > 0) {
FUNC_0(&p[VAR_2], VAR_1 - 1);
} else {
destroy_page_desc(p[VAR_2].u.leaf);
}
}
g_free(p);
VAR_0->u.node = NULL;
}
| [
"static void FUNC_0(PhysPageEntry *VAR_0, unsigned VAR_1)\n{",
"unsigned VAR_2;",
"PhysPageEntry *p = VAR_0->u.node;",
"if (!p) {",
"return;",
"}",
"for (VAR_2 = 0; VAR_2 < L2_SIZE; ++VAR_2) {",
"if (VAR_1 > 0) {",
"FUNC_0(&p[VAR_2], VAR_1 - 1);",
"} else {",
"destroy_page_desc(p[VAR_2].u.leaf);",
"}",
"}",
"g_free(p);",
"VAR_0->u.node = NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
4,904 | static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)
{
memset(stbuf, 0, sizeof(*stbuf));
stbuf->st_dev = prstat->st_dev;
stbuf->st_ino = prstat->st_ino;
stbuf->st_nlink = prstat->st_nlink;
stbuf->st_mode = prstat->st_mode;
stbuf->st_uid = prstat->st_uid;
stbuf->st_gid = prstat->st_gid;
stbuf->st_rdev = prstat->st_rdev;
stbuf->st_size = prstat->st_size;
stbuf->st_blksize = prstat->st_blksize;
stbuf->st_blocks = prstat->st_blocks;
stbuf->st_atim.tv_sec = prstat->st_atim_sec;
stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;
stbuf->st_mtime = prstat->st_mtim_sec;
stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;
stbuf->st_ctime = prstat->st_ctim_sec;
stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)
{
memset(stbuf, 0, sizeof(*stbuf));
stbuf->st_dev = prstat->st_dev;
stbuf->st_ino = prstat->st_ino;
stbuf->st_nlink = prstat->st_nlink;
stbuf->st_mode = prstat->st_mode;
stbuf->st_uid = prstat->st_uid;
stbuf->st_gid = prstat->st_gid;
stbuf->st_rdev = prstat->st_rdev;
stbuf->st_size = prstat->st_size;
stbuf->st_blksize = prstat->st_blksize;
stbuf->st_blocks = prstat->st_blocks;
stbuf->st_atim.tv_sec = prstat->st_atim_sec;
stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;
stbuf->st_mtime = prstat->st_mtim_sec;
stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;
stbuf->st_ctime = prstat->st_ctim_sec;
stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct stat *VAR_0, ProxyStat *VAR_1)
{
memset(VAR_0, 0, sizeof(*VAR_0));
VAR_0->st_dev = VAR_1->st_dev;
VAR_0->st_ino = VAR_1->st_ino;
VAR_0->st_nlink = VAR_1->st_nlink;
VAR_0->st_mode = VAR_1->st_mode;
VAR_0->st_uid = VAR_1->st_uid;
VAR_0->st_gid = VAR_1->st_gid;
VAR_0->st_rdev = VAR_1->st_rdev;
VAR_0->st_size = VAR_1->st_size;
VAR_0->st_blksize = VAR_1->st_blksize;
VAR_0->st_blocks = VAR_1->st_blocks;
VAR_0->st_atim.tv_sec = VAR_1->st_atim_sec;
VAR_0->st_atim.tv_nsec = VAR_1->st_atim_nsec;
VAR_0->st_mtime = VAR_1->st_mtim_sec;
VAR_0->st_mtim.tv_nsec = VAR_1->st_mtim_nsec;
VAR_0->st_ctime = VAR_1->st_ctim_sec;
VAR_0->st_ctim.tv_nsec = VAR_1->st_ctim_nsec;
}
| [
"static void FUNC_0(struct stat *VAR_0, ProxyStat *VAR_1)\n{",
"memset(VAR_0, 0, sizeof(*VAR_0));",
"VAR_0->st_dev = VAR_1->st_dev;",
"VAR_0->st_ino = VAR_1->st_ino;",
"VAR_0->st_nlink = VAR_1->st_nlink;",
"VAR_0->st_mode = VAR_1->st_mode;",
"VAR_0->st_uid = VAR_1->st_uid;",
"VAR_0->st_gid = VAR_1->st_gid;",
"VAR_0->st_rdev = VAR_1->st_rdev;",
"VAR_0->st_size = VAR_1->st_size;",
"VAR_0->st_blksize = VAR_1->st_blksize;",
"VAR_0->st_blocks = VAR_1->st_blocks;",
"VAR_0->st_atim.tv_sec = VAR_1->st_atim_sec;",
"VAR_0->st_atim.tv_nsec = VAR_1->st_atim_nsec;",
"VAR_0->st_mtime = VAR_1->st_mtim_sec;",
"VAR_0->st_mtim.tv_nsec = VAR_1->st_mtim_nsec;",
"VAR_0->st_ctime = VAR_1->st_ctim_sec;",
"VAR_0->st_ctim.tv_nsec = VAR_1->st_ctim_nsec;",
"}"
] | [
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
]
] |
4,905 | S390CPU *cpu_s390x_init(const char *cpu_model)
{
S390CPU *cpu;
cpu = S390_CPU(object_new(TYPE_S390_CPU));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| false | qemu | 96b1a8bb55f1aeb72a943d1001841ff8b0687059 | S390CPU *cpu_s390x_init(const char *cpu_model)
{
S390CPU *cpu;
cpu = S390_CPU(object_new(TYPE_S390_CPU));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| {
"code": [],
"line_no": []
} | S390CPU *FUNC_0(const char *cpu_model)
{
S390CPU *cpu;
cpu = S390_CPU(object_new(TYPE_S390_CPU));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| [
"S390CPU *FUNC_0(const char *cpu_model)\n{",
"S390CPU *cpu;",
"cpu = S390_CPU(object_new(TYPE_S390_CPU));",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", NULL);",
"return cpu;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
]
] |
4,906 | void pci_unregister_vga(PCIDevice *pci_dev)
{
if (!pci_dev->has_vga) {
return;
}
memory_region_del_subregion(pci_dev->bus->address_space_mem,
pci_dev->vga_regions[QEMU_PCI_VGA_MEM]);
memory_region_del_subregion(pci_dev->bus->address_space_io,
pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO]);
memory_region_del_subregion(pci_dev->bus->address_space_io,
pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI]);
pci_dev->has_vga = false;
}
| false | qemu | fd56e0612b6454a282fa6a953fdb09281a98c589 | void pci_unregister_vga(PCIDevice *pci_dev)
{
if (!pci_dev->has_vga) {
return;
}
memory_region_del_subregion(pci_dev->bus->address_space_mem,
pci_dev->vga_regions[QEMU_PCI_VGA_MEM]);
memory_region_del_subregion(pci_dev->bus->address_space_io,
pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO]);
memory_region_del_subregion(pci_dev->bus->address_space_io,
pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI]);
pci_dev->has_vga = false;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCIDevice *VAR_0)
{
if (!VAR_0->has_vga) {
return;
}
memory_region_del_subregion(VAR_0->bus->address_space_mem,
VAR_0->vga_regions[QEMU_PCI_VGA_MEM]);
memory_region_del_subregion(VAR_0->bus->address_space_io,
VAR_0->vga_regions[QEMU_PCI_VGA_IO_LO]);
memory_region_del_subregion(VAR_0->bus->address_space_io,
VAR_0->vga_regions[QEMU_PCI_VGA_IO_HI]);
VAR_0->has_vga = false;
}
| [
"void FUNC_0(PCIDevice *VAR_0)\n{",
"if (!VAR_0->has_vga) {",
"return;",
"}",
"memory_region_del_subregion(VAR_0->bus->address_space_mem,\nVAR_0->vga_regions[QEMU_PCI_VGA_MEM]);",
"memory_region_del_subregion(VAR_0->bus->address_space_io,\nVAR_0->vga_regions[QEMU_PCI_VGA_IO_LO]);",
"memory_region_del_subregion(VAR_0->bus->address_space_io,\nVAR_0->vga_regions[QEMU_PCI_VGA_IO_HI]);",
"VAR_0->has_vga = false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27
]
] |
4,907 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
C93DecoderContext * const c93 = avctx->priv_data;
AVFrame * const newpic = &c93->pictures[c93->currentpic];
AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];
GetByteContext gb;
uint8_t *out;
int stride, ret, i, x, y, b, bt = 0;
c93->currentpic ^= 1;
if ((ret = ff_reget_buffer(avctx, newpic)) < 0)
return ret;
stride = newpic->linesize[0];
bytestream2_init(&gb, buf, buf_size);
b = bytestream2_get_byte(&gb);
if (b & C93_FIRST_FRAME) {
newpic->pict_type = AV_PICTURE_TYPE_I;
newpic->key_frame = 1;
} else {
newpic->pict_type = AV_PICTURE_TYPE_P;
newpic->key_frame = 0;
}
for (y = 0; y < HEIGHT; y += 8) {
out = newpic->data[0] + y * stride;
for (x = 0; x < WIDTH; x += 8) {
uint8_t *copy_from = oldpic->data[0];
unsigned int offset, j;
uint8_t cols[4], grps[4];
C93BlockType block_type;
if (!bt)
bt = bytestream2_get_byte(&gb);
block_type= bt & 0x0F;
switch (block_type) {
case C93_8X8_FROM_PREV:
offset = bytestream2_get_le16(&gb);
if ((ret = copy_block(avctx, out, copy_from, offset, 8, stride)) < 0)
return ret;
break;
case C93_4X4_FROM_CURR:
copy_from = newpic->data[0];
case C93_4X4_FROM_PREV:
for (j = 0; j < 8; j += 4) {
for (i = 0; i < 8; i += 4) {
offset = bytestream2_get_le16(&gb);
if ((ret = copy_block(avctx, &out[j*stride+i],
copy_from, offset, 4, stride)) < 0)
return ret;
}
}
break;
case C93_8X8_2COLOR:
bytestream2_get_buffer(&gb, cols, 2);
for (i = 0; i < 8; i++) {
draw_n_color(out + i*stride, stride, 8, 1, 1, cols,
NULL, bytestream2_get_byte(&gb));
}
break;
case C93_4X4_2COLOR:
case C93_4X4_4COLOR:
case C93_4X4_4COLOR_GRP:
for (j = 0; j < 8; j += 4) {
for (i = 0; i < 8; i += 4) {
if (block_type == C93_4X4_2COLOR) {
bytestream2_get_buffer(&gb, cols, 2);
draw_n_color(out + i + j*stride, stride, 4, 4,
1, cols, NULL, bytestream2_get_le16(&gb));
} else if (block_type == C93_4X4_4COLOR) {
bytestream2_get_buffer(&gb, cols, 4);
draw_n_color(out + i + j*stride, stride, 4, 4,
2, cols, NULL, bytestream2_get_le32(&gb));
} else {
bytestream2_get_buffer(&gb, grps, 4);
draw_n_color(out + i + j*stride, stride, 4, 4,
1, cols, grps, bytestream2_get_le16(&gb));
}
}
}
break;
case C93_NOOP:
break;
case C93_8X8_INTRA:
for (j = 0; j < 8; j++)
bytestream2_get_buffer(&gb, out + j*stride, 8);
break;
default:
av_log(avctx, AV_LOG_ERROR, "unexpected type %x at %dx%d\n",
block_type, x, y);
return AVERROR_INVALIDDATA;
}
bt >>= 4;
out += 8;
}
}
if (b & C93_HAS_PALETTE) {
uint32_t *palette = (uint32_t *) newpic->data[1];
for (i = 0; i < 256; i++) {
palette[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
newpic->palette_has_changed = 1;
} else {
if (oldpic->data[1])
memcpy(newpic->data[1], oldpic->data[1], 256 * 4);
}
if ((ret = av_frame_ref(data, newpic)) < 0)
return ret;
*got_frame = 1;
return buf_size;
}
| false | FFmpeg | 6b657ac7889738b9ab38924cca4e7c418f6fbc38 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
C93DecoderContext * const c93 = avctx->priv_data;
AVFrame * const newpic = &c93->pictures[c93->currentpic];
AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];
GetByteContext gb;
uint8_t *out;
int stride, ret, i, x, y, b, bt = 0;
c93->currentpic ^= 1;
if ((ret = ff_reget_buffer(avctx, newpic)) < 0)
return ret;
stride = newpic->linesize[0];
bytestream2_init(&gb, buf, buf_size);
b = bytestream2_get_byte(&gb);
if (b & C93_FIRST_FRAME) {
newpic->pict_type = AV_PICTURE_TYPE_I;
newpic->key_frame = 1;
} else {
newpic->pict_type = AV_PICTURE_TYPE_P;
newpic->key_frame = 0;
}
for (y = 0; y < HEIGHT; y += 8) {
out = newpic->data[0] + y * stride;
for (x = 0; x < WIDTH; x += 8) {
uint8_t *copy_from = oldpic->data[0];
unsigned int offset, j;
uint8_t cols[4], grps[4];
C93BlockType block_type;
if (!bt)
bt = bytestream2_get_byte(&gb);
block_type= bt & 0x0F;
switch (block_type) {
case C93_8X8_FROM_PREV:
offset = bytestream2_get_le16(&gb);
if ((ret = copy_block(avctx, out, copy_from, offset, 8, stride)) < 0)
return ret;
break;
case C93_4X4_FROM_CURR:
copy_from = newpic->data[0];
case C93_4X4_FROM_PREV:
for (j = 0; j < 8; j += 4) {
for (i = 0; i < 8; i += 4) {
offset = bytestream2_get_le16(&gb);
if ((ret = copy_block(avctx, &out[j*stride+i],
copy_from, offset, 4, stride)) < 0)
return ret;
}
}
break;
case C93_8X8_2COLOR:
bytestream2_get_buffer(&gb, cols, 2);
for (i = 0; i < 8; i++) {
draw_n_color(out + i*stride, stride, 8, 1, 1, cols,
NULL, bytestream2_get_byte(&gb));
}
break;
case C93_4X4_2COLOR:
case C93_4X4_4COLOR:
case C93_4X4_4COLOR_GRP:
for (j = 0; j < 8; j += 4) {
for (i = 0; i < 8; i += 4) {
if (block_type == C93_4X4_2COLOR) {
bytestream2_get_buffer(&gb, cols, 2);
draw_n_color(out + i + j*stride, stride, 4, 4,
1, cols, NULL, bytestream2_get_le16(&gb));
} else if (block_type == C93_4X4_4COLOR) {
bytestream2_get_buffer(&gb, cols, 4);
draw_n_color(out + i + j*stride, stride, 4, 4,
2, cols, NULL, bytestream2_get_le32(&gb));
} else {
bytestream2_get_buffer(&gb, grps, 4);
draw_n_color(out + i + j*stride, stride, 4, 4,
1, cols, grps, bytestream2_get_le16(&gb));
}
}
}
break;
case C93_NOOP:
break;
case C93_8X8_INTRA:
for (j = 0; j < 8; j++)
bytestream2_get_buffer(&gb, out + j*stride, 8);
break;
default:
av_log(avctx, AV_LOG_ERROR, "unexpected type %x at %dx%d\n",
block_type, x, y);
return AVERROR_INVALIDDATA;
}
bt >>= 4;
out += 8;
}
}
if (b & C93_HAS_PALETTE) {
uint32_t *palette = (uint32_t *) newpic->data[1];
for (i = 0; i < 256; i++) {
palette[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
newpic->palette_has_changed = 1;
} else {
if (oldpic->data[1])
memcpy(newpic->data[1], oldpic->data[1], 256 * 4);
}
if ((ret = av_frame_ref(data, newpic)) < 0)
return ret;
*got_frame = 1;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
C93DecoderContext * const c93 = VAR_0->priv_data;
AVFrame * const newpic = &c93->pictures[c93->currentpic];
AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];
GetByteContext gb;
uint8_t *out;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12 = 0;
c93->currentpic ^= 1;
if ((VAR_7 = ff_reget_buffer(VAR_0, newpic)) < 0)
return VAR_7;
VAR_6 = newpic->linesize[0];
bytestream2_init(&gb, VAR_4, VAR_5);
VAR_11 = bytestream2_get_byte(&gb);
if (VAR_11 & C93_FIRST_FRAME) {
newpic->pict_type = AV_PICTURE_TYPE_I;
newpic->key_frame = 1;
} else {
newpic->pict_type = AV_PICTURE_TYPE_P;
newpic->key_frame = 0;
}
for (VAR_10 = 0; VAR_10 < HEIGHT; VAR_10 += 8) {
out = newpic->VAR_1[0] + VAR_10 * VAR_6;
for (VAR_9 = 0; VAR_9 < WIDTH; VAR_9 += 8) {
uint8_t *copy_from = oldpic->VAR_1[0];
unsigned int offset, j;
uint8_t cols[4], grps[4];
C93BlockType block_type;
if (!VAR_12)
VAR_12 = bytestream2_get_byte(&gb);
block_type= VAR_12 & 0x0F;
switch (block_type) {
case C93_8X8_FROM_PREV:
offset = bytestream2_get_le16(&gb);
if ((VAR_7 = copy_block(VAR_0, out, copy_from, offset, 8, VAR_6)) < 0)
return VAR_7;
break;
case C93_4X4_FROM_CURR:
copy_from = newpic->VAR_1[0];
case C93_4X4_FROM_PREV:
for (j = 0; j < 8; j += 4) {
for (VAR_8 = 0; VAR_8 < 8; VAR_8 += 4) {
offset = bytestream2_get_le16(&gb);
if ((VAR_7 = copy_block(VAR_0, &out[j*VAR_6+VAR_8],
copy_from, offset, 4, VAR_6)) < 0)
return VAR_7;
}
}
break;
case C93_8X8_2COLOR:
bytestream2_get_buffer(&gb, cols, 2);
for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {
draw_n_color(out + VAR_8*VAR_6, VAR_6, 8, 1, 1, cols,
NULL, bytestream2_get_byte(&gb));
}
break;
case C93_4X4_2COLOR:
case C93_4X4_4COLOR:
case C93_4X4_4COLOR_GRP:
for (j = 0; j < 8; j += 4) {
for (VAR_8 = 0; VAR_8 < 8; VAR_8 += 4) {
if (block_type == C93_4X4_2COLOR) {
bytestream2_get_buffer(&gb, cols, 2);
draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,
1, cols, NULL, bytestream2_get_le16(&gb));
} else if (block_type == C93_4X4_4COLOR) {
bytestream2_get_buffer(&gb, cols, 4);
draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,
2, cols, NULL, bytestream2_get_le32(&gb));
} else {
bytestream2_get_buffer(&gb, grps, 4);
draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,
1, cols, grps, bytestream2_get_le16(&gb));
}
}
}
break;
case C93_NOOP:
break;
case C93_8X8_INTRA:
for (j = 0; j < 8; j++)
bytestream2_get_buffer(&gb, out + j*VAR_6, 8);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "unexpected type %VAR_9 at %dx%d\n",
block_type, VAR_9, VAR_10);
return AVERROR_INVALIDDATA;
}
VAR_12 >>= 4;
out += 8;
}
}
if (VAR_11 & C93_HAS_PALETTE) {
uint32_t *palette = (uint32_t *) newpic->VAR_1[1];
for (VAR_8 = 0; VAR_8 < 256; VAR_8++) {
palette[VAR_8] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
newpic->palette_has_changed = 1;
} else {
if (oldpic->VAR_1[1])
memcpy(newpic->VAR_1[1], oldpic->VAR_1[1], 256 * 4);
}
if ((VAR_7 = av_frame_ref(VAR_1, newpic)) < 0)
return VAR_7;
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"C93DecoderContext * const c93 = VAR_0->priv_data;",
"AVFrame * const newpic = &c93->pictures[c93->currentpic];",
"AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];",
"GetByteContext gb;",
"uint8_t *out;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12 = 0;",
"c93->currentpic ^= 1;",
"if ((VAR_7 = ff_reget_buffer(VAR_0, newpic)) < 0)\nreturn VAR_7;",
"VAR_6 = newpic->linesize[0];",
"bytestream2_init(&gb, VAR_4, VAR_5);",
"VAR_11 = bytestream2_get_byte(&gb);",
"if (VAR_11 & C93_FIRST_FRAME) {",
"newpic->pict_type = AV_PICTURE_TYPE_I;",
"newpic->key_frame = 1;",
"} else {",
"newpic->pict_type = AV_PICTURE_TYPE_P;",
"newpic->key_frame = 0;",
"}",
"for (VAR_10 = 0; VAR_10 < HEIGHT; VAR_10 += 8) {",
"out = newpic->VAR_1[0] + VAR_10 * VAR_6;",
"for (VAR_9 = 0; VAR_9 < WIDTH; VAR_9 += 8) {",
"uint8_t *copy_from = oldpic->VAR_1[0];",
"unsigned int offset, j;",
"uint8_t cols[4], grps[4];",
"C93BlockType block_type;",
"if (!VAR_12)\nVAR_12 = bytestream2_get_byte(&gb);",
"block_type= VAR_12 & 0x0F;",
"switch (block_type) {",
"case C93_8X8_FROM_PREV:\noffset = bytestream2_get_le16(&gb);",
"if ((VAR_7 = copy_block(VAR_0, out, copy_from, offset, 8, VAR_6)) < 0)\nreturn VAR_7;",
"break;",
"case C93_4X4_FROM_CURR:\ncopy_from = newpic->VAR_1[0];",
"case C93_4X4_FROM_PREV:\nfor (j = 0; j < 8; j += 4) {",
"for (VAR_8 = 0; VAR_8 < 8; VAR_8 += 4) {",
"offset = bytestream2_get_le16(&gb);",
"if ((VAR_7 = copy_block(VAR_0, &out[j*VAR_6+VAR_8],\ncopy_from, offset, 4, VAR_6)) < 0)\nreturn VAR_7;",
"}",
"}",
"break;",
"case C93_8X8_2COLOR:\nbytestream2_get_buffer(&gb, cols, 2);",
"for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {",
"draw_n_color(out + VAR_8*VAR_6, VAR_6, 8, 1, 1, cols,\nNULL, bytestream2_get_byte(&gb));",
"}",
"break;",
"case C93_4X4_2COLOR:\ncase C93_4X4_4COLOR:\ncase C93_4X4_4COLOR_GRP:\nfor (j = 0; j < 8; j += 4) {",
"for (VAR_8 = 0; VAR_8 < 8; VAR_8 += 4) {",
"if (block_type == C93_4X4_2COLOR) {",
"bytestream2_get_buffer(&gb, cols, 2);",
"draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,\n1, cols, NULL, bytestream2_get_le16(&gb));",
"} else if (block_type == C93_4X4_4COLOR) {",
"bytestream2_get_buffer(&gb, cols, 4);",
"draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,\n2, cols, NULL, bytestream2_get_le32(&gb));",
"} else {",
"bytestream2_get_buffer(&gb, grps, 4);",
"draw_n_color(out + VAR_8 + j*VAR_6, VAR_6, 4, 4,\n1, cols, grps, bytestream2_get_le16(&gb));",
"}",
"}",
"}",
"break;",
"case C93_NOOP:\nbreak;",
"case C93_8X8_INTRA:\nfor (j = 0; j < 8; j++)",
"bytestream2_get_buffer(&gb, out + j*VAR_6, 8);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"unexpected type %VAR_9 at %dx%d\\n\",\nblock_type, VAR_9, VAR_10);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_12 >>= 4;",
"out += 8;",
"}",
"}",
"if (VAR_11 & C93_HAS_PALETTE) {",
"uint32_t *palette = (uint32_t *) newpic->VAR_1[1];",
"for (VAR_8 = 0; VAR_8 < 256; VAR_8++) {",
"palette[VAR_8] = 0xFFU << 24 | bytestream2_get_be24(&gb);",
"}",
"newpic->palette_has_changed = 1;",
"} else {",
"if (oldpic->VAR_1[1])\nmemcpy(newpic->VAR_1[1], oldpic->VAR_1[1], 256 * 4);",
"}",
"if ((VAR_7 = av_frame_ref(VAR_1, newpic)) < 0)\nreturn VAR_7;",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29,
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
81
],
[
83
],
[
85,
87
],
[
89,
91
],
[
93
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
137
],
[
141,
143,
145,
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185,
187
],
[
191,
193
],
[
195
],
[
197
],
[
201,
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
243,
245
],
[
247
],
[
251
],
[
253
]
] |
4,908 | VncInfo2List *qmp_query_vnc_servers(Error **errp)
{
VncInfo2List *item, *prev = NULL;
VncInfo2 *info;
VncDisplay *vd;
DeviceState *dev;
QTAILQ_FOREACH(vd, &vnc_displays, next) {
info = g_new0(VncInfo2, 1);
info->id = g_strdup(vd->id);
info->clients = qmp_query_client_list(vd);
qmp_query_auth(vd, info);
if (vd->dcl.con) {
dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
"device", NULL));
info->has_display = true;
info->display = g_strdup(dev->id);
}
if (vd->lsock != NULL) {
info->server = qmp_query_server_entry(
vd->lsock, false, info->server);
}
if (vd->lwebsock != NULL) {
info->server = qmp_query_server_entry(
vd->lwebsock, true, info->server);
}
item = g_new0(VncInfo2List, 1);
item->value = info;
item->next = prev;
prev = item;
}
return prev;
}
| false | qemu | 2a7e6857cd3178d705a49c4adde2f3af26ed3ae1 | VncInfo2List *qmp_query_vnc_servers(Error **errp)
{
VncInfo2List *item, *prev = NULL;
VncInfo2 *info;
VncDisplay *vd;
DeviceState *dev;
QTAILQ_FOREACH(vd, &vnc_displays, next) {
info = g_new0(VncInfo2, 1);
info->id = g_strdup(vd->id);
info->clients = qmp_query_client_list(vd);
qmp_query_auth(vd, info);
if (vd->dcl.con) {
dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
"device", NULL));
info->has_display = true;
info->display = g_strdup(dev->id);
}
if (vd->lsock != NULL) {
info->server = qmp_query_server_entry(
vd->lsock, false, info->server);
}
if (vd->lwebsock != NULL) {
info->server = qmp_query_server_entry(
vd->lwebsock, true, info->server);
}
item = g_new0(VncInfo2List, 1);
item->value = info;
item->next = prev;
prev = item;
}
return prev;
}
| {
"code": [],
"line_no": []
} | VncInfo2List *FUNC_0(Error **errp)
{
VncInfo2List *item, *prev = NULL;
VncInfo2 *info;
VncDisplay *vd;
DeviceState *dev;
QTAILQ_FOREACH(vd, &vnc_displays, next) {
info = g_new0(VncInfo2, 1);
info->id = g_strdup(vd->id);
info->clients = qmp_query_client_list(vd);
qmp_query_auth(vd, info);
if (vd->dcl.con) {
dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
"device", NULL));
info->has_display = true;
info->display = g_strdup(dev->id);
}
if (vd->lsock != NULL) {
info->server = qmp_query_server_entry(
vd->lsock, false, info->server);
}
if (vd->lwebsock != NULL) {
info->server = qmp_query_server_entry(
vd->lwebsock, true, info->server);
}
item = g_new0(VncInfo2List, 1);
item->value = info;
item->next = prev;
prev = item;
}
return prev;
}
| [
"VncInfo2List *FUNC_0(Error **errp)\n{",
"VncInfo2List *item, *prev = NULL;",
"VncInfo2 *info;",
"VncDisplay *vd;",
"DeviceState *dev;",
"QTAILQ_FOREACH(vd, &vnc_displays, next) {",
"info = g_new0(VncInfo2, 1);",
"info->id = g_strdup(vd->id);",
"info->clients = qmp_query_client_list(vd);",
"qmp_query_auth(vd, info);",
"if (vd->dcl.con) {",
"dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),\n\"device\", NULL));",
"info->has_display = true;",
"info->display = g_strdup(dev->id);",
"}",
"if (vd->lsock != NULL) {",
"info->server = qmp_query_server_entry(\nvd->lsock, false, info->server);",
"}",
"if (vd->lwebsock != NULL) {",
"info->server = qmp_query_server_entry(\nvd->lwebsock, true, info->server);",
"}",
"item = g_new0(VncInfo2List, 1);",
"item->value = info;",
"item->next = prev;",
"prev = item;",
"}",
"return prev;",
"}"
] | [
0,
0,
0,
0,
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
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
4,910 | pic_read(void *opaque, target_phys_addr_t addr, unsigned int size)
{
struct etrax_pic *fs = opaque;
uint32_t rval;
rval = fs->regs[addr >> 2];
D(printf("%s %x=%x\n", __func__, addr, rval));
return rval;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | pic_read(void *opaque, target_phys_addr_t addr, unsigned int size)
{
struct etrax_pic *fs = opaque;
uint32_t rval;
rval = fs->regs[addr >> 2];
D(printf("%s %x=%x\n", __func__, addr, rval));
return rval;
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, unsigned int VAR_2)
{
struct etrax_pic *VAR_3 = VAR_0;
uint32_t rval;
rval = VAR_3->regs[VAR_1 >> 2];
D(printf("%s %x=%x\n", __func__, VAR_1, rval));
return rval;
}
| [
"FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, unsigned int VAR_2)\n{",
"struct etrax_pic *VAR_3 = VAR_0;",
"uint32_t rval;",
"rval = VAR_3->regs[VAR_1 >> 2];",
"D(printf(\"%s %x=%x\\n\", __func__, VAR_1, rval));",
"return rval;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,911 | static int coroutine_fn nfs_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
NFSClient *client = bs->opaque;
NFSRPC task;
char *buf = NULL;
nfs_co_init_task(client, &task);
buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);
if (nb_sectors && buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);
if (nfs_pwrite_async(client->context, client->fh,
sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE,
buf, nfs_co_generic_cb, &task) != 0) {
g_free(buf);
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
qemu_coroutine_yield();
}
g_free(buf);
if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {
return task.ret < 0 ? task.ret : -EIO;
}
return 0;
}
| false | qemu | aa92d6c4609e174fc6884e4b7b87367fac33cbe9 | static int coroutine_fn nfs_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
NFSClient *client = bs->opaque;
NFSRPC task;
char *buf = NULL;
nfs_co_init_task(client, &task);
buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);
if (nb_sectors && buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);
if (nfs_pwrite_async(client->context, client->fh,
sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE,
buf, nfs_co_generic_cb, &task) != 0) {
g_free(buf);
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
qemu_coroutine_yield();
}
g_free(buf);
if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {
return task.ret < 0 ? task.ret : -EIO;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 nfs_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
NFSClient *client = bs->opaque;
NFSRPC task;
char *buf = NULL;
nfs_co_init_task(client, &task);
buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);
if (nb_sectors && buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);
if (nfs_pwrite_async(client->context, client->fh,
sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE,
buf, nfs_co_generic_cb, &task) != 0) {
g_free(buf);
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
qemu_coroutine_yield();
}
g_free(buf);
if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {
return task.ret < 0 ? task.ret : -EIO;
}
return 0;
}
| [
"static int VAR_0 nfs_co_writev(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors,\nQEMUIOVector *iov)\n{",
"NFSClient *client = bs->opaque;",
"NFSRPC task;",
"char *buf = NULL;",
"nfs_co_init_task(client, &task);",
"buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);",
"if (nb_sectors && buf == NULL) {",
"return -ENOMEM;",
"}",
"qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);",
"if (nfs_pwrite_async(client->context, client->fh,\nsector_num * BDRV_SECTOR_SIZE,\nnb_sectors * BDRV_SECTOR_SIZE,\nbuf, nfs_co_generic_cb, &task) != 0) {",
"g_free(buf);",
"return -ENOMEM;",
"}",
"while (!task.complete) {",
"nfs_set_events(client);",
"qemu_coroutine_yield();",
"}",
"g_free(buf);",
"if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {",
"return task.ret < 0 ? task.ret : -EIO;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
4,912 | static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond,
void *opaque)
{
CadenceUARTState *s = opaque;
int ret;
/* instant drain the fifo when there's no back-end */
if (!s->chr) {
s->tx_count = 0;
return FALSE;
}
if (!s->tx_count) {
return FALSE;
}
ret = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);
s->tx_count -= ret;
memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
if (s->tx_count) {
int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
cadence_uart_xmit, s);
assert(r);
}
uart_update_status(s);
return FALSE;
}
| false | qemu | 6f1de6b70d857d5e316ae6fd908f52818b827b08 | static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond,
void *opaque)
{
CadenceUARTState *s = opaque;
int ret;
if (!s->chr) {
s->tx_count = 0;
return FALSE;
}
if (!s->tx_count) {
return FALSE;
}
ret = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);
s->tx_count -= ret;
memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
if (s->tx_count) {
int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
cadence_uart_xmit, s);
assert(r);
}
uart_update_status(s);
return FALSE;
}
| {
"code": [],
"line_no": []
} | static gboolean FUNC_0(GIOChannel *chan, GIOCondition cond,
void *opaque)
{
CadenceUARTState *s = opaque;
int VAR_0;
if (!s->chr) {
s->tx_count = 0;
return FALSE;
}
if (!s->tx_count) {
return FALSE;
}
VAR_0 = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);
s->tx_count -= VAR_0;
memmove(s->tx_fifo, s->tx_fifo + VAR_0, s->tx_count);
if (s->tx_count) {
int VAR_1 = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
FUNC_0, s);
assert(VAR_1);
}
uart_update_status(s);
return FALSE;
}
| [
"static gboolean FUNC_0(GIOChannel *chan, GIOCondition cond,\nvoid *opaque)\n{",
"CadenceUARTState *s = opaque;",
"int VAR_0;",
"if (!s->chr) {",
"s->tx_count = 0;",
"return FALSE;",
"}",
"if (!s->tx_count) {",
"return FALSE;",
"}",
"VAR_0 = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);",
"s->tx_count -= VAR_0;",
"memmove(s->tx_fifo, s->tx_fifo + VAR_0, s->tx_count);",
"if (s->tx_count) {",
"int VAR_1 = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,\nFUNC_0, s);",
"assert(VAR_1);",
"}",
"uart_update_status(s);",
"return FALSE;",
"}"
] | [
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
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
]
] |
4,914 | void error_set_field(Error *err, const char *field, const char *value)
{
QDict *dict = qdict_get_qdict(err->obj, "data");
return qdict_put(dict, field, qstring_from_str(value));
}
| false | qemu | 0ed6dc1a982fd029557a17fda7606d679a6ebb28 | void error_set_field(Error *err, const char *field, const char *value)
{
QDict *dict = qdict_get_qdict(err->obj, "data");
return qdict_put(dict, field, qstring_from_str(value));
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Error *VAR_0, const char *VAR_1, const char *VAR_2)
{
QDict *dict = qdict_get_qdict(VAR_0->obj, "data");
return qdict_put(dict, VAR_1, qstring_from_str(VAR_2));
}
| [
"void FUNC_0(Error *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"QDict *dict = qdict_get_qdict(VAR_0->obj, \"data\");",
"return qdict_put(dict, VAR_1, qstring_from_str(VAR_2));",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
4,915 | static void replay_add_event(ReplayAsyncEventKind event_kind,
void *opaque,
void *opaque2, uint64_t id)
{
assert(event_kind < REPLAY_ASYNC_COUNT);
if (!replay_file || replay_mode == REPLAY_MODE_NONE
|| !events_enabled) {
Event e;
e.event_kind = event_kind;
e.opaque = opaque;
e.opaque2 = opaque2;
e.id = id;
replay_run_event(&e);
return;
}
Event *event = g_malloc0(sizeof(Event));
event->event_kind = event_kind;
event->opaque = opaque;
event->opaque2 = opaque2;
event->id = id;
replay_mutex_lock();
QTAILQ_INSERT_TAIL(&events_list, event, events);
replay_mutex_unlock();
}
| false | qemu | 33577b47c64435fcc2a1bc01c7e82534256f1fc3 | static void replay_add_event(ReplayAsyncEventKind event_kind,
void *opaque,
void *opaque2, uint64_t id)
{
assert(event_kind < REPLAY_ASYNC_COUNT);
if (!replay_file || replay_mode == REPLAY_MODE_NONE
|| !events_enabled) {
Event e;
e.event_kind = event_kind;
e.opaque = opaque;
e.opaque2 = opaque2;
e.id = id;
replay_run_event(&e);
return;
}
Event *event = g_malloc0(sizeof(Event));
event->event_kind = event_kind;
event->opaque = opaque;
event->opaque2 = opaque2;
event->id = id;
replay_mutex_lock();
QTAILQ_INSERT_TAIL(&events_list, event, events);
replay_mutex_unlock();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ReplayAsyncEventKind VAR_0,
void *VAR_1,
void *VAR_2, uint64_t VAR_3)
{
assert(VAR_0 < REPLAY_ASYNC_COUNT);
if (!replay_file || replay_mode == REPLAY_MODE_NONE
|| !events_enabled) {
Event e;
e.VAR_0 = VAR_0;
e.VAR_1 = VAR_1;
e.VAR_2 = VAR_2;
e.VAR_3 = VAR_3;
replay_run_event(&e);
return;
}
Event *event = g_malloc0(sizeof(Event));
event->VAR_0 = VAR_0;
event->VAR_1 = VAR_1;
event->VAR_2 = VAR_2;
event->VAR_3 = VAR_3;
replay_mutex_lock();
QTAILQ_INSERT_TAIL(&events_list, event, events);
replay_mutex_unlock();
}
| [
"static void FUNC_0(ReplayAsyncEventKind VAR_0,\nvoid *VAR_1,\nvoid *VAR_2, uint64_t VAR_3)\n{",
"assert(VAR_0 < REPLAY_ASYNC_COUNT);",
"if (!replay_file || replay_mode == REPLAY_MODE_NONE\n|| !events_enabled) {",
"Event e;",
"e.VAR_0 = VAR_0;",
"e.VAR_1 = VAR_1;",
"e.VAR_2 = VAR_2;",
"e.VAR_3 = VAR_3;",
"replay_run_event(&e);",
"return;",
"}",
"Event *event = g_malloc0(sizeof(Event));",
"event->VAR_0 = VAR_0;",
"event->VAR_1 = VAR_1;",
"event->VAR_2 = VAR_2;",
"event->VAR_3 = VAR_3;",
"replay_mutex_lock();",
"QTAILQ_INSERT_TAIL(&events_list, event, events);",
"replay_mutex_unlock();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
4,917 | static void unsafe_flush_warning(BDRVSSHState *s, const char *what)
{
if (!s->unsafe_flush_warning) {
error_report("warning: ssh server %s does not support fsync",
s->inet->host);
if (what) {
error_report("to support fsync, you need %s", what);
}
s->unsafe_flush_warning = true;
}
}
| false | qemu | 3dc6f8693694a649a9c83f1e2746565b47683923 | static void unsafe_flush_warning(BDRVSSHState *s, const char *what)
{
if (!s->unsafe_flush_warning) {
error_report("warning: ssh server %s does not support fsync",
s->inet->host);
if (what) {
error_report("to support fsync, you need %s", what);
}
s->unsafe_flush_warning = true;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BDRVSSHState *VAR_0, const char *VAR_1)
{
if (!VAR_0->FUNC_0) {
error_report("warning: ssh server %VAR_0 does not support fsync",
VAR_0->inet->host);
if (VAR_1) {
error_report("to support fsync, you need %VAR_0", VAR_1);
}
VAR_0->FUNC_0 = true;
}
}
| [
"static void FUNC_0(BDRVSSHState *VAR_0, const char *VAR_1)\n{",
"if (!VAR_0->FUNC_0) {",
"error_report(\"warning: ssh server %VAR_0 does not support fsync\",\nVAR_0->inet->host);",
"if (VAR_1) {",
"error_report(\"to support fsync, you need %VAR_0\", VAR_1);",
"}",
"VAR_0->FUNC_0 = true;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
4,918 | static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
SliceHeader *sh = &s->sh;
int i, j, ret;
// Coded parameters
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
s->pps != (HEVCPPS*)s->pps_list[sh->pps_id]->data) {
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data;
if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) {
const HEVCSPS* last_sps = s->sps;
s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data;
if (last_sps && IS_IRAP(s) && s->nal_unit_type != NAL_CRA_NUT) {
if (s->sps->width != last_sps->width || s->sps->height != last_sps->height ||
s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering !=
last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(s);
ret = set_sps(s, s->sps, AV_PIX_FMT_NONE);
if (ret < 0)
return ret;
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (s->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
slice_address_length = av_ceil_log2(s->sps->ctb_width *
s->sps->ctb_height);
sh->slice_segment_addr = get_bits(gb, slice_address_length);
if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
s->slice_idx = 0;
s->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
s->slice_initialized = 0;
for (i = 0; i < s->pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == I_SLICE ||
sh->slice_type == P_SLICE ||
sh->slice_type == B_SLICE)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(s) && sh->slice_type != I_SLICE) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
// when flag is not present, picture is inferred to be output
sh->pic_output_flag = 1;
if (s->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (s->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(s)) {
int poc;
sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb);
poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
poc = s->poc;
}
s->poc = poc;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
int pos = get_bits_left(gb);
ret = ff_hevc_decode_short_term_rps(s, &sh->slice_rps, s->sps, 1);
if (ret < 0)
return ret;
sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
sh->short_term_rps = &sh->slice_rps;
} else {
int numbits, rps_idx;
if (!s->sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
numbits = av_ceil_log2(s->sps->nb_st_rps);
rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
sh->short_term_rps = &s->sps->st_rps[rps_idx];
}
ret = decode_lt_rps(s, &sh->long_term_rps, gb);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
if (s->sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
s->sh.short_term_rps = NULL;
s->poc = 0;
}
/* 8.3.1 */
if (s->temporal_id == 0 &&
s->nal_unit_type != NAL_TRAIL_N &&
s->nal_unit_type != NAL_TSA_N &&
s->nal_unit_type != NAL_STSA_N &&
s->nal_unit_type != NAL_RADL_N &&
s->nal_unit_type != NAL_RADL_R &&
s->nal_unit_type != NAL_RASL_N &&
s->nal_unit_type != NAL_RASL_R)
s->pocTid0 = s->poc;
if (s->sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (s->sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {
int nb_refs;
sh->nb_refs[L0] = s->pps->num_ref_idx_l0_default_active;
if (sh->slice_type == B_SLICE)
sh->nb_refs[L1] = s->pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) { // num_ref_idx_active_override_flag
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == B_SLICE)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > MAX_REFS || sh->nb_refs[L1] > MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
nb_refs = ff_hevc_frame_nb_refs(s);
if (!nb_refs) {
av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (s->pps->lists_modification_present_flag && nb_refs > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (i = 0; i < sh->nb_refs[L0]; i++)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
if (sh->slice_type == B_SLICE) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
}
if (sh->slice_type == B_SLICE)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == B_SLICE)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((s->pps->weighted_pred_flag && sh->slice_type == P_SLICE) ||
(s->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {
pred_weight_table(s, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (s->pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (s->pps->deblocking_filter_control_present_flag) {
int deblocking_filter_override_flag = 0;
if (s->pps->deblocking_filter_override_enabled_flag)
deblocking_filter_override_flag = get_bits1(gb);
if (deblocking_filter_override_flag) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
sh->beta_offset = get_se_golomb(gb) * 2;
sh->tc_offset = get_se_golomb(gb) * 2;
}
} else {
sh->disable_deblocking_filter_flag = s->pps->disable_dbf;
sh->beta_offset = s->pps->beta_offset;
sh->tc_offset = s->pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (s->pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) {
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
// It would be possible to bound this tighter but this here is simpler
if (sh->num_entry_point_offsets > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = num_entry_point_offsets;
if (sh->num_entry_point_offsets > 0) {
int offset_len = get_ue_golomb_long(gb) + 1;
if (offset_len < 1 || offset_len > 32) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < sh->num_entry_point_offsets; i++) {
unsigned val = get_bits_long(gb, offset_len);
sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size
}
if (s->threads_number > 1 && (s->pps->num_tile_rows > 1 || s->pps->num_tile_columns > 1)) {
s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here
s->threads_number = 1;
} else
s->enable_parallel_tiles = 0;
} else
s->enable_parallel_tiles = 0;
}
if (s->pps->slice_header_extension_present_flag) {
unsigned int length = get_ue_golomb_long(gb);
if (length*8LL > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < length; i++)
skip_bits(gb, 8); // slice_header_extension_data_byte
}
// Inferred parameters
sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -s->sps->qp_bd_offset) {
av_log(s->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-s->sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
s->HEVClc->tu.cu_qp_offset_cb = 0;
s->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| false | FFmpeg | 3051e7fa712dfe2136f19b7157211453895f2a3c | static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
SliceHeader *sh = &s->sh;
int i, j, ret;
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
s->pps != (HEVCPPS*)s->pps_list[sh->pps_id]->data) {
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data;
if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) {
const HEVCSPS* last_sps = s->sps;
s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data;
if (last_sps && IS_IRAP(s) && s->nal_unit_type != NAL_CRA_NUT) {
if (s->sps->width != last_sps->width || s->sps->height != last_sps->height ||
s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering !=
last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(s);
ret = set_sps(s, s->sps, AV_PIX_FMT_NONE);
if (ret < 0)
return ret;
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (s->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
slice_address_length = av_ceil_log2(s->sps->ctb_width *
s->sps->ctb_height);
sh->slice_segment_addr = get_bits(gb, slice_address_length);
if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
s->slice_idx = 0;
s->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
s->slice_initialized = 0;
for (i = 0; i < s->pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == I_SLICE ||
sh->slice_type == P_SLICE ||
sh->slice_type == B_SLICE)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(s) && sh->slice_type != I_SLICE) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
sh->pic_output_flag = 1;
if (s->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (s->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(s)) {
int poc;
sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb);
poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
poc = s->poc;
}
s->poc = poc;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
int pos = get_bits_left(gb);
ret = ff_hevc_decode_short_term_rps(s, &sh->slice_rps, s->sps, 1);
if (ret < 0)
return ret;
sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
sh->short_term_rps = &sh->slice_rps;
} else {
int numbits, rps_idx;
if (!s->sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
numbits = av_ceil_log2(s->sps->nb_st_rps);
rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
sh->short_term_rps = &s->sps->st_rps[rps_idx];
}
ret = decode_lt_rps(s, &sh->long_term_rps, gb);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
if (s->sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
s->sh.short_term_rps = NULL;
s->poc = 0;
}
if (s->temporal_id == 0 &&
s->nal_unit_type != NAL_TRAIL_N &&
s->nal_unit_type != NAL_TSA_N &&
s->nal_unit_type != NAL_STSA_N &&
s->nal_unit_type != NAL_RADL_N &&
s->nal_unit_type != NAL_RADL_R &&
s->nal_unit_type != NAL_RASL_N &&
s->nal_unit_type != NAL_RASL_R)
s->pocTid0 = s->poc;
if (s->sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (s->sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {
int nb_refs;
sh->nb_refs[L0] = s->pps->num_ref_idx_l0_default_active;
if (sh->slice_type == B_SLICE)
sh->nb_refs[L1] = s->pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) {
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == B_SLICE)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > MAX_REFS || sh->nb_refs[L1] > MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
nb_refs = ff_hevc_frame_nb_refs(s);
if (!nb_refs) {
av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (s->pps->lists_modification_present_flag && nb_refs > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (i = 0; i < sh->nb_refs[L0]; i++)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
if (sh->slice_type == B_SLICE) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
}
if (sh->slice_type == B_SLICE)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == B_SLICE)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((s->pps->weighted_pred_flag && sh->slice_type == P_SLICE) ||
(s->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {
pred_weight_table(s, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (s->pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (s->pps->deblocking_filter_control_present_flag) {
int deblocking_filter_override_flag = 0;
if (s->pps->deblocking_filter_override_enabled_flag)
deblocking_filter_override_flag = get_bits1(gb);
if (deblocking_filter_override_flag) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
sh->beta_offset = get_se_golomb(gb) * 2;
sh->tc_offset = get_se_golomb(gb) * 2;
}
} else {
sh->disable_deblocking_filter_flag = s->pps->disable_dbf;
sh->beta_offset = s->pps->beta_offset;
sh->tc_offset = s->pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (s->pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) {
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
if (sh->num_entry_point_offsets > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = num_entry_point_offsets;
if (sh->num_entry_point_offsets > 0) {
int offset_len = get_ue_golomb_long(gb) + 1;
if (offset_len < 1 || offset_len > 32) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < sh->num_entry_point_offsets; i++) {
unsigned val = get_bits_long(gb, offset_len);
sh->entry_point_offset[i] = val + 1;
}
if (s->threads_number > 1 && (s->pps->num_tile_rows > 1 || s->pps->num_tile_columns > 1)) {
s->enable_parallel_tiles = 0;
s->threads_number = 1;
} else
s->enable_parallel_tiles = 0;
} else
s->enable_parallel_tiles = 0;
}
if (s->pps->slice_header_extension_present_flag) {
unsigned int length = get_ue_golomb_long(gb);
if (length*8LL > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < length; i++)
skip_bits(gb, 8);
}
sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -s->sps->qp_bd_offset) {
av_log(s->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-s->sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
s->HEVClc->tu.cu_qp_offset_cb = 0;
s->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HEVCContext *VAR_0)
{
GetBitContext *gb = &VAR_0->HEVClc->gb;
SliceHeader *sh = &VAR_0->sh;
int VAR_1, VAR_2, VAR_3;
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(VAR_0) || IS_BLA(VAR_0)) && sh->first_slice_in_pic_flag) {
VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;
VAR_0->max_ra = INT_MAX;
if (IS_IDR(VAR_0))
ff_hevc_clear_refs(VAR_0);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(VAR_0))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !VAR_0->pps_list[sh->pps_id]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
VAR_0->pps != (HEVCPPS*)VAR_0->pps_list[sh->pps_id]->data) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
VAR_0->pps = (HEVCPPS*)VAR_0->pps_list[sh->pps_id]->data;
if (VAR_0->nal_unit_type == NAL_CRA_NUT && VAR_0->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (VAR_0->sps != (HEVCSPS*)VAR_0->sps_list[VAR_0->pps->sps_id]->data) {
const HEVCSPS* VAR_4 = VAR_0->sps;
VAR_0->sps = (HEVCSPS*)VAR_0->sps_list[VAR_0->pps->sps_id]->data;
if (VAR_4 && IS_IRAP(VAR_0) && VAR_0->nal_unit_type != NAL_CRA_NUT) {
if (VAR_0->sps->width != VAR_4->width || VAR_0->sps->height != VAR_4->height ||
VAR_0->sps->temporal_layer[VAR_0->sps->max_sub_layers - 1].max_dec_pic_buffering !=
VAR_4->temporal_layer[VAR_4->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(VAR_0);
VAR_3 = set_sps(VAR_0, VAR_0->sps, AV_PIX_FMT_NONE);
if (VAR_3 < 0)
return VAR_3;
VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;
VAR_0->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int VAR_5;
if (VAR_0->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
VAR_5 = av_ceil_log2(VAR_0->sps->ctb_width *
VAR_0->sps->ctb_height);
sh->slice_segment_addr = get_bits(gb, VAR_5);
if (sh->slice_segment_addr >= VAR_0->sps->ctb_width * VAR_0->sps->ctb_height) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
VAR_0->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
VAR_0->slice_idx = 0;
VAR_0->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
VAR_0->slice_initialized = 0;
for (VAR_1 = 0; VAR_1 < VAR_0->pps->num_extra_slice_header_bits; VAR_1++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == I_SLICE ||
sh->slice_type == P_SLICE ||
sh->slice_type == B_SLICE)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(VAR_0) && sh->slice_type != I_SLICE) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
sh->pic_output_flag = 1;
if (VAR_0->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (VAR_0->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(VAR_0)) {
int VAR_6;
sh->pic_order_cnt_lsb = get_bits(gb, VAR_0->sps->log2_max_poc_lsb);
VAR_6 = ff_hevc_compute_poc(VAR_0, sh->pic_order_cnt_lsb);
if (!sh->first_slice_in_pic_flag && VAR_6 != VAR_0->VAR_6) {
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", VAR_0->VAR_6, VAR_6);
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
VAR_6 = VAR_0->VAR_6;
}
VAR_0->VAR_6 = VAR_6;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
int VAR_7 = get_bits_left(gb);
VAR_3 = ff_hevc_decode_short_term_rps(VAR_0, &sh->slice_rps, VAR_0->sps, 1);
if (VAR_3 < 0)
return VAR_3;
sh->short_term_ref_pic_set_size = VAR_7 - get_bits_left(gb);
sh->short_term_rps = &sh->slice_rps;
} else {
int VAR_8, VAR_9;
if (!VAR_0->sps->nb_st_rps) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
VAR_8 = av_ceil_log2(VAR_0->sps->nb_st_rps);
VAR_9 = VAR_8 > 0 ? get_bits(gb, VAR_8) : 0;
sh->short_term_rps = &VAR_0->sps->st_rps[VAR_9];
}
VAR_3 = decode_lt_rps(VAR_0, &sh->long_term_rps, gb);
if (VAR_3 < 0) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
if (VAR_0->sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
VAR_0->sh.short_term_rps = NULL;
VAR_0->VAR_6 = 0;
}
if (VAR_0->temporal_id == 0 &&
VAR_0->nal_unit_type != NAL_TRAIL_N &&
VAR_0->nal_unit_type != NAL_TSA_N &&
VAR_0->nal_unit_type != NAL_STSA_N &&
VAR_0->nal_unit_type != NAL_RADL_N &&
VAR_0->nal_unit_type != NAL_RADL_R &&
VAR_0->nal_unit_type != NAL_RASL_N &&
VAR_0->nal_unit_type != NAL_RASL_R)
VAR_0->pocTid0 = VAR_0->VAR_6;
if (VAR_0->sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (VAR_0->sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->VAR_10[L0] = sh->VAR_10[L1] = 0;
if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {
int VAR_10;
sh->VAR_10[L0] = VAR_0->pps->num_ref_idx_l0_default_active;
if (sh->slice_type == B_SLICE)
sh->VAR_10[L1] = VAR_0->pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) {
sh->VAR_10[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == B_SLICE)
sh->VAR_10[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->VAR_10[L0] > MAX_REFS || sh->VAR_10[L1] > MAX_REFS) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->VAR_10[L0], sh->VAR_10[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
VAR_10 = ff_hevc_frame_nb_refs(VAR_0);
if (!VAR_10) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->pps->lists_modification_present_flag && VAR_10 > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (VAR_1 = 0; VAR_1 < sh->VAR_10[L0]; VAR_1++)
sh->list_entry_lx[0][VAR_1] = get_bits(gb, av_ceil_log2(VAR_10));
}
if (sh->slice_type == B_SLICE) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (VAR_1 = 0; VAR_1 < sh->VAR_10[L1]; VAR_1++)
sh->list_entry_lx[1][VAR_1] = get_bits(gb, av_ceil_log2(VAR_10));
}
}
if (sh->slice_type == B_SLICE)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (VAR_0->pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == B_SLICE)
sh->collocated_list = !get_bits1(gb);
if (sh->VAR_10[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->VAR_10[sh->collocated_list]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((VAR_0->pps->weighted_pred_flag && sh->slice_type == P_SLICE) ||
(VAR_0->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {
pred_weight_table(VAR_0, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (VAR_0->pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (VAR_0->pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (VAR_0->pps->deblocking_filter_control_present_flag) {
int VAR_11 = 0;
if (VAR_0->pps->deblocking_filter_override_enabled_flag)
VAR_11 = get_bits1(gb);
if (VAR_11) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
sh->beta_offset = get_se_golomb(gb) * 2;
sh->tc_offset = get_se_golomb(gb) * 2;
}
} else {
sh->disable_deblocking_filter_flag = VAR_0->pps->disable_dbf;
sh->beta_offset = VAR_0->pps->beta_offset;
sh->tc_offset = VAR_0->pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (VAR_0->pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = VAR_0->pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!VAR_0->slice_initialized) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->VAR_12 = 0;
if (VAR_0->pps->tiles_enabled_flag || VAR_0->pps->entropy_coding_sync_enabled_flag) {
unsigned VAR_12 = get_ue_golomb_long(gb);
if (sh->VAR_12 > get_bits_left(gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_12 %d is invalid\n", VAR_12);
return AVERROR_INVALIDDATA;
}
sh->VAR_12 = VAR_12;
if (sh->VAR_12 > 0) {
int VAR_13 = get_ue_golomb_long(gb) + 1;
if (VAR_13 < 1 || VAR_13 > 32) {
sh->VAR_12 = 0;
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_13 %d is invalid\n", VAR_13);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->VAR_12, sizeof(int));
sh->offset = av_malloc_array(sh->VAR_12, sizeof(int));
sh->size = av_malloc_array(sh->VAR_12, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->VAR_12 = 0;
av_log(VAR_0->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (VAR_1 = 0; VAR_1 < sh->VAR_12; VAR_1++) {
unsigned val = get_bits_long(gb, VAR_13);
sh->entry_point_offset[VAR_1] = val + 1;
}
if (VAR_0->threads_number > 1 && (VAR_0->pps->num_tile_rows > 1 || VAR_0->pps->num_tile_columns > 1)) {
VAR_0->enable_parallel_tiles = 0;
VAR_0->threads_number = 1;
} else
VAR_0->enable_parallel_tiles = 0;
} else
VAR_0->enable_parallel_tiles = 0;
}
if (VAR_0->pps->slice_header_extension_present_flag) {
unsigned int VAR_14 = get_ue_golomb_long(gb);
if (VAR_14*8LL > get_bits_left(gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (VAR_1 = 0; VAR_1 < VAR_14; VAR_1++)
skip_bits(gb, 8);
}
sh->slice_qp = 26U + VAR_0->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -VAR_0->sps->qp_bd_offset) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-VAR_0->sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!VAR_0->sh.slice_ctb_addr_rs && VAR_0->sh.dependent_slice_segment_flag) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
VAR_0->HEVClc->first_qp_group = !VAR_0->sh.dependent_slice_segment_flag;
if (!VAR_0->pps->cu_qp_delta_enabled_flag)
VAR_0->HEVClc->qp_y = VAR_0->sh.slice_qp;
VAR_0->slice_initialized = 1;
VAR_0->HEVClc->tu.cu_qp_offset_cb = 0;
VAR_0->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| [
"static int FUNC_0(HEVCContext *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->HEVClc->gb;",
"SliceHeader *sh = &VAR_0->sh;",
"int VAR_1, VAR_2, VAR_3;",
"sh->first_slice_in_pic_flag = get_bits1(gb);",
"if ((IS_IDR(VAR_0) || IS_BLA(VAR_0)) && sh->first_slice_in_pic_flag) {",
"VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;",
"VAR_0->max_ra = INT_MAX;",
"if (IS_IDR(VAR_0))\nff_hevc_clear_refs(VAR_0);",
"}",
"sh->no_output_of_prior_pics_flag = 0;",
"if (IS_IRAP(VAR_0))\nsh->no_output_of_prior_pics_flag = get_bits1(gb);",
"sh->pps_id = get_ue_golomb_long(gb);",
"if (sh->pps_id >= MAX_PPS_COUNT || !VAR_0->pps_list[sh->pps_id]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS id out of range: %d\\n\", sh->pps_id);",
"return AVERROR_INVALIDDATA;",
"}",
"if (!sh->first_slice_in_pic_flag &&\nVAR_0->pps != (HEVCPPS*)VAR_0->pps_list[sh->pps_id]->data) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS changed between slices.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->pps = (HEVCPPS*)VAR_0->pps_list[sh->pps_id]->data;",
"if (VAR_0->nal_unit_type == NAL_CRA_NUT && VAR_0->last_eos == 1)\nsh->no_output_of_prior_pics_flag = 1;",
"if (VAR_0->sps != (HEVCSPS*)VAR_0->sps_list[VAR_0->pps->sps_id]->data) {",
"const HEVCSPS* VAR_4 = VAR_0->sps;",
"VAR_0->sps = (HEVCSPS*)VAR_0->sps_list[VAR_0->pps->sps_id]->data;",
"if (VAR_4 && IS_IRAP(VAR_0) && VAR_0->nal_unit_type != NAL_CRA_NUT) {",
"if (VAR_0->sps->width != VAR_4->width || VAR_0->sps->height != VAR_4->height ||\nVAR_0->sps->temporal_layer[VAR_0->sps->max_sub_layers - 1].max_dec_pic_buffering !=\nVAR_4->temporal_layer[VAR_4->max_sub_layers - 1].max_dec_pic_buffering)\nsh->no_output_of_prior_pics_flag = 0;",
"}",
"ff_hevc_clear_refs(VAR_0);",
"VAR_3 = set_sps(VAR_0, VAR_0->sps, AV_PIX_FMT_NONE);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;",
"VAR_0->max_ra = INT_MAX;",
"}",
"sh->dependent_slice_segment_flag = 0;",
"if (!sh->first_slice_in_pic_flag) {",
"int VAR_5;",
"if (VAR_0->pps->dependent_slice_segments_enabled_flag)\nsh->dependent_slice_segment_flag = get_bits1(gb);",
"VAR_5 = av_ceil_log2(VAR_0->sps->ctb_width *\nVAR_0->sps->ctb_height);",
"sh->slice_segment_addr = get_bits(gb, VAR_5);",
"if (sh->slice_segment_addr >= VAR_0->sps->ctb_width * VAR_0->sps->ctb_height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid slice segment address: %u.\\n\",\nsh->slice_segment_addr);",
"return AVERROR_INVALIDDATA;",
"}",
"if (!sh->dependent_slice_segment_flag) {",
"sh->slice_addr = sh->slice_segment_addr;",
"VAR_0->slice_idx++;",
"}",
"} else {",
"sh->slice_segment_addr = sh->slice_addr = 0;",
"VAR_0->slice_idx = 0;",
"VAR_0->slice_initialized = 0;",
"}",
"if (!sh->dependent_slice_segment_flag) {",
"VAR_0->slice_initialized = 0;",
"for (VAR_1 = 0; VAR_1 < VAR_0->pps->num_extra_slice_header_bits; VAR_1++)",
"skip_bits(gb, 1);",
"sh->slice_type = get_ue_golomb_long(gb);",
"if (!(sh->slice_type == I_SLICE ||\nsh->slice_type == P_SLICE ||\nsh->slice_type == B_SLICE)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown slice type: %d.\\n\",\nsh->slice_type);",
"return AVERROR_INVALIDDATA;",
"}",
"if (IS_IRAP(VAR_0) && sh->slice_type != I_SLICE) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Inter slices in an IRAP frame.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"sh->pic_output_flag = 1;",
"if (VAR_0->pps->output_flag_present_flag)\nsh->pic_output_flag = get_bits1(gb);",
"if (VAR_0->sps->separate_colour_plane_flag)\nsh->colour_plane_id = get_bits(gb, 2);",
"if (!IS_IDR(VAR_0)) {",
"int VAR_6;",
"sh->pic_order_cnt_lsb = get_bits(gb, VAR_0->sps->log2_max_poc_lsb);",
"VAR_6 = ff_hevc_compute_poc(VAR_0, sh->pic_order_cnt_lsb);",
"if (!sh->first_slice_in_pic_flag && VAR_6 != VAR_0->VAR_6) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Ignoring POC change between slices: %d -> %d\\n\", VAR_0->VAR_6, VAR_6);",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"VAR_6 = VAR_0->VAR_6;",
"}",
"VAR_0->VAR_6 = VAR_6;",
"sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);",
"if (!sh->short_term_ref_pic_set_sps_flag) {",
"int VAR_7 = get_bits_left(gb);",
"VAR_3 = ff_hevc_decode_short_term_rps(VAR_0, &sh->slice_rps, VAR_0->sps, 1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"sh->short_term_ref_pic_set_size = VAR_7 - get_bits_left(gb);",
"sh->short_term_rps = &sh->slice_rps;",
"} else {",
"int VAR_8, VAR_9;",
"if (!VAR_0->sps->nb_st_rps) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"No ref lists in the SPS.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_8 = av_ceil_log2(VAR_0->sps->nb_st_rps);",
"VAR_9 = VAR_8 > 0 ? get_bits(gb, VAR_8) : 0;",
"sh->short_term_rps = &VAR_0->sps->st_rps[VAR_9];",
"}",
"VAR_3 = decode_lt_rps(VAR_0, &sh->long_term_rps, gb);",
"if (VAR_3 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid long term RPS.\\n\");",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->sps->sps_temporal_mvp_enabled_flag)\nsh->slice_temporal_mvp_enabled_flag = get_bits1(gb);",
"else\nsh->slice_temporal_mvp_enabled_flag = 0;",
"} else {",
"VAR_0->sh.short_term_rps = NULL;",
"VAR_0->VAR_6 = 0;",
"}",
"if (VAR_0->temporal_id == 0 &&\nVAR_0->nal_unit_type != NAL_TRAIL_N &&\nVAR_0->nal_unit_type != NAL_TSA_N &&\nVAR_0->nal_unit_type != NAL_STSA_N &&\nVAR_0->nal_unit_type != NAL_RADL_N &&\nVAR_0->nal_unit_type != NAL_RADL_R &&\nVAR_0->nal_unit_type != NAL_RASL_N &&\nVAR_0->nal_unit_type != NAL_RASL_R)\nVAR_0->pocTid0 = VAR_0->VAR_6;",
"if (VAR_0->sps->sao_enabled) {",
"sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);",
"if (VAR_0->sps->chroma_format_idc) {",
"sh->slice_sample_adaptive_offset_flag[1] =\nsh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);",
"}",
"} else {",
"sh->slice_sample_adaptive_offset_flag[0] = 0;",
"sh->slice_sample_adaptive_offset_flag[1] = 0;",
"sh->slice_sample_adaptive_offset_flag[2] = 0;",
"}",
"sh->VAR_10[L0] = sh->VAR_10[L1] = 0;",
"if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {",
"int VAR_10;",
"sh->VAR_10[L0] = VAR_0->pps->num_ref_idx_l0_default_active;",
"if (sh->slice_type == B_SLICE)\nsh->VAR_10[L1] = VAR_0->pps->num_ref_idx_l1_default_active;",
"if (get_bits1(gb)) {",
"sh->VAR_10[L0] = get_ue_golomb_long(gb) + 1;",
"if (sh->slice_type == B_SLICE)\nsh->VAR_10[L1] = get_ue_golomb_long(gb) + 1;",
"}",
"if (sh->VAR_10[L0] > MAX_REFS || sh->VAR_10[L1] > MAX_REFS) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Too many refs: %d/%d.\\n\",\nsh->VAR_10[L0], sh->VAR_10[L1]);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->rpl_modification_flag[0] = 0;",
"sh->rpl_modification_flag[1] = 0;",
"VAR_10 = ff_hevc_frame_nb_refs(VAR_0);",
"if (!VAR_10) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Zero refs for a frame with P or B slices.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->pps->lists_modification_present_flag && VAR_10 > 1) {",
"sh->rpl_modification_flag[0] = get_bits1(gb);",
"if (sh->rpl_modification_flag[0]) {",
"for (VAR_1 = 0; VAR_1 < sh->VAR_10[L0]; VAR_1++)",
"sh->list_entry_lx[0][VAR_1] = get_bits(gb, av_ceil_log2(VAR_10));",
"}",
"if (sh->slice_type == B_SLICE) {",
"sh->rpl_modification_flag[1] = get_bits1(gb);",
"if (sh->rpl_modification_flag[1] == 1)\nfor (VAR_1 = 0; VAR_1 < sh->VAR_10[L1]; VAR_1++)",
"sh->list_entry_lx[1][VAR_1] = get_bits(gb, av_ceil_log2(VAR_10));",
"}",
"}",
"if (sh->slice_type == B_SLICE)\nsh->mvd_l1_zero_flag = get_bits1(gb);",
"if (VAR_0->pps->cabac_init_present_flag)\nsh->cabac_init_flag = get_bits1(gb);",
"else\nsh->cabac_init_flag = 0;",
"sh->collocated_ref_idx = 0;",
"if (sh->slice_temporal_mvp_enabled_flag) {",
"sh->collocated_list = L0;",
"if (sh->slice_type == B_SLICE)\nsh->collocated_list = !get_bits1(gb);",
"if (sh->VAR_10[sh->collocated_list] > 1) {",
"sh->collocated_ref_idx = get_ue_golomb_long(gb);",
"if (sh->collocated_ref_idx >= sh->VAR_10[sh->collocated_list]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid collocated_ref_idx: %d.\\n\",\nsh->collocated_ref_idx);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"if ((VAR_0->pps->weighted_pred_flag && sh->slice_type == P_SLICE) ||\n(VAR_0->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {",
"pred_weight_table(VAR_0, gb);",
"}",
"sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);",
"if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid number of merging MVP candidates: %d.\\n\",\nsh->max_num_merge_cand);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"sh->slice_qp_delta = get_se_golomb(gb);",
"if (VAR_0->pps->pic_slice_level_chroma_qp_offsets_present_flag) {",
"sh->slice_cb_qp_offset = get_se_golomb(gb);",
"sh->slice_cr_qp_offset = get_se_golomb(gb);",
"} else {",
"sh->slice_cb_qp_offset = 0;",
"sh->slice_cr_qp_offset = 0;",
"}",
"if (VAR_0->pps->chroma_qp_offset_list_enabled_flag)\nsh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);",
"else\nsh->cu_chroma_qp_offset_enabled_flag = 0;",
"if (VAR_0->pps->deblocking_filter_control_present_flag) {",
"int VAR_11 = 0;",
"if (VAR_0->pps->deblocking_filter_override_enabled_flag)\nVAR_11 = get_bits1(gb);",
"if (VAR_11) {",
"sh->disable_deblocking_filter_flag = get_bits1(gb);",
"if (!sh->disable_deblocking_filter_flag) {",
"sh->beta_offset = get_se_golomb(gb) * 2;",
"sh->tc_offset = get_se_golomb(gb) * 2;",
"}",
"} else {",
"sh->disable_deblocking_filter_flag = VAR_0->pps->disable_dbf;",
"sh->beta_offset = VAR_0->pps->beta_offset;",
"sh->tc_offset = VAR_0->pps->tc_offset;",
"}",
"} else {",
"sh->disable_deblocking_filter_flag = 0;",
"sh->beta_offset = 0;",
"sh->tc_offset = 0;",
"}",
"if (VAR_0->pps->seq_loop_filter_across_slices_enabled_flag &&\n(sh->slice_sample_adaptive_offset_flag[0] ||\nsh->slice_sample_adaptive_offset_flag[1] ||\n!sh->disable_deblocking_filter_flag)) {",
"sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);",
"} else {",
"sh->slice_loop_filter_across_slices_enabled_flag = VAR_0->pps->seq_loop_filter_across_slices_enabled_flag;",
"}",
"} else if (!VAR_0->slice_initialized) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Independent slice segment missing.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"sh->VAR_12 = 0;",
"if (VAR_0->pps->tiles_enabled_flag || VAR_0->pps->entropy_coding_sync_enabled_flag) {",
"unsigned VAR_12 = get_ue_golomb_long(gb);",
"if (sh->VAR_12 > get_bits_left(gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_12 %d is invalid\\n\", VAR_12);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->VAR_12 = VAR_12;",
"if (sh->VAR_12 > 0) {",
"int VAR_13 = get_ue_golomb_long(gb) + 1;",
"if (VAR_13 < 1 || VAR_13 > 32) {",
"sh->VAR_12 = 0;",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_13 %d is invalid\\n\", VAR_13);",
"return AVERROR_INVALIDDATA;",
"}",
"av_freep(&sh->entry_point_offset);",
"av_freep(&sh->offset);",
"av_freep(&sh->size);",
"sh->entry_point_offset = av_malloc_array(sh->VAR_12, sizeof(int));",
"sh->offset = av_malloc_array(sh->VAR_12, sizeof(int));",
"sh->size = av_malloc_array(sh->VAR_12, sizeof(int));",
"if (!sh->entry_point_offset || !sh->offset || !sh->size) {",
"sh->VAR_12 = 0;",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Failed to allocate memory\\n\");",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_1 = 0; VAR_1 < sh->VAR_12; VAR_1++) {",
"unsigned val = get_bits_long(gb, VAR_13);",
"sh->entry_point_offset[VAR_1] = val + 1;",
"}",
"if (VAR_0->threads_number > 1 && (VAR_0->pps->num_tile_rows > 1 || VAR_0->pps->num_tile_columns > 1)) {",
"VAR_0->enable_parallel_tiles = 0;",
"VAR_0->threads_number = 1;",
"} else",
"VAR_0->enable_parallel_tiles = 0;",
"} else",
"VAR_0->enable_parallel_tiles = 0;",
"}",
"if (VAR_0->pps->slice_header_extension_present_flag) {",
"unsigned int VAR_14 = get_ue_golomb_long(gb);",
"if (VAR_14*8LL > get_bits_left(gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"too many slice_header_extension_data_bytes\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_14; VAR_1++)",
"skip_bits(gb, 8);",
"}",
"sh->slice_qp = 26U + VAR_0->pps->pic_init_qp_minus26 + sh->slice_qp_delta;",
"if (sh->slice_qp > 51 ||\nsh->slice_qp < -VAR_0->sps->qp_bd_offset) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"The slice_qp %d is outside the valid range \"\n\"[%d, 51].\\n\",\nsh->slice_qp,\n-VAR_0->sps->qp_bd_offset);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->slice_ctb_addr_rs = sh->slice_segment_addr;",
"if (!VAR_0->sh.slice_ctb_addr_rs && VAR_0->sh.dependent_slice_segment_flag) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Impossible slice segment.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (get_bits_left(gb) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Overread slice header by %d bits\\n\", -get_bits_left(gb));",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->HEVClc->first_qp_group = !VAR_0->sh.dependent_slice_segment_flag;",
"if (!VAR_0->pps->cu_qp_delta_enabled_flag)\nVAR_0->HEVClc->qp_y = VAR_0->sh.slice_qp;",
"VAR_0->slice_initialized = 1;",
"VAR_0->HEVClc->tu.cu_qp_offset_cb = 0;",
"VAR_0->HEVClc->tu.cu_qp_offset_cr = 0;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77,
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
115,
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
161
],
[
163
],
[
167
],
[
169,
171,
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197,
199
],
[
203,
205
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287,
289
],
[
291
],
[
295,
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
315,
317,
319,
321,
323,
325,
327,
329,
331
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
367
],
[
369,
371
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
387,
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
427
],
[
429
],
[
431,
433
],
[
435
],
[
437
],
[
439
],
[
443,
445
],
[
449,
451
],
[
453,
455
],
[
459
],
[
461
],
[
463
],
[
465,
467
],
[
471
],
[
473
],
[
475
],
[
477,
479,
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
493,
495
],
[
497
],
[
499
],
[
503
],
[
505
],
[
507,
509,
511
],
[
513
],
[
515
],
[
517
],
[
521
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
541,
543
],
[
545,
547
],
[
551
],
[
553
],
[
557,
559
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
597,
599,
601,
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
623
],
[
625
],
[
627
],
[
631
],
[
633
],
[
635
],
[
637
],
[
641
],
[
643
],
[
645
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
731
],
[
733,
735
],
[
737,
739,
741,
743,
745
],
[
747
],
[
749
],
[
753
],
[
757
],
[
759
],
[
761
],
[
763
],
[
767
],
[
769,
771
],
[
773
],
[
775
],
[
779
],
[
783,
785
],
[
789
],
[
791
],
[
793
],
[
797
],
[
799
]
] |
4,919 | static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
int w, int h, int stride, int color)
{
int x, y, fr, f;
sx = av_clip(sx, 0, w - 1);
sy = av_clip(sy, 0, h - 1);
ex = av_clip(ex, 0, w - 1);
ey = av_clip(ey, 0, h - 1);
buf[sy * stride + sx] += color;
if (FFABS(ex - sx) > FFABS(ey - sy)) {
if (sx > ex) {
FFSWAP(int, sx, ex);
FFSWAP(int, sy, ey);
}
buf += sx + sy * stride;
ex -= sx;
f = ((ey - sy) << 16) / ex;
for (x = 0; x = ex; x++) {
y = (x * f) >> 16;
fr = (x * f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
buf[(y + 1) * stride + x] += (color * fr ) >> 16;
}
} else {
if (sy > ey) {
FFSWAP(int, sx, ex);
FFSWAP(int, sy, ey);
}
buf += sx + sy * stride;
ey -= sy;
if (ey)
f = ((ex - sx) << 16) / ey;
else
f = 0;
for (y = 0; y = ey; y++) {
x = (y * f) >> 16;
fr = (y * f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
buf[y * stride + x + 1] += (color * fr ) >> 16;
}
}
}
| false | FFmpeg | 992b03183819553a73b4f870a710ef500b4eb6d0 | static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
int w, int h, int stride, int color)
{
int x, y, fr, f;
sx = av_clip(sx, 0, w - 1);
sy = av_clip(sy, 0, h - 1);
ex = av_clip(ex, 0, w - 1);
ey = av_clip(ey, 0, h - 1);
buf[sy * stride + sx] += color;
if (FFABS(ex - sx) > FFABS(ey - sy)) {
if (sx > ex) {
FFSWAP(int, sx, ex);
FFSWAP(int, sy, ey);
}
buf += sx + sy * stride;
ex -= sx;
f = ((ey - sy) << 16) / ex;
for (x = 0; x = ex; x++) {
y = (x * f) >> 16;
fr = (x * f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
buf[(y + 1) * stride + x] += (color * fr ) >> 16;
}
} else {
if (sy > ey) {
FFSWAP(int, sx, ex);
FFSWAP(int, sy, ey);
}
buf += sx + sy * stride;
ey -= sy;
if (ey)
f = ((ex - sx) << 16) / ey;
else
f = 0;
for (y = 0; y = ey; y++) {
x = (y * f) >> 16;
fr = (y * f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
buf[y * stride + x + 1] += (color * fr ) >> 16;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4,
int VAR_5, int VAR_6, int VAR_7, int VAR_8)
{
int VAR_9, VAR_10, VAR_11, VAR_12;
VAR_1 = av_clip(VAR_1, 0, VAR_5 - 1);
VAR_2 = av_clip(VAR_2, 0, VAR_6 - 1);
VAR_3 = av_clip(VAR_3, 0, VAR_5 - 1);
VAR_4 = av_clip(VAR_4, 0, VAR_6 - 1);
VAR_0[VAR_2 * VAR_7 + VAR_1] += VAR_8;
if (FFABS(VAR_3 - VAR_1) > FFABS(VAR_4 - VAR_2)) {
if (VAR_1 > VAR_3) {
FFSWAP(int, VAR_1, VAR_3);
FFSWAP(int, VAR_2, VAR_4);
}
VAR_0 += VAR_1 + VAR_2 * VAR_7;
VAR_3 -= VAR_1;
VAR_12 = ((VAR_4 - VAR_2) << 16) / VAR_3;
for (VAR_9 = 0; VAR_9 = VAR_3; VAR_9++) {
VAR_10 = (VAR_9 * VAR_12) >> 16;
VAR_11 = (VAR_9 * VAR_12) & 0xFFFF;
VAR_0[VAR_10 * VAR_7 + VAR_9] += (VAR_8 * (0x10000 - VAR_11)) >> 16;
VAR_0[(VAR_10 + 1) * VAR_7 + VAR_9] += (VAR_8 * VAR_11 ) >> 16;
}
} else {
if (VAR_2 > VAR_4) {
FFSWAP(int, VAR_1, VAR_3);
FFSWAP(int, VAR_2, VAR_4);
}
VAR_0 += VAR_1 + VAR_2 * VAR_7;
VAR_4 -= VAR_2;
if (VAR_4)
VAR_12 = ((VAR_3 - VAR_1) << 16) / VAR_4;
else
VAR_12 = 0;
for (VAR_10 = 0; VAR_10 = VAR_4; VAR_10++) {
VAR_9 = (VAR_10 * VAR_12) >> 16;
VAR_11 = (VAR_10 * VAR_12) & 0xFFFF;
VAR_0[VAR_10 * VAR_7 + VAR_9] += (VAR_8 * (0x10000 - VAR_11)) >> 16;
VAR_0[VAR_10 * VAR_7 + VAR_9 + 1] += (VAR_8 * VAR_11 ) >> 16;
}
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int VAR_8)\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12;",
"VAR_1 = av_clip(VAR_1, 0, VAR_5 - 1);",
"VAR_2 = av_clip(VAR_2, 0, VAR_6 - 1);",
"VAR_3 = av_clip(VAR_3, 0, VAR_5 - 1);",
"VAR_4 = av_clip(VAR_4, 0, VAR_6 - 1);",
"VAR_0[VAR_2 * VAR_7 + VAR_1] += VAR_8;",
"if (FFABS(VAR_3 - VAR_1) > FFABS(VAR_4 - VAR_2)) {",
"if (VAR_1 > VAR_3) {",
"FFSWAP(int, VAR_1, VAR_3);",
"FFSWAP(int, VAR_2, VAR_4);",
"}",
"VAR_0 += VAR_1 + VAR_2 * VAR_7;",
"VAR_3 -= VAR_1;",
"VAR_12 = ((VAR_4 - VAR_2) << 16) / VAR_3;",
"for (VAR_9 = 0; VAR_9 = VAR_3; VAR_9++) {",
"VAR_10 = (VAR_9 * VAR_12) >> 16;",
"VAR_11 = (VAR_9 * VAR_12) & 0xFFFF;",
"VAR_0[VAR_10 * VAR_7 + VAR_9] += (VAR_8 * (0x10000 - VAR_11)) >> 16;",
"VAR_0[(VAR_10 + 1) * VAR_7 + VAR_9] += (VAR_8 * VAR_11 ) >> 16;",
"}",
"} else {",
"if (VAR_2 > VAR_4) {",
"FFSWAP(int, VAR_1, VAR_3);",
"FFSWAP(int, VAR_2, VAR_4);",
"}",
"VAR_0 += VAR_1 + VAR_2 * VAR_7;",
"VAR_4 -= VAR_2;",
"if (VAR_4)\nVAR_12 = ((VAR_3 - VAR_1) << 16) / VAR_4;",
"else\nVAR_12 = 0;",
"for (VAR_10 = 0; VAR_10 = VAR_4; VAR_10++) {",
"VAR_9 = (VAR_10 * VAR_12) >> 16;",
"VAR_11 = (VAR_10 * VAR_12) & 0xFFFF;",
"VAR_0[VAR_10 * VAR_7 + VAR_9] += (VAR_8 * (0x10000 - VAR_11)) >> 16;",
"VAR_0[VAR_10 * VAR_7 + VAR_9 + 1] += (VAR_8 * VAR_11 ) >> 16;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
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
]
] |
4,920 | static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
QEMUIOVector *qiov, bool is_write,
BdrvRequestFlags flags)
{
Coroutine *co;
RwCo rwco = {
.bs = bs,
.offset = offset,
.qiov = qiov,
.is_write = is_write,
.ret = NOT_DONE,
.flags = flags,
};
/**
* In sync call context, when the vcpu is blocked, this throttling timer
* will not fire; so the I/O throttling function has to be disabled here
* if it has been enabled.
*/
if (bs->io_limits_enabled) {
fprintf(stderr, "Disabling I/O throttling on '%s' due "
"to synchronous I/O.\n", bdrv_get_device_name(bs));
bdrv_io_limits_disable(bs);
}
if (qemu_in_coroutine()) {
/* Fast-path if already in coroutine context */
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
QEMUIOVector *qiov, bool is_write,
BdrvRequestFlags flags)
{
Coroutine *co;
RwCo rwco = {
.bs = bs,
.offset = offset,
.qiov = qiov,
.is_write = is_write,
.ret = NOT_DONE,
.flags = flags,
};
if (bs->io_limits_enabled) {
fprintf(stderr, "Disabling I/O throttling on '%s' due "
"to synchronous I/O.\n", bdrv_get_device_name(bs));
bdrv_io_limits_disable(bs);
}
if (qemu_in_coroutine()) {
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
QEMUIOVector *VAR_2, bool VAR_3,
BdrvRequestFlags VAR_4)
{
Coroutine *co;
RwCo rwco = {
.VAR_0 = VAR_0,
.VAR_1 = VAR_1,
.VAR_2 = VAR_2,
.VAR_3 = VAR_3,
.ret = NOT_DONE,
.VAR_4 = VAR_4,
};
if (VAR_0->io_limits_enabled) {
fprintf(stderr, "Disabling I/O throttling on '%s' due "
"to synchronous I/O.\n", bdrv_get_device_name(VAR_0));
bdrv_io_limits_disable(VAR_0);
}
if (qemu_in_coroutine()) {
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(VAR_0);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nQEMUIOVector *VAR_2, bool VAR_3,\nBdrvRequestFlags VAR_4)\n{",
"Coroutine *co;",
"RwCo rwco = {",
".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_3 = VAR_3,\n.ret = NOT_DONE,\n.VAR_4 = VAR_4,\n};",
"if (VAR_0->io_limits_enabled) {",
"fprintf(stderr, \"Disabling I/O throttling on '%s' due \"\n\"to synchronous I/O.\\n\", bdrv_get_device_name(VAR_0));",
"bdrv_io_limits_disable(VAR_0);",
"}",
"if (qemu_in_coroutine()) {",
"bdrv_rw_co_entry(&rwco);",
"} else {",
"AioContext *aio_context = bdrv_get_aio_context(VAR_0);",
"co = qemu_coroutine_create(bdrv_rw_co_entry);",
"qemu_coroutine_enter(co, &rwco);",
"while (rwco.ret == NOT_DONE) {",
"aio_poll(aio_context, true);",
"}",
"}",
"return rwco.ret;",
"}"
] | [
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
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
4,921 | static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
unsigned size)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
uint16_t ret;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (offset) {
case 0x00: /* DRR2 */
if (((s->rcr[0] >> 5) & 7) < 3) /* RWDLEN1 */
return 0x0000;
/* Fall through. */
case 0x02: /* DRR1 */
if (s->rx_req < 2) {
printf("%s: Rx FIFO underrun\n", __FUNCTION__);
omap_mcbsp_rx_done(s);
} else {
s->tx_req -= 2;
if (s->codec && s->codec->in.len >= 2) {
ret = s->codec->in.fifo[s->codec->in.start ++] << 8;
ret |= s->codec->in.fifo[s->codec->in.start ++];
s->codec->in.len -= 2;
} else
ret = 0x0000;
if (!s->tx_req)
omap_mcbsp_rx_done(s);
return ret;
}
return 0x0000;
case 0x04: /* DXR2 */
case 0x06: /* DXR1 */
return 0x0000;
case 0x08: /* SPCR2 */
return s->spcr[1];
case 0x0a: /* SPCR1 */
return s->spcr[0];
case 0x0c: /* RCR2 */
return s->rcr[1];
case 0x0e: /* RCR1 */
return s->rcr[0];
case 0x10: /* XCR2 */
return s->xcr[1];
case 0x12: /* XCR1 */
return s->xcr[0];
case 0x14: /* SRGR2 */
return s->srgr[1];
case 0x16: /* SRGR1 */
return s->srgr[0];
case 0x18: /* MCR2 */
return s->mcr[1];
case 0x1a: /* MCR1 */
return s->mcr[0];
case 0x1c: /* RCERA */
return s->rcer[0];
case 0x1e: /* RCERB */
return s->rcer[1];
case 0x20: /* XCERA */
return s->xcer[0];
case 0x22: /* XCERB */
return s->xcer[1];
case 0x24: /* PCR0 */
return s->pcr;
case 0x26: /* RCERC */
return s->rcer[2];
case 0x28: /* RCERD */
return s->rcer[3];
case 0x2a: /* XCERC */
return s->xcer[2];
case 0x2c: /* XCERD */
return s->xcer[3];
case 0x2e: /* RCERE */
return s->rcer[4];
case 0x30: /* RCERF */
return s->rcer[5];
case 0x32: /* XCERE */
return s->xcer[4];
case 0x34: /* XCERF */
return s->xcer[5];
case 0x36: /* RCERG */
return s->rcer[6];
case 0x38: /* RCERH */
return s->rcer[7];
case 0x3a: /* XCERG */
return s->xcer[6];
case 0x3c: /* XCERH */
return s->xcer[7];
}
OMAP_BAD_REG(addr);
return 0;
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
unsigned size)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
uint16_t ret;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (offset) {
case 0x00:
if (((s->rcr[0] >> 5) & 7) < 3)
return 0x0000;
case 0x02:
if (s->rx_req < 2) {
printf("%s: Rx FIFO underrun\n", __FUNCTION__);
omap_mcbsp_rx_done(s);
} else {
s->tx_req -= 2;
if (s->codec && s->codec->in.len >= 2) {
ret = s->codec->in.fifo[s->codec->in.start ++] << 8;
ret |= s->codec->in.fifo[s->codec->in.start ++];
s->codec->in.len -= 2;
} else
ret = 0x0000;
if (!s->tx_req)
omap_mcbsp_rx_done(s);
return ret;
}
return 0x0000;
case 0x04:
case 0x06:
return 0x0000;
case 0x08:
return s->spcr[1];
case 0x0a:
return s->spcr[0];
case 0x0c:
return s->rcr[1];
case 0x0e:
return s->rcr[0];
case 0x10:
return s->xcr[1];
case 0x12:
return s->xcr[0];
case 0x14:
return s->srgr[1];
case 0x16:
return s->srgr[0];
case 0x18:
return s->mcr[1];
case 0x1a:
return s->mcr[0];
case 0x1c:
return s->rcer[0];
case 0x1e:
return s->rcer[1];
case 0x20:
return s->xcer[0];
case 0x22:
return s->xcer[1];
case 0x24:
return s->pcr;
case 0x26:
return s->rcer[2];
case 0x28:
return s->rcer[3];
case 0x2a:
return s->xcer[2];
case 0x2c:
return s->xcer[3];
case 0x2e:
return s->rcer[4];
case 0x30:
return s->rcer[5];
case 0x32:
return s->xcer[4];
case 0x34:
return s->xcer[5];
case 0x36:
return s->rcer[6];
case 0x38:
return s->rcer[7];
case 0x3a:
return s->xcer[6];
case 0x3c:
return s->xcer[7];
}
OMAP_BAD_REG(addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
struct omap_mcbsp_s *VAR_0 = (struct omap_mcbsp_s *) opaque;
int VAR_1 = addr & OMAP_MPUI_REG_MASK;
uint16_t ret;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (VAR_1) {
case 0x00:
if (((VAR_0->rcr[0] >> 5) & 7) < 3)
return 0x0000;
case 0x02:
if (VAR_0->rx_req < 2) {
printf("%VAR_0: Rx FIFO underrun\n", __FUNCTION__);
omap_mcbsp_rx_done(VAR_0);
} else {
VAR_0->tx_req -= 2;
if (VAR_0->codec && VAR_0->codec->in.len >= 2) {
ret = VAR_0->codec->in.fifo[VAR_0->codec->in.start ++] << 8;
ret |= VAR_0->codec->in.fifo[VAR_0->codec->in.start ++];
VAR_0->codec->in.len -= 2;
} else
ret = 0x0000;
if (!VAR_0->tx_req)
omap_mcbsp_rx_done(VAR_0);
return ret;
}
return 0x0000;
case 0x04:
case 0x06:
return 0x0000;
case 0x08:
return VAR_0->spcr[1];
case 0x0a:
return VAR_0->spcr[0];
case 0x0c:
return VAR_0->rcr[1];
case 0x0e:
return VAR_0->rcr[0];
case 0x10:
return VAR_0->xcr[1];
case 0x12:
return VAR_0->xcr[0];
case 0x14:
return VAR_0->srgr[1];
case 0x16:
return VAR_0->srgr[0];
case 0x18:
return VAR_0->mcr[1];
case 0x1a:
return VAR_0->mcr[0];
case 0x1c:
return VAR_0->rcer[0];
case 0x1e:
return VAR_0->rcer[1];
case 0x20:
return VAR_0->xcer[0];
case 0x22:
return VAR_0->xcer[1];
case 0x24:
return VAR_0->pcr;
case 0x26:
return VAR_0->rcer[2];
case 0x28:
return VAR_0->rcer[3];
case 0x2a:
return VAR_0->xcer[2];
case 0x2c:
return VAR_0->xcer[3];
case 0x2e:
return VAR_0->rcer[4];
case 0x30:
return VAR_0->rcer[5];
case 0x32:
return VAR_0->xcer[4];
case 0x34:
return VAR_0->xcer[5];
case 0x36:
return VAR_0->rcer[6];
case 0x38:
return VAR_0->rcer[7];
case 0x3a:
return VAR_0->xcer[6];
case 0x3c:
return VAR_0->xcer[7];
}
OMAP_BAD_REG(addr);
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"struct omap_mcbsp_s *VAR_0 = (struct omap_mcbsp_s *) opaque;",
"int VAR_1 = addr & OMAP_MPUI_REG_MASK;",
"uint16_t ret;",
"if (size != 2) {",
"return omap_badwidth_read16(opaque, addr);",
"}",
"switch (VAR_1) {",
"case 0x00:\nif (((VAR_0->rcr[0] >> 5) & 7) < 3)\nreturn 0x0000;",
"case 0x02:\nif (VAR_0->rx_req < 2) {",
"printf(\"%VAR_0: Rx FIFO underrun\\n\", __FUNCTION__);",
"omap_mcbsp_rx_done(VAR_0);",
"} else {",
"VAR_0->tx_req -= 2;",
"if (VAR_0->codec && VAR_0->codec->in.len >= 2) {",
"ret = VAR_0->codec->in.fifo[VAR_0->codec->in.start ++] << 8;",
"ret |= VAR_0->codec->in.fifo[VAR_0->codec->in.start ++];",
"VAR_0->codec->in.len -= 2;",
"} else",
"ret = 0x0000;",
"if (!VAR_0->tx_req)\nomap_mcbsp_rx_done(VAR_0);",
"return ret;",
"}",
"return 0x0000;",
"case 0x04:\ncase 0x06:\nreturn 0x0000;",
"case 0x08:\nreturn VAR_0->spcr[1];",
"case 0x0a:\nreturn VAR_0->spcr[0];",
"case 0x0c:\nreturn VAR_0->rcr[1];",
"case 0x0e:\nreturn VAR_0->rcr[0];",
"case 0x10:\nreturn VAR_0->xcr[1];",
"case 0x12:\nreturn VAR_0->xcr[0];",
"case 0x14:\nreturn VAR_0->srgr[1];",
"case 0x16:\nreturn VAR_0->srgr[0];",
"case 0x18:\nreturn VAR_0->mcr[1];",
"case 0x1a:\nreturn VAR_0->mcr[0];",
"case 0x1c:\nreturn VAR_0->rcer[0];",
"case 0x1e:\nreturn VAR_0->rcer[1];",
"case 0x20:\nreturn VAR_0->xcer[0];",
"case 0x22:\nreturn VAR_0->xcer[1];",
"case 0x24:\nreturn VAR_0->pcr;",
"case 0x26:\nreturn VAR_0->rcer[2];",
"case 0x28:\nreturn VAR_0->rcer[3];",
"case 0x2a:\nreturn VAR_0->xcer[2];",
"case 0x2c:\nreturn VAR_0->xcer[3];",
"case 0x2e:\nreturn VAR_0->rcer[4];",
"case 0x30:\nreturn VAR_0->rcer[5];",
"case 0x32:\nreturn VAR_0->xcer[4];",
"case 0x34:\nreturn VAR_0->xcer[5];",
"case 0x36:\nreturn VAR_0->rcer[6];",
"case 0x38:\nreturn VAR_0->rcer[7];",
"case 0x3a:\nreturn VAR_0->xcer[6];",
"case 0x3c:\nreturn VAR_0->xcer[7];",
"}",
"OMAP_BAD_REG(addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69,
71,
73
],
[
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
],
[
189
],
[
191
],
[
193
]
] |
4,922 | static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
{
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
Error *local_err = NULL;
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
if (!GetPwrCapabilities(&sys_pwr_caps)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to determine guest suspend capabilities");
goto out;
}
switch (mode) {
case GUEST_SUSPEND_MODE_DISK:
if (!sys_pwr_caps.SystemS4) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-disk not supported by OS");
}
break;
case GUEST_SUSPEND_MODE_RAM:
if (!sys_pwr_caps.SystemS3) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-ram not supported by OS");
}
break;
default:
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
"GuestSuspendMode");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
{
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
Error *local_err = NULL;
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
if (!GetPwrCapabilities(&sys_pwr_caps)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to determine guest suspend capabilities");
goto out;
}
switch (mode) {
case GUEST_SUSPEND_MODE_DISK:
if (!sys_pwr_caps.SystemS4) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-disk not supported by OS");
}
break;
case GUEST_SUSPEND_MODE_RAM:
if (!sys_pwr_caps.SystemS3) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-ram not supported by OS");
}
break;
default:
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
"GuestSuspendMode");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GuestSuspendMode VAR_0, Error **VAR_1)
{
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
Error *local_err = NULL;
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
if (!GetPwrCapabilities(&sys_pwr_caps)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to determine guest suspend capabilities");
goto out;
}
switch (VAR_0) {
case GUEST_SUSPEND_MODE_DISK:
if (!sys_pwr_caps.SystemS4) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-disk not supported by OS");
}
break;
case GUEST_SUSPEND_MODE_RAM:
if (!sys_pwr_caps.SystemS3) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"suspend-to-ram not supported by OS");
}
break;
default:
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "VAR_0",
"GuestSuspendMode");
}
out:
if (local_err) {
error_propagate(VAR_1, local_err);
}
}
| [
"static void FUNC_0(GuestSuspendMode VAR_0, Error **VAR_1)\n{",
"SYSTEM_POWER_CAPABILITIES sys_pwr_caps;",
"Error *local_err = NULL;",
"ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));",
"if (!GetPwrCapabilities(&sys_pwr_caps)) {",
"error_setg(&local_err, QERR_QGA_COMMAND_FAILED,\n\"failed to determine guest suspend capabilities\");",
"goto out;",
"}",
"switch (VAR_0) {",
"case GUEST_SUSPEND_MODE_DISK:\nif (!sys_pwr_caps.SystemS4) {",
"error_setg(&local_err, QERR_QGA_COMMAND_FAILED,\n\"suspend-to-disk not supported by OS\");",
"}",
"break;",
"case GUEST_SUSPEND_MODE_RAM:\nif (!sys_pwr_caps.SystemS3) {",
"error_setg(&local_err, QERR_QGA_COMMAND_FAILED,\n\"suspend-to-ram not supported by OS\");",
"}",
"break;",
"default:\nerror_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, \"VAR_0\",\n\"GuestSuspendMode\");",
"}",
"out:\nif (local_err) {",
"error_propagate(VAR_1, local_err);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69
]
] |
4,923 | av_cold static int lavfi_read_header(AVFormatContext *avctx)
{
LavfiContext *lavfi = avctx->priv_data;
AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;
AVFilter *buffersink, *abuffersink;
int *pix_fmts = create_all_formats(AV_PIX_FMT_NB);
enum AVMediaType type;
int ret = 0, i, n;
#define FAIL(ERR) { ret = ERR; goto end; }
if (!pix_fmts)
FAIL(AVERROR(ENOMEM));
avfilter_register_all();
buffersink = avfilter_get_by_name("buffersink");
abuffersink = avfilter_get_by_name("abuffersink");
if (lavfi->graph_filename && lavfi->graph_str) {
av_log(avctx, AV_LOG_ERROR,
"Only one of the graph or graph_file options must be specified\n");
FAIL(AVERROR(EINVAL));
}
if (lavfi->graph_filename) {
uint8_t *file_buf, *graph_buf;
size_t file_bufsize;
ret = av_file_map(lavfi->graph_filename,
&file_buf, &file_bufsize, 0, avctx);
if (ret < 0)
goto end;
/* create a 0-terminated string based on the read file */
graph_buf = av_malloc(file_bufsize + 1);
if (!graph_buf) {
av_file_unmap(file_buf, file_bufsize);
FAIL(AVERROR(ENOMEM));
}
memcpy(graph_buf, file_buf, file_bufsize);
graph_buf[file_bufsize] = 0;
av_file_unmap(file_buf, file_bufsize);
lavfi->graph_str = graph_buf;
}
if (!lavfi->graph_str)
lavfi->graph_str = av_strdup(avctx->filename);
/* parse the graph, create a stream for each open output */
if (!(lavfi->graph = avfilter_graph_alloc()))
FAIL(AVERROR(ENOMEM));
if ((ret = avfilter_graph_parse(lavfi->graph, lavfi->graph_str,
&input_links, &output_links, avctx)) < 0)
FAIL(ret);
if (input_links) {
av_log(avctx, AV_LOG_ERROR,
"Open inputs in the filtergraph are not acceptable\n");
FAIL(AVERROR(EINVAL));
}
/* count the outputs */
for (n = 0, inout = output_links; inout; n++, inout = inout->next);
if (!(lavfi->sink_stream_map = av_malloc(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->sink_eof = av_mallocz(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->stream_sink_map = av_malloc(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
for (i = 0; i < n; i++)
lavfi->stream_sink_map[i] = -1;
/* parse the output link names - they need to be of the form out0, out1, ...
* create a mapping between them and the streams */
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
int stream_idx;
if (!strcmp(inout->name, "out"))
stream_idx = 0;
else if (sscanf(inout->name, "out%d\n", &stream_idx) != 1) {
av_log(avctx, AV_LOG_ERROR,
"Invalid outpad name '%s'\n", inout->name);
FAIL(AVERROR(EINVAL));
}
if ((unsigned)stream_idx >= n) {
av_log(avctx, AV_LOG_ERROR,
"Invalid index was specified in output '%s', "
"must be a non-negative value < %d\n",
inout->name, n);
FAIL(AVERROR(EINVAL));
}
/* is an audio or video output? */
type = inout->filter_ctx->output_pads[inout->pad_idx].type;
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
av_log(avctx, AV_LOG_ERROR,
"Output '%s' is not a video or audio output, not yet supported\n", inout->name);
FAIL(AVERROR(EINVAL));
}
if (lavfi->stream_sink_map[stream_idx] != -1) {
av_log(avctx, AV_LOG_ERROR,
"An output with stream index %d was already specified\n",
stream_idx);
FAIL(AVERROR(EINVAL));
}
lavfi->sink_stream_map[i] = stream_idx;
lavfi->stream_sink_map[stream_idx] = i;
}
/* for each open output create a corresponding stream */
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
AVStream *st;
if (!(st = avformat_new_stream(avctx, NULL)))
FAIL(AVERROR(ENOMEM));
st->id = i;
}
/* create a sink for each output and connect them to the graph */
lavfi->sinks = av_malloc(sizeof(AVFilterContext *) * avctx->nb_streams);
if (!lavfi->sinks)
FAIL(AVERROR(ENOMEM));
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
AVFilterContext *sink;
type = inout->filter_ctx->output_pads[inout->pad_idx].type;
if (type == AVMEDIA_TYPE_VIDEO && ! buffersink ||
type == AVMEDIA_TYPE_AUDIO && ! abuffersink) {
av_log(avctx, AV_LOG_ERROR, "Missing required buffersink filter, aborting.\n");
FAIL(AVERROR_FILTER_NOT_FOUND);
}
if (type == AVMEDIA_TYPE_VIDEO) {
ret = avfilter_graph_create_filter(&sink, buffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (ret < 0)
goto end;
} else if (type == AVMEDIA_TYPE_AUDIO) {
enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8,
AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_FLT,
AV_SAMPLE_FMT_DBL, -1 };
ret = avfilter_graph_create_filter(&sink, abuffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (ret < 0)
goto end;
}
lavfi->sinks[i] = sink;
if ((ret = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)
FAIL(ret);
}
/* configure the graph */
if ((ret = avfilter_graph_config(lavfi->graph, avctx)) < 0)
FAIL(ret);
if (lavfi->dump_graph) {
char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
fputs(dump, stderr);
fflush(stderr);
av_free(dump);
}
/* fill each stream with the information in the corresponding sink */
for (i = 0; i < avctx->nb_streams; i++) {
AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0];
AVStream *st = avctx->streams[i];
st->codec->codec_type = link->type;
avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);
if (link->type == AVMEDIA_TYPE_VIDEO) {
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = link->format;
st->codec->time_base = link->time_base;
st->codec->width = link->w;
st->codec->height = link->h;
st ->sample_aspect_ratio =
st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
avctx->probesize = FFMAX(avctx->probesize,
link->w * link->h *
av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *
30);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
st->codec->codec_id = av_get_pcm_codec(link->format, -1);
st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout);
st->codec->sample_fmt = link->format;
st->codec->sample_rate = link->sample_rate;
st->codec->time_base = link->time_base;
st->codec->channel_layout = link->channel_layout;
if (st->codec->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\n",
av_get_sample_fmt_name(link->format));
}
}
if (!(lavfi->decoded_frame = av_frame_alloc()))
FAIL(AVERROR(ENOMEM));
end:
av_free(pix_fmts);
avfilter_inout_free(&input_links);
avfilter_inout_free(&output_links);
if (ret < 0)
lavfi_read_close(avctx);
return ret;
}
| false | FFmpeg | 9b595e86e342e0e39c5ddf9020286cae258b9965 | av_cold static int lavfi_read_header(AVFormatContext *avctx)
{
LavfiContext *lavfi = avctx->priv_data;
AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;
AVFilter *buffersink, *abuffersink;
int *pix_fmts = create_all_formats(AV_PIX_FMT_NB);
enum AVMediaType type;
int ret = 0, i, n;
#define FAIL(ERR) { ret = ERR; goto end; }
if (!pix_fmts)
FAIL(AVERROR(ENOMEM));
avfilter_register_all();
buffersink = avfilter_get_by_name("buffersink");
abuffersink = avfilter_get_by_name("abuffersink");
if (lavfi->graph_filename && lavfi->graph_str) {
av_log(avctx, AV_LOG_ERROR,
"Only one of the graph or graph_file options must be specified\n");
FAIL(AVERROR(EINVAL));
}
if (lavfi->graph_filename) {
uint8_t *file_buf, *graph_buf;
size_t file_bufsize;
ret = av_file_map(lavfi->graph_filename,
&file_buf, &file_bufsize, 0, avctx);
if (ret < 0)
goto end;
graph_buf = av_malloc(file_bufsize + 1);
if (!graph_buf) {
av_file_unmap(file_buf, file_bufsize);
FAIL(AVERROR(ENOMEM));
}
memcpy(graph_buf, file_buf, file_bufsize);
graph_buf[file_bufsize] = 0;
av_file_unmap(file_buf, file_bufsize);
lavfi->graph_str = graph_buf;
}
if (!lavfi->graph_str)
lavfi->graph_str = av_strdup(avctx->filename);
if (!(lavfi->graph = avfilter_graph_alloc()))
FAIL(AVERROR(ENOMEM));
if ((ret = avfilter_graph_parse(lavfi->graph, lavfi->graph_str,
&input_links, &output_links, avctx)) < 0)
FAIL(ret);
if (input_links) {
av_log(avctx, AV_LOG_ERROR,
"Open inputs in the filtergraph are not acceptable\n");
FAIL(AVERROR(EINVAL));
}
for (n = 0, inout = output_links; inout; n++, inout = inout->next);
if (!(lavfi->sink_stream_map = av_malloc(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->sink_eof = av_mallocz(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->stream_sink_map = av_malloc(sizeof(int) * n)))
FAIL(AVERROR(ENOMEM));
for (i = 0; i < n; i++)
lavfi->stream_sink_map[i] = -1;
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
int stream_idx;
if (!strcmp(inout->name, "out"))
stream_idx = 0;
else if (sscanf(inout->name, "out%d\n", &stream_idx) != 1) {
av_log(avctx, AV_LOG_ERROR,
"Invalid outpad name '%s'\n", inout->name);
FAIL(AVERROR(EINVAL));
}
if ((unsigned)stream_idx >= n) {
av_log(avctx, AV_LOG_ERROR,
"Invalid index was specified in output '%s', "
"must be a non-negative value < %d\n",
inout->name, n);
FAIL(AVERROR(EINVAL));
}
type = inout->filter_ctx->output_pads[inout->pad_idx].type;
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
av_log(avctx, AV_LOG_ERROR,
"Output '%s' is not a video or audio output, not yet supported\n", inout->name);
FAIL(AVERROR(EINVAL));
}
if (lavfi->stream_sink_map[stream_idx] != -1) {
av_log(avctx, AV_LOG_ERROR,
"An output with stream index %d was already specified\n",
stream_idx);
FAIL(AVERROR(EINVAL));
}
lavfi->sink_stream_map[i] = stream_idx;
lavfi->stream_sink_map[stream_idx] = i;
}
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
AVStream *st;
if (!(st = avformat_new_stream(avctx, NULL)))
FAIL(AVERROR(ENOMEM));
st->id = i;
}
lavfi->sinks = av_malloc(sizeof(AVFilterContext *) * avctx->nb_streams);
if (!lavfi->sinks)
FAIL(AVERROR(ENOMEM));
for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
AVFilterContext *sink;
type = inout->filter_ctx->output_pads[inout->pad_idx].type;
if (type == AVMEDIA_TYPE_VIDEO && ! buffersink ||
type == AVMEDIA_TYPE_AUDIO && ! abuffersink) {
av_log(avctx, AV_LOG_ERROR, "Missing required buffersink filter, aborting.\n");
FAIL(AVERROR_FILTER_NOT_FOUND);
}
if (type == AVMEDIA_TYPE_VIDEO) {
ret = avfilter_graph_create_filter(&sink, buffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (ret < 0)
goto end;
} else if (type == AVMEDIA_TYPE_AUDIO) {
enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8,
AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_FLT,
AV_SAMPLE_FMT_DBL, -1 };
ret = avfilter_graph_create_filter(&sink, abuffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (ret < 0)
goto end;
}
lavfi->sinks[i] = sink;
if ((ret = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)
FAIL(ret);
}
if ((ret = avfilter_graph_config(lavfi->graph, avctx)) < 0)
FAIL(ret);
if (lavfi->dump_graph) {
char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
fputs(dump, stderr);
fflush(stderr);
av_free(dump);
}
for (i = 0; i < avctx->nb_streams; i++) {
AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0];
AVStream *st = avctx->streams[i];
st->codec->codec_type = link->type;
avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);
if (link->type == AVMEDIA_TYPE_VIDEO) {
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = link->format;
st->codec->time_base = link->time_base;
st->codec->width = link->w;
st->codec->height = link->h;
st ->sample_aspect_ratio =
st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
avctx->probesize = FFMAX(avctx->probesize,
link->w * link->h *
av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *
30);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
st->codec->codec_id = av_get_pcm_codec(link->format, -1);
st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout);
st->codec->sample_fmt = link->format;
st->codec->sample_rate = link->sample_rate;
st->codec->time_base = link->time_base;
st->codec->channel_layout = link->channel_layout;
if (st->codec->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\n",
av_get_sample_fmt_name(link->format));
}
}
if (!(lavfi->decoded_frame = av_frame_alloc()))
FAIL(AVERROR(ENOMEM));
end:
av_free(pix_fmts);
avfilter_inout_free(&input_links);
avfilter_inout_free(&output_links);
if (ret < 0)
lavfi_read_close(avctx);
return ret;
}
| {
"code": [],
"line_no": []
} | av_cold static int FUNC_0(AVFormatContext *avctx)
{
LavfiContext *lavfi = avctx->priv_data;
AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;
AVFilter *buffersink, *abuffersink;
int *VAR_0 = create_all_formats(AV_PIX_FMT_NB);
enum AVMediaType VAR_1;
int VAR_2 = 0, VAR_3, VAR_4;
#define FAIL(ERR) { VAR_2 = ERR; goto end; }
if (!VAR_0)
FAIL(AVERROR(ENOMEM));
avfilter_register_all();
buffersink = avfilter_get_by_name("buffersink");
abuffersink = avfilter_get_by_name("abuffersink");
if (lavfi->graph_filename && lavfi->graph_str) {
av_log(avctx, AV_LOG_ERROR,
"Only one of the graph or graph_file options must be specified\VAR_4");
FAIL(AVERROR(EINVAL));
}
if (lavfi->graph_filename) {
uint8_t *file_buf, *graph_buf;
size_t file_bufsize;
VAR_2 = av_file_map(lavfi->graph_filename,
&file_buf, &file_bufsize, 0, avctx);
if (VAR_2 < 0)
goto end;
graph_buf = av_malloc(file_bufsize + 1);
if (!graph_buf) {
av_file_unmap(file_buf, file_bufsize);
FAIL(AVERROR(ENOMEM));
}
memcpy(graph_buf, file_buf, file_bufsize);
graph_buf[file_bufsize] = 0;
av_file_unmap(file_buf, file_bufsize);
lavfi->graph_str = graph_buf;
}
if (!lavfi->graph_str)
lavfi->graph_str = av_strdup(avctx->filename);
if (!(lavfi->graph = avfilter_graph_alloc()))
FAIL(AVERROR(ENOMEM));
if ((VAR_2 = avfilter_graph_parse(lavfi->graph, lavfi->graph_str,
&input_links, &output_links, avctx)) < 0)
FAIL(VAR_2);
if (input_links) {
av_log(avctx, AV_LOG_ERROR,
"Open inputs in the filtergraph are not acceptable\VAR_4");
FAIL(AVERROR(EINVAL));
}
for (VAR_4 = 0, inout = output_links; inout; VAR_4++, inout = inout->next);
if (!(lavfi->sink_stream_map = av_malloc(sizeof(int) * VAR_4)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->sink_eof = av_mallocz(sizeof(int) * VAR_4)))
FAIL(AVERROR(ENOMEM));
if (!(lavfi->stream_sink_map = av_malloc(sizeof(int) * VAR_4)))
FAIL(AVERROR(ENOMEM));
for (VAR_3 = 0; VAR_3 < VAR_4; VAR_3++)
lavfi->stream_sink_map[VAR_3] = -1;
for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {
int stream_idx;
if (!strcmp(inout->name, "out"))
stream_idx = 0;
else if (sscanf(inout->name, "out%d\VAR_4", &stream_idx) != 1) {
av_log(avctx, AV_LOG_ERROR,
"Invalid outpad name '%s'\VAR_4", inout->name);
FAIL(AVERROR(EINVAL));
}
if ((unsigned)stream_idx >= VAR_4) {
av_log(avctx, AV_LOG_ERROR,
"Invalid index was specified in output '%s', "
"must be a non-negative value < %d\VAR_4",
inout->name, VAR_4);
FAIL(AVERROR(EINVAL));
}
VAR_1 = inout->filter_ctx->output_pads[inout->pad_idx].VAR_1;
if (VAR_1 != AVMEDIA_TYPE_VIDEO && VAR_1 != AVMEDIA_TYPE_AUDIO) {
av_log(avctx, AV_LOG_ERROR,
"Output '%s' is not a video or audio output, not yet supported\VAR_4", inout->name);
FAIL(AVERROR(EINVAL));
}
if (lavfi->stream_sink_map[stream_idx] != -1) {
av_log(avctx, AV_LOG_ERROR,
"An output with stream index %d was already specified\VAR_4",
stream_idx);
FAIL(AVERROR(EINVAL));
}
lavfi->sink_stream_map[VAR_3] = stream_idx;
lavfi->stream_sink_map[stream_idx] = VAR_3;
}
for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {
AVStream *st;
if (!(st = avformat_new_stream(avctx, NULL)))
FAIL(AVERROR(ENOMEM));
st->id = VAR_3;
}
lavfi->sinks = av_malloc(sizeof(AVFilterContext *) * avctx->nb_streams);
if (!lavfi->sinks)
FAIL(AVERROR(ENOMEM));
for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {
AVFilterContext *sink;
VAR_1 = inout->filter_ctx->output_pads[inout->pad_idx].VAR_1;
if (VAR_1 == AVMEDIA_TYPE_VIDEO && ! buffersink ||
VAR_1 == AVMEDIA_TYPE_AUDIO && ! abuffersink) {
av_log(avctx, AV_LOG_ERROR, "Missing required buffersink filter, aborting.\VAR_4");
FAIL(AVERROR_FILTER_NOT_FOUND);
}
if (VAR_1 == AVMEDIA_TYPE_VIDEO) {
VAR_2 = avfilter_graph_create_filter(&sink, buffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "VAR_0", VAR_0, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (VAR_2 < 0)
goto end;
} else if (VAR_1 == AVMEDIA_TYPE_AUDIO) {
enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8,
AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_FLT,
AV_SAMPLE_FMT_DBL, -1 };
VAR_2 = avfilter_graph_create_filter(&sink, abuffersink,
inout->name, NULL,
NULL, lavfi->graph);
av_opt_set_int_list(sink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (VAR_2 < 0)
goto end;
}
lavfi->sinks[VAR_3] = sink;
if ((VAR_2 = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)
FAIL(VAR_2);
}
if ((VAR_2 = avfilter_graph_config(lavfi->graph, avctx)) < 0)
FAIL(VAR_2);
if (lavfi->dump_graph) {
char *VAR_5 = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
fputs(VAR_5, stderr);
fflush(stderr);
av_free(VAR_5);
}
for (VAR_3 = 0; VAR_3 < avctx->nb_streams; VAR_3++) {
AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[VAR_3]]->inputs[0];
AVStream *st = avctx->streams[VAR_3];
st->codec->codec_type = link->VAR_1;
avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);
if (link->VAR_1 == AVMEDIA_TYPE_VIDEO) {
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = link->format;
st->codec->time_base = link->time_base;
st->codec->width = link->w;
st->codec->height = link->h;
st ->sample_aspect_ratio =
st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
avctx->probesize = FFMAX(avctx->probesize,
link->w * link->h *
av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *
30);
} else if (link->VAR_1 == AVMEDIA_TYPE_AUDIO) {
st->codec->codec_id = av_get_pcm_codec(link->format, -1);
st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout);
st->codec->sample_fmt = link->format;
st->codec->sample_rate = link->sample_rate;
st->codec->time_base = link->time_base;
st->codec->channel_layout = link->channel_layout;
if (st->codec->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\VAR_4",
av_get_sample_fmt_name(link->format));
}
}
if (!(lavfi->decoded_frame = av_frame_alloc()))
FAIL(AVERROR(ENOMEM));
end:
av_free(VAR_0);
avfilter_inout_free(&input_links);
avfilter_inout_free(&output_links);
if (VAR_2 < 0)
lavfi_read_close(avctx);
return VAR_2;
}
| [
"av_cold static int FUNC_0(AVFormatContext *avctx)\n{",
"LavfiContext *lavfi = avctx->priv_data;",
"AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;",
"AVFilter *buffersink, *abuffersink;",
"int *VAR_0 = create_all_formats(AV_PIX_FMT_NB);",
"enum AVMediaType VAR_1;",
"int VAR_2 = 0, VAR_3, VAR_4;",
"#define FAIL(ERR) { VAR_2 = ERR; goto end; }",
"if (!VAR_0)\nFAIL(AVERROR(ENOMEM));",
"avfilter_register_all();",
"buffersink = avfilter_get_by_name(\"buffersink\");",
"abuffersink = avfilter_get_by_name(\"abuffersink\");",
"if (lavfi->graph_filename && lavfi->graph_str) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Only one of the graph or graph_file options must be specified\\VAR_4\");",
"FAIL(AVERROR(EINVAL));",
"}",
"if (lavfi->graph_filename) {",
"uint8_t *file_buf, *graph_buf;",
"size_t file_bufsize;",
"VAR_2 = av_file_map(lavfi->graph_filename,\n&file_buf, &file_bufsize, 0, avctx);",
"if (VAR_2 < 0)\ngoto end;",
"graph_buf = av_malloc(file_bufsize + 1);",
"if (!graph_buf) {",
"av_file_unmap(file_buf, file_bufsize);",
"FAIL(AVERROR(ENOMEM));",
"}",
"memcpy(graph_buf, file_buf, file_bufsize);",
"graph_buf[file_bufsize] = 0;",
"av_file_unmap(file_buf, file_bufsize);",
"lavfi->graph_str = graph_buf;",
"}",
"if (!lavfi->graph_str)\nlavfi->graph_str = av_strdup(avctx->filename);",
"if (!(lavfi->graph = avfilter_graph_alloc()))\nFAIL(AVERROR(ENOMEM));",
"if ((VAR_2 = avfilter_graph_parse(lavfi->graph, lavfi->graph_str,\n&input_links, &output_links, avctx)) < 0)\nFAIL(VAR_2);",
"if (input_links) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Open inputs in the filtergraph are not acceptable\\VAR_4\");",
"FAIL(AVERROR(EINVAL));",
"}",
"for (VAR_4 = 0, inout = output_links; inout; VAR_4++, inout = inout->next);",
"if (!(lavfi->sink_stream_map = av_malloc(sizeof(int) * VAR_4)))\nFAIL(AVERROR(ENOMEM));",
"if (!(lavfi->sink_eof = av_mallocz(sizeof(int) * VAR_4)))\nFAIL(AVERROR(ENOMEM));",
"if (!(lavfi->stream_sink_map = av_malloc(sizeof(int) * VAR_4)))\nFAIL(AVERROR(ENOMEM));",
"for (VAR_3 = 0; VAR_3 < VAR_4; VAR_3++)",
"lavfi->stream_sink_map[VAR_3] = -1;",
"for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {",
"int stream_idx;",
"if (!strcmp(inout->name, \"out\"))\nstream_idx = 0;",
"else if (sscanf(inout->name, \"out%d\\VAR_4\", &stream_idx) != 1) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Invalid outpad name '%s'\\VAR_4\", inout->name);",
"FAIL(AVERROR(EINVAL));",
"}",
"if ((unsigned)stream_idx >= VAR_4) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Invalid index was specified in output '%s', \"\n\"must be a non-negative value < %d\\VAR_4\",\ninout->name, VAR_4);",
"FAIL(AVERROR(EINVAL));",
"}",
"VAR_1 = inout->filter_ctx->output_pads[inout->pad_idx].VAR_1;",
"if (VAR_1 != AVMEDIA_TYPE_VIDEO && VAR_1 != AVMEDIA_TYPE_AUDIO) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Output '%s' is not a video or audio output, not yet supported\\VAR_4\", inout->name);",
"FAIL(AVERROR(EINVAL));",
"}",
"if (lavfi->stream_sink_map[stream_idx] != -1) {",
"av_log(avctx, AV_LOG_ERROR,\n\"An output with stream index %d was already specified\\VAR_4\",\nstream_idx);",
"FAIL(AVERROR(EINVAL));",
"}",
"lavfi->sink_stream_map[VAR_3] = stream_idx;",
"lavfi->stream_sink_map[stream_idx] = VAR_3;",
"}",
"for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {",
"AVStream *st;",
"if (!(st = avformat_new_stream(avctx, NULL)))\nFAIL(AVERROR(ENOMEM));",
"st->id = VAR_3;",
"}",
"lavfi->sinks = av_malloc(sizeof(AVFilterContext *) * avctx->nb_streams);",
"if (!lavfi->sinks)\nFAIL(AVERROR(ENOMEM));",
"for (VAR_3 = 0, inout = output_links; inout; VAR_3++, inout = inout->next) {",
"AVFilterContext *sink;",
"VAR_1 = inout->filter_ctx->output_pads[inout->pad_idx].VAR_1;",
"if (VAR_1 == AVMEDIA_TYPE_VIDEO && ! buffersink ||\nVAR_1 == AVMEDIA_TYPE_AUDIO && ! abuffersink) {",
"av_log(avctx, AV_LOG_ERROR, \"Missing required buffersink filter, aborting.\\VAR_4\");",
"FAIL(AVERROR_FILTER_NOT_FOUND);",
"}",
"if (VAR_1 == AVMEDIA_TYPE_VIDEO) {",
"VAR_2 = avfilter_graph_create_filter(&sink, buffersink,\ninout->name, NULL,\nNULL, lavfi->graph);",
"av_opt_set_int_list(sink, \"VAR_0\", VAR_0, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);",
"if (VAR_2 < 0)\ngoto end;",
"} else if (VAR_1 == AVMEDIA_TYPE_AUDIO) {",
"enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8,",
"AV_SAMPLE_FMT_S16,\nAV_SAMPLE_FMT_S32,\nAV_SAMPLE_FMT_FLT,\nAV_SAMPLE_FMT_DBL, -1 };",
"VAR_2 = avfilter_graph_create_filter(&sink, abuffersink,\ninout->name, NULL,\nNULL, lavfi->graph);",
"av_opt_set_int_list(sink, \"sample_fmts\", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);",
"if (VAR_2 < 0)\ngoto end;",
"}",
"lavfi->sinks[VAR_3] = sink;",
"if ((VAR_2 = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)\nFAIL(VAR_2);",
"}",
"if ((VAR_2 = avfilter_graph_config(lavfi->graph, avctx)) < 0)\nFAIL(VAR_2);",
"if (lavfi->dump_graph) {",
"char *VAR_5 = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);",
"fputs(VAR_5, stderr);",
"fflush(stderr);",
"av_free(VAR_5);",
"}",
"for (VAR_3 = 0; VAR_3 < avctx->nb_streams; VAR_3++) {",
"AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[VAR_3]]->inputs[0];",
"AVStream *st = avctx->streams[VAR_3];",
"st->codec->codec_type = link->VAR_1;",
"avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);",
"if (link->VAR_1 == AVMEDIA_TYPE_VIDEO) {",
"st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;",
"st->codec->pix_fmt = link->format;",
"st->codec->time_base = link->time_base;",
"st->codec->width = link->w;",
"st->codec->height = link->h;",
"st ->sample_aspect_ratio =\nst->codec->sample_aspect_ratio = link->sample_aspect_ratio;",
"avctx->probesize = FFMAX(avctx->probesize,\nlink->w * link->h *\nav_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *\n30);",
"} else if (link->VAR_1 == AVMEDIA_TYPE_AUDIO) {",
"st->codec->codec_id = av_get_pcm_codec(link->format, -1);",
"st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout);",
"st->codec->sample_fmt = link->format;",
"st->codec->sample_rate = link->sample_rate;",
"st->codec->time_base = link->time_base;",
"st->codec->channel_layout = link->channel_layout;",
"if (st->codec->codec_id == AV_CODEC_ID_NONE)\nav_log(avctx, AV_LOG_ERROR,\n\"Could not find PCM codec for sample format %s.\\VAR_4\",\nav_get_sample_fmt_name(link->format));",
"}",
"}",
"if (!(lavfi->decoded_frame = av_frame_alloc()))\nFAIL(AVERROR(ENOMEM));",
"end:\nav_free(VAR_0);",
"avfilter_inout_free(&input_links);",
"avfilter_inout_free(&output_links);",
"if (VAR_2 < 0)\nlavfi_read_close(avctx);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61,
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
99,
101
],
[
105,
107,
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
127
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
145
],
[
147
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
175
],
[
177,
179,
181,
183
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
245
],
[
247,
249
],
[
253
],
[
255
],
[
259
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277,
279,
281
],
[
283
],
[
287,
289
],
[
291
],
[
293
],
[
295,
297,
299,
301
],
[
305,
307,
309
],
[
313
],
[
315,
317
],
[
319
],
[
323
],
[
325,
327
],
[
329
],
[
335,
337
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383,
385,
387,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405,
407,
409,
411
],
[
413
],
[
415
],
[
419,
421
],
[
425,
427
],
[
429
],
[
431
],
[
433,
435
],
[
437
],
[
439
]
] |
4,925 | int do_balloon(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque)
{
int ret;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
ret = qemu_balloon(qdict_get_int(params, "value"));
if (ret == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
cb(opaque, NULL);
return 0;
}
| false | qemu | 514e73ecebc0aeadef218e91e36ee42b3d145c93 | int do_balloon(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque)
{
int ret;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
ret = qemu_balloon(qdict_get_int(params, "value"));
if (ret == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
cb(opaque, NULL);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Monitor *VAR_0, const QDict *VAR_1,
MonitorCompletion VAR_2, void *VAR_3)
{
int VAR_4;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
VAR_4 = qemu_balloon(qdict_get_int(VAR_1, "value"));
if (VAR_4 == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
VAR_2(VAR_3, NULL);
return 0;
}
| [
"int FUNC_0(Monitor *VAR_0, const QDict *VAR_1,\nMonitorCompletion VAR_2, void *VAR_3)\n{",
"int VAR_4;",
"if (kvm_enabled() && !kvm_has_sync_mmu()) {",
"qerror_report(QERR_KVM_MISSING_CAP, \"synchronous MMU\", \"balloon\");",
"return -1;",
"}",
"VAR_4 = qemu_balloon(qdict_get_int(VAR_1, \"value\"));",
"if (VAR_4 == 0) {",
"qerror_report(QERR_DEVICE_NOT_ACTIVE, \"balloon\");",
"return -1;",
"}",
"VAR_2(VAR_3, NULL);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
4,926 | static av_cold int movie_init(AVFilterContext *ctx, const char *args)
{
MovieContext *movie = ctx->priv;
AVInputFormat *iformat = NULL;
int64_t timestamp;
int nb_streams, ret, i;
char default_streams[16], *stream_specs, *spec, *cursor;
char name[16];
AVStream *st;
movie->class = &movie_class;
av_opt_set_defaults(movie);
if (args)
movie->file_name = av_get_token(&args, ":");
if (!movie->file_name || !*movie->file_name) {
av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
return AVERROR(EINVAL);
}
if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0)
return ret;
movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
stream_specs = movie->stream_specs;
if (!stream_specs) {
snprintf(default_streams, sizeof(default_streams), "d%c%d",
!strcmp(ctx->filter->name, "amovie") ? 'a' : 'v',
movie->stream_index);
stream_specs = default_streams;
}
for (cursor = stream_specs, nb_streams = 1; *cursor; cursor++)
if (*cursor == '+')
nb_streams++;
if (movie->loop_count != 1 && nb_streams != 1) {
av_log(ctx, AV_LOG_ERROR,
"Loop with several streams is currently unsupported\n");
return AVERROR_PATCHWELCOME;
}
av_register_all();
// Try to find the movie format (container)
iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
movie->format_ctx = NULL;
if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR,
"Failed to avformat_open_input '%s'\n", movie->file_name);
return ret;
}
if ((ret = avformat_find_stream_info(movie->format_ctx, NULL)) < 0)
av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n");
// if seeking requested, we execute it
if (movie->seek_point > 0) {
timestamp = movie->seek_point;
// add the stream start time, should it exist
if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {
if (timestamp > INT64_MAX - movie->format_ctx->start_time) {
av_log(ctx, AV_LOG_ERROR,
"%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n",
movie->file_name, movie->format_ctx->start_time, movie->seek_point);
return AVERROR(EINVAL);
}
timestamp += movie->format_ctx->start_time;
}
if ((ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {
av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n",
movie->file_name, timestamp);
return ret;
}
}
for (i = 0; i < movie->format_ctx->nb_streams; i++)
movie->format_ctx->streams[i]->discard = AVDISCARD_ALL;
movie->st = av_calloc(nb_streams, sizeof(*movie->st));
if (!movie->st)
return AVERROR(ENOMEM);
for (i = 0; i < nb_streams; i++) {
spec = av_strtok(stream_specs, "+", &cursor);
if (!spec)
return AVERROR_BUG;
stream_specs = NULL; /* for next strtok */
st = find_stream(ctx, movie->format_ctx, spec);
if (!st)
return AVERROR(EINVAL);
st->discard = AVDISCARD_DEFAULT;
movie->st[i].st = st;
movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);
}
if (av_strtok(NULL, "+", &cursor))
return AVERROR_BUG;
movie->out_index = av_calloc(movie->max_stream_index + 1,
sizeof(*movie->out_index));
if (!movie->out_index)
return AVERROR(ENOMEM);
for (i = 0; i <= movie->max_stream_index; i++)
movie->out_index[i] = -1;
for (i = 0; i < nb_streams; i++)
movie->out_index[movie->st[i].st->index] = i;
for (i = 0; i < nb_streams; i++) {
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "out%d", i);
pad.type = movie->st[i].st->codec->codec_type;
pad.name = av_strdup(name);
pad.config_props = movie_config_output_props;
pad.request_frame = movie_request_frame;
ff_insert_outpad(ctx, i, &pad);
ret = open_stream(ctx, &movie->st[i]);
if (ret < 0)
return ret;
if ( movie->st[i].st->codec->codec->type == AVMEDIA_TYPE_AUDIO &&
!movie->st[i].st->codec->channel_layout) {
ret = guess_channel_layout(&movie->st[i], i, ctx);
if (ret < 0)
return ret;
}
}
if (!(movie->frame = avcodec_alloc_frame()) ) {
av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n");
return AVERROR(ENOMEM);
}
av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
movie->seek_point, movie->format_name, movie->file_name,
movie->stream_index);
return 0;
}
| false | FFmpeg | 831a999ddaf89ad3bb31bfcf4201463098444539 | static av_cold int movie_init(AVFilterContext *ctx, const char *args)
{
MovieContext *movie = ctx->priv;
AVInputFormat *iformat = NULL;
int64_t timestamp;
int nb_streams, ret, i;
char default_streams[16], *stream_specs, *spec, *cursor;
char name[16];
AVStream *st;
movie->class = &movie_class;
av_opt_set_defaults(movie);
if (args)
movie->file_name = av_get_token(&args, ":");
if (!movie->file_name || !*movie->file_name) {
av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
return AVERROR(EINVAL);
}
if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0)
return ret;
movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
stream_specs = movie->stream_specs;
if (!stream_specs) {
snprintf(default_streams, sizeof(default_streams), "d%c%d",
!strcmp(ctx->filter->name, "amovie") ? 'a' : 'v',
movie->stream_index);
stream_specs = default_streams;
}
for (cursor = stream_specs, nb_streams = 1; *cursor; cursor++)
if (*cursor == '+')
nb_streams++;
if (movie->loop_count != 1 && nb_streams != 1) {
av_log(ctx, AV_LOG_ERROR,
"Loop with several streams is currently unsupported\n");
return AVERROR_PATCHWELCOME;
}
av_register_all();
iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
movie->format_ctx = NULL;
if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR,
"Failed to avformat_open_input '%s'\n", movie->file_name);
return ret;
}
if ((ret = avformat_find_stream_info(movie->format_ctx, NULL)) < 0)
av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n");
if (movie->seek_point > 0) {
timestamp = movie->seek_point;
if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {
if (timestamp > INT64_MAX - movie->format_ctx->start_time) {
av_log(ctx, AV_LOG_ERROR,
"%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n",
movie->file_name, movie->format_ctx->start_time, movie->seek_point);
return AVERROR(EINVAL);
}
timestamp += movie->format_ctx->start_time;
}
if ((ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {
av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n",
movie->file_name, timestamp);
return ret;
}
}
for (i = 0; i < movie->format_ctx->nb_streams; i++)
movie->format_ctx->streams[i]->discard = AVDISCARD_ALL;
movie->st = av_calloc(nb_streams, sizeof(*movie->st));
if (!movie->st)
return AVERROR(ENOMEM);
for (i = 0; i < nb_streams; i++) {
spec = av_strtok(stream_specs, "+", &cursor);
if (!spec)
return AVERROR_BUG;
stream_specs = NULL;
st = find_stream(ctx, movie->format_ctx, spec);
if (!st)
return AVERROR(EINVAL);
st->discard = AVDISCARD_DEFAULT;
movie->st[i].st = st;
movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);
}
if (av_strtok(NULL, "+", &cursor))
return AVERROR_BUG;
movie->out_index = av_calloc(movie->max_stream_index + 1,
sizeof(*movie->out_index));
if (!movie->out_index)
return AVERROR(ENOMEM);
for (i = 0; i <= movie->max_stream_index; i++)
movie->out_index[i] = -1;
for (i = 0; i < nb_streams; i++)
movie->out_index[movie->st[i].st->index] = i;
for (i = 0; i < nb_streams; i++) {
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "out%d", i);
pad.type = movie->st[i].st->codec->codec_type;
pad.name = av_strdup(name);
pad.config_props = movie_config_output_props;
pad.request_frame = movie_request_frame;
ff_insert_outpad(ctx, i, &pad);
ret = open_stream(ctx, &movie->st[i]);
if (ret < 0)
return ret;
if ( movie->st[i].st->codec->codec->type == AVMEDIA_TYPE_AUDIO &&
!movie->st[i].st->codec->channel_layout) {
ret = guess_channel_layout(&movie->st[i], i, ctx);
if (ret < 0)
return ret;
}
}
if (!(movie->frame = avcodec_alloc_frame()) ) {
av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n");
return AVERROR(ENOMEM);
}
av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
movie->seek_point, movie->format_name, movie->file_name,
movie->stream_index);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVFilterContext *ctx, const char *args)
{
MovieContext *movie = ctx->priv;
AVInputFormat *iformat = NULL;
int64_t timestamp;
int VAR_0, VAR_1, VAR_2;
char VAR_3[16], *VAR_4, *VAR_5, *VAR_6;
char VAR_7[16];
AVStream *st;
movie->class = &movie_class;
av_opt_set_defaults(movie);
if (args)
movie->file_name = av_get_token(&args, ":");
if (!movie->file_name || !*movie->file_name) {
av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
return AVERROR(EINVAL);
}
if (*args++ == ':' && (VAR_1 = av_set_options_string(movie, args, "=", ":")) < 0)
return VAR_1;
movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
VAR_4 = movie->VAR_4;
if (!VAR_4) {
snprintf(VAR_3, sizeof(VAR_3), "d%c%d",
!strcmp(ctx->filter->VAR_7, "amovie") ? 'a' : 'v',
movie->stream_index);
VAR_4 = VAR_3;
}
for (VAR_6 = VAR_4, VAR_0 = 1; *VAR_6; VAR_6++)
if (*VAR_6 == '+')
VAR_0++;
if (movie->loop_count != 1 && VAR_0 != 1) {
av_log(ctx, AV_LOG_ERROR,
"Loop with several streams is currently unsupported\n");
return AVERROR_PATCHWELCOME;
}
av_register_all();
iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
movie->format_ctx = NULL;
if ((VAR_1 = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR,
"Failed to avformat_open_input '%s'\n", movie->file_name);
return VAR_1;
}
if ((VAR_1 = avformat_find_stream_info(movie->format_ctx, NULL)) < 0)
av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n");
if (movie->seek_point > 0) {
timestamp = movie->seek_point;
if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {
if (timestamp > INT64_MAX - movie->format_ctx->start_time) {
av_log(ctx, AV_LOG_ERROR,
"%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n",
movie->file_name, movie->format_ctx->start_time, movie->seek_point);
return AVERROR(EINVAL);
}
timestamp += movie->format_ctx->start_time;
}
if ((VAR_1 = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {
av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n",
movie->file_name, timestamp);
return VAR_1;
}
}
for (VAR_2 = 0; VAR_2 < movie->format_ctx->VAR_0; VAR_2++)
movie->format_ctx->streams[VAR_2]->discard = AVDISCARD_ALL;
movie->st = av_calloc(VAR_0, sizeof(*movie->st));
if (!movie->st)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {
VAR_5 = av_strtok(VAR_4, "+", &VAR_6);
if (!VAR_5)
return AVERROR_BUG;
VAR_4 = NULL;
st = find_stream(ctx, movie->format_ctx, VAR_5);
if (!st)
return AVERROR(EINVAL);
st->discard = AVDISCARD_DEFAULT;
movie->st[VAR_2].st = st;
movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);
}
if (av_strtok(NULL, "+", &VAR_6))
return AVERROR_BUG;
movie->out_index = av_calloc(movie->max_stream_index + 1,
sizeof(*movie->out_index));
if (!movie->out_index)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 <= movie->max_stream_index; VAR_2++)
movie->out_index[VAR_2] = -1;
for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++)
movie->out_index[movie->st[VAR_2].st->index] = VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {
AVFilterPad pad = { 0 };
snprintf(VAR_7, sizeof(VAR_7), "out%d", VAR_2);
pad.type = movie->st[VAR_2].st->codec->codec_type;
pad.VAR_7 = av_strdup(VAR_7);
pad.config_props = movie_config_output_props;
pad.request_frame = movie_request_frame;
ff_insert_outpad(ctx, VAR_2, &pad);
VAR_1 = open_stream(ctx, &movie->st[VAR_2]);
if (VAR_1 < 0)
return VAR_1;
if ( movie->st[VAR_2].st->codec->codec->type == AVMEDIA_TYPE_AUDIO &&
!movie->st[VAR_2].st->codec->channel_layout) {
VAR_1 = guess_channel_layout(&movie->st[VAR_2], VAR_2, ctx);
if (VAR_1 < 0)
return VAR_1;
}
}
if (!(movie->frame = avcodec_alloc_frame()) ) {
av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n");
return AVERROR(ENOMEM);
}
av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
movie->seek_point, movie->format_name, movie->file_name,
movie->stream_index);
return 0;
}
| [
"static av_cold int FUNC_0(AVFilterContext *ctx, const char *args)\n{",
"MovieContext *movie = ctx->priv;",
"AVInputFormat *iformat = NULL;",
"int64_t timestamp;",
"int VAR_0, VAR_1, VAR_2;",
"char VAR_3[16], *VAR_4, *VAR_5, *VAR_6;",
"char VAR_7[16];",
"AVStream *st;",
"movie->class = &movie_class;",
"av_opt_set_defaults(movie);",
"if (args)\nmovie->file_name = av_get_token(&args, \":\");",
"if (!movie->file_name || !*movie->file_name) {",
"av_log(ctx, AV_LOG_ERROR, \"No filename provided!\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (*args++ == ':' && (VAR_1 = av_set_options_string(movie, args, \"=\", \":\")) < 0)\nreturn VAR_1;",
"movie->seek_point = movie->seek_point_d * 1000000 + 0.5;",
"VAR_4 = movie->VAR_4;",
"if (!VAR_4) {",
"snprintf(VAR_3, sizeof(VAR_3), \"d%c%d\",\n!strcmp(ctx->filter->VAR_7, \"amovie\") ? 'a' : 'v',\nmovie->stream_index);",
"VAR_4 = VAR_3;",
"}",
"for (VAR_6 = VAR_4, VAR_0 = 1; *VAR_6; VAR_6++)",
"if (*VAR_6 == '+')\nVAR_0++;",
"if (movie->loop_count != 1 && VAR_0 != 1) {",
"av_log(ctx, AV_LOG_ERROR,\n\"Loop with several streams is currently unsupported\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"av_register_all();",
"iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;",
"movie->format_ctx = NULL;",
"if ((VAR_1 = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {",
"av_log(ctx, AV_LOG_ERROR,\n\"Failed to avformat_open_input '%s'\\n\", movie->file_name);",
"return VAR_1;",
"}",
"if ((VAR_1 = avformat_find_stream_info(movie->format_ctx, NULL)) < 0)\nav_log(ctx, AV_LOG_WARNING, \"Failed to find stream info\\n\");",
"if (movie->seek_point > 0) {",
"timestamp = movie->seek_point;",
"if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {",
"if (timestamp > INT64_MAX - movie->format_ctx->start_time) {",
"av_log(ctx, AV_LOG_ERROR,\n\"%s: seek value overflow with start_time:%\"PRId64\" seek_point:%\"PRId64\"\\n\",\nmovie->file_name, movie->format_ctx->start_time, movie->seek_point);",
"return AVERROR(EINVAL);",
"}",
"timestamp += movie->format_ctx->start_time;",
"}",
"if ((VAR_1 = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"%s: could not seek to position %\"PRId64\"\\n\",\nmovie->file_name, timestamp);",
"return VAR_1;",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < movie->format_ctx->VAR_0; VAR_2++)",
"movie->format_ctx->streams[VAR_2]->discard = AVDISCARD_ALL;",
"movie->st = av_calloc(VAR_0, sizeof(*movie->st));",
"if (!movie->st)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {",
"VAR_5 = av_strtok(VAR_4, \"+\", &VAR_6);",
"if (!VAR_5)\nreturn AVERROR_BUG;",
"VAR_4 = NULL;",
"st = find_stream(ctx, movie->format_ctx, VAR_5);",
"if (!st)\nreturn AVERROR(EINVAL);",
"st->discard = AVDISCARD_DEFAULT;",
"movie->st[VAR_2].st = st;",
"movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);",
"}",
"if (av_strtok(NULL, \"+\", &VAR_6))\nreturn AVERROR_BUG;",
"movie->out_index = av_calloc(movie->max_stream_index + 1,\nsizeof(*movie->out_index));",
"if (!movie->out_index)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 <= movie->max_stream_index; VAR_2++)",
"movie->out_index[VAR_2] = -1;",
"for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++)",
"movie->out_index[movie->st[VAR_2].st->index] = VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {",
"AVFilterPad pad = { 0 };",
"snprintf(VAR_7, sizeof(VAR_7), \"out%d\", VAR_2);",
"pad.type = movie->st[VAR_2].st->codec->codec_type;",
"pad.VAR_7 = av_strdup(VAR_7);",
"pad.config_props = movie_config_output_props;",
"pad.request_frame = movie_request_frame;",
"ff_insert_outpad(ctx, VAR_2, &pad);",
"VAR_1 = open_stream(ctx, &movie->st[VAR_2]);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"if ( movie->st[VAR_2].st->codec->codec->type == AVMEDIA_TYPE_AUDIO &&\n!movie->st[VAR_2].st->codec->channel_layout) {",
"VAR_1 = guess_channel_layout(&movie->st[VAR_2], VAR_2, ctx);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"}",
"}",
"if (!(movie->frame = avcodec_alloc_frame()) ) {",
"av_log(log, AV_LOG_ERROR, \"Failed to alloc frame\\n\");",
"return AVERROR(ENOMEM);",
"}",
"av_log(ctx, AV_LOG_VERBOSE, \"seek_point:%\"PRIi64\" format_name:%s file_name:%s stream_index:%d\\n\",\nmovie->seek_point, movie->format_name, movie->file_name,\nmovie->stream_index);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
47
],
[
51
],
[
53
],
[
55,
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85
],
[
91
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159
],
[
161,
163
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
197,
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237,
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263,
265,
267
],
[
271
],
[
273
]
] |
4,927 | void cpu_outl(pio_addr_t addr, uint32_t val)
{
LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
trace_cpu_out(addr, val);
ioport_write(2, addr, val);
}
| false | qemu | b40acf99bef69fa8ab0f9092ff162fde945eec12 | void cpu_outl(pio_addr_t addr, uint32_t val)
{
LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
trace_cpu_out(addr, val);
ioport_write(2, addr, val);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(pio_addr_t VAR_0, uint32_t VAR_1)
{
LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", VAR_0, VAR_1);
trace_cpu_out(VAR_0, VAR_1);
ioport_write(2, VAR_0, VAR_1);
}
| [
"void FUNC_0(pio_addr_t VAR_0, uint32_t VAR_1)\n{",
"LOG_IOPORT(\"outl: %04\"FMT_pioaddr\" %08\"PRIx32\"\\n\", VAR_0, VAR_1);",
"trace_cpu_out(VAR_0, VAR_1);",
"ioport_write(2, VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
4,928 | static void do_loadvm(int argc, const char **argv)
{
if (argc != 2) {
help_cmd(argv[0]);
return;
}
if (qemu_loadvm(argv[1]) < 0)
term_printf("I/O error when loading VM from '%s'\n", argv[1]);
}
| false | qemu | 9307c4c1d93939db9b04117b654253af5113dc21 | static void do_loadvm(int argc, const char **argv)
{
if (argc != 2) {
help_cmd(argv[0]);
return;
}
if (qemu_loadvm(argv[1]) < 0)
term_printf("I/O error when loading VM from '%s'\n", argv[1]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, const char **VAR_1)
{
if (VAR_0 != 2) {
help_cmd(VAR_1[0]);
return;
}
if (qemu_loadvm(VAR_1[1]) < 0)
term_printf("I/O error when loading VM from '%s'\n", VAR_1[1]);
}
| [
"static void FUNC_0(int VAR_0, const char **VAR_1)\n{",
"if (VAR_0 != 2) {",
"help_cmd(VAR_1[0]);",
"return;",
"}",
"if (qemu_loadvm(VAR_1[1]) < 0)\nterm_printf(\"I/O error when loading VM from '%s'\\n\", VAR_1[1]);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
]
] |
4,929 | static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)
{
BDRVVmdkState *s = bs->opaque;
int i;
for (i = 0; i < s->num_extents; i++) {
if (!s->extents[i].flat) {
bs->bl.write_zeroes_alignment =
MAX(bs->bl.write_zeroes_alignment,
s->extents[i].cluster_sectors);
}
}
}
| false | qemu | cf081fca4e3cc02a309659b571ab0c5b225ea4cf | static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)
{
BDRVVmdkState *s = bs->opaque;
int i;
for (i = 0; i < s->num_extents; i++) {
if (!s->extents[i].flat) {
bs->bl.write_zeroes_alignment =
MAX(bs->bl.write_zeroes_alignment,
s->extents[i].cluster_sectors);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{
BDRVVmdkState *s = VAR_0->opaque;
int VAR_2;
for (VAR_2 = 0; VAR_2 < s->num_extents; VAR_2++) {
if (!s->extents[VAR_2].flat) {
VAR_0->bl.write_zeroes_alignment =
MAX(VAR_0->bl.write_zeroes_alignment,
s->extents[VAR_2].cluster_sectors);
}
}
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{",
"BDRVVmdkState *s = VAR_0->opaque;",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < s->num_extents; VAR_2++) {",
"if (!s->extents[VAR_2].flat) {",
"VAR_0->bl.write_zeroes_alignment =\nMAX(VAR_0->bl.write_zeroes_alignment,\ns->extents[VAR_2].cluster_sectors);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
]
] |
4,931 | static int handle_cmd(AHCIState *s, int port, int slot)
{
IDEState *ide_state;
uint32_t opts;
uint64_t tbl_addr;
AHCICmdHdr *cmd;
uint8_t *cmd_fis;
dma_addr_t cmd_len;
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
/* Engine currently busy, try again later */
DPRINTF(port, "engine busy\n");
return -1;
}
cmd = &((AHCICmdHdr *)s->dev[port].lst)[slot];
if (!s->dev[port].lst) {
DPRINTF(port, "error: lst not given but cmd handled");
return -1;
}
/* remember current slot handle for later */
s->dev[port].cur_cmd = cmd;
opts = le32_to_cpu(cmd->opts);
tbl_addr = le64_to_cpu(cmd->tbl_addr);
cmd_len = 0x80;
cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len,
DMA_DIRECTION_FROM_DEVICE);
if (!cmd_fis) {
DPRINTF(port, "error: guest passed us an invalid cmd fis\n");
return -1;
}
/* The device we are working for */
ide_state = &s->dev[port].port.ifs[0];
if (!ide_state->bs) {
DPRINTF(port, "error: guest accessed unused port");
goto out;
}
debug_print_fis(cmd_fis, 0x90);
//debug_print_fis(cmd_fis, (opts & AHCI_CMD_HDR_CMD_FIS_LEN) * 4);
switch (cmd_fis[0]) {
case SATA_FIS_TYPE_REGISTER_H2D:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (cmd_fis[1]) {
case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER:
break;
case 0:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (s->dev[port].port_state) {
case STATE_RUN:
if (cmd_fis[15] & ATA_SRST) {
s->dev[port].port_state = STATE_RESET;
}
break;
case STATE_RESET:
if (!(cmd_fis[15] & ATA_SRST)) {
ahci_reset_port(s, port);
}
break;
}
if (cmd_fis[1] == SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER) {
/* Check for NCQ command */
if ((cmd_fis[2] == READ_FPDMA_QUEUED) ||
(cmd_fis[2] == WRITE_FPDMA_QUEUED)) {
process_ncq_command(s, port, cmd_fis, slot);
goto out;
}
/* Decompose the FIS */
ide_state->nsector = (int64_t)((cmd_fis[13] << 8) | cmd_fis[12]);
ide_state->feature = cmd_fis[3];
if (!ide_state->nsector) {
ide_state->nsector = 256;
}
if (ide_state->drive_kind != IDE_CD) {
/*
* We set the sector depending on the sector defined in the FIS.
* Unfortunately, the spec isn't exactly obvious on this one.
*
* Apparently LBA48 commands set fis bytes 10,9,8,6,5,4 to the
* 48 bit sector number. ATA_CMD_READ_DMA_EXT is an example for
* such a command.
*
* Non-LBA48 commands however use 7[lower 4 bits],6,5,4 to define a
* 28-bit sector number. ATA_CMD_READ_DMA is an example for such
* a command.
*
* Since the spec doesn't explicitly state what each field should
* do, I simply assume non-used fields as reserved and OR everything
* together, independent of the command.
*/
ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
| ((uint64_t)cmd_fis[9] << 32)
/* This is used for LBA48 commands */
| ((uint64_t)cmd_fis[8] << 24)
/* This is used for non-LBA48 commands */
| ((uint64_t)(cmd_fis[7] & 0xf) << 24)
| ((uint64_t)cmd_fis[6] << 16)
| ((uint64_t)cmd_fis[5] << 8)
| cmd_fis[4]);
}
/* Copy the ACMD field (ATAPI packet, if any) from the AHCI command
* table to ide_state->io_buffer
*/
if (opts & AHCI_CMD_ATAPI) {
memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10);
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
debug_print_fis(ide_state->io_buffer, 0x10);
ide_state->feature = IDE_FEATURE_DMA;
s->dev[port].done_atapi_packet = false;
/* XXX send PIO setup FIS */
}
ide_state->error = 0;
/* Reset transferred byte counter */
cmd->status = 0;
/* We're ready to process the command in FIS byte 2. */
ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);
}
out:
dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
cmd_len);
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
/* async command, complete later */
s->dev[port].busy_slot = slot;
return -1;
}
/* done handling the command */
return 0;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static int handle_cmd(AHCIState *s, int port, int slot)
{
IDEState *ide_state;
uint32_t opts;
uint64_t tbl_addr;
AHCICmdHdr *cmd;
uint8_t *cmd_fis;
dma_addr_t cmd_len;
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
DPRINTF(port, "engine busy\n");
return -1;
}
cmd = &((AHCICmdHdr *)s->dev[port].lst)[slot];
if (!s->dev[port].lst) {
DPRINTF(port, "error: lst not given but cmd handled");
return -1;
}
s->dev[port].cur_cmd = cmd;
opts = le32_to_cpu(cmd->opts);
tbl_addr = le64_to_cpu(cmd->tbl_addr);
cmd_len = 0x80;
cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len,
DMA_DIRECTION_FROM_DEVICE);
if (!cmd_fis) {
DPRINTF(port, "error: guest passed us an invalid cmd fis\n");
return -1;
}
ide_state = &s->dev[port].port.ifs[0];
if (!ide_state->bs) {
DPRINTF(port, "error: guest accessed unused port");
goto out;
}
debug_print_fis(cmd_fis, 0x90);
switch (cmd_fis[0]) {
case SATA_FIS_TYPE_REGISTER_H2D:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (cmd_fis[1]) {
case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER:
break;
case 0:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (s->dev[port].port_state) {
case STATE_RUN:
if (cmd_fis[15] & ATA_SRST) {
s->dev[port].port_state = STATE_RESET;
}
break;
case STATE_RESET:
if (!(cmd_fis[15] & ATA_SRST)) {
ahci_reset_port(s, port);
}
break;
}
if (cmd_fis[1] == SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER) {
if ((cmd_fis[2] == READ_FPDMA_QUEUED) ||
(cmd_fis[2] == WRITE_FPDMA_QUEUED)) {
process_ncq_command(s, port, cmd_fis, slot);
goto out;
}
ide_state->nsector = (int64_t)((cmd_fis[13] << 8) | cmd_fis[12]);
ide_state->feature = cmd_fis[3];
if (!ide_state->nsector) {
ide_state->nsector = 256;
}
if (ide_state->drive_kind != IDE_CD) {
ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
| ((uint64_t)cmd_fis[9] << 32)
| ((uint64_t)cmd_fis[8] << 24)
| ((uint64_t)(cmd_fis[7] & 0xf) << 24)
| ((uint64_t)cmd_fis[6] << 16)
| ((uint64_t)cmd_fis[5] << 8)
| cmd_fis[4]);
}
if (opts & AHCI_CMD_ATAPI) {
memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10);
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
debug_print_fis(ide_state->io_buffer, 0x10);
ide_state->feature = IDE_FEATURE_DMA;
s->dev[port].done_atapi_packet = false;
}
ide_state->error = 0;
cmd->status = 0;
ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);
}
out:
dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
cmd_len);
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
s->dev[port].busy_slot = slot;
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AHCIState *VAR_0, int VAR_1, int VAR_2)
{
IDEState *ide_state;
uint32_t opts;
uint64_t tbl_addr;
AHCICmdHdr *cmd;
uint8_t *cmd_fis;
dma_addr_t cmd_len;
if (VAR_0->dev[VAR_1].VAR_1.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
DPRINTF(VAR_1, "engine busy\n");
return -1;
}
cmd = &((AHCICmdHdr *)VAR_0->dev[VAR_1].lst)[VAR_2];
if (!VAR_0->dev[VAR_1].lst) {
DPRINTF(VAR_1, "error: lst not given but cmd handled");
return -1;
}
VAR_0->dev[VAR_1].cur_cmd = cmd;
opts = le32_to_cpu(cmd->opts);
tbl_addr = le64_to_cpu(cmd->tbl_addr);
cmd_len = 0x80;
cmd_fis = dma_memory_map(VAR_0->as, tbl_addr, &cmd_len,
DMA_DIRECTION_FROM_DEVICE);
if (!cmd_fis) {
DPRINTF(VAR_1, "error: guest passed us an invalid cmd fis\n");
return -1;
}
ide_state = &VAR_0->dev[VAR_1].VAR_1.ifs[0];
if (!ide_state->bs) {
DPRINTF(VAR_1, "error: guest accessed unused VAR_1");
goto out;
}
debug_print_fis(cmd_fis, 0x90);
switch (cmd_fis[0]) {
case SATA_FIS_TYPE_REGISTER_H2D:
break;
default:
DPRINTF(VAR_1, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (cmd_fis[1]) {
case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER:
break;
case 0:
break;
default:
DPRINTF(VAR_1, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (VAR_0->dev[VAR_1].port_state) {
case STATE_RUN:
if (cmd_fis[15] & ATA_SRST) {
VAR_0->dev[VAR_1].port_state = STATE_RESET;
}
break;
case STATE_RESET:
if (!(cmd_fis[15] & ATA_SRST)) {
ahci_reset_port(VAR_0, VAR_1);
}
break;
}
if (cmd_fis[1] == SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER) {
if ((cmd_fis[2] == READ_FPDMA_QUEUED) ||
(cmd_fis[2] == WRITE_FPDMA_QUEUED)) {
process_ncq_command(VAR_0, VAR_1, cmd_fis, VAR_2);
goto out;
}
ide_state->nsector = (int64_t)((cmd_fis[13] << 8) | cmd_fis[12]);
ide_state->feature = cmd_fis[3];
if (!ide_state->nsector) {
ide_state->nsector = 256;
}
if (ide_state->drive_kind != IDE_CD) {
ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
| ((uint64_t)cmd_fis[9] << 32)
| ((uint64_t)cmd_fis[8] << 24)
| ((uint64_t)(cmd_fis[7] & 0xf) << 24)
| ((uint64_t)cmd_fis[6] << 16)
| ((uint64_t)cmd_fis[5] << 8)
| cmd_fis[4]);
}
if (opts & AHCI_CMD_ATAPI) {
memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10);
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
debug_print_fis(ide_state->io_buffer, 0x10);
ide_state->feature = IDE_FEATURE_DMA;
VAR_0->dev[VAR_1].done_atapi_packet = false;
}
ide_state->error = 0;
cmd->status = 0;
ide_exec_cmd(&VAR_0->dev[VAR_1].VAR_1, cmd_fis[2]);
}
out:
dma_memory_unmap(VAR_0->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
cmd_len);
if (VAR_0->dev[VAR_1].VAR_1.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
VAR_0->dev[VAR_1].busy_slot = VAR_2;
return -1;
}
return 0;
}
| [
"static int FUNC_0(AHCIState *VAR_0, int VAR_1, int VAR_2)\n{",
"IDEState *ide_state;",
"uint32_t opts;",
"uint64_t tbl_addr;",
"AHCICmdHdr *cmd;",
"uint8_t *cmd_fis;",
"dma_addr_t cmd_len;",
"if (VAR_0->dev[VAR_1].VAR_1.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {",
"DPRINTF(VAR_1, \"engine busy\\n\");",
"return -1;",
"}",
"cmd = &((AHCICmdHdr *)VAR_0->dev[VAR_1].lst)[VAR_2];",
"if (!VAR_0->dev[VAR_1].lst) {",
"DPRINTF(VAR_1, \"error: lst not given but cmd handled\");",
"return -1;",
"}",
"VAR_0->dev[VAR_1].cur_cmd = cmd;",
"opts = le32_to_cpu(cmd->opts);",
"tbl_addr = le64_to_cpu(cmd->tbl_addr);",
"cmd_len = 0x80;",
"cmd_fis = dma_memory_map(VAR_0->as, tbl_addr, &cmd_len,\nDMA_DIRECTION_FROM_DEVICE);",
"if (!cmd_fis) {",
"DPRINTF(VAR_1, \"error: guest passed us an invalid cmd fis\\n\");",
"return -1;",
"}",
"ide_state = &VAR_0->dev[VAR_1].VAR_1.ifs[0];",
"if (!ide_state->bs) {",
"DPRINTF(VAR_1, \"error: guest accessed unused VAR_1\");",
"goto out;",
"}",
"debug_print_fis(cmd_fis, 0x90);",
"switch (cmd_fis[0]) {",
"case SATA_FIS_TYPE_REGISTER_H2D:\nbreak;",
"default:\nDPRINTF(VAR_1, \"unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x \"\n\"cmd_fis[2]=%02x\\n\", cmd_fis[0], cmd_fis[1],\ncmd_fis[2]);",
"goto out;",
"break;",
"}",
"switch (cmd_fis[1]) {",
"case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER:\nbreak;",
"case 0:\nbreak;",
"default:\nDPRINTF(VAR_1, \"unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x \"\n\"cmd_fis[2]=%02x\\n\", cmd_fis[0], cmd_fis[1],\ncmd_fis[2]);",
"goto out;",
"break;",
"}",
"switch (VAR_0->dev[VAR_1].port_state) {",
"case STATE_RUN:\nif (cmd_fis[15] & ATA_SRST) {",
"VAR_0->dev[VAR_1].port_state = STATE_RESET;",
"}",
"break;",
"case STATE_RESET:\nif (!(cmd_fis[15] & ATA_SRST)) {",
"ahci_reset_port(VAR_0, VAR_1);",
"}",
"break;",
"}",
"if (cmd_fis[1] == SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER) {",
"if ((cmd_fis[2] == READ_FPDMA_QUEUED) ||\n(cmd_fis[2] == WRITE_FPDMA_QUEUED)) {",
"process_ncq_command(VAR_0, VAR_1, cmd_fis, VAR_2);",
"goto out;",
"}",
"ide_state->nsector = (int64_t)((cmd_fis[13] << 8) | cmd_fis[12]);",
"ide_state->feature = cmd_fis[3];",
"if (!ide_state->nsector) {",
"ide_state->nsector = 256;",
"}",
"if (ide_state->drive_kind != IDE_CD) {",
"ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)\n| ((uint64_t)cmd_fis[9] << 32)\n| ((uint64_t)cmd_fis[8] << 24)\n| ((uint64_t)(cmd_fis[7] & 0xf) << 24)\n| ((uint64_t)cmd_fis[6] << 16)\n| ((uint64_t)cmd_fis[5] << 8)\n| cmd_fis[4]);",
"}",
"if (opts & AHCI_CMD_ATAPI) {",
"memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10);",
"ide_state->lcyl = 0x14;",
"ide_state->hcyl = 0xeb;",
"debug_print_fis(ide_state->io_buffer, 0x10);",
"ide_state->feature = IDE_FEATURE_DMA;",
"VAR_0->dev[VAR_1].done_atapi_packet = false;",
"}",
"ide_state->error = 0;",
"cmd->status = 0;",
"ide_exec_cmd(&VAR_0->dev[VAR_1].VAR_1, cmd_fis[2]);",
"}",
"out:\ndma_memory_unmap(VAR_0->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,\ncmd_len);",
"if (VAR_0->dev[VAR_1].VAR_1.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {",
"VAR_0->dev[VAR_1].busy_slot = VAR_2;",
"return -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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
97
],
[
99,
101
],
[
103,
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129,
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
237,
239,
243,
247,
249,
251,
253
],
[
255
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
285
],
[
291
],
[
297
],
[
299
],
[
303,
305,
307
],
[
311
],
[
315
],
[
317
],
[
319
],
[
325
],
[
327
]
] |
4,932 | static void virtio_rng_process(VirtIORNG *vrng)
{
size_t size;
if (!is_guest_ready(vrng)) {
return;
}
size = get_request_size(vrng->vq);
size = MIN(vrng->quota_remaining, size);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
}
}
| false | qemu | e1f7b4812eab992de46c98b3726745afb042a7f0 | static void virtio_rng_process(VirtIORNG *vrng)
{
size_t size;
if (!is_guest_ready(vrng)) {
return;
}
size = get_request_size(vrng->vq);
size = MIN(vrng->quota_remaining, size);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIORNG *VAR_0)
{
size_t size;
if (!is_guest_ready(VAR_0)) {
return;
}
size = get_request_size(VAR_0->vq);
size = MIN(VAR_0->quota_remaining, size);
if (size) {
rng_backend_request_entropy(VAR_0->rng, size, chr_read, VAR_0);
}
}
| [
"static void FUNC_0(VirtIORNG *VAR_0)\n{",
"size_t size;",
"if (!is_guest_ready(VAR_0)) {",
"return;",
"}",
"size = get_request_size(VAR_0->vq);",
"size = MIN(VAR_0->quota_remaining, size);",
"if (size) {",
"rng_backend_request_entropy(VAR_0->rng, size, chr_read, VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
4,933 | static int vhost_verify_ring_part_mapping(void *part,
uint64_t part_addr,
uint64_t part_size,
uint64_t start_addr,
uint64_t size)
{
hwaddr l;
void *p;
int r = 0;
if (!ranges_overlap(start_addr, size, part_addr, part_size)) {
return 0;
}
l = part_size;
p = cpu_physical_memory_map(part_addr, &l, 1);
if (!p || l != part_size) {
r = -ENOMEM;
}
if (p != part) {
r = -EBUSY;
}
cpu_physical_memory_unmap(p, l, 0, 0);
return r;
}
| false | qemu | c471ad0e9bd46ca5f5c9c796e727230e043a091d | static int vhost_verify_ring_part_mapping(void *part,
uint64_t part_addr,
uint64_t part_size,
uint64_t start_addr,
uint64_t size)
{
hwaddr l;
void *p;
int r = 0;
if (!ranges_overlap(start_addr, size, part_addr, part_size)) {
return 0;
}
l = part_size;
p = cpu_physical_memory_map(part_addr, &l, 1);
if (!p || l != part_size) {
r = -ENOMEM;
}
if (p != part) {
r = -EBUSY;
}
cpu_physical_memory_unmap(p, l, 0, 0);
return r;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0,
uint64_t VAR_1,
uint64_t VAR_2,
uint64_t VAR_3,
uint64_t VAR_4)
{
hwaddr l;
void *VAR_5;
int VAR_6 = 0;
if (!ranges_overlap(VAR_3, VAR_4, VAR_1, VAR_2)) {
return 0;
}
l = VAR_2;
VAR_5 = cpu_physical_memory_map(VAR_1, &l, 1);
if (!VAR_5 || l != VAR_2) {
VAR_6 = -ENOMEM;
}
if (VAR_5 != VAR_0) {
VAR_6 = -EBUSY;
}
cpu_physical_memory_unmap(VAR_5, l, 0, 0);
return VAR_6;
}
| [
"static int FUNC_0(void *VAR_0,\nuint64_t VAR_1,\nuint64_t VAR_2,\nuint64_t VAR_3,\nuint64_t VAR_4)\n{",
"hwaddr l;",
"void *VAR_5;",
"int VAR_6 = 0;",
"if (!ranges_overlap(VAR_3, VAR_4, VAR_1, VAR_2)) {",
"return 0;",
"}",
"l = VAR_2;",
"VAR_5 = cpu_physical_memory_map(VAR_1, &l, 1);",
"if (!VAR_5 || l != VAR_2) {",
"VAR_6 = -ENOMEM;",
"}",
"if (VAR_5 != VAR_0) {",
"VAR_6 = -EBUSY;",
"}",
"cpu_physical_memory_unmap(VAR_5, l, 0, 0);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.