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
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
16,573 | void ff_read_frame_flush(AVFormatContext *s)
{
AVStream *st;
int i, j;
flush_packet_queue(s);
s->cur_st = NULL;
/* for each stream, reset read state */
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->parser) {
av_parser_close(st->parser);
st->parser = NULL;
av_free_packet(&st->cur_pkt);
}
st->last_IP_pts = AV_NOPTS_VALUE;
st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
st->reference_dts = AV_NOPTS_VALUE;
/* fail safe */
st->cur_ptr = NULL;
st->cur_len = 0;
st->probe_packets = MAX_PROBE_PACKETS;
for(j=0; j<MAX_REORDER_DELAY+1; j++)
st->pts_buffer[j]= AV_NOPTS_VALUE;
}
}
| false | FFmpeg | 27c7ca9c12bb42d5c44d46f24cd970469d0ef55a | void ff_read_frame_flush(AVFormatContext *s)
{
AVStream *st;
int i, j;
flush_packet_queue(s);
s->cur_st = NULL;
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->parser) {
av_parser_close(st->parser);
st->parser = NULL;
av_free_packet(&st->cur_pkt);
}
st->last_IP_pts = AV_NOPTS_VALUE;
st->cur_dts = AV_NOPTS_VALUE;
st->reference_dts = AV_NOPTS_VALUE;
st->cur_ptr = NULL;
st->cur_len = 0;
st->probe_packets = MAX_PROBE_PACKETS;
for(j=0; j<MAX_REORDER_DELAY+1; j++)
st->pts_buffer[j]= AV_NOPTS_VALUE;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVFormatContext *VAR_0)
{
AVStream *st;
int VAR_1, VAR_2;
flush_packet_queue(VAR_0);
VAR_0->cur_st = NULL;
for(VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
st = VAR_0->streams[VAR_1];
if (st->parser) {
av_parser_close(st->parser);
st->parser = NULL;
av_free_packet(&st->cur_pkt);
}
st->last_IP_pts = AV_NOPTS_VALUE;
st->cur_dts = AV_NOPTS_VALUE;
st->reference_dts = AV_NOPTS_VALUE;
st->cur_ptr = NULL;
st->cur_len = 0;
st->probe_packets = MAX_PROBE_PACKETS;
for(VAR_2=0; VAR_2<MAX_REORDER_DELAY+1; VAR_2++)
st->pts_buffer[VAR_2]= AV_NOPTS_VALUE;
}
}
| [
"void FUNC_0(AVFormatContext *VAR_0)\n{",
"AVStream *st;",
"int VAR_1, VAR_2;",
"flush_packet_queue(VAR_0);",
"VAR_0->cur_st = NULL;",
"for(VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"st = VAR_0->streams[VAR_1];",
"if (st->parser) {",
"av_parser_close(st->parser);",
"st->parser = NULL;",
"av_free_packet(&st->cur_pkt);",
"}",
"st->last_IP_pts = AV_NOPTS_VALUE;",
"st->cur_dts = AV_NOPTS_VALUE;",
"st->reference_dts = AV_NOPTS_VALUE;",
"st->cur_ptr = NULL;",
"st->cur_len = 0;",
"st->probe_packets = MAX_PROBE_PACKETS;",
"for(VAR_2=0; VAR_2<MAX_REORDER_DELAY+1; VAR_2++)",
"st->pts_buffer[VAR_2]= AV_NOPTS_VALUE;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
]
]
|
16,574 | void av_register_input_format(AVInputFormat *format)
{
AVInputFormat **p = &first_iformat;
while (*p != NULL)
p = &(*p)->next;
*p = format;
format->next = NULL;
}
| false | FFmpeg | 4b1f5e5090abed6c618c8ba380cd7d28d140f867 | void av_register_input_format(AVInputFormat *format)
{
AVInputFormat **p = &first_iformat;
while (*p != NULL)
p = &(*p)->next;
*p = format;
format->next = NULL;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVInputFormat *VAR_0)
{
AVInputFormat **p = &first_iformat;
while (*p != NULL)
p = &(*p)->next;
*p = VAR_0;
VAR_0->next = NULL;
}
| [
"void FUNC_0(AVInputFormat *VAR_0)\n{",
"AVInputFormat **p = &first_iformat;",
"while (*p != NULL)\np = &(*p)->next;",
"*p = VAR_0;",
"VAR_0->next = NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19
]
]
|
16,575 | static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)
{
const char *proto = avio_find_protocol_name(s->filename);
int http_base_proto = !av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https");
if (c->method) {
av_dict_set(options, "method", c->method, 0);
} else if (proto && http_base_proto) {
av_log(c, AV_LOG_WARNING, "No HTTP method set, hls muxer defaulting to method PUT.\n");
av_dict_set(options, "method", "PUT", 0);
}
}
| false | FFmpeg | 0c0aef1caf0cb5dd3b294f9fff923175036bd985 | static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)
{
const char *proto = avio_find_protocol_name(s->filename);
int http_base_proto = !av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https");
if (c->method) {
av_dict_set(options, "method", c->method, 0);
} else if (proto && http_base_proto) {
av_log(c, AV_LOG_WARNING, "No HTTP method set, hls muxer defaulting to method PUT.\n");
av_dict_set(options, "method", "PUT", 0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1, HLSContext *VAR_2)
{
const char *VAR_3 = avio_find_protocol_name(VAR_0->filename);
int VAR_4 = !av_strcasecmp(VAR_3, "http") || !av_strcasecmp(VAR_3, "https");
if (VAR_2->method) {
av_dict_set(VAR_1, "method", VAR_2->method, 0);
} else if (VAR_3 && VAR_4) {
av_log(VAR_2, AV_LOG_WARNING, "No HTTP method set, hls muxer defaulting to method PUT.\n");
av_dict_set(VAR_1, "method", "PUT", 0);
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1, HLSContext *VAR_2)\n{",
"const char *VAR_3 = avio_find_protocol_name(VAR_0->filename);",
"int VAR_4 = !av_strcasecmp(VAR_3, \"http\") || !av_strcasecmp(VAR_3, \"https\");",
"if (VAR_2->method) {",
"av_dict_set(VAR_1, \"method\", VAR_2->method, 0);",
"} else if (VAR_3 && VAR_4) {",
"av_log(VAR_2, AV_LOG_WARNING, \"No HTTP method set, hls muxer defaulting to method PUT.\\n\");",
"av_dict_set(VAR_1, \"method\", \"PUT\", 0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
16,576 | static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int i, entries;
get_byte(pb); /* version */
get_be24(pb); /* flags */
entries = get_be32(pb);
dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
if(entries >= UINT_MAX / sizeof(*sc->ctts_data))
return -1;
sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);
sc->ctts_count = entries;
for(i=0; i<entries; i++) {
int count =get_be32(pb);
int duration =get_be32(pb);
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
}
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int i, entries;
get_byte(pb);
get_be24(pb);
entries = get_be32(pb);
dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
if(entries >= UINT_MAX / sizeof(*sc->ctts_data))
return -1;
sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);
sc->ctts_count = entries;
for(i=0; i<entries; i++) {
int count =get_be32(pb);
int duration =get_be32(pb);
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int VAR_3, VAR_4;
get_byte(VAR_1);
get_be24(VAR_1);
VAR_4 = get_be32(VAR_1);
dprintf(VAR_0->fc, "track[%VAR_3].ctts.VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams-1, VAR_4);
if(VAR_4 >= UINT_MAX / sizeof(*sc->ctts_data))
return -1;
sc->ctts_data = av_malloc(VAR_4 * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);
sc->ctts_count = VAR_4;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++) {
int VAR_5 =get_be32(VAR_1);
int VAR_6 =get_be32(VAR_1);
sc->ctts_data[VAR_3].VAR_5 = VAR_5;
sc->ctts_data[VAR_3].VAR_6= VAR_6;
}
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"MOVStreamContext *sc = st->priv_data;",
"unsigned int VAR_3, VAR_4;",
"get_byte(VAR_1);",
"get_be24(VAR_1);",
"VAR_4 = get_be32(VAR_1);",
"dprintf(VAR_0->fc, \"track[%VAR_3].ctts.VAR_4 = %VAR_3\\n\", VAR_0->fc->nb_streams-1, VAR_4);",
"if(VAR_4 >= UINT_MAX / sizeof(*sc->ctts_data))\nreturn -1;",
"sc->ctts_data = av_malloc(VAR_4 * sizeof(*sc->ctts_data));",
"if (!sc->ctts_data)\nreturn AVERROR(ENOMEM);",
"sc->ctts_count = VAR_4;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++) {",
"int VAR_5 =get_be32(VAR_1);",
"int VAR_6 =get_be32(VAR_1);",
"sc->ctts_data[VAR_3].VAR_5 = VAR_5;",
"sc->ctts_data[VAR_3].VAR_6= VAR_6;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
]
|
16,579 | int cpu_cris_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int mmu_idx, int is_softmmu)
{
struct cris_mmu_result res;
int prot, miss;
int r = -1;
target_ulong phy;
D(printf ("%s addr=%x pc=%x rw=%x\n", __func__, address, env->pc, rw));
miss = cris_mmu_translate(&res, env, address & TARGET_PAGE_MASK,
rw, mmu_idx, 0);
if (miss)
{
if (env->exception_index == EXCP_BUSFAULT)
cpu_abort(env,
"CRIS: Illegal recursive bus fault."
"addr=%x rw=%d\n",
address, rw);
env->pregs[PR_EDA] = address;
env->exception_index = EXCP_BUSFAULT;
env->fault_vector = res.bf_vec;
r = 1;
}
else
{
/*
* Mask off the cache selection bit. The ETRAX busses do not
* see the top bit.
*/
phy = res.phy & ~0x80000000;
prot = res.prot;
tlb_set_page(env, address & TARGET_PAGE_MASK, phy,
prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE);
r = 0;
}
if (r > 0)
D_LOG("%s returns %d irqreq=%x addr=%x"
" phy=%x ismmu=%d vec=%x pc=%x\n",
__func__, r, env->interrupt_request,
address, res.phy, is_softmmu, res.bf_vec, env->pc);
return r;
}
| false | qemu | 58aebb946acff82c62383f350cab593e55cc13dc | int cpu_cris_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int mmu_idx, int is_softmmu)
{
struct cris_mmu_result res;
int prot, miss;
int r = -1;
target_ulong phy;
D(printf ("%s addr=%x pc=%x rw=%x\n", __func__, address, env->pc, rw));
miss = cris_mmu_translate(&res, env, address & TARGET_PAGE_MASK,
rw, mmu_idx, 0);
if (miss)
{
if (env->exception_index == EXCP_BUSFAULT)
cpu_abort(env,
"CRIS: Illegal recursive bus fault."
"addr=%x rw=%d\n",
address, rw);
env->pregs[PR_EDA] = address;
env->exception_index = EXCP_BUSFAULT;
env->fault_vector = res.bf_vec;
r = 1;
}
else
{
phy = res.phy & ~0x80000000;
prot = res.prot;
tlb_set_page(env, address & TARGET_PAGE_MASK, phy,
prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE);
r = 0;
}
if (r > 0)
D_LOG("%s returns %d irqreq=%x addr=%x"
" phy=%x ismmu=%d vec=%x pc=%x\n",
__func__, r, env->interrupt_request,
address, res.phy, is_softmmu, res.bf_vec, env->pc);
return r;
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,
int VAR_3, int VAR_4)
{
struct cris_mmu_result VAR_5;
int VAR_6, VAR_7;
int VAR_8 = -1;
target_ulong phy;
D(printf ("%s addr=%x pc=%x VAR_2=%x\n", __func__, VAR_1, VAR_0->pc, VAR_2));
VAR_7 = cris_mmu_translate(&VAR_5, VAR_0, VAR_1 & TARGET_PAGE_MASK,
VAR_2, VAR_3, 0);
if (VAR_7)
{
if (VAR_0->exception_index == EXCP_BUSFAULT)
cpu_abort(VAR_0,
"CRIS: Illegal recursive bus fault."
"addr=%x VAR_2=%d\n",
VAR_1, VAR_2);
VAR_0->pregs[PR_EDA] = VAR_1;
VAR_0->exception_index = EXCP_BUSFAULT;
VAR_0->fault_vector = VAR_5.bf_vec;
VAR_8 = 1;
}
else
{
phy = VAR_5.phy & ~0x80000000;
VAR_6 = VAR_5.VAR_6;
tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK, phy,
VAR_6 | PAGE_EXEC, VAR_3, TARGET_PAGE_SIZE);
VAR_8 = 0;
}
if (VAR_8 > 0)
D_LOG("%s returns %d irqreq=%x addr=%x"
" phy=%x ismmu=%d vec=%x pc=%x\n",
__func__, VAR_8, VAR_0->interrupt_request,
VAR_1, VAR_5.phy, VAR_4, VAR_5.bf_vec, VAR_0->pc);
return VAR_8;
}
| [
"int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{",
"struct cris_mmu_result VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8 = -1;",
"target_ulong phy;",
"D(printf (\"%s addr=%x pc=%x VAR_2=%x\\n\", __func__, VAR_1, VAR_0->pc, VAR_2));",
"VAR_7 = cris_mmu_translate(&VAR_5, VAR_0, VAR_1 & TARGET_PAGE_MASK,\nVAR_2, VAR_3, 0);",
"if (VAR_7)\n{",
"if (VAR_0->exception_index == EXCP_BUSFAULT)\ncpu_abort(VAR_0,\n\"CRIS: Illegal recursive bus fault.\"\n\"addr=%x VAR_2=%d\\n\",\nVAR_1, VAR_2);",
"VAR_0->pregs[PR_EDA] = VAR_1;",
"VAR_0->exception_index = EXCP_BUSFAULT;",
"VAR_0->fault_vector = VAR_5.bf_vec;",
"VAR_8 = 1;",
"}",
"else\n{",
"phy = VAR_5.phy & ~0x80000000;",
"VAR_6 = VAR_5.VAR_6;",
"tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK, phy,\nVAR_6 | PAGE_EXEC, VAR_3, TARGET_PAGE_SIZE);",
"VAR_8 = 0;",
"}",
"if (VAR_8 > 0)\nD_LOG(\"%s returns %d irqreq=%x addr=%x\"\n\" phy=%x ismmu=%d vec=%x pc=%x\\n\",\n__func__, VAR_8, VAR_0->interrupt_request,\nVAR_1, VAR_5.phy, VAR_4, VAR_5.bf_vec, VAR_0->pc);",
"return VAR_8;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
29,
31,
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75,
77,
79,
81
],
[
83
],
[
85
]
]
|
16,580 | static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step,
const int stride, const int dmode,
const int lim_q1, const int lim_p1,
const int alpha,
const int beta, const int beta2,
const int chroma, const int edge)
{
int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4];
int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0;
uint8_t *ptr;
int flag_strong0 = 1, flag_strong1 = 1;
int filter_p1, filter_q1;
int i;
int lims;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p0[i] = ptr[-2*step] - ptr[-1*step];
diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step];
sum_p1p0 += diff_p1p0[i];
sum_q1q0 += diff_q1q0[i];
}
filter_p1 = FFABS(sum_p1p0) < (beta<<2);
filter_q1 = FFABS(sum_q1q0) < (beta<<2);
if(!filter_p1 && !filter_q1)
return;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p2[i] = ptr[-2*step] - ptr[-3*step];
diff_q1q2[i] = ptr[ 1*step] - ptr[ 2*step];
sum_p1p2 += diff_p1p2[i];
sum_q1q2 += diff_q1q2[i];
}
if(edge){
flag_strong0 = filter_p1 && (FFABS(sum_p1p2) < beta2);
flag_strong1 = filter_q1 && (FFABS(sum_q1q2) < beta2);
}else{
flag_strong0 = flag_strong1 = 0;
}
lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1;
if(flag_strong0 && flag_strong1){ /* strong filtering */
for(i = 0; i < 4; i++, src += stride){
int sflag, p0, q0, p1, q1;
int t = src[0*step] - src[-1*step];
if(!t) continue;
sflag = (alpha * FFABS(t)) >> 7;
if(sflag > 1) continue;
p0 = (25*src[-3*step] + 26*src[-2*step]
+ 26*src[-1*step]
+ 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + i]) >> 7;
q0 = (25*src[-2*step] + 26*src[-1*step]
+ 26*src[ 0*step]
+ 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims);
q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims);
}
p1 = (25*src[-4*step] + 26*src[-3*step]
+ 26*src[-2*step]
+ 26*p0 + 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7;
q1 = (25*src[-1*step] + 26*q0
+ 26*src[ 1*step]
+ 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims);
q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims);
}
src[-2*step] = p1;
src[-1*step] = p0;
src[ 0*step] = q0;
src[ 1*step] = q1;
if(!chroma){
src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;
src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;
}
}
}else if(filter_p1 && filter_q1){
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, lims, lim_q1, lim_p1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}else{
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, filter_p1, filter_q1,
alpha, beta, lims>>1, lim_q1>>1, lim_p1>>1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}
}
| false | FFmpeg | d8edf1b515ae9fbcea2103305241d130c16e1003 | static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step,
const int stride, const int dmode,
const int lim_q1, const int lim_p1,
const int alpha,
const int beta, const int beta2,
const int chroma, const int edge)
{
int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4];
int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0;
uint8_t *ptr;
int flag_strong0 = 1, flag_strong1 = 1;
int filter_p1, filter_q1;
int i;
int lims;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p0[i] = ptr[-2*step] - ptr[-1*step];
diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step];
sum_p1p0 += diff_p1p0[i];
sum_q1q0 += diff_q1q0[i];
}
filter_p1 = FFABS(sum_p1p0) < (beta<<2);
filter_q1 = FFABS(sum_q1q0) < (beta<<2);
if(!filter_p1 && !filter_q1)
return;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p2[i] = ptr[-2*step] - ptr[-3*step];
diff_q1q2[i] = ptr[ 1*step] - ptr[ 2*step];
sum_p1p2 += diff_p1p2[i];
sum_q1q2 += diff_q1q2[i];
}
if(edge){
flag_strong0 = filter_p1 && (FFABS(sum_p1p2) < beta2);
flag_strong1 = filter_q1 && (FFABS(sum_q1q2) < beta2);
}else{
flag_strong0 = flag_strong1 = 0;
}
lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1;
if(flag_strong0 && flag_strong1){
for(i = 0; i < 4; i++, src += stride){
int sflag, p0, q0, p1, q1;
int t = src[0*step] - src[-1*step];
if(!t) continue;
sflag = (alpha * FFABS(t)) >> 7;
if(sflag > 1) continue;
p0 = (25*src[-3*step] + 26*src[-2*step]
+ 26*src[-1*step]
+ 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + i]) >> 7;
q0 = (25*src[-2*step] + 26*src[-1*step]
+ 26*src[ 0*step]
+ 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims);
q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims);
}
p1 = (25*src[-4*step] + 26*src[-3*step]
+ 26*src[-2*step]
+ 26*p0 + 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7;
q1 = (25*src[-1*step] + 26*q0
+ 26*src[ 1*step]
+ 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims);
q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims);
}
src[-2*step] = p1;
src[-1*step] = p0;
src[ 0*step] = q0;
src[ 1*step] = q1;
if(!chroma){
src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;
src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;
}
}
}else if(filter_p1 && filter_q1){
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, lims, lim_q1, lim_p1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}else{
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, filter_p1, filter_q1,
alpha, beta, lims>>1, lim_q1>>1, lim_p1>>1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(uint8_t *src, const int step,
const int stride, const int dmode,
const int lim_q1, const int lim_p1,
const int alpha,
const int beta, const int beta2,
const int chroma, const int edge)
{
int VAR_0[4], VAR_1[4], VAR_2[4], VAR_3[4];
int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;
uint8_t *ptr;
int VAR_8 = 1, VAR_9 = 1;
int VAR_10, VAR_11;
int VAR_12;
int VAR_13;
for(VAR_12 = 0, ptr = src; VAR_12 < 4; VAR_12++, ptr += stride){
VAR_0[VAR_12] = ptr[-2*step] - ptr[-1*step];
VAR_1[VAR_12] = ptr[ 1*step] - ptr[ 0*step];
VAR_4 += VAR_0[VAR_12];
VAR_5 += VAR_1[VAR_12];
}
VAR_10 = FFABS(VAR_4) < (beta<<2);
VAR_11 = FFABS(VAR_5) < (beta<<2);
if(!VAR_10 && !VAR_11)
return;
for(VAR_12 = 0, ptr = src; VAR_12 < 4; VAR_12++, ptr += stride){
VAR_2[VAR_12] = ptr[-2*step] - ptr[-3*step];
VAR_3[VAR_12] = ptr[ 1*step] - ptr[ 2*step];
VAR_6 += VAR_2[VAR_12];
VAR_7 += VAR_3[VAR_12];
}
if(edge){
VAR_8 = VAR_10 && (FFABS(VAR_6) < beta2);
VAR_9 = VAR_11 && (FFABS(VAR_7) < beta2);
}else{
VAR_8 = VAR_9 = 0;
}
VAR_13 = VAR_10 + VAR_11 + ((lim_q1 + lim_p1) >> 1) + 1;
if(VAR_8 && VAR_9){
for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride){
int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18;
int VAR_19 = src[0*step] - src[-1*step];
if(!VAR_19) continue;
VAR_14 = (alpha * FFABS(VAR_19)) >> 7;
if(VAR_14 > 1) continue;
VAR_15 = (25*src[-3*step] + 26*src[-2*step]
+ 26*src[-1*step]
+ 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + VAR_12]) >> 7;
VAR_16 = (25*src[-2*step] + 26*src[-1*step]
+ 26*src[ 0*step]
+ 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + VAR_12]) >> 7;
if(VAR_14){
VAR_15 = av_clip(VAR_15, src[-1*step] - VAR_13, src[-1*step] + VAR_13);
VAR_16 = av_clip(VAR_16, src[ 0*step] - VAR_13, src[ 0*step] + VAR_13);
}
VAR_17 = (25*src[-4*step] + 26*src[-3*step]
+ 26*src[-2*step]
+ 26*VAR_15 + 25*src[ 0*step] + rv40_dither_l[dmode + VAR_12]) >> 7;
VAR_18 = (25*src[-1*step] + 26*VAR_16
+ 26*src[ 1*step]
+ 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + VAR_12]) >> 7;
if(VAR_14){
VAR_17 = av_clip(VAR_17, src[-2*step] - VAR_13, src[-2*step] + VAR_13);
VAR_18 = av_clip(VAR_18, src[ 1*step] - VAR_13, src[ 1*step] + VAR_13);
}
src[-2*step] = VAR_17;
src[-1*step] = VAR_15;
src[ 0*step] = VAR_16;
src[ 1*step] = VAR_18;
if(!chroma){
src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;
src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;
}
}
}else if(VAR_10 && VAR_11){
for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride)
rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, VAR_13, lim_q1, lim_p1,
VAR_0[VAR_12], VAR_1[VAR_12], VAR_2[VAR_12], VAR_3[VAR_12]);
}else{
for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride)
rv40_weak_loop_filter(src, step, VAR_10, VAR_11,
alpha, beta, VAR_13>>1, lim_q1>>1, lim_p1>>1,
VAR_0[VAR_12], VAR_1[VAR_12], VAR_2[VAR_12], VAR_3[VAR_12]);
}
}
| [
"static av_always_inline void FUNC_0(uint8_t *src, const int step,\nconst int stride, const int dmode,\nconst int lim_q1, const int lim_p1,\nconst int alpha,\nconst int beta, const int beta2,\nconst int chroma, const int edge)\n{",
"int VAR_0[4], VAR_1[4], VAR_2[4], VAR_3[4];",
"int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;",
"uint8_t *ptr;",
"int VAR_8 = 1, VAR_9 = 1;",
"int VAR_10, VAR_11;",
"int VAR_12;",
"int VAR_13;",
"for(VAR_12 = 0, ptr = src; VAR_12 < 4; VAR_12++, ptr += stride){",
"VAR_0[VAR_12] = ptr[-2*step] - ptr[-1*step];",
"VAR_1[VAR_12] = ptr[ 1*step] - ptr[ 0*step];",
"VAR_4 += VAR_0[VAR_12];",
"VAR_5 += VAR_1[VAR_12];",
"}",
"VAR_10 = FFABS(VAR_4) < (beta<<2);",
"VAR_11 = FFABS(VAR_5) < (beta<<2);",
"if(!VAR_10 && !VAR_11)\nreturn;",
"for(VAR_12 = 0, ptr = src; VAR_12 < 4; VAR_12++, ptr += stride){",
"VAR_2[VAR_12] = ptr[-2*step] - ptr[-3*step];",
"VAR_3[VAR_12] = ptr[ 1*step] - ptr[ 2*step];",
"VAR_6 += VAR_2[VAR_12];",
"VAR_7 += VAR_3[VAR_12];",
"}",
"if(edge){",
"VAR_8 = VAR_10 && (FFABS(VAR_6) < beta2);",
"VAR_9 = VAR_11 && (FFABS(VAR_7) < beta2);",
"}else{",
"VAR_8 = VAR_9 = 0;",
"}",
"VAR_13 = VAR_10 + VAR_11 + ((lim_q1 + lim_p1) >> 1) + 1;",
"if(VAR_8 && VAR_9){",
"for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride){",
"int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18;",
"int VAR_19 = src[0*step] - src[-1*step];",
"if(!VAR_19) continue;",
"VAR_14 = (alpha * FFABS(VAR_19)) >> 7;",
"if(VAR_14 > 1) continue;",
"VAR_15 = (25*src[-3*step] + 26*src[-2*step]\n+ 26*src[-1*step]\n+ 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + VAR_12]) >> 7;",
"VAR_16 = (25*src[-2*step] + 26*src[-1*step]\n+ 26*src[ 0*step]\n+ 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + VAR_12]) >> 7;",
"if(VAR_14){",
"VAR_15 = av_clip(VAR_15, src[-1*step] - VAR_13, src[-1*step] + VAR_13);",
"VAR_16 = av_clip(VAR_16, src[ 0*step] - VAR_13, src[ 0*step] + VAR_13);",
"}",
"VAR_17 = (25*src[-4*step] + 26*src[-3*step]\n+ 26*src[-2*step]\n+ 26*VAR_15 + 25*src[ 0*step] + rv40_dither_l[dmode + VAR_12]) >> 7;",
"VAR_18 = (25*src[-1*step] + 26*VAR_16\n+ 26*src[ 1*step]\n+ 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + VAR_12]) >> 7;",
"if(VAR_14){",
"VAR_17 = av_clip(VAR_17, src[-2*step] - VAR_13, src[-2*step] + VAR_13);",
"VAR_18 = av_clip(VAR_18, src[ 1*step] - VAR_13, src[ 1*step] + VAR_13);",
"}",
"src[-2*step] = VAR_17;",
"src[-1*step] = VAR_15;",
"src[ 0*step] = VAR_16;",
"src[ 1*step] = VAR_18;",
"if(!chroma){",
"src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;",
"src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;",
"}",
"}",
"}else if(VAR_10 && VAR_11){",
"for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride)",
"rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, VAR_13, lim_q1, lim_p1,\nVAR_0[VAR_12], VAR_1[VAR_12], VAR_2[VAR_12], VAR_3[VAR_12]);",
"}else{",
"for(VAR_12 = 0; VAR_12 < 4; VAR_12++, src += stride)",
"rv40_weak_loop_filter(src, step, VAR_10, VAR_11,\nalpha, beta, VAR_13>>1, lim_q1>>1, lim_p1>>1,\nVAR_0[VAR_12], VAR_1[VAR_12], VAR_2[VAR_12], VAR_3[VAR_12]);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101,
103,
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123,
125
],
[
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
]
]
|
16,581 | void framebuffer_update_display(
DisplayState *ds,
MemoryRegion *address_space,
target_phys_addr_t base,
int cols, /* Width in pixels. */
int rows, /* Height in pixels. */
int src_width, /* Length of source line, in bytes. */
int dest_row_pitch, /* Bytes between adjacent horizontal output pixels. */
int dest_col_pitch, /* Bytes between adjacent vertical output pixels. */
int invalidate, /* nonzero to redraw the whole image. */
drawfn fn,
void *opaque,
int *first_row, /* Input and output. */
int *last_row /* Output only */)
{
target_phys_addr_t src_len;
uint8_t *dest;
uint8_t *src;
uint8_t *src_base;
int first, last = 0;
int dirty;
int i;
ram_addr_t addr;
MemoryRegionSection mem_section;
MemoryRegion *mem;
i = *first_row;
*first_row = -1;
src_len = src_width * rows;
mem_section = memory_region_find(address_space, base, src_len);
if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {
return;
}
mem = mem_section.mr;
assert(mem);
assert(mem_section.offset_within_address_space == base);
memory_region_sync_dirty_bitmap(mem);
src_base = cpu_physical_memory_map(base, &src_len, 0);
/* If we can't map the framebuffer then bail. We could try harder,
but it's not really worth it as dirty flag tracking will probably
already have failed above. */
if (!src_base)
return;
if (src_len != src_width * rows) {
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
return;
}
src = src_base;
dest = ds_get_data(ds);
if (dest_col_pitch < 0)
dest -= dest_col_pitch * (cols - 1);
if (dest_row_pitch < 0) {
dest -= dest_row_pitch * (rows - 1);
}
first = -1;
addr = mem_section.offset_within_region;
addr += i * src_width;
src += i * src_width;
dest += i * dest_row_pitch;
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
first = i;
last = i;
}
addr += src_width;
src += src_width;
dest += dest_row_pitch;
}
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | void framebuffer_update_display(
DisplayState *ds,
MemoryRegion *address_space,
target_phys_addr_t base,
int cols,
int rows,
int src_width,
int dest_row_pitch,
int dest_col_pitch,
int invalidate,
drawfn fn,
void *opaque,
int *first_row,
int *last_row )
{
target_phys_addr_t src_len;
uint8_t *dest;
uint8_t *src;
uint8_t *src_base;
int first, last = 0;
int dirty;
int i;
ram_addr_t addr;
MemoryRegionSection mem_section;
MemoryRegion *mem;
i = *first_row;
*first_row = -1;
src_len = src_width * rows;
mem_section = memory_region_find(address_space, base, src_len);
if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {
return;
}
mem = mem_section.mr;
assert(mem);
assert(mem_section.offset_within_address_space == base);
memory_region_sync_dirty_bitmap(mem);
src_base = cpu_physical_memory_map(base, &src_len, 0);
if (!src_base)
return;
if (src_len != src_width * rows) {
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
return;
}
src = src_base;
dest = ds_get_data(ds);
if (dest_col_pitch < 0)
dest -= dest_col_pitch * (cols - 1);
if (dest_row_pitch < 0) {
dest -= dest_row_pitch * (rows - 1);
}
first = -1;
addr = mem_section.offset_within_region;
addr += i * src_width;
src += i * src_width;
dest += i * dest_row_pitch;
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
first = i;
last = i;
}
addr += src_width;
src += src_width;
dest += dest_row_pitch;
}
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(
DisplayState *VAR_0,
MemoryRegion *VAR_1,
target_phys_addr_t VAR_2,
int VAR_3,
int VAR_4,
int VAR_5,
int VAR_6,
int VAR_7,
int VAR_8,
drawfn VAR_9,
void *VAR_10,
int *VAR_11,
int *VAR_12 )
{
target_phys_addr_t src_len;
uint8_t *dest;
uint8_t *src;
uint8_t *src_base;
int VAR_13, VAR_14 = 0;
int VAR_15;
int VAR_16;
ram_addr_t addr;
MemoryRegionSection mem_section;
MemoryRegion *mem;
VAR_16 = *VAR_11;
*VAR_11 = -1;
src_len = VAR_5 * VAR_4;
mem_section = memory_region_find(VAR_1, VAR_2, src_len);
if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {
return;
}
mem = mem_section.mr;
assert(mem);
assert(mem_section.offset_within_address_space == VAR_2);
memory_region_sync_dirty_bitmap(mem);
src_base = cpu_physical_memory_map(VAR_2, &src_len, 0);
if (!src_base)
return;
if (src_len != VAR_5 * VAR_4) {
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
return;
}
src = src_base;
dest = ds_get_data(VAR_0);
if (VAR_7 < 0)
dest -= VAR_7 * (VAR_3 - 1);
if (VAR_6 < 0) {
dest -= VAR_6 * (VAR_4 - 1);
}
VAR_13 = -1;
addr = mem_section.offset_within_region;
addr += VAR_16 * VAR_5;
src += VAR_16 * VAR_5;
dest += VAR_16 * VAR_6;
for (; VAR_16 < VAR_4; VAR_16++) {
VAR_15 = memory_region_get_dirty(mem, addr, VAR_5,
DIRTY_MEMORY_VGA);
if (VAR_15 || VAR_8) {
VAR_9(VAR_10, dest, src, VAR_3, VAR_7);
if (VAR_13 == -1)
VAR_13 = VAR_16;
VAR_14 = VAR_16;
}
addr += VAR_5;
src += VAR_5;
dest += VAR_6;
}
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
if (VAR_13 < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*VAR_11 = VAR_13;
*VAR_12 = VAR_14;
}
| [
"void FUNC_0(\nDisplayState *VAR_0,\nMemoryRegion *VAR_1,\ntarget_phys_addr_t VAR_2,\nint VAR_3,\nint VAR_4,\nint VAR_5,\nint VAR_6,\nint VAR_7,\nint VAR_8,\ndrawfn VAR_9,\nvoid *VAR_10,\nint *VAR_11,\nint *VAR_12 )\n{",
"target_phys_addr_t src_len;",
"uint8_t *dest;",
"uint8_t *src;",
"uint8_t *src_base;",
"int VAR_13, VAR_14 = 0;",
"int VAR_15;",
"int VAR_16;",
"ram_addr_t addr;",
"MemoryRegionSection mem_section;",
"MemoryRegion *mem;",
"VAR_16 = *VAR_11;",
"*VAR_11 = -1;",
"src_len = VAR_5 * VAR_4;",
"mem_section = memory_region_find(VAR_1, VAR_2, src_len);",
"if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {",
"return;",
"}",
"mem = mem_section.mr;",
"assert(mem);",
"assert(mem_section.offset_within_address_space == VAR_2);",
"memory_region_sync_dirty_bitmap(mem);",
"src_base = cpu_physical_memory_map(VAR_2, &src_len, 0);",
"if (!src_base)\nreturn;",
"if (src_len != VAR_5 * VAR_4) {",
"cpu_physical_memory_unmap(src_base, src_len, 0, 0);",
"return;",
"}",
"src = src_base;",
"dest = ds_get_data(VAR_0);",
"if (VAR_7 < 0)\ndest -= VAR_7 * (VAR_3 - 1);",
"if (VAR_6 < 0) {",
"dest -= VAR_6 * (VAR_4 - 1);",
"}",
"VAR_13 = -1;",
"addr = mem_section.offset_within_region;",
"addr += VAR_16 * VAR_5;",
"src += VAR_16 * VAR_5;",
"dest += VAR_16 * VAR_6;",
"for (; VAR_16 < VAR_4; VAR_16++) {",
"VAR_15 = memory_region_get_dirty(mem, addr, VAR_5,\nDIRTY_MEMORY_VGA);",
"if (VAR_15 || VAR_8) {",
"VAR_9(VAR_10, dest, src, VAR_3, VAR_7);",
"if (VAR_13 == -1)\nVAR_13 = VAR_16;",
"VAR_14 = VAR_16;",
"}",
"addr += VAR_5;",
"src += VAR_5;",
"dest += VAR_6;",
"}",
"cpu_physical_memory_unmap(src_base, src_len, 0, 0);",
"if (VAR_13 < 0) {",
"return;",
"}",
"memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,\nDIRTY_MEMORY_VGA);",
"*VAR_11 = VAR_13;",
"*VAR_12 = VAR_14;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
]
]
|
16,583 | build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
AcpiTableMcfg *mcfg;
const MemMapEntry *memmap = guest_info->memmap;
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[VIRT_PCIE_ECAM].base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1;
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL);
}
| false | qemu | 37ad223c515da2fe9f1c679768cb5ccaa42e57e1 | build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
AcpiTableMcfg *mcfg;
const MemMapEntry *memmap = guest_info->memmap;
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[VIRT_PCIE_ECAM].base);
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1;
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, VirtGuestInfo *VAR_2)
{
AcpiTableMcfg *mcfg;
const MemMapEntry *VAR_3 = VAR_2->VAR_3;
int VAR_4 = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(VAR_0, VAR_4);
mcfg->allocation[0].address = cpu_to_le64(VAR_3[VIRT_PCIE_ECAM].base);
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = (VAR_3[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1;
build_header(VAR_1, VAR_0, (void *)mcfg, "MCFG", VAR_4, 1, NULL);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, VirtGuestInfo *VAR_2)\n{",
"AcpiTableMcfg *mcfg;",
"const MemMapEntry *VAR_3 = VAR_2->VAR_3;",
"int VAR_4 = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);",
"mcfg = acpi_data_push(VAR_0, VAR_4);",
"mcfg->allocation[0].address = cpu_to_le64(VAR_3[VIRT_PCIE_ECAM].base);",
"mcfg->allocation[0].pci_segment = cpu_to_le16(0);",
"mcfg->allocation[0].start_bus_number = 0;",
"mcfg->allocation[0].end_bus_number = (VAR_3[VIRT_PCIE_ECAM].size\n/ PCIE_MMCFG_SIZE_MIN) - 1;",
"build_header(VAR_1, VAR_0, (void *)mcfg, \"MCFG\", VAR_4, 1, NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33
]
]
|
16,586 | static void bdrv_raw_init(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
}
| false | qemu | 84a12e6648444f517055138a7d7f25a22d7e1029 | static void bdrv_raw_init(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
}
| [
"static void FUNC_0(void)\n{",
"bdrv_register(&bdrv_raw);",
"bdrv_register(&bdrv_host_device);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
16,587 | void helper_lock(void)
{
spin_lock(&global_cpu_lock);
}
| false | qemu | 677ef6230b603571ae05125db469f7b4c8912a77 | void helper_lock(void)
{
spin_lock(&global_cpu_lock);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
spin_lock(&global_cpu_lock);
}
| [
"void FUNC_0(void)\n{",
"spin_lock(&global_cpu_lock);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
16,588 | static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIORNG *vrng = DO_UPCAST(VirtIORNG, vdev, vdev);
size_t size;
size = pop_an_elem(vrng);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
}
}
| false | qemu | 904d6f588063fb5ad2b61998acdf1e73fb465067 | static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIORNG *vrng = DO_UPCAST(VirtIORNG, vdev, vdev);
size_t size;
size = pop_an_elem(vrng);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)
{
VirtIORNG *vrng = DO_UPCAST(VirtIORNG, VAR_0, VAR_0);
size_t size;
size = pop_an_elem(vrng);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
}
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)\n{",
"VirtIORNG *vrng = DO_UPCAST(VirtIORNG, VAR_0, VAR_0);",
"size_t size;",
"size = pop_an_elem(vrng);",
"if (size) {",
"rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
16,589 | bool vfio_blacklist_opt_rom(VFIOPCIDevice *vdev)
{
PCIDevice *pdev = &vdev->pdev;
uint16_t vendor_id, device_id;
int count = 0;
vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);
device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);
while (count < ARRAY_SIZE(romblacklist)) {
if (romblacklist[count].vendor_id == vendor_id &&
romblacklist[count].device_id == device_id) {
return true;
}
count++;
}
return false;
}
| false | qemu | 056dfcb695cde3c62b7dc1d5ed6d2e38b3a73e29 | bool vfio_blacklist_opt_rom(VFIOPCIDevice *vdev)
{
PCIDevice *pdev = &vdev->pdev;
uint16_t vendor_id, device_id;
int count = 0;
vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);
device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);
while (count < ARRAY_SIZE(romblacklist)) {
if (romblacklist[count].vendor_id == vendor_id &&
romblacklist[count].device_id == device_id) {
return true;
}
count++;
}
return false;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(VFIOPCIDevice *vdev)
{
PCIDevice *pdev = &vdev->pdev;
uint16_t vendor_id, device_id;
int VAR_0 = 0;
vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);
device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);
while (VAR_0 < ARRAY_SIZE(romblacklist)) {
if (romblacklist[VAR_0].vendor_id == vendor_id &&
romblacklist[VAR_0].device_id == device_id) {
return true;
}
VAR_0++;
}
return false;
}
| [
"bool FUNC_0(VFIOPCIDevice *vdev)\n{",
"PCIDevice *pdev = &vdev->pdev;",
"uint16_t vendor_id, device_id;",
"int VAR_0 = 0;",
"vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);",
"device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);",
"while (VAR_0 < ARRAY_SIZE(romblacklist)) {",
"if (romblacklist[VAR_0].vendor_id == vendor_id &&\nromblacklist[VAR_0].device_id == device_id) {",
"return true;",
"}",
"VAR_0++;",
"}",
"return false;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
]
|
16,590 | static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write)
{
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
if (!bus->devices[devfn])
goto found;
}
return NULL;
found: ;
} else if (bus->devices[devfn]) {
return NULL;
}
pci_dev->bus = bus;
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));
pci_config_alloc(pci_dev);
pci_set_default_subsystem_id(pci_dev);
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
pci_dev->version_id = 2; /* Current pci device vmstate version */
return pci_dev;
}
| false | qemu | fb23162885f7fd8cf7334bed22c25ac32c7d8b9d | static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write)
{
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
if (!bus->devices[devfn])
goto found;
}
return NULL;
found: ;
} else if (bus->devices[devfn]) {
return NULL;
}
pci_dev->bus = bus;
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));
pci_config_alloc(pci_dev);
pci_set_default_subsystem_id(pci_dev);
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
pci_dev->version_id = 2;
return pci_dev;
}
| {
"code": [],
"line_no": []
} | static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write)
{
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
if (!bus->devices[devfn])
goto found;
}
return NULL;
found: ;
} else if (bus->devices[devfn]) {
return NULL;
}
pci_dev->bus = bus;
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));
pci_config_alloc(pci_dev);
pci_set_default_subsystem_id(pci_dev);
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
pci_dev->version_id = 2;
return pci_dev;
}
| [
"static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus,\nconst char *name, int devfn,\nPCIConfigReadFunc *config_read,\nPCIConfigWriteFunc *config_write)\n{",
"if (devfn < 0) {",
"for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {",
"if (!bus->devices[devfn])\ngoto found;",
"}",
"return NULL;",
"found: ;",
"} else if (bus->devices[devfn]) {",
"return NULL;",
"}",
"pci_dev->bus = bus;",
"pci_dev->devfn = devfn;",
"pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);",
"memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));",
"pci_config_alloc(pci_dev);",
"pci_set_default_subsystem_id(pci_dev);",
"pci_init_cmask(pci_dev);",
"pci_init_wmask(pci_dev);",
"if (!config_read)\nconfig_read = pci_default_read_config;",
"if (!config_write)\nconfig_write = pci_default_write_config;",
"pci_dev->config_read = config_read;",
"pci_dev->config_write = config_write;",
"bus->devices[devfn] = pci_dev;",
"pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);",
"pci_dev->version_id = 2;",
"return pci_dev;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
]
|
16,591 | static int pcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *src = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
int sample_size, c, n, ret, samples_per_block;
uint8_t *samples;
int32_t *dst_int32_t;
sample_size = av_get_bits_per_sample(avctx->codec_id) / 8;
/* av_get_bits_per_sample returns 0 for AV_CODEC_ID_PCM_DVD */
samples_per_block = 1;
if (AV_CODEC_ID_PCM_DVD == avctx->codec_id) {
if (avctx->bits_per_coded_sample != 20 &&
avctx->bits_per_coded_sample != 24) {
av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n");
return AVERROR(EINVAL);
}
/* 2 samples are interleaved per block in PCM_DVD */
samples_per_block = 2;
sample_size = avctx->bits_per_coded_sample * 2 / 8;
} else if (avctx->codec_id == AV_CODEC_ID_PCM_LXF) {
/* we process 40-bit blocks per channel for LXF */
samples_per_block = 2;
sample_size = 5;
}
if (sample_size == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
return AVERROR(EINVAL);
}
n = avctx->channels * sample_size;
if (n && buf_size % n) {
if (buf_size < n) {
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
} else
buf_size -= buf_size % n;
}
n = buf_size / sample_size;
/* get output buffer */
s->frame.nb_samples = n * samples_per_block / avctx->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples = s->frame.data[0];
switch (avctx->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
DECODE(32, le32, src, samples, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
DECODE(32, be32, src, samples, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
DECODE(32, le24, src, samples, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
DECODE(32, be24, src, samples, n, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
DECODE(32, le24, src, samples, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
DECODE(32, be24, src, samples, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; n > 0; n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4; // sync flags are here
AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] +
(ff_reverse[v & 0xff] << 8));
samples += 2;
}
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
{
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
samples = s->frame.extended_data[c];
#if HAVE_BIGENDIAN
DECODE(16, le16, src, samples, n, 0, 0)
#else
memcpy(samples, src, n * 2);
#endif
src += n * 2;
}
break;
}
case AV_CODEC_ID_PCM_U16LE:
DECODE(16, le16, src, samples, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
DECODE(16, be16, src, samples, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
for (; n > 0; n--)
*samples++ = *src++ + 128;
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
DECODE(64, le64, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
DECODE(32, le32, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
DECODE(16, le16, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
DECODE(64, be64, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
DECODE(32, be32, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
DECODE(16, be16, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif /* HAVE_BIGENDIAN */
case AV_CODEC_ID_PCM_U8:
memcpy(samples, src, n * sample_size);
break;
case AV_CODEC_ID_PCM_ZORK:
for (; n > 0; n--) {
int v = *src++;
if (v < 128)
v = 128 - v;
*samples++ = v;
}
break;
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
for (; n > 0; n--) {
AV_WN16A(samples, s->table[*src++]);
samples += 2;
}
break;
case AV_CODEC_ID_PCM_DVD:
{
const uint8_t *src8;
dst_int32_t = (int32_t *)s->frame.data[0];
n /= avctx->channels;
switch (avctx->bits_per_coded_sample) {
case 20:
while (n--) {
c = avctx->channels;
src8 = src + 4 * c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 & 0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ & 0x0f) << 12);
}
src = src8;
}
break;
case 24:
while (n--) {
c = avctx->channels;
src8 = src + 4 * c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
}
src = src8;
}
break;
}
break;
}
case AV_CODEC_ID_PCM_LXF:
{
int i;
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
dst_int32_t = (int32_t *)s->frame.extended_data[c];
for (i = 0; i < n; i++) {
// extract low 20 bits and expand to 32 bits
*dst_int32_t++ = (src[2] << 28) |
(src[1] << 20) |
(src[0] << 12) |
((src[2] & 0x0F) << 8) |
src[1];
// extract high 20 bits and expand to 32 bits
*dst_int32_t++ = (src[4] << 24) |
(src[3] << 16) |
((src[2] & 0xF0) << 8) |
(src[4] << 4) |
(src[3] >> 4);
src += 5;
}
}
break;
}
default:
return -1;
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return buf_size;
}
| false | FFmpeg | 00dd9a6d6a5c3cc209082023595354a81aff9bb9 | static int pcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *src = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
int sample_size, c, n, ret, samples_per_block;
uint8_t *samples;
int32_t *dst_int32_t;
sample_size = av_get_bits_per_sample(avctx->codec_id) / 8;
samples_per_block = 1;
if (AV_CODEC_ID_PCM_DVD == avctx->codec_id) {
if (avctx->bits_per_coded_sample != 20 &&
avctx->bits_per_coded_sample != 24) {
av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n");
return AVERROR(EINVAL);
}
samples_per_block = 2;
sample_size = avctx->bits_per_coded_sample * 2 / 8;
} else if (avctx->codec_id == AV_CODEC_ID_PCM_LXF) {
samples_per_block = 2;
sample_size = 5;
}
if (sample_size == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
return AVERROR(EINVAL);
}
n = avctx->channels * sample_size;
if (n && buf_size % n) {
if (buf_size < n) {
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
} else
buf_size -= buf_size % n;
}
n = buf_size / sample_size;
s->frame.nb_samples = n * samples_per_block / avctx->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples = s->frame.data[0];
switch (avctx->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
DECODE(32, le32, src, samples, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
DECODE(32, be32, src, samples, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
DECODE(32, le24, src, samples, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
DECODE(32, be24, src, samples, n, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
DECODE(32, le24, src, samples, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
DECODE(32, be24, src, samples, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; n > 0; n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4;
AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] +
(ff_reverse[v & 0xff] << 8));
samples += 2;
}
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
{
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
samples = s->frame.extended_data[c];
#if HAVE_BIGENDIAN
DECODE(16, le16, src, samples, n, 0, 0)
#else
memcpy(samples, src, n * 2);
#endif
src += n * 2;
}
break;
}
case AV_CODEC_ID_PCM_U16LE:
DECODE(16, le16, src, samples, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
DECODE(16, be16, src, samples, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
for (; n > 0; n--)
*samples++ = *src++ + 128;
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
DECODE(64, le64, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
DECODE(32, le32, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
DECODE(16, le16, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
DECODE(64, be64, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
DECODE(32, be32, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
DECODE(16, be16, src, samples, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif
case AV_CODEC_ID_PCM_U8:
memcpy(samples, src, n * sample_size);
break;
case AV_CODEC_ID_PCM_ZORK:
for (; n > 0; n--) {
int v = *src++;
if (v < 128)
v = 128 - v;
*samples++ = v;
}
break;
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
for (; n > 0; n--) {
AV_WN16A(samples, s->table[*src++]);
samples += 2;
}
break;
case AV_CODEC_ID_PCM_DVD:
{
const uint8_t *src8;
dst_int32_t = (int32_t *)s->frame.data[0];
n /= avctx->channels;
switch (avctx->bits_per_coded_sample) {
case 20:
while (n--) {
c = avctx->channels;
src8 = src + 4 * c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 & 0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ & 0x0f) << 12);
}
src = src8;
}
break;
case 24:
while (n--) {
c = avctx->channels;
src8 = src + 4 * c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
}
src = src8;
}
break;
}
break;
}
case AV_CODEC_ID_PCM_LXF:
{
int i;
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
dst_int32_t = (int32_t *)s->frame.extended_data[c];
for (i = 0; i < n; i++) {
*dst_int32_t++ = (src[2] << 28) |
(src[1] << 20) |
(src[0] << 12) |
((src[2] & 0x0F) << 8) |
src[1];
*dst_int32_t++ = (src[4] << 24) |
(src[3] << 16) |
((src[2] & 0xF0) << 8) |
(src[4] << 4) |
(src[3] >> 4);
src += 5;
}
}
break;
}
default:
return -1;
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
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;
PCMDecode *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
uint8_t *samples;
int32_t *dst_int32_t;
VAR_6 = av_get_bits_per_sample(VAR_0->codec_id) / 8;
VAR_10 = 1;
if (AV_CODEC_ID_PCM_DVD == VAR_0->codec_id) {
if (VAR_0->bits_per_coded_sample != 20 &&
VAR_0->bits_per_coded_sample != 24) {
av_log(VAR_0, AV_LOG_ERROR, "PCM DVD unsupported sample depth\VAR_8");
return AVERROR(EINVAL);
}
VAR_10 = 2;
VAR_6 = VAR_0->bits_per_coded_sample * 2 / 8;
} else if (VAR_0->codec_id == AV_CODEC_ID_PCM_LXF) {
VAR_10 = 2;
VAR_6 = 5;
}
if (VAR_6 == 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_6\VAR_8");
return AVERROR(EINVAL);
}
VAR_8 = VAR_0->channels * VAR_6;
if (VAR_8 && VAR_5 % VAR_8) {
if (VAR_5 < VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "invalid PCM packet\VAR_8");
return -1;
} else
VAR_5 -= VAR_5 % VAR_8;
}
VAR_8 = VAR_5 / VAR_6;
s->frame.nb_samples = VAR_8 * VAR_10 / VAR_0->channels;
if ((VAR_9 = VAR_0->get_buffer(VAR_0, &s->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\VAR_8");
return VAR_9;
}
samples = s->frame.VAR_1[0];
switch (VAR_0->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
DECODE(32, le32, VAR_4, samples, VAR_8, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
DECODE(32, be32, VAR_4, samples, VAR_8, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
DECODE(32, le24, VAR_4, samples, VAR_8, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
DECODE(32, be24, VAR_4, samples, VAR_8, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
DECODE(32, le24, VAR_4, samples, VAR_8, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
DECODE(32, be24, VAR_4, samples, VAR_8, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; VAR_8 > 0; VAR_8--) {
uint32_t VAR_11 = bytestream_get_be24(&VAR_4);
VAR_11 >>= 4;
AV_WN16A(samples, ff_reverse[(VAR_11 >> 8) & 0xff] +
(ff_reverse[VAR_11 & 0xff] << 8));
samples += 2;
}
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
{
VAR_8 /= VAR_0->channels;
for (VAR_7 = 0; VAR_7 < VAR_0->channels; VAR_7++) {
samples = s->frame.extended_data[VAR_7];
#if HAVE_BIGENDIAN
DECODE(16, le16, VAR_4, samples, VAR_8, 0, 0)
#else
memcpy(samples, VAR_4, VAR_8 * 2);
#endif
VAR_4 += VAR_8 * 2;
}
break;
}
case AV_CODEC_ID_PCM_U16LE:
DECODE(16, le16, VAR_4, samples, VAR_8, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
DECODE(16, be16, VAR_4, samples, VAR_8, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
for (; VAR_8 > 0; VAR_8--)
*samples++ = *VAR_4++ + 128;
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
DECODE(64, le64, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
DECODE(32, le32, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
DECODE(16, le16, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
DECODE(64, be64, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
DECODE(32, be32, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
DECODE(16, be16, VAR_4, samples, VAR_8, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif
case AV_CODEC_ID_PCM_U8:
memcpy(samples, VAR_4, VAR_8 * VAR_6);
break;
case AV_CODEC_ID_PCM_ZORK:
for (; VAR_8 > 0; VAR_8--) {
int VAR_11 = *VAR_4++;
if (VAR_11 < 128)
VAR_11 = 128 - VAR_11;
*samples++ = VAR_11;
}
break;
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
for (; VAR_8 > 0; VAR_8--) {
AV_WN16A(samples, s->table[*VAR_4++]);
samples += 2;
}
break;
case AV_CODEC_ID_PCM_DVD:
{
const uint8_t *VAR_12;
dst_int32_t = (int32_t *)s->frame.VAR_1[0];
VAR_8 /= VAR_0->channels;
switch (VAR_0->bits_per_coded_sample) {
case 20:
while (VAR_8--) {
VAR_7 = VAR_0->channels;
VAR_12 = VAR_4 + 4 * VAR_7;
while (VAR_7--) {
*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12 & 0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++ & 0x0f) << 12);
}
VAR_4 = VAR_12;
}
break;
case 24:
while (VAR_8--) {
VAR_7 = VAR_0->channels;
VAR_12 = VAR_4 + 4 * VAR_7;
while (VAR_7--) {
*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++) << 8);
}
VAR_4 = VAR_12;
}
break;
}
break;
}
case AV_CODEC_ID_PCM_LXF:
{
int VAR_13;
VAR_8 /= VAR_0->channels;
for (VAR_7 = 0; VAR_7 < VAR_0->channels; VAR_7++) {
dst_int32_t = (int32_t *)s->frame.extended_data[VAR_7];
for (VAR_13 = 0; VAR_13 < VAR_8; VAR_13++) {
*dst_int32_t++ = (VAR_4[2] << 28) |
(VAR_4[1] << 20) |
(VAR_4[0] << 12) |
((VAR_4[2] & 0x0F) << 8) |
VAR_4[1];
*dst_int32_t++ = (VAR_4[4] << 24) |
(VAR_4[3] << 16) |
((VAR_4[2] & 0xF0) << 8) |
(VAR_4[4] << 4) |
(VAR_4[3] >> 4);
VAR_4 += 5;
}
}
break;
}
default:
return -1;
}
*VAR_2 = 1;
*(AVFrame *)VAR_1 = s->frame;
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;",
"PCMDecode *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"uint8_t *samples;",
"int32_t *dst_int32_t;",
"VAR_6 = av_get_bits_per_sample(VAR_0->codec_id) / 8;",
"VAR_10 = 1;",
"if (AV_CODEC_ID_PCM_DVD == VAR_0->codec_id) {",
"if (VAR_0->bits_per_coded_sample != 20 &&\nVAR_0->bits_per_coded_sample != 24) {",
"av_log(VAR_0, AV_LOG_ERROR, \"PCM DVD unsupported sample depth\\VAR_8\");",
"return AVERROR(EINVAL);",
"}",
"VAR_10 = 2;",
"VAR_6 = VAR_0->bits_per_coded_sample * 2 / 8;",
"} else if (VAR_0->codec_id == AV_CODEC_ID_PCM_LXF) {",
"VAR_10 = 2;",
"VAR_6 = 5;",
"}",
"if (VAR_6 == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_6\\VAR_8\");",
"return AVERROR(EINVAL);",
"}",
"VAR_8 = VAR_0->channels * VAR_6;",
"if (VAR_8 && VAR_5 % VAR_8) {",
"if (VAR_5 < VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid PCM packet\\VAR_8\");",
"return -1;",
"} else",
"VAR_5 -= VAR_5 % VAR_8;",
"}",
"VAR_8 = VAR_5 / VAR_6;",
"s->frame.nb_samples = VAR_8 * VAR_10 / VAR_0->channels;",
"if ((VAR_9 = VAR_0->get_buffer(VAR_0, &s->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\VAR_8\");",
"return VAR_9;",
"}",
"samples = s->frame.VAR_1[0];",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_PCM_U32LE:\nDECODE(32, le32, VAR_4, samples, VAR_8, 0, 0x80000000)\nbreak;",
"case AV_CODEC_ID_PCM_U32BE:\nDECODE(32, be32, VAR_4, samples, VAR_8, 0, 0x80000000)\nbreak;",
"case AV_CODEC_ID_PCM_S24LE:\nDECODE(32, le24, VAR_4, samples, VAR_8, 8, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S24BE:\nDECODE(32, be24, VAR_4, samples, VAR_8, 8, 0)\nbreak;",
"case AV_CODEC_ID_PCM_U24LE:\nDECODE(32, le24, VAR_4, samples, VAR_8, 8, 0x800000)\nbreak;",
"case AV_CODEC_ID_PCM_U24BE:\nDECODE(32, be24, VAR_4, samples, VAR_8, 8, 0x800000)\nbreak;",
"case AV_CODEC_ID_PCM_S24DAUD:\nfor (; VAR_8 > 0; VAR_8--) {",
"uint32_t VAR_11 = bytestream_get_be24(&VAR_4);",
"VAR_11 >>= 4;",
"AV_WN16A(samples, ff_reverse[(VAR_11 >> 8) & 0xff] +\n(ff_reverse[VAR_11 & 0xff] << 8));",
"samples += 2;",
"}",
"break;",
"case AV_CODEC_ID_PCM_S16LE_PLANAR:\n{",
"VAR_8 /= VAR_0->channels;",
"for (VAR_7 = 0; VAR_7 < VAR_0->channels; VAR_7++) {",
"samples = s->frame.extended_data[VAR_7];",
"#if HAVE_BIGENDIAN\nDECODE(16, le16, VAR_4, samples, VAR_8, 0, 0)\n#else\nmemcpy(samples, VAR_4, VAR_8 * 2);",
"#endif\nVAR_4 += VAR_8 * 2;",
"}",
"break;",
"}",
"case AV_CODEC_ID_PCM_U16LE:\nDECODE(16, le16, VAR_4, samples, VAR_8, 0, 0x8000)\nbreak;",
"case AV_CODEC_ID_PCM_U16BE:\nDECODE(16, be16, VAR_4, samples, VAR_8, 0, 0x8000)\nbreak;",
"case AV_CODEC_ID_PCM_S8:\nfor (; VAR_8 > 0; VAR_8--)",
"*samples++ = *VAR_4++ + 128;",
"break;",
"#if HAVE_BIGENDIAN\ncase AV_CODEC_ID_PCM_F64LE:\nDECODE(64, le64, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S32LE:\ncase AV_CODEC_ID_PCM_F32LE:\nDECODE(32, le32, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16LE:\nDECODE(16, le16, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F64BE:\ncase AV_CODEC_ID_PCM_F32BE:\ncase AV_CODEC_ID_PCM_S32BE:\ncase AV_CODEC_ID_PCM_S16BE:\n#else\ncase AV_CODEC_ID_PCM_F64BE:\nDECODE(64, be64, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F32BE:\ncase AV_CODEC_ID_PCM_S32BE:\nDECODE(32, be32, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16BE:\nDECODE(16, be16, VAR_4, samples, VAR_8, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F64LE:\ncase AV_CODEC_ID_PCM_F32LE:\ncase AV_CODEC_ID_PCM_S32LE:\ncase AV_CODEC_ID_PCM_S16LE:\n#endif\ncase AV_CODEC_ID_PCM_U8:\nmemcpy(samples, VAR_4, VAR_8 * VAR_6);",
"break;",
"case AV_CODEC_ID_PCM_ZORK:\nfor (; VAR_8 > 0; VAR_8--) {",
"int VAR_11 = *VAR_4++;",
"if (VAR_11 < 128)\nVAR_11 = 128 - VAR_11;",
"*samples++ = VAR_11;",
"}",
"break;",
"case AV_CODEC_ID_PCM_ALAW:\ncase AV_CODEC_ID_PCM_MULAW:\nfor (; VAR_8 > 0; VAR_8--) {",
"AV_WN16A(samples, s->table[*VAR_4++]);",
"samples += 2;",
"}",
"break;",
"case AV_CODEC_ID_PCM_DVD:\n{",
"const uint8_t *VAR_12;",
"dst_int32_t = (int32_t *)s->frame.VAR_1[0];",
"VAR_8 /= VAR_0->channels;",
"switch (VAR_0->bits_per_coded_sample) {",
"case 20:\nwhile (VAR_8--) {",
"VAR_7 = VAR_0->channels;",
"VAR_12 = VAR_4 + 4 * VAR_7;",
"while (VAR_7--) {",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12 & 0xf0) << 8);",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++ & 0x0f) << 12);",
"}",
"VAR_4 = VAR_12;",
"}",
"break;",
"case 24:\nwhile (VAR_8--) {",
"VAR_7 = VAR_0->channels;",
"VAR_12 = VAR_4 + 4 * VAR_7;",
"while (VAR_7--) {",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++) << 8);",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_4) << 16) + ((*VAR_12++) << 8);",
"}",
"VAR_4 = VAR_12;",
"}",
"break;",
"}",
"break;",
"}",
"case AV_CODEC_ID_PCM_LXF:\n{",
"int VAR_13;",
"VAR_8 /= VAR_0->channels;",
"for (VAR_7 = 0; VAR_7 < VAR_0->channels; VAR_7++) {",
"dst_int32_t = (int32_t *)s->frame.extended_data[VAR_7];",
"for (VAR_13 = 0; VAR_13 < VAR_8; VAR_13++) {",
"*dst_int32_t++ = (VAR_4[2] << 28) |\n(VAR_4[1] << 20) |\n(VAR_4[0] << 12) |\n((VAR_4[2] & 0x0F) << 8) |\nVAR_4[1];",
"*dst_int32_t++ = (VAR_4[4] << 24) |\n(VAR_4[3] << 16) |\n((VAR_4[2] & 0xF0) << 8) |\n(VAR_4[4] << 4) |\n(VAR_4[3] >> 4);",
"VAR_4 += 5;",
"}",
"}",
"break;",
"}",
"default:\nreturn -1;",
"}",
"*VAR_2 = 1;",
"*(AVFrame *)VAR_1 = s->frame;",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111,
113,
115
],
[
117,
119,
121
],
[
123,
125,
127
],
[
129,
131,
133
],
[
135,
137,
139
],
[
141,
143,
145
],
[
147,
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175,
177,
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193,
195,
197
],
[
199,
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213,
215,
217,
219
],
[
221,
223,
225,
227
],
[
229,
231,
233
],
[
235,
237,
239,
241,
243,
245,
247,
249
],
[
251,
253,
255,
257
],
[
259,
261,
263
],
[
265,
267,
269,
271,
273,
275,
277
],
[
279
],
[
281,
283
],
[
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297,
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389,
391,
393,
395,
397
],
[
401,
403,
405,
407,
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
429
],
[
431
],
[
435
],
[
437
]
]
|
16,592 | void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
{
#ifdef DEBUG_IDE
printf("%s: 0x%08x\n", __func__, val);
#endif
/* Ignore writes to SSBM if it keeps the old value */
if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) {
if (!(val & BM_CMD_START)) {
/*
* We can't cancel Scatter Gather DMA in the middle of the
* operation or a partial (not full) DMA transfer would reach
* the storage so we wait for completion instead (we beahve
* like if the DMA was completed by the time the guest trying
* to cancel dma with bmdma_cmd_writeb with BM_CMD_START not
* set).
*
* In the future we'll be able to safely cancel the I/O if the
* whole DMA operation will be submitted to disk with a single
* aio operation with preadv/pwritev.
*/
if (bm->bus->dma->aiocb) {
qemu_aio_flush();
assert(bm->bus->dma->aiocb == NULL);
assert((bm->status & BM_STATUS_DMAING) == 0);
}
} else {
bm->cur_addr = bm->addr;
if (!(bm->status & BM_STATUS_DMAING)) {
bm->status |= BM_STATUS_DMAING;
/* start dma transfer if possible */
if (bm->dma_cb)
bm->dma_cb(bmdma_active_if(bm), 0);
}
}
}
bm->cmd = val & 0x09;
}
| false | qemu | 922453bca6a927bb527068ae8679d587cfa45dbc | void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
{
#ifdef DEBUG_IDE
printf("%s: 0x%08x\n", __func__, val);
#endif
if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) {
if (!(val & BM_CMD_START)) {
if (bm->bus->dma->aiocb) {
qemu_aio_flush();
assert(bm->bus->dma->aiocb == NULL);
assert((bm->status & BM_STATUS_DMAING) == 0);
}
} else {
bm->cur_addr = bm->addr;
if (!(bm->status & BM_STATUS_DMAING)) {
bm->status |= BM_STATUS_DMAING;
if (bm->dma_cb)
bm->dma_cb(bmdma_active_if(bm), 0);
}
}
}
bm->cmd = val & 0x09;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BMDMAState *VAR_0, uint32_t VAR_1)
{
#ifdef DEBUG_IDE
printf("%s: 0x%08x\n", __func__, VAR_1);
#endif
if ((VAR_1 & BM_CMD_START) != (VAR_0->cmd & BM_CMD_START)) {
if (!(VAR_1 & BM_CMD_START)) {
if (VAR_0->bus->dma->aiocb) {
qemu_aio_flush();
assert(VAR_0->bus->dma->aiocb == NULL);
assert((VAR_0->status & BM_STATUS_DMAING) == 0);
}
} else {
VAR_0->cur_addr = VAR_0->addr;
if (!(VAR_0->status & BM_STATUS_DMAING)) {
VAR_0->status |= BM_STATUS_DMAING;
if (VAR_0->dma_cb)
VAR_0->dma_cb(bmdma_active_if(VAR_0), 0);
}
}
}
VAR_0->cmd = VAR_1 & 0x09;
}
| [
"void FUNC_0(BMDMAState *VAR_0, uint32_t VAR_1)\n{",
"#ifdef DEBUG_IDE\nprintf(\"%s: 0x%08x\\n\", __func__, VAR_1);",
"#endif\nif ((VAR_1 & BM_CMD_START) != (VAR_0->cmd & BM_CMD_START)) {",
"if (!(VAR_1 & BM_CMD_START)) {",
"if (VAR_0->bus->dma->aiocb) {",
"qemu_aio_flush();",
"assert(VAR_0->bus->dma->aiocb == NULL);",
"assert((VAR_0->status & BM_STATUS_DMAING) == 0);",
"}",
"} else {",
"VAR_0->cur_addr = VAR_0->addr;",
"if (!(VAR_0->status & BM_STATUS_DMAING)) {",
"VAR_0->status |= BM_STATUS_DMAING;",
"if (VAR_0->dma_cb)\nVAR_0->dma_cb(bmdma_active_if(VAR_0), 0);",
"}",
"}",
"}",
"VAR_0->cmd = VAR_1 & 0x09;",
"}"
]
| [
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
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
]
]
|
16,593 | static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
{
struct virtio_9p_config *cfg;
V9fsState *s = to_virtio_9p(vdev);
cfg = g_malloc0(sizeof(struct virtio_9p_config) +
s->tag_len);
stw_raw(&cfg->tag_len, s->tag_len);
memcpy(cfg->tag, s->tag, s->tag_len);
memcpy(config, cfg, s->config_size);
g_free(cfg);
}
| false | qemu | e9a0152ba182c5ce9929ee60f83a37b61a1d5195 | static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
{
struct virtio_9p_config *cfg;
V9fsState *s = to_virtio_9p(vdev);
cfg = g_malloc0(sizeof(struct virtio_9p_config) +
s->tag_len);
stw_raw(&cfg->tag_len, s->tag_len);
memcpy(cfg->tag, s->tag, s->tag_len);
memcpy(config, cfg, s->config_size);
g_free(cfg);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIODevice *VAR_0, uint8_t *VAR_1)
{
struct virtio_9p_config *VAR_2;
V9fsState *s = to_virtio_9p(VAR_0);
VAR_2 = g_malloc0(sizeof(struct virtio_9p_config) +
s->tag_len);
stw_raw(&VAR_2->tag_len, s->tag_len);
memcpy(VAR_2->tag, s->tag, s->tag_len);
memcpy(VAR_1, VAR_2, s->config_size);
g_free(VAR_2);
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, uint8_t *VAR_1)\n{",
"struct virtio_9p_config *VAR_2;",
"V9fsState *s = to_virtio_9p(VAR_0);",
"VAR_2 = g_malloc0(sizeof(struct virtio_9p_config) +\ns->tag_len);",
"stw_raw(&VAR_2->tag_len, s->tag_len);",
"memcpy(VAR_2->tag, s->tag, s->tag_len);",
"memcpy(VAR_1, VAR_2, s->config_size);",
"g_free(VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
16,594 | static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len;
NetClientState *nc;
NetSocketState *s;
/* fd passed: multicast: "learn" dgram_dst address from bound address and save it
* Because this may be "shared" socket from a "master" process, datagrams would be recv()
* by ONLY ONE process: we must "clone" this dgram socket --jjo
*/
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
/* must be bound */
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
/* clone dgram socket */
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
/* error already reported by net_socket_mcast_create() */
goto err;
}
/* clone newfd to fd, close newfd */
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
/* mcast: save bound address as dst */
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| false | qemu | ed6273e26fdfb94a282dbbf1234a75422c6b4c4b | static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len;
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
goto err;
}
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| {
"code": [],
"line_no": []
} | static NetSocketState *FUNC_0(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in VAR_0;
int VAR_1;
socklen_t saddr_len;
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) {
if (VAR_0.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
VAR_1 = net_socket_mcast_create(&VAR_0, NULL);
if (VAR_1 < 0) {
goto err;
}
dup2(VAR_1, fd);
close(VAR_1);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = VAR_0;
}
return s;
err:
closesocket(fd);
return NULL;
}
| [
"static NetSocketState *FUNC_0(NetClientState *peer,\nconst char *model,\nconst char *name,\nint fd, int is_connected)\n{",
"struct sockaddr_in VAR_0;",
"int VAR_1;",
"socklen_t saddr_len;",
"NetClientState *nc;",
"NetSocketState *s;",
"if (is_connected) {",
"if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) {",
"if (VAR_0.sin_addr.s_addr == 0) {",
"fprintf(stderr, \"qemu: error: init_dgram: fd=%d unbound, \"\n\"cannot setup multicast dst addr\\n\", fd);",
"goto err;",
"}",
"VAR_1 = net_socket_mcast_create(&VAR_0, NULL);",
"if (VAR_1 < 0) {",
"goto err;",
"}",
"dup2(VAR_1, fd);",
"close(VAR_1);",
"} else {",
"fprintf(stderr,\n\"qemu: error: init_dgram: fd=%d failed getsockname(): %s\\n\",\nfd, strerror(errno));",
"goto err;",
"}",
"}",
"nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);",
"snprintf(nc->info_str, sizeof(nc->info_str),\n\"socket: fd=%d (%s mcast=%s:%d)\",\nfd, is_connected ? \"cloned\" : \"\",\ninet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port));",
"s = DO_UPCAST(NetSocketState, nc, nc);",
"s->fd = fd;",
"s->listen_fd = -1;",
"s->send_fn = net_socket_send_dgram;",
"net_socket_read_poll(s, true);",
"if (is_connected) {",
"s->dgram_dst = VAR_0;",
"}",
"return s;",
"err:\nclosesocket(fd);",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89,
91,
93,
95
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
123
],
[
127,
129
],
[
131
],
[
133
]
]
|
16,595 | static int qcow2_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags, size_t cluster_size, int prealloc,
QEMUOptionParameter *options, int version,
Error **errp)
{
/* Calculate cluster_bits */
int cluster_bits;
cluster_bits = ffs(cluster_size) - 1;
if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS ||
(1 << cluster_bits) != cluster_size)
{
error_setg(errp, "Cluster size must be a power of two between %d and "
"%dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
/*
* Open the image file and write a minimal qcow2 header.
*
* We keep things simple and start with a zero-sized image. We also
* do without refcount blocks or a L1 table for now. We'll fix the
* inconsistency later.
*
* We do need a refcount table because growing the refcount table means
* allocating two new refcount blocks - the seconds of which would be at
* 2 GB for 64k clusters, and we don't want to have a 2 GB initial file
* size for any qcow2 image.
*/
BlockDriverState* bs;
QCowHeader header;
uint8_t* refcount_table;
Error *local_err = NULL;
int ret;
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
ret = bdrv_file_open(&bs, filename, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
/* Write the header */
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(version);
header.cluster_bits = cpu_to_be32(cluster_bits);
header.size = cpu_to_be64(0);
header.l1_table_offset = cpu_to_be64(0);
header.l1_size = cpu_to_be32(0);
header.refcount_table_offset = cpu_to_be64(cluster_size);
header.refcount_table_clusters = cpu_to_be32(1);
header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);
header.header_length = cpu_to_be32(sizeof(header));
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
if (flags & BLOCK_FLAG_LAZY_REFCOUNTS) {
header.compatible_features |=
cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);
}
ret = bdrv_pwrite(bs, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write qcow2 header");
goto out;
}
/* Write an empty refcount table */
refcount_table = g_malloc0(cluster_size);
ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size);
g_free(refcount_table);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write refcount table");
goto out;
}
bdrv_close(bs);
/*
* And now open the image and make it consistent first (i.e. increase the
* refcount of the cluster that is occupied by the header and the refcount
* table)
*/
BlockDriver* drv = bdrv_find_format("qcow2");
assert(drv != NULL);
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
ret = qcow2_alloc_clusters(bs, 2 * cluster_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not allocate clusters for qcow2 "
"header and refcount table");
goto out;
} else if (ret != 0) {
error_report("Huh, first cluster in empty image is already in use?");
abort();
}
/* Okay, now that we have a valid image, let's give it the right size */
ret = bdrv_truncate(bs, total_size * BDRV_SECTOR_SIZE);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not resize image");
goto out;
}
/* Want a backing file? There you go.*/
if (backing_file) {
ret = bdrv_change_backing_file(bs, backing_file, backing_format);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not assign backing file '%s' "
"with format '%s'", backing_file, backing_format);
goto out;
}
}
/* And if we're supposed to preallocate metadata, do that now */
if (prealloc) {
BDRVQcowState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = preallocate(bs);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not preallocate metadata");
goto out;
}
}
bdrv_close(bs);
/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
goto out;
}
ret = 0;
out:
bdrv_unref(bs);
return ret;
}
| false | qemu | c9fbb99d41b05acf0d7b93deb2fcdbf9047c238e | static int qcow2_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags, size_t cluster_size, int prealloc,
QEMUOptionParameter *options, int version,
Error **errp)
{
int cluster_bits;
cluster_bits = ffs(cluster_size) - 1;
if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS ||
(1 << cluster_bits) != cluster_size)
{
error_setg(errp, "Cluster size must be a power of two between %d and "
"%dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
BlockDriverState* bs;
QCowHeader header;
uint8_t* refcount_table;
Error *local_err = NULL;
int ret;
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
ret = bdrv_file_open(&bs, filename, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(version);
header.cluster_bits = cpu_to_be32(cluster_bits);
header.size = cpu_to_be64(0);
header.l1_table_offset = cpu_to_be64(0);
header.l1_size = cpu_to_be32(0);
header.refcount_table_offset = cpu_to_be64(cluster_size);
header.refcount_table_clusters = cpu_to_be32(1);
header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);
header.header_length = cpu_to_be32(sizeof(header));
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
if (flags & BLOCK_FLAG_LAZY_REFCOUNTS) {
header.compatible_features |=
cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);
}
ret = bdrv_pwrite(bs, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write qcow2 header");
goto out;
}
refcount_table = g_malloc0(cluster_size);
ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size);
g_free(refcount_table);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write refcount table");
goto out;
}
bdrv_close(bs);
BlockDriver* drv = bdrv_find_format("qcow2");
assert(drv != NULL);
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
ret = qcow2_alloc_clusters(bs, 2 * cluster_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not allocate clusters for qcow2 "
"header and refcount table");
goto out;
} else if (ret != 0) {
error_report("Huh, first cluster in empty image is already in use?");
abort();
}
ret = bdrv_truncate(bs, total_size * BDRV_SECTOR_SIZE);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not resize image");
goto out;
}
if (backing_file) {
ret = bdrv_change_backing_file(bs, backing_file, backing_format);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not assign backing file '%s' "
"with format '%s'", backing_file, backing_format);
goto out;
}
}
if (prealloc) {
BDRVQcowState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = preallocate(bs);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not preallocate metadata");
goto out;
}
}
bdrv_close(bs);
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
goto out;
}
ret = 0;
out:
bdrv_unref(bs);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, int64_t VAR_1,
const char *VAR_2, const char *VAR_3,
int VAR_4, size_t VAR_5, int VAR_6,
QEMUOptionParameter *VAR_7, int VAR_8,
Error **VAR_9)
{
int VAR_10;
VAR_10 = ffs(VAR_5) - 1;
if (VAR_10 < MIN_CLUSTER_BITS || VAR_10 > MAX_CLUSTER_BITS ||
(1 << VAR_10) != VAR_5)
{
error_setg(VAR_9, "Cluster size must be a power of two between %d and "
"%dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
BlockDriverState* bs;
QCowHeader header;
uint8_t* refcount_table;
Error *local_err = NULL;
int VAR_11;
VAR_11 = bdrv_create_file(VAR_0, VAR_7, &local_err);
if (VAR_11 < 0) {
error_propagate(VAR_9, local_err);
return VAR_11;
}
VAR_11 = bdrv_file_open(&bs, VAR_0, NULL, BDRV_O_RDWR, &local_err);
if (VAR_11 < 0) {
error_propagate(VAR_9, local_err);
return VAR_11;
}
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.VAR_8 = cpu_to_be32(VAR_8);
header.VAR_10 = cpu_to_be32(VAR_10);
header.size = cpu_to_be64(0);
header.l1_table_offset = cpu_to_be64(0);
header.l1_size = cpu_to_be32(0);
header.refcount_table_offset = cpu_to_be64(VAR_5);
header.refcount_table_clusters = cpu_to_be32(1);
header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);
header.header_length = cpu_to_be32(sizeof(header));
if (VAR_4 & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
if (VAR_4 & BLOCK_FLAG_LAZY_REFCOUNTS) {
header.compatible_features |=
cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);
}
VAR_11 = bdrv_pwrite(bs, 0, &header, sizeof(header));
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not write qcow2 header");
goto out;
}
refcount_table = g_malloc0(VAR_5);
VAR_11 = bdrv_pwrite(bs, VAR_5, refcount_table, VAR_5);
g_free(refcount_table);
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not write refcount table");
goto out;
}
bdrv_close(bs);
BlockDriver* drv = bdrv_find_format("qcow2");
assert(drv != NULL);
VAR_11 = bdrv_open(bs, VAR_0, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);
if (VAR_11 < 0) {
error_propagate(VAR_9, local_err);
goto out;
}
VAR_11 = qcow2_alloc_clusters(bs, 2 * VAR_5);
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not allocate clusters for qcow2 "
"header and refcount table");
goto out;
} else if (VAR_11 != 0) {
error_report("Huh, first cluster in empty image is already in use?");
abort();
}
VAR_11 = bdrv_truncate(bs, VAR_1 * BDRV_SECTOR_SIZE);
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not resize image");
goto out;
}
if (VAR_2) {
VAR_11 = bdrv_change_backing_file(bs, VAR_2, VAR_3);
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not assign backing file '%s' "
"with format '%s'", VAR_2, VAR_3);
goto out;
}
}
if (VAR_6) {
BDRVQcowState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
VAR_11 = preallocate(bs);
qemu_co_mutex_unlock(&s->lock);
if (VAR_11 < 0) {
error_setg_errno(VAR_9, -VAR_11, "Could not preallocate metadata");
goto out;
}
}
bdrv_close(bs);
VAR_11 = bdrv_open(bs, VAR_0, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
if (error_is_set(&local_err)) {
error_propagate(VAR_9, local_err);
goto out;
}
VAR_11 = 0;
out:
bdrv_unref(bs);
return VAR_11;
}
| [
"static int FUNC_0(const char *VAR_0, int64_t VAR_1,\nconst char *VAR_2, const char *VAR_3,\nint VAR_4, size_t VAR_5, int VAR_6,\nQEMUOptionParameter *VAR_7, int VAR_8,\nError **VAR_9)\n{",
"int VAR_10;",
"VAR_10 = ffs(VAR_5) - 1;",
"if (VAR_10 < MIN_CLUSTER_BITS || VAR_10 > MAX_CLUSTER_BITS ||\n(1 << VAR_10) != VAR_5)\n{",
"error_setg(VAR_9, \"Cluster size must be a power of two between %d and \"\n\"%dk\", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10));",
"return -EINVAL;",
"}",
"BlockDriverState* bs;",
"QCowHeader header;",
"uint8_t* refcount_table;",
"Error *local_err = NULL;",
"int VAR_11;",
"VAR_11 = bdrv_create_file(VAR_0, VAR_7, &local_err);",
"if (VAR_11 < 0) {",
"error_propagate(VAR_9, local_err);",
"return VAR_11;",
"}",
"VAR_11 = bdrv_file_open(&bs, VAR_0, NULL, BDRV_O_RDWR, &local_err);",
"if (VAR_11 < 0) {",
"error_propagate(VAR_9, local_err);",
"return VAR_11;",
"}",
"memset(&header, 0, sizeof(header));",
"header.magic = cpu_to_be32(QCOW_MAGIC);",
"header.VAR_8 = cpu_to_be32(VAR_8);",
"header.VAR_10 = cpu_to_be32(VAR_10);",
"header.size = cpu_to_be64(0);",
"header.l1_table_offset = cpu_to_be64(0);",
"header.l1_size = cpu_to_be32(0);",
"header.refcount_table_offset = cpu_to_be64(VAR_5);",
"header.refcount_table_clusters = cpu_to_be32(1);",
"header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);",
"header.header_length = cpu_to_be32(sizeof(header));",
"if (VAR_4 & BLOCK_FLAG_ENCRYPT) {",
"header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);",
"} else {",
"header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);",
"}",
"if (VAR_4 & BLOCK_FLAG_LAZY_REFCOUNTS) {",
"header.compatible_features |=\ncpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);",
"}",
"VAR_11 = bdrv_pwrite(bs, 0, &header, sizeof(header));",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not write qcow2 header\");",
"goto out;",
"}",
"refcount_table = g_malloc0(VAR_5);",
"VAR_11 = bdrv_pwrite(bs, VAR_5, refcount_table, VAR_5);",
"g_free(refcount_table);",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not write refcount table\");",
"goto out;",
"}",
"bdrv_close(bs);",
"BlockDriver* drv = bdrv_find_format(\"qcow2\");",
"assert(drv != NULL);",
"VAR_11 = bdrv_open(bs, VAR_0, NULL,\nBDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);",
"if (VAR_11 < 0) {",
"error_propagate(VAR_9, local_err);",
"goto out;",
"}",
"VAR_11 = qcow2_alloc_clusters(bs, 2 * VAR_5);",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not allocate clusters for qcow2 \"\n\"header and refcount table\");",
"goto out;",
"} else if (VAR_11 != 0) {",
"error_report(\"Huh, first cluster in empty image is already in use?\");",
"abort();",
"}",
"VAR_11 = bdrv_truncate(bs, VAR_1 * BDRV_SECTOR_SIZE);",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not resize image\");",
"goto out;",
"}",
"if (VAR_2) {",
"VAR_11 = bdrv_change_backing_file(bs, VAR_2, VAR_3);",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not assign backing file '%s' \"\n\"with format '%s'\", VAR_2, VAR_3);",
"goto out;",
"}",
"}",
"if (VAR_6) {",
"BDRVQcowState *s = bs->opaque;",
"qemu_co_mutex_lock(&s->lock);",
"VAR_11 = preallocate(bs);",
"qemu_co_mutex_unlock(&s->lock);",
"if (VAR_11 < 0) {",
"error_setg_errno(VAR_9, -VAR_11, \"Could not preallocate metadata\");",
"goto out;",
"}",
"}",
"bdrv_close(bs);",
"VAR_11 = bdrv_open(bs, VAR_0, NULL,\nBDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_9, local_err);",
"goto out;",
"}",
"VAR_11 = 0;",
"out:\nbdrv_unref(bs);",
"return VAR_11;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309,
311
],
[
313
],
[
315
]
]
|
16,598 | static void tci_out_label(TCGContext *s, TCGArg arg)
{
TCGLabel *label = &s->labels[arg];
if (label->has_value) {
tcg_out_i(s, label->u.value);
assert(label->u.value);
} else {
tcg_out_reloc(s, s->code_ptr, sizeof(tcg_target_ulong), arg, 0);
s->code_ptr += sizeof(tcg_target_ulong);
}
}
| false | qemu | bec1631100323fac0900aea71043d5c4e22fc2fa | static void tci_out_label(TCGContext *s, TCGArg arg)
{
TCGLabel *label = &s->labels[arg];
if (label->has_value) {
tcg_out_i(s, label->u.value);
assert(label->u.value);
} else {
tcg_out_reloc(s, s->code_ptr, sizeof(tcg_target_ulong), arg, 0);
s->code_ptr += sizeof(tcg_target_ulong);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGArg VAR_1)
{
TCGLabel *label = &VAR_0->labels[VAR_1];
if (label->has_value) {
tcg_out_i(VAR_0, label->u.value);
assert(label->u.value);
} else {
tcg_out_reloc(VAR_0, VAR_0->code_ptr, sizeof(tcg_target_ulong), VAR_1, 0);
VAR_0->code_ptr += sizeof(tcg_target_ulong);
}
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGArg VAR_1)\n{",
"TCGLabel *label = &VAR_0->labels[VAR_1];",
"if (label->has_value) {",
"tcg_out_i(VAR_0, label->u.value);",
"assert(label->u.value);",
"} else {",
"tcg_out_reloc(VAR_0, VAR_0->code_ptr, sizeof(tcg_target_ulong), VAR_1, 0);",
"VAR_0->code_ptr += sizeof(tcg_target_ulong);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
16,599 | uint32_t lduw_le_phys(target_phys_addr_t addr)
{
return lduw_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | uint32_t lduw_le_phys(target_phys_addr_t addr)
{
return lduw_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(target_phys_addr_t addr)
{
return lduw_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| [
"uint32_t FUNC_0(target_phys_addr_t addr)\n{",
"return lduw_phys_internal(addr, DEVICE_LITTLE_ENDIAN);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
16,600 | int get_async_context_id(void)
{
return async_context->id;
}
| false | qemu | 384acbf46b70edf0d2c1648aa1a92a90bcf7057d | int get_async_context_id(void)
{
return async_context->id;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
return async_context->id;
}
| [
"int FUNC_0(void)\n{",
"return async_context->id;",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
16,601 | static void piix4_pm_realize(PCIDevice *dev, Error **errp)
{
PIIX4PMState *s = PIIX4_PM(dev);
uint8_t *pci_conf;
pci_conf = dev->config;
pci_conf[0x06] = 0x80;
pci_conf[0x07] = 0x02;
pci_conf[0x09] = 0x00;
pci_conf[0x3d] = 0x01; // interrupt pin 1
/* APM */
apm_init(dev, &s->apm, apm_ctrl_changed, s);
if (!s->smm_enabled) {
/* Mark SMM as already inited to prevent SMM from running. KVM does not
* support SMM mode. */
pci_conf[0x5B] = 0x02;
}
/* XXX: which specification is used ? The i82731AB has different
mappings */
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
pm_smbus_init(DEVICE(dev), &s->smb);
memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);
memory_region_add_subregion(pci_address_space_io(dev),
s->smb_io_base, &s->smb.io);
memory_region_init(&s->io, OBJECT(s), "piix4-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(pci_address_space_io(dev),
0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);
acpi_gpe_init(&s->ar, GPE_LEN);
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
qemu_register_powerdown_notifier(&s->powerdown_notifier);
s->machine_ready.notify = piix4_pm_machine_ready;
qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu_register_reset(piix4_reset, s);
piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s);
piix4_pm_add_propeties(s);
}
| false | qemu | fd56e0612b6454a282fa6a953fdb09281a98c589 | static void piix4_pm_realize(PCIDevice *dev, Error **errp)
{
PIIX4PMState *s = PIIX4_PM(dev);
uint8_t *pci_conf;
pci_conf = dev->config;
pci_conf[0x06] = 0x80;
pci_conf[0x07] = 0x02;
pci_conf[0x09] = 0x00;
pci_conf[0x3d] = 0x01;
apm_init(dev, &s->apm, apm_ctrl_changed, s);
if (!s->smm_enabled) {
pci_conf[0x5B] = 0x02;
}
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
pm_smbus_init(DEVICE(dev), &s->smb);
memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);
memory_region_add_subregion(pci_address_space_io(dev),
s->smb_io_base, &s->smb.io);
memory_region_init(&s->io, OBJECT(s), "piix4-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(pci_address_space_io(dev),
0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);
acpi_gpe_init(&s->ar, GPE_LEN);
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
qemu_register_powerdown_notifier(&s->powerdown_notifier);
s->machine_ready.notify = piix4_pm_machine_ready;
qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu_register_reset(piix4_reset, s);
piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s);
piix4_pm_add_propeties(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)
{
PIIX4PMState *s = PIIX4_PM(VAR_0);
uint8_t *pci_conf;
pci_conf = VAR_0->config;
pci_conf[0x06] = 0x80;
pci_conf[0x07] = 0x02;
pci_conf[0x09] = 0x00;
pci_conf[0x3d] = 0x01;
apm_init(VAR_0, &s->apm, apm_ctrl_changed, s);
if (!s->smm_enabled) {
pci_conf[0x5B] = 0x02;
}
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
pm_smbus_init(DEVICE(VAR_0), &s->smb);
memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);
memory_region_add_subregion(pci_address_space_io(VAR_0),
s->smb_io_base, &s->smb.io);
memory_region_init(&s->io, OBJECT(s), "piix4-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(pci_address_space_io(VAR_0),
0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);
acpi_gpe_init(&s->ar, GPE_LEN);
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
qemu_register_powerdown_notifier(&s->powerdown_notifier);
s->machine_ready.notify = piix4_pm_machine_ready;
qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu_register_reset(piix4_reset, s);
piix4_acpi_system_hot_add_init(pci_address_space_io(VAR_0), VAR_0->bus, s);
piix4_pm_add_propeties(s);
}
| [
"static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{",
"PIIX4PMState *s = PIIX4_PM(VAR_0);",
"uint8_t *pci_conf;",
"pci_conf = VAR_0->config;",
"pci_conf[0x06] = 0x80;",
"pci_conf[0x07] = 0x02;",
"pci_conf[0x09] = 0x00;",
"pci_conf[0x3d] = 0x01;",
"apm_init(VAR_0, &s->apm, apm_ctrl_changed, s);",
"if (!s->smm_enabled) {",
"pci_conf[0x5B] = 0x02;",
"}",
"pci_conf[0x90] = s->smb_io_base | 1;",
"pci_conf[0x91] = s->smb_io_base >> 8;",
"pci_conf[0xd2] = 0x09;",
"pm_smbus_init(DEVICE(VAR_0), &s->smb);",
"memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);",
"memory_region_add_subregion(pci_address_space_io(VAR_0),\ns->smb_io_base, &s->smb.io);",
"memory_region_init(&s->io, OBJECT(s), \"piix4-pm\", 64);",
"memory_region_set_enabled(&s->io, false);",
"memory_region_add_subregion(pci_address_space_io(VAR_0),\n0, &s->io);",
"acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);",
"acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);",
"acpi_pm1_cnt_init(&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);",
"acpi_gpe_init(&s->ar, GPE_LEN);",
"s->powerdown_notifier.notify = piix4_pm_powerdown_req;",
"qemu_register_powerdown_notifier(&s->powerdown_notifier);",
"s->machine_ready.notify = piix4_pm_machine_ready;",
"qemu_add_machine_init_done_notifier(&s->machine_ready);",
"qemu_register_reset(piix4_reset, s);",
"piix4_acpi_system_hot_add_init(pci_address_space_io(VAR_0), VAR_0->bus, s);",
"piix4_pm_add_propeties(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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
29
],
[
35
],
[
37
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
61
],
[
63
],
[
65,
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99
],
[
101
]
]
|
16,603 | static always_inline void gen_qemu_ldg (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_qemu_ld64(tmp, t1, flags);
tcg_gen_helper_1_1(helper_memory_to_g, t0, tmp);
tcg_temp_free(tmp);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static always_inline void gen_qemu_ldg (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_qemu_ld64(tmp, t1, flags);
tcg_gen_helper_1_1(helper_memory_to_g, t0, tmp);
tcg_temp_free(tmp);
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_qemu_ld64(tmp, t1, flags);
tcg_gen_helper_1_1(helper_memory_to_g, t0, tmp);
tcg_temp_free(tmp);
}
| [
"static always_inline void FUNC_0 (TCGv t0, TCGv t1, int flags)\n{",
"TCGv tmp = tcg_temp_new(TCG_TYPE_I64);",
"tcg_gen_qemu_ld64(tmp, t1, flags);",
"tcg_gen_helper_1_1(helper_memory_to_g, t0, tmp);",
"tcg_temp_free(tmp);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
16,604 | static void register_subpage(MemoryRegionSection *section)
{
subpage_t *subpage;
target_phys_addr_t base = section->offset_within_address_space
& TARGET_PAGE_MASK;
MemoryRegionSection *existing = phys_page_find(base >> TARGET_PAGE_BITS);
MemoryRegionSection subsection = {
.offset_within_address_space = base,
.size = TARGET_PAGE_SIZE,
};
target_phys_addr_t start, end;
assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
if (!(existing->mr->subpage)) {
subpage = subpage_init(base);
subsection.mr = &subpage->iomem;
phys_page_set(base >> TARGET_PAGE_BITS, 1,
phys_section_add(&subsection));
} else {
subpage = container_of(existing->mr, subpage_t, iomem);
}
start = section->offset_within_address_space & ~TARGET_PAGE_MASK;
end = start + section->size - 1;
subpage_register(subpage, start, end, phys_section_add(section));
}
| false | qemu | ac1970fbe8ad5a70174f462109ac0f6c7bf1bc43 | static void register_subpage(MemoryRegionSection *section)
{
subpage_t *subpage;
target_phys_addr_t base = section->offset_within_address_space
& TARGET_PAGE_MASK;
MemoryRegionSection *existing = phys_page_find(base >> TARGET_PAGE_BITS);
MemoryRegionSection subsection = {
.offset_within_address_space = base,
.size = TARGET_PAGE_SIZE,
};
target_phys_addr_t start, end;
assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
if (!(existing->mr->subpage)) {
subpage = subpage_init(base);
subsection.mr = &subpage->iomem;
phys_page_set(base >> TARGET_PAGE_BITS, 1,
phys_section_add(&subsection));
} else {
subpage = container_of(existing->mr, subpage_t, iomem);
}
start = section->offset_within_address_space & ~TARGET_PAGE_MASK;
end = start + section->size - 1;
subpage_register(subpage, start, end, phys_section_add(section));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MemoryRegionSection *VAR_0)
{
subpage_t *subpage;
target_phys_addr_t base = VAR_0->offset_within_address_space
& TARGET_PAGE_MASK;
MemoryRegionSection *existing = phys_page_find(base >> TARGET_PAGE_BITS);
MemoryRegionSection subsection = {
.offset_within_address_space = base,
.size = TARGET_PAGE_SIZE,
};
target_phys_addr_t start, end;
assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
if (!(existing->mr->subpage)) {
subpage = subpage_init(base);
subsection.mr = &subpage->iomem;
phys_page_set(base >> TARGET_PAGE_BITS, 1,
phys_section_add(&subsection));
} else {
subpage = container_of(existing->mr, subpage_t, iomem);
}
start = VAR_0->offset_within_address_space & ~TARGET_PAGE_MASK;
end = start + VAR_0->size - 1;
subpage_register(subpage, start, end, phys_section_add(VAR_0));
}
| [
"static void FUNC_0(MemoryRegionSection *VAR_0)\n{",
"subpage_t *subpage;",
"target_phys_addr_t base = VAR_0->offset_within_address_space\n& TARGET_PAGE_MASK;",
"MemoryRegionSection *existing = phys_page_find(base >> TARGET_PAGE_BITS);",
"MemoryRegionSection subsection = {",
".offset_within_address_space = base,\n.size = TARGET_PAGE_SIZE,\n};",
"target_phys_addr_t start, end;",
"assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);",
"if (!(existing->mr->subpage)) {",
"subpage = subpage_init(base);",
"subsection.mr = &subpage->iomem;",
"phys_page_set(base >> TARGET_PAGE_BITS, 1,\nphys_section_add(&subsection));",
"} else {",
"subpage = container_of(existing->mr, subpage_t, iomem);",
"}",
"start = VAR_0->offset_within_address_space & ~TARGET_PAGE_MASK;",
"end = start + VAR_0->size - 1;",
"subpage_register(subpage, start, end, phys_section_add(VAR_0));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
]
|
16,605 | static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size)
{
/* This writes the bottom N bits of a 128 bit wide vector to memory */
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(srcidx, MO_64));
if (size < 4) {
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TE + size);
} else {
TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_qemu_st64(tmp, tcg_addr, get_mem_index(s));
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(srcidx));
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_temp_free_i64(tmp);
}
| false | qemu | 90e496386fe7fd32c189561f846b7913f95b8cf4 | static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size)
{
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(srcidx, MO_64));
if (size < 4) {
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TE + size);
} else {
TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_qemu_st64(tmp, tcg_addr, get_mem_index(s));
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(srcidx));
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_temp_free_i64(tmp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, TCGv_i64 VAR_2, int VAR_3)
{
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(VAR_1, MO_64));
if (VAR_3 < 4) {
tcg_gen_qemu_st_i64(tmp, VAR_2, get_mem_index(VAR_0), MO_TE + VAR_3);
} else {
TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_st_i64(tmp, VAR_2, get_mem_index(VAR_0), MO_TEQ);
tcg_gen_qemu_st64(tmp, VAR_2, get_mem_index(VAR_0));
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(VAR_1));
tcg_gen_addi_i64(tcg_hiaddr, VAR_2, 8);
tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(VAR_0), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_temp_free_i64(tmp);
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, TCGv_i64 VAR_2, int VAR_3)\n{",
"TCGv_i64 tmp = tcg_temp_new_i64();",
"tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(VAR_1, MO_64));",
"if (VAR_3 < 4) {",
"tcg_gen_qemu_st_i64(tmp, VAR_2, get_mem_index(VAR_0), MO_TE + VAR_3);",
"} else {",
"TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();",
"tcg_gen_qemu_st_i64(tmp, VAR_2, get_mem_index(VAR_0), MO_TEQ);",
"tcg_gen_qemu_st64(tmp, VAR_2, get_mem_index(VAR_0));",
"tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(VAR_1));",
"tcg_gen_addi_i64(tcg_hiaddr, VAR_2, 8);",
"tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(VAR_0), MO_TEQ);",
"tcg_temp_free_i64(tcg_hiaddr);",
"}",
"tcg_temp_free_i64(tmp);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
]
|
16,606 | bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr)
{
MemoryRegionSection *section;
section = phys_page_find(phys_addr >> TARGET_PAGE_BITS);
return !(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr));
}
| false | qemu | ac1970fbe8ad5a70174f462109ac0f6c7bf1bc43 | bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr)
{
MemoryRegionSection *section;
section = phys_page_find(phys_addr >> TARGET_PAGE_BITS);
return !(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr));
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(target_phys_addr_t phys_addr)
{
MemoryRegionSection *section;
section = phys_page_find(phys_addr >> TARGET_PAGE_BITS);
return !(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr));
}
| [
"bool FUNC_0(target_phys_addr_t phys_addr)\n{",
"MemoryRegionSection *section;",
"section = phys_page_find(phys_addr >> TARGET_PAGE_BITS);",
"return !(memory_region_is_ram(section->mr) ||\nmemory_region_is_romd(section->mr));",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
17
]
]
|
16,607 | void qemu_start_warp_timer(void)
{
int64_t clock;
int64_t deadline;
if (!use_icount) {
return;
}
/* Nothing to do if the VM is stopped: QEMU_CLOCK_VIRTUAL timers
* do not fire, so computing the deadline does not make sense.
*/
if (!runstate_is_running()) {
return;
}
/* warp clock deterministically in record/replay mode */
if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_START)) {
return;
}
if (!all_cpu_threads_idle()) {
return;
}
if (qtest_enabled()) {
/* When testing, qtest commands advance icount. */
return;
}
/* We want to use the earliest deadline from ALL vm_clocks */
clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT);
deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
if (deadline < 0) {
static bool notified;
if (!icount_sleep && !notified) {
error_report("WARNING: icount sleep disabled and no active timers");
notified = true;
}
return;
}
if (deadline > 0) {
/*
* Ensure QEMU_CLOCK_VIRTUAL proceeds even when the virtual CPU goes to
* sleep. Otherwise, the CPU might be waiting for a future timer
* interrupt to wake it up, but the interrupt never comes because
* the vCPU isn't running any insns and thus doesn't advance the
* QEMU_CLOCK_VIRTUAL.
*/
if (!icount_sleep) {
/*
* We never let VCPUs sleep in no sleep icount mode.
* If there is a pending QEMU_CLOCK_VIRTUAL timer we just advance
* to the next QEMU_CLOCK_VIRTUAL event and notify it.
* It is useful when we want a deterministic execution time,
* isolated from host latencies.
*/
seqlock_write_begin(&timers_state.vm_clock_seqlock);
timers_state.qemu_icount_bias += deadline;
seqlock_write_end(&timers_state.vm_clock_seqlock);
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
} else {
/*
* We do stop VCPUs and only advance QEMU_CLOCK_VIRTUAL after some
* "real" time, (related to the time left until the next event) has
* passed. The QEMU_CLOCK_VIRTUAL_RT clock will do this.
* This avoids that the warps are visible externally; for example,
* you will not be sending network packets continuously instead of
* every 100ms.
*/
seqlock_write_begin(&timers_state.vm_clock_seqlock);
if (vm_clock_warp_start == -1 || vm_clock_warp_start > clock) {
vm_clock_warp_start = clock;
}
seqlock_write_end(&timers_state.vm_clock_seqlock);
timer_mod_anticipate(icount_warp_timer, clock + deadline);
}
} else if (deadline == 0) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
| false | qemu | 3dc6f8693694a649a9c83f1e2746565b47683923 | void qemu_start_warp_timer(void)
{
int64_t clock;
int64_t deadline;
if (!use_icount) {
return;
}
if (!runstate_is_running()) {
return;
}
if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_START)) {
return;
}
if (!all_cpu_threads_idle()) {
return;
}
if (qtest_enabled()) {
return;
}
clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT);
deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
if (deadline < 0) {
static bool notified;
if (!icount_sleep && !notified) {
error_report("WARNING: icount sleep disabled and no active timers");
notified = true;
}
return;
}
if (deadline > 0) {
if (!icount_sleep) {
seqlock_write_begin(&timers_state.vm_clock_seqlock);
timers_state.qemu_icount_bias += deadline;
seqlock_write_end(&timers_state.vm_clock_seqlock);
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
} else {
seqlock_write_begin(&timers_state.vm_clock_seqlock);
if (vm_clock_warp_start == -1 || vm_clock_warp_start > clock) {
vm_clock_warp_start = clock;
}
seqlock_write_end(&timers_state.vm_clock_seqlock);
timer_mod_anticipate(icount_warp_timer, clock + deadline);
}
} else if (deadline == 0) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
int64_t clock;
int64_t deadline;
if (!use_icount) {
return;
}
if (!runstate_is_running()) {
return;
}
if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_START)) {
return;
}
if (!all_cpu_threads_idle()) {
return;
}
if (qtest_enabled()) {
return;
}
clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT);
deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
if (deadline < 0) {
static bool VAR_0;
if (!icount_sleep && !VAR_0) {
error_report("WARNING: icount sleep disabled and no active timers");
VAR_0 = true;
}
return;
}
if (deadline > 0) {
if (!icount_sleep) {
seqlock_write_begin(&timers_state.vm_clock_seqlock);
timers_state.qemu_icount_bias += deadline;
seqlock_write_end(&timers_state.vm_clock_seqlock);
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
} else {
seqlock_write_begin(&timers_state.vm_clock_seqlock);
if (vm_clock_warp_start == -1 || vm_clock_warp_start > clock) {
vm_clock_warp_start = clock;
}
seqlock_write_end(&timers_state.vm_clock_seqlock);
timer_mod_anticipate(icount_warp_timer, clock + deadline);
}
} else if (deadline == 0) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
| [
"void FUNC_0(void)\n{",
"int64_t clock;",
"int64_t deadline;",
"if (!use_icount) {",
"return;",
"}",
"if (!runstate_is_running()) {",
"return;",
"}",
"if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_START)) {",
"return;",
"}",
"if (!all_cpu_threads_idle()) {",
"return;",
"}",
"if (qtest_enabled()) {",
"return;",
"}",
"clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT);",
"deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);",
"if (deadline < 0) {",
"static bool VAR_0;",
"if (!icount_sleep && !VAR_0) {",
"error_report(\"WARNING: icount sleep disabled and no active timers\");",
"VAR_0 = true;",
"}",
"return;",
"}",
"if (deadline > 0) {",
"if (!icount_sleep) {",
"seqlock_write_begin(&timers_state.vm_clock_seqlock);",
"timers_state.qemu_icount_bias += deadline;",
"seqlock_write_end(&timers_state.vm_clock_seqlock);",
"qemu_clock_notify(QEMU_CLOCK_VIRTUAL);",
"} else {",
"seqlock_write_begin(&timers_state.vm_clock_seqlock);",
"if (vm_clock_warp_start == -1 || vm_clock_warp_start > clock) {",
"vm_clock_warp_start = clock;",
"}",
"seqlock_write_end(&timers_state.vm_clock_seqlock);",
"timer_mod_anticipate(icount_warp_timer, clock + deadline);",
"}",
"} else if (deadline == 0) {",
"qemu_clock_notify(QEMU_CLOCK_VIRTUAL);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
101
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
]
]
|
16,608 | sdhci_writefn(void *opaque, hwaddr off, uint64_t val, unsigned sz)
{
SDHCIState *s = (SDHCIState *)opaque;
SDHCI_GET_CLASS(s)->mem_write(s, off, val, sz);
}
| false | qemu | d368ba4376b2c1c24175c74b3733b8fe64dbe8a6 | sdhci_writefn(void *opaque, hwaddr off, uint64_t val, unsigned sz)
{
SDHCIState *s = (SDHCIState *)opaque;
SDHCI_GET_CLASS(s)->mem_write(s, off, val, sz);
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned VAR_3)
{
SDHCIState *s = (SDHCIState *)VAR_0;
SDHCI_GET_CLASS(s)->mem_write(s, VAR_1, VAR_2, VAR_3);
}
| [
"FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned VAR_3)\n{",
"SDHCIState *s = (SDHCIState *)VAR_0;",
"SDHCI_GET_CLASS(s)->mem_write(s, VAR_1, VAR_2, VAR_3);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
]
]
|
16,609 | static void rtas_set_xive(sPAPREnvironment *spapr, uint32_t token,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
struct ics_state *ics = spapr->icp->ics;
uint32_t nr, server, priority;
if ((nargs != 3) || (nret != 1)) {
rtas_st(rets, 0, -3);
return;
}
nr = rtas_ld(args, 0);
server = rtas_ld(args, 1);
priority = rtas_ld(args, 2);
if (!ics_valid_irq(ics, nr) || (server >= ics->icp->nr_servers)
|| (priority > 0xff)) {
rtas_st(rets, 0, -3);
return;
}
ics_write_xive(ics, nr, server, priority, priority);
rtas_st(rets, 0, 0); /* Success */
}
| false | qemu | 210b580b106fa798149e28aa13c66b325a43204e | static void rtas_set_xive(sPAPREnvironment *spapr, uint32_t token,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
struct ics_state *ics = spapr->icp->ics;
uint32_t nr, server, priority;
if ((nargs != 3) || (nret != 1)) {
rtas_st(rets, 0, -3);
return;
}
nr = rtas_ld(args, 0);
server = rtas_ld(args, 1);
priority = rtas_ld(args, 2);
if (!ics_valid_irq(ics, nr) || (server >= ics->icp->nr_servers)
|| (priority > 0xff)) {
rtas_st(rets, 0, -3);
return;
}
ics_write_xive(ics, nr, server, priority, priority);
rtas_st(rets, 0, 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPREnvironment *VAR_0, uint32_t VAR_1,
uint32_t VAR_2, target_ulong VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{
struct ics_state *VAR_6 = VAR_0->icp->VAR_6;
uint32_t nr, server, priority;
if ((VAR_2 != 3) || (VAR_4 != 1)) {
rtas_st(VAR_5, 0, -3);
return;
}
nr = rtas_ld(VAR_3, 0);
server = rtas_ld(VAR_3, 1);
priority = rtas_ld(VAR_3, 2);
if (!ics_valid_irq(VAR_6, nr) || (server >= VAR_6->icp->nr_servers)
|| (priority > 0xff)) {
rtas_st(VAR_5, 0, -3);
return;
}
ics_write_xive(VAR_6, nr, server, priority, priority);
rtas_st(VAR_5, 0, 0);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0, uint32_t VAR_1,\nuint32_t VAR_2, target_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{",
"struct ics_state *VAR_6 = VAR_0->icp->VAR_6;",
"uint32_t nr, server, priority;",
"if ((VAR_2 != 3) || (VAR_4 != 1)) {",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"nr = rtas_ld(VAR_3, 0);",
"server = rtas_ld(VAR_3, 1);",
"priority = rtas_ld(VAR_3, 2);",
"if (!ics_valid_irq(VAR_6, nr) || (server >= VAR_6->icp->nr_servers)\n|| (priority > 0xff)) {",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"ics_write_xive(VAR_6, nr, server, priority, priority);",
"rtas_st(VAR_5, 0, 0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
]
]
|
16,610 | static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, NULL, &head, &err);
error_free_or_abort(&err);
g_assert(!head);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, NULL, &head, &err);
error_free_or_abort(&err);
g_assert(!head);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(VAR_0, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, NULL, &head, &err);
error_free_or_abort(&err);
g_assert(!head);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"UserDefOneList *head = NULL;",
"Error *err = NULL;",
"Visitor *v;",
"v = validate_test_init(VAR_0, \"[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]\");",
"visit_type_UserDefOneList(v, NULL, &head, &err);",
"error_free_or_abort(&err);",
"g_assert(!head);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
16,611 | static int migrate_fd_cleanup(MigrationState *s)
{
int ret = 0;
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
if (s->file) {
DPRINTF("closing file\n");
if (qemu_fclose(s->file) != 0) {
ret = -1;
}
s->file = NULL;
} else {
if (s->mon) {
monitor_resume(s->mon);
}
}
if (s->fd != -1) {
close(s->fd);
s->fd = -1;
}
return ret;
}
| false | qemu | a6d34a949c3546404d403bda61a5e37431b4a6ad | static int migrate_fd_cleanup(MigrationState *s)
{
int ret = 0;
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
if (s->file) {
DPRINTF("closing file\n");
if (qemu_fclose(s->file) != 0) {
ret = -1;
}
s->file = NULL;
} else {
if (s->mon) {
monitor_resume(s->mon);
}
}
if (s->fd != -1) {
close(s->fd);
s->fd = -1;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MigrationState *VAR_0)
{
int VAR_1 = 0;
qemu_set_fd_handler2(VAR_0->fd, NULL, NULL, NULL, NULL);
if (VAR_0->file) {
DPRINTF("closing file\n");
if (qemu_fclose(VAR_0->file) != 0) {
VAR_1 = -1;
}
VAR_0->file = NULL;
} else {
if (VAR_0->mon) {
monitor_resume(VAR_0->mon);
}
}
if (VAR_0->fd != -1) {
close(VAR_0->fd);
VAR_0->fd = -1;
}
return VAR_1;
}
| [
"static int FUNC_0(MigrationState *VAR_0)\n{",
"int VAR_1 = 0;",
"qemu_set_fd_handler2(VAR_0->fd, NULL, NULL, NULL, NULL);",
"if (VAR_0->file) {",
"DPRINTF(\"closing file\\n\");",
"if (qemu_fclose(VAR_0->file) != 0) {",
"VAR_1 = -1;",
"}",
"VAR_0->file = NULL;",
"} else {",
"if (VAR_0->mon) {",
"monitor_resume(VAR_0->mon);",
"}",
"}",
"if (VAR_0->fd != -1) {",
"close(VAR_0->fd);",
"VAR_0->fd = -1;",
"}",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
]
|
16,612 | static bool all_cpu_threads_idle(void)
{
CPUState *env;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
if (!cpu_thread_is_idle(env)) {
return false;
}
}
return true;
}
| true | qemu | ab33fcda9f96b9195dfb3fcf5bd9bb5383caeaea | static bool all_cpu_threads_idle(void)
{
CPUState *env;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
if (!cpu_thread_is_idle(env)) {
return false;
}
}
return true;
}
| {
"code": [
"static bool all_cpu_threads_idle(void)"
],
"line_no": [
1
]
} | static bool FUNC_0(void)
{
CPUState *env;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
if (!cpu_thread_is_idle(env)) {
return false;
}
}
return true;
}
| [
"static bool FUNC_0(void)\n{",
"CPUState *env;",
"for (env = first_cpu; env != NULL; env = env->next_cpu) {",
"if (!cpu_thread_is_idle(env)) {",
"return false;",
"}",
"}",
"return true;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
16,613 | static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVVPCState *s = (BDRVVPCState *)bs->opaque;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
if (cpu_to_be32(footer->type) != VHD_FIXED) {
bdi->cluster_size = s->block_size;
}
bdi->unallocated_blocks_are_zero = true;
return 0;
}
| true | qemu | 0d4cc3e715f5794077895345577725539afe81eb | static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVVPCState *s = (BDRVVPCState *)bs->opaque;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
if (cpu_to_be32(footer->type) != VHD_FIXED) {
bdi->cluster_size = s->block_size;
}
bdi->unallocated_blocks_are_zero = true;
return 0;
}
| {
"code": [
" if (cpu_to_be32(footer->type) != VHD_FIXED) {"
],
"line_no": [
11
]
} | static int FUNC_0(BlockDriverState *VAR_0, BlockDriverInfo *VAR_1)
{
BDRVVPCState *s = (BDRVVPCState *)VAR_0->opaque;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
if (cpu_to_be32(footer->type) != VHD_FIXED) {
VAR_1->cluster_size = s->block_size;
}
VAR_1->unallocated_blocks_are_zero = true;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BlockDriverInfo *VAR_1)\n{",
"BDRVVPCState *s = (BDRVVPCState *)VAR_0->opaque;",
"VHDFooter *footer = (VHDFooter *) s->footer_buf;",
"if (cpu_to_be32(footer->type) != VHD_FIXED) {",
"VAR_1->cluster_size = s->block_size;",
"}",
"VAR_1->unallocated_blocks_are_zero = true;",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
]
]
|
16,615 | static int read_header_openmpt(AVFormatContext *s)
{
AVStream *st;
OpenMPTContext *openmpt = s->priv_data;
int64_t size = avio_size(s->pb);
if (!size)
return AVERROR_INVALIDDATA;
char *buf = av_malloc(size);
int ret;
if (!buf)
return AVERROR(ENOMEM);
size = avio_read(s->pb, buf, size);
if (size < 0) {
av_log(s, AV_LOG_ERROR, "Reading input buffer failed.\n");
av_freep(&buf);
return size;
}
openmpt->module = openmpt_module_create_from_memory(buf, size, openmpt_logfunc, s, NULL);
av_freep(&buf);
if (!openmpt->module)
return AVERROR_INVALIDDATA;
openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
add_meta(s, "artist", openmpt_module_get_metadata(openmpt->module, "artist"));
add_meta(s, "title", openmpt_module_get_metadata(openmpt->module, "title"));
add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
add_meta(s, "date", openmpt_module_get_metadata(openmpt->module, "date"));
if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
openmpt_module_destroy(openmpt->module);
av_log(s, AV_LOG_ERROR, "Invalid subsong index: %d\n", openmpt->subsong);
return AVERROR(EINVAL);
}
if (openmpt->subsong != -2) {
if (openmpt->subsong >= 0) {
av_dict_set_int(&s->metadata, "track", openmpt->subsong + 1, 0);
}
ret = openmpt_module_select_subsong(openmpt->module, openmpt->subsong);
if (!ret){
openmpt_module_destroy(openmpt->module);
av_log(s, AV_LOG_ERROR, "Could not select requested subsong: %d", openmpt->subsong);
return AVERROR(EINVAL);
}
}
st = avformat_new_stream(s, NULL);
if (!st) {
openmpt_module_destroy(openmpt->module);
openmpt->module = NULL;
return AVERROR(ENOMEM);
}
avpriv_set_pts_info(st, 64, 1, AV_TIME_BASE);
st->duration = llrint(openmpt->duration*AV_TIME_BASE);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_F32BE, AV_CODEC_ID_PCM_F32LE);
st->codecpar->channels = openmpt->channels;
st->codecpar->sample_rate = openmpt->sample_rate;
return 0;
}
| true | FFmpeg | bd8201566d754384105923bb1fb3bb3a5c08cc8b | static int read_header_openmpt(AVFormatContext *s)
{
AVStream *st;
OpenMPTContext *openmpt = s->priv_data;
int64_t size = avio_size(s->pb);
if (!size)
return AVERROR_INVALIDDATA;
char *buf = av_malloc(size);
int ret;
if (!buf)
return AVERROR(ENOMEM);
size = avio_read(s->pb, buf, size);
if (size < 0) {
av_log(s, AV_LOG_ERROR, "Reading input buffer failed.\n");
av_freep(&buf);
return size;
}
openmpt->module = openmpt_module_create_from_memory(buf, size, openmpt_logfunc, s, NULL);
av_freep(&buf);
if (!openmpt->module)
return AVERROR_INVALIDDATA;
openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
add_meta(s, "artist", openmpt_module_get_metadata(openmpt->module, "artist"));
add_meta(s, "title", openmpt_module_get_metadata(openmpt->module, "title"));
add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
add_meta(s, "date", openmpt_module_get_metadata(openmpt->module, "date"));
if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
openmpt_module_destroy(openmpt->module);
av_log(s, AV_LOG_ERROR, "Invalid subsong index: %d\n", openmpt->subsong);
return AVERROR(EINVAL);
}
if (openmpt->subsong != -2) {
if (openmpt->subsong >= 0) {
av_dict_set_int(&s->metadata, "track", openmpt->subsong + 1, 0);
}
ret = openmpt_module_select_subsong(openmpt->module, openmpt->subsong);
if (!ret){
openmpt_module_destroy(openmpt->module);
av_log(s, AV_LOG_ERROR, "Could not select requested subsong: %d", openmpt->subsong);
return AVERROR(EINVAL);
}
}
st = avformat_new_stream(s, NULL);
if (!st) {
openmpt_module_destroy(openmpt->module);
openmpt->module = NULL;
return AVERROR(ENOMEM);
}
avpriv_set_pts_info(st, 64, 1, AV_TIME_BASE);
st->duration = llrint(openmpt->duration*AV_TIME_BASE);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_F32BE, AV_CODEC_ID_PCM_F32LE);
st->codecpar->channels = openmpt->channels;
st->codecpar->sample_rate = openmpt->sample_rate;
return 0;
}
| {
"code": [
" if (!size)"
],
"line_no": [
11
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVStream *st;
OpenMPTContext *openmpt = VAR_0->priv_data;
int64_t size = avio_size(VAR_0->pb);
if (!size)
return AVERROR_INVALIDDATA;
char *VAR_1 = av_malloc(size);
int VAR_2;
if (!VAR_1)
return AVERROR(ENOMEM);
size = avio_read(VAR_0->pb, VAR_1, size);
if (size < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Reading input buffer failed.\n");
av_freep(&VAR_1);
return size;
}
openmpt->module = openmpt_module_create_from_memory(VAR_1, size, openmpt_logfunc, VAR_0, NULL);
av_freep(&VAR_1);
if (!openmpt->module)
return AVERROR_INVALIDDATA;
openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
add_meta(VAR_0, "artist", openmpt_module_get_metadata(openmpt->module, "artist"));
add_meta(VAR_0, "title", openmpt_module_get_metadata(openmpt->module, "title"));
add_meta(VAR_0, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
add_meta(VAR_0, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
add_meta(VAR_0, "date", openmpt_module_get_metadata(openmpt->module, "date"));
if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
openmpt_module_destroy(openmpt->module);
av_log(VAR_0, AV_LOG_ERROR, "Invalid subsong index: %d\n", openmpt->subsong);
return AVERROR(EINVAL);
}
if (openmpt->subsong != -2) {
if (openmpt->subsong >= 0) {
av_dict_set_int(&VAR_0->metadata, "track", openmpt->subsong + 1, 0);
}
VAR_2 = openmpt_module_select_subsong(openmpt->module, openmpt->subsong);
if (!VAR_2){
openmpt_module_destroy(openmpt->module);
av_log(VAR_0, AV_LOG_ERROR, "Could not select requested subsong: %d", openmpt->subsong);
return AVERROR(EINVAL);
}
}
st = avformat_new_stream(VAR_0, NULL);
if (!st) {
openmpt_module_destroy(openmpt->module);
openmpt->module = NULL;
return AVERROR(ENOMEM);
}
avpriv_set_pts_info(st, 64, 1, AV_TIME_BASE);
st->duration = llrint(openmpt->duration*AV_TIME_BASE);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_F32BE, AV_CODEC_ID_PCM_F32LE);
st->codecpar->channels = openmpt->channels;
st->codecpar->sample_rate = openmpt->sample_rate;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVStream *st;",
"OpenMPTContext *openmpt = VAR_0->priv_data;",
"int64_t size = avio_size(VAR_0->pb);",
"if (!size)\nreturn AVERROR_INVALIDDATA;",
"char *VAR_1 = av_malloc(size);",
"int VAR_2;",
"if (!VAR_1)\nreturn AVERROR(ENOMEM);",
"size = avio_read(VAR_0->pb, VAR_1, size);",
"if (size < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Reading input buffer failed.\\n\");",
"av_freep(&VAR_1);",
"return size;",
"}",
"openmpt->module = openmpt_module_create_from_memory(VAR_1, size, openmpt_logfunc, VAR_0, NULL);",
"av_freep(&VAR_1);",
"if (!openmpt->module)\nreturn AVERROR_INVALIDDATA;",
"openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);",
"openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);",
"add_meta(VAR_0, \"artist\", openmpt_module_get_metadata(openmpt->module, \"artist\"));",
"add_meta(VAR_0, \"title\", openmpt_module_get_metadata(openmpt->module, \"title\"));",
"add_meta(VAR_0, \"encoder\", openmpt_module_get_metadata(openmpt->module, \"tracker\"));",
"add_meta(VAR_0, \"comment\", openmpt_module_get_metadata(openmpt->module, \"message\"));",
"add_meta(VAR_0, \"date\", openmpt_module_get_metadata(openmpt->module, \"date\"));",
"if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {",
"openmpt_module_destroy(openmpt->module);",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid subsong index: %d\\n\", openmpt->subsong);",
"return AVERROR(EINVAL);",
"}",
"if (openmpt->subsong != -2) {",
"if (openmpt->subsong >= 0) {",
"av_dict_set_int(&VAR_0->metadata, \"track\", openmpt->subsong + 1, 0);",
"}",
"VAR_2 = openmpt_module_select_subsong(openmpt->module, openmpt->subsong);",
"if (!VAR_2){",
"openmpt_module_destroy(openmpt->module);",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not select requested subsong: %d\", openmpt->subsong);",
"return AVERROR(EINVAL);",
"}",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st) {",
"openmpt_module_destroy(openmpt->module);",
"openmpt->module = NULL;",
"return AVERROR(ENOMEM);",
"}",
"avpriv_set_pts_info(st, 64, 1, AV_TIME_BASE);",
"st->duration = llrint(openmpt->duration*AV_TIME_BASE);",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_F32BE, AV_CODEC_ID_PCM_F32LE);",
"st->codecpar->channels = openmpt->channels;",
"st->codecpar->sample_rate = openmpt->sample_rate;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
]
]
|
16,616 | void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1)
{
env->CP0_HWREna = arg1 & 0x0000000F;
}
| true | qemu | d279279e2b5cd40dbcc863fb66a695990f304077 | void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1)
{
env->CP0_HWREna = arg1 & 0x0000000F;
}
| {
"code": [
" env->CP0_HWREna = arg1 & 0x0000000F;"
],
"line_no": [
5
]
} | void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1)
{
VAR_0->CP0_HWREna = VAR_1 & 0x0000000F;
}
| [
"void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1)\n{",
"VAR_0->CP0_HWREna = VAR_1 & 0x0000000F;",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
16,617 | void qemu_cpu_kick(void *_env)
{
CPUState *env = _env;
qemu_cond_broadcast(env->halt_cond);
qemu_thread_signal(env->thread, SIG_IPI);
}
| true | qemu | aa2c364b4cf2fae4d9c8acf53ee4436ed533902d | void qemu_cpu_kick(void *_env)
{
CPUState *env = _env;
qemu_cond_broadcast(env->halt_cond);
qemu_thread_signal(env->thread, SIG_IPI);
}
| {
"code": [
" qemu_thread_signal(env->thread, SIG_IPI);"
],
"line_no": [
9
]
} | void FUNC_0(void *VAR_0)
{
CPUState *env = VAR_0;
qemu_cond_broadcast(env->halt_cond);
qemu_thread_signal(env->thread, SIG_IPI);
}
| [
"void FUNC_0(void *VAR_0)\n{",
"CPUState *env = VAR_0;",
"qemu_cond_broadcast(env->halt_cond);",
"qemu_thread_signal(env->thread, SIG_IPI);",
"}"
]
| [
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
16,618 | iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data,
void *opaque)
{
struct IscsiTask *itask = opaque;
struct scsi_task *task = command_data;
struct scsi_inquiry_standard *inq;
if (status != 0) {
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
error_report("iSCSI: Failed to unmarshall inquiry data.");
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
itask->iscsilun->type = inq->periperal_device_type;
scsi_free_scsi_task(task);
switch (itask->iscsilun->type) {
case TYPE_DISK:
task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun,
iscsi_readcapacity16_cb, opaque);
if (task == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
itask->status = 1;
itask->complete = 1;
return;
}
break;
case TYPE_ROM:
task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun,
0, 0,
iscsi_readcapacity10_cb, opaque);
if (task == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
itask->status = 1;
itask->complete = 1;
return;
}
break;
default:
itask->status = 0;
itask->complete = 1;
}
}
| true | qemu | e829b0bb054ed3389e5b22dad61875e51674e629 | iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data,
void *opaque)
{
struct IscsiTask *itask = opaque;
struct scsi_task *task = command_data;
struct scsi_inquiry_standard *inq;
if (status != 0) {
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
error_report("iSCSI: Failed to unmarshall inquiry data.");
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
itask->iscsilun->type = inq->periperal_device_type;
scsi_free_scsi_task(task);
switch (itask->iscsilun->type) {
case TYPE_DISK:
task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun,
iscsi_readcapacity16_cb, opaque);
if (task == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
itask->status = 1;
itask->complete = 1;
return;
}
break;
case TYPE_ROM:
task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun,
0, 0,
iscsi_readcapacity10_cb, opaque);
if (task == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
itask->status = 1;
itask->complete = 1;
return;
}
break;
default:
itask->status = 0;
itask->complete = 1;
}
}
| {
"code": [
" struct IscsiTask *itask = opaque;",
" struct scsi_task *task = command_data;",
" if (status != 0) {",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" scsi_free_scsi_task(task);",
" struct IscsiTask *itask = opaque;",
" struct scsi_task *task = command_data;",
" if (status != 0) {",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" scsi_free_scsi_task(task);",
"iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data,",
" void *opaque)",
" struct IscsiTask *itask = opaque;",
" struct scsi_task *task = command_data;",
" struct scsi_inquiry_standard *inq;",
" if (status != 0) {",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" inq = scsi_datain_unmarshall(task);",
" if (inq == NULL) {",
" error_report(\"iSCSI: Failed to unmarshall inquiry data.\");",
" itask->status = 1;",
" itask->complete = 1;",
" scsi_free_scsi_task(task);",
" itask->iscsilun->type = inq->periperal_device_type;",
" scsi_free_scsi_task(task);",
" switch (itask->iscsilun->type) {",
" case TYPE_DISK:",
" task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun,",
" iscsi_readcapacity16_cb, opaque);",
" if (task == NULL) {",
" error_report(\"iSCSI: failed to send readcapacity16 command.\");",
" itask->status = 1;",
" itask->complete = 1;",
" break;",
" case TYPE_ROM:",
" task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun,",
" 0, 0,",
" iscsi_readcapacity10_cb, opaque);",
" if (task == NULL) {",
" error_report(\"iSCSI: failed to send readcapacity16 command.\");",
" itask->status = 1;",
" itask->complete = 1;",
" break;",
" default:",
" itask->status = 0;",
" itask->complete = 1;",
" void *opaque)",
" struct IscsiTask *itask = opaque;",
" if (status != 0) {",
" itask->status = 1;",
" itask->complete = 1;",
" itask->status = 1;",
" itask->complete = 1;"
],
"line_no": [
7,
9,
15,
17,
19,
21,
17,
19,
21,
51,
7,
9,
15,
17,
19,
21,
17,
19,
21,
51,
1,
3,
7,
9,
11,
15,
17,
19,
21,
29,
31,
33,
17,
19,
21,
47,
51,
55,
57,
59,
61,
63,
65,
67,
69,
75,
77,
79,
81,
83,
63,
65,
67,
69,
75,
99,
101,
19,
3,
7,
15,
17,
19,
17,
19
]
} | FUNC_0(struct iscsi_context *VAR_0, int VAR_1, void *VAR_2,
void *VAR_3)
{
struct IscsiTask *VAR_4 = VAR_3;
struct scsi_task *VAR_5 = VAR_2;
struct scsi_inquiry_standard *VAR_6;
if (VAR_1 != 0) {
VAR_4->VAR_1 = 1;
VAR_4->complete = 1;
scsi_free_scsi_task(VAR_5);
return;
}
VAR_6 = scsi_datain_unmarshall(VAR_5);
if (VAR_6 == NULL) {
error_report("iSCSI: Failed to unmarshall inquiry data.");
VAR_4->VAR_1 = 1;
VAR_4->complete = 1;
scsi_free_scsi_task(VAR_5);
return;
}
VAR_4->iscsilun->type = VAR_6->periperal_device_type;
scsi_free_scsi_task(VAR_5);
switch (VAR_4->iscsilun->type) {
case TYPE_DISK:
VAR_5 = iscsi_readcapacity16_task(VAR_0, VAR_4->iscsilun->lun,
iscsi_readcapacity16_cb, VAR_3);
if (VAR_5 == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
VAR_4->VAR_1 = 1;
VAR_4->complete = 1;
return;
}
break;
case TYPE_ROM:
VAR_5 = iscsi_readcapacity10_task(VAR_0, VAR_4->iscsilun->lun,
0, 0,
iscsi_readcapacity10_cb, VAR_3);
if (VAR_5 == NULL) {
error_report("iSCSI: failed to send readcapacity16 command.");
VAR_4->VAR_1 = 1;
VAR_4->complete = 1;
return;
}
break;
default:
VAR_4->VAR_1 = 0;
VAR_4->complete = 1;
}
}
| [
"FUNC_0(struct iscsi_context *VAR_0, int VAR_1, void *VAR_2,\nvoid *VAR_3)\n{",
"struct IscsiTask *VAR_4 = VAR_3;",
"struct scsi_task *VAR_5 = VAR_2;",
"struct scsi_inquiry_standard *VAR_6;",
"if (VAR_1 != 0) {",
"VAR_4->VAR_1 = 1;",
"VAR_4->complete = 1;",
"scsi_free_scsi_task(VAR_5);",
"return;",
"}",
"VAR_6 = scsi_datain_unmarshall(VAR_5);",
"if (VAR_6 == NULL) {",
"error_report(\"iSCSI: Failed to unmarshall inquiry data.\");",
"VAR_4->VAR_1 = 1;",
"VAR_4->complete = 1;",
"scsi_free_scsi_task(VAR_5);",
"return;",
"}",
"VAR_4->iscsilun->type = VAR_6->periperal_device_type;",
"scsi_free_scsi_task(VAR_5);",
"switch (VAR_4->iscsilun->type) {",
"case TYPE_DISK:\nVAR_5 = iscsi_readcapacity16_task(VAR_0, VAR_4->iscsilun->lun,\niscsi_readcapacity16_cb, VAR_3);",
"if (VAR_5 == NULL) {",
"error_report(\"iSCSI: failed to send readcapacity16 command.\");",
"VAR_4->VAR_1 = 1;",
"VAR_4->complete = 1;",
"return;",
"}",
"break;",
"case TYPE_ROM:\nVAR_5 = iscsi_readcapacity10_task(VAR_0, VAR_4->iscsilun->lun,\n0, 0,\niscsi_readcapacity10_cb, VAR_3);",
"if (VAR_5 == NULL) {",
"error_report(\"iSCSI: failed to send readcapacity16 command.\");",
"VAR_4->VAR_1 = 1;",
"VAR_4->complete = 1;",
"return;",
"}",
"break;",
"default:\nVAR_4->VAR_1 = 0;",
"VAR_4->complete = 1;",
"}",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
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
]
]
|
16,619 | static inline uint8_t mipsdsp_lshift8(uint8_t a, uint8_t s, CPUMIPSState *env)
{
uint8_t sign;
uint8_t discard;
if (s == 0) {
return a;
} else {
sign = (a >> 7) & 0x01;
if (sign != 0) {
discard = (((0x01 << (8 - s)) - 1) << s) |
((a >> (6 - (s - 1))) & ((0x01 << s) - 1));
} else {
discard = a >> (6 - (s - 1));
}
if (discard != 0x00) {
set_DSPControl_overflow_flag(1, 22, env);
}
return a << s;
}
}
| true | qemu | 29851ee7c8bd3fb8542e21cd0270c73132590350 | static inline uint8_t mipsdsp_lshift8(uint8_t a, uint8_t s, CPUMIPSState *env)
{
uint8_t sign;
uint8_t discard;
if (s == 0) {
return a;
} else {
sign = (a >> 7) & 0x01;
if (sign != 0) {
discard = (((0x01 << (8 - s)) - 1) << s) |
((a >> (6 - (s - 1))) & ((0x01 << s) - 1));
} else {
discard = a >> (6 - (s - 1));
}
if (discard != 0x00) {
set_DSPControl_overflow_flag(1, 22, env);
}
return a << s;
}
}
| {
"code": [
" uint8_t sign;",
" if (s == 0) {",
" return a;",
" } else {",
" sign = (a >> 7) & 0x01;",
" if (sign != 0) {",
" discard = (((0x01 << (8 - s)) - 1) << s) |",
" ((a >> (6 - (s - 1))) & ((0x01 << s) - 1));",
" } else {",
" discard = a >> (6 - (s - 1));",
" return a << s;",
" if (s == 0) {",
" return a;",
" } else {",
" if (sign != 0) {",
" } else {",
" return a << s;"
],
"line_no": [
5,
11,
13,
15,
17,
19,
21,
23,
25,
27,
39,
11,
13,
15,
19,
25,
39
]
} | static inline uint8_t FUNC_0(uint8_t a, uint8_t s, CPUMIPSState *env)
{
uint8_t sign;
uint8_t discard;
if (s == 0) {
return a;
} else {
sign = (a >> 7) & 0x01;
if (sign != 0) {
discard = (((0x01 << (8 - s)) - 1) << s) |
((a >> (6 - (s - 1))) & ((0x01 << s) - 1));
} else {
discard = a >> (6 - (s - 1));
}
if (discard != 0x00) {
set_DSPControl_overflow_flag(1, 22, env);
}
return a << s;
}
}
| [
"static inline uint8_t FUNC_0(uint8_t a, uint8_t s, CPUMIPSState *env)\n{",
"uint8_t sign;",
"uint8_t discard;",
"if (s == 0) {",
"return a;",
"} else {",
"sign = (a >> 7) & 0x01;",
"if (sign != 0) {",
"discard = (((0x01 << (8 - s)) - 1) << s) |\n((a >> (6 - (s - 1))) & ((0x01 << s) - 1));",
"} else {",
"discard = a >> (6 - (s - 1));",
"}",
"if (discard != 0x00) {",
"set_DSPControl_overflow_flag(1, 22, env);",
"}",
"return a << s;",
"}",
"}"
]
| [
0,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
]
|
16,620 | static void dwt_encode97_float(DWTContext *s, float *t)
{
int lev,
w = s->linelen[s->ndeclevels-1][0];
float *line = s->f_linebuf;
line += 5;
for (lev = s->ndeclevels-1; lev >= 0; lev--){
int lh = s->linelen[lev][0],
lv = s->linelen[lev][1],
mh = s->mod[lev][0],
mv = s->mod[lev][1],
lp;
float *l;
// HOR_SD
l = line + mh;
for (lp = 0; lp < lv; lp++){
int i, j = 0;
for (i = 0; i < lh; i++)
l[i] = t[w*lp + i];
sd_1d97_float(line, mh, mh + lh);
// copy back and deinterleave
for (i = mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_X * l[i] / 2;
for (i = 1-mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_K * l[i] / 2;
}
// VER_SD
l = line + mv;
for (lp = 0; lp < lh; lp++) {
int i, j = 0;
for (i = 0; i < lv; i++)
l[i] = t[w*i + lp];
sd_1d97_float(line, mv, mv + lv);
// copy back and deinterleave
for (i = mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_X * l[i] / 2;
for (i = 1-mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_K * l[i] / 2;
}
}
}
| true | FFmpeg | 1c495b0bf690995c45f79f4f19500921e14ec78a | static void dwt_encode97_float(DWTContext *s, float *t)
{
int lev,
w = s->linelen[s->ndeclevels-1][0];
float *line = s->f_linebuf;
line += 5;
for (lev = s->ndeclevels-1; lev >= 0; lev--){
int lh = s->linelen[lev][0],
lv = s->linelen[lev][1],
mh = s->mod[lev][0],
mv = s->mod[lev][1],
lp;
float *l;
l = line + mh;
for (lp = 0; lp < lv; lp++){
int i, j = 0;
for (i = 0; i < lh; i++)
l[i] = t[w*lp + i];
sd_1d97_float(line, mh, mh + lh);
for (i = mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_X * l[i] / 2;
for (i = 1-mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_K * l[i] / 2;
}
l = line + mv;
for (lp = 0; lp < lh; lp++) {
int i, j = 0;
for (i = 0; i < lv; i++)
l[i] = t[w*i + lp];
sd_1d97_float(line, mv, mv + lv);
for (i = mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_X * l[i] / 2;
for (i = 1-mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_K * l[i] / 2;
}
}
}
| {
"code": [
" t[w*lp + j] = F_LFTG_X * l[i] / 2;",
" t[w*lp + j] = F_LFTG_K * l[i] / 2;",
" t[w*j + lp] = F_LFTG_X * l[i] / 2;",
" t[w*j + lp] = F_LFTG_K * l[i] / 2;"
],
"line_no": [
55,
59,
89,
93
]
} | static void FUNC_0(DWTContext *VAR_0, float *VAR_1)
{
int VAR_2,
VAR_3 = VAR_0->linelen[VAR_0->ndeclevels-1][0];
float *VAR_4 = VAR_0->f_linebuf;
VAR_4 += 5;
for (VAR_2 = VAR_0->ndeclevels-1; VAR_2 >= 0; VAR_2--){
int VAR_5 = VAR_0->linelen[VAR_2][0],
VAR_6 = VAR_0->linelen[VAR_2][1],
VAR_7 = VAR_0->mod[VAR_2][0],
VAR_8 = VAR_0->mod[VAR_2][1],
VAR_9;
float *VAR_10;
VAR_10 = VAR_4 + VAR_7;
for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++){
int VAR_13, VAR_13 = 0;
for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++)
VAR_10[VAR_13] = VAR_1[VAR_3*VAR_9 + VAR_13];
sd_1d97_float(VAR_4, VAR_7, VAR_7 + VAR_5);
for (VAR_13 = VAR_7; VAR_13 < VAR_5; VAR_13+=2, VAR_13++)
VAR_1[VAR_3*VAR_9 + VAR_13] = F_LFTG_X * VAR_10[VAR_13] / 2;
for (VAR_13 = 1-VAR_7; VAR_13 < VAR_5; VAR_13+=2, VAR_13++)
VAR_1[VAR_3*VAR_9 + VAR_13] = F_LFTG_K * VAR_10[VAR_13] / 2;
}
VAR_10 = VAR_4 + VAR_8;
for (VAR_9 = 0; VAR_9 < VAR_5; VAR_9++) {
int VAR_13, VAR_13 = 0;
for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++)
VAR_10[VAR_13] = VAR_1[VAR_3*VAR_13 + VAR_9];
sd_1d97_float(VAR_4, VAR_8, VAR_8 + VAR_6);
for (VAR_13 = VAR_8; VAR_13 < VAR_6; VAR_13+=2, VAR_13++)
VAR_1[VAR_3*VAR_13 + VAR_9] = F_LFTG_X * VAR_10[VAR_13] / 2;
for (VAR_13 = 1-VAR_8; VAR_13 < VAR_6; VAR_13+=2, VAR_13++)
VAR_1[VAR_3*VAR_13 + VAR_9] = F_LFTG_K * VAR_10[VAR_13] / 2;
}
}
}
| [
"static void FUNC_0(DWTContext *VAR_0, float *VAR_1)\n{",
"int VAR_2,\nVAR_3 = VAR_0->linelen[VAR_0->ndeclevels-1][0];",
"float *VAR_4 = VAR_0->f_linebuf;",
"VAR_4 += 5;",
"for (VAR_2 = VAR_0->ndeclevels-1; VAR_2 >= 0; VAR_2--){",
"int VAR_5 = VAR_0->linelen[VAR_2][0],\nVAR_6 = VAR_0->linelen[VAR_2][1],\nVAR_7 = VAR_0->mod[VAR_2][0],\nVAR_8 = VAR_0->mod[VAR_2][1],\nVAR_9;",
"float *VAR_10;",
"VAR_10 = VAR_4 + VAR_7;",
"for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++){",
"int VAR_13, VAR_13 = 0;",
"for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++)",
"VAR_10[VAR_13] = VAR_1[VAR_3*VAR_9 + VAR_13];",
"sd_1d97_float(VAR_4, VAR_7, VAR_7 + VAR_5);",
"for (VAR_13 = VAR_7; VAR_13 < VAR_5; VAR_13+=2, VAR_13++)",
"VAR_1[VAR_3*VAR_9 + VAR_13] = F_LFTG_X * VAR_10[VAR_13] / 2;",
"for (VAR_13 = 1-VAR_7; VAR_13 < VAR_5; VAR_13+=2, VAR_13++)",
"VAR_1[VAR_3*VAR_9 + VAR_13] = F_LFTG_K * VAR_10[VAR_13] / 2;",
"}",
"VAR_10 = VAR_4 + VAR_8;",
"for (VAR_9 = 0; VAR_9 < VAR_5; VAR_9++) {",
"int VAR_13, VAR_13 = 0;",
"for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++)",
"VAR_10[VAR_13] = VAR_1[VAR_3*VAR_13 + VAR_9];",
"sd_1d97_float(VAR_4, VAR_8, VAR_8 + VAR_6);",
"for (VAR_13 = VAR_8; VAR_13 < VAR_6; VAR_13+=2, VAR_13++)",
"VAR_1[VAR_3*VAR_13 + VAR_9] = F_LFTG_X * VAR_10[VAR_13] / 2;",
"for (VAR_13 = 1-VAR_8; VAR_13 < VAR_6; VAR_13+=2, VAR_13++)",
"VAR_1[VAR_3*VAR_13 + VAR_9] = F_LFTG_K * VAR_10[VAR_13] / 2;",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
15
],
[
17,
19,
21,
23,
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
]
|
16,621 | static void taihu_405ep_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
char *filename;
qemu_irq *pic;
ram_addr_t bios_offset;
target_phys_addr_t ram_bases[2], ram_sizes[2];
long bios_size;
target_ulong kernel_base, initrd_base;
long kernel_size, initrd_size;
int linux_boot;
int fl_idx, fl_sectors;
DriveInfo *dinfo;
/* RAM is soldered to the board so the size cannot be changed */
ram_bases[0] = qemu_ram_alloc(NULL, "taihu_405ep.ram-0", 0x04000000);
ram_sizes[0] = 0x04000000;
ram_bases[1] = qemu_ram_alloc(NULL, "taihu_405ep.ram-1", 0x04000000);
ram_sizes[1] = 0x04000000;
ram_size = 0x08000000;
#ifdef DEBUG_BOARD_INIT
printf("%s: register cpu\n", __func__);
#endif
ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,
kernel_filename == NULL ? 0 : 1);
/* allocate and load BIOS */
#ifdef DEBUG_BOARD_INIT
printf("%s: register BIOS\n", __func__);
#endif
fl_idx = 0;
#if defined(USE_FLASH_BIOS)
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
bios_size = bdrv_getlength(dinfo->bdrv);
/* XXX: should check that size is 2MB */
// bios_size = 2 * 1024 * 1024;
fl_sectors = (bios_size + 65535) >> 16;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", bios_size);
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr %lx '%s' %d\n",
fl_idx, bios_size, bios_offset, -bios_size,
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
#endif
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
dinfo->bdrv, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
} else
#endif
{
#ifdef DEBUG_BOARD_INIT
printf("Load BIOS from file\n");
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", BIOS_SIZE);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
bios_name);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
}
/* Register Linux flash */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
bios_size = bdrv_getlength(dinfo->bdrv);
/* XXX: should check that size is 32MB */
bios_size = 32 * 1024 * 1024;
fl_sectors = (bios_size + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr " TARGET_FMT_lx " '%s'\n",
fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000,
bdrv_get_device_name(dinfo->bdrv));
#endif
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.flash", bios_size);
pflash_cfi02_register(0xfc000000, bios_offset,
dinfo->bdrv, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
}
/* Register CLPD & LCD display */
#ifdef DEBUG_BOARD_INIT
printf("%s: register CPLD\n", __func__);
#endif
taihu_cpld_init(0x50100000);
/* Load kernel */
linux_boot = (kernel_filename != NULL);
if (linux_boot) {
#ifdef DEBUG_BOARD_INIT
printf("%s: load kernel\n", __func__);
#endif
kernel_base = KERNEL_LOAD_ADDR;
/* now we can load the kernel */
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
/* load initrd */
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr,
"qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: Done\n", __func__);
#endif
} | true | qemu | e98ccb3fbba94d0b2165caabf7aeee370d4ce900 | static void taihu_405ep_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
char *filename;
qemu_irq *pic;
ram_addr_t bios_offset;
target_phys_addr_t ram_bases[2], ram_sizes[2];
long bios_size;
target_ulong kernel_base, initrd_base;
long kernel_size, initrd_size;
int linux_boot;
int fl_idx, fl_sectors;
DriveInfo *dinfo;
ram_bases[0] = qemu_ram_alloc(NULL, "taihu_405ep.ram-0", 0x04000000);
ram_sizes[0] = 0x04000000;
ram_bases[1] = qemu_ram_alloc(NULL, "taihu_405ep.ram-1", 0x04000000);
ram_sizes[1] = 0x04000000;
ram_size = 0x08000000;
#ifdef DEBUG_BOARD_INIT
printf("%s: register cpu\n", __func__);
#endif
ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,
kernel_filename == NULL ? 0 : 1);
#ifdef DEBUG_BOARD_INIT
printf("%s: register BIOS\n", __func__);
#endif
fl_idx = 0;
#if defined(USE_FLASH_BIOS)
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
bios_size = bdrv_getlength(dinfo->bdrv);
fl_sectors = (bios_size + 65535) >> 16;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", bios_size);
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr %lx '%s' %d\n",
fl_idx, bios_size, bios_offset, -bios_size,
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
#endif
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
dinfo->bdrv, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
} else
#endif
{
#ifdef DEBUG_BOARD_INIT
printf("Load BIOS from file\n");
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", BIOS_SIZE);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
bios_name);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
}
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
bios_size = bdrv_getlength(dinfo->bdrv);
bios_size = 32 * 1024 * 1024;
fl_sectors = (bios_size + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr " TARGET_FMT_lx " '%s'\n",
fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000,
bdrv_get_device_name(dinfo->bdrv));
#endif
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.flash", bios_size);
pflash_cfi02_register(0xfc000000, bios_offset,
dinfo->bdrv, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: register CPLD\n", __func__);
#endif
taihu_cpld_init(0x50100000);
linux_boot = (kernel_filename != NULL);
if (linux_boot) {
#ifdef DEBUG_BOARD_INIT
printf("%s: load kernel\n", __func__);
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr,
"qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: Done\n", __func__);
#endif
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3,
const char *VAR_4,
const char *VAR_5)
{
char *VAR_6;
qemu_irq *pic;
ram_addr_t bios_offset;
target_phys_addr_t ram_bases[2], ram_sizes[2];
long VAR_7;
target_ulong kernel_base, initrd_base;
long VAR_8, VAR_9;
int VAR_10;
int VAR_11, VAR_12;
DriveInfo *dinfo;
ram_bases[0] = qemu_ram_alloc(NULL, "taihu_405ep.ram-0", 0x04000000);
ram_sizes[0] = 0x04000000;
ram_bases[1] = qemu_ram_alloc(NULL, "taihu_405ep.ram-1", 0x04000000);
ram_sizes[1] = 0x04000000;
VAR_0 = 0x08000000;
#ifdef DEBUG_BOARD_INIT
printf("%s: register cpu\n", __func__);
#endif
ppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,
VAR_2 == NULL ? 0 : 1);
#ifdef DEBUG_BOARD_INIT
printf("%s: register BIOS\n", __func__);
#endif
VAR_11 = 0;
#if defined(USE_FLASH_BIOS)
dinfo = drive_get(IF_PFLASH, 0, VAR_11);
if (dinfo) {
VAR_7 = bdrv_getlength(dinfo->bdrv);
VAR_12 = (VAR_7 + 65535) >> 16;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", VAR_7);
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr %lx '%s' %d\n",
VAR_11, VAR_7, bios_offset, -VAR_7,
bdrv_get_device_name(dinfo->bdrv), VAR_12);
#endif
pflash_cfi02_register((uint32_t)(-VAR_7), bios_offset,
dinfo->bdrv, 65536, VAR_12, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
VAR_11++;
} else
#endif
{
#ifdef DEBUG_BOARD_INIT
printf("Load BIOS from file\n");
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", BIOS_SIZE);
VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_6) {
VAR_7 = load_image(VAR_6, qemu_get_ram_ptr(bios_offset));
} else {
VAR_7 = -1;
}
if (VAR_7 < 0 || VAR_7 > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
bios_name);
exit(1);
}
VAR_7 = (VAR_7 + 0xfff) & ~0xfff;
cpu_register_physical_memory((uint32_t)(-VAR_7),
VAR_7, bios_offset | IO_MEM_ROM);
}
dinfo = drive_get(IF_PFLASH, 0, VAR_11);
if (dinfo) {
VAR_7 = bdrv_getlength(dinfo->bdrv);
VAR_7 = 32 * 1024 * 1024;
VAR_12 = (VAR_7 + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at offset %08lx addr " TARGET_FMT_lx " '%s'\n",
VAR_11, VAR_7, bios_offset, (target_ulong)0xfc000000,
bdrv_get_device_name(dinfo->bdrv));
#endif
bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.flash", VAR_7);
pflash_cfi02_register(0xfc000000, bios_offset,
dinfo->bdrv, 65536, VAR_12, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
VAR_11++;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: register CPLD\n", __func__);
#endif
taihu_cpld_init(0x50100000);
VAR_10 = (VAR_2 != NULL);
if (VAR_10) {
#ifdef DEBUG_BOARD_INIT
printf("%s: load kernel\n", __func__);
#endif
kernel_base = KERNEL_LOAD_ADDR;
VAR_8 = load_image_targphys(VAR_2, kernel_base,
VAR_0 - kernel_base);
if (VAR_8 < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_2);
exit(1);
}
if (VAR_4) {
initrd_base = INITRD_LOAD_ADDR;
VAR_9 = load_image_targphys(VAR_4, initrd_base,
VAR_0 - initrd_base);
if (VAR_9 < 0) {
fprintf(stderr,
"qemu: could not load initial ram disk '%s'\n",
VAR_4);
exit(1);
}
} else {
initrd_base = 0;
VAR_9 = 0;
}
} else {
kernel_base = 0;
VAR_8 = 0;
initrd_base = 0;
VAR_9 = 0;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: Done\n", __func__);
#endif
} | [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2,\nconst char *VAR_3,\nconst char *VAR_4,\nconst char *VAR_5)\n{",
"char *VAR_6;",
"qemu_irq *pic;",
"ram_addr_t bios_offset;",
"target_phys_addr_t ram_bases[2], ram_sizes[2];",
"long VAR_7;",
"target_ulong kernel_base, initrd_base;",
"long VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11, VAR_12;",
"DriveInfo *dinfo;",
"ram_bases[0] = qemu_ram_alloc(NULL, \"taihu_405ep.ram-0\", 0x04000000);",
"ram_sizes[0] = 0x04000000;",
"ram_bases[1] = qemu_ram_alloc(NULL, \"taihu_405ep.ram-1\", 0x04000000);",
"ram_sizes[1] = 0x04000000;",
"VAR_0 = 0x08000000;",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"%s: register cpu\\n\", __func__);",
"#endif\nppc405ep_init(ram_bases, ram_sizes, 33333333, &pic,\nVAR_2 == NULL ? 0 : 1);",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"%s: register BIOS\\n\", __func__);",
"#endif\nVAR_11 = 0;",
"#if defined(USE_FLASH_BIOS)\ndinfo = drive_get(IF_PFLASH, 0, VAR_11);",
"if (dinfo) {",
"VAR_7 = bdrv_getlength(dinfo->bdrv);",
"VAR_12 = (VAR_7 + 65535) >> 16;",
"bios_offset = qemu_ram_alloc(NULL, \"taihu_405ep.bios\", VAR_7);",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"Register parallel flash %d size %lx\"\n\" at offset %08lx addr %lx '%s' %d\\n\",\nVAR_11, VAR_7, bios_offset, -VAR_7,\nbdrv_get_device_name(dinfo->bdrv), VAR_12);",
"#endif\npflash_cfi02_register((uint32_t)(-VAR_7), bios_offset,\ndinfo->bdrv, 65536, VAR_12, 1,\n4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,\n1);",
"VAR_11++;",
"} else",
"#endif\n{",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"Load BIOS from file\\n\");",
"#endif\nif (bios_name == NULL)\nbios_name = BIOS_FILENAME;",
"bios_offset = qemu_ram_alloc(NULL, \"taihu_405ep.bios\", BIOS_SIZE);",
"VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_6) {",
"VAR_7 = load_image(VAR_6, qemu_get_ram_ptr(bios_offset));",
"} else {",
"VAR_7 = -1;",
"}",
"if (VAR_7 < 0 || VAR_7 > BIOS_SIZE) {",
"fprintf(stderr, \"qemu: could not load PowerPC bios '%s'\\n\",\nbios_name);",
"exit(1);",
"}",
"VAR_7 = (VAR_7 + 0xfff) & ~0xfff;",
"cpu_register_physical_memory((uint32_t)(-VAR_7),\nVAR_7, bios_offset | IO_MEM_ROM);",
"}",
"dinfo = drive_get(IF_PFLASH, 0, VAR_11);",
"if (dinfo) {",
"VAR_7 = bdrv_getlength(dinfo->bdrv);",
"VAR_7 = 32 * 1024 * 1024;",
"VAR_12 = (VAR_7 + 65535) >> 16;",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"Register parallel flash %d size %lx\"\n\" at offset %08lx addr \" TARGET_FMT_lx \" '%s'\\n\",\nVAR_11, VAR_7, bios_offset, (target_ulong)0xfc000000,\nbdrv_get_device_name(dinfo->bdrv));",
"#endif\nbios_offset = qemu_ram_alloc(NULL, \"taihu_405ep.flash\", VAR_7);",
"pflash_cfi02_register(0xfc000000, bios_offset,\ndinfo->bdrv, 65536, VAR_12, 1,\n4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,\n1);",
"VAR_11++;",
"}",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"%s: register CPLD\\n\", __func__);",
"#endif\ntaihu_cpld_init(0x50100000);",
"VAR_10 = (VAR_2 != NULL);",
"if (VAR_10) {",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"%s: load kernel\\n\", __func__);",
"#endif\nkernel_base = KERNEL_LOAD_ADDR;",
"VAR_8 = load_image_targphys(VAR_2, kernel_base,\nVAR_0 - kernel_base);",
"if (VAR_8 < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_2);",
"exit(1);",
"}",
"if (VAR_4) {",
"initrd_base = INITRD_LOAD_ADDR;",
"VAR_9 = load_image_targphys(VAR_4, initrd_base,\nVAR_0 - initrd_base);",
"if (VAR_9 < 0) {",
"fprintf(stderr,\n\"qemu: could not load initial ram disk '%s'\\n\",\nVAR_4);",
"exit(1);",
"}",
"} else {",
"initrd_base = 0;",
"VAR_9 = 0;",
"}",
"} else {",
"kernel_base = 0;",
"VAR_8 = 0;",
"initrd_base = 0;",
"VAR_9 = 0;",
"}",
"#ifdef DEBUG_BOARD_INIT\nprintf(\"%s: Done\\n\", __func__);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55,
57
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
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
],
[
132
],
[
134
],
[
136
],
[
138
],
[
140,
142
],
[
144
],
[
146
],
[
148
],
[
150,
152
],
[
154
],
[
158
],
[
160
],
[
162
],
[
166
],
[
168
],
[
170,
172,
174,
176,
178
],
[
180,
182
],
[
184,
186,
188,
190
],
[
192
],
[
194
],
[
198,
200
],
[
202,
204
],
[
208
],
[
210
],
[
212,
214
],
[
216,
218
],
[
222,
224
],
[
226
],
[
228,
230
],
[
232
],
[
234
],
[
238
],
[
240
],
[
242,
244
],
[
246
],
[
248,
250,
252
],
[
254
],
[
256
],
[
258
],
[
260
],
[
262
],
[
264
],
[
266
],
[
268
],
[
270
],
[
272
],
[
274
],
[
276
],
[
278,
280
],
[
282,
284
]
]
|
16,622 | int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int reslevelno, bandno, gbandno = 0, ret, i, j;
uint32_t csize;
if (!codsty->nreslevels2decode) {
av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
return AVERROR_INVALIDDATA;
}
if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
codsty->nreslevels2decode - 1,
codsty->transform))
return ret;
// component size comp->coord is uint16_t so ir cannot overflow
csize = (comp->coord[0][1] - comp->coord[0][0]) *
(comp->coord[1][1] - comp->coord[1][0]);
if (codsty->transform == FF_DWT97) {
comp->i_data = NULL;
comp->f_data = av_malloc_array(csize, sizeof(*comp->f_data));
if (!comp->f_data)
return AVERROR(ENOMEM);
} else {
comp->f_data = NULL;
comp->i_data = av_malloc_array(csize, sizeof(*comp->i_data));
if (!comp->i_data)
return AVERROR(ENOMEM);
}
comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
/* LOOP on resolution levels */
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
/* Compute borders for each resolution level.
* Computation of trx_0, trx_1, try_0 and try_1.
* see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
// update precincts size: 2^n value
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
/* Number of bands for each resolution level */
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
/* Number of precincts wich span the tile for resolution level reslevelno
* see B.6 in ISO/IEC 15444-1:2002 eq. B-16
* num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width)
* num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width)
* for Dcinema profiles in JPEG 2000
* num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -|
* num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| */
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
switch (qntsty->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
/* TODO: to verify. No quantization in this case */
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
/*TODO: Compute formula to implement. */
numbps = cbps +
lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SE:
/* Exponent quantization step.
* Formula:
* delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
* R_b = R_I + log2 (gain_b )
* see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
/* TODO/WARN: value of log2 (gain_b ) not taken into account
* but it works (compared to OpenJPEG). Why?
* Further investigation needed. */
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
/* computation of tbx_0, tbx_1, tby_0, tby_1
* see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
* codeblock width and height is computed for
* DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
if (reslevelno == 0) {
/* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height);
} else {
/* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
/* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
/* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
/* TODO: Manage case of 3 band offsets here or
* in coding/decoding function? */
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
/* TODO: Explain formula for JPEG200 DCINEMA. */
/* TODO: Verify with previous count of codeblocks per band */
/* Compute P_x0 */
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
/* Compute P_y0 */
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
/* Compute P_x1 */
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
/* Compute P_y1 */
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
/* Tag trees initialization */
prec->cblkincl =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_mallocz_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
/* Compute coordinates of codeblocks */
/* Compute Cx0*/
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
/* Compute Cy0*/
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
/* Compute Cx1 */
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
/* Compute Cy1 */
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
/* Update code-blocks coordinates according sub-band position */
if ((bandno + !!reslevelno) & 1) {
cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
}
if ((bandno + !!reslevelno) & 2) {
cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| false | FFmpeg | 10306e9c5fcc28bd9310a9b38f21540e9e1433e9 | int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int reslevelno, bandno, gbandno = 0, ret, i, j;
uint32_t csize;
if (!codsty->nreslevels2decode) {
av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
return AVERROR_INVALIDDATA;
}
if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
codsty->nreslevels2decode - 1,
codsty->transform))
return ret;
csize = (comp->coord[0][1] - comp->coord[0][0]) *
(comp->coord[1][1] - comp->coord[1][0]);
if (codsty->transform == FF_DWT97) {
comp->i_data = NULL;
comp->f_data = av_malloc_array(csize, sizeof(*comp->f_data));
if (!comp->f_data)
return AVERROR(ENOMEM);
} else {
comp->f_data = NULL;
comp->i_data = av_malloc_array(csize, sizeof(*comp->i_data));
if (!comp->i_data)
return AVERROR(ENOMEM);
}
comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
switch (qntsty->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
numbps = cbps +
lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SE:
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
if (reslevelno == 0) {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height);
} else {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
prec->cblkincl =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_mallocz_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if ((bandno + !!reslevelno) & 1) {
cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] -
comp->reslevel[reslevelno-1].coord[0][0];
}
if ((bandno + !!reslevelno) & 2) {
cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] -
comp->reslevel[reslevelno-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Jpeg2000Component *VAR_0,
Jpeg2000CodingStyle *VAR_1,
Jpeg2000QuantStyle *VAR_2,
int VAR_3, int VAR_4, int VAR_5,
AVCodecContext *VAR_6)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int VAR_7, VAR_8, VAR_9 = 0, VAR_10, VAR_11, VAR_12;
uint32_t csize;
if (!VAR_1->nreslevels2decode) {
av_log(VAR_6, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
return AVERROR_INVALIDDATA;
}
if (VAR_10 = ff_jpeg2000_dwt_init(&VAR_0->dwt, VAR_0->coord,
VAR_1->nreslevels2decode - 1,
VAR_1->transform))
return VAR_10;
csize = (VAR_0->coord[0][1] - VAR_0->coord[0][0]) *
(VAR_0->coord[1][1] - VAR_0->coord[1][0]);
if (VAR_1->transform == FF_DWT97) {
VAR_0->i_data = NULL;
VAR_0->f_data = av_malloc_array(csize, sizeof(*VAR_0->f_data));
if (!VAR_0->f_data)
return AVERROR(ENOMEM);
} else {
VAR_0->f_data = NULL;
VAR_0->i_data = av_malloc_array(csize, sizeof(*VAR_0->i_data));
if (!VAR_0->i_data)
return AVERROR(ENOMEM);
}
VAR_0->reslevel = av_malloc_array(VAR_1->nreslevels, sizeof(*VAR_0->reslevel));
if (!VAR_0->reslevel)
return AVERROR(ENOMEM);
for (VAR_7 = 0; VAR_7 < VAR_1->nreslevels; VAR_7++) {
int declvl = VAR_1->nreslevels - VAR_7;
Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_7;
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
reslevel->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12], declvl - 1);
reslevel->log2_prec_width = VAR_1->log2_prec_widths[VAR_7];
reslevel->log2_prec_height = VAR_1->log2_prec_heights[VAR_7];
if (VAR_7 == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (VAR_8 = 0; VAR_8 < reslevel->nbands; VAR_8++, VAR_9++) {
Jpeg2000Band *band = reslevel->band + VAR_8;
int cblkno, precno;
int nb_precincts;
switch (VAR_2->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
numbps = VAR_3 +
lut_gain[VAR_1->transform == FF_DWT53][VAR_8 + (VAR_7 > 0)];
band->f_stepsize = SHL(2048 + VAR_2->mant[VAR_9],
2 + numbps - VAR_2->expn[VAR_9]);
break;
case JPEG2000_QSTY_SE:
gain = VAR_3;
band->f_stepsize = pow(2.0, gain - VAR_2->expn[VAR_9]);
band->f_stepsize *= VAR_2->mant[VAR_9] / 2048.0 + 1.0;
break;
default:
band->f_stepsize = 0;
av_log(VAR_6, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (!av_codec_is_encoder(VAR_6->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
if (VAR_7 == 0) {
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,
reslevel->log2_prec_height);
} else {
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0] -
(((VAR_8 + 1 >> VAR_11) & 1) << declvl - 1),
declvl);
band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[0][VAR_12] = ff_jpeg2000_ceildiv(band->coord[0][VAR_12], VAR_4);
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[1][VAR_12] = ff_jpeg2000_ceildiv(band->coord[1][VAR_12], VAR_5);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
prec->cblkincl =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_mallocz_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if ((VAR_8 + !!VAR_7) & 1) {
cblk->coord[0][0] += VAR_0->reslevel[VAR_7-1].coord[0][1] -
VAR_0->reslevel[VAR_7-1].coord[0][0];
cblk->coord[0][1] += VAR_0->reslevel[VAR_7-1].coord[0][1] -
VAR_0->reslevel[VAR_7-1].coord[0][0];
}
if ((VAR_8 + !!VAR_7) & 2) {
cblk->coord[1][0] += VAR_0->reslevel[VAR_7-1].coord[1][1] -
VAR_0->reslevel[VAR_7-1].coord[1][0];
cblk->coord[1][1] += VAR_0->reslevel[VAR_7-1].coord[1][1] -
VAR_0->reslevel[VAR_7-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| [
"int FUNC_0(Jpeg2000Component *VAR_0,\nJpeg2000CodingStyle *VAR_1,\nJpeg2000QuantStyle *VAR_2,\nint VAR_3, int VAR_4, int VAR_5,\nAVCodecContext *VAR_6)\n{",
"uint8_t log2_band_prec_width, log2_band_prec_height;",
"int VAR_7, VAR_8, VAR_9 = 0, VAR_10, VAR_11, VAR_12;",
"uint32_t csize;",
"if (!VAR_1->nreslevels2decode) {",
"av_log(VAR_6, AV_LOG_ERROR, \"nreslevels2decode uninitialized\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_10 = ff_jpeg2000_dwt_init(&VAR_0->dwt, VAR_0->coord,\nVAR_1->nreslevels2decode - 1,\nVAR_1->transform))\nreturn VAR_10;",
"csize = (VAR_0->coord[0][1] - VAR_0->coord[0][0]) *\n(VAR_0->coord[1][1] - VAR_0->coord[1][0]);",
"if (VAR_1->transform == FF_DWT97) {",
"VAR_0->i_data = NULL;",
"VAR_0->f_data = av_malloc_array(csize, sizeof(*VAR_0->f_data));",
"if (!VAR_0->f_data)\nreturn AVERROR(ENOMEM);",
"} else {",
"VAR_0->f_data = NULL;",
"VAR_0->i_data = av_malloc_array(csize, sizeof(*VAR_0->i_data));",
"if (!VAR_0->i_data)\nreturn AVERROR(ENOMEM);",
"}",
"VAR_0->reslevel = av_malloc_array(VAR_1->nreslevels, sizeof(*VAR_0->reslevel));",
"if (!VAR_0->reslevel)\nreturn AVERROR(ENOMEM);",
"for (VAR_7 = 0; VAR_7 < VAR_1->nreslevels; VAR_7++) {",
"int declvl = VAR_1->nreslevels - VAR_7;",
"Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_7;",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"reslevel->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12], declvl - 1);",
"reslevel->log2_prec_width = VAR_1->log2_prec_widths[VAR_7];",
"reslevel->log2_prec_height = VAR_1->log2_prec_heights[VAR_7];",
"if (VAR_7 == 0)\nreslevel->nbands = 1;",
"else\nreslevel->nbands = 3;",
"if (reslevel->coord[0][1] == reslevel->coord[0][0])\nreslevel->num_precincts_x = 0;",
"else\nreslevel->num_precincts_x =\nff_jpeg2000_ceildivpow2(reslevel->coord[0][1],\nreslevel->log2_prec_width) -\n(reslevel->coord[0][0] >> reslevel->log2_prec_width);",
"if (reslevel->coord[1][1] == reslevel->coord[1][0])\nreslevel->num_precincts_y = 0;",
"else\nreslevel->num_precincts_y =\nff_jpeg2000_ceildivpow2(reslevel->coord[1][1],\nreslevel->log2_prec_height) -\n(reslevel->coord[1][0] >> reslevel->log2_prec_height);",
"reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));",
"if (!reslevel->band)\nreturn AVERROR(ENOMEM);",
"for (VAR_8 = 0; VAR_8 < reslevel->nbands; VAR_8++, VAR_9++) {",
"Jpeg2000Band *band = reslevel->band + VAR_8;",
"int cblkno, precno;",
"int nb_precincts;",
"switch (VAR_2->quantsty) {",
"uint8_t gain;",
"int numbps;",
"case JPEG2000_QSTY_NONE:\nband->f_stepsize = 1;",
"break;",
"case JPEG2000_QSTY_SI:\nnumbps = VAR_3 +\nlut_gain[VAR_1->transform == FF_DWT53][VAR_8 + (VAR_7 > 0)];",
"band->f_stepsize = SHL(2048 + VAR_2->mant[VAR_9],\n2 + numbps - VAR_2->expn[VAR_9]);",
"break;",
"case JPEG2000_QSTY_SE:\ngain = VAR_3;",
"band->f_stepsize = pow(2.0, gain - VAR_2->expn[VAR_9]);",
"band->f_stepsize *= VAR_2->mant[VAR_9] / 2048.0 + 1.0;",
"break;",
"default:\nband->f_stepsize = 0;",
"av_log(VAR_6, AV_LOG_ERROR, \"Unknown quantization format\\n\");",
"break;",
"}",
"if (!av_codec_is_encoder(VAR_6->codec))\nband->f_stepsize *= 0.5;",
"band->i_stepsize = band->f_stepsize * (1 << 16);",
"if (VAR_7 == 0) {",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0],\ndeclvl - 1);",
"log2_band_prec_width = reslevel->log2_prec_width;",
"log2_band_prec_height = reslevel->log2_prec_height;",
"band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,\nreslevel->log2_prec_width);",
"band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,\nreslevel->log2_prec_height);",
"} else {",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0] -\n(((VAR_8 + 1 >> VAR_11) & 1) << declvl - 1),\ndeclvl);",
"band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,\nreslevel->log2_prec_width - 1);",
"band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,\nreslevel->log2_prec_height - 1);",
"log2_band_prec_width = reslevel->log2_prec_width - 1;",
"log2_band_prec_height = reslevel->log2_prec_height - 1;",
"}",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[0][VAR_12] = ff_jpeg2000_ceildiv(band->coord[0][VAR_12], VAR_4);",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[1][VAR_12] = ff_jpeg2000_ceildiv(band->coord[1][VAR_12], VAR_5);",
"band->prec = av_malloc_array(reslevel->num_precincts_x *\nreslevel->num_precincts_y,\nsizeof(*band->prec));",
"if (!band->prec)\nreturn AVERROR(ENOMEM);",
"nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;",
"for (precno = 0; precno < nb_precincts; precno++) {",
"Jpeg2000Prec *prec = band->prec + precno;",
"prec->coord[0][0] = (precno % reslevel->num_precincts_x) *\n(1 << log2_band_prec_width);",
"prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);",
"prec->coord[1][0] = (precno / reslevel->num_precincts_x) *\n(1 << log2_band_prec_height);",
"prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);",
"prec->coord[0][1] = prec->coord[0][0] +\n(1 << log2_band_prec_width);",
"prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);",
"prec->coord[1][1] = prec->coord[1][0] +\n(1 << log2_band_prec_height);",
"prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);",
"prec->nb_codeblocks_width =\nff_jpeg2000_ceildivpow2(prec->coord[0][1] -\nprec->coord[0][0],\nband->log2_cblk_width);",
"prec->nb_codeblocks_height =\nff_jpeg2000_ceildivpow2(prec->coord[1][1] -\nprec->coord[1][0],\nband->log2_cblk_height);",
"prec->cblkincl =\nff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,\nprec->nb_codeblocks_height);",
"if (!prec->cblkincl)\nreturn AVERROR(ENOMEM);",
"prec->zerobits =\nff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,\nprec->nb_codeblocks_height);",
"if (!prec->zerobits)\nreturn AVERROR(ENOMEM);",
"prec->cblk = av_mallocz_array(prec->nb_codeblocks_width *\nprec->nb_codeblocks_height,\nsizeof(*prec->cblk));",
"if (!prec->cblk)\nreturn AVERROR(ENOMEM);",
"for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {",
"Jpeg2000Cblk *cblk = prec->cblk + cblkno;",
"uint16_t Cx0, Cy0;",
"Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;",
"Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);",
"cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);",
"Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;",
"Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);",
"cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);",
"cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),\nprec->coord[0][1]);",
"cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),\nprec->coord[1][1]);",
"if ((VAR_8 + !!VAR_7) & 1) {",
"cblk->coord[0][0] += VAR_0->reslevel[VAR_7-1].coord[0][1] -\nVAR_0->reslevel[VAR_7-1].coord[0][0];",
"cblk->coord[0][1] += VAR_0->reslevel[VAR_7-1].coord[0][1] -\nVAR_0->reslevel[VAR_7-1].coord[0][0];",
"}",
"if ((VAR_8 + !!VAR_7) & 2) {",
"cblk->coord[1][0] += VAR_0->reslevel[VAR_7-1].coord[1][1] -\nVAR_0->reslevel[VAR_7-1].coord[1][0];",
"cblk->coord[1][1] += VAR_0->reslevel[VAR_7-1].coord[1][1] -\nVAR_0->reslevel[VAR_7-1].coord[1][0];",
"}",
"cblk->zero = 0;",
"cblk->lblock = 3;",
"cblk->length = 0;",
"cblk->lengthinc = 0;",
"cblk->npasses = 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
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33,
35,
37
],
[
41,
43
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
109,
111
],
[
113,
115
],
[
133,
135
],
[
137,
139,
141,
143,
145
],
[
149,
151
],
[
153,
155,
157,
159,
161
],
[
165
],
[
167,
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
187
],
[
189
],
[
191
],
[
193,
197
],
[
199
],
[
201,
205,
207
],
[
209,
211
],
[
213
],
[
215,
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
255,
257
],
[
261
],
[
273
],
[
277
],
[
279
],
[
281,
283,
285
],
[
287
],
[
289
],
[
293,
295
],
[
297,
299
],
[
301
],
[
307
],
[
309
],
[
313,
315,
317,
319
],
[
329,
331
],
[
333,
335
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
357,
359,
361
],
[
363,
365
],
[
369
],
[
373
],
[
375
],
[
387,
389
],
[
391
],
[
397,
399
],
[
401
],
[
407,
409
],
[
411
],
[
417,
419
],
[
421
],
[
425,
427,
429,
431
],
[
433,
435,
437,
439
],
[
445,
447,
449
],
[
451,
453
],
[
457,
459,
461
],
[
463,
465
],
[
469,
471,
473
],
[
475,
477
],
[
479
],
[
481
],
[
483
],
[
491
],
[
493
],
[
495
],
[
501
],
[
503
],
[
505
],
[
511,
513
],
[
519,
521
],
[
525
],
[
527,
529
],
[
531,
533
],
[
535
],
[
537
],
[
539,
541
],
[
543,
545
],
[
547
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
]
]
|
16,623 | static void bonito_writel(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
int reset = 0;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, val, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
case BONITO_SDCFG:
case BONITO_PCIMAP:
case BONITO_PCIMEMBASECFG:
case BONITO_PCIMAP_CFG:
case BONITO_GPIODATA:
case BONITO_GPIOIE:
case BONITO_INTEDGE:
case BONITO_INTSTEER:
case BONITO_INTPOL:
case BONITO_PCIMAIL0:
case BONITO_PCIMAIL1:
case BONITO_PCIMAIL2:
case BONITO_PCIMAIL3:
case BONITO_PCICACHECTRL:
case BONITO_PCICACHETAG:
case BONITO_PCIBADADDR:
case BONITO_PCIMSTAT:
case BONITO_TIMECFG:
case BONITO_CPUCFG:
case BONITO_DQCFG:
case BONITO_MEMSIZE:
s->regs[saddr] = val;
break;
case BONITO_BONGENCFG:
if (!(s->regs[saddr] & 0x04) && (val & 0x04)) {
reset = 1; /* bit 2 jump from 0 to 1 cause reset */
}
s->regs[saddr] = val;
if (reset) {
qemu_system_reset_request();
}
break;
case BONITO_INTENSET:
s->regs[BONITO_INTENSET] = val;
s->regs[BONITO_INTEN] |= val;
break;
case BONITO_INTENCLR:
s->regs[BONITO_INTENCLR] = val;
s->regs[BONITO_INTEN] &= ~val;
break;
case BONITO_INTEN:
case BONITO_INTISR:
DPRINTF("write to readonly bonito register %x\n", saddr);
break;
default:
DPRINTF("write to unknown bonito register %x\n", saddr);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void bonito_writel(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
int reset = 0;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, val, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
case BONITO_SDCFG:
case BONITO_PCIMAP:
case BONITO_PCIMEMBASECFG:
case BONITO_PCIMAP_CFG:
case BONITO_GPIODATA:
case BONITO_GPIOIE:
case BONITO_INTEDGE:
case BONITO_INTSTEER:
case BONITO_INTPOL:
case BONITO_PCIMAIL0:
case BONITO_PCIMAIL1:
case BONITO_PCIMAIL2:
case BONITO_PCIMAIL3:
case BONITO_PCICACHECTRL:
case BONITO_PCICACHETAG:
case BONITO_PCIBADADDR:
case BONITO_PCIMSTAT:
case BONITO_TIMECFG:
case BONITO_CPUCFG:
case BONITO_DQCFG:
case BONITO_MEMSIZE:
s->regs[saddr] = val;
break;
case BONITO_BONGENCFG:
if (!(s->regs[saddr] & 0x04) && (val & 0x04)) {
reset = 1;
}
s->regs[saddr] = val;
if (reset) {
qemu_system_reset_request();
}
break;
case BONITO_INTENSET:
s->regs[BONITO_INTENSET] = val;
s->regs[BONITO_INTEN] |= val;
break;
case BONITO_INTENCLR:
s->regs[BONITO_INTENCLR] = val;
s->regs[BONITO_INTEN] &= ~val;
break;
case BONITO_INTEN:
case BONITO_INTISR:
DPRINTF("write to readonly bonito register %x\n", saddr);
break;
default:
DPRINTF("write to unknown bonito register %x\n", saddr);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
PCIBonitoState *s = VAR_0;
uint32_t saddr;
int VAR_4 = 0;
saddr = (VAR_1 - BONITO_REGBASE) >> 2;
DPRINTF("FUNC_0 "TARGET_FMT_plx" VAR_2 %x saddr %x\n", VAR_1, VAR_2, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
case BONITO_SDCFG:
case BONITO_PCIMAP:
case BONITO_PCIMEMBASECFG:
case BONITO_PCIMAP_CFG:
case BONITO_GPIODATA:
case BONITO_GPIOIE:
case BONITO_INTEDGE:
case BONITO_INTSTEER:
case BONITO_INTPOL:
case BONITO_PCIMAIL0:
case BONITO_PCIMAIL1:
case BONITO_PCIMAIL2:
case BONITO_PCIMAIL3:
case BONITO_PCICACHECTRL:
case BONITO_PCICACHETAG:
case BONITO_PCIBADADDR:
case BONITO_PCIMSTAT:
case BONITO_TIMECFG:
case BONITO_CPUCFG:
case BONITO_DQCFG:
case BONITO_MEMSIZE:
s->regs[saddr] = VAR_2;
break;
case BONITO_BONGENCFG:
if (!(s->regs[saddr] & 0x04) && (VAR_2 & 0x04)) {
VAR_4 = 1;
}
s->regs[saddr] = VAR_2;
if (VAR_4) {
qemu_system_reset_request();
}
break;
case BONITO_INTENSET:
s->regs[BONITO_INTENSET] = VAR_2;
s->regs[BONITO_INTEN] |= VAR_2;
break;
case BONITO_INTENCLR:
s->regs[BONITO_INTENCLR] = VAR_2;
s->regs[BONITO_INTEN] &= ~VAR_2;
break;
case BONITO_INTEN:
case BONITO_INTISR:
DPRINTF("write to readonly bonito register %x\n", saddr);
break;
default:
DPRINTF("write to unknown bonito register %x\n", saddr);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"PCIBonitoState *s = VAR_0;",
"uint32_t saddr;",
"int VAR_4 = 0;",
"saddr = (VAR_1 - BONITO_REGBASE) >> 2;",
"DPRINTF(\"FUNC_0 \"TARGET_FMT_plx\" VAR_2 %x saddr %x\\n\", VAR_1, VAR_2, saddr);",
"switch (saddr) {",
"case BONITO_BONPONCFG:\ncase BONITO_IODEVCFG:\ncase BONITO_SDCFG:\ncase BONITO_PCIMAP:\ncase BONITO_PCIMEMBASECFG:\ncase BONITO_PCIMAP_CFG:\ncase BONITO_GPIODATA:\ncase BONITO_GPIOIE:\ncase BONITO_INTEDGE:\ncase BONITO_INTSTEER:\ncase BONITO_INTPOL:\ncase BONITO_PCIMAIL0:\ncase BONITO_PCIMAIL1:\ncase BONITO_PCIMAIL2:\ncase BONITO_PCIMAIL3:\ncase BONITO_PCICACHECTRL:\ncase BONITO_PCICACHETAG:\ncase BONITO_PCIBADADDR:\ncase BONITO_PCIMSTAT:\ncase BONITO_TIMECFG:\ncase BONITO_CPUCFG:\ncase BONITO_DQCFG:\ncase BONITO_MEMSIZE:\ns->regs[saddr] = VAR_2;",
"break;",
"case BONITO_BONGENCFG:\nif (!(s->regs[saddr] & 0x04) && (VAR_2 & 0x04)) {",
"VAR_4 = 1;",
"}",
"s->regs[saddr] = VAR_2;",
"if (VAR_4) {",
"qemu_system_reset_request();",
"}",
"break;",
"case BONITO_INTENSET:\ns->regs[BONITO_INTENSET] = VAR_2;",
"s->regs[BONITO_INTEN] |= VAR_2;",
"break;",
"case BONITO_INTENCLR:\ns->regs[BONITO_INTENCLR] = VAR_2;",
"s->regs[BONITO_INTEN] &= ~VAR_2;",
"break;",
"case BONITO_INTEN:\ncase BONITO_INTISR:\nDPRINTF(\"write to readonly bonito register %x\\n\", saddr);",
"break;",
"default:\nDPRINTF(\"write to unknown bonito register %x\\n\", saddr);",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
]
]
|
16,625 | static int aacPlus_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
aacPlusAudioContext *s = avctx->priv_data;
int32_t *input_buffer = (int32_t *)frame->data[0];
int ret;
if ((ret = ff_alloc_packet2(avctx, pkt, s->max_output_bytes)))
return ret;
pkt->size = aacplusEncEncode(s->aacplus_handle, input_buffer,
s->samples_input, pkt->data, pkt->size);
*got_packet = 1;
pkt->pts = frame->pts;
return 0;
}
| false | FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | static int aacPlus_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
aacPlusAudioContext *s = avctx->priv_data;
int32_t *input_buffer = (int32_t *)frame->data[0];
int ret;
if ((ret = ff_alloc_packet2(avctx, pkt, s->max_output_bytes)))
return ret;
pkt->size = aacplusEncEncode(s->aacplus_handle, input_buffer,
s->samples_input, pkt->data, pkt->size);
*got_packet = 1;
pkt->pts = frame->pts;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
aacPlusAudioContext *s = VAR_0->priv_data;
int32_t *input_buffer = (int32_t *)VAR_2->data[0];
int VAR_4;
if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, s->max_output_bytes)))
return VAR_4;
VAR_1->size = aacplusEncEncode(s->aacplus_handle, input_buffer,
s->samples_input, VAR_1->data, VAR_1->size);
*VAR_3 = 1;
VAR_1->pts = VAR_2->pts;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"aacPlusAudioContext *s = VAR_0->priv_data;",
"int32_t *input_buffer = (int32_t *)VAR_2->data[0];",
"int VAR_4;",
"if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, s->max_output_bytes)))\nreturn VAR_4;",
"VAR_1->size = aacplusEncEncode(s->aacplus_handle, input_buffer,\ns->samples_input, VAR_1->data, VAR_1->size);",
"*VAR_3 = 1;",
"VAR_1->pts = VAR_2->pts;",
"return 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
]
]
|
16,626 | static void test_acpi_fadt_table(test_data *data)
{
AcpiFadtDescriptorRev1 *fadt_table = &data->fadt_table;
uint32_t addr;
/* FADT table comes first */
addr = data->rsdt_tables_addr[0];
ACPI_READ_TABLE_HEADER(fadt_table, addr);
ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
ACPI_READ_FIELD(fadt_table->dsdt, addr);
ACPI_READ_FIELD(fadt_table->model, addr);
ACPI_READ_FIELD(fadt_table->reserved1, addr);
ACPI_READ_FIELD(fadt_table->sci_int, addr);
ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
ACPI_READ_FIELD(fadt_table->reserved2, addr);
ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
ACPI_READ_FIELD(fadt_table->reserved3, addr);
ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
ACPI_READ_FIELD(fadt_table->flush_size, addr);
ACPI_READ_FIELD(fadt_table->flush_stride, addr);
ACPI_READ_FIELD(fadt_table->duty_offset, addr);
ACPI_READ_FIELD(fadt_table->duty_width, addr);
ACPI_READ_FIELD(fadt_table->day_alrm, addr);
ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
ACPI_READ_FIELD(fadt_table->century, addr);
ACPI_READ_FIELD(fadt_table->reserved4, addr);
ACPI_READ_FIELD(fadt_table->reserved4a, addr);
ACPI_READ_FIELD(fadt_table->reserved4b, addr);
ACPI_READ_FIELD(fadt_table->flags, addr);
ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
}
| false | qemu | 77af8a2b95b79699de650965d5228772743efe84 | static void test_acpi_fadt_table(test_data *data)
{
AcpiFadtDescriptorRev1 *fadt_table = &data->fadt_table;
uint32_t addr;
addr = data->rsdt_tables_addr[0];
ACPI_READ_TABLE_HEADER(fadt_table, addr);
ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
ACPI_READ_FIELD(fadt_table->dsdt, addr);
ACPI_READ_FIELD(fadt_table->model, addr);
ACPI_READ_FIELD(fadt_table->reserved1, addr);
ACPI_READ_FIELD(fadt_table->sci_int, addr);
ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
ACPI_READ_FIELD(fadt_table->reserved2, addr);
ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
ACPI_READ_FIELD(fadt_table->reserved3, addr);
ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
ACPI_READ_FIELD(fadt_table->flush_size, addr);
ACPI_READ_FIELD(fadt_table->flush_stride, addr);
ACPI_READ_FIELD(fadt_table->duty_offset, addr);
ACPI_READ_FIELD(fadt_table->duty_width, addr);
ACPI_READ_FIELD(fadt_table->day_alrm, addr);
ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
ACPI_READ_FIELD(fadt_table->century, addr);
ACPI_READ_FIELD(fadt_table->reserved4, addr);
ACPI_READ_FIELD(fadt_table->reserved4a, addr);
ACPI_READ_FIELD(fadt_table->reserved4b, addr);
ACPI_READ_FIELD(fadt_table->flags, addr);
ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(test_data *VAR_0)
{
AcpiFadtDescriptorRev1 *fadt_table = &VAR_0->fadt_table;
uint32_t addr;
addr = VAR_0->rsdt_tables_addr[0];
ACPI_READ_TABLE_HEADER(fadt_table, addr);
ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
ACPI_READ_FIELD(fadt_table->dsdt, addr);
ACPI_READ_FIELD(fadt_table->model, addr);
ACPI_READ_FIELD(fadt_table->reserved1, addr);
ACPI_READ_FIELD(fadt_table->sci_int, addr);
ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
ACPI_READ_FIELD(fadt_table->reserved2, addr);
ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
ACPI_READ_FIELD(fadt_table->reserved3, addr);
ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
ACPI_READ_FIELD(fadt_table->flush_size, addr);
ACPI_READ_FIELD(fadt_table->flush_stride, addr);
ACPI_READ_FIELD(fadt_table->duty_offset, addr);
ACPI_READ_FIELD(fadt_table->duty_width, addr);
ACPI_READ_FIELD(fadt_table->day_alrm, addr);
ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
ACPI_READ_FIELD(fadt_table->century, addr);
ACPI_READ_FIELD(fadt_table->reserved4, addr);
ACPI_READ_FIELD(fadt_table->reserved4a, addr);
ACPI_READ_FIELD(fadt_table->reserved4b, addr);
ACPI_READ_FIELD(fadt_table->flags, addr);
ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
}
| [
"static void FUNC_0(test_data *VAR_0)\n{",
"AcpiFadtDescriptorRev1 *fadt_table = &VAR_0->fadt_table;",
"uint32_t addr;",
"addr = VAR_0->rsdt_tables_addr[0];",
"ACPI_READ_TABLE_HEADER(fadt_table, addr);",
"ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);",
"ACPI_READ_FIELD(fadt_table->dsdt, addr);",
"ACPI_READ_FIELD(fadt_table->model, addr);",
"ACPI_READ_FIELD(fadt_table->reserved1, addr);",
"ACPI_READ_FIELD(fadt_table->sci_int, addr);",
"ACPI_READ_FIELD(fadt_table->smi_cmd, addr);",
"ACPI_READ_FIELD(fadt_table->acpi_enable, addr);",
"ACPI_READ_FIELD(fadt_table->acpi_disable, addr);",
"ACPI_READ_FIELD(fadt_table->S4bios_req, addr);",
"ACPI_READ_FIELD(fadt_table->reserved2, addr);",
"ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);",
"ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);",
"ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);",
"ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);",
"ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);",
"ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);",
"ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);",
"ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);",
"ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);",
"ACPI_READ_FIELD(fadt_table->gpe1_base, addr);",
"ACPI_READ_FIELD(fadt_table->reserved3, addr);",
"ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);",
"ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);",
"ACPI_READ_FIELD(fadt_table->flush_size, addr);",
"ACPI_READ_FIELD(fadt_table->flush_stride, addr);",
"ACPI_READ_FIELD(fadt_table->duty_offset, addr);",
"ACPI_READ_FIELD(fadt_table->duty_width, addr);",
"ACPI_READ_FIELD(fadt_table->day_alrm, addr);",
"ACPI_READ_FIELD(fadt_table->mon_alrm, addr);",
"ACPI_READ_FIELD(fadt_table->century, addr);",
"ACPI_READ_FIELD(fadt_table->reserved4, addr);",
"ACPI_READ_FIELD(fadt_table->reserved4a, addr);",
"ACPI_READ_FIELD(fadt_table->reserved4b, addr);",
"ACPI_READ_FIELD(fadt_table->flags, addr);",
"ACPI_ASSERT_CMP(fadt_table->signature, \"FACP\");",
"g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
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
],
[
99
],
[
101
],
[
103
]
]
|
16,627 | opts_end_list(Visitor *v)
{
OptsVisitor *ov = to_ov(v);
assert(ov->list_mode == LM_STARTED ||
ov->list_mode == LM_IN_PROGRESS ||
ov->list_mode == LM_SIGNED_INTERVAL ||
ov->list_mode == LM_UNSIGNED_INTERVAL);
ov->repeated_opts = NULL;
ov->list_mode = LM_NONE;
}
| false | qemu | d9f62dde1303286b24ac8ce88be27e2b9b9c5f46 | opts_end_list(Visitor *v)
{
OptsVisitor *ov = to_ov(v);
assert(ov->list_mode == LM_STARTED ||
ov->list_mode == LM_IN_PROGRESS ||
ov->list_mode == LM_SIGNED_INTERVAL ||
ov->list_mode == LM_UNSIGNED_INTERVAL);
ov->repeated_opts = NULL;
ov->list_mode = LM_NONE;
}
| {
"code": [],
"line_no": []
} | FUNC_0(Visitor *VAR_0)
{
OptsVisitor *ov = to_ov(VAR_0);
assert(ov->list_mode == LM_STARTED ||
ov->list_mode == LM_IN_PROGRESS ||
ov->list_mode == LM_SIGNED_INTERVAL ||
ov->list_mode == LM_UNSIGNED_INTERVAL);
ov->repeated_opts = NULL;
ov->list_mode = LM_NONE;
}
| [
"FUNC_0(Visitor *VAR_0)\n{",
"OptsVisitor *ov = to_ov(VAR_0);",
"assert(ov->list_mode == LM_STARTED ||\nov->list_mode == LM_IN_PROGRESS ||\nov->list_mode == LM_SIGNED_INTERVAL ||\nov->list_mode == LM_UNSIGNED_INTERVAL);",
"ov->repeated_opts = NULL;",
"ov->list_mode = LM_NONE;",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
]
]
|
16,629 | static void rate_start (SpiceRateCtl *rate)
{
memset (rate, 0, sizeof (*rate));
rate->start_ticks = qemu_get_clock (vm_clock);
}
| false | qemu | 74475455442398a64355428b37422d14ccc293cb | static void rate_start (SpiceRateCtl *rate)
{
memset (rate, 0, sizeof (*rate));
rate->start_ticks = qemu_get_clock (vm_clock);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (SpiceRateCtl *VAR_0)
{
memset (VAR_0, 0, sizeof (*VAR_0));
VAR_0->start_ticks = qemu_get_clock (vm_clock);
}
| [
"static void FUNC_0 (SpiceRateCtl *VAR_0)\n{",
"memset (VAR_0, 0, sizeof (*VAR_0));",
"VAR_0->start_ticks = qemu_get_clock (vm_clock);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
16,630 | void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
uint64_t param64)
{
CPUS390XState *env = &cpu->env;
if (env->ext_index == MAX_EXT_QUEUE - 1) {
/* ugh - can't queue anymore. Let's drop. */
return;
}
env->ext_index++;
assert(env->ext_index < MAX_EXT_QUEUE);
env->ext_queue[env->ext_index].code = code;
env->ext_queue[env->ext_index].param = param;
env->ext_queue[env->ext_index].param64 = param64;
env->pending_int |= INTERRUPT_EXT;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| false | qemu | 6482b0ffd12ce83810c10b1a3884a75eba2ade1a | void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
uint64_t param64)
{
CPUS390XState *env = &cpu->env;
if (env->ext_index == MAX_EXT_QUEUE - 1) {
return;
}
env->ext_index++;
assert(env->ext_index < MAX_EXT_QUEUE);
env->ext_queue[env->ext_index].code = code;
env->ext_queue[env->ext_index].param = param;
env->ext_queue[env->ext_index].param64 = param64;
env->pending_int |= INTERRUPT_EXT;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(S390CPU *VAR_0, uint32_t VAR_1, uint32_t VAR_2,
uint64_t VAR_3)
{
CPUS390XState *env = &VAR_0->env;
if (env->ext_index == MAX_EXT_QUEUE - 1) {
return;
}
env->ext_index++;
assert(env->ext_index < MAX_EXT_QUEUE);
env->ext_queue[env->ext_index].VAR_1 = VAR_1;
env->ext_queue[env->ext_index].VAR_2 = VAR_2;
env->ext_queue[env->ext_index].VAR_3 = VAR_3;
env->pending_int |= INTERRUPT_EXT;
cpu_interrupt(CPU(VAR_0), CPU_INTERRUPT_HARD);
}
| [
"void FUNC_0(S390CPU *VAR_0, uint32_t VAR_1, uint32_t VAR_2,\nuint64_t VAR_3)\n{",
"CPUS390XState *env = &VAR_0->env;",
"if (env->ext_index == MAX_EXT_QUEUE - 1) {",
"return;",
"}",
"env->ext_index++;",
"assert(env->ext_index < MAX_EXT_QUEUE);",
"env->ext_queue[env->ext_index].VAR_1 = VAR_1;",
"env->ext_queue[env->ext_index].VAR_2 = VAR_2;",
"env->ext_queue[env->ext_index].VAR_3 = VAR_3;",
"env->pending_int |= INTERRUPT_EXT;",
"cpu_interrupt(CPU(VAR_0), CPU_INTERRUPT_HARD);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
]
]
|
16,631 | static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSerial *vser = VIRTIO_SERIAL(dev);
uint32_t i, max_supported_ports;
if (!vser->serial.max_virtserial_ports) {
error_setg(errp, "Maximum number of serial ports not specified");
return;
}
/* Each port takes 2 queues, and one pair is for the control queue */
max_supported_ports = VIRTIO_QUEUE_MAX / 2 - 1;
if (vser->serial.max_virtserial_ports > max_supported_ports) {
error_setg(errp, "maximum ports supported: %u", max_supported_ports);
return;
}
/* We don't support emergency write, skip it for now. */
/* TODO: cleaner fix, depending on host features. */
virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
offsetof(struct virtio_console_config, emerg_wr));
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
dev, vdev->bus_name);
qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), errp);
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
vser->ovqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
/* Add a queue for guest to host transfers for port 0 (backward compat) */
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
/* TODO: host to guest notifications can get dropped
* if the queue fills up. Implement queueing in host,
* this might also make it possible to reduce the control
* queue size: as guest preposts buffers there,
* this will save 4Kbyte of guest memory per entry. */
/* control queue: host to guest */
vser->c_ivq = virtio_add_queue(vdev, 32, control_in);
/* control queue: guest to host */
vser->c_ovq = virtio_add_queue(vdev, 32, control_out);
for (i = 1; i < vser->bus.max_nr_ports; i++) {
/* Add a per-port queue for host to guest transfers */
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
/* Add a per-per queue for guest to host transfers */
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
/*
* Reserve location 0 for a console port for backward compat
* (old kernel, new qemu)
*/
mark_port_added(vser, 0);
vser->post_load = NULL;
QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
}
| false | qemu | a06b1dae4706fccb9394b35e88d1905dabec85e7 | static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSerial *vser = VIRTIO_SERIAL(dev);
uint32_t i, max_supported_ports;
if (!vser->serial.max_virtserial_ports) {
error_setg(errp, "Maximum number of serial ports not specified");
return;
}
max_supported_ports = VIRTIO_QUEUE_MAX / 2 - 1;
if (vser->serial.max_virtserial_ports > max_supported_ports) {
error_setg(errp, "maximum ports supported: %u", max_supported_ports);
return;
}
virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
offsetof(struct virtio_console_config, emerg_wr));
qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
dev, vdev->bus_name);
qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), errp);
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
vser->ovqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
vser->c_ivq = virtio_add_queue(vdev, 32, control_in);
vser->c_ovq = virtio_add_queue(vdev, 32, control_out);
for (i = 1; i < vser->bus.max_nr_ports; i++) {
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
mark_port_added(vser, 0);
vser->post_load = NULL;
QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VirtIOSerial *vser = VIRTIO_SERIAL(VAR_0);
uint32_t i, max_supported_ports;
if (!vser->serial.max_virtserial_ports) {
error_setg(VAR_1, "Maximum number of serial ports not specified");
return;
}
max_supported_ports = VIRTIO_QUEUE_MAX / 2 - 1;
if (vser->serial.max_virtserial_ports > max_supported_ports) {
error_setg(VAR_1, "maximum ports supported: %u", max_supported_ports);
return;
}
virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
offsetof(struct virtio_console_config, emerg_wr));
qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
VAR_0, vdev->bus_name);
qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), VAR_1);
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
vser->ovqs = g_malloc(vser->serial.max_virtserial_ports
* sizeof(VirtQueue *));
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
vser->c_ivq = virtio_add_queue(vdev, 32, control_in);
vser->c_ovq = virtio_add_queue(vdev, 32, control_out);
for (i = 1; i < vser->bus.max_nr_ports; i++) {
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
mark_port_added(vser, 0);
vser->post_load = NULL;
QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VirtIOSerial *vser = VIRTIO_SERIAL(VAR_0);",
"uint32_t i, max_supported_ports;",
"if (!vser->serial.max_virtserial_ports) {",
"error_setg(VAR_1, \"Maximum number of serial ports not specified\");",
"return;",
"}",
"max_supported_ports = VIRTIO_QUEUE_MAX / 2 - 1;",
"if (vser->serial.max_virtserial_ports > max_supported_ports) {",
"error_setg(VAR_1, \"maximum ports supported: %u\", max_supported_ports);",
"return;",
"}",
"virtio_init(vdev, \"virtio-serial\", VIRTIO_ID_CONSOLE,\noffsetof(struct virtio_console_config, emerg_wr));",
"qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,\nVAR_0, vdev->bus_name);",
"qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), VAR_1);",
"vser->bus.vser = vser;",
"QTAILQ_INIT(&vser->ports);",
"vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;",
"vser->ivqs = g_malloc(vser->serial.max_virtserial_ports\n* sizeof(VirtQueue *));",
"vser->ovqs = g_malloc(vser->serial.max_virtserial_ports\n* sizeof(VirtQueue *));",
"vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);",
"vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);",
"vser->c_ivq = virtio_add_queue(vdev, 32, control_in);",
"vser->c_ovq = virtio_add_queue(vdev, 32, control_out);",
"for (i = 1; i < vser->bus.max_nr_ports; i++) {",
"vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);",
"vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);",
"}",
"vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)\n* sizeof(vser->ports_map[0]));",
"mark_port_added(vser, 0);",
"vser->post_load = NULL;",
"QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43,
45
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69,
71
],
[
77
],
[
81
],
[
99
],
[
103
],
[
107
],
[
111
],
[
115
],
[
117
],
[
121,
123
],
[
133
],
[
137
],
[
141
],
[
143
]
]
|
16,632 | void object_property_set_qobject(Object *obj, QObject *value,
const char *name, Error **errp)
{
Visitor *v;
/* TODO: Should we reject, rather than ignore, excess input? */
v = qmp_input_visitor_new(value, false);
object_property_set(obj, v, name, errp);
visit_free(v);
}
| false | qemu | 09e68369a88d7de0f988972bf28eec1b80cc47f9 | void object_property_set_qobject(Object *obj, QObject *value,
const char *name, Error **errp)
{
Visitor *v;
v = qmp_input_visitor_new(value, false);
object_property_set(obj, v, name, errp);
visit_free(v);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Object *VAR_0, QObject *VAR_1,
const char *VAR_2, Error **VAR_3)
{
Visitor *v;
v = qmp_input_visitor_new(VAR_1, false);
object_property_set(VAR_0, v, VAR_2, VAR_3);
visit_free(v);
}
| [
"void FUNC_0(Object *VAR_0, QObject *VAR_1,\nconst char *VAR_2, Error **VAR_3)\n{",
"Visitor *v;",
"v = qmp_input_visitor_new(VAR_1, false);",
"object_property_set(VAR_0, v, VAR_2, VAR_3);",
"visit_free(v);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
16,634 | static uint32_t pci_apb_ioreadb (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = cpu_inb(addr & IOPORTS_MASK);
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t pci_apb_ioreadb (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = cpu_inb(addr & IOPORTS_MASK);
return val;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = cpu_inb(addr & IOPORTS_MASK);
return val;
}
| [
"static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)\n{",
"uint32_t val;",
"val = cpu_inb(addr & IOPORTS_MASK);",
"return val;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
16,635 | static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);
remove_migration_state_change_notifier(&s->migration_state_notifier);
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
qemu_del_vm_change_state_handler(s->change);
unregister_savevm(dev, "virtio-blk", s);
blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);
remove_migration_state_change_notifier(&s->migration_state_notifier);
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
qemu_del_vm_change_state_handler(s->change);
unregister_savevm(dev, "virtio-blk", s);
blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VirtIOBlock *s = VIRTIO_BLK(VAR_0);
remove_migration_state_change_notifier(&s->migration_state_notifier);
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
qemu_del_vm_change_state_handler(s->change);
unregister_savevm(VAR_0, "virtio-blk", s);
blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VirtIOBlock *s = VIRTIO_BLK(VAR_0);",
"remove_migration_state_change_notifier(&s->migration_state_notifier);",
"virtio_blk_data_plane_destroy(s->dataplane);",
"s->dataplane = NULL;",
"qemu_del_vm_change_state_handler(s->change);",
"unregister_savevm(VAR_0, \"virtio-blk\", s);",
"blockdev_mark_auto_del(s->bs);",
"virtio_cleanup(vdev);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
16,636 | static int exif_decode_tag(AVCodecContext *avctx, GetByteContext *gbytes, int le,
int depth, AVDictionary **metadata)
{
int ret, cur_pos;
unsigned id, count;
enum TiffTypes type;
if (depth > 2) {
return 0;
}
ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos);
if (!bytestream2_tell(gbytes)) {
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return 0;
}
// read count values and add it metadata
// store metadata or proceed with next IFD
ret = ff_tis_ifd(id);
if (ret) {
ret = avpriv_exif_decode_ifd(avctx, gbytes, le, depth + 1, metadata);
} else {
const char *name = exif_get_tag_name(id);
char *use_name = (char*) name;
if (!use_name) {
use_name = av_malloc(7);
if (!use_name) {
return AVERROR(ENOMEM);
}
snprintf(use_name, 7, "0x%04X", id);
}
ret = exif_add_metadata(avctx, count, type, use_name, NULL,
gbytes, le, metadata);
if (!name) {
av_freep(&use_name);
}
}
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return ret;
}
| false | FFmpeg | ce87711df563a9d2d0537a062b86bb91b15ea1a0 | static int exif_decode_tag(AVCodecContext *avctx, GetByteContext *gbytes, int le,
int depth, AVDictionary **metadata)
{
int ret, cur_pos;
unsigned id, count;
enum TiffTypes type;
if (depth > 2) {
return 0;
}
ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos);
if (!bytestream2_tell(gbytes)) {
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return 0;
}
ret = ff_tis_ifd(id);
if (ret) {
ret = avpriv_exif_decode_ifd(avctx, gbytes, le, depth + 1, metadata);
} else {
const char *name = exif_get_tag_name(id);
char *use_name = (char*) name;
if (!use_name) {
use_name = av_malloc(7);
if (!use_name) {
return AVERROR(ENOMEM);
}
snprintf(use_name, 7, "0x%04X", id);
}
ret = exif_add_metadata(avctx, count, type, use_name, NULL,
gbytes, le, metadata);
if (!name) {
av_freep(&use_name);
}
}
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1, int VAR_2,
int VAR_3, AVDictionary **VAR_4)
{
int VAR_5, VAR_6;
unsigned VAR_7, VAR_8;
enum TiffTypes VAR_9;
if (VAR_3 > 2) {
return 0;
}
ff_tread_tag(VAR_1, VAR_2, &VAR_7, &VAR_9, &VAR_8, &VAR_6);
if (!bytestream2_tell(VAR_1)) {
bytestream2_seek(VAR_1, VAR_6, SEEK_SET);
return 0;
}
VAR_5 = ff_tis_ifd(VAR_7);
if (VAR_5) {
VAR_5 = avpriv_exif_decode_ifd(VAR_0, VAR_1, VAR_2, VAR_3 + 1, VAR_4);
} else {
const char *VAR_10 = exif_get_tag_name(VAR_7);
char *VAR_11 = (char*) VAR_10;
if (!VAR_11) {
VAR_11 = av_malloc(7);
if (!VAR_11) {
return AVERROR(ENOMEM);
}
snprintf(VAR_11, 7, "0x%04X", VAR_7);
}
VAR_5 = exif_add_metadata(VAR_0, VAR_8, VAR_9, VAR_11, NULL,
VAR_1, VAR_2, VAR_4);
if (!VAR_10) {
av_freep(&VAR_11);
}
}
bytestream2_seek(VAR_1, VAR_6, SEEK_SET);
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1, int VAR_2,\nint VAR_3, AVDictionary **VAR_4)\n{",
"int VAR_5, VAR_6;",
"unsigned VAR_7, VAR_8;",
"enum TiffTypes VAR_9;",
"if (VAR_3 > 2) {",
"return 0;",
"}",
"ff_tread_tag(VAR_1, VAR_2, &VAR_7, &VAR_9, &VAR_8, &VAR_6);",
"if (!bytestream2_tell(VAR_1)) {",
"bytestream2_seek(VAR_1, VAR_6, SEEK_SET);",
"return 0;",
"}",
"VAR_5 = ff_tis_ifd(VAR_7);",
"if (VAR_5) {",
"VAR_5 = avpriv_exif_decode_ifd(VAR_0, VAR_1, VAR_2, VAR_3 + 1, VAR_4);",
"} else {",
"const char *VAR_10 = exif_get_tag_name(VAR_7);",
"char *VAR_11 = (char*) VAR_10;",
"if (!VAR_11) {",
"VAR_11 = av_malloc(7);",
"if (!VAR_11) {",
"return AVERROR(ENOMEM);",
"}",
"snprintf(VAR_11, 7, \"0x%04X\", VAR_7);",
"}",
"VAR_5 = exif_add_metadata(VAR_0, VAR_8, VAR_9, VAR_11, NULL,\nVAR_1, VAR_2, VAR_4);",
"if (!VAR_10) {",
"av_freep(&VAR_11);",
"}",
"}",
"bytestream2_seek(VAR_1, VAR_6, SEEK_SET);",
"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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
]
]
|
16,637 | static int setup_sigcontext(struct target_sigcontext *sc, CPUAlphaState *env,
abi_ulong frame_addr, target_sigset_t *set)
{
int i, err = 0;
__put_user(on_sig_stack(frame_addr), &sc->sc_onstack);
__put_user(set->sig[0], &sc->sc_mask);
__put_user(env->pc, &sc->sc_pc);
__put_user(8, &sc->sc_ps);
for (i = 0; i < 31; ++i) {
__put_user(env->ir[i], &sc->sc_regs[i]);
}
__put_user(0, &sc->sc_regs[31]);
for (i = 0; i < 31; ++i) {
__put_user(env->fir[i], &sc->sc_fpregs[i]);
}
__put_user(0, &sc->sc_fpregs[31]);
__put_user(cpu_alpha_load_fpcr(env), &sc->sc_fpcr);
__put_user(0, &sc->sc_traparg_a0); /* FIXME */
__put_user(0, &sc->sc_traparg_a1); /* FIXME */
__put_user(0, &sc->sc_traparg_a2); /* FIXME */
return err;
}
| false | qemu | 41ecc72ba5932381208e151bf2d2149a0342beff | static int setup_sigcontext(struct target_sigcontext *sc, CPUAlphaState *env,
abi_ulong frame_addr, target_sigset_t *set)
{
int i, err = 0;
__put_user(on_sig_stack(frame_addr), &sc->sc_onstack);
__put_user(set->sig[0], &sc->sc_mask);
__put_user(env->pc, &sc->sc_pc);
__put_user(8, &sc->sc_ps);
for (i = 0; i < 31; ++i) {
__put_user(env->ir[i], &sc->sc_regs[i]);
}
__put_user(0, &sc->sc_regs[31]);
for (i = 0; i < 31; ++i) {
__put_user(env->fir[i], &sc->sc_fpregs[i]);
}
__put_user(0, &sc->sc_fpregs[31]);
__put_user(cpu_alpha_load_fpcr(env), &sc->sc_fpcr);
__put_user(0, &sc->sc_traparg_a0);
__put_user(0, &sc->sc_traparg_a1);
__put_user(0, &sc->sc_traparg_a2);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct target_sigcontext *VAR_0, CPUAlphaState *VAR_1,
abi_ulong VAR_2, target_sigset_t *VAR_3)
{
int VAR_4, VAR_5 = 0;
__put_user(on_sig_stack(VAR_2), &VAR_0->sc_onstack);
__put_user(VAR_3->sig[0], &VAR_0->sc_mask);
__put_user(VAR_1->pc, &VAR_0->sc_pc);
__put_user(8, &VAR_0->sc_ps);
for (VAR_4 = 0; VAR_4 < 31; ++VAR_4) {
__put_user(VAR_1->ir[VAR_4], &VAR_0->sc_regs[VAR_4]);
}
__put_user(0, &VAR_0->sc_regs[31]);
for (VAR_4 = 0; VAR_4 < 31; ++VAR_4) {
__put_user(VAR_1->fir[VAR_4], &VAR_0->sc_fpregs[VAR_4]);
}
__put_user(0, &VAR_0->sc_fpregs[31]);
__put_user(cpu_alpha_load_fpcr(VAR_1), &VAR_0->sc_fpcr);
__put_user(0, &VAR_0->sc_traparg_a0);
__put_user(0, &VAR_0->sc_traparg_a1);
__put_user(0, &VAR_0->sc_traparg_a2);
return VAR_5;
}
| [
"static int FUNC_0(struct target_sigcontext *VAR_0, CPUAlphaState *VAR_1,\nabi_ulong VAR_2, target_sigset_t *VAR_3)\n{",
"int VAR_4, VAR_5 = 0;",
"__put_user(on_sig_stack(VAR_2), &VAR_0->sc_onstack);",
"__put_user(VAR_3->sig[0], &VAR_0->sc_mask);",
"__put_user(VAR_1->pc, &VAR_0->sc_pc);",
"__put_user(8, &VAR_0->sc_ps);",
"for (VAR_4 = 0; VAR_4 < 31; ++VAR_4) {",
"__put_user(VAR_1->ir[VAR_4], &VAR_0->sc_regs[VAR_4]);",
"}",
"__put_user(0, &VAR_0->sc_regs[31]);",
"for (VAR_4 = 0; VAR_4 < 31; ++VAR_4) {",
"__put_user(VAR_1->fir[VAR_4], &VAR_0->sc_fpregs[VAR_4]);",
"}",
"__put_user(0, &VAR_0->sc_fpregs[31]);",
"__put_user(cpu_alpha_load_fpcr(VAR_1), &VAR_0->sc_fpcr);",
"__put_user(0, &VAR_0->sc_traparg_a0);",
"__put_user(0, &VAR_0->sc_traparg_a1);",
"__put_user(0, &VAR_0->sc_traparg_a2);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
]
|
16,638 | static const char *full_name(QObjectInputVisitor *qiv, const char *name)
{
StackObject *so;
char buf[32];
if (qiv->errname) {
g_string_truncate(qiv->errname, 0);
} else {
qiv->errname = g_string_new("");
}
QSLIST_FOREACH(so , &qiv->stack, node) {
if (qobject_type(so->obj) == QTYPE_QDICT) {
g_string_prepend(qiv->errname, name);
g_string_prepend_c(qiv->errname, '.');
} else {
snprintf(buf, sizeof(buf), "[%u]", so->index);
g_string_prepend(qiv->errname, buf);
}
name = so->name;
}
if (name) {
g_string_prepend(qiv->errname, name);
} else if (qiv->errname->str[0] == '.') {
g_string_erase(qiv->errname, 0, 1);
} else {
return "<anonymous>";
}
return qiv->errname->str;
}
| false | qemu | a4a1c70dc759e5b81627e96564f344ab43ea86eb | static const char *full_name(QObjectInputVisitor *qiv, const char *name)
{
StackObject *so;
char buf[32];
if (qiv->errname) {
g_string_truncate(qiv->errname, 0);
} else {
qiv->errname = g_string_new("");
}
QSLIST_FOREACH(so , &qiv->stack, node) {
if (qobject_type(so->obj) == QTYPE_QDICT) {
g_string_prepend(qiv->errname, name);
g_string_prepend_c(qiv->errname, '.');
} else {
snprintf(buf, sizeof(buf), "[%u]", so->index);
g_string_prepend(qiv->errname, buf);
}
name = so->name;
}
if (name) {
g_string_prepend(qiv->errname, name);
} else if (qiv->errname->str[0] == '.') {
g_string_erase(qiv->errname, 0, 1);
} else {
return "<anonymous>";
}
return qiv->errname->str;
}
| {
"code": [],
"line_no": []
} | static const char *FUNC_0(QObjectInputVisitor *VAR_0, const char *VAR_1)
{
StackObject *so;
char VAR_2[32];
if (VAR_0->errname) {
g_string_truncate(VAR_0->errname, 0);
} else {
VAR_0->errname = g_string_new("");
}
QSLIST_FOREACH(so , &VAR_0->stack, node) {
if (qobject_type(so->obj) == QTYPE_QDICT) {
g_string_prepend(VAR_0->errname, VAR_1);
g_string_prepend_c(VAR_0->errname, '.');
} else {
snprintf(VAR_2, sizeof(VAR_2), "[%u]", so->index);
g_string_prepend(VAR_0->errname, VAR_2);
}
VAR_1 = so->VAR_1;
}
if (VAR_1) {
g_string_prepend(VAR_0->errname, VAR_1);
} else if (VAR_0->errname->str[0] == '.') {
g_string_erase(VAR_0->errname, 0, 1);
} else {
return "<anonymous>";
}
return VAR_0->errname->str;
}
| [
"static const char *FUNC_0(QObjectInputVisitor *VAR_0, const char *VAR_1)\n{",
"StackObject *so;",
"char VAR_2[32];",
"if (VAR_0->errname) {",
"g_string_truncate(VAR_0->errname, 0);",
"} else {",
"VAR_0->errname = g_string_new(\"\");",
"}",
"QSLIST_FOREACH(so , &VAR_0->stack, node) {",
"if (qobject_type(so->obj) == QTYPE_QDICT) {",
"g_string_prepend(VAR_0->errname, VAR_1);",
"g_string_prepend_c(VAR_0->errname, '.');",
"} else {",
"snprintf(VAR_2, sizeof(VAR_2), \"[%u]\", so->index);",
"g_string_prepend(VAR_0->errname, VAR_2);",
"}",
"VAR_1 = so->VAR_1;",
"}",
"if (VAR_1) {",
"g_string_prepend(VAR_0->errname, VAR_1);",
"} else if (VAR_0->errname->str[0] == '.') {",
"g_string_erase(VAR_0->errname, 0, 1);",
"} else {",
"return \"<anonymous>\";",
"}",
"return VAR_0->errname->str;",
"}"
]
| [
0,
0,
0,
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
]
|
16,639 | static void tcg_out_tlb_read (TCGContext *s, int r0, int r1, int r2,
int addr_reg, int s_bits, int offset)
{
#ifdef TARGET_LONG_BITS
tcg_out_rld (s, RLDICL, addr_reg, addr_reg, 0, 32);
tcg_out32 (s, (RLWINM
| RA (r0)
| RS (addr_reg)
| SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS))
| MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS))
| ME (31 - CPU_TLB_ENTRY_BITS)
)
);
tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (TCG_AREG0));
tcg_out32 (s, (LWZU | RT (r1) | RA (r0) | offset));
tcg_out32 (s, (RLWINM
| RA (r2)
| RS (addr_reg)
| SH (0)
| MB ((32 - s_bits) & 31)
| ME (31 - TARGET_PAGE_BITS)
)
);
#else
tcg_out_rld (s, RLDICL, r0, addr_reg,
64 - TARGET_PAGE_BITS,
64 - CPU_TLB_BITS);
tcg_out_rld (s, RLDICR, r0, r0,
CPU_TLB_ENTRY_BITS,
63 - CPU_TLB_ENTRY_BITS);
tcg_out32 (s, ADD | TAB (r0, r0, TCG_AREG0));
tcg_out32 (s, LD_ADDR | RT (r1) | RA (r0) | offset);
if (!s_bits) {
tcg_out_rld (s, RLDICR, r2, addr_reg, 0, 63 - TARGET_PAGE_BITS);
}
else {
tcg_out_rld (s, RLDICL, r2, addr_reg,
64 - TARGET_PAGE_BITS,
TARGET_PAGE_BITS - s_bits);
tcg_out_rld (s, RLDICL, r2, r2, TARGET_PAGE_BITS, 0);
}
#endif
}
| false | qemu | 880e52b8b037d5878c1120a15b45ebf6ac690d31 | static void tcg_out_tlb_read (TCGContext *s, int r0, int r1, int r2,
int addr_reg, int s_bits, int offset)
{
#ifdef TARGET_LONG_BITS
tcg_out_rld (s, RLDICL, addr_reg, addr_reg, 0, 32);
tcg_out32 (s, (RLWINM
| RA (r0)
| RS (addr_reg)
| SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS))
| MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS))
| ME (31 - CPU_TLB_ENTRY_BITS)
)
);
tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (TCG_AREG0));
tcg_out32 (s, (LWZU | RT (r1) | RA (r0) | offset));
tcg_out32 (s, (RLWINM
| RA (r2)
| RS (addr_reg)
| SH (0)
| MB ((32 - s_bits) & 31)
| ME (31 - TARGET_PAGE_BITS)
)
);
#else
tcg_out_rld (s, RLDICL, r0, addr_reg,
64 - TARGET_PAGE_BITS,
64 - CPU_TLB_BITS);
tcg_out_rld (s, RLDICR, r0, r0,
CPU_TLB_ENTRY_BITS,
63 - CPU_TLB_ENTRY_BITS);
tcg_out32 (s, ADD | TAB (r0, r0, TCG_AREG0));
tcg_out32 (s, LD_ADDR | RT (r1) | RA (r0) | offset);
if (!s_bits) {
tcg_out_rld (s, RLDICR, r2, addr_reg, 0, 63 - TARGET_PAGE_BITS);
}
else {
tcg_out_rld (s, RLDICL, r2, addr_reg,
64 - TARGET_PAGE_BITS,
TARGET_PAGE_BITS - s_bits);
tcg_out_rld (s, RLDICL, r2, r2, TARGET_PAGE_BITS, 0);
}
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (TCGContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
#ifdef TARGET_LONG_BITS
tcg_out_rld (VAR_0, RLDICL, VAR_4, VAR_4, 0, 32);
tcg_out32 (VAR_0, (RLWINM
| RA (VAR_1)
| RS (VAR_4)
| SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS))
| MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS))
| ME (31 - CPU_TLB_ENTRY_BITS)
)
);
tcg_out32 (VAR_0, ADD | RT (VAR_1) | RA (VAR_1) | RB (TCG_AREG0));
tcg_out32 (VAR_0, (LWZU | RT (VAR_2) | RA (VAR_1) | VAR_6));
tcg_out32 (VAR_0, (RLWINM
| RA (VAR_3)
| RS (VAR_4)
| SH (0)
| MB ((32 - VAR_5) & 31)
| ME (31 - TARGET_PAGE_BITS)
)
);
#else
tcg_out_rld (VAR_0, RLDICL, VAR_1, VAR_4,
64 - TARGET_PAGE_BITS,
64 - CPU_TLB_BITS);
tcg_out_rld (VAR_0, RLDICR, VAR_1, VAR_1,
CPU_TLB_ENTRY_BITS,
63 - CPU_TLB_ENTRY_BITS);
tcg_out32 (VAR_0, ADD | TAB (VAR_1, VAR_1, TCG_AREG0));
tcg_out32 (VAR_0, LD_ADDR | RT (VAR_2) | RA (VAR_1) | VAR_6);
if (!VAR_5) {
tcg_out_rld (VAR_0, RLDICR, VAR_3, VAR_4, 0, 63 - TARGET_PAGE_BITS);
}
else {
tcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_4,
64 - TARGET_PAGE_BITS,
TARGET_PAGE_BITS - VAR_5);
tcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_3, TARGET_PAGE_BITS, 0);
}
#endif
}
| [
"static void FUNC_0 (TCGContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"#ifdef TARGET_LONG_BITS\ntcg_out_rld (VAR_0, RLDICL, VAR_4, VAR_4, 0, 32);",
"tcg_out32 (VAR_0, (RLWINM\n| RA (VAR_1)\n| RS (VAR_4)\n| SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS))\n| MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS))\n| ME (31 - CPU_TLB_ENTRY_BITS)\n)\n);",
"tcg_out32 (VAR_0, ADD | RT (VAR_1) | RA (VAR_1) | RB (TCG_AREG0));",
"tcg_out32 (VAR_0, (LWZU | RT (VAR_2) | RA (VAR_1) | VAR_6));",
"tcg_out32 (VAR_0, (RLWINM\n| RA (VAR_3)\n| RS (VAR_4)\n| SH (0)\n| MB ((32 - VAR_5) & 31)\n| ME (31 - TARGET_PAGE_BITS)\n)\n);",
"#else\ntcg_out_rld (VAR_0, RLDICL, VAR_1, VAR_4,\n64 - TARGET_PAGE_BITS,\n64 - CPU_TLB_BITS);",
"tcg_out_rld (VAR_0, RLDICR, VAR_1, VAR_1,\nCPU_TLB_ENTRY_BITS,\n63 - CPU_TLB_ENTRY_BITS);",
"tcg_out32 (VAR_0, ADD | TAB (VAR_1, VAR_1, TCG_AREG0));",
"tcg_out32 (VAR_0, LD_ADDR | RT (VAR_2) | RA (VAR_1) | VAR_6);",
"if (!VAR_5) {",
"tcg_out_rld (VAR_0, RLDICR, VAR_3, VAR_4, 0, 63 - TARGET_PAGE_BITS);",
"}",
"else {",
"tcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_4,\n64 - TARGET_PAGE_BITS,\nTARGET_PAGE_BITS - VAR_5);",
"tcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_3, TARGET_PAGE_BITS, 0);",
"}",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
13,
15,
17,
19,
21,
23,
25,
27
],
[
29
],
[
31
],
[
33,
35,
37,
39,
41,
43,
45,
47
],
[
49,
51,
53,
55
],
[
57,
59,
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81,
83
],
[
85
],
[
87
],
[
89,
91
]
]
|
16,640 | float32 HELPER(ucf64_si2sf)(float32 x, CPUUniCore32State *env)
{
return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);
}
| false | qemu | e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe | float32 HELPER(ucf64_si2sf)(float32 x, CPUUniCore32State *env)
{
return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0(ucf64_si2sf)(float32 x, CPUUniCore32State *env)
{
return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);
}
| [
"float32 FUNC_0(ucf64_si2sf)(float32 x, CPUUniCore32State *env)\n{",
"return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
16,641 | static void v7m_push_stack(ARMCPU *cpu)
{
/* Do the "set up stack frame" part of exception entry,
* similar to pseudocode PushStack().
*/
CPUARMState *env = &cpu->env;
uint32_t xpsr = xpsr_read(env);
/* Align stack pointer if the guest wants that */
if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {
env->regs[13] -= 4;
xpsr |= XPSR_SPREALIGN;
}
/* Switch to the handler mode. */
v7m_push(env, xpsr);
v7m_push(env, env->regs[15]);
v7m_push(env, env->regs[14]);
v7m_push(env, env->regs[12]);
v7m_push(env, env->regs[3]);
v7m_push(env, env->regs[2]);
v7m_push(env, env->regs[1]);
v7m_push(env, env->regs[0]);
}
| false | qemu | 9d40cd8a68cfc7606f4548cc9e812bab15c6dc28 | static void v7m_push_stack(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
uint32_t xpsr = xpsr_read(env);
if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {
env->regs[13] -= 4;
xpsr |= XPSR_SPREALIGN;
}
v7m_push(env, xpsr);
v7m_push(env, env->regs[15]);
v7m_push(env, env->regs[14]);
v7m_push(env, env->regs[12]);
v7m_push(env, env->regs[3]);
v7m_push(env, env->regs[2]);
v7m_push(env, env->regs[1]);
v7m_push(env, env->regs[0]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ARMCPU *VAR_0)
{
CPUARMState *env = &VAR_0->env;
uint32_t xpsr = xpsr_read(env);
if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {
env->regs[13] -= 4;
xpsr |= XPSR_SPREALIGN;
}
v7m_push(env, xpsr);
v7m_push(env, env->regs[15]);
v7m_push(env, env->regs[14]);
v7m_push(env, env->regs[12]);
v7m_push(env, env->regs[3]);
v7m_push(env, env->regs[2]);
v7m_push(env, env->regs[1]);
v7m_push(env, env->regs[0]);
}
| [
"static void FUNC_0(ARMCPU *VAR_0)\n{",
"CPUARMState *env = &VAR_0->env;",
"uint32_t xpsr = xpsr_read(env);",
"if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {",
"env->regs[13] -= 4;",
"xpsr |= XPSR_SPREALIGN;",
"}",
"v7m_push(env, xpsr);",
"v7m_push(env, env->regs[15]);",
"v7m_push(env, env->regs[14]);",
"v7m_push(env, env->regs[12]);",
"v7m_push(env, env->regs[3]);",
"v7m_push(env, env->regs[2]);",
"v7m_push(env, env->regs[1]);",
"v7m_push(env, env->regs[0]);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
]
|
16,642 | int bdrv_attach(BlockDriverState *bs, DeviceState *qdev)
{
if (bs->peer) {
return -EBUSY;
}
bs->peer = qdev;
return 0;
}
| false | qemu | fa879d62eb51253d00b6920ce1d1d9d261370a49 | int bdrv_attach(BlockDriverState *bs, DeviceState *qdev)
{
if (bs->peer) {
return -EBUSY;
}
bs->peer = qdev;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, DeviceState *VAR_1)
{
if (VAR_0->peer) {
return -EBUSY;
}
VAR_0->peer = VAR_1;
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, DeviceState *VAR_1)\n{",
"if (VAR_0->peer) {",
"return -EBUSY;",
"}",
"VAR_0->peer = VAR_1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
16,643 | static void vnc_init_timer(VncDisplay *vd)
{
vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
vd->timer = qemu_new_timer(rt_clock, vnc_refresh, vd);
vnc_dpy_resize(vd->ds);
vnc_refresh(vd);
}
}
| false | qemu | 7bd427d801e1e3293a634d3c83beadaa90ffb911 | static void vnc_init_timer(VncDisplay *vd)
{
vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
vd->timer = qemu_new_timer(rt_clock, vnc_refresh, vd);
vnc_dpy_resize(vd->ds);
vnc_refresh(vd);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VncDisplay *VAR_0)
{
VAR_0->timer_interval = VNC_REFRESH_INTERVAL_BASE;
if (VAR_0->timer == NULL && !QTAILQ_EMPTY(&VAR_0->clients)) {
VAR_0->timer = qemu_new_timer(rt_clock, vnc_refresh, VAR_0);
vnc_dpy_resize(VAR_0->ds);
vnc_refresh(VAR_0);
}
}
| [
"static void FUNC_0(VncDisplay *VAR_0)\n{",
"VAR_0->timer_interval = VNC_REFRESH_INTERVAL_BASE;",
"if (VAR_0->timer == NULL && !QTAILQ_EMPTY(&VAR_0->clients)) {",
"VAR_0->timer = qemu_new_timer(rt_clock, vnc_refresh, VAR_0);",
"vnc_dpy_resize(VAR_0->ds);",
"vnc_refresh(VAR_0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
16,644 | static int pxa2xx_pic_load(QEMUFile *f, void *opaque, int version_id)
{
PXA2xxPICState *s = (PXA2xxPICState *) opaque;
int i;
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->int_enabled[i]);
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->int_pending[i]);
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->is_fiq[i]);
qemu_get_be32s(f, &s->int_idle);
for (i = 0; i < PXA2XX_PIC_SRCS; i ++)
qemu_get_be32s(f, &s->priority[i]);
pxa2xx_pic_update(opaque);
return 0;
}
| false | qemu | e1f8c729fa890c67bb4532f22c22ace6fb0e1aaf | static int pxa2xx_pic_load(QEMUFile *f, void *opaque, int version_id)
{
PXA2xxPICState *s = (PXA2xxPICState *) opaque;
int i;
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->int_enabled[i]);
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->int_pending[i]);
for (i = 0; i < 2; i ++)
qemu_get_be32s(f, &s->is_fiq[i]);
qemu_get_be32s(f, &s->int_idle);
for (i = 0; i < PXA2XX_PIC_SRCS; i ++)
qemu_get_be32s(f, &s->priority[i]);
pxa2xx_pic_update(opaque);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)
{
PXA2xxPICState *s = (PXA2xxPICState *) VAR_1;
int VAR_3;
for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)
qemu_get_be32s(VAR_0, &s->int_enabled[VAR_3]);
for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)
qemu_get_be32s(VAR_0, &s->int_pending[VAR_3]);
for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)
qemu_get_be32s(VAR_0, &s->is_fiq[VAR_3]);
qemu_get_be32s(VAR_0, &s->int_idle);
for (VAR_3 = 0; VAR_3 < PXA2XX_PIC_SRCS; VAR_3 ++)
qemu_get_be32s(VAR_0, &s->priority[VAR_3]);
pxa2xx_pic_update(VAR_1);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)\n{",
"PXA2xxPICState *s = (PXA2xxPICState *) VAR_1;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)",
"qemu_get_be32s(VAR_0, &s->int_enabled[VAR_3]);",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)",
"qemu_get_be32s(VAR_0, &s->int_pending[VAR_3]);",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3 ++)",
"qemu_get_be32s(VAR_0, &s->is_fiq[VAR_3]);",
"qemu_get_be32s(VAR_0, &s->int_idle);",
"for (VAR_3 = 0; VAR_3 < PXA2XX_PIC_SRCS; VAR_3 ++)",
"qemu_get_be32s(VAR_0, &s->priority[VAR_3]);",
"pxa2xx_pic_update(VAR_1);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
]
]
|
16,645 | static void lsi_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
LSIState *s = opaque;
lsi_reg_writeb(s, addr & 0xff, val);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void lsi_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
LSIState *s = opaque;
lsi_reg_writeb(s, addr & 0xff, val);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
LSIState *s = VAR_0;
lsi_reg_writeb(s, VAR_1 & 0xff, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"LSIState *s = VAR_0;",
"lsi_reg_writeb(s, VAR_1 & 0xff, VAR_2);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
]
]
|
16,646 | static void pmac_ide_writew (void *opaque,
target_phys_addr_t addr, uint32_t val)
{
MACIOIDEState *d = opaque;
addr = (addr & 0xFFF) >> 4;
val = bswap16(val);
if (addr == 0) {
ide_data_writew(&d->bus, 0, val);
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void pmac_ide_writew (void *opaque,
target_phys_addr_t addr, uint32_t val)
{
MACIOIDEState *d = opaque;
addr = (addr & 0xFFF) >> 4;
val = bswap16(val);
if (addr == 0) {
ide_data_writew(&d->bus, 0, val);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0,
target_phys_addr_t VAR_1, uint32_t VAR_2)
{
MACIOIDEState *d = VAR_0;
VAR_1 = (VAR_1 & 0xFFF) >> 4;
VAR_2 = bswap16(VAR_2);
if (VAR_1 == 0) {
ide_data_writew(&d->bus, 0, VAR_2);
}
}
| [
"static void FUNC_0 (void *VAR_0,\ntarget_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"MACIOIDEState *d = VAR_0;",
"VAR_1 = (VAR_1 & 0xFFF) >> 4;",
"VAR_2 = bswap16(VAR_2);",
"if (VAR_1 == 0) {",
"ide_data_writew(&d->bus, 0, VAR_2);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
16,647 | make_setup_request (AVFormatContext *s, const char *host, int port,
int lower_transport, const char *real_challenge)
{
RTSPState *rt = s->priv_data;
int rtx, j, i, err, interleave = 0;
RTSPStream *rtsp_st;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[2048];
const char *trans_pref;
if (rt->transport == RTSP_TRANSPORT_RDT)
trans_pref = "x-pn-tng";
else
trans_pref = "RTP/AVP";
/* default timeout: 1 minute */
rt->timeout = 60;
/* for each stream, make the setup request */
/* XXX: we assume the same server is used for the control of each
RTSP stream */
for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[2048];
/**
* WMS serves all UDP data over a single connection, the RTX, which
* isn't necessarily the first in the SDP but has to be the first
* to be set up, else the second/third SETUP will fail with a 461.
*/
if (lower_transport == RTSP_LOWER_TRANSPORT_UDP &&
rt->server_type == RTSP_SERVER_WMS) {
if (i == 0) {
/* rtx first */
for (rtx = 0; rtx < rt->nb_rtsp_streams; rtx++) {
int len = strlen(rt->rtsp_streams[rtx]->control_url);
if (len >= 4 &&
!strcmp(rt->rtsp_streams[rtx]->control_url + len - 4, "/rtx"))
break;
}
if (rtx == rt->nb_rtsp_streams)
return -1; /* no RTX found */
rtsp_st = rt->rtsp_streams[rtx];
} else
rtsp_st = rt->rtsp_streams[i > rtx ? i : i - 1];
} else
rtsp_st = rt->rtsp_streams[i];
/* RTP/UDP */
if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) {
char buf[256];
if (rt->server_type == RTSP_SERVER_WMS && i > 1) {
port = reply->transports[0].client_port_min;
goto have_port;
}
/* first try in specified port range */
if (RTSP_RTP_PORT_MIN != 0) {
while(j <= RTSP_RTP_PORT_MAX) {
snprintf(buf, sizeof(buf), "rtp://%s?localport=%d", host, j);
j += 2; /* we will use two port by rtp stream (rtp and rtcp) */
if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) {
goto rtp_opened;
}
}
}
/* then try on any port
** if (url_open(&rtsp_st->rtp_handle, "rtp://", URL_RDONLY) < 0) {
** err = AVERROR_INVALIDDATA;
** goto fail;
** }
*/
rtp_opened:
port = rtp_get_local_port(rtsp_st->rtp_handle);
have_port:
snprintf(transport, sizeof(transport) - 1,
"%s/UDP;", trans_pref);
if (rt->server_type != RTSP_SERVER_REAL)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"client_port=%d", port);
if (rt->transport == RTSP_TRANSPORT_RTP &&
!(rt->server_type == RTSP_SERVER_WMS && i > 0))
av_strlcatf(transport, sizeof(transport), "-%d", port + 1);
}
/* RTP/TCP */
else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
/** For WMS streams, the application streams are only used for
* UDP. When trying to set it up for TCP streams, the server
* will return an error. Therefore, we skip those streams. */
if (rt->server_type == RTSP_SERVER_WMS &&
s->streams[rtsp_st->stream_index]->codec->codec_type == CODEC_TYPE_DATA)
continue;
snprintf(transport, sizeof(transport) - 1,
"%s/TCP;", trans_pref);
if (rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"interleaved=%d-%d",
interleave, interleave + 1);
interleave += 2;
}
else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {
snprintf(transport, sizeof(transport) - 1,
"%s/UDP;multicast", trans_pref);
}
if (rt->server_type == RTSP_SERVER_REAL ||
rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, ";mode=play", sizeof(transport));
snprintf(cmd, sizeof(cmd),
"SETUP %s RTSP/1.0\r\n"
"Transport: %s\r\n",
rtsp_st->control_url, transport);
if (i == 0 && rt->server_type == RTSP_SERVER_REAL) {
char real_res[41], real_csum[9];
ff_rdt_calc_response_and_checksum(real_res, real_csum,
real_challenge);
av_strlcatf(cmd, sizeof(cmd),
"If-Match: %s\r\n"
"RealChallenge2: %s, sd=%s\r\n",
rt->session_id, real_res, real_csum);
}
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) {
err = 1;
goto fail;
} else if (reply->status_code != RTSP_STATUS_OK ||
reply->nb_transports != 1) {
err = AVERROR_INVALIDDATA;
goto fail;
}
/* XXX: same protocol for all streams is required */
if (i > 0) {
if (reply->transports[0].lower_transport != rt->lower_transport ||
reply->transports[0].transport != rt->transport) {
err = AVERROR_INVALIDDATA;
goto fail;
}
} else {
rt->lower_transport = reply->transports[0].lower_transport;
rt->transport = reply->transports[0].transport;
}
/* close RTP connection if not choosen */
if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP &&
(lower_transport == RTSP_LOWER_TRANSPORT_UDP)) {
url_close(rtsp_st->rtp_handle);
rtsp_st->rtp_handle = NULL;
}
switch(reply->transports[0].lower_transport) {
case RTSP_LOWER_TRANSPORT_TCP:
rtsp_st->interleaved_min = reply->transports[0].interleaved_min;
rtsp_st->interleaved_max = reply->transports[0].interleaved_max;
break;
case RTSP_LOWER_TRANSPORT_UDP:
{
char url[1024];
/* XXX: also use address if specified */
snprintf(url, sizeof(url), "rtp://%s:%d",
host, reply->transports[0].server_port_min);
if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
{
char url[1024];
struct in_addr in;
int port, ttl;
if (reply->transports[0].destination) {
in.s_addr = htonl(reply->transports[0].destination);
port = reply->transports[0].port_min;
ttl = reply->transports[0].ttl;
} else {
in = rtsp_st->sdp_ip;
port = rtsp_st->sdp_port;
ttl = rtsp_st->sdp_ttl;
}
snprintf(url, sizeof(url), "rtp://%s:%d?ttl=%d",
inet_ntoa(in), port, ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
}
if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
if (reply->timeout > 0)
rt->timeout = reply->timeout;
if (rt->server_type == RTSP_SERVER_REAL)
rt->need_subscription = 1;
return 0;
fail:
for (i=0; i<rt->nb_rtsp_streams; i++) {
if (rt->rtsp_streams[i]->rtp_handle) {
url_close(rt->rtsp_streams[i]->rtp_handle);
rt->rtsp_streams[i]->rtp_handle = NULL;
}
}
return err;
}
| false | FFmpeg | c89658008705d949c319df3fa6f400c481ad73e1 | make_setup_request (AVFormatContext *s, const char *host, int port,
int lower_transport, const char *real_challenge)
{
RTSPState *rt = s->priv_data;
int rtx, j, i, err, interleave = 0;
RTSPStream *rtsp_st;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[2048];
const char *trans_pref;
if (rt->transport == RTSP_TRANSPORT_RDT)
trans_pref = "x-pn-tng";
else
trans_pref = "RTP/AVP";
rt->timeout = 60;
for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[2048];
if (lower_transport == RTSP_LOWER_TRANSPORT_UDP &&
rt->server_type == RTSP_SERVER_WMS) {
if (i == 0) {
for (rtx = 0; rtx < rt->nb_rtsp_streams; rtx++) {
int len = strlen(rt->rtsp_streams[rtx]->control_url);
if (len >= 4 &&
!strcmp(rt->rtsp_streams[rtx]->control_url + len - 4, "/rtx"))
break;
}
if (rtx == rt->nb_rtsp_streams)
return -1;
rtsp_st = rt->rtsp_streams[rtx];
} else
rtsp_st = rt->rtsp_streams[i > rtx ? i : i - 1];
} else
rtsp_st = rt->rtsp_streams[i];
if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) {
char buf[256];
if (rt->server_type == RTSP_SERVER_WMS && i > 1) {
port = reply->transports[0].client_port_min;
goto have_port;
}
if (RTSP_RTP_PORT_MIN != 0) {
while(j <= RTSP_RTP_PORT_MAX) {
snprintf(buf, sizeof(buf), "rtp:
j += 2;
if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) {
goto rtp_opened;
}
}
}
rtp_opened:
port = rtp_get_local_port(rtsp_st->rtp_handle);
have_port:
snprintf(transport, sizeof(transport) - 1,
"%s/UDP;", trans_pref);
if (rt->server_type != RTSP_SERVER_REAL)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"client_port=%d", port);
if (rt->transport == RTSP_TRANSPORT_RTP &&
!(rt->server_type == RTSP_SERVER_WMS && i > 0))
av_strlcatf(transport, sizeof(transport), "-%d", port + 1);
}
else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
if (rt->server_type == RTSP_SERVER_WMS &&
s->streams[rtsp_st->stream_index]->codec->codec_type == CODEC_TYPE_DATA)
continue;
snprintf(transport, sizeof(transport) - 1,
"%s/TCP;", trans_pref);
if (rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"interleaved=%d-%d",
interleave, interleave + 1);
interleave += 2;
}
else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {
snprintf(transport, sizeof(transport) - 1,
"%s/UDP;multicast", trans_pref);
}
if (rt->server_type == RTSP_SERVER_REAL ||
rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, ";mode=play", sizeof(transport));
snprintf(cmd, sizeof(cmd),
"SETUP %s RTSP/1.0\r\n"
"Transport: %s\r\n",
rtsp_st->control_url, transport);
if (i == 0 && rt->server_type == RTSP_SERVER_REAL) {
char real_res[41], real_csum[9];
ff_rdt_calc_response_and_checksum(real_res, real_csum,
real_challenge);
av_strlcatf(cmd, sizeof(cmd),
"If-Match: %s\r\n"
"RealChallenge2: %s, sd=%s\r\n",
rt->session_id, real_res, real_csum);
}
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code == 461 && i == 0) {
err = 1;
goto fail;
} else if (reply->status_code != RTSP_STATUS_OK ||
reply->nb_transports != 1) {
err = AVERROR_INVALIDDATA;
goto fail;
}
if (i > 0) {
if (reply->transports[0].lower_transport != rt->lower_transport ||
reply->transports[0].transport != rt->transport) {
err = AVERROR_INVALIDDATA;
goto fail;
}
} else {
rt->lower_transport = reply->transports[0].lower_transport;
rt->transport = reply->transports[0].transport;
}
if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP &&
(lower_transport == RTSP_LOWER_TRANSPORT_UDP)) {
url_close(rtsp_st->rtp_handle);
rtsp_st->rtp_handle = NULL;
}
switch(reply->transports[0].lower_transport) {
case RTSP_LOWER_TRANSPORT_TCP:
rtsp_st->interleaved_min = reply->transports[0].interleaved_min;
rtsp_st->interleaved_max = reply->transports[0].interleaved_max;
break;
case RTSP_LOWER_TRANSPORT_UDP:
{
char url[1024];
snprintf(url, sizeof(url), "rtp:
host, reply->transports[0].server_port_min);
if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
{
char url[1024];
struct in_addr in;
int port, ttl;
if (reply->transports[0].destination) {
in.s_addr = htonl(reply->transports[0].destination);
port = reply->transports[0].port_min;
ttl = reply->transports[0].ttl;
} else {
in = rtsp_st->sdp_ip;
port = rtsp_st->sdp_port;
ttl = rtsp_st->sdp_ttl;
}
snprintf(url, sizeof(url), "rtp:
inet_ntoa(in), port, ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
}
if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
if (reply->timeout > 0)
rt->timeout = reply->timeout;
if (rt->server_type == RTSP_SERVER_REAL)
rt->need_subscription = 1;
return 0;
fail:
for (i=0; i<rt->nb_rtsp_streams; i++) {
if (rt->rtsp_streams[i]->rtp_handle) {
url_close(rt->rtsp_streams[i]->rtp_handle);
rt->rtsp_streams[i]->rtp_handle = NULL;
}
}
return err;
}
| {
"code": [],
"line_no": []
} | FUNC_0 (AVFormatContext *VAR_0, const char *VAR_1, int VAR_2,
int VAR_3, const char *VAR_4)
{
RTSPState *rt = VAR_0->priv_data;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 0;
RTSPStream *rtsp_st;
RTSPMessageHeader reply1, *reply = &reply1;
char VAR_10[2048];
const char *VAR_11;
if (rt->transport == RTSP_TRANSPORT_RDT)
VAR_11 = "x-pn-tng";
else
VAR_11 = "RTP/AVP";
rt->timeout = 60;
for(VAR_6 = RTSP_RTP_PORT_MIN, VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; ++VAR_7) {
char transport[2048];
if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP &&
rt->server_type == RTSP_SERVER_WMS) {
if (VAR_7 == 0) {
for (VAR_5 = 0; VAR_5 < rt->nb_rtsp_streams; VAR_5++) {
int len = strlen(rt->rtsp_streams[VAR_5]->control_url);
if (len >= 4 &&
!strcmp(rt->rtsp_streams[VAR_5]->control_url + len - 4, "/VAR_5"))
break;
}
if (VAR_5 == rt->nb_rtsp_streams)
return -1;
rtsp_st = rt->rtsp_streams[VAR_5];
} else
rtsp_st = rt->rtsp_streams[VAR_7 > VAR_5 ? VAR_7 : VAR_7 - 1];
} else
rtsp_st = rt->rtsp_streams[VAR_7];
if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP) {
char buf[256];
if (rt->server_type == RTSP_SERVER_WMS && VAR_7 > 1) {
VAR_2 = reply->transports[0].client_port_min;
goto have_port;
}
if (RTSP_RTP_PORT_MIN != 0) {
while(VAR_6 <= RTSP_RTP_PORT_MAX) {
snprintf(buf, sizeof(buf), "rtp:
VAR_6 += 2;
if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) {
goto rtp_opened;
}
}
}
rtp_opened:
VAR_2 = rtp_get_local_port(rtsp_st->rtp_handle);
have_port:
snprintf(transport, sizeof(transport) - 1,
"%VAR_0/UDP;", VAR_11);
if (rt->server_type != RTSP_SERVER_REAL)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"client_port=%d", VAR_2);
if (rt->transport == RTSP_TRANSPORT_RTP &&
!(rt->server_type == RTSP_SERVER_WMS && VAR_7 > 0))
av_strlcatf(transport, sizeof(transport), "-%d", VAR_2 + 1);
}
else if (VAR_3 == RTSP_LOWER_TRANSPORT_TCP) {
if (rt->server_type == RTSP_SERVER_WMS &&
VAR_0->streams[rtsp_st->stream_index]->codec->codec_type == CODEC_TYPE_DATA)
continue;
snprintf(transport, sizeof(transport) - 1,
"%VAR_0/TCP;", VAR_11);
if (rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport),
"interleaved=%d-%d",
VAR_9, VAR_9 + 1);
VAR_9 += 2;
}
else if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {
snprintf(transport, sizeof(transport) - 1,
"%VAR_0/UDP;multicast", VAR_11);
}
if (rt->server_type == RTSP_SERVER_REAL ||
rt->server_type == RTSP_SERVER_WMS)
av_strlcat(transport, ";mode=play", sizeof(transport));
snprintf(VAR_10, sizeof(VAR_10),
"SETUP %VAR_0 RTSP/1.0\r\n"
"Transport: %VAR_0\r\n",
rtsp_st->control_url, transport);
if (VAR_7 == 0 && rt->server_type == RTSP_SERVER_REAL) {
char real_res[41], real_csum[9];
ff_rdt_calc_response_and_checksum(real_res, real_csum,
VAR_4);
av_strlcatf(VAR_10, sizeof(VAR_10),
"If-Match: %VAR_0\r\n"
"RealChallenge2: %VAR_0, sd=%VAR_0\r\n",
rt->session_id, real_res, real_csum);
}
rtsp_send_cmd(VAR_0, VAR_10, reply, NULL);
if (reply->status_code == 461 && VAR_7 == 0) {
VAR_8 = 1;
goto fail;
} else if (reply->status_code != RTSP_STATUS_OK ||
reply->nb_transports != 1) {
VAR_8 = AVERROR_INVALIDDATA;
goto fail;
}
if (VAR_7 > 0) {
if (reply->transports[0].VAR_3 != rt->VAR_3 ||
reply->transports[0].transport != rt->transport) {
VAR_8 = AVERROR_INVALIDDATA;
goto fail;
}
} else {
rt->VAR_3 = reply->transports[0].VAR_3;
rt->transport = reply->transports[0].transport;
}
if (reply->transports[0].VAR_3 != RTSP_LOWER_TRANSPORT_UDP &&
(VAR_3 == RTSP_LOWER_TRANSPORT_UDP)) {
url_close(rtsp_st->rtp_handle);
rtsp_st->rtp_handle = NULL;
}
switch(reply->transports[0].VAR_3) {
case RTSP_LOWER_TRANSPORT_TCP:
rtsp_st->interleaved_min = reply->transports[0].interleaved_min;
rtsp_st->interleaved_max = reply->transports[0].interleaved_max;
break;
case RTSP_LOWER_TRANSPORT_UDP:
{
char url[1024];
snprintf(url, sizeof(url), "rtp:
VAR_1, reply->transports[0].server_port_min);
if (!(rt->server_type == RTSP_SERVER_WMS && VAR_7 > 1) &&
rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
VAR_8 = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
{
char url[1024];
struct in_addr in;
int VAR_2, ttl;
if (reply->transports[0].destination) {
in.s_addr = htonl(reply->transports[0].destination);
VAR_2 = reply->transports[0].port_min;
ttl = reply->transports[0].ttl;
} else {
in = rtsp_st->sdp_ip;
VAR_2 = rtsp_st->sdp_port;
ttl = rtsp_st->sdp_ttl;
}
snprintf(url, sizeof(url), "rtp:
inet_ntoa(in), VAR_2, ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
VAR_8 = AVERROR_INVALIDDATA;
goto fail;
}
}
break;
}
if ((VAR_8 = rtsp_open_transport_ctx(VAR_0, rtsp_st)))
goto fail;
}
if (reply->timeout > 0)
rt->timeout = reply->timeout;
if (rt->server_type == RTSP_SERVER_REAL)
rt->need_subscription = 1;
return 0;
fail:
for (VAR_7=0; VAR_7<rt->nb_rtsp_streams; VAR_7++) {
if (rt->rtsp_streams[VAR_7]->rtp_handle) {
url_close(rt->rtsp_streams[VAR_7]->rtp_handle);
rt->rtsp_streams[VAR_7]->rtp_handle = NULL;
}
}
return VAR_8;
}
| [
"FUNC_0 (AVFormatContext *VAR_0, const char *VAR_1, int VAR_2,\nint VAR_3, const char *VAR_4)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 0;",
"RTSPStream *rtsp_st;",
"RTSPMessageHeader reply1, *reply = &reply1;",
"char VAR_10[2048];",
"const char *VAR_11;",
"if (rt->transport == RTSP_TRANSPORT_RDT)\nVAR_11 = \"x-pn-tng\";",
"else\nVAR_11 = \"RTP/AVP\";",
"rt->timeout = 60;",
"for(VAR_6 = RTSP_RTP_PORT_MIN, VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; ++VAR_7) {",
"char transport[2048];",
"if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP &&\nrt->server_type == RTSP_SERVER_WMS) {",
"if (VAR_7 == 0) {",
"for (VAR_5 = 0; VAR_5 < rt->nb_rtsp_streams; VAR_5++) {",
"int len = strlen(rt->rtsp_streams[VAR_5]->control_url);",
"if (len >= 4 &&\n!strcmp(rt->rtsp_streams[VAR_5]->control_url + len - 4, \"/VAR_5\"))\nbreak;",
"}",
"if (VAR_5 == rt->nb_rtsp_streams)\nreturn -1;",
"rtsp_st = rt->rtsp_streams[VAR_5];",
"} else",
"rtsp_st = rt->rtsp_streams[VAR_7 > VAR_5 ? VAR_7 : VAR_7 - 1];",
"} else",
"rtsp_st = rt->rtsp_streams[VAR_7];",
"if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP) {",
"char buf[256];",
"if (rt->server_type == RTSP_SERVER_WMS && VAR_7 > 1) {",
"VAR_2 = reply->transports[0].client_port_min;",
"goto have_port;",
"}",
"if (RTSP_RTP_PORT_MIN != 0) {",
"while(VAR_6 <= RTSP_RTP_PORT_MAX) {",
"snprintf(buf, sizeof(buf), \"rtp:\nVAR_6 += 2;",
"if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) {",
"goto rtp_opened;",
"}",
"}",
"}",
"rtp_opened:\nVAR_2 = rtp_get_local_port(rtsp_st->rtp_handle);",
"have_port:\nsnprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/UDP;\", VAR_11);",
"if (rt->server_type != RTSP_SERVER_REAL)\nav_strlcat(transport, \"unicast;\", sizeof(transport));",
"av_strlcatf(transport, sizeof(transport),\n\"client_port=%d\", VAR_2);",
"if (rt->transport == RTSP_TRANSPORT_RTP &&\n!(rt->server_type == RTSP_SERVER_WMS && VAR_7 > 0))\nav_strlcatf(transport, sizeof(transport), \"-%d\", VAR_2 + 1);",
"}",
"else if (VAR_3 == RTSP_LOWER_TRANSPORT_TCP) {",
"if (rt->server_type == RTSP_SERVER_WMS &&\nVAR_0->streams[rtsp_st->stream_index]->codec->codec_type == CODEC_TYPE_DATA)\ncontinue;",
"snprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/TCP;\", VAR_11);",
"if (rt->server_type == RTSP_SERVER_WMS)\nav_strlcat(transport, \"unicast;\", sizeof(transport));",
"av_strlcatf(transport, sizeof(transport),\n\"interleaved=%d-%d\",\nVAR_9, VAR_9 + 1);",
"VAR_9 += 2;",
"}",
"else if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {",
"snprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/UDP;multicast\", VAR_11);",
"}",
"if (rt->server_type == RTSP_SERVER_REAL ||\nrt->server_type == RTSP_SERVER_WMS)\nav_strlcat(transport, \";mode=play\", sizeof(transport));",
"snprintf(VAR_10, sizeof(VAR_10),\n\"SETUP %VAR_0 RTSP/1.0\\r\\n\"\n\"Transport: %VAR_0\\r\\n\",\nrtsp_st->control_url, transport);",
"if (VAR_7 == 0 && rt->server_type == RTSP_SERVER_REAL) {",
"char real_res[41], real_csum[9];",
"ff_rdt_calc_response_and_checksum(real_res, real_csum,\nVAR_4);",
"av_strlcatf(VAR_10, sizeof(VAR_10),\n\"If-Match: %VAR_0\\r\\n\"\n\"RealChallenge2: %VAR_0, sd=%VAR_0\\r\\n\",\nrt->session_id, real_res, real_csum);",
"}",
"rtsp_send_cmd(VAR_0, VAR_10, reply, NULL);",
"if (reply->status_code == 461 && VAR_7 == 0) {",
"VAR_8 = 1;",
"goto fail;",
"} else if (reply->status_code != RTSP_STATUS_OK ||",
"reply->nb_transports != 1) {",
"VAR_8 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (VAR_7 > 0) {",
"if (reply->transports[0].VAR_3 != rt->VAR_3 ||\nreply->transports[0].transport != rt->transport) {",
"VAR_8 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"} else {",
"rt->VAR_3 = reply->transports[0].VAR_3;",
"rt->transport = reply->transports[0].transport;",
"}",
"if (reply->transports[0].VAR_3 != RTSP_LOWER_TRANSPORT_UDP &&\n(VAR_3 == RTSP_LOWER_TRANSPORT_UDP)) {",
"url_close(rtsp_st->rtp_handle);",
"rtsp_st->rtp_handle = NULL;",
"}",
"switch(reply->transports[0].VAR_3) {",
"case RTSP_LOWER_TRANSPORT_TCP:\nrtsp_st->interleaved_min = reply->transports[0].interleaved_min;",
"rtsp_st->interleaved_max = reply->transports[0].interleaved_max;",
"break;",
"case RTSP_LOWER_TRANSPORT_UDP:\n{",
"char url[1024];",
"snprintf(url, sizeof(url), \"rtp:\nVAR_1, reply->transports[0].server_port_min);",
"if (!(rt->server_type == RTSP_SERVER_WMS && VAR_7 > 1) &&\nrtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {",
"VAR_8 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"}",
"break;",
"case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:\n{",
"char url[1024];",
"struct in_addr in;",
"int VAR_2, ttl;",
"if (reply->transports[0].destination) {",
"in.s_addr = htonl(reply->transports[0].destination);",
"VAR_2 = reply->transports[0].port_min;",
"ttl = reply->transports[0].ttl;",
"} else {",
"in = rtsp_st->sdp_ip;",
"VAR_2 = rtsp_st->sdp_port;",
"ttl = rtsp_st->sdp_ttl;",
"}",
"snprintf(url, sizeof(url), \"rtp:\ninet_ntoa(in), VAR_2, ttl);",
"if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {",
"VAR_8 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"}",
"break;",
"}",
"if ((VAR_8 = rtsp_open_transport_ctx(VAR_0, rtsp_st)))\ngoto fail;",
"}",
"if (reply->timeout > 0)\nrt->timeout = reply->timeout;",
"if (rt->server_type == RTSP_SERVER_REAL)\nrt->need_subscription = 1;",
"return 0;",
"fail:\nfor (VAR_7=0; VAR_7<rt->nb_rtsp_streams; VAR_7++) {",
"if (rt->rtsp_streams[VAR_7]->rtp_handle) {",
"url_close(rt->rtsp_streams[VAR_7]->rtp_handle);",
"rt->rtsp_streams[VAR_7]->rtp_handle = NULL;",
"}",
"}",
"return VAR_8;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
45
],
[
47
],
[
61,
63
],
[
65
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
151,
153
],
[
155,
157,
159
],
[
161,
163
],
[
165,
167
],
[
169,
171,
173
],
[
175
],
[
181
],
[
189,
191,
193
],
[
195,
197
],
[
199,
201
],
[
203,
205,
207
],
[
209
],
[
211
],
[
215
],
[
217,
219
],
[
221
],
[
223,
225,
227
],
[
229,
231,
233,
235
],
[
237
],
[
239
],
[
241,
243
],
[
245,
247,
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
325,
327
],
[
329
],
[
335,
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403,
405
],
[
407
],
[
411,
413
],
[
417,
419
],
[
423
],
[
427,
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
]
]
|
16,649 | static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
{
uint8_t checksum;
memset(sdt_table, 0, sizeof(*sdt_table));
ACPI_READ_TABLE_HEADER(&sdt_table->header, addr);
sdt_table->aml_len = le32_to_cpu(sdt_table->header.length)
- sizeof(AcpiTableHeader);
sdt_table->aml = g_malloc0(sdt_table->aml_len);
ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
checksum = acpi_calc_checksum((uint8_t *)sdt_table,
sizeof(AcpiTableHeader)) +
acpi_calc_checksum((uint8_t *)sdt_table->aml,
sdt_table->aml_len);
g_assert(!checksum);
}
| false | qemu | 03010579835a17450693888f8b35a66817668d68 | static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
{
uint8_t checksum;
memset(sdt_table, 0, sizeof(*sdt_table));
ACPI_READ_TABLE_HEADER(&sdt_table->header, addr);
sdt_table->aml_len = le32_to_cpu(sdt_table->header.length)
- sizeof(AcpiTableHeader);
sdt_table->aml = g_malloc0(sdt_table->aml_len);
ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
checksum = acpi_calc_checksum((uint8_t *)sdt_table,
sizeof(AcpiTableHeader)) +
acpi_calc_checksum((uint8_t *)sdt_table->aml,
sdt_table->aml_len);
g_assert(!checksum);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AcpiSdtTable *VAR_0, uint32_t VAR_1)
{
uint8_t checksum;
memset(VAR_0, 0, sizeof(*VAR_0));
ACPI_READ_TABLE_HEADER(&VAR_0->header, VAR_1);
VAR_0->aml_len = le32_to_cpu(VAR_0->header.length)
- sizeof(AcpiTableHeader);
VAR_0->aml = g_malloc0(VAR_0->aml_len);
ACPI_READ_ARRAY_PTR(VAR_0->aml, VAR_0->aml_len, VAR_1);
checksum = acpi_calc_checksum((uint8_t *)VAR_0,
sizeof(AcpiTableHeader)) +
acpi_calc_checksum((uint8_t *)VAR_0->aml,
VAR_0->aml_len);
g_assert(!checksum);
}
| [
"static void FUNC_0(AcpiSdtTable *VAR_0, uint32_t VAR_1)\n{",
"uint8_t checksum;",
"memset(VAR_0, 0, sizeof(*VAR_0));",
"ACPI_READ_TABLE_HEADER(&VAR_0->header, VAR_1);",
"VAR_0->aml_len = le32_to_cpu(VAR_0->header.length)\n- sizeof(AcpiTableHeader);",
"VAR_0->aml = g_malloc0(VAR_0->aml_len);",
"ACPI_READ_ARRAY_PTR(VAR_0->aml, VAR_0->aml_len, VAR_1);",
"checksum = acpi_calc_checksum((uint8_t *)VAR_0,\nsizeof(AcpiTableHeader)) +\nacpi_calc_checksum((uint8_t *)VAR_0->aml,\nVAR_0->aml_len);",
"g_assert(!checksum);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25,
27,
29,
31
],
[
33
],
[
35
]
]
|
16,650 | static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
PIIX4PMState *s = PIIX4_PM(hotplug_dev);
if (s->acpi_memory_hotplug.is_enabled &&
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
nvdimm_acpi_plug_cb(hotplug_dev, dev);
} else {
acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug,
dev, errp);
}
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
if (!xen_enabled()) {
acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
errp);
}
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
if (s->cpu_hotplug_legacy) {
legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
} else {
acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
}
} else {
error_setg(errp, "acpi: device plug request for not supported device"
" type: %s", object_get_typename(OBJECT(dev)));
}
}
| false | qemu | 2bed1ba77fae50bc8b5e68ede2d80b652b30c3b8 | static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
PIIX4PMState *s = PIIX4_PM(hotplug_dev);
if (s->acpi_memory_hotplug.is_enabled &&
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
nvdimm_acpi_plug_cb(hotplug_dev, dev);
} else {
acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug,
dev, errp);
}
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
if (!xen_enabled()) {
acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
errp);
}
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
if (s->cpu_hotplug_legacy) {
legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
} else {
acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
}
} else {
error_setg(errp, "acpi: device plug request for not supported device"
" type: %s", object_get_typename(OBJECT(dev)));
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HotplugHandler *VAR_0,
DeviceState *VAR_1, Error **VAR_2)
{
PIIX4PMState *s = PIIX4_PM(VAR_0);
if (s->acpi_memory_hotplug.is_enabled &&
object_dynamic_cast(OBJECT(VAR_1), TYPE_PC_DIMM)) {
if (object_dynamic_cast(OBJECT(VAR_1), TYPE_NVDIMM)) {
nvdimm_acpi_plug_cb(VAR_0, VAR_1);
} else {
acpi_memory_plug_cb(VAR_0, &s->acpi_memory_hotplug,
VAR_1, VAR_2);
}
} else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_PCI_DEVICE)) {
if (!xen_enabled()) {
acpi_pcihp_device_plug_cb(VAR_0, &s->acpi_pci_hotplug, VAR_1,
VAR_2);
}
} else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_CPU)) {
if (s->cpu_hotplug_legacy) {
legacy_acpi_cpu_plug_cb(VAR_0, &s->gpe_cpu, VAR_1, VAR_2);
} else {
acpi_cpu_plug_cb(VAR_0, &s->cpuhp_state, VAR_1, VAR_2);
}
} else {
error_setg(VAR_2, "acpi: device plug request for not supported device"
" type: %s", object_get_typename(OBJECT(VAR_1)));
}
}
| [
"static void FUNC_0(HotplugHandler *VAR_0,\nDeviceState *VAR_1, Error **VAR_2)\n{",
"PIIX4PMState *s = PIIX4_PM(VAR_0);",
"if (s->acpi_memory_hotplug.is_enabled &&\nobject_dynamic_cast(OBJECT(VAR_1), TYPE_PC_DIMM)) {",
"if (object_dynamic_cast(OBJECT(VAR_1), TYPE_NVDIMM)) {",
"nvdimm_acpi_plug_cb(VAR_0, VAR_1);",
"} else {",
"acpi_memory_plug_cb(VAR_0, &s->acpi_memory_hotplug,\nVAR_1, VAR_2);",
"}",
"} else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_PCI_DEVICE)) {",
"if (!xen_enabled()) {",
"acpi_pcihp_device_plug_cb(VAR_0, &s->acpi_pci_hotplug, VAR_1,\nVAR_2);",
"}",
"} else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_CPU)) {",
"if (s->cpu_hotplug_legacy) {",
"legacy_acpi_cpu_plug_cb(VAR_0, &s->gpe_cpu, VAR_1, VAR_2);",
"} else {",
"acpi_cpu_plug_cb(VAR_0, &s->cpuhp_state, VAR_1, VAR_2);",
"}",
"} else {",
"error_setg(VAR_2, \"acpi: device plug request for not supported device\"\n\" type: %s\", object_get_typename(OBJECT(VAR_1)));",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
]
]
|
16,652 | static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ASyncContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int nb_channels = av_get_channel_layout_nb_channels(buf->audio->channel_layout);
int64_t pts = (buf->pts == AV_NOPTS_VALUE) ? buf->pts :
av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
int out_size, ret;
int64_t delta;
/* buffer data until we get the first timestamp */
if (s->pts == AV_NOPTS_VALUE) {
if (pts != AV_NOPTS_VALUE) {
s->pts = pts - get_delay(s);
}
return write_to_fifo(s, buf);
}
/* now wait for the next timestamp */
if (pts == AV_NOPTS_VALUE) {
return write_to_fifo(s, buf);
}
/* when we have two timestamps, compute how many samples would we have
* to add/remove to get proper sync between data and timestamps */
delta = pts - s->pts - get_delay(s);
out_size = avresample_available(s->avr);
if (labs(delta) > s->min_delta) {
av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta);
out_size = av_clipl_int32((int64_t)out_size + delta);
} else {
if (s->resample) {
int comp = av_clip(delta, -s->max_comp, s->max_comp);
av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp);
avresample_set_compensation(s->avr, delta, inlink->sample_rate);
}
delta = 0;
}
if (out_size > 0) {
AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
out_size);
if (!buf_out) {
ret = AVERROR(ENOMEM);
goto fail;
}
avresample_read(s->avr, buf_out->extended_data, out_size);
buf_out->pts = s->pts;
if (delta > 0) {
av_samples_set_silence(buf_out->extended_data, out_size - delta,
delta, nb_channels, buf->format);
}
ret = ff_filter_frame(outlink, buf_out);
if (ret < 0)
goto fail;
s->got_output = 1;
} else {
av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping "
"whole buffer.\n");
}
/* drain any remaining buffered data */
avresample_read(s->avr, NULL, avresample_available(s->avr));
s->pts = pts - avresample_get_delay(s->avr);
ret = avresample_convert(s->avr, NULL, 0, 0, buf->extended_data,
buf->linesize[0], buf->audio->nb_samples);
fail:
avfilter_unref_buffer(buf);
return ret;
}
| false | FFmpeg | 8083332c2de9ee189f96844ff4c2d9be1844116f | static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ASyncContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int nb_channels = av_get_channel_layout_nb_channels(buf->audio->channel_layout);
int64_t pts = (buf->pts == AV_NOPTS_VALUE) ? buf->pts :
av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
int out_size, ret;
int64_t delta;
if (s->pts == AV_NOPTS_VALUE) {
if (pts != AV_NOPTS_VALUE) {
s->pts = pts - get_delay(s);
}
return write_to_fifo(s, buf);
}
if (pts == AV_NOPTS_VALUE) {
return write_to_fifo(s, buf);
}
delta = pts - s->pts - get_delay(s);
out_size = avresample_available(s->avr);
if (labs(delta) > s->min_delta) {
av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta);
out_size = av_clipl_int32((int64_t)out_size + delta);
} else {
if (s->resample) {
int comp = av_clip(delta, -s->max_comp, s->max_comp);
av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp);
avresample_set_compensation(s->avr, delta, inlink->sample_rate);
}
delta = 0;
}
if (out_size > 0) {
AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
out_size);
if (!buf_out) {
ret = AVERROR(ENOMEM);
goto fail;
}
avresample_read(s->avr, buf_out->extended_data, out_size);
buf_out->pts = s->pts;
if (delta > 0) {
av_samples_set_silence(buf_out->extended_data, out_size - delta,
delta, nb_channels, buf->format);
}
ret = ff_filter_frame(outlink, buf_out);
if (ret < 0)
goto fail;
s->got_output = 1;
} else {
av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping "
"whole buffer.\n");
}
avresample_read(s->avr, NULL, avresample_available(s->avr));
s->pts = pts - avresample_get_delay(s->avr);
ret = avresample_convert(s->avr, NULL, 0, 0, buf->extended_data,
buf->linesize[0], buf->audio->nb_samples);
fail:
avfilter_unref_buffer(buf);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
ASyncContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int VAR_2 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout);
int64_t pts = (VAR_1->pts == AV_NOPTS_VALUE) ? VAR_1->pts :
av_rescale_q(VAR_1->pts, VAR_0->time_base, outlink->time_base);
int VAR_3, VAR_4;
int64_t delta;
if (s->pts == AV_NOPTS_VALUE) {
if (pts != AV_NOPTS_VALUE) {
s->pts = pts - get_delay(s);
}
return write_to_fifo(s, VAR_1);
}
if (pts == AV_NOPTS_VALUE) {
return write_to_fifo(s, VAR_1);
}
delta = pts - s->pts - get_delay(s);
VAR_3 = avresample_available(s->avr);
if (labs(delta) > s->min_delta) {
av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta);
VAR_3 = av_clipl_int32((int64_t)VAR_3 + delta);
} else {
if (s->resample) {
int VAR_5 = av_clip(delta, -s->max_comp, s->max_comp);
av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", VAR_5);
avresample_set_compensation(s->avr, delta, VAR_0->sample_rate);
}
delta = 0;
}
if (VAR_3 > 0) {
AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
VAR_3);
if (!buf_out) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
avresample_read(s->avr, buf_out->extended_data, VAR_3);
buf_out->pts = s->pts;
if (delta > 0) {
av_samples_set_silence(buf_out->extended_data, VAR_3 - delta,
delta, VAR_2, VAR_1->format);
}
VAR_4 = ff_filter_frame(outlink, buf_out);
if (VAR_4 < 0)
goto fail;
s->got_output = 1;
} else {
av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping "
"whole buffer.\n");
}
avresample_read(s->avr, NULL, avresample_available(s->avr));
s->pts = pts - avresample_get_delay(s->avr);
VAR_4 = avresample_convert(s->avr, NULL, 0, 0, VAR_1->extended_data,
VAR_1->linesize[0], VAR_1->audio->nb_samples);
fail:
avfilter_unref_buffer(VAR_1);
return VAR_4;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"ASyncContext *s = ctx->priv;",
"AVFilterLink *outlink = ctx->outputs[0];",
"int VAR_2 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout);",
"int64_t pts = (VAR_1->pts == AV_NOPTS_VALUE) ? VAR_1->pts :\nav_rescale_q(VAR_1->pts, VAR_0->time_base, outlink->time_base);",
"int VAR_3, VAR_4;",
"int64_t delta;",
"if (s->pts == AV_NOPTS_VALUE) {",
"if (pts != AV_NOPTS_VALUE) {",
"s->pts = pts - get_delay(s);",
"}",
"return write_to_fifo(s, VAR_1);",
"}",
"if (pts == AV_NOPTS_VALUE) {",
"return write_to_fifo(s, VAR_1);",
"}",
"delta = pts - s->pts - get_delay(s);",
"VAR_3 = avresample_available(s->avr);",
"if (labs(delta) > s->min_delta) {",
"av_log(ctx, AV_LOG_VERBOSE, \"Discontinuity - %\"PRId64\" samples.\\n\", delta);",
"VAR_3 = av_clipl_int32((int64_t)VAR_3 + delta);",
"} else {",
"if (s->resample) {",
"int VAR_5 = av_clip(delta, -s->max_comp, s->max_comp);",
"av_log(ctx, AV_LOG_VERBOSE, \"Compensating %d samples per second.\\n\", VAR_5);",
"avresample_set_compensation(s->avr, delta, VAR_0->sample_rate);",
"}",
"delta = 0;",
"}",
"if (VAR_3 > 0) {",
"AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE,\nVAR_3);",
"if (!buf_out) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"avresample_read(s->avr, buf_out->extended_data, VAR_3);",
"buf_out->pts = s->pts;",
"if (delta > 0) {",
"av_samples_set_silence(buf_out->extended_data, VAR_3 - delta,\ndelta, VAR_2, VAR_1->format);",
"}",
"VAR_4 = ff_filter_frame(outlink, buf_out);",
"if (VAR_4 < 0)\ngoto fail;",
"s->got_output = 1;",
"} else {",
"av_log(ctx, AV_LOG_WARNING, \"Non-monotonous timestamps, dropping \"\n\"whole buffer.\\n\");",
"}",
"avresample_read(s->avr, NULL, avresample_available(s->avr));",
"s->pts = pts - avresample_get_delay(s->avr);",
"VAR_4 = avresample_convert(s->avr, NULL, 0, 0, VAR_1->extended_data,\nVAR_1->linesize[0], VAR_1->audio->nb_samples);",
"fail:\navfilter_unref_buffer(VAR_1);",
"return VAR_4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
133
],
[
137
],
[
139,
141
],
[
145,
147
],
[
151
],
[
153
]
]
|
16,653 | static void test_tco2_status_bits(void)
{
TestData d;
uint16_t ticks = 8;
uint16_t val;
int ret;
d.args = NULL;
d.noreboot = true;
test_init(&d);
stop_tco(&d);
clear_tco_status(&d);
reset_on_second_timeout(true);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
clock_step(ticks * TCO_TICK_NSEC * 2);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
ret = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;
g_assert(ret == 1);
qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);
qtest_end();
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static void test_tco2_status_bits(void)
{
TestData d;
uint16_t ticks = 8;
uint16_t val;
int ret;
d.args = NULL;
d.noreboot = true;
test_init(&d);
stop_tco(&d);
clear_tco_status(&d);
reset_on_second_timeout(true);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
clock_step(ticks * TCO_TICK_NSEC * 2);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
ret = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;
g_assert(ret == 1);
qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);
qtest_end();
}
| {
"code": [
" val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);",
" val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);",
" qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);",
" g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);"
],
"line_no": [
39,
39,
45,
47
]
} | static void FUNC_0(void)
{
TestData d;
uint16_t ticks = 8;
uint16_t val;
int VAR_0;
d.args = NULL;
d.noreboot = true;
test_init(&d);
stop_tco(&d);
clear_tco_status(&d);
reset_on_second_timeout(true);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
clock_step(ticks * TCO_TICK_NSEC * 2);
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
VAR_0 = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;
g_assert(VAR_0 == 1);
qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"TestData d;",
"uint16_t ticks = 8;",
"uint16_t val;",
"int VAR_0;",
"d.args = NULL;",
"d.noreboot = true;",
"test_init(&d);",
"stop_tco(&d);",
"clear_tco_status(&d);",
"reset_on_second_timeout(true);",
"set_tco_timeout(&d, ticks);",
"load_tco(&d);",
"start_tco(&d);",
"clock_step(ticks * TCO_TICK_NSEC * 2);",
"val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);",
"VAR_0 = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;",
"g_assert(VAR_0 == 1);",
"qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);",
"g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);",
"qtest_end();",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
]
|
16,654 | static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int j, entries, pseudo_stream_id;
get_byte(pb); /* version */
get_be24(pb); /* flags */
entries = get_be32(pb);
for(pseudo_stream_id=0; pseudo_stream_id<entries; pseudo_stream_id++) {
//Parsing Sample description table
enum CodecID id;
int dref_id = 1;
MOVAtom a = { 0, 0, 0 };
int64_t start_pos = url_ftell(pb);
int size = get_be32(pb); /* size */
uint32_t format = get_le32(pb); /* data format */
if (size >= 16) {
get_be32(pb); /* reserved */
get_be16(pb); /* reserved */
dref_id = get_be16(pb);
}
if (st->codec->codec_tag &&
st->codec->codec_tag != format &&
(c->fc->video_codec_id ? ff_codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id
: st->codec->codec_tag != MKTAG('j','p','e','g'))
){
/* Multiple fourcc, we skip JPEG. This is not correct, we should
* export it as a separate AVStream but this needs a few changes
* in the MOV demuxer, patch welcome. */
av_log(c->fc, AV_LOG_WARNING, "multiple fourcc not supported\n");
url_fskip(pb, size - (url_ftell(pb) - start_pos));
continue;
}
sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id;
st->codec->codec_tag = format;
id = ff_codec_get_id(codec_movaudio_tags, format);
if (id<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8)))
id = ff_codec_get_id(ff_codec_wav_tags, bswap_32(format)&0xFFFF);
if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if (st->codec->codec_type != CODEC_TYPE_AUDIO && /* do not overwrite codec type */
format && format != MKTAG('m','p','4','s')) { /* skip old asf mpeg4 tag */
id = ff_codec_get_id(codec_movvideo_tags, format);
if (id <= 0)
id = ff_codec_get_id(ff_codec_bmp_tags, format);
if (id > 0)
st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(st->codec->codec_type == CODEC_TYPE_DATA){
id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
if(id > 0)
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
(format >> 24) & 0xff, st->codec->codec_type);
if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
uint8_t codec_name[32];
unsigned int color_depth;
int color_greyscale;
st->codec->codec_id = id;
get_be16(pb); /* version */
get_be16(pb); /* revision level */
get_be32(pb); /* vendor */
get_be32(pb); /* temporal quality */
get_be32(pb); /* spatial quality */
st->codec->width = get_be16(pb); /* width */
st->codec->height = get_be16(pb); /* height */
get_be32(pb); /* horiz resolution */
get_be32(pb); /* vert resolution */
get_be32(pb); /* data size, always 0 */
get_be16(pb); /* frames per samples */
get_buffer(pb, codec_name, 32); /* codec name, pascal string */
if (codec_name[0] <= 31) {
memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
st->codec->codec_name[codec_name[0]] = 0;
}
st->codec->bits_per_coded_sample = get_be16(pb); /* depth */
st->codec->color_table_id = get_be16(pb); /* colortable id */
dprintf(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
/* figure out the palette situation */
color_depth = st->codec->bits_per_coded_sample & 0x1F;
color_greyscale = st->codec->bits_per_coded_sample & 0x20;
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if ((color_depth == 2) || (color_depth == 4) ||
(color_depth == 8)) {
/* for palette traversal */
unsigned int color_start, color_count, color_end;
unsigned char r, g, b;
st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));
if (color_greyscale) {
int color_index, color_dec;
/* compute the greyscale palette */
st->codec->bits_per_coded_sample = color_depth;
color_count = 1 << color_depth;
color_index = 255;
color_dec = 256 / (color_count - 1);
for (j = 0; j < color_count; j++) {
r = g = b = color_index;
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
color_index -= color_dec;
if (color_index < 0)
color_index = 0;
}
} else if (st->codec->color_table_id) {
const uint8_t *color_table;
/* if flag bit 3 is set, use the default palette */
color_count = 1 << color_depth;
if (color_depth == 2)
color_table = ff_qt_default_palette_4;
else if (color_depth == 4)
color_table = ff_qt_default_palette_16;
else
color_table = ff_qt_default_palette_256;
for (j = 0; j < color_count; j++) {
r = color_table[j * 3 + 0];
g = color_table[j * 3 + 1];
b = color_table[j * 3 + 2];
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
} else {
/* load the palette from the file */
color_start = get_be32(pb);
color_count = get_be16(pb);
color_end = get_be16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
get_byte(pb);
get_byte(pb);
r = get_byte(pb);
get_byte(pb);
g = get_byte(pb);
get_byte(pb);
b = get_byte(pb);
get_byte(pb);
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
}
}
st->codec->palctrl->palette_changed = 1;
}
} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {
int bits_per_sample, flags;
uint16_t version = get_be16(pb);
st->codec->codec_id = id;
get_be16(pb); /* revision level */
get_be32(pb); /* vendor */
st->codec->channels = get_be16(pb); /* channel count */
dprintf(c->fc, "audio channels %d\n", st->codec->channels);
st->codec->bits_per_coded_sample = get_be16(pb); /* sample size */
sc->audio_cid = get_be16(pb);
get_be16(pb); /* packet size = 0 */
st->codec->sample_rate = ((get_be32(pb) >> 16));
//Read QT version 1 fields. In version 0 these do not exist.
dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
sc->samples_per_frame = get_be32(pb);
get_be32(pb); /* bytes per packet */
sc->bytes_per_frame = get_be32(pb);
get_be32(pb); /* bytes per sample */
} else if(version==2) {
get_be32(pb); /* sizeof struct only */
st->codec->sample_rate = av_int2dbl(get_be64(pb)); /* float 64 */
st->codec->channels = get_be32(pb);
get_be32(pb); /* always 0x7F000000 */
st->codec->bits_per_coded_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
flags = get_be32(pb); /* lcpm format specific flag */
sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
}
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
if (st->codec->bits_per_coded_sample == 16)
st->codec->codec_id = CODEC_ID_PCM_S16BE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
if (st->codec->bits_per_coded_sample == 8)
st->codec->codec_id = CODEC_ID_PCM_S8;
else if (st->codec->bits_per_coded_sample == 24)
st->codec->codec_id =
st->codec->codec_id == CODEC_ID_PCM_S16BE ?
CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;
break;
/* set values for old format before stsd version 1 appeared */
case CODEC_ID_MACE3:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 2*st->codec->channels;
break;
case CODEC_ID_MACE6:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 1*st->codec->channels;
break;
case CODEC_ID_ADPCM_IMA_QT:
sc->samples_per_frame = 64;
sc->bytes_per_frame = 34*st->codec->channels;
break;
case CODEC_ID_GSM:
sc->samples_per_frame = 160;
sc->bytes_per_frame = 33;
break;
default:
break;
}
bits_per_sample = av_get_bits_per_sample(st->codec->codec_id);
if (bits_per_sample) {
st->codec->bits_per_coded_sample = bits_per_sample;
sc->sample_size = (bits_per_sample >> 3) * st->codec->channels;
}
} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){
// ttxt stsd contains display flags, justification, background
// color, fonts, and default styles, so fake an atom to read it
MOVAtom fake_atom = { .size = size - (url_ftell(pb) - start_pos) };
if (format != AV_RL32("mp4s")) // mp4s contains a regular esds atom
mov_read_glbl(c, pb, fake_atom);
st->codec->codec_id= id;
st->codec->width = sc->width;
st->codec->height = sc->height;
} else {
/* other codec type, just skip (rtp, mp4s, tmcd ...) */
url_fskip(pb, size - (url_ftell(pb) - start_pos));
}
/* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */
a.size = size - (url_ftell(pb) - start_pos);
if (a.size > 8) {
if (mov_read_default(c, pb, a) < 0)
return -1;
} else if (a.size > 0)
url_fskip(pb, a.size);
}
if(st->codec->codec_type==CODEC_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)
st->codec->sample_rate= sc->time_scale;
/* special codec parameters handling */
switch (st->codec->codec_id) {
#if CONFIG_DV_DEMUXER
case CODEC_ID_DVAUDIO:
c->dv_fctx = avformat_alloc_context();
c->dv_demux = dv_init_demux(c->dv_fctx);
if (!c->dv_demux) {
av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n");
return -1;
}
sc->dv_audio_container = 1;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
#endif
/* no ifdef since parameters are always those */
case CODEC_ID_QCELP:
// force sample rate for qcelp when not stored in mov
if (st->codec->codec_tag != MKTAG('Q','c','l','p'))
st->codec->sample_rate = 8000;
st->codec->frame_size= 160;
st->codec->channels= 1; /* really needed */
break;
case CODEC_ID_AMR_NB:
case CODEC_ID_AMR_WB:
st->codec->frame_size= sc->samples_per_frame;
st->codec->channels= 1; /* really needed */
/* force sample rate for amr, stsd in 3gp does not store sample rate */
if (st->codec->codec_id == CODEC_ID_AMR_NB)
st->codec->sample_rate = 8000;
else if (st->codec->codec_id == CODEC_ID_AMR_WB)
st->codec->sample_rate = 16000;
break;
case CODEC_ID_MP2:
case CODEC_ID_MP3:
st->codec->codec_type = CODEC_TYPE_AUDIO; /* force type after stsd for m1a hdlr */
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
case CODEC_ID_GSM:
case CODEC_ID_ADPCM_MS:
case CODEC_ID_ADPCM_IMA_WAV:
st->codec->block_align = sc->bytes_per_frame;
break;
case CODEC_ID_ALAC:
if (st->codec->extradata_size == 36) {
st->codec->frame_size = AV_RB32(st->codec->extradata+12);
st->codec->channels = AV_RB8 (st->codec->extradata+21);
}
break;
default:
break;
}
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int j, entries, pseudo_stream_id;
get_byte(pb);
get_be24(pb);
entries = get_be32(pb);
for(pseudo_stream_id=0; pseudo_stream_id<entries; pseudo_stream_id++) {
enum CodecID id;
int dref_id = 1;
MOVAtom a = { 0, 0, 0 };
int64_t start_pos = url_ftell(pb);
int size = get_be32(pb);
uint32_t format = get_le32(pb);
if (size >= 16) {
get_be32(pb);
get_be16(pb);
dref_id = get_be16(pb);
}
if (st->codec->codec_tag &&
st->codec->codec_tag != format &&
(c->fc->video_codec_id ? ff_codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id
: st->codec->codec_tag != MKTAG('j','p','e','g'))
){
av_log(c->fc, AV_LOG_WARNING, "multiple fourcc not supported\n");
url_fskip(pb, size - (url_ftell(pb) - start_pos));
continue;
}
sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id;
st->codec->codec_tag = format;
id = ff_codec_get_id(codec_movaudio_tags, format);
if (id<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8)))
id = ff_codec_get_id(ff_codec_wav_tags, bswap_32(format)&0xFFFF);
if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if (st->codec->codec_type != CODEC_TYPE_AUDIO &&
format && format != MKTAG('m','p','4','s')) {
id = ff_codec_get_id(codec_movvideo_tags, format);
if (id <= 0)
id = ff_codec_get_id(ff_codec_bmp_tags, format);
if (id > 0)
st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(st->codec->codec_type == CODEC_TYPE_DATA){
id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
if(id > 0)
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
(format >> 24) & 0xff, st->codec->codec_type);
if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
uint8_t codec_name[32];
unsigned int color_depth;
int color_greyscale;
st->codec->codec_id = id;
get_be16(pb);
get_be16(pb);
get_be32(pb);
get_be32(pb);
get_be32(pb);
st->codec->width = get_be16(pb);
st->codec->height = get_be16(pb);
get_be32(pb);
get_be32(pb);
get_be32(pb);
get_be16(pb);
get_buffer(pb, codec_name, 32);
if (codec_name[0] <= 31) {
memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
st->codec->codec_name[codec_name[0]] = 0;
}
st->codec->bits_per_coded_sample = get_be16(pb);
st->codec->color_table_id = get_be16(pb);
dprintf(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
color_depth = st->codec->bits_per_coded_sample & 0x1F;
color_greyscale = st->codec->bits_per_coded_sample & 0x20;
if ((color_depth == 2) || (color_depth == 4) ||
(color_depth == 8)) {
unsigned int color_start, color_count, color_end;
unsigned char r, g, b;
st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));
if (color_greyscale) {
int color_index, color_dec;
st->codec->bits_per_coded_sample = color_depth;
color_count = 1 << color_depth;
color_index = 255;
color_dec = 256 / (color_count - 1);
for (j = 0; j < color_count; j++) {
r = g = b = color_index;
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
color_index -= color_dec;
if (color_index < 0)
color_index = 0;
}
} else if (st->codec->color_table_id) {
const uint8_t *color_table;
color_count = 1 << color_depth;
if (color_depth == 2)
color_table = ff_qt_default_palette_4;
else if (color_depth == 4)
color_table = ff_qt_default_palette_16;
else
color_table = ff_qt_default_palette_256;
for (j = 0; j < color_count; j++) {
r = color_table[j * 3 + 0];
g = color_table[j * 3 + 1];
b = color_table[j * 3 + 2];
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
} else {
color_start = get_be32(pb);
color_count = get_be16(pb);
color_end = get_be16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
get_byte(pb);
get_byte(pb);
r = get_byte(pb);
get_byte(pb);
g = get_byte(pb);
get_byte(pb);
b = get_byte(pb);
get_byte(pb);
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
}
}
st->codec->palctrl->palette_changed = 1;
}
} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {
int bits_per_sample, flags;
uint16_t version = get_be16(pb);
st->codec->codec_id = id;
get_be16(pb);
get_be32(pb);
st->codec->channels = get_be16(pb);
dprintf(c->fc, "audio channels %d\n", st->codec->channels);
st->codec->bits_per_coded_sample = get_be16(pb);
sc->audio_cid = get_be16(pb);
get_be16(pb);
st->codec->sample_rate = ((get_be32(pb) >> 16));
dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
sc->samples_per_frame = get_be32(pb);
get_be32(pb);
sc->bytes_per_frame = get_be32(pb);
get_be32(pb);
} else if(version==2) {
get_be32(pb);
st->codec->sample_rate = av_int2dbl(get_be64(pb));
st->codec->channels = get_be32(pb);
get_be32(pb);
st->codec->bits_per_coded_sample = get_be32(pb);
flags = get_be32(pb);
sc->bytes_per_frame = get_be32(pb);
sc->samples_per_frame = get_be32(pb);
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
}
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
if (st->codec->bits_per_coded_sample == 16)
st->codec->codec_id = CODEC_ID_PCM_S16BE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
if (st->codec->bits_per_coded_sample == 8)
st->codec->codec_id = CODEC_ID_PCM_S8;
else if (st->codec->bits_per_coded_sample == 24)
st->codec->codec_id =
st->codec->codec_id == CODEC_ID_PCM_S16BE ?
CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_MACE3:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 2*st->codec->channels;
break;
case CODEC_ID_MACE6:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 1*st->codec->channels;
break;
case CODEC_ID_ADPCM_IMA_QT:
sc->samples_per_frame = 64;
sc->bytes_per_frame = 34*st->codec->channels;
break;
case CODEC_ID_GSM:
sc->samples_per_frame = 160;
sc->bytes_per_frame = 33;
break;
default:
break;
}
bits_per_sample = av_get_bits_per_sample(st->codec->codec_id);
if (bits_per_sample) {
st->codec->bits_per_coded_sample = bits_per_sample;
sc->sample_size = (bits_per_sample >> 3) * st->codec->channels;
}
} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){
MOVAtom fake_atom = { .size = size - (url_ftell(pb) - start_pos) };
if (format != AV_RL32("mp4s"))
mov_read_glbl(c, pb, fake_atom);
st->codec->codec_id= id;
st->codec->width = sc->width;
st->codec->height = sc->height;
} else {
url_fskip(pb, size - (url_ftell(pb) - start_pos));
}
a.size = size - (url_ftell(pb) - start_pos);
if (a.size > 8) {
if (mov_read_default(c, pb, a) < 0)
return -1;
} else if (a.size > 0)
url_fskip(pb, a.size);
}
if(st->codec->codec_type==CODEC_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)
st->codec->sample_rate= sc->time_scale;
switch (st->codec->codec_id) {
#if CONFIG_DV_DEMUXER
case CODEC_ID_DVAUDIO:
c->dv_fctx = avformat_alloc_context();
c->dv_demux = dv_init_demux(c->dv_fctx);
if (!c->dv_demux) {
av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n");
return -1;
}
sc->dv_audio_container = 1;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
#endif
case CODEC_ID_QCELP:
if (st->codec->codec_tag != MKTAG('Q','c','l','p'))
st->codec->sample_rate = 8000;
st->codec->frame_size= 160;
st->codec->channels= 1;
break;
case CODEC_ID_AMR_NB:
case CODEC_ID_AMR_WB:
st->codec->frame_size= sc->samples_per_frame;
st->codec->channels= 1;
if (st->codec->codec_id == CODEC_ID_AMR_NB)
st->codec->sample_rate = 8000;
else if (st->codec->codec_id == CODEC_ID_AMR_WB)
st->codec->sample_rate = 16000;
break;
case CODEC_ID_MP2:
case CODEC_ID_MP3:
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
case CODEC_ID_GSM:
case CODEC_ID_ADPCM_MS:
case CODEC_ID_ADPCM_IMA_WAV:
st->codec->block_align = sc->bytes_per_frame;
break;
case CODEC_ID_ALAC:
if (st->codec->extradata_size == 36) {
st->codec->frame_size = AV_RB32(st->codec->extradata+12);
st->codec->channels = AV_RB8 (st->codec->extradata+21);
}
break;
default:
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int VAR_3, VAR_4, VAR_5;
get_byte(VAR_1);
get_be24(VAR_1);
VAR_4 = get_be32(VAR_1);
for(VAR_5=0; VAR_5<VAR_4; VAR_5++) {
enum CodecID VAR_6;
int VAR_7 = 1;
MOVAtom a = { 0, 0, 0 };
int64_t start_pos = url_ftell(VAR_1);
int VAR_8 = get_be32(VAR_1);
uint32_t format = get_le32(VAR_1);
if (VAR_8 >= 16) {
get_be32(VAR_1);
get_be16(VAR_1);
VAR_7 = get_be16(VAR_1);
}
if (st->codec->codec_tag &&
st->codec->codec_tag != format &&
(VAR_0->fc->video_codec_id ? ff_codec_get_id(codec_movvideo_tags, format) != VAR_0->fc->video_codec_id
: st->codec->codec_tag != MKTAG('VAR_3','p','e','VAR_15'))
){
av_log(VAR_0->fc, AV_LOG_WARNING, "multiple fourcc not supported\n");
url_fskip(VAR_1, VAR_8 - (url_ftell(VAR_1) - start_pos));
continue;
}
sc->VAR_5 = st->codec->codec_tag ? -1 : VAR_5;
sc->VAR_7= VAR_7;
st->codec->codec_tag = format;
VAR_6 = ff_codec_get_id(codec_movaudio_tags, format);
if (VAR_6<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8)))
VAR_6 = ff_codec_get_id(ff_codec_wav_tags, bswap_32(format)&0xFFFF);
if (st->codec->codec_type != CODEC_TYPE_VIDEO && VAR_6 > 0) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if (st->codec->codec_type != CODEC_TYPE_AUDIO &&
format && format != MKTAG('m','p','4','s')) {
VAR_6 = ff_codec_get_id(codec_movvideo_tags, format);
if (VAR_6 <= 0)
VAR_6 = ff_codec_get_id(ff_codec_bmp_tags, format);
if (VAR_6 > 0)
st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(st->codec->codec_type == CODEC_TYPE_DATA){
VAR_6 = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
if(VAR_6 > 0)
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
dprintf(VAR_0->fc, "VAR_8=%d 4CC= %VAR_0%VAR_0%VAR_0%VAR_0 codec_type=%d\n", VAR_8,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
(format >> 24) & 0xff, st->codec->codec_type);
if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
uint8_t codec_name[32];
unsigned int VAR_9;
int VAR_10;
st->codec->codec_id = VAR_6;
get_be16(VAR_1);
get_be16(VAR_1);
get_be32(VAR_1);
get_be32(VAR_1);
get_be32(VAR_1);
st->codec->width = get_be16(VAR_1);
st->codec->height = get_be16(VAR_1);
get_be32(VAR_1);
get_be32(VAR_1);
get_be32(VAR_1);
get_be16(VAR_1);
get_buffer(VAR_1, codec_name, 32);
if (codec_name[0] <= 31) {
memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
st->codec->codec_name[codec_name[0]] = 0;
}
st->codec->bits_per_coded_sample = get_be16(VAR_1);
st->codec->color_table_id = get_be16(VAR_1);
dprintf(VAR_0->fc, "depth %d, ctab VAR_6 %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
VAR_9 = st->codec->bits_per_coded_sample & 0x1F;
VAR_10 = st->codec->bits_per_coded_sample & 0x20;
if ((VAR_9 == 2) || (VAR_9 == 4) ||
(VAR_9 == 8)) {
unsigned int VAR_11, VAR_12, VAR_13;
unsigned char VAR_14, VAR_15, VAR_16;
st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));
if (VAR_10) {
int VAR_17, VAR_18;
st->codec->bits_per_coded_sample = VAR_9;
VAR_12 = 1 << VAR_9;
VAR_17 = 255;
VAR_18 = 256 / (VAR_12 - 1);
for (VAR_3 = 0; VAR_3 < VAR_12; VAR_3++) {
VAR_14 = VAR_15 = VAR_16 = VAR_17;
st->codec->palctrl->palette[VAR_3] =
(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);
VAR_17 -= VAR_18;
if (VAR_17 < 0)
VAR_17 = 0;
}
} else if (st->codec->color_table_id) {
const uint8_t *VAR_19;
VAR_12 = 1 << VAR_9;
if (VAR_9 == 2)
VAR_19 = ff_qt_default_palette_4;
else if (VAR_9 == 4)
VAR_19 = ff_qt_default_palette_16;
else
VAR_19 = ff_qt_default_palette_256;
for (VAR_3 = 0; VAR_3 < VAR_12; VAR_3++) {
VAR_14 = VAR_19[VAR_3 * 3 + 0];
VAR_15 = VAR_19[VAR_3 * 3 + 1];
VAR_16 = VAR_19[VAR_3 * 3 + 2];
st->codec->palctrl->palette[VAR_3] =
(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);
}
} else {
VAR_11 = get_be32(VAR_1);
VAR_12 = get_be16(VAR_1);
VAR_13 = get_be16(VAR_1);
if ((VAR_11 <= 255) &&
(VAR_13 <= 255)) {
for (VAR_3 = VAR_11; VAR_3 <= VAR_13; VAR_3++) {
get_byte(VAR_1);
get_byte(VAR_1);
VAR_14 = get_byte(VAR_1);
get_byte(VAR_1);
VAR_15 = get_byte(VAR_1);
get_byte(VAR_1);
VAR_16 = get_byte(VAR_1);
get_byte(VAR_1);
st->codec->palctrl->palette[VAR_3] =
(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);
}
}
}
st->codec->palctrl->palette_changed = 1;
}
} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {
int VAR_20, VAR_21;
uint16_t version = get_be16(VAR_1);
st->codec->codec_id = VAR_6;
get_be16(VAR_1);
get_be32(VAR_1);
st->codec->channels = get_be16(VAR_1);
dprintf(VAR_0->fc, "audio channels %d\n", st->codec->channels);
st->codec->bits_per_coded_sample = get_be16(VAR_1);
sc->audio_cid = get_be16(VAR_1);
get_be16(VAR_1);
st->codec->sample_rate = ((get_be32(VAR_1) >> 16));
dprintf(VAR_0->fc, "version =%d, isom =%d\n",version,VAR_0->isom);
if(!VAR_0->isom) {
if(version==1) {
sc->samples_per_frame = get_be32(VAR_1);
get_be32(VAR_1);
sc->bytes_per_frame = get_be32(VAR_1);
get_be32(VAR_1);
} else if(version==2) {
get_be32(VAR_1);
st->codec->sample_rate = av_int2dbl(get_be64(VAR_1));
st->codec->channels = get_be32(VAR_1);
get_be32(VAR_1);
st->codec->bits_per_coded_sample = get_be32(VAR_1);
VAR_21 = get_be32(VAR_1);
sc->bytes_per_frame = get_be32(VAR_1);
sc->samples_per_frame = get_be32(VAR_1);
if (format == MKTAG('l','p','VAR_0','m'))
st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, VAR_21);
}
}
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
if (st->codec->bits_per_coded_sample == 16)
st->codec->codec_id = CODEC_ID_PCM_S16BE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
if (st->codec->bits_per_coded_sample == 8)
st->codec->codec_id = CODEC_ID_PCM_S8;
else if (st->codec->bits_per_coded_sample == 24)
st->codec->codec_id =
st->codec->codec_id == CODEC_ID_PCM_S16BE ?
CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_MACE3:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 2*st->codec->channels;
break;
case CODEC_ID_MACE6:
sc->samples_per_frame = 6;
sc->bytes_per_frame = 1*st->codec->channels;
break;
case CODEC_ID_ADPCM_IMA_QT:
sc->samples_per_frame = 64;
sc->bytes_per_frame = 34*st->codec->channels;
break;
case CODEC_ID_GSM:
sc->samples_per_frame = 160;
sc->bytes_per_frame = 33;
break;
default:
break;
}
VAR_20 = av_get_bits_per_sample(st->codec->codec_id);
if (VAR_20) {
st->codec->bits_per_coded_sample = VAR_20;
sc->sample_size = (VAR_20 >> 3) * st->codec->channels;
}
} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){
MOVAtom fake_atom = { .VAR_8 = VAR_8 - (url_ftell(VAR_1) - start_pos) };
if (format != AV_RL32("mp4s"))
mov_read_glbl(VAR_0, VAR_1, fake_atom);
st->codec->codec_id= VAR_6;
st->codec->width = sc->width;
st->codec->height = sc->height;
} else {
url_fskip(VAR_1, VAR_8 - (url_ftell(VAR_1) - start_pos));
}
a.VAR_8 = VAR_8 - (url_ftell(VAR_1) - start_pos);
if (a.VAR_8 > 8) {
if (mov_read_default(VAR_0, VAR_1, a) < 0)
return -1;
} else if (a.VAR_8 > 0)
url_fskip(VAR_1, a.VAR_8);
}
if(st->codec->codec_type==CODEC_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)
st->codec->sample_rate= sc->time_scale;
switch (st->codec->codec_id) {
#if CONFIG_DV_DEMUXER
case CODEC_ID_DVAUDIO:
VAR_0->dv_fctx = avformat_alloc_context();
VAR_0->dv_demux = dv_init_demux(VAR_0->dv_fctx);
if (!VAR_0->dv_demux) {
av_log(VAR_0->fc, AV_LOG_ERROR, "dv demux context init error\n");
return -1;
}
sc->dv_audio_container = 1;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
#endif
case CODEC_ID_QCELP:
if (st->codec->codec_tag != MKTAG('Q','VAR_0','l','p'))
st->codec->sample_rate = 8000;
st->codec->frame_size= 160;
st->codec->channels= 1;
break;
case CODEC_ID_AMR_NB:
case CODEC_ID_AMR_WB:
st->codec->frame_size= sc->samples_per_frame;
st->codec->channels= 1;
if (st->codec->codec_id == CODEC_ID_AMR_NB)
st->codec->sample_rate = 8000;
else if (st->codec->codec_id == CODEC_ID_AMR_WB)
st->codec->sample_rate = 16000;
break;
case CODEC_ID_MP2:
case CODEC_ID_MP3:
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
case CODEC_ID_GSM:
case CODEC_ID_ADPCM_MS:
case CODEC_ID_ADPCM_IMA_WAV:
st->codec->block_align = sc->bytes_per_frame;
break;
case CODEC_ID_ALAC:
if (st->codec->extradata_size == 36) {
st->codec->frame_size = AV_RB32(st->codec->extradata+12);
st->codec->channels = AV_RB8 (st->codec->extradata+21);
}
break;
default:
break;
}
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"MOVStreamContext *sc = st->priv_data;",
"int VAR_3, VAR_4, VAR_5;",
"get_byte(VAR_1);",
"get_be24(VAR_1);",
"VAR_4 = get_be32(VAR_1);",
"for(VAR_5=0; VAR_5<VAR_4; VAR_5++) {",
"enum CodecID VAR_6;",
"int VAR_7 = 1;",
"MOVAtom a = { 0, 0, 0 };",
"int64_t start_pos = url_ftell(VAR_1);",
"int VAR_8 = get_be32(VAR_1);",
"uint32_t format = get_le32(VAR_1);",
"if (VAR_8 >= 16) {",
"get_be32(VAR_1);",
"get_be16(VAR_1);",
"VAR_7 = get_be16(VAR_1);",
"}",
"if (st->codec->codec_tag &&\nst->codec->codec_tag != format &&\n(VAR_0->fc->video_codec_id ? ff_codec_get_id(codec_movvideo_tags, format) != VAR_0->fc->video_codec_id\n: st->codec->codec_tag != MKTAG('VAR_3','p','e','VAR_15'))\n){",
"av_log(VAR_0->fc, AV_LOG_WARNING, \"multiple fourcc not supported\\n\");",
"url_fskip(VAR_1, VAR_8 - (url_ftell(VAR_1) - start_pos));",
"continue;",
"}",
"sc->VAR_5 = st->codec->codec_tag ? -1 : VAR_5;",
"sc->VAR_7= VAR_7;",
"st->codec->codec_tag = format;",
"VAR_6 = ff_codec_get_id(codec_movaudio_tags, format);",
"if (VAR_6<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8)))\nVAR_6 = ff_codec_get_id(ff_codec_wav_tags, bswap_32(format)&0xFFFF);",
"if (st->codec->codec_type != CODEC_TYPE_VIDEO && VAR_6 > 0) {",
"st->codec->codec_type = CODEC_TYPE_AUDIO;",
"} else if (st->codec->codec_type != CODEC_TYPE_AUDIO &&",
"format && format != MKTAG('m','p','4','s')) {",
"VAR_6 = ff_codec_get_id(codec_movvideo_tags, format);",
"if (VAR_6 <= 0)\nVAR_6 = ff_codec_get_id(ff_codec_bmp_tags, format);",
"if (VAR_6 > 0)\nst->codec->codec_type = CODEC_TYPE_VIDEO;",
"else if(st->codec->codec_type == CODEC_TYPE_DATA){",
"VAR_6 = ff_codec_get_id(ff_codec_movsubtitle_tags, format);",
"if(VAR_6 > 0)\nst->codec->codec_type = CODEC_TYPE_SUBTITLE;",
"}",
"}",
"dprintf(VAR_0->fc, \"VAR_8=%d 4CC= %VAR_0%VAR_0%VAR_0%VAR_0 codec_type=%d\\n\", VAR_8,\n(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,\n(format >> 24) & 0xff, st->codec->codec_type);",
"if(st->codec->codec_type==CODEC_TYPE_VIDEO) {",
"uint8_t codec_name[32];",
"unsigned int VAR_9;",
"int VAR_10;",
"st->codec->codec_id = VAR_6;",
"get_be16(VAR_1);",
"get_be16(VAR_1);",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"st->codec->width = get_be16(VAR_1);",
"st->codec->height = get_be16(VAR_1);",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"get_be16(VAR_1);",
"get_buffer(VAR_1, codec_name, 32);",
"if (codec_name[0] <= 31) {",
"memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);",
"st->codec->codec_name[codec_name[0]] = 0;",
"}",
"st->codec->bits_per_coded_sample = get_be16(VAR_1);",
"st->codec->color_table_id = get_be16(VAR_1);",
"dprintf(VAR_0->fc, \"depth %d, ctab VAR_6 %d\\n\",\nst->codec->bits_per_coded_sample, st->codec->color_table_id);",
"VAR_9 = st->codec->bits_per_coded_sample & 0x1F;",
"VAR_10 = st->codec->bits_per_coded_sample & 0x20;",
"if ((VAR_9 == 2) || (VAR_9 == 4) ||\n(VAR_9 == 8)) {",
"unsigned int VAR_11, VAR_12, VAR_13;",
"unsigned char VAR_14, VAR_15, VAR_16;",
"st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));",
"if (VAR_10) {",
"int VAR_17, VAR_18;",
"st->codec->bits_per_coded_sample = VAR_9;",
"VAR_12 = 1 << VAR_9;",
"VAR_17 = 255;",
"VAR_18 = 256 / (VAR_12 - 1);",
"for (VAR_3 = 0; VAR_3 < VAR_12; VAR_3++) {",
"VAR_14 = VAR_15 = VAR_16 = VAR_17;",
"st->codec->palctrl->palette[VAR_3] =\n(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);",
"VAR_17 -= VAR_18;",
"if (VAR_17 < 0)\nVAR_17 = 0;",
"}",
"} else if (st->codec->color_table_id) {",
"const uint8_t *VAR_19;",
"VAR_12 = 1 << VAR_9;",
"if (VAR_9 == 2)\nVAR_19 = ff_qt_default_palette_4;",
"else if (VAR_9 == 4)\nVAR_19 = ff_qt_default_palette_16;",
"else\nVAR_19 = ff_qt_default_palette_256;",
"for (VAR_3 = 0; VAR_3 < VAR_12; VAR_3++) {",
"VAR_14 = VAR_19[VAR_3 * 3 + 0];",
"VAR_15 = VAR_19[VAR_3 * 3 + 1];",
"VAR_16 = VAR_19[VAR_3 * 3 + 2];",
"st->codec->palctrl->palette[VAR_3] =\n(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);",
"}",
"} else {",
"VAR_11 = get_be32(VAR_1);",
"VAR_12 = get_be16(VAR_1);",
"VAR_13 = get_be16(VAR_1);",
"if ((VAR_11 <= 255) &&\n(VAR_13 <= 255)) {",
"for (VAR_3 = VAR_11; VAR_3 <= VAR_13; VAR_3++) {",
"get_byte(VAR_1);",
"get_byte(VAR_1);",
"VAR_14 = get_byte(VAR_1);",
"get_byte(VAR_1);",
"VAR_15 = get_byte(VAR_1);",
"get_byte(VAR_1);",
"VAR_16 = get_byte(VAR_1);",
"get_byte(VAR_1);",
"st->codec->palctrl->palette[VAR_3] =\n(VAR_14 << 16) | (VAR_15 << 8) | (VAR_16);",
"}",
"}",
"}",
"st->codec->palctrl->palette_changed = 1;",
"}",
"} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {",
"int VAR_20, VAR_21;",
"uint16_t version = get_be16(VAR_1);",
"st->codec->codec_id = VAR_6;",
"get_be16(VAR_1);",
"get_be32(VAR_1);",
"st->codec->channels = get_be16(VAR_1);",
"dprintf(VAR_0->fc, \"audio channels %d\\n\", st->codec->channels);",
"st->codec->bits_per_coded_sample = get_be16(VAR_1);",
"sc->audio_cid = get_be16(VAR_1);",
"get_be16(VAR_1);",
"st->codec->sample_rate = ((get_be32(VAR_1) >> 16));",
"dprintf(VAR_0->fc, \"version =%d, isom =%d\\n\",version,VAR_0->isom);",
"if(!VAR_0->isom) {",
"if(version==1) {",
"sc->samples_per_frame = get_be32(VAR_1);",
"get_be32(VAR_1);",
"sc->bytes_per_frame = get_be32(VAR_1);",
"get_be32(VAR_1);",
"} else if(version==2) {",
"get_be32(VAR_1);",
"st->codec->sample_rate = av_int2dbl(get_be64(VAR_1));",
"st->codec->channels = get_be32(VAR_1);",
"get_be32(VAR_1);",
"st->codec->bits_per_coded_sample = get_be32(VAR_1);",
"VAR_21 = get_be32(VAR_1);",
"sc->bytes_per_frame = get_be32(VAR_1);",
"sc->samples_per_frame = get_be32(VAR_1);",
"if (format == MKTAG('l','p','VAR_0','m'))\nst->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, VAR_21);",
"}",
"}",
"switch (st->codec->codec_id) {",
"case CODEC_ID_PCM_S8:\ncase CODEC_ID_PCM_U8:\nif (st->codec->bits_per_coded_sample == 16)\nst->codec->codec_id = CODEC_ID_PCM_S16BE;",
"break;",
"case CODEC_ID_PCM_S16LE:\ncase CODEC_ID_PCM_S16BE:\nif (st->codec->bits_per_coded_sample == 8)\nst->codec->codec_id = CODEC_ID_PCM_S8;",
"else if (st->codec->bits_per_coded_sample == 24)\nst->codec->codec_id =\nst->codec->codec_id == CODEC_ID_PCM_S16BE ?\nCODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;",
"break;",
"case CODEC_ID_MACE3:\nsc->samples_per_frame = 6;",
"sc->bytes_per_frame = 2*st->codec->channels;",
"break;",
"case CODEC_ID_MACE6:\nsc->samples_per_frame = 6;",
"sc->bytes_per_frame = 1*st->codec->channels;",
"break;",
"case CODEC_ID_ADPCM_IMA_QT:\nsc->samples_per_frame = 64;",
"sc->bytes_per_frame = 34*st->codec->channels;",
"break;",
"case CODEC_ID_GSM:\nsc->samples_per_frame = 160;",
"sc->bytes_per_frame = 33;",
"break;",
"default:\nbreak;",
"}",
"VAR_20 = av_get_bits_per_sample(st->codec->codec_id);",
"if (VAR_20) {",
"st->codec->bits_per_coded_sample = VAR_20;",
"sc->sample_size = (VAR_20 >> 3) * st->codec->channels;",
"}",
"} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){",
"MOVAtom fake_atom = { .VAR_8 = VAR_8 - (url_ftell(VAR_1) - start_pos) };",
"if (format != AV_RL32(\"mp4s\"))\nmov_read_glbl(VAR_0, VAR_1, fake_atom);",
"st->codec->codec_id= VAR_6;",
"st->codec->width = sc->width;",
"st->codec->height = sc->height;",
"} else {",
"url_fskip(VAR_1, VAR_8 - (url_ftell(VAR_1) - start_pos));",
"}",
"a.VAR_8 = VAR_8 - (url_ftell(VAR_1) - start_pos);",
"if (a.VAR_8 > 8) {",
"if (mov_read_default(VAR_0, VAR_1, a) < 0)\nreturn -1;",
"} else if (a.VAR_8 > 0)",
"url_fskip(VAR_1, a.VAR_8);",
"}",
"if(st->codec->codec_type==CODEC_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)\nst->codec->sample_rate= sc->time_scale;",
"switch (st->codec->codec_id) {",
"#if CONFIG_DV_DEMUXER\ncase CODEC_ID_DVAUDIO:\nVAR_0->dv_fctx = avformat_alloc_context();",
"VAR_0->dv_demux = dv_init_demux(VAR_0->dv_fctx);",
"if (!VAR_0->dv_demux) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"dv demux context init error\\n\");",
"return -1;",
"}",
"sc->dv_audio_container = 1;",
"st->codec->codec_id = CODEC_ID_PCM_S16LE;",
"break;",
"#endif\ncase CODEC_ID_QCELP:\nif (st->codec->codec_tag != MKTAG('Q','VAR_0','l','p'))\nst->codec->sample_rate = 8000;",
"st->codec->frame_size= 160;",
"st->codec->channels= 1;",
"break;",
"case CODEC_ID_AMR_NB:\ncase CODEC_ID_AMR_WB:\nst->codec->frame_size= sc->samples_per_frame;",
"st->codec->channels= 1;",
"if (st->codec->codec_id == CODEC_ID_AMR_NB)\nst->codec->sample_rate = 8000;",
"else if (st->codec->codec_id == CODEC_ID_AMR_WB)\nst->codec->sample_rate = 16000;",
"break;",
"case CODEC_ID_MP2:\ncase CODEC_ID_MP3:\nst->codec->codec_type = CODEC_TYPE_AUDIO;",
"st->need_parsing = AVSTREAM_PARSE_FULL;",
"break;",
"case CODEC_ID_GSM:\ncase CODEC_ID_ADPCM_MS:\ncase CODEC_ID_ADPCM_IMA_WAV:\nst->codec->block_align = sc->bytes_per_frame;",
"break;",
"case CODEC_ID_ALAC:\nif (st->codec->extradata_size == 36) {",
"st->codec->frame_size = AV_RB32(st->codec->extradata+12);",
"st->codec->channels = AV_RB8 (st->codec->extradata+21);",
"}",
"break;",
"default:\nbreak;",
"}",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55,
57,
59,
61
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125,
127,
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189,
191
],
[
195
],
[
197
],
[
203,
205
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255,
257
],
[
259,
261
],
[
263,
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
365
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407
],
[
409
],
[
413
],
[
415,
417,
419,
421
],
[
423
],
[
425,
427,
429,
431
],
[
433,
435,
437,
439
],
[
441
],
[
445,
447
],
[
449
],
[
451
],
[
453,
455
],
[
457
],
[
459
],
[
461,
463
],
[
465
],
[
467
],
[
469,
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
501
],
[
503,
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
519
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533
],
[
535
],
[
539,
541
],
[
547
],
[
549,
551,
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571,
575,
579,
581
],
[
583
],
[
585
],
[
587
],
[
589,
591,
593
],
[
595
],
[
599,
601
],
[
603,
605
],
[
607
],
[
609,
611,
613
],
[
615
],
[
617
],
[
619,
621,
623,
625
],
[
627
],
[
629,
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641,
643
],
[
645
],
[
649
],
[
651
]
]
|
16,655 | void rgb15tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | void rgb15tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
}
}
| {
"code": [
"void rgb15tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)"
],
"line_no": [
1
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)
{
const uint16_t *VAR_3;
uint8_t *d = (uint8_t *)VAR_1;
const uint16_t *VAR_4 = (uint16_t *)VAR_0;
VAR_3 = VAR_4 + VAR_2/2;
while(VAR_4 < VAR_3)
{
register uint16_t VAR_5;
VAR_5 = *VAR_4++;
*d++ = (VAR_5&0x7C00)>>7;
*d++ = (VAR_5&0x3E0)>>2;
*d++ = (VAR_5&0x1F)<<3;
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)\n{",
"const uint16_t *VAR_3;",
"uint8_t *d = (uint8_t *)VAR_1;",
"const uint16_t *VAR_4 = (uint16_t *)VAR_0;",
"VAR_3 = VAR_4 + VAR_2/2;",
"while(VAR_4 < VAR_3)\n{",
"register uint16_t VAR_5;",
"VAR_5 = *VAR_4++;",
"*d++ = (VAR_5&0x7C00)>>7;",
"*d++ = (VAR_5&0x3E0)>>2;",
"*d++ = (VAR_5&0x1F)<<3;",
"}",
"}"
]
| [
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
]
]
|
16,656 | int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
{
BufferSinkContext *s = ctx->priv;
AVFilterLink *link = ctx->inputs[0];
AVFrame *cur_frame;
int ret = 0;
if (!s->audio_fifo) {
int nb_channels = link->channels;
if (!(s->audio_fifo = av_audio_fifo_alloc(link->format, nb_channels, nb_samples)))
return AVERROR(ENOMEM);
}
while (ret >= 0) {
if (av_audio_fifo_size(s->audio_fifo) >= nb_samples)
return read_from_fifo(ctx, frame, nb_samples);
if (!(cur_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
ret = av_buffersink_get_frame_flags(ctx, cur_frame, 0);
if (ret == AVERROR_EOF && av_audio_fifo_size(s->audio_fifo)) {
av_frame_free(&cur_frame);
return read_from_fifo(ctx, frame, av_audio_fifo_size(s->audio_fifo));
} else if (ret < 0) {
av_frame_free(&cur_frame);
return ret;
}
if (cur_frame->pts != AV_NOPTS_VALUE) {
s->next_pts = cur_frame->pts -
av_rescale_q(av_audio_fifo_size(s->audio_fifo),
(AVRational){ 1, link->sample_rate },
link->time_base);
}
ret = av_audio_fifo_write(s->audio_fifo, (void**)cur_frame->extended_data,
cur_frame->nb_samples);
av_frame_free(&cur_frame);
}
return ret;
}
| true | FFmpeg | d8dccf69ff2df7014a2bb8e0e17828a820f45b27 | int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
{
BufferSinkContext *s = ctx->priv;
AVFilterLink *link = ctx->inputs[0];
AVFrame *cur_frame;
int ret = 0;
if (!s->audio_fifo) {
int nb_channels = link->channels;
if (!(s->audio_fifo = av_audio_fifo_alloc(link->format, nb_channels, nb_samples)))
return AVERROR(ENOMEM);
}
while (ret >= 0) {
if (av_audio_fifo_size(s->audio_fifo) >= nb_samples)
return read_from_fifo(ctx, frame, nb_samples);
if (!(cur_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
ret = av_buffersink_get_frame_flags(ctx, cur_frame, 0);
if (ret == AVERROR_EOF && av_audio_fifo_size(s->audio_fifo)) {
av_frame_free(&cur_frame);
return read_from_fifo(ctx, frame, av_audio_fifo_size(s->audio_fifo));
} else if (ret < 0) {
av_frame_free(&cur_frame);
return ret;
}
if (cur_frame->pts != AV_NOPTS_VALUE) {
s->next_pts = cur_frame->pts -
av_rescale_q(av_audio_fifo_size(s->audio_fifo),
(AVRational){ 1, link->sample_rate },
link->time_base);
}
ret = av_audio_fifo_write(s->audio_fifo, (void**)cur_frame->extended_data,
cur_frame->nb_samples);
av_frame_free(&cur_frame);
}
return ret;
}
| {
"code": [
"int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)"
],
"line_no": [
1
]
} | int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1, int VAR_2)
{
BufferSinkContext *s = VAR_0->priv;
AVFilterLink *link = VAR_0->inputs[0];
AVFrame *cur_frame;
int VAR_3 = 0;
if (!s->audio_fifo) {
int VAR_4 = link->channels;
if (!(s->audio_fifo = av_audio_fifo_alloc(link->format, VAR_4, VAR_2)))
return AVERROR(ENOMEM);
}
while (VAR_3 >= 0) {
if (av_audio_fifo_size(s->audio_fifo) >= VAR_2)
return read_from_fifo(VAR_0, VAR_1, VAR_2);
if (!(cur_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
VAR_3 = av_buffersink_get_frame_flags(VAR_0, cur_frame, 0);
if (VAR_3 == AVERROR_EOF && av_audio_fifo_size(s->audio_fifo)) {
av_frame_free(&cur_frame);
return read_from_fifo(VAR_0, VAR_1, av_audio_fifo_size(s->audio_fifo));
} else if (VAR_3 < 0) {
av_frame_free(&cur_frame);
return VAR_3;
}
if (cur_frame->pts != AV_NOPTS_VALUE) {
s->next_pts = cur_frame->pts -
av_rescale_q(av_audio_fifo_size(s->audio_fifo),
(AVRational){ 1, link->sample_rate },
link->time_base);
}
VAR_3 = av_audio_fifo_write(s->audio_fifo, (void**)cur_frame->extended_data,
cur_frame->VAR_2);
av_frame_free(&cur_frame);
}
return VAR_3;
}
| [
"int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1, int VAR_2)\n{",
"BufferSinkContext *s = VAR_0->priv;",
"AVFilterLink *link = VAR_0->inputs[0];",
"AVFrame *cur_frame;",
"int VAR_3 = 0;",
"if (!s->audio_fifo) {",
"int VAR_4 = link->channels;",
"if (!(s->audio_fifo = av_audio_fifo_alloc(link->format, VAR_4, VAR_2)))\nreturn AVERROR(ENOMEM);",
"}",
"while (VAR_3 >= 0) {",
"if (av_audio_fifo_size(s->audio_fifo) >= VAR_2)\nreturn read_from_fifo(VAR_0, VAR_1, VAR_2);",
"if (!(cur_frame = av_frame_alloc()))\nreturn AVERROR(ENOMEM);",
"VAR_3 = av_buffersink_get_frame_flags(VAR_0, cur_frame, 0);",
"if (VAR_3 == AVERROR_EOF && av_audio_fifo_size(s->audio_fifo)) {",
"av_frame_free(&cur_frame);",
"return read_from_fifo(VAR_0, VAR_1, av_audio_fifo_size(s->audio_fifo));",
"} else if (VAR_3 < 0) {",
"av_frame_free(&cur_frame);",
"return VAR_3;",
"}",
"if (cur_frame->pts != AV_NOPTS_VALUE) {",
"s->next_pts = cur_frame->pts -\nav_rescale_q(av_audio_fifo_size(s->audio_fifo),\n(AVRational){ 1, link->sample_rate },",
"link->time_base);",
"}",
"VAR_3 = av_audio_fifo_write(s->audio_fifo, (void**)cur_frame->extended_data,\ncur_frame->VAR_2);",
"av_frame_free(&cur_frame);",
"}",
"return VAR_3;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29,
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59,
61,
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
81
],
[
85
]
]
|
16,657 | static int rtsp_parse_request(HTTPContext *c)
{
const char *p, *p1, *p2;
char cmd[32];
char url[1024];
char protocol[32];
char line[1024];
int len;
RTSPMessageHeader header1, *header = &header1;
c->buffer_ptr[0] = '\0';
p = c->buffer;
get_word(cmd, sizeof(cmd), &p);
get_word(url, sizeof(url), &p);
get_word(protocol, sizeof(protocol), &p);
av_strlcpy(c->method, cmd, sizeof(c->method));
av_strlcpy(c->url, url, sizeof(c->url));
av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
if (url_open_dyn_buf(&c->pb) < 0) {
/* XXX: cannot do more */
c->pb = NULL; /* safety */
return -1;
}
/* check version name */
if (strcmp(protocol, "RTSP/1.0") != 0) {
rtsp_reply_error(c, RTSP_STATUS_VERSION);
goto the_end;
}
/* parse each header line */
memset(header, 0, sizeof(*header));
/* skip to next line */
while (*p != '\n' && *p != '\0')
p++;
if (*p == '\n')
p++;
while (*p != '\0') {
p1 = strchr(p, '\n');
if (!p1)
break;
p2 = p1;
if (p2 > p && p2[-1] == '\r')
p2--;
/* skip empty line */
if (p2 == p)
break;
len = p2 - p;
if (len > sizeof(line) - 1)
len = sizeof(line) - 1;
memcpy(line, p, len);
line[len] = '\0';
ff_rtsp_parse_line(header, line, NULL);
p = p1 + 1;
}
/* handle sequence number */
c->seq = header->seq;
if (!strcmp(cmd, "DESCRIBE"))
rtsp_cmd_describe(c, url);
else if (!strcmp(cmd, "OPTIONS"))
rtsp_cmd_options(c, url);
else if (!strcmp(cmd, "SETUP"))
rtsp_cmd_setup(c, url, header);
else if (!strcmp(cmd, "PLAY"))
rtsp_cmd_play(c, url, header);
else if (!strcmp(cmd, "PAUSE"))
rtsp_cmd_pause(c, url, header);
else if (!strcmp(cmd, "TEARDOWN"))
rtsp_cmd_teardown(c, url, header);
else
rtsp_reply_error(c, RTSP_STATUS_METHOD);
the_end:
len = url_close_dyn_buf(c->pb, &c->pb_buffer);
c->pb = NULL; /* safety */
if (len < 0) {
/* XXX: cannot do more */
return -1;
}
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
c->state = RTSPSTATE_SEND_REPLY;
return 0;
}
| true | FFmpeg | c966c91279f8bca0f1d4865779519b077a2221f0 | static int rtsp_parse_request(HTTPContext *c)
{
const char *p, *p1, *p2;
char cmd[32];
char url[1024];
char protocol[32];
char line[1024];
int len;
RTSPMessageHeader header1, *header = &header1;
c->buffer_ptr[0] = '\0';
p = c->buffer;
get_word(cmd, sizeof(cmd), &p);
get_word(url, sizeof(url), &p);
get_word(protocol, sizeof(protocol), &p);
av_strlcpy(c->method, cmd, sizeof(c->method));
av_strlcpy(c->url, url, sizeof(c->url));
av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
if (url_open_dyn_buf(&c->pb) < 0) {
c->pb = NULL;
return -1;
}
if (strcmp(protocol, "RTSP/1.0") != 0) {
rtsp_reply_error(c, RTSP_STATUS_VERSION);
goto the_end;
}
memset(header, 0, sizeof(*header));
while (*p != '\n' && *p != '\0')
p++;
if (*p == '\n')
p++;
while (*p != '\0') {
p1 = strchr(p, '\n');
if (!p1)
break;
p2 = p1;
if (p2 > p && p2[-1] == '\r')
p2--;
if (p2 == p)
break;
len = p2 - p;
if (len > sizeof(line) - 1)
len = sizeof(line) - 1;
memcpy(line, p, len);
line[len] = '\0';
ff_rtsp_parse_line(header, line, NULL);
p = p1 + 1;
}
c->seq = header->seq;
if (!strcmp(cmd, "DESCRIBE"))
rtsp_cmd_describe(c, url);
else if (!strcmp(cmd, "OPTIONS"))
rtsp_cmd_options(c, url);
else if (!strcmp(cmd, "SETUP"))
rtsp_cmd_setup(c, url, header);
else if (!strcmp(cmd, "PLAY"))
rtsp_cmd_play(c, url, header);
else if (!strcmp(cmd, "PAUSE"))
rtsp_cmd_pause(c, url, header);
else if (!strcmp(cmd, "TEARDOWN"))
rtsp_cmd_teardown(c, url, header);
else
rtsp_reply_error(c, RTSP_STATUS_METHOD);
the_end:
len = url_close_dyn_buf(c->pb, &c->pb_buffer);
c->pb = NULL;
if (len < 0) {
return -1;
}
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
c->state = RTSPSTATE_SEND_REPLY;
return 0;
}
| {
"code": [
" p1 = strchr(p, '\\n');"
],
"line_no": [
83
]
} | static int FUNC_0(HTTPContext *VAR_0)
{
const char *VAR_1, *VAR_2, *VAR_3;
char VAR_4[32];
char VAR_5[1024];
char VAR_6[32];
char VAR_7[1024];
int VAR_8;
RTSPMessageHeader header1, *header = &header1;
VAR_0->buffer_ptr[0] = '\0';
VAR_1 = VAR_0->buffer;
get_word(VAR_4, sizeof(VAR_4), &VAR_1);
get_word(VAR_5, sizeof(VAR_5), &VAR_1);
get_word(VAR_6, sizeof(VAR_6), &VAR_1);
av_strlcpy(VAR_0->method, VAR_4, sizeof(VAR_0->method));
av_strlcpy(VAR_0->VAR_5, VAR_5, sizeof(VAR_0->VAR_5));
av_strlcpy(VAR_0->VAR_6, VAR_6, sizeof(VAR_0->VAR_6));
if (url_open_dyn_buf(&VAR_0->pb) < 0) {
VAR_0->pb = NULL;
return -1;
}
if (strcmp(VAR_6, "RTSP/1.0") != 0) {
rtsp_reply_error(VAR_0, RTSP_STATUS_VERSION);
goto the_end;
}
memset(header, 0, sizeof(*header));
while (*VAR_1 != '\n' && *VAR_1 != '\0')
VAR_1++;
if (*VAR_1 == '\n')
VAR_1++;
while (*VAR_1 != '\0') {
VAR_2 = strchr(VAR_1, '\n');
if (!VAR_2)
break;
VAR_3 = VAR_2;
if (VAR_3 > VAR_1 && VAR_3[-1] == '\r')
VAR_3--;
if (VAR_3 == VAR_1)
break;
VAR_8 = VAR_3 - VAR_1;
if (VAR_8 > sizeof(VAR_7) - 1)
VAR_8 = sizeof(VAR_7) - 1;
memcpy(VAR_7, VAR_1, VAR_8);
VAR_7[VAR_8] = '\0';
ff_rtsp_parse_line(header, VAR_7, NULL);
VAR_1 = VAR_2 + 1;
}
VAR_0->seq = header->seq;
if (!strcmp(VAR_4, "DESCRIBE"))
rtsp_cmd_describe(VAR_0, VAR_5);
else if (!strcmp(VAR_4, "OPTIONS"))
rtsp_cmd_options(VAR_0, VAR_5);
else if (!strcmp(VAR_4, "SETUP"))
rtsp_cmd_setup(VAR_0, VAR_5, header);
else if (!strcmp(VAR_4, "PLAY"))
rtsp_cmd_play(VAR_0, VAR_5, header);
else if (!strcmp(VAR_4, "PAUSE"))
rtsp_cmd_pause(VAR_0, VAR_5, header);
else if (!strcmp(VAR_4, "TEARDOWN"))
rtsp_cmd_teardown(VAR_0, VAR_5, header);
else
rtsp_reply_error(VAR_0, RTSP_STATUS_METHOD);
the_end:
VAR_8 = url_close_dyn_buf(VAR_0->pb, &VAR_0->pb_buffer);
VAR_0->pb = NULL;
if (VAR_8 < 0) {
return -1;
}
VAR_0->buffer_ptr = VAR_0->pb_buffer;
VAR_0->buffer_end = VAR_0->pb_buffer + VAR_8;
VAR_0->state = RTSPSTATE_SEND_REPLY;
return 0;
}
| [
"static int FUNC_0(HTTPContext *VAR_0)\n{",
"const char *VAR_1, *VAR_2, *VAR_3;",
"char VAR_4[32];",
"char VAR_5[1024];",
"char VAR_6[32];",
"char VAR_7[1024];",
"int VAR_8;",
"RTSPMessageHeader header1, *header = &header1;",
"VAR_0->buffer_ptr[0] = '\\0';",
"VAR_1 = VAR_0->buffer;",
"get_word(VAR_4, sizeof(VAR_4), &VAR_1);",
"get_word(VAR_5, sizeof(VAR_5), &VAR_1);",
"get_word(VAR_6, sizeof(VAR_6), &VAR_1);",
"av_strlcpy(VAR_0->method, VAR_4, sizeof(VAR_0->method));",
"av_strlcpy(VAR_0->VAR_5, VAR_5, sizeof(VAR_0->VAR_5));",
"av_strlcpy(VAR_0->VAR_6, VAR_6, sizeof(VAR_0->VAR_6));",
"if (url_open_dyn_buf(&VAR_0->pb) < 0) {",
"VAR_0->pb = NULL;",
"return -1;",
"}",
"if (strcmp(VAR_6, \"RTSP/1.0\") != 0) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_VERSION);",
"goto the_end;",
"}",
"memset(header, 0, sizeof(*header));",
"while (*VAR_1 != '\\n' && *VAR_1 != '\\0')\nVAR_1++;",
"if (*VAR_1 == '\\n')\nVAR_1++;",
"while (*VAR_1 != '\\0') {",
"VAR_2 = strchr(VAR_1, '\\n');",
"if (!VAR_2)\nbreak;",
"VAR_3 = VAR_2;",
"if (VAR_3 > VAR_1 && VAR_3[-1] == '\\r')\nVAR_3--;",
"if (VAR_3 == VAR_1)\nbreak;",
"VAR_8 = VAR_3 - VAR_1;",
"if (VAR_8 > sizeof(VAR_7) - 1)\nVAR_8 = sizeof(VAR_7) - 1;",
"memcpy(VAR_7, VAR_1, VAR_8);",
"VAR_7[VAR_8] = '\\0';",
"ff_rtsp_parse_line(header, VAR_7, NULL);",
"VAR_1 = VAR_2 + 1;",
"}",
"VAR_0->seq = header->seq;",
"if (!strcmp(VAR_4, \"DESCRIBE\"))\nrtsp_cmd_describe(VAR_0, VAR_5);",
"else if (!strcmp(VAR_4, \"OPTIONS\"))\nrtsp_cmd_options(VAR_0, VAR_5);",
"else if (!strcmp(VAR_4, \"SETUP\"))\nrtsp_cmd_setup(VAR_0, VAR_5, header);",
"else if (!strcmp(VAR_4, \"PLAY\"))\nrtsp_cmd_play(VAR_0, VAR_5, header);",
"else if (!strcmp(VAR_4, \"PAUSE\"))\nrtsp_cmd_pause(VAR_0, VAR_5, header);",
"else if (!strcmp(VAR_4, \"TEARDOWN\"))\nrtsp_cmd_teardown(VAR_0, VAR_5, header);",
"else\nrtsp_reply_error(VAR_0, RTSP_STATUS_METHOD);",
"the_end:\nVAR_8 = url_close_dyn_buf(VAR_0->pb, &VAR_0->pb_buffer);",
"VAR_0->pb = NULL;",
"if (VAR_8 < 0) {",
"return -1;",
"}",
"VAR_0->buffer_ptr = VAR_0->pb_buffer;",
"VAR_0->buffer_end = VAR_0->pb_buffer + VAR_8;",
"VAR_0->state = RTSPSTATE_SEND_REPLY;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
125,
127
],
[
129,
131
],
[
133,
135
],
[
137,
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
155,
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
]
]
|
16,658 | void cpu_dump_state (CPUPPCState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
#endif
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
#endif
);
#endif
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
}
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
/* FSL-specific */
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
/*
* IVORs are left out as they are large and do not change often --
* they can be read with "p $ivor0", "p $ivor1", etc.
*/
}
#if defined(TARGET_PPC64)
if (env->flags & POWERPC_FLAG_CFAR) {
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
}
#endif
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
#if defined(TARGET_PPC64)
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
#endif
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "\n", env->spr[SPR_SDR1]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
}
#endif
#undef RGPL
#undef RFPL
} | true | qemu | 29979a8d2596d33b474c11efb376ed47ba1d44d3 | void cpu_dump_state (CPUPPCState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
#endif
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
#endif
);
#endif
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
}
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
}
#if defined(TARGET_PPC64)
if (env->flags & POWERPC_FLAG_CFAR) {
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
}
#endif
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
#if defined(TARGET_PPC64)
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
#endif
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "\n", env->spr[SPR_SDR1]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
}
#endif
#undef RGPL
#undef RFPL
} | {
"code": [],
"line_no": []
} | void FUNC_0 (CPUPPCState *VAR_0, FILE *VAR_1, fprintf_function VAR_2,
int VAR_3)
{
#define RGPL 4
#define RFPL 4
int VAR_4;
VAR_2(VAR_1, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
VAR_0->nip, VAR_0->lr, VAR_0->ctr, VAR_0->xer);
VAR_2(VAR_1, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", VAR_0->msr, VAR_0->spr[SPR_HID0],
VAR_0->hflags, VAR_0->mmu_idx);
#if !defined(NO_TIMER_DUMP)
VAR_2(VAR_1, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
#endif
"\n",
cpu_ppc_load_tbu(VAR_0), cpu_ppc_load_tbl(VAR_0)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(VAR_0)
#endif
);
#endif
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if ((VAR_4 & (RGPL - 1)) == 0)
VAR_2(VAR_1, "GPR%02d", VAR_4);
VAR_2(VAR_1, " %016" PRIx64, ppc_dump_gpr(VAR_0, VAR_4));
if ((VAR_4 & (RGPL - 1)) == (RGPL - 1))
VAR_2(VAR_1, "\n");
}
VAR_2(VAR_1, "CR ");
for (VAR_4 = 0; VAR_4 < 8; VAR_4++)
VAR_2(VAR_1, "%01x", VAR_0->crf[VAR_4]);
VAR_2(VAR_1, " [");
for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {
char VAR_5 = '-';
if (VAR_0->crf[VAR_4] & 0x08)
VAR_5 = 'L';
else if (VAR_0->crf[VAR_4] & 0x04)
VAR_5 = 'G';
else if (VAR_0->crf[VAR_4] & 0x02)
VAR_5 = 'E';
VAR_2(VAR_1, " %c%c", VAR_5, VAR_0->crf[VAR_4] & 0x01 ? 'O' : ' ');
}
VAR_2(VAR_1, " ] RES " TARGET_FMT_lx "\n",
VAR_0->reserve_addr);
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if ((VAR_4 & (RFPL - 1)) == 0)
VAR_2(VAR_1, "FPR%02d", VAR_4);
VAR_2(VAR_1, " %016" PRIx64, *((uint64_t *)&VAR_0->fpr[VAR_4]));
if ((VAR_4 & (RFPL - 1)) == (RFPL - 1))
VAR_2(VAR_1, "\n");
}
VAR_2(VAR_1, "FPSCR %08x\n", VAR_0->fpscr);
#if !defined(CONFIG_USER_ONLY)
VAR_2(VAR_1, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_SRR0], VAR_0->spr[SPR_SRR1],
VAR_0->spr[SPR_PVR], VAR_0->spr[SPR_VRSAVE]);
VAR_2(VAR_1, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_SPRG0], VAR_0->spr[SPR_SPRG1],
VAR_0->spr[SPR_SPRG2], VAR_0->spr[SPR_SPRG3]);
VAR_2(VAR_1, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_SPRG4], VAR_0->spr[SPR_SPRG5],
VAR_0->spr[SPR_SPRG6], VAR_0->spr[SPR_SPRG7]);
if (VAR_0->excp_model == POWERPC_EXCP_BOOKE) {
VAR_2(VAR_1, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_CSRR0], VAR_0->spr[SPR_BOOKE_CSRR1],
VAR_0->spr[SPR_BOOKE_MCSRR0], VAR_0->spr[SPR_BOOKE_MCSRR1]);
VAR_2(VAR_1, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_TCR], VAR_0->spr[SPR_BOOKE_TSR],
VAR_0->spr[SPR_BOOKE_ESR], VAR_0->spr[SPR_BOOKE_DEAR]);
VAR_2(VAR_1, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_PIR], VAR_0->spr[SPR_BOOKE_DECAR],
VAR_0->spr[SPR_BOOKE_IVPR], VAR_0->spr[SPR_BOOKE_EPCR]);
VAR_2(VAR_1, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_MCSR], VAR_0->spr[SPR_BOOKE_SPRG8],
VAR_0->spr[SPR_BOOKE_EPR]);
VAR_2(VAR_1, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_Exxx_MCAR], VAR_0->spr[SPR_BOOKE_PID1],
VAR_0->spr[SPR_BOOKE_PID2], VAR_0->spr[SPR_E500_SVR]);
}
#if defined(TARGET_PPC64)
if (VAR_0->VAR_3 & POWERPC_FLAG_CFAR) {
VAR_2(VAR_1, " CFAR " TARGET_FMT_lx"\n", VAR_0->cfar);
}
#endif
switch (VAR_0->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
#if defined(TARGET_PPC64)
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
#endif
VAR_2(VAR_1, " SDR1 " TARGET_FMT_lx "\n", VAR_0->spr[SPR_SDR1]);
break;
case POWERPC_MMU_BOOKE206:
VAR_2(VAR_1, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_MAS0], VAR_0->spr[SPR_BOOKE_MAS1],
VAR_0->spr[SPR_BOOKE_MAS2], VAR_0->spr[SPR_BOOKE_MAS3]);
VAR_2(VAR_1, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_BOOKE_MAS4], VAR_0->spr[SPR_BOOKE_MAS6],
VAR_0->spr[SPR_BOOKE_MAS7], VAR_0->spr[SPR_BOOKE_PID]);
VAR_2(VAR_1, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
VAR_0->spr[SPR_MMUCFG], VAR_0->spr[SPR_BOOKE_TLB0CFG],
VAR_0->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
}
#endif
#undef RGPL
#undef RFPL
} | [
"void FUNC_0 (CPUPPCState *VAR_0, FILE *VAR_1, fprintf_function VAR_2,\nint VAR_3)\n{",
"#define RGPL 4\n#define RFPL 4\nint VAR_4;",
"VAR_2(VAR_1, \"NIP \" TARGET_FMT_lx \" LR \" TARGET_FMT_lx \" CTR \"\nTARGET_FMT_lx \" XER \" TARGET_FMT_lx \"\\n\",\nVAR_0->nip, VAR_0->lr, VAR_0->ctr, VAR_0->xer);",
"VAR_2(VAR_1, \"MSR \" TARGET_FMT_lx \" HID0 \" TARGET_FMT_lx \" HF \"\nTARGET_FMT_lx \" idx %d\\n\", VAR_0->msr, VAR_0->spr[SPR_HID0],\nVAR_0->hflags, VAR_0->mmu_idx);",
"#if !defined(NO_TIMER_DUMP)\nVAR_2(VAR_1, \"TB %08\" PRIu32 \" %08\" PRIu64\n#if !defined(CONFIG_USER_ONLY)\n\" DECR %08\" PRIu32\n#endif\n\"\\n\",\ncpu_ppc_load_tbu(VAR_0), cpu_ppc_load_tbl(VAR_0)\n#if !defined(CONFIG_USER_ONLY)\n, cpu_ppc_load_decr(VAR_0)\n#endif\n);",
"#endif\nfor (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if ((VAR_4 & (RGPL - 1)) == 0)\nVAR_2(VAR_1, \"GPR%02d\", VAR_4);",
"VAR_2(VAR_1, \" %016\" PRIx64, ppc_dump_gpr(VAR_0, VAR_4));",
"if ((VAR_4 & (RGPL - 1)) == (RGPL - 1))\nVAR_2(VAR_1, \"\\n\");",
"}",
"VAR_2(VAR_1, \"CR \");",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++)",
"VAR_2(VAR_1, \"%01x\", VAR_0->crf[VAR_4]);",
"VAR_2(VAR_1, \" [\");",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {",
"char VAR_5 = '-';",
"if (VAR_0->crf[VAR_4] & 0x08)\nVAR_5 = 'L';",
"else if (VAR_0->crf[VAR_4] & 0x04)\nVAR_5 = 'G';",
"else if (VAR_0->crf[VAR_4] & 0x02)\nVAR_5 = 'E';",
"VAR_2(VAR_1, \" %c%c\", VAR_5, VAR_0->crf[VAR_4] & 0x01 ? 'O' : ' ');",
"}",
"VAR_2(VAR_1, \" ] RES \" TARGET_FMT_lx \"\\n\",\nVAR_0->reserve_addr);",
"for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if ((VAR_4 & (RFPL - 1)) == 0)\nVAR_2(VAR_1, \"FPR%02d\", VAR_4);",
"VAR_2(VAR_1, \" %016\" PRIx64, *((uint64_t *)&VAR_0->fpr[VAR_4]));",
"if ((VAR_4 & (RFPL - 1)) == (RFPL - 1))\nVAR_2(VAR_1, \"\\n\");",
"}",
"VAR_2(VAR_1, \"FPSCR %08x\\n\", VAR_0->fpscr);",
"#if !defined(CONFIG_USER_ONLY)\nVAR_2(VAR_1, \" SRR0 \" TARGET_FMT_lx \" SRR1 \" TARGET_FMT_lx\n\" PVR \" TARGET_FMT_lx \" VRSAVE \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_SRR0], VAR_0->spr[SPR_SRR1],\nVAR_0->spr[SPR_PVR], VAR_0->spr[SPR_VRSAVE]);",
"VAR_2(VAR_1, \"SPRG0 \" TARGET_FMT_lx \" SPRG1 \" TARGET_FMT_lx\n\" SPRG2 \" TARGET_FMT_lx \" SPRG3 \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_SPRG0], VAR_0->spr[SPR_SPRG1],\nVAR_0->spr[SPR_SPRG2], VAR_0->spr[SPR_SPRG3]);",
"VAR_2(VAR_1, \"SPRG4 \" TARGET_FMT_lx \" SPRG5 \" TARGET_FMT_lx\n\" SPRG6 \" TARGET_FMT_lx \" SPRG7 \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_SPRG4], VAR_0->spr[SPR_SPRG5],\nVAR_0->spr[SPR_SPRG6], VAR_0->spr[SPR_SPRG7]);",
"if (VAR_0->excp_model == POWERPC_EXCP_BOOKE) {",
"VAR_2(VAR_1, \"CSRR0 \" TARGET_FMT_lx \" CSRR1 \" TARGET_FMT_lx\n\" MCSRR0 \" TARGET_FMT_lx \" MCSRR1 \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_CSRR0], VAR_0->spr[SPR_BOOKE_CSRR1],\nVAR_0->spr[SPR_BOOKE_MCSRR0], VAR_0->spr[SPR_BOOKE_MCSRR1]);",
"VAR_2(VAR_1, \" TCR \" TARGET_FMT_lx \" TSR \" TARGET_FMT_lx\n\" ESR \" TARGET_FMT_lx \" DEAR \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_TCR], VAR_0->spr[SPR_BOOKE_TSR],\nVAR_0->spr[SPR_BOOKE_ESR], VAR_0->spr[SPR_BOOKE_DEAR]);",
"VAR_2(VAR_1, \" PIR \" TARGET_FMT_lx \" DECAR \" TARGET_FMT_lx\n\" IVPR \" TARGET_FMT_lx \" EPCR \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_PIR], VAR_0->spr[SPR_BOOKE_DECAR],\nVAR_0->spr[SPR_BOOKE_IVPR], VAR_0->spr[SPR_BOOKE_EPCR]);",
"VAR_2(VAR_1, \" MCSR \" TARGET_FMT_lx \" SPRG8 \" TARGET_FMT_lx\n\" EPR \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_MCSR], VAR_0->spr[SPR_BOOKE_SPRG8],\nVAR_0->spr[SPR_BOOKE_EPR]);",
"VAR_2(VAR_1, \" MCAR \" TARGET_FMT_lx \" PID1 \" TARGET_FMT_lx\n\" PID2 \" TARGET_FMT_lx \" SVR \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_Exxx_MCAR], VAR_0->spr[SPR_BOOKE_PID1],\nVAR_0->spr[SPR_BOOKE_PID2], VAR_0->spr[SPR_E500_SVR]);",
"}",
"#if defined(TARGET_PPC64)\nif (VAR_0->VAR_3 & POWERPC_FLAG_CFAR) {",
"VAR_2(VAR_1, \" CFAR \" TARGET_FMT_lx\"\\n\", VAR_0->cfar);",
"}",
"#endif\nswitch (VAR_0->mmu_model) {",
"case POWERPC_MMU_32B:\ncase POWERPC_MMU_601:\ncase POWERPC_MMU_SOFT_6xx:\ncase POWERPC_MMU_SOFT_74xx:\n#if defined(TARGET_PPC64)\ncase POWERPC_MMU_620:\ncase POWERPC_MMU_64B:\n#endif\nVAR_2(VAR_1, \" SDR1 \" TARGET_FMT_lx \"\\n\", VAR_0->spr[SPR_SDR1]);",
"break;",
"case POWERPC_MMU_BOOKE206:\nVAR_2(VAR_1, \" MAS0 \" TARGET_FMT_lx \" MAS1 \" TARGET_FMT_lx\n\" MAS2 \" TARGET_FMT_lx \" MAS3 \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_MAS0], VAR_0->spr[SPR_BOOKE_MAS1],\nVAR_0->spr[SPR_BOOKE_MAS2], VAR_0->spr[SPR_BOOKE_MAS3]);",
"VAR_2(VAR_1, \" MAS4 \" TARGET_FMT_lx \" MAS6 \" TARGET_FMT_lx\n\" MAS7 \" TARGET_FMT_lx \" PID \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_BOOKE_MAS4], VAR_0->spr[SPR_BOOKE_MAS6],\nVAR_0->spr[SPR_BOOKE_MAS7], VAR_0->spr[SPR_BOOKE_PID]);",
"VAR_2(VAR_1, \"MMUCFG \" TARGET_FMT_lx \" TLB0CFG \" TARGET_FMT_lx\n\" TLB1CFG \" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_MMUCFG], VAR_0->spr[SPR_BOOKE_TLB0CFG],\nVAR_0->spr[SPR_BOOKE_TLB1CFG]);",
"break;",
"default:\nbreak;",
"}",
"#endif\n#undef RGPL\n#undef RFPL\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
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,
47
],
[
48
],
[
49,
50
],
[
51
],
[
52,
53
],
[
54
],
[
55
],
[
56,
57,
58,
59,
60
],
[
61,
62,
63,
64
],
[
65,
66,
67,
68
],
[
69
],
[
70,
71,
72,
73
],
[
74,
75,
76,
77
],
[
78,
79,
80,
81
],
[
82,
83,
84,
85
],
[
87,
88,
89,
90
],
[
95
],
[
96,
97
],
[
98
],
[
99
],
[
100,
101
],
[
102,
103,
104,
105,
106,
107,
108,
109,
110
],
[
111
],
[
112,
113,
114,
115,
116
],
[
117,
118,
119,
120
],
[
121,
122,
123,
124
],
[
125
],
[
126,
127
],
[
128
],
[
129,
130,
131,
132
]
]
|
16,661 | pvscsi_init_msi(PVSCSIState *s)
{
int res;
PCIDevice *d = PCI_DEVICE(s);
res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);
if (res < 0) {
trace_pvscsi_init_msi_fail(res);
s->msi_used = false;
} else {
s->msi_used = true;
}
}
| true | qemu | 1108b2f8a939fb5778d384149e2f1b99062a72da | pvscsi_init_msi(PVSCSIState *s)
{
int res;
PCIDevice *d = PCI_DEVICE(s);
res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);
if (res < 0) {
trace_pvscsi_init_msi_fail(res);
s->msi_used = false;
} else {
s->msi_used = true;
}
}
| {
"code": [
" PCIDevice *d = PCI_DEVICE(s);",
" int res;",
" s->msi_used = false;",
" } else {",
" s->msi_used = true;",
" PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);"
],
"line_no": [
7,
5,
19,
21,
23,
13
]
} | FUNC_0(PVSCSIState *VAR_0)
{
int VAR_1;
PCIDevice *d = PCI_DEVICE(VAR_0);
VAR_1 = msi_init(d, PVSCSI_MSI_OFFSET(VAR_0), PVSCSI_MSIX_NUM_VECTORS,
PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);
if (VAR_1 < 0) {
trace_pvscsi_init_msi_fail(VAR_1);
VAR_0->msi_used = false;
} else {
VAR_0->msi_used = true;
}
}
| [
"FUNC_0(PVSCSIState *VAR_0)\n{",
"int VAR_1;",
"PCIDevice *d = PCI_DEVICE(VAR_0);",
"VAR_1 = msi_init(d, PVSCSI_MSI_OFFSET(VAR_0), PVSCSI_MSIX_NUM_VECTORS,\nPVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);",
"if (VAR_1 < 0) {",
"trace_pvscsi_init_msi_fail(VAR_1);",
"VAR_0->msi_used = false;",
"} else {",
"VAR_0->msi_used = true;",
"}",
"}"
]
| [
0,
1,
1,
1,
0,
0,
1,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
16,662 | static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC])
{
#if USE_FIXED
par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \
0x40000000) >> 31);
par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \
0x40000000) >> 31);
par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \
0x40000000) >> 31);
par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \
0x40000000) >> 31);
#else
par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
#endif /* USE_FIXED */
par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]);
par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]);
par[ 6] = par[10];
par[ 7] = par[11];
par[ 8] = AAC_HALF_SUM(par[12], par[13]);
par[ 9] = AAC_HALF_SUM(par[14], par[15]);
par[10] = par[16];
par[11] = par[17];
par[12] = par[18];
par[13] = par[19];
par[14] = AAC_HALF_SUM(par[20], par[21]);
par[15] = AAC_HALF_SUM(par[22], par[23]);
par[16] = AAC_HALF_SUM(par[24], par[25]);
par[17] = AAC_HALF_SUM(par[26], par[27]);
#if USE_FIXED
par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2));
#else
par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
#endif /* USE_FIXED */
par[19] = AAC_HALF_SUM(par[32], par[33]);
}
| true | FFmpeg | 0764fe1d09833ae4dcf9e427df09378d0d6a3386 | static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC])
{
#if USE_FIXED
par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \
0x40000000) >> 31);
par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \
0x40000000) >> 31);
par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \
0x40000000) >> 31);
par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \
0x40000000) >> 31);
#else
par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
#endif
par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]);
par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]);
par[ 6] = par[10];
par[ 7] = par[11];
par[ 8] = AAC_HALF_SUM(par[12], par[13]);
par[ 9] = AAC_HALF_SUM(par[14], par[15]);
par[10] = par[16];
par[11] = par[17];
par[12] = par[18];
par[13] = par[19];
par[14] = AAC_HALF_SUM(par[20], par[21]);
par[15] = AAC_HALF_SUM(par[22], par[23]);
par[16] = AAC_HALF_SUM(par[24], par[25]);
par[17] = AAC_HALF_SUM(par[26], par[27]);
#if USE_FIXED
par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2));
#else
par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
#endif
par[19] = AAC_HALF_SUM(par[32], par[33]);
}
| {
"code": [
" par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \\",
" par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \\",
" par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \\",
" par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \\"
],
"line_no": [
7,
11,
15,
19
]
} | static void FUNC_0(INTFLOAT VAR_0[PS_MAX_NR_IIDICC])
{
#if USE_FIXED
VAR_0[ 0] = (int)(((int64_t)(VAR_0[ 0] + (VAR_0[ 1]>>1)) * 1431655765 + \
0x40000000) >> 31);
VAR_0[ 1] = (int)(((int64_t)((VAR_0[ 1]>>1) + VAR_0[ 2]) * 1431655765 + \
0x40000000) >> 31);
VAR_0[ 2] = (int)(((int64_t)(VAR_0[ 3] + (VAR_0[ 4]>>1)) * 1431655765 + \
0x40000000) >> 31);
VAR_0[ 3] = (int)(((int64_t)((VAR_0[ 4]>>1) + VAR_0[ 5]) * 1431655765 + \
0x40000000) >> 31);
#else
VAR_0[ 0] = (2*VAR_0[ 0] + VAR_0[ 1]) * 0.33333333f;
VAR_0[ 1] = ( VAR_0[ 1] + 2*VAR_0[ 2]) * 0.33333333f;
VAR_0[ 2] = (2*VAR_0[ 3] + VAR_0[ 4]) * 0.33333333f;
VAR_0[ 3] = ( VAR_0[ 4] + 2*VAR_0[ 5]) * 0.33333333f;
#endif
VAR_0[ 4] = AAC_HALF_SUM(VAR_0[ 6], VAR_0[ 7]);
VAR_0[ 5] = AAC_HALF_SUM(VAR_0[ 8], VAR_0[ 9]);
VAR_0[ 6] = VAR_0[10];
VAR_0[ 7] = VAR_0[11];
VAR_0[ 8] = AAC_HALF_SUM(VAR_0[12], VAR_0[13]);
VAR_0[ 9] = AAC_HALF_SUM(VAR_0[14], VAR_0[15]);
VAR_0[10] = VAR_0[16];
VAR_0[11] = VAR_0[17];
VAR_0[12] = VAR_0[18];
VAR_0[13] = VAR_0[19];
VAR_0[14] = AAC_HALF_SUM(VAR_0[20], VAR_0[21]);
VAR_0[15] = AAC_HALF_SUM(VAR_0[22], VAR_0[23]);
VAR_0[16] = AAC_HALF_SUM(VAR_0[24], VAR_0[25]);
VAR_0[17] = AAC_HALF_SUM(VAR_0[26], VAR_0[27]);
#if USE_FIXED
VAR_0[18] = (((VAR_0[28]+2)>>2) + ((VAR_0[29]+2)>>2) + ((VAR_0[30]+2)>>2) + ((VAR_0[31]+2)>>2));
#else
VAR_0[18] = ( VAR_0[28] + VAR_0[29] + VAR_0[30] + VAR_0[31]) * 0.25f;
#endif
VAR_0[19] = AAC_HALF_SUM(VAR_0[32], VAR_0[33]);
}
| [
"static void FUNC_0(INTFLOAT VAR_0[PS_MAX_NR_IIDICC])\n{",
"#if USE_FIXED\nVAR_0[ 0] = (int)(((int64_t)(VAR_0[ 0] + (VAR_0[ 1]>>1)) * 1431655765 + \\\n0x40000000) >> 31);",
"VAR_0[ 1] = (int)(((int64_t)((VAR_0[ 1]>>1) + VAR_0[ 2]) * 1431655765 + \\\n0x40000000) >> 31);",
"VAR_0[ 2] = (int)(((int64_t)(VAR_0[ 3] + (VAR_0[ 4]>>1)) * 1431655765 + \\\n0x40000000) >> 31);",
"VAR_0[ 3] = (int)(((int64_t)((VAR_0[ 4]>>1) + VAR_0[ 5]) * 1431655765 + \\\n0x40000000) >> 31);",
"#else\nVAR_0[ 0] = (2*VAR_0[ 0] + VAR_0[ 1]) * 0.33333333f;",
"VAR_0[ 1] = ( VAR_0[ 1] + 2*VAR_0[ 2]) * 0.33333333f;",
"VAR_0[ 2] = (2*VAR_0[ 3] + VAR_0[ 4]) * 0.33333333f;",
"VAR_0[ 3] = ( VAR_0[ 4] + 2*VAR_0[ 5]) * 0.33333333f;",
"#endif\nVAR_0[ 4] = AAC_HALF_SUM(VAR_0[ 6], VAR_0[ 7]);",
"VAR_0[ 5] = AAC_HALF_SUM(VAR_0[ 8], VAR_0[ 9]);",
"VAR_0[ 6] = VAR_0[10];",
"VAR_0[ 7] = VAR_0[11];",
"VAR_0[ 8] = AAC_HALF_SUM(VAR_0[12], VAR_0[13]);",
"VAR_0[ 9] = AAC_HALF_SUM(VAR_0[14], VAR_0[15]);",
"VAR_0[10] = VAR_0[16];",
"VAR_0[11] = VAR_0[17];",
"VAR_0[12] = VAR_0[18];",
"VAR_0[13] = VAR_0[19];",
"VAR_0[14] = AAC_HALF_SUM(VAR_0[20], VAR_0[21]);",
"VAR_0[15] = AAC_HALF_SUM(VAR_0[22], VAR_0[23]);",
"VAR_0[16] = AAC_HALF_SUM(VAR_0[24], VAR_0[25]);",
"VAR_0[17] = AAC_HALF_SUM(VAR_0[26], VAR_0[27]);",
"#if USE_FIXED\nVAR_0[18] = (((VAR_0[28]+2)>>2) + ((VAR_0[29]+2)>>2) + ((VAR_0[30]+2)>>2) + ((VAR_0[31]+2)>>2));",
"#else\nVAR_0[18] = ( VAR_0[28] + VAR_0[29] + VAR_0[30] + VAR_0[31]) * 0.25f;",
"#endif\nVAR_0[19] = AAC_HALF_SUM(VAR_0[32], VAR_0[33]);",
"}"
]
| [
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
]
| [
[
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
]
]
|
16,663 | GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
bool has_count, int64_t count,
Error **errp)
{
GuestFileWrite *write_data = NULL;
guchar *buf;
gsize buf_len;
int write_count;
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
FILE *fh;
if (!gfh) {
fh = gfh->fh;
buf = g_base64_decode(buf_b64, &buf_len);
if (!has_count) {
count = buf_len;
} else if (count < 0 || count > buf_len) {
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
count);
g_free(buf);
write_count = fwrite(buf, 1, count, fh);
if (ferror(fh)) {
error_setg_errno(errp, errno, "failed to write to file");
slog("guest-file-write failed, handle: %" PRId64, handle);
} else {
write_data = g_new0(GuestFileWrite, 1);
write_data->count = write_count;
write_data->eof = feof(fh);
gfh->state = RW_STATE_WRITING;
g_free(buf);
clearerr(fh);
return write_data; | true | qemu | 895b00f62a7e86724dc7352d67c7808d37366130 | GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
bool has_count, int64_t count,
Error **errp)
{
GuestFileWrite *write_data = NULL;
guchar *buf;
gsize buf_len;
int write_count;
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
FILE *fh;
if (!gfh) {
fh = gfh->fh;
buf = g_base64_decode(buf_b64, &buf_len);
if (!has_count) {
count = buf_len;
} else if (count < 0 || count > buf_len) {
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
count);
g_free(buf);
write_count = fwrite(buf, 1, count, fh);
if (ferror(fh)) {
error_setg_errno(errp, errno, "failed to write to file");
slog("guest-file-write failed, handle: %" PRId64, handle);
} else {
write_data = g_new0(GuestFileWrite, 1);
write_data->count = write_count;
write_data->eof = feof(fh);
gfh->state = RW_STATE_WRITING;
g_free(buf);
clearerr(fh);
return write_data; | {
"code": [],
"line_no": []
} | GuestFileWrite *FUNC_0(int64_t handle, const char *buf_b64,
bool has_count, int64_t count,
Error **errp)
{
GuestFileWrite *write_data = NULL;
guchar *buf;
gsize buf_len;
int VAR_0;
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
FILE *fh;
if (!gfh) {
fh = gfh->fh;
buf = g_base64_decode(buf_b64, &buf_len);
if (!has_count) {
count = buf_len;
} else if (count < 0 || count > buf_len) {
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
count);
g_free(buf);
VAR_0 = fwrite(buf, 1, count, fh);
if (ferror(fh)) {
error_setg_errno(errp, errno, "failed to write to file");
slog("guest-file-write failed, handle: %" PRId64, handle);
} else {
write_data = g_new0(GuestFileWrite, 1);
write_data->count = VAR_0;
write_data->eof = feof(fh);
gfh->state = RW_STATE_WRITING;
g_free(buf);
clearerr(fh);
return write_data; | [
"GuestFileWrite *FUNC_0(int64_t handle, const char *buf_b64,\nbool has_count, int64_t count,\nError **errp)\n{",
"GuestFileWrite *write_data = NULL;",
"guchar *buf;",
"gsize buf_len;",
"int VAR_0;",
"GuestFileHandle *gfh = guest_file_handle_find(handle, errp);",
"FILE *fh;",
"if (!gfh) {",
"fh = gfh->fh;",
"buf = g_base64_decode(buf_b64, &buf_len);",
"if (!has_count) {",
"count = buf_len;",
"} else if (count < 0 || count > buf_len) {",
"error_setg(errp, \"value '%\" PRId64 \"' is invalid for argument count\",\ncount);",
"g_free(buf);",
"VAR_0 = fwrite(buf, 1, count, fh);",
"if (ferror(fh)) {",
"error_setg_errno(errp, errno, \"failed to write to file\");",
"slog(\"guest-file-write failed, handle: %\" PRId64, handle);",
"} else {",
"write_data = g_new0(GuestFileWrite, 1);",
"write_data->count = VAR_0;",
"write_data->eof = feof(fh);",
"gfh->state = RW_STATE_WRITING;",
"g_free(buf);",
"clearerr(fh);",
"return write_data;"
]
| [
0,
0,
0,
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
]
]
|
16,665 | static void fill_picture_parameters(AVCodecContext *avctx,
struct dxva_context *ctx, const VC1Context *v,
DXVA_PictureParameters *pp)
{
const MpegEncContext *s = &v->s;
const Picture *current_picture = s->current_picture_ptr;
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex =
pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, ¤t_picture->f);
if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type)
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type)
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
if (v->profile == PROFILE_ADVANCED) {
/* It is the cropped width/height -1 of the frame */
pp->wPicWidthInMBminus1 = avctx->width - 1;
pp->wPicHeightInMBminus1= avctx->height - 1;
} else {
/* It is the coded width/height in macroblock -1 of the frame */
pp->wPicWidthInMBminus1 = s->mb_width - 1;
pp->wPicHeightInMBminus1= s->mb_height - 1;
}
pp->bMacroblockWidthMinus1 = 15;
pp->bMacroblockHeightMinus1 = 15;
pp->bBlockWidthMinus1 = 7;
pp->bBlockHeightMinus1 = 7;
pp->bBPPminus1 = 7;
if (s->picture_structure & PICT_TOP_FIELD)
pp->bPicStructure |= 0x01;
if (s->picture_structure & PICT_BOTTOM_FIELD)
pp->bPicStructure |= 0x02;
pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field;
pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type;
pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type;
pp->bBidirectionalAveragingMode = (1 << 7) |
((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) |
((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) |
((v->lumscale != 32 || v->lumshift != 0) << 4) |
((v->profile == PROFILE_ADVANCED) << 3);
pp->bMVprecisionAndChromaRelation = ((v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
(1 << 2) |
(0 << 1) |
(!s->quarter_sample );
pp->bChromaFormat = v->chromaformat;
ctx->report_id++;
if (ctx->report_id >= (1 << 16))
ctx->report_id = 1;
pp->bPicScanFixed = ctx->report_id >> 8;
pp->bPicScanMethod = ctx->report_id & 0xff;
pp->bPicReadbackRequests = 0;
pp->bRcontrol = v->rnd;
pp->bPicSpatialResid8 = (v->panscanflag << 7) |
(v->refdist_flag << 6) |
(s->loop_filter << 5) |
(v->fastuvmc << 4) |
(v->extended_mv << 3) |
(v->dquant << 1) |
(v->vstransform );
pp->bPicOverflowBlocks = (v->quantizer_mode << 6) |
(v->multires << 5) |
(v->resync_marker << 4) |
(v->rangered << 3) |
(s->max_b_frames );
pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2;
pp->bPicDeblocked = ((!pp->bPicBackwardPrediction && v->overlap) << 6) |
((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) |
(s->loop_filter << 1);
pp->bPicDeblockConfined = (v->postprocflag << 7) |
(v->broadcast << 6) |
(v->interlace << 5) |
(v->tfcntrflag << 4) |
(v->finterpflag << 3) |
((s->pict_type != AV_PICTURE_TYPE_B) << 2) |
(v->psf << 1) |
(v->extended_dmv );
if (s->pict_type != AV_PICTURE_TYPE_I)
pp->bPic4MVallowed = v->mv_mode == MV_PMODE_MIXED_MV ||
(v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV);
if (v->profile == PROFILE_ADVANCED)
pp->bPicOBMC = (v->range_mapy_flag << 7) |
(v->range_mapy << 4) |
(v->range_mapuv_flag << 3) |
(v->range_mapuv );
pp->bPicBinPB = 0;
pp->bMV_RPS = 0;
pp->bReservedBits = 0;
if (s->picture_structure == PICT_FRAME) {
pp->wBitstreamFcodes = v->lumscale;
pp->wBitstreamPCEelements = v->lumshift;
} else {
/* Syntax: (top_field_param << 8) | bottom_field_param */
pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale;
pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift;
}
pp->bBitstreamConcealmentNeed = 0;
pp->bBitstreamConcealmentMethod = 0;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static void fill_picture_parameters(AVCodecContext *avctx,
struct dxva_context *ctx, const VC1Context *v,
DXVA_PictureParameters *pp)
{
const MpegEncContext *s = &v->s;
const Picture *current_picture = s->current_picture_ptr;
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex =
pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, ¤t_picture->f);
if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type)
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type)
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
if (v->profile == PROFILE_ADVANCED) {
pp->wPicWidthInMBminus1 = avctx->width - 1;
pp->wPicHeightInMBminus1= avctx->height - 1;
} else {
pp->wPicWidthInMBminus1 = s->mb_width - 1;
pp->wPicHeightInMBminus1= s->mb_height - 1;
}
pp->bMacroblockWidthMinus1 = 15;
pp->bMacroblockHeightMinus1 = 15;
pp->bBlockWidthMinus1 = 7;
pp->bBlockHeightMinus1 = 7;
pp->bBPPminus1 = 7;
if (s->picture_structure & PICT_TOP_FIELD)
pp->bPicStructure |= 0x01;
if (s->picture_structure & PICT_BOTTOM_FIELD)
pp->bPicStructure |= 0x02;
pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field;
pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type;
pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type;
pp->bBidirectionalAveragingMode = (1 << 7) |
((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) |
((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) |
((v->lumscale != 32 || v->lumshift != 0) << 4) |
((v->profile == PROFILE_ADVANCED) << 3);
pp->bMVprecisionAndChromaRelation = ((v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
(1 << 2) |
(0 << 1) |
(!s->quarter_sample );
pp->bChromaFormat = v->chromaformat;
ctx->report_id++;
if (ctx->report_id >= (1 << 16))
ctx->report_id = 1;
pp->bPicScanFixed = ctx->report_id >> 8;
pp->bPicScanMethod = ctx->report_id & 0xff;
pp->bPicReadbackRequests = 0;
pp->bRcontrol = v->rnd;
pp->bPicSpatialResid8 = (v->panscanflag << 7) |
(v->refdist_flag << 6) |
(s->loop_filter << 5) |
(v->fastuvmc << 4) |
(v->extended_mv << 3) |
(v->dquant << 1) |
(v->vstransform );
pp->bPicOverflowBlocks = (v->quantizer_mode << 6) |
(v->multires << 5) |
(v->resync_marker << 4) |
(v->rangered << 3) |
(s->max_b_frames );
pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2;
pp->bPicDeblocked = ((!pp->bPicBackwardPrediction && v->overlap) << 6) |
((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) |
(s->loop_filter << 1);
pp->bPicDeblockConfined = (v->postprocflag << 7) |
(v->broadcast << 6) |
(v->interlace << 5) |
(v->tfcntrflag << 4) |
(v->finterpflag << 3) |
((s->pict_type != AV_PICTURE_TYPE_B) << 2) |
(v->psf << 1) |
(v->extended_dmv );
if (s->pict_type != AV_PICTURE_TYPE_I)
pp->bPic4MVallowed = v->mv_mode == MV_PMODE_MIXED_MV ||
(v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV);
if (v->profile == PROFILE_ADVANCED)
pp->bPicOBMC = (v->range_mapy_flag << 7) |
(v->range_mapy << 4) |
(v->range_mapuv_flag << 3) |
(v->range_mapuv );
pp->bPicBinPB = 0;
pp->bMV_RPS = 0;
pp->bReservedBits = 0;
if (s->picture_structure == PICT_FRAME) {
pp->wBitstreamFcodes = v->lumscale;
pp->wBitstreamPCEelements = v->lumshift;
} else {
pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale;
pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift;
}
pp->bBitstreamConcealmentNeed = 0;
pp->bBitstreamConcealmentMethod = 0;
}
| {
"code": [
" pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);",
" pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, ¤t_picture->f);",
" pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);",
" pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);"
],
"line_no": [
31,
19,
23,
31
]
} | static void FUNC_0(AVCodecContext *VAR_0,
struct dxva_context *VAR_1, const VC1Context *VAR_2,
DXVA_PictureParameters *VAR_3)
{
const MpegEncContext *VAR_4 = &VAR_2->VAR_4;
const Picture *VAR_5 = VAR_4->current_picture_ptr;
memset(VAR_3, 0, sizeof(*VAR_3));
VAR_3->wDecodedPictureIndex =
VAR_3->wDeblockedPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_5->f);
if (VAR_4->pict_type != AV_PICTURE_TYPE_I && !VAR_2->bi_type)
VAR_3->wForwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_4->last_picture.f);
else
VAR_3->wForwardRefPictureIndex = 0xffff;
if (VAR_4->pict_type == AV_PICTURE_TYPE_B && !VAR_2->bi_type)
VAR_3->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_4->next_picture.f);
else
VAR_3->wBackwardRefPictureIndex = 0xffff;
if (VAR_2->profile == PROFILE_ADVANCED) {
VAR_3->wPicWidthInMBminus1 = VAR_0->width - 1;
VAR_3->wPicHeightInMBminus1= VAR_0->height - 1;
} else {
VAR_3->wPicWidthInMBminus1 = VAR_4->mb_width - 1;
VAR_3->wPicHeightInMBminus1= VAR_4->mb_height - 1;
}
VAR_3->bMacroblockWidthMinus1 = 15;
VAR_3->bMacroblockHeightMinus1 = 15;
VAR_3->bBlockWidthMinus1 = 7;
VAR_3->bBlockHeightMinus1 = 7;
VAR_3->bBPPminus1 = 7;
if (VAR_4->picture_structure & PICT_TOP_FIELD)
VAR_3->bPicStructure |= 0x01;
if (VAR_4->picture_structure & PICT_BOTTOM_FIELD)
VAR_3->bPicStructure |= 0x02;
VAR_3->bSecondField = VAR_2->interlace && VAR_2->fcm != ILACE_FIELD && !VAR_4->first_field;
VAR_3->bPicIntra = VAR_4->pict_type == AV_PICTURE_TYPE_I || VAR_2->bi_type;
VAR_3->bPicBackwardPrediction = VAR_4->pict_type == AV_PICTURE_TYPE_B && !VAR_2->bi_type;
VAR_3->bBidirectionalAveragingMode = (1 << 7) |
((VAR_1->cfg->ConfigIntraResidUnsigned != 0) << 6) |
((VAR_1->cfg->ConfigResidDiffAccelerator != 0) << 5) |
((VAR_2->lumscale != 32 || VAR_2->lumshift != 0) << 4) |
((VAR_2->profile == PROFILE_ADVANCED) << 3);
VAR_3->bMVprecisionAndChromaRelation = ((VAR_2->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
(1 << 2) |
(0 << 1) |
(!VAR_4->quarter_sample );
VAR_3->bChromaFormat = VAR_2->chromaformat;
VAR_1->report_id++;
if (VAR_1->report_id >= (1 << 16))
VAR_1->report_id = 1;
VAR_3->bPicScanFixed = VAR_1->report_id >> 8;
VAR_3->bPicScanMethod = VAR_1->report_id & 0xff;
VAR_3->bPicReadbackRequests = 0;
VAR_3->bRcontrol = VAR_2->rnd;
VAR_3->bPicSpatialResid8 = (VAR_2->panscanflag << 7) |
(VAR_2->refdist_flag << 6) |
(VAR_4->loop_filter << 5) |
(VAR_2->fastuvmc << 4) |
(VAR_2->extended_mv << 3) |
(VAR_2->dquant << 1) |
(VAR_2->vstransform );
VAR_3->bPicOverflowBlocks = (VAR_2->quantizer_mode << 6) |
(VAR_2->multires << 5) |
(VAR_2->resync_marker << 4) |
(VAR_2->rangered << 3) |
(VAR_4->max_b_frames );
VAR_3->bPicExtrapolation = (!VAR_2->interlace || VAR_2->fcm == PROGRESSIVE) ? 1 : 2;
VAR_3->bPicDeblocked = ((!VAR_3->bPicBackwardPrediction && VAR_2->overlap) << 6) |
((VAR_2->profile != PROFILE_ADVANCED && VAR_2->rangeredfrm) << 5) |
(VAR_4->loop_filter << 1);
VAR_3->bPicDeblockConfined = (VAR_2->postprocflag << 7) |
(VAR_2->broadcast << 6) |
(VAR_2->interlace << 5) |
(VAR_2->tfcntrflag << 4) |
(VAR_2->finterpflag << 3) |
((VAR_4->pict_type != AV_PICTURE_TYPE_B) << 2) |
(VAR_2->psf << 1) |
(VAR_2->extended_dmv );
if (VAR_4->pict_type != AV_PICTURE_TYPE_I)
VAR_3->bPic4MVallowed = VAR_2->mv_mode == MV_PMODE_MIXED_MV ||
(VAR_2->mv_mode == MV_PMODE_INTENSITY_COMP &&
VAR_2->mv_mode2 == MV_PMODE_MIXED_MV);
if (VAR_2->profile == PROFILE_ADVANCED)
VAR_3->bPicOBMC = (VAR_2->range_mapy_flag << 7) |
(VAR_2->range_mapy << 4) |
(VAR_2->range_mapuv_flag << 3) |
(VAR_2->range_mapuv );
VAR_3->bPicBinPB = 0;
VAR_3->bMV_RPS = 0;
VAR_3->bReservedBits = 0;
if (VAR_4->picture_structure == PICT_FRAME) {
VAR_3->wBitstreamFcodes = VAR_2->lumscale;
VAR_3->wBitstreamPCEelements = VAR_2->lumshift;
} else {
VAR_3->wBitstreamFcodes = (VAR_2->lumscale << 8) | VAR_2->lumscale;
VAR_3->wBitstreamPCEelements = (VAR_2->lumshift << 8) | VAR_2->lumshift;
}
VAR_3->bBitstreamConcealmentNeed = 0;
VAR_3->bBitstreamConcealmentMethod = 0;
}
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nstruct dxva_context *VAR_1, const VC1Context *VAR_2,\nDXVA_PictureParameters *VAR_3)\n{",
"const MpegEncContext *VAR_4 = &VAR_2->VAR_4;",
"const Picture *VAR_5 = VAR_4->current_picture_ptr;",
"memset(VAR_3, 0, sizeof(*VAR_3));",
"VAR_3->wDecodedPictureIndex =\nVAR_3->wDeblockedPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_5->f);",
"if (VAR_4->pict_type != AV_PICTURE_TYPE_I && !VAR_2->bi_type)\nVAR_3->wForwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_4->last_picture.f);",
"else\nVAR_3->wForwardRefPictureIndex = 0xffff;",
"if (VAR_4->pict_type == AV_PICTURE_TYPE_B && !VAR_2->bi_type)\nVAR_3->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_4->next_picture.f);",
"else\nVAR_3->wBackwardRefPictureIndex = 0xffff;",
"if (VAR_2->profile == PROFILE_ADVANCED) {",
"VAR_3->wPicWidthInMBminus1 = VAR_0->width - 1;",
"VAR_3->wPicHeightInMBminus1= VAR_0->height - 1;",
"} else {",
"VAR_3->wPicWidthInMBminus1 = VAR_4->mb_width - 1;",
"VAR_3->wPicHeightInMBminus1= VAR_4->mb_height - 1;",
"}",
"VAR_3->bMacroblockWidthMinus1 = 15;",
"VAR_3->bMacroblockHeightMinus1 = 15;",
"VAR_3->bBlockWidthMinus1 = 7;",
"VAR_3->bBlockHeightMinus1 = 7;",
"VAR_3->bBPPminus1 = 7;",
"if (VAR_4->picture_structure & PICT_TOP_FIELD)\nVAR_3->bPicStructure |= 0x01;",
"if (VAR_4->picture_structure & PICT_BOTTOM_FIELD)\nVAR_3->bPicStructure |= 0x02;",
"VAR_3->bSecondField = VAR_2->interlace && VAR_2->fcm != ILACE_FIELD && !VAR_4->first_field;",
"VAR_3->bPicIntra = VAR_4->pict_type == AV_PICTURE_TYPE_I || VAR_2->bi_type;",
"VAR_3->bPicBackwardPrediction = VAR_4->pict_type == AV_PICTURE_TYPE_B && !VAR_2->bi_type;",
"VAR_3->bBidirectionalAveragingMode = (1 << 7) |\n((VAR_1->cfg->ConfigIntraResidUnsigned != 0) << 6) |\n((VAR_1->cfg->ConfigResidDiffAccelerator != 0) << 5) |\n((VAR_2->lumscale != 32 || VAR_2->lumshift != 0) << 4) |\n((VAR_2->profile == PROFILE_ADVANCED) << 3);",
"VAR_3->bMVprecisionAndChromaRelation = ((VAR_2->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |\n(1 << 2) |\n(0 << 1) |\n(!VAR_4->quarter_sample );",
"VAR_3->bChromaFormat = VAR_2->chromaformat;",
"VAR_1->report_id++;",
"if (VAR_1->report_id >= (1 << 16))\nVAR_1->report_id = 1;",
"VAR_3->bPicScanFixed = VAR_1->report_id >> 8;",
"VAR_3->bPicScanMethod = VAR_1->report_id & 0xff;",
"VAR_3->bPicReadbackRequests = 0;",
"VAR_3->bRcontrol = VAR_2->rnd;",
"VAR_3->bPicSpatialResid8 = (VAR_2->panscanflag << 7) |\n(VAR_2->refdist_flag << 6) |\n(VAR_4->loop_filter << 5) |\n(VAR_2->fastuvmc << 4) |\n(VAR_2->extended_mv << 3) |\n(VAR_2->dquant << 1) |\n(VAR_2->vstransform );",
"VAR_3->bPicOverflowBlocks = (VAR_2->quantizer_mode << 6) |\n(VAR_2->multires << 5) |\n(VAR_2->resync_marker << 4) |\n(VAR_2->rangered << 3) |\n(VAR_4->max_b_frames );",
"VAR_3->bPicExtrapolation = (!VAR_2->interlace || VAR_2->fcm == PROGRESSIVE) ? 1 : 2;",
"VAR_3->bPicDeblocked = ((!VAR_3->bPicBackwardPrediction && VAR_2->overlap) << 6) |\n((VAR_2->profile != PROFILE_ADVANCED && VAR_2->rangeredfrm) << 5) |\n(VAR_4->loop_filter << 1);",
"VAR_3->bPicDeblockConfined = (VAR_2->postprocflag << 7) |\n(VAR_2->broadcast << 6) |\n(VAR_2->interlace << 5) |\n(VAR_2->tfcntrflag << 4) |\n(VAR_2->finterpflag << 3) |\n((VAR_4->pict_type != AV_PICTURE_TYPE_B) << 2) |\n(VAR_2->psf << 1) |\n(VAR_2->extended_dmv );",
"if (VAR_4->pict_type != AV_PICTURE_TYPE_I)\nVAR_3->bPic4MVallowed = VAR_2->mv_mode == MV_PMODE_MIXED_MV ||\n(VAR_2->mv_mode == MV_PMODE_INTENSITY_COMP &&\nVAR_2->mv_mode2 == MV_PMODE_MIXED_MV);",
"if (VAR_2->profile == PROFILE_ADVANCED)\nVAR_3->bPicOBMC = (VAR_2->range_mapy_flag << 7) |\n(VAR_2->range_mapy << 4) |\n(VAR_2->range_mapuv_flag << 3) |\n(VAR_2->range_mapuv );",
"VAR_3->bPicBinPB = 0;",
"VAR_3->bMV_RPS = 0;",
"VAR_3->bReservedBits = 0;",
"if (VAR_4->picture_structure == PICT_FRAME) {",
"VAR_3->wBitstreamFcodes = VAR_2->lumscale;",
"VAR_3->wBitstreamPCEelements = VAR_2->lumshift;",
"} else {",
"VAR_3->wBitstreamFcodes = (VAR_2->lumscale << 8) | VAR_2->lumscale;",
"VAR_3->wBitstreamPCEelements = (VAR_2->lumshift << 8) | VAR_2->lumshift;",
"}",
"VAR_3->bBitstreamConcealmentNeed = 0;",
"VAR_3->bBitstreamConcealmentMethod = 0;",
"}"
]
| [
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79,
81,
83,
85,
87
],
[
89,
91,
93,
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115,
117,
119,
121,
123,
125
],
[
127,
129,
131,
133,
135
],
[
137
],
[
139,
141,
143
],
[
145,
147,
149,
151,
153,
155,
157,
159
],
[
161,
163,
165,
167
],
[
169,
171,
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
]
]
|
16,667 | static av_always_inline void sbr_hf_apply_noise(int (*Y)[2],
const SoftFloat *s_m,
const SoftFloat *q_filt,
int noise,
int phi_sign0,
int phi_sign1,
int m_max)
{
int m;
for (m = 0; m < m_max; m++) {
int y0 = Y[m][0];
int y1 = Y[m][1];
noise = (noise + 1) & 0x1ff;
if (s_m[m].mant) {
int shift, round;
shift = 22 - s_m[m].exp;
if (shift < 30) {
round = 1 << (shift-1);
y0 += (s_m[m].mant * phi_sign0 + round) >> shift;
y1 += (s_m[m].mant * phi_sign1 + round) >> shift;
}
} else {
int shift, round, tmp;
int64_t accu;
shift = 22 - q_filt[m].exp;
if (shift < 30) {
round = 1 << (shift-1);
accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][0];
tmp = (int)((accu + 0x40000000) >> 31);
y0 += (tmp + round) >> shift;
accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][1];
tmp = (int)((accu + 0x40000000) >> 31);
y1 += (tmp + round) >> shift;
}
}
Y[m][0] = y0;
Y[m][1] = y1;
phi_sign1 = -phi_sign1;
}
}
| true | FFmpeg | d549f026d8b64b879c3ce3b8c7d153c82aa5eb52 | static av_always_inline void sbr_hf_apply_noise(int (*Y)[2],
const SoftFloat *s_m,
const SoftFloat *q_filt,
int noise,
int phi_sign0,
int phi_sign1,
int m_max)
{
int m;
for (m = 0; m < m_max; m++) {
int y0 = Y[m][0];
int y1 = Y[m][1];
noise = (noise + 1) & 0x1ff;
if (s_m[m].mant) {
int shift, round;
shift = 22 - s_m[m].exp;
if (shift < 30) {
round = 1 << (shift-1);
y0 += (s_m[m].mant * phi_sign0 + round) >> shift;
y1 += (s_m[m].mant * phi_sign1 + round) >> shift;
}
} else {
int shift, round, tmp;
int64_t accu;
shift = 22 - q_filt[m].exp;
if (shift < 30) {
round = 1 << (shift-1);
accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][0];
tmp = (int)((accu + 0x40000000) >> 31);
y0 += (tmp + round) >> shift;
accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][1];
tmp = (int)((accu + 0x40000000) >> 31);
y1 += (tmp + round) >> shift;
}
}
Y[m][0] = y0;
Y[m][1] = y1;
phi_sign1 = -phi_sign1;
}
}
| {
"code": [
"static av_always_inline void sbr_hf_apply_noise(int (*Y)[2],",
" if (shift < 30) {",
" if (shift < 30) {"
],
"line_no": [
1,
37,
37
]
} | static av_always_inline void FUNC_0(int (*Y)[2],
const SoftFloat *s_m,
const SoftFloat *q_filt,
int noise,
int phi_sign0,
int phi_sign1,
int m_max)
{
int VAR_0;
for (VAR_0 = 0; VAR_0 < m_max; VAR_0++) {
int VAR_1 = Y[VAR_0][0];
int VAR_2 = Y[VAR_0][1];
noise = (noise + 1) & 0x1ff;
if (s_m[VAR_0].mant) {
int VAR_5, VAR_5;
VAR_5 = 22 - s_m[VAR_0].exp;
if (VAR_5 < 30) {
VAR_5 = 1 << (VAR_5-1);
VAR_1 += (s_m[VAR_0].mant * phi_sign0 + VAR_5) >> VAR_5;
VAR_2 += (s_m[VAR_0].mant * phi_sign1 + VAR_5) >> VAR_5;
}
} else {
int VAR_5, VAR_5, VAR_5;
int64_t accu;
VAR_5 = 22 - q_filt[VAR_0].exp;
if (VAR_5 < 30) {
VAR_5 = 1 << (VAR_5-1);
accu = (int64_t)q_filt[VAR_0].mant * ff_sbr_noise_table_fixed[noise][0];
VAR_5 = (int)((accu + 0x40000000) >> 31);
VAR_1 += (VAR_5 + VAR_5) >> VAR_5;
accu = (int64_t)q_filt[VAR_0].mant * ff_sbr_noise_table_fixed[noise][1];
VAR_5 = (int)((accu + 0x40000000) >> 31);
VAR_2 += (VAR_5 + VAR_5) >> VAR_5;
}
}
Y[VAR_0][0] = VAR_1;
Y[VAR_0][1] = VAR_2;
phi_sign1 = -phi_sign1;
}
}
| [
"static av_always_inline void FUNC_0(int (*Y)[2],\nconst SoftFloat *s_m,\nconst SoftFloat *q_filt,\nint noise,\nint phi_sign0,\nint phi_sign1,\nint m_max)\n{",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < m_max; VAR_0++) {",
"int VAR_1 = Y[VAR_0][0];",
"int VAR_2 = Y[VAR_0][1];",
"noise = (noise + 1) & 0x1ff;",
"if (s_m[VAR_0].mant) {",
"int VAR_5, VAR_5;",
"VAR_5 = 22 - s_m[VAR_0].exp;",
"if (VAR_5 < 30) {",
"VAR_5 = 1 << (VAR_5-1);",
"VAR_1 += (s_m[VAR_0].mant * phi_sign0 + VAR_5) >> VAR_5;",
"VAR_2 += (s_m[VAR_0].mant * phi_sign1 + VAR_5) >> VAR_5;",
"}",
"} else {",
"int VAR_5, VAR_5, VAR_5;",
"int64_t accu;",
"VAR_5 = 22 - q_filt[VAR_0].exp;",
"if (VAR_5 < 30) {",
"VAR_5 = 1 << (VAR_5-1);",
"accu = (int64_t)q_filt[VAR_0].mant * ff_sbr_noise_table_fixed[noise][0];",
"VAR_5 = (int)((accu + 0x40000000) >> 31);",
"VAR_1 += (VAR_5 + VAR_5) >> VAR_5;",
"accu = (int64_t)q_filt[VAR_0].mant * ff_sbr_noise_table_fixed[noise][1];",
"VAR_5 = (int)((accu + 0x40000000) >> 31);",
"VAR_2 += (VAR_5 + VAR_5) >> VAR_5;",
"}",
"}",
"Y[VAR_0][0] = VAR_1;",
"Y[VAR_0][1] = VAR_2;",
"phi_sign1 = -phi_sign1;",
"}",
"}"
]
| [
1,
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
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
]
]
|
16,668 | av_cold void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
if (bit_depth == 8) {
c->h264_idct_add = h264_idct_add_altivec;
if (chroma_format_idc == 1)
c->h264_idct_add8 = h264_idct_add8_altivec;
c->h264_idct_add16 = h264_idct_add16_altivec;
c->h264_idct_add16intra = h264_idct_add16intra_altivec;
c->h264_idct_dc_add= h264_idct_dc_add_altivec;
c->h264_idct8_dc_add = h264_idct8_dc_add_altivec;
c->h264_idct8_add = h264_idct8_add_altivec;
c->h264_idct8_add4 = h264_idct8_add4_altivec;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec;
c->weight_h264_pixels_tab[0] = weight_h264_pixels16_altivec;
c->weight_h264_pixels_tab[1] = weight_h264_pixels8_altivec;
c->biweight_h264_pixels_tab[0] = biweight_h264_pixels16_altivec;
c->biweight_h264_pixels_tab[1] = biweight_h264_pixels8_altivec;
}
#endif /* HAVE_ALTIVEC */
}
| true | FFmpeg | a03a642d5ceb5f2f7c6ebbf56ff365dfbcdb65eb | av_cold void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
if (bit_depth == 8) {
c->h264_idct_add = h264_idct_add_altivec;
if (chroma_format_idc == 1)
c->h264_idct_add8 = h264_idct_add8_altivec;
c->h264_idct_add16 = h264_idct_add16_altivec;
c->h264_idct_add16intra = h264_idct_add16intra_altivec;
c->h264_idct_dc_add= h264_idct_dc_add_altivec;
c->h264_idct8_dc_add = h264_idct8_dc_add_altivec;
c->h264_idct8_add = h264_idct8_add_altivec;
c->h264_idct8_add4 = h264_idct8_add4_altivec;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec;
c->weight_h264_pixels_tab[0] = weight_h264_pixels16_altivec;
c->weight_h264_pixels_tab[1] = weight_h264_pixels8_altivec;
c->biweight_h264_pixels_tab[0] = biweight_h264_pixels16_altivec;
c->biweight_h264_pixels_tab[1] = biweight_h264_pixels8_altivec;
}
#endif
}
| {
"code": [
" if (chroma_format_idc == 1)"
],
"line_no": [
19
]
} | av_cold void FUNC_0(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
if (bit_depth == 8) {
c->h264_idct_add = h264_idct_add_altivec;
if (chroma_format_idc == 1)
c->h264_idct_add8 = h264_idct_add8_altivec;
c->h264_idct_add16 = h264_idct_add16_altivec;
c->h264_idct_add16intra = h264_idct_add16intra_altivec;
c->h264_idct_dc_add= h264_idct_dc_add_altivec;
c->h264_idct8_dc_add = h264_idct8_dc_add_altivec;
c->h264_idct8_add = h264_idct8_add_altivec;
c->h264_idct8_add4 = h264_idct8_add4_altivec;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec;
c->weight_h264_pixels_tab[0] = weight_h264_pixels16_altivec;
c->weight_h264_pixels_tab[1] = weight_h264_pixels8_altivec;
c->biweight_h264_pixels_tab[0] = biweight_h264_pixels16_altivec;
c->biweight_h264_pixels_tab[1] = biweight_h264_pixels8_altivec;
}
#endif
}
| [
"av_cold void FUNC_0(H264DSPContext *c, const int bit_depth,\nconst int chroma_format_idc)\n{",
"#if HAVE_ALTIVEC\nif (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))\nreturn;",
"if (bit_depth == 8) {",
"c->h264_idct_add = h264_idct_add_altivec;",
"if (chroma_format_idc == 1)\nc->h264_idct_add8 = h264_idct_add8_altivec;",
"c->h264_idct_add16 = h264_idct_add16_altivec;",
"c->h264_idct_add16intra = h264_idct_add16intra_altivec;",
"c->h264_idct_dc_add= h264_idct_dc_add_altivec;",
"c->h264_idct8_dc_add = h264_idct8_dc_add_altivec;",
"c->h264_idct8_add = h264_idct8_add_altivec;",
"c->h264_idct8_add4 = h264_idct8_add4_altivec;",
"c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec;",
"c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec;",
"c->weight_h264_pixels_tab[0] = weight_h264_pixels16_altivec;",
"c->weight_h264_pixels_tab[1] = weight_h264_pixels8_altivec;",
"c->biweight_h264_pixels_tab[0] = biweight_h264_pixels16_altivec;",
"c->biweight_h264_pixels_tab[1] = biweight_h264_pixels8_altivec;",
"}",
"#endif\n}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9,
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
]
]
|
16,669 | static av_cold int atrac1_decode_init(AVCodecContext *avctx)
{
AT1Ctx *q = avctx->priv_data;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n",
avctx->channels);
return AVERROR(EINVAL);
}
q->channels = avctx->channels;
if (avctx->channels == 2) {
q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0]));
q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES;
if (!q->out_samples[0]) {
av_freep(&q->out_samples[0]);
return AVERROR(ENOMEM);
}
}
/* Init the mdct transforms */
ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
ff_init_ff_sine_windows(5);
atrac_generate_tables();
dsputil_init(&q->dsp, avctx);
ff_fmt_convert_init(&q->fmt_conv, avctx);
q->bands[0] = q->low;
q->bands[1] = q->mid;
q->bands[2] = q->high;
/* Prepare the mdct overlap buffers */
q->SUs[0].spectrum[0] = q->SUs[0].spec1;
q->SUs[0].spectrum[1] = q->SUs[0].spec2;
q->SUs[1].spectrum[0] = q->SUs[1].spec1;
q->SUs[1].spectrum[1] = q->SUs[1].spec2;
return 0;
}
| true | FFmpeg | 6dc7dd7af45aa1e341b471fd054f85ae2747775b | static av_cold int atrac1_decode_init(AVCodecContext *avctx)
{
AT1Ctx *q = avctx->priv_data;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n",
avctx->channels);
return AVERROR(EINVAL);
}
q->channels = avctx->channels;
if (avctx->channels == 2) {
q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0]));
q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES;
if (!q->out_samples[0]) {
av_freep(&q->out_samples[0]);
return AVERROR(ENOMEM);
}
}
ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
ff_init_ff_sine_windows(5);
atrac_generate_tables();
dsputil_init(&q->dsp, avctx);
ff_fmt_convert_init(&q->fmt_conv, avctx);
q->bands[0] = q->low;
q->bands[1] = q->mid;
q->bands[2] = q->high;
q->SUs[0].spectrum[0] = q->SUs[0].spec1;
q->SUs[0].spectrum[1] = q->SUs[0].spec2;
q->SUs[1].spectrum[0] = q->SUs[1].spec1;
q->SUs[1].spectrum[1] = q->SUs[1].spec2;
return 0;
}
| {
"code": [
" ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));",
" ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));",
" ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));",
" AT1Ctx *q = avctx->priv_data;",
" return 0;"
],
"line_no": [
47,
49,
51,
5,
89
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
AT1Ctx *q = avctx->priv_data;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n",
avctx->channels);
return AVERROR(EINVAL);
}
q->channels = avctx->channels;
if (avctx->channels == 2) {
q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0]));
q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES;
if (!q->out_samples[0]) {
av_freep(&q->out_samples[0]);
return AVERROR(ENOMEM);
}
}
ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
ff_init_ff_sine_windows(5);
atrac_generate_tables();
dsputil_init(&q->dsp, avctx);
ff_fmt_convert_init(&q->fmt_conv, avctx);
q->bands[0] = q->low;
q->bands[1] = q->mid;
q->bands[2] = q->high;
q->SUs[0].spectrum[0] = q->SUs[0].spec1;
q->SUs[0].spectrum[1] = q->SUs[0].spec2;
q->SUs[1].spectrum[0] = q->SUs[1].spec1;
q->SUs[1].spectrum[1] = q->SUs[1].spec2;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"AT1Ctx *q = avctx->priv_data;",
"avctx->sample_fmt = AV_SAMPLE_FMT_FLT;",
"if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) {",
"av_log(avctx, AV_LOG_ERROR, \"Unsupported number of channels: %d\\n\",\navctx->channels);",
"return AVERROR(EINVAL);",
"}",
"q->channels = avctx->channels;",
"if (avctx->channels == 2) {",
"q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0]));",
"q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES;",
"if (!q->out_samples[0]) {",
"av_freep(&q->out_samples[0]);",
"return AVERROR(ENOMEM);",
"}",
"}",
"ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));",
"ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));",
"ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));",
"ff_init_ff_sine_windows(5);",
"atrac_generate_tables();",
"dsputil_init(&q->dsp, avctx);",
"ff_fmt_convert_init(&q->fmt_conv, avctx);",
"q->bands[0] = q->low;",
"q->bands[1] = q->mid;",
"q->bands[2] = q->high;",
"q->SUs[0].spectrum[0] = q->SUs[0].spec1;",
"q->SUs[0].spectrum[1] = q->SUs[0].spec2;",
"q->SUs[1].spectrum[0] = q->SUs[1].spec1;",
"q->SUs[1].spectrum[1] = q->SUs[1].spec2;",
"return 0;",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
]
]
|
16,670 | static int query_formats(AVFilterContext *ctx)
{
AVFilterFormats *formats = NULL;
int fmt;
for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
if (!(desc->flags & PIX_FMT_PAL ||
fmt == AV_PIX_FMT_NV21 ||
fmt == AV_PIX_FMT_NV12))
ff_add_format(&formats, fmt);
}
ff_set_common_formats(ctx, formats);
return 0;
}
| true | FFmpeg | 63a99622876ff79a07862167f243a7d3823b7315 | static int query_formats(AVFilterContext *ctx)
{
AVFilterFormats *formats = NULL;
int fmt;
for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
if (!(desc->flags & PIX_FMT_PAL ||
fmt == AV_PIX_FMT_NV21 ||
fmt == AV_PIX_FMT_NV12))
ff_add_format(&formats, fmt);
}
ff_set_common_formats(ctx, formats);
return 0;
}
| {
"code": [
" if (!(desc->flags & PIX_FMT_PAL ||",
" fmt == AV_PIX_FMT_NV21 ||",
" fmt == AV_PIX_FMT_NV12))"
],
"line_no": [
15,
17,
19
]
} | static int FUNC_0(AVFilterContext *VAR_0)
{
AVFilterFormats *formats = NULL;
int VAR_1;
for (VAR_1 = 0; VAR_1 < AV_PIX_FMT_NB; VAR_1++) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(VAR_1);
if (!(desc->flags & PIX_FMT_PAL ||
VAR_1 == AV_PIX_FMT_NV21 ||
VAR_1 == AV_PIX_FMT_NV12))
ff_add_format(&formats, VAR_1);
}
ff_set_common_formats(VAR_0, formats);
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0)\n{",
"AVFilterFormats *formats = NULL;",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < AV_PIX_FMT_NB; VAR_1++) {",
"const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(VAR_1);",
"if (!(desc->flags & PIX_FMT_PAL ||\nVAR_1 == AV_PIX_FMT_NV21 ||\nVAR_1 == AV_PIX_FMT_NV12))\nff_add_format(&formats, VAR_1);",
"}",
"ff_set_common_formats(VAR_0, formats);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
]
]
|
16,671 | Object *container_get(Object *root, const char *path)
{
Object *obj, *child;
gchar **parts;
int i;
parts = g_strsplit(path, "/", 0);
assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
obj = root;
for (i = 1; parts[i] != NULL; i++, obj = child) {
child = object_resolve_path_component(obj, parts[i]);
if (!child) {
child = object_new("container");
object_property_add_child(obj, parts[i], child, NULL);
}
}
g_strfreev(parts);
return obj;
} | true | qemu | f8df5f922152a47b3889921d249e00dab766d950 | Object *container_get(Object *root, const char *path)
{
Object *obj, *child;
gchar **parts;
int i;
parts = g_strsplit(path, "/", 0);
assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
obj = root;
for (i = 1; parts[i] != NULL; i++, obj = child) {
child = object_resolve_path_component(obj, parts[i]);
if (!child) {
child = object_new("container");
object_property_add_child(obj, parts[i], child, NULL);
}
}
g_strfreev(parts);
return obj;
} | {
"code": [],
"line_no": []
} | Object *FUNC_0(Object *root, const char *path)
{
Object *obj, *child;
gchar **parts;
int VAR_0;
parts = g_strsplit(path, "/", 0);
assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
obj = root;
for (VAR_0 = 1; parts[VAR_0] != NULL; VAR_0++, obj = child) {
child = object_resolve_path_component(obj, parts[VAR_0]);
if (!child) {
child = object_new("container");
object_property_add_child(obj, parts[VAR_0], child, NULL);
}
}
g_strfreev(parts);
return obj;
} | [
"Object *FUNC_0(Object *root, const char *path)\n{",
"Object *obj, *child;",
"gchar **parts;",
"int VAR_0;",
"parts = g_strsplit(path, \"/\", 0);",
"assert(parts != NULL && parts[0] != NULL && !parts[0][0]);",
"obj = root;",
"for (VAR_0 = 1; parts[VAR_0] != NULL; VAR_0++, obj = child) {",
"child = object_resolve_path_component(obj, parts[VAR_0]);",
"if (!child) {",
"child = object_new(\"container\");",
"object_property_add_child(obj, parts[VAR_0], child, NULL);",
"}",
"}",
"g_strfreev(parts);",
"return obj;",
"}"
]
| [
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
],
[
32
],
[
34
],
[
38
],
[
42
],
[
44
]
]
|
16,672 | int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
int list, index, pic_structure, i;
print_short_term(h);
print_long_term(h);
for(list=0; list<h->list_count; list++){
for (i = 0; i < h->ref_count[list]; i++)
COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]);
if(get_bits1(&h->gb)){
int pred= h->curr_pic_num;
for(index=0; ; index++){
unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&h->gb);
unsigned int pic_id;
int i;
Picture *ref = NULL;
if(reordering_of_pic_nums_idc==3)
break;
if(index >= h->ref_count[list]){
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc<3){
if(reordering_of_pic_nums_idc<2){
const unsigned int abs_diff_pic_num= get_ue_golomb(&h->gb) + 1;
int frame_num;
if(abs_diff_pic_num > h->max_pic_num){
av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
else pred+= abs_diff_pic_num;
pred &= h->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for(i= h->short_ref_count-1; i>=0; i--){
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if(
ref->frame_num == frame_num &&
(ref->reference & pic_structure)
)
break;
}
if(i>=0)
ref->pic_id= pred;
}else{
int long_idx;
pic_id= get_ue_golomb(&h->gb); //long_term_pic_idx
long_idx= pic_num_extract(h, pic_id, &pic_structure);
if(long_idx>31){
av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
return -1;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure)) {
ref->pic_id= pic_id;
assert(ref->long_ref);
i=0;
}else{
i=-1;
}
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
} else {
for(i=index; i+1<h->ref_count[list]; i++){
if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id)
break;
}
for(; i > index; i--){
COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
}
COPY_PICTURE(&h->ref_list[list][index], ref);
if (FIELD_PICTURE){
pic_as_field(&h->ref_list[list][index], pic_structure);
}
}
}else{
av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
return -1;
}
}
}
}
for(list=0; list<h->list_count; list++){
for(index= 0; index < h->ref_count[list]; index++){
if (!h->ref_list[list][index].f.data[0]) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
for (i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
if (h->default_ref_list[list][0].f.data[0])
COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]);
else
return -1;
}
}
}
return 0;
}
| true | FFmpeg | 01a0283c92b124f185ce4e814a1c5b600f1135e0 | int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
int list, index, pic_structure, i;
print_short_term(h);
print_long_term(h);
for(list=0; list<h->list_count; list++){
for (i = 0; i < h->ref_count[list]; i++)
COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]);
if(get_bits1(&h->gb)){
int pred= h->curr_pic_num;
for(index=0; ; index++){
unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&h->gb);
unsigned int pic_id;
int i;
Picture *ref = NULL;
if(reordering_of_pic_nums_idc==3)
break;
if(index >= h->ref_count[list]){
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc<3){
if(reordering_of_pic_nums_idc<2){
const unsigned int abs_diff_pic_num= get_ue_golomb(&h->gb) + 1;
int frame_num;
if(abs_diff_pic_num > h->max_pic_num){
av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
else pred+= abs_diff_pic_num;
pred &= h->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for(i= h->short_ref_count-1; i>=0; i--){
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if(
ref->frame_num == frame_num &&
(ref->reference & pic_structure)
)
break;
}
if(i>=0)
ref->pic_id= pred;
}else{
int long_idx;
pic_id= get_ue_golomb(&h->gb);
long_idx= pic_num_extract(h, pic_id, &pic_structure);
if(long_idx>31){
av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
return -1;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure)) {
ref->pic_id= pic_id;
assert(ref->long_ref);
i=0;
}else{
i=-1;
}
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
memset(&h->ref_list[list][index], 0, sizeof(Picture));
} else {
for(i=index; i+1<h->ref_count[list]; i++){
if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id)
break;
}
for(; i > index; i--){
COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
}
COPY_PICTURE(&h->ref_list[list][index], ref);
if (FIELD_PICTURE){
pic_as_field(&h->ref_list[list][index], pic_structure);
}
}
}else{
av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
return -1;
}
}
}
}
for(list=0; list<h->list_count; list++){
for(index= 0; index < h->ref_count[list]; index++){
if (!h->ref_list[list][index].f.data[0]) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
for (i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
if (h->default_ref_list[list][0].f.data[0])
COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]);
else
return -1;
}
}
}
return 0;
}
| {
"code": [
" if (!h->ref_list[list][index].f.data[0]) {",
" if (h->default_ref_list[list][0].f.data[0])"
],
"line_no": [
203,
213
]
} | int FUNC_0(H264Context *VAR_0){
int VAR_1, VAR_2, VAR_3, VAR_4;
print_short_term(VAR_0);
print_long_term(VAR_0);
for(VAR_1=0; VAR_1<VAR_0->list_count; VAR_1++){
for (VAR_4 = 0; VAR_4 < VAR_0->ref_count[VAR_1]; VAR_4++)
COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_4], &VAR_0->default_ref_list[VAR_1][VAR_4]);
if(get_bits1(&VAR_0->gb)){
int pred= VAR_0->curr_pic_num;
for(VAR_2=0; ; VAR_2++){
unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&VAR_0->gb);
unsigned int pic_id;
int VAR_4;
Picture *ref = NULL;
if(reordering_of_pic_nums_idc==3)
break;
if(VAR_2 >= VAR_0->ref_count[VAR_1]){
av_log(VAR_0->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc<3){
if(reordering_of_pic_nums_idc<2){
const unsigned int abs_diff_pic_num= get_ue_golomb(&VAR_0->gb) + 1;
int frame_num;
if(abs_diff_pic_num > VAR_0->max_pic_num){
av_log(VAR_0->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
return -1;
}
if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
else pred+= abs_diff_pic_num;
pred &= VAR_0->max_pic_num - 1;
frame_num = pic_num_extract(VAR_0, pred, &VAR_3);
for(VAR_4= VAR_0->short_ref_count-1; VAR_4>=0; VAR_4--){
ref = VAR_0->short_ref[VAR_4];
assert(ref->reference);
assert(!ref->long_ref);
if(
ref->frame_num == frame_num &&
(ref->reference & VAR_3)
)
break;
}
if(VAR_4>=0)
ref->pic_id= pred;
}else{
int long_idx;
pic_id= get_ue_golomb(&VAR_0->gb);
long_idx= pic_num_extract(VAR_0, pic_id, &VAR_3);
if(long_idx>31){
av_log(VAR_0->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
return -1;
}
ref = VAR_0->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & VAR_3)) {
ref->pic_id= pic_id;
assert(ref->long_ref);
VAR_4=0;
}else{
VAR_4=-1;
}
}
if (VAR_4 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
memset(&VAR_0->ref_list[VAR_1][VAR_2], 0, sizeof(Picture));
} else {
for(VAR_4=VAR_2; VAR_4+1<VAR_0->ref_count[VAR_1]; VAR_4++){
if(ref->long_ref == VAR_0->ref_list[VAR_1][VAR_4].long_ref && ref->pic_id == VAR_0->ref_list[VAR_1][VAR_4].pic_id)
break;
}
for(; VAR_4 > VAR_2; VAR_4--){
COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_4], &VAR_0->ref_list[VAR_1][VAR_4 - 1]);
}
COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_2], ref);
if (FIELD_PICTURE){
pic_as_field(&VAR_0->ref_list[VAR_1][VAR_2], VAR_3);
}
}
}else{
av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
return -1;
}
}
}
}
for(VAR_1=0; VAR_1<VAR_0->list_count; VAR_1++){
for(VAR_2= 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++){
if (!VAR_0->ref_list[VAR_1][VAR_2].f.data[0]) {
int VAR_4;
av_log(VAR_0->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", VAR_0->default_ref_list[VAR_1][0].poc);
for (VAR_4=0; VAR_4<FF_ARRAY_ELEMS(VAR_0->last_pocs); VAR_4++)
VAR_0->last_pocs[VAR_4] = INT_MIN;
if (VAR_0->default_ref_list[VAR_1][0].f.data[0])
COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_2], &VAR_0->default_ref_list[VAR_1][0]);
else
return -1;
}
}
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0){",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"print_short_term(VAR_0);",
"print_long_term(VAR_0);",
"for(VAR_1=0; VAR_1<VAR_0->list_count; VAR_1++){",
"for (VAR_4 = 0; VAR_4 < VAR_0->ref_count[VAR_1]; VAR_4++)",
"COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_4], &VAR_0->default_ref_list[VAR_1][VAR_4]);",
"if(get_bits1(&VAR_0->gb)){",
"int pred= VAR_0->curr_pic_num;",
"for(VAR_2=0; ; VAR_2++){",
"unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&VAR_0->gb);",
"unsigned int pic_id;",
"int VAR_4;",
"Picture *ref = NULL;",
"if(reordering_of_pic_nums_idc==3)\nbreak;",
"if(VAR_2 >= VAR_0->ref_count[VAR_1]){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"reference count overflow\\n\");",
"return -1;",
"}",
"if(reordering_of_pic_nums_idc<3){",
"if(reordering_of_pic_nums_idc<2){",
"const unsigned int abs_diff_pic_num= get_ue_golomb(&VAR_0->gb) + 1;",
"int frame_num;",
"if(abs_diff_pic_num > VAR_0->max_pic_num){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"abs_diff_pic_num overflow\\n\");",
"return -1;",
"}",
"if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;",
"else pred+= abs_diff_pic_num;",
"pred &= VAR_0->max_pic_num - 1;",
"frame_num = pic_num_extract(VAR_0, pred, &VAR_3);",
"for(VAR_4= VAR_0->short_ref_count-1; VAR_4>=0; VAR_4--){",
"ref = VAR_0->short_ref[VAR_4];",
"assert(ref->reference);",
"assert(!ref->long_ref);",
"if(\nref->frame_num == frame_num &&\n(ref->reference & VAR_3)\n)\nbreak;",
"}",
"if(VAR_4>=0)\nref->pic_id= pred;",
"}else{",
"int long_idx;",
"pic_id= get_ue_golomb(&VAR_0->gb);",
"long_idx= pic_num_extract(VAR_0, pic_id, &VAR_3);",
"if(long_idx>31){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"long_term_pic_idx overflow\\n\");",
"return -1;",
"}",
"ref = VAR_0->long_ref[long_idx];",
"assert(!(ref && !ref->reference));",
"if (ref && (ref->reference & VAR_3)) {",
"ref->pic_id= pic_id;",
"assert(ref->long_ref);",
"VAR_4=0;",
"}else{",
"VAR_4=-1;",
"}",
"}",
"if (VAR_4 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"reference picture missing during reorder\\n\");",
"memset(&VAR_0->ref_list[VAR_1][VAR_2], 0, sizeof(Picture));",
"} else {",
"for(VAR_4=VAR_2; VAR_4+1<VAR_0->ref_count[VAR_1]; VAR_4++){",
"if(ref->long_ref == VAR_0->ref_list[VAR_1][VAR_4].long_ref && ref->pic_id == VAR_0->ref_list[VAR_1][VAR_4].pic_id)\nbreak;",
"}",
"for(; VAR_4 > VAR_2; VAR_4--){",
"COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_4], &VAR_0->ref_list[VAR_1][VAR_4 - 1]);",
"}",
"COPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_2], ref);",
"if (FIELD_PICTURE){",
"pic_as_field(&VAR_0->ref_list[VAR_1][VAR_2], VAR_3);",
"}",
"}",
"}else{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal reordering_of_pic_nums_idc\\n\");",
"return -1;",
"}",
"}",
"}",
"}",
"for(VAR_1=0; VAR_1<VAR_0->list_count; VAR_1++){",
"for(VAR_2= 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++){",
"if (!VAR_0->ref_list[VAR_1][VAR_2].f.data[0]) {",
"int VAR_4;",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Missing reference picture, default is %d\\n\", VAR_0->default_ref_list[VAR_1][0].poc);",
"for (VAR_4=0; VAR_4<FF_ARRAY_ELEMS(VAR_0->last_pocs); VAR_4++)",
"VAR_0->last_pocs[VAR_4] = INT_MIN;",
"if (VAR_0->default_ref_list[VAR_1][0].f.data[0])\nCOPY_PICTURE(&VAR_0->ref_list[VAR_1][VAR_2], &VAR_0->default_ref_list[VAR_1][0]);",
"else\nreturn -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,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97,
99,
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
]
]
|
16,673 | static void nfs_client_close(NFSClient *client)
{
if (client->context) {
if (client->fh) {
nfs_close(client->context, client->fh);
}
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
false, NULL, NULL, NULL, NULL);
nfs_destroy_context(client->context);
}
memset(client, 0, sizeof(NFSClient));
}
| true | qemu | 113fe792fd4931dd0538f03859278b8719ee4fa2 | static void nfs_client_close(NFSClient *client)
{
if (client->context) {
if (client->fh) {
nfs_close(client->context, client->fh);
}
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
false, NULL, NULL, NULL, NULL);
nfs_destroy_context(client->context);
}
memset(client, 0, sizeof(NFSClient));
}
| {
"code": [
" memset(client, 0, sizeof(NFSClient));"
],
"line_no": [
21
]
} | static void FUNC_0(NFSClient *VAR_0)
{
if (VAR_0->context) {
if (VAR_0->fh) {
nfs_close(VAR_0->context, VAR_0->fh);
}
aio_set_fd_handler(VAR_0->aio_context, nfs_get_fd(VAR_0->context),
false, NULL, NULL, NULL, NULL);
nfs_destroy_context(VAR_0->context);
}
memset(VAR_0, 0, sizeof(NFSClient));
}
| [
"static void FUNC_0(NFSClient *VAR_0)\n{",
"if (VAR_0->context) {",
"if (VAR_0->fh) {",
"nfs_close(VAR_0->context, VAR_0->fh);",
"}",
"aio_set_fd_handler(VAR_0->aio_context, nfs_get_fd(VAR_0->context),\nfalse, NULL, NULL, NULL, NULL);",
"nfs_destroy_context(VAR_0->context);",
"}",
"memset(VAR_0, 0, sizeof(NFSClient));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
16,674 | static void musicpal_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[32];
DeviceState *dev;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
#ifdef HAS_AUDIO
DeviceState *wm8750_dev;
SysBusDevice *s;
#endif
i2c_bus *i2c;
int i;
unsigned long flash_size;
DriveInfo *dinfo;
ram_addr_t sram_off;
if (!cpu_model) {
cpu_model = "arm926";
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
cpu_pic = arm_pic_init_cpu(env);
/* For now we use a fixed - the original - RAM size */
cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,
qemu_ram_alloc(MP_RAM_DEFAULT_SIZE));
sram_off = qemu_ram_alloc(MP_SRAM_SIZE);
cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);
dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
if (serial_hds[0]) {
serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000,
serial_hds[0], 1);
}
if (serial_hds[1]) {
serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000,
serial_hds[1], 1);
}
/* Register flash */
dinfo = drive_get(IF_PFLASH, 0, 0);
if (dinfo) {
flash_size = bdrv_getlength(dinfo->bdrv);
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
flash_size != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
exit(1);
}
/*
* The original U-Boot accesses the flash at 0xFE000000 instead of
* 0xFF800000 (if there is 8 MB flash). So remap flash access if the
* image is smaller than 32 MB.
*/
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size),
dinfo->bdrv, 0x10000,
(flash_size + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / flash_size,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA);
}
sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth");
dev->nd = &nd_table[0];
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
musicpal_misc_init();
dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("bitbang_i2c", 0, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple("musicpal_key", 0, NULL);
/* I2C read data */
qdev_connect_gpio_out(i2c_dev, 0,
qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));
/* I2C data */
qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));
/* I2C clock */
qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));
for (i = 0; i < 3; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i));
}
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8));
}
for (i = 4; i < 8; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
#ifdef HAS_AUDIO
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = sysbus_from_qdev(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
#endif
musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
musicpal_binfo.kernel_filename = kernel_filename;
musicpal_binfo.kernel_cmdline = kernel_cmdline;
musicpal_binfo.initrd_filename = initrd_filename;
arm_load_kernel(env, &musicpal_binfo);
}
| true | qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | static void musicpal_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[32];
DeviceState *dev;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
#ifdef HAS_AUDIO
DeviceState *wm8750_dev;
SysBusDevice *s;
#endif
i2c_bus *i2c;
int i;
unsigned long flash_size;
DriveInfo *dinfo;
ram_addr_t sram_off;
if (!cpu_model) {
cpu_model = "arm926";
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
cpu_pic = arm_pic_init_cpu(env);
cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,
qemu_ram_alloc(MP_RAM_DEFAULT_SIZE));
sram_off = qemu_ram_alloc(MP_SRAM_SIZE);
cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);
dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
if (serial_hds[0]) {
serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000,
serial_hds[0], 1);
}
if (serial_hds[1]) {
serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000,
serial_hds[1], 1);
}
dinfo = drive_get(IF_PFLASH, 0, 0);
if (dinfo) {
flash_size = bdrv_getlength(dinfo->bdrv);
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
flash_size != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
exit(1);
}
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size),
dinfo->bdrv, 0x10000,
(flash_size + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / flash_size,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA);
}
sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth");
dev->nd = &nd_table[0];
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
musicpal_misc_init();
dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("bitbang_i2c", 0, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple("musicpal_key", 0, NULL);
qdev_connect_gpio_out(i2c_dev, 0,
qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));
qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));
qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));
for (i = 0; i < 3; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i));
}
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8));
}
for (i = 4; i < 8; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
#ifdef HAS_AUDIO
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = sysbus_from_qdev(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
#endif
musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
musicpal_binfo.kernel_filename = kernel_filename;
musicpal_binfo.kernel_cmdline = kernel_cmdline;
musicpal_binfo.initrd_filename = initrd_filename;
arm_load_kernel(env, &musicpal_binfo);
}
| {
"code": [
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);"
],
"line_no": [
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169,
169
]
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2, const char *VAR_3,
const char *VAR_4, const char *VAR_5)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[32];
DeviceState *dev;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
#ifdef HAS_AUDIO
DeviceState *wm8750_dev;
SysBusDevice *s;
#endif
i2c_bus *i2c;
int VAR_6;
unsigned long VAR_7;
DriveInfo *dinfo;
ram_addr_t sram_off;
if (!VAR_5) {
VAR_5 = "arm926";
}
env = cpu_init(VAR_5);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
cpu_pic = arm_pic_init_cpu(env);
cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,
qemu_ram_alloc(MP_RAM_DEFAULT_SIZE));
sram_off = qemu_ram_alloc(MP_SRAM_SIZE);
cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);
dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {
pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);
}
sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
if (serial_hds[0]) {
serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000,
serial_hds[0], 1);
}
if (serial_hds[1]) {
serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000,
serial_hds[1], 1);
}
dinfo = drive_get(IF_PFLASH, 0, 0);
if (dinfo) {
VAR_7 = bdrv_getlength(dinfo->bdrv);
if (VAR_7 != 8*1024*1024 && VAR_7 != 16*1024*1024 &&
VAR_7 != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
exit(1);
}
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(VAR_7),
dinfo->bdrv, 0x10000,
(VAR_7 + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / VAR_7,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA);
}
sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth");
dev->nd = &nd_table[0];
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
musicpal_misc_init();
dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("bitbang_i2c", 0, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple("musicpal_key", 0, NULL);
qdev_connect_gpio_out(i2c_dev, 0,
qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));
qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));
qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
qdev_connect_gpio_out(dev, VAR_6, qdev_get_gpio_in(lcd_dev, VAR_6));
}
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
qdev_connect_gpio_out(key_dev, VAR_6, qdev_get_gpio_in(dev, VAR_6 + 8));
}
for (VAR_6 = 4; VAR_6 < 8; VAR_6++) {
qdev_connect_gpio_out(key_dev, VAR_6, qdev_get_gpio_in(dev, VAR_6 + 15));
}
#ifdef HAS_AUDIO
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = sysbus_from_qdev(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
#endif
musicpal_binfo.VAR_0 = MP_RAM_DEFAULT_SIZE;
musicpal_binfo.VAR_2 = VAR_2;
musicpal_binfo.VAR_3 = VAR_3;
musicpal_binfo.VAR_4 = VAR_4;
arm_load_kernel(env, &musicpal_binfo);
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5)\n{",
"CPUState *env;",
"qemu_irq *cpu_pic;",
"qemu_irq pic[32];",
"DeviceState *dev;",
"DeviceState *i2c_dev;",
"DeviceState *lcd_dev;",
"DeviceState *key_dev;",
"#ifdef HAS_AUDIO\nDeviceState *wm8750_dev;",
"SysBusDevice *s;",
"#endif\ni2c_bus *i2c;",
"int VAR_6;",
"unsigned long VAR_7;",
"DriveInfo *dinfo;",
"ram_addr_t sram_off;",
"if (!VAR_5) {",
"VAR_5 = \"arm926\";",
"}",
"env = cpu_init(VAR_5);",
"if (!env) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"cpu_pic = arm_pic_init_cpu(env);",
"cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,\nqemu_ram_alloc(MP_RAM_DEFAULT_SIZE));",
"sram_off = qemu_ram_alloc(MP_SRAM_SIZE);",
"cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);",
"dev = sysbus_create_simple(\"mv88w8618_pic\", MP_PIC_BASE,\ncpu_pic[ARM_PIC_CPU_IRQ]);",
"for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {",
"pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);",
"}",
"sysbus_create_varargs(\"mv88w8618_pit\", MP_PIT_BASE, pic[MP_TIMER1_IRQ],\npic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],\npic[MP_TIMER4_IRQ], NULL);",
"if (serial_hds[0]) {",
"serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000,\nserial_hds[0], 1);",
"}",
"if (serial_hds[1]) {",
"serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000,\nserial_hds[1], 1);",
"}",
"dinfo = drive_get(IF_PFLASH, 0, 0);",
"if (dinfo) {",
"VAR_7 = bdrv_getlength(dinfo->bdrv);",
"if (VAR_7 != 8*1024*1024 && VAR_7 != 16*1024*1024 &&\nVAR_7 != 32*1024*1024) {",
"fprintf(stderr, \"Invalid flash image size\\n\");",
"exit(1);",
"}",
"pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(VAR_7),\ndinfo->bdrv, 0x10000,\n(VAR_7 + 0xffff) >> 16,\nMP_FLASH_SIZE_MAX / VAR_7,\n2, 0x00BF, 0x236D, 0x0000, 0x0000,\n0x5555, 0x2AAA);",
"}",
"sysbus_create_simple(\"mv88w8618_flashcfg\", MP_FLASHCFG_BASE, NULL);",
"qemu_check_nic_model(&nd_table[0], \"mv88w8618\");",
"dev = qdev_create(NULL, \"mv88w8618_eth\");",
"dev->nd = &nd_table[0];",
"qdev_init(dev);",
"sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);",
"sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);",
"sysbus_create_simple(\"mv88w8618_wlan\", MP_WLAN_BASE, NULL);",
"musicpal_misc_init();",
"dev = sysbus_create_simple(\"musicpal_gpio\", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);",
"i2c_dev = sysbus_create_simple(\"bitbang_i2c\", 0, NULL);",
"i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, \"i2c\");",
"lcd_dev = sysbus_create_simple(\"musicpal_lcd\", MP_LCD_BASE, NULL);",
"key_dev = sysbus_create_simple(\"musicpal_key\", 0, NULL);",
"qdev_connect_gpio_out(i2c_dev, 0,\nqdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));",
"qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));",
"qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"qdev_connect_gpio_out(dev, VAR_6, qdev_get_gpio_in(lcd_dev, VAR_6));",
"}",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"qdev_connect_gpio_out(key_dev, VAR_6, qdev_get_gpio_in(dev, VAR_6 + 8));",
"}",
"for (VAR_6 = 4; VAR_6 < 8; VAR_6++) {",
"qdev_connect_gpio_out(key_dev, VAR_6, qdev_get_gpio_in(dev, VAR_6 + 15));",
"}",
"#ifdef HAS_AUDIO\nwm8750_dev = i2c_create_slave(i2c, \"wm8750\", MP_WM_ADDR);",
"dev = qdev_create(NULL, \"mv88w8618_audio\");",
"s = sysbus_from_qdev(dev);",
"qdev_prop_set_ptr(dev, \"wm8750\", wm8750_dev);",
"qdev_init(dev);",
"sysbus_mmio_map(s, 0, MP_AUDIO_BASE);",
"sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);",
"#endif\nmusicpal_binfo.VAR_0 = MP_RAM_DEFAULT_SIZE;",
"musicpal_binfo.VAR_2 = VAR_2;",
"musicpal_binfo.VAR_3 = VAR_3;",
"musicpal_binfo.VAR_4 = VAR_4;",
"arm_load_kernel(env, &musicpal_binfo);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67,
69
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89,
91,
93
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
145,
147,
149,
151,
153,
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
181
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
201,
203
],
[
207
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
]
]
|
16,675 | size_t qemu_mempath_getpagesize(const char *mem_path)
{
#ifdef CONFIG_LINUX
struct statfs fs;
int ret;
do {
ret = statfs(mem_path, &fs);
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
fprintf(stderr, "Couldn't statfs() memory path: %s\n",
strerror(errno));
exit(1);
}
if (fs.f_type == HUGETLBFS_MAGIC) {
/* It's hugepage, return the huge page size */
return fs.f_bsize;
}
return getpagesize();
} | true | qemu | 57d1f6d7ce23e79a8ebe4a57bd2363b269b4664b | size_t qemu_mempath_getpagesize(const char *mem_path)
{
#ifdef CONFIG_LINUX
struct statfs fs;
int ret;
do {
ret = statfs(mem_path, &fs);
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
fprintf(stderr, "Couldn't statfs() memory path: %s\n",
strerror(errno));
exit(1);
}
if (fs.f_type == HUGETLBFS_MAGIC) {
return fs.f_bsize;
}
return getpagesize();
} | {
"code": [],
"line_no": []
} | size_t FUNC_0(const char *mem_path)
{
#ifdef CONFIG_LINUX
struct statfs fs;
int ret;
do {
ret = statfs(mem_path, &fs);
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
fprintf(stderr, "Couldn't statfs() memory path: %s\n",
strerror(errno));
exit(1);
}
if (fs.f_type == HUGETLBFS_MAGIC) {
return fs.f_bsize;
}
return getpagesize();
} | [
"size_t FUNC_0(const char *mem_path)\n{",
"#ifdef CONFIG_LINUX\nstruct statfs fs;",
"int ret;",
"do {",
"ret = statfs(mem_path, &fs);",
"} while (ret != 0 && errno == EINTR);",
"if (ret != 0) {",
"fprintf(stderr, \"Couldn't statfs() memory path: %s\\n\",\nstrerror(errno));",
"exit(1);",
"}",
"if (fs.f_type == HUGETLBFS_MAGIC) {",
"return fs.f_bsize;",
"}",
"return getpagesize();",
"}"
]
| [
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
],
[
33
],
[
37
],
[
39
],
[
48
],
[
50
]
]
|
16,676 | static int nbd_send_negotiate(NBDClient *client)
{
int csock = client->sock;
char buf[8 + 8 + 8 + 128];
int rc;
const int myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
/* Negotiation header without options:
[ 0 .. 7] passwd ("NBDMAGIC")
[ 8 .. 15] magic (NBD_CLIENT_MAGIC)
[16 .. 23] size
[24 .. 25] server flags (0)
[24 .. 27] export flags
[28 .. 151] reserved (0)
Negotiation header with options, part 1:
[ 0 .. 7] passwd ("NBDMAGIC")
[ 8 .. 15] magic (NBD_OPTS_MAGIC)
[16 .. 17] server flags (0)
part 2 (after options are sent):
[18 .. 25] size
[26 .. 27] export flags
[28 .. 151] reserved (0)
*/
socket_set_block(csock);
rc = -EINVAL;
TRACE("Beginning negotiation.");
memcpy(buf, "NBDMAGIC", 8);
if (client->exp) {
assert ((client->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(buf + 8), NBD_CLIENT_MAGIC);
cpu_to_be64w((uint64_t*)(buf + 16), client->exp->size);
cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
} else {
cpu_to_be64w((uint64_t*)(buf + 8), NBD_OPTS_MAGIC);
}
memset(buf + 28, 0, 124);
if (client->exp) {
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("write failed");
goto fail;
}
} else {
if (write_sync(csock, buf, 18) != 18) {
LOG("write failed");
goto fail;
}
rc = nbd_receive_options(client);
if (rc < 0) {
LOG("option negotiation failed");
goto fail;
}
assert ((client->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
if (write_sync(csock, buf + 18, sizeof(buf) - 18) != sizeof(buf) - 18) {
LOG("write failed");
goto fail;
}
}
TRACE("Negotiation succeeded.");
rc = 0;
fail:
socket_set_nonblock(csock);
return rc;
}
| true | qemu | 8ffaaba0e939f2a284bb23d1f6f7f9e2104a97e2 | static int nbd_send_negotiate(NBDClient *client)
{
int csock = client->sock;
char buf[8 + 8 + 8 + 128];
int rc;
const int myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
socket_set_block(csock);
rc = -EINVAL;
TRACE("Beginning negotiation.");
memcpy(buf, "NBDMAGIC", 8);
if (client->exp) {
assert ((client->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(buf + 8), NBD_CLIENT_MAGIC);
cpu_to_be64w((uint64_t*)(buf + 16), client->exp->size);
cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
} else {
cpu_to_be64w((uint64_t*)(buf + 8), NBD_OPTS_MAGIC);
}
memset(buf + 28, 0, 124);
if (client->exp) {
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("write failed");
goto fail;
}
} else {
if (write_sync(csock, buf, 18) != 18) {
LOG("write failed");
goto fail;
}
rc = nbd_receive_options(client);
if (rc < 0) {
LOG("option negotiation failed");
goto fail;
}
assert ((client->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
if (write_sync(csock, buf + 18, sizeof(buf) - 18) != sizeof(buf) - 18) {
LOG("write failed");
goto fail;
}
}
TRACE("Negotiation succeeded.");
rc = 0;
fail:
socket_set_nonblock(csock);
return rc;
}
| {
"code": [
" memset(buf + 28, 0, 124);"
],
"line_no": [
81
]
} | static int FUNC_0(NBDClient *VAR_0)
{
int VAR_1 = VAR_0->sock;
char VAR_2[8 + 8 + 8 + 128];
int VAR_3;
const int VAR_4 = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
socket_set_block(VAR_1);
VAR_3 = -EINVAL;
TRACE("Beginning negotiation.");
memcpy(VAR_2, "NBDMAGIC", 8);
if (VAR_0->exp) {
assert ((VAR_0->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(VAR_2 + 8), NBD_CLIENT_MAGIC);
cpu_to_be64w((uint64_t*)(VAR_2 + 16), VAR_0->exp->size);
cpu_to_be16w((uint16_t*)(VAR_2 + 26), VAR_0->exp->nbdflags | VAR_4);
} else {
cpu_to_be64w((uint64_t*)(VAR_2 + 8), NBD_OPTS_MAGIC);
}
memset(VAR_2 + 28, 0, 124);
if (VAR_0->exp) {
if (write_sync(VAR_1, VAR_2, sizeof(VAR_2)) != sizeof(VAR_2)) {
LOG("write failed");
goto fail;
}
} else {
if (write_sync(VAR_1, VAR_2, 18) != 18) {
LOG("write failed");
goto fail;
}
VAR_3 = nbd_receive_options(VAR_0);
if (VAR_3 < 0) {
LOG("option negotiation failed");
goto fail;
}
assert ((VAR_0->exp->nbdflags & ~65535) == 0);
cpu_to_be64w((uint64_t*)(VAR_2 + 18), VAR_0->exp->size);
cpu_to_be16w((uint16_t*)(VAR_2 + 26), VAR_0->exp->nbdflags | VAR_4);
if (write_sync(VAR_1, VAR_2 + 18, sizeof(VAR_2) - 18) != sizeof(VAR_2) - 18) {
LOG("write failed");
goto fail;
}
}
TRACE("Negotiation succeeded.");
VAR_3 = 0;
fail:
socket_set_nonblock(VAR_1);
return VAR_3;
}
| [
"static int FUNC_0(NBDClient *VAR_0)\n{",
"int VAR_1 = VAR_0->sock;",
"char VAR_2[8 + 8 + 8 + 128];",
"int VAR_3;",
"const int VAR_4 = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |\nNBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);",
"socket_set_block(VAR_1);",
"VAR_3 = -EINVAL;",
"TRACE(\"Beginning negotiation.\");",
"memcpy(VAR_2, \"NBDMAGIC\", 8);",
"if (VAR_0->exp) {",
"assert ((VAR_0->exp->nbdflags & ~65535) == 0);",
"cpu_to_be64w((uint64_t*)(VAR_2 + 8), NBD_CLIENT_MAGIC);",
"cpu_to_be64w((uint64_t*)(VAR_2 + 16), VAR_0->exp->size);",
"cpu_to_be16w((uint16_t*)(VAR_2 + 26), VAR_0->exp->nbdflags | VAR_4);",
"} else {",
"cpu_to_be64w((uint64_t*)(VAR_2 + 8), NBD_OPTS_MAGIC);",
"}",
"memset(VAR_2 + 28, 0, 124);",
"if (VAR_0->exp) {",
"if (write_sync(VAR_1, VAR_2, sizeof(VAR_2)) != sizeof(VAR_2)) {",
"LOG(\"write failed\");",
"goto fail;",
"}",
"} else {",
"if (write_sync(VAR_1, VAR_2, 18) != 18) {",
"LOG(\"write failed\");",
"goto fail;",
"}",
"VAR_3 = nbd_receive_options(VAR_0);",
"if (VAR_3 < 0) {",
"LOG(\"option negotiation failed\");",
"goto fail;",
"}",
"assert ((VAR_0->exp->nbdflags & ~65535) == 0);",
"cpu_to_be64w((uint64_t*)(VAR_2 + 18), VAR_0->exp->size);",
"cpu_to_be16w((uint16_t*)(VAR_2 + 26), VAR_0->exp->nbdflags | VAR_4);",
"if (write_sync(VAR_1, VAR_2 + 18, sizeof(VAR_2) - 18) != sizeof(VAR_2) - 18) {",
"LOG(\"write failed\");",
"goto fail;",
"}",
"}",
"TRACE(\"Negotiation succeeded.\");",
"VAR_3 = 0;",
"fail:\nsocket_set_nonblock(VAR_1);",
"return VAR_3;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
]
]
|
16,677 | static void dmix_sub_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] -= mul15(src[i], coeff);
}
| true | FFmpeg | 9244b839b788e4677019041907ff5a4378a23490 | static void dmix_sub_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] -= mul15(src[i], coeff);
}
| {
"code": [
" dst[i] -= mul15(src[i], coeff);"
],
"line_no": [
11
]
} | static void FUNC_0(int32_t *VAR_0, const int32_t *VAR_1, int VAR_2, ptrdiff_t VAR_3)
{
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)
VAR_0[VAR_4] -= mul15(VAR_1[VAR_4], VAR_2);
}
| [
"static void FUNC_0(int32_t *VAR_0, const int32_t *VAR_1, int VAR_2, ptrdiff_t VAR_3)\n{",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)",
"VAR_0[VAR_4] -= mul15(VAR_1[VAR_4], VAR_2);",
"}"
]
| [
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
16,678 | static int read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
AVStream *st = s->streams[0];
CaffContext *caf = s->priv_data;
int64_t pos;
timestamp = FFMAX(timestamp, 0);
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
/* calculate new byte position based on target frame position */
pos = caf->bytes_per_packet * timestamp / caf->frames_per_packet;
if (caf->data_size > 0)
pos = FFMIN(pos, caf->data_size);
caf->packet_cnt = pos / caf->bytes_per_packet;
caf->frame_cnt = caf->frames_per_packet * caf->packet_cnt;
} else if (st->nb_index_entries) {
caf->packet_cnt = av_index_search_timestamp(st, timestamp, flags);
caf->frame_cnt = st->index_entries[caf->packet_cnt].timestamp;
pos = st->index_entries[caf->packet_cnt].pos;
} else {
return -1;
}
avio_seek(s->pb, pos + caf->data_start, SEEK_SET);
return 0;
}
| true | FFmpeg | 75f418064ecf5c2713151cbe6b3a716d2c047f1d | static int read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
AVStream *st = s->streams[0];
CaffContext *caf = s->priv_data;
int64_t pos;
timestamp = FFMAX(timestamp, 0);
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
pos = caf->bytes_per_packet * timestamp / caf->frames_per_packet;
if (caf->data_size > 0)
pos = FFMIN(pos, caf->data_size);
caf->packet_cnt = pos / caf->bytes_per_packet;
caf->frame_cnt = caf->frames_per_packet * caf->packet_cnt;
} else if (st->nb_index_entries) {
caf->packet_cnt = av_index_search_timestamp(st, timestamp, flags);
caf->frame_cnt = st->index_entries[caf->packet_cnt].timestamp;
pos = st->index_entries[caf->packet_cnt].pos;
} else {
return -1;
}
avio_seek(s->pb, pos + caf->data_start, SEEK_SET);
return 0;
}
| {
"code": [
" avio_seek(s->pb, pos + caf->data_start, SEEK_SET);"
],
"line_no": [
49
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int VAR_3)
{
AVStream *st = VAR_0->streams[0];
CaffContext *caf = VAR_0->priv_data;
int64_t pos;
VAR_2 = FFMAX(VAR_2, 0);
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
pos = caf->bytes_per_packet * VAR_2 / caf->frames_per_packet;
if (caf->data_size > 0)
pos = FFMIN(pos, caf->data_size);
caf->packet_cnt = pos / caf->bytes_per_packet;
caf->frame_cnt = caf->frames_per_packet * caf->packet_cnt;
} else if (st->nb_index_entries) {
caf->packet_cnt = av_index_search_timestamp(st, VAR_2, VAR_3);
caf->frame_cnt = st->index_entries[caf->packet_cnt].VAR_2;
pos = st->index_entries[caf->packet_cnt].pos;
} else {
return -1;
}
avio_seek(VAR_0->pb, pos + caf->data_start, SEEK_SET);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int VAR_3)\n{",
"AVStream *st = VAR_0->streams[0];",
"CaffContext *caf = VAR_0->priv_data;",
"int64_t pos;",
"VAR_2 = FFMAX(VAR_2, 0);",
"if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {",
"pos = caf->bytes_per_packet * VAR_2 / caf->frames_per_packet;",
"if (caf->data_size > 0)\npos = FFMIN(pos, caf->data_size);",
"caf->packet_cnt = pos / caf->bytes_per_packet;",
"caf->frame_cnt = caf->frames_per_packet * caf->packet_cnt;",
"} else if (st->nb_index_entries) {",
"caf->packet_cnt = av_index_search_timestamp(st, VAR_2, VAR_3);",
"caf->frame_cnt = st->index_entries[caf->packet_cnt].VAR_2;",
"pos = st->index_entries[caf->packet_cnt].pos;",
"} else {",
"return -1;",
"}",
"avio_seek(VAR_0->pb, pos + caf->data_start, SEEK_SET);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
]
]
|
16,679 | static int tta_read_header(AVFormatContext *s)
{
TTAContext *c = s->priv_data;
AVStream *st;
int i, channels, bps, samplerate;
uint64_t framepos, start_offset;
uint32_t nb_samples, crc;
ff_id3v1_read(s);
start_offset = avio_tell(s->pb);
ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 2); // FIXME: flags
channels = avio_rl16(s->pb);
bps = avio_rl16(s->pb);
samplerate = avio_rl32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return AVERROR_INVALIDDATA;
}
nb_samples = avio_rl32(s->pb);
if (!nb_samples) {
av_log(s, AV_LOG_ERROR, "invalid number of samples\n");
return AVERROR_INVALIDDATA;
}
crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
if (crc != avio_rl32(s->pb)) {
av_log(s, AV_LOG_ERROR, "Header CRC error\n");
return AVERROR_INVALIDDATA;
}
c->frame_size = samplerate * 256 / 245;
c->last_frame_size = nb_samples % c->frame_size;
if (!c->last_frame_size)
c->last_frame_size = c->frame_size;
c->totalframes = nb_samples / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
av_log(s, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes);
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, samplerate);
st->start_time = 0;
st->duration = nb_samples;
framepos = avio_tell(s->pb) + 4*c->totalframes + 4;
if (ff_alloc_extradata(st->codec, avio_tell(s->pb) - start_offset))
return AVERROR(ENOMEM);
avio_seek(s->pb, start_offset, SEEK_SET);
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
for (i = 0; i < c->totalframes; i++) {
uint32_t size = avio_rl32(s->pb);
av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
AVINDEX_KEYFRAME);
framepos += size;
}
crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
if (crc != avio_rl32(s->pb)) {
av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
return AVERROR_INVALIDDATA;
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TTA;
st->codec->channels = channels;
st->codec->sample_rate = samplerate;
st->codec->bits_per_coded_sample = bps;
if (s->pb->seekable) {
int64_t pos = avio_tell(s->pb);
ff_ape_parse_tag(s);
avio_seek(s->pb, pos, SEEK_SET);
}
return 0;
}
| true | FFmpeg | 6a0cd529a35190d9374b0b26504e71857cd67b83 | static int tta_read_header(AVFormatContext *s)
{
TTAContext *c = s->priv_data;
AVStream *st;
int i, channels, bps, samplerate;
uint64_t framepos, start_offset;
uint32_t nb_samples, crc;
ff_id3v1_read(s);
start_offset = avio_tell(s->pb);
ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 2);
channels = avio_rl16(s->pb);
bps = avio_rl16(s->pb);
samplerate = avio_rl32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return AVERROR_INVALIDDATA;
}
nb_samples = avio_rl32(s->pb);
if (!nb_samples) {
av_log(s, AV_LOG_ERROR, "invalid number of samples\n");
return AVERROR_INVALIDDATA;
}
crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
if (crc != avio_rl32(s->pb)) {
av_log(s, AV_LOG_ERROR, "Header CRC error\n");
return AVERROR_INVALIDDATA;
}
c->frame_size = samplerate * 256 / 245;
c->last_frame_size = nb_samples % c->frame_size;
if (!c->last_frame_size)
c->last_frame_size = c->frame_size;
c->totalframes = nb_samples / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
av_log(s, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes);
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, samplerate);
st->start_time = 0;
st->duration = nb_samples;
framepos = avio_tell(s->pb) + 4*c->totalframes + 4;
if (ff_alloc_extradata(st->codec, avio_tell(s->pb) - start_offset))
return AVERROR(ENOMEM);
avio_seek(s->pb, start_offset, SEEK_SET);
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
for (i = 0; i < c->totalframes; i++) {
uint32_t size = avio_rl32(s->pb);
av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
AVINDEX_KEYFRAME);
framepos += size;
}
crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
if (crc != avio_rl32(s->pb)) {
av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
return AVERROR_INVALIDDATA;
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TTA;
st->codec->channels = channels;
st->codec->sample_rate = samplerate;
st->codec->bits_per_coded_sample = bps;
if (s->pb->seekable) {
int64_t pos = avio_tell(s->pb);
ff_ape_parse_tag(s);
avio_seek(s->pb, pos, SEEK_SET);
}
return 0;
}
| {
"code": [
" av_add_index_entry(st, framepos, i * c->frame_size, size, 0,",
" AVINDEX_KEYFRAME);"
],
"line_no": [
135,
137
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
TTAContext *c = VAR_0->priv_data;
AVStream *st;
int VAR_1, VAR_2, VAR_3, VAR_4;
uint64_t framepos, start_offset;
uint32_t nb_samples, crc;
ff_id3v1_read(VAR_0);
start_offset = avio_tell(VAR_0->pb);
ffio_init_checksum(VAR_0->pb, tta_check_crc, UINT32_MAX);
if (avio_rl32(VAR_0->pb) != AV_RL32("TTA1"))
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, 2);
VAR_2 = avio_rl16(VAR_0->pb);
VAR_3 = avio_rl16(VAR_0->pb);
VAR_4 = avio_rl32(VAR_0->pb);
if(VAR_4 <= 0 || VAR_4 > 1000000){
av_log(VAR_0, AV_LOG_ERROR, "nonsense VAR_4\n");
return AVERROR_INVALIDDATA;
}
nb_samples = avio_rl32(VAR_0->pb);
if (!nb_samples) {
av_log(VAR_0, AV_LOG_ERROR, "invalid number of samples\n");
return AVERROR_INVALIDDATA;
}
crc = ffio_get_checksum(VAR_0->pb) ^ UINT32_MAX;
if (crc != avio_rl32(VAR_0->pb)) {
av_log(VAR_0, AV_LOG_ERROR, "Header CRC error\n");
return AVERROR_INVALIDDATA;
}
c->frame_size = VAR_4 * 256 / 245;
c->last_frame_size = nb_samples % c->frame_size;
if (!c->last_frame_size)
c->last_frame_size = c->frame_size;
c->totalframes = nb_samples / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
av_log(VAR_0, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes);
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, VAR_4);
st->start_time = 0;
st->duration = nb_samples;
framepos = avio_tell(VAR_0->pb) + 4*c->totalframes + 4;
if (ff_alloc_extradata(st->codec, avio_tell(VAR_0->pb) - start_offset))
return AVERROR(ENOMEM);
avio_seek(VAR_0->pb, start_offset, SEEK_SET);
avio_read(VAR_0->pb, st->codec->extradata, st->codec->extradata_size);
ffio_init_checksum(VAR_0->pb, tta_check_crc, UINT32_MAX);
for (VAR_1 = 0; VAR_1 < c->totalframes; VAR_1++) {
uint32_t size = avio_rl32(VAR_0->pb);
av_add_index_entry(st, framepos, VAR_1 * c->frame_size, size, 0,
AVINDEX_KEYFRAME);
framepos += size;
}
crc = ffio_get_checksum(VAR_0->pb) ^ UINT32_MAX;
if (crc != avio_rl32(VAR_0->pb)) {
av_log(VAR_0, AV_LOG_ERROR, "Seek table CRC error\n");
return AVERROR_INVALIDDATA;
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TTA;
st->codec->VAR_2 = VAR_2;
st->codec->sample_rate = VAR_4;
st->codec->bits_per_coded_sample = VAR_3;
if (VAR_0->pb->seekable) {
int64_t pos = avio_tell(VAR_0->pb);
ff_ape_parse_tag(VAR_0);
avio_seek(VAR_0->pb, pos, SEEK_SET);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"TTAContext *c = VAR_0->priv_data;",
"AVStream *st;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"uint64_t framepos, start_offset;",
"uint32_t nb_samples, crc;",
"ff_id3v1_read(VAR_0);",
"start_offset = avio_tell(VAR_0->pb);",
"ffio_init_checksum(VAR_0->pb, tta_check_crc, UINT32_MAX);",
"if (avio_rl32(VAR_0->pb) != AV_RL32(\"TTA1\"))\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, 2);",
"VAR_2 = avio_rl16(VAR_0->pb);",
"VAR_3 = avio_rl16(VAR_0->pb);",
"VAR_4 = avio_rl32(VAR_0->pb);",
"if(VAR_4 <= 0 || VAR_4 > 1000000){",
"av_log(VAR_0, AV_LOG_ERROR, \"nonsense VAR_4\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"nb_samples = avio_rl32(VAR_0->pb);",
"if (!nb_samples) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid number of samples\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"crc = ffio_get_checksum(VAR_0->pb) ^ UINT32_MAX;",
"if (crc != avio_rl32(VAR_0->pb)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Header CRC error\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"c->frame_size = VAR_4 * 256 / 245;",
"c->last_frame_size = nb_samples % c->frame_size;",
"if (!c->last_frame_size)\nc->last_frame_size = c->frame_size;",
"c->totalframes = nb_samples / c->frame_size + (c->last_frame_size < c->frame_size);",
"c->currentframe = 0;",
"if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"totalframes %d invalid\\n\", c->totalframes);",
"return AVERROR_INVALIDDATA;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 64, 1, VAR_4);",
"st->start_time = 0;",
"st->duration = nb_samples;",
"framepos = avio_tell(VAR_0->pb) + 4*c->totalframes + 4;",
"if (ff_alloc_extradata(st->codec, avio_tell(VAR_0->pb) - start_offset))\nreturn AVERROR(ENOMEM);",
"avio_seek(VAR_0->pb, start_offset, SEEK_SET);",
"avio_read(VAR_0->pb, st->codec->extradata, st->codec->extradata_size);",
"ffio_init_checksum(VAR_0->pb, tta_check_crc, UINT32_MAX);",
"for (VAR_1 = 0; VAR_1 < c->totalframes; VAR_1++) {",
"uint32_t size = avio_rl32(VAR_0->pb);",
"av_add_index_entry(st, framepos, VAR_1 * c->frame_size, size, 0,\nAVINDEX_KEYFRAME);",
"framepos += size;",
"}",
"crc = ffio_get_checksum(VAR_0->pb) ^ UINT32_MAX;",
"if (crc != avio_rl32(VAR_0->pb)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Seek table CRC error\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codec->codec_id = AV_CODEC_ID_TTA;",
"st->codec->VAR_2 = VAR_2;",
"st->codec->sample_rate = VAR_4;",
"st->codec->bits_per_coded_sample = VAR_3;",
"if (VAR_0->pb->seekable) {",
"int64_t pos = avio_tell(VAR_0->pb);",
"ff_ape_parse_tag(VAR_0);",
"avio_seek(VAR_0->pb, pos, 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99,
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117,
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
]
]
|
16,680 | static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
int plane, i, j;
for (plane=0; plane<4; plane++) {
int length= (plane==0 || plane==3) ? c->srcW : -((-c->srcW )>>c->chrDstHSubSample);
int y= (plane==0 || plane==3) ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
int height= (plane==0 || plane==3) ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
const uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
if (!dst[plane]) continue;
// ignore palette for GRAY8
if (plane == 1 && !dst[2]) continue;
if (!src[plane] || (plane == 1 && !src[2])) {
if(is16BPS(c->dstFormat))
length*=2;
fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
} else {
if(is9_OR_10BPS(c->srcFormat)) {
const int src_depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
if (is16BPS(c->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO16(rfunc, wfunc) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
int srcpx = rfunc(&srcPtr2[j]); \
wfunc(&dstPtr2[j], (srcpx<<(16-src_depth)) | (srcpx>>(2*src_depth-16))); \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr2 += srcStride[plane]/2; \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WL16);
}
}
} else if (is9_OR_10BPS(c->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO9_OR_10(loop) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
loop; \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr2 += srcStride[plane]/2; \
}
#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \
if (dst_depth > src_depth) { \
COPY9_OR_10TO9_OR_10(int srcpx = rfunc(&srcPtr2[j]); \
wfunc(&dstPtr2[j], (srcpx << 1) | (srcpx >> 9))); \
} else if (dst_depth < src_depth) { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]))); \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WL16);
}
}
} else {
#define W8(a, b) { *(a) = (b); }
#define COPY9_OR_10TO8(rfunc) \
if (src_depth == 9) { \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_3, 2); \
}
if (isBE(c->srcFormat)) {
COPY9_OR_10TO8(AV_RB16);
} else {
COPY9_OR_10TO8(AV_RL16);
}
}
} else if(is9_OR_10BPS(c->dstFormat)) {
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
if (is16BPS(c->srcFormat)) {
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
#define COPY16TO9_OR_10(rfunc, wfunc) \
if (dst_depth == 9) { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_128, 7); \
} else { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_64, 6); \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WB16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WL16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WL16);
}
}
} else /* 8bit */ {
#define COPY8TO9_OR_10(wfunc) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
const int srcpx = srcPtr[j]; \
wfunc(&dstPtr2[j], (srcpx<<(dst_depth-8)) | (srcpx >> (16-dst_depth))); \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr += srcStride[plane]; \
}
if (isBE(c->dstFormat)) {
COPY8TO9_OR_10(AV_WB16);
} else {
COPY8TO9_OR_10(AV_WL16);
}
}
} else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
#define COPY16TO8(rfunc) \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_256, 8);
if (isBE(c->srcFormat)) {
COPY16TO8(AV_RB16);
} else {
COPY16TO8(AV_RL16);
}
} else if(!is16BPS(c->srcFormat) && is16BPS(c->dstFormat)) {
for (i=0; i<height; i++) {
for (j=0; j<length; j++) {
dstPtr[ j<<1 ] = srcPtr[j];
dstPtr[(j<<1)+1] = srcPtr[j];
}
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
} else if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat)
&& isBE(c->srcFormat) != isBE(c->dstFormat)) {
for (i=0; i<height; i++) {
for (j=0; j<length; j++)
((uint16_t*)dstPtr)[j] = av_bswap16(((const uint16_t*)srcPtr)[j]);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
} else if (dstStride[plane] == srcStride[plane] &&
srcStride[plane] > 0 && srcStride[plane] == length) {
memcpy(dst[plane] + dstStride[plane]*y, src[plane],
height*dstStride[plane]);
} else {
if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
length*=2;
for (i=0; i<height; i++) {
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
}
}
}
return srcSliceH;
}
| true | FFmpeg | 55eda370cb6fe9e4c21539f3f90fd940fcf7a103 | static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
int plane, i, j;
for (plane=0; plane<4; plane++) {
int length= (plane==0 || plane==3) ? c->srcW : -((-c->srcW )>>c->chrDstHSubSample);
int y= (plane==0 || plane==3) ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
int height= (plane==0 || plane==3) ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
const uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
if (!dst[plane]) continue;
if (plane == 1 && !dst[2]) continue;
if (!src[plane] || (plane == 1 && !src[2])) {
if(is16BPS(c->dstFormat))
length*=2;
fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
} else {
if(is9_OR_10BPS(c->srcFormat)) {
const int src_depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
if (is16BPS(c->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO16(rfunc, wfunc) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
int srcpx = rfunc(&srcPtr2[j]); \
wfunc(&dstPtr2[j], (srcpx<<(16-src_depth)) | (srcpx>>(2*src_depth-16))); \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr2 += srcStride[plane]/2; \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WL16);
}
}
} else if (is9_OR_10BPS(c->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO9_OR_10(loop) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
loop; \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr2 += srcStride[plane]/2; \
}
#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \
if (dst_depth > src_depth) { \
COPY9_OR_10TO9_OR_10(int srcpx = rfunc(&srcPtr2[j]); \
wfunc(&dstPtr2[j], (srcpx << 1) | (srcpx >> 9))); \
} else if (dst_depth < src_depth) { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]))); \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WL16);
}
}
} else {
#define W8(a, b) { *(a) = (b); }
#define COPY9_OR_10TO8(rfunc) \
if (src_depth == 9) { \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_3, 2); \
}
if (isBE(c->srcFormat)) {
COPY9_OR_10TO8(AV_RB16);
} else {
COPY9_OR_10TO8(AV_RL16);
}
}
} else if(is9_OR_10BPS(c->dstFormat)) {
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
if (is16BPS(c->srcFormat)) {
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
#define COPY16TO9_OR_10(rfunc, wfunc) \
if (dst_depth == 9) { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_128, 7); \
} else { \
DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_64, 6); \
}
if (isBE(c->dstFormat)) {
if (isBE(c->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WB16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WB16);
}
} else {
if (isBE(c->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WL16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WL16);
}
}
} else {
#define COPY8TO9_OR_10(wfunc) \
for (i = 0; i < height; i++) { \
for (j = 0; j < length; j++) { \
const int srcpx = srcPtr[j]; \
wfunc(&dstPtr2[j], (srcpx<<(dst_depth-8)) | (srcpx >> (16-dst_depth))); \
} \
dstPtr2 += dstStride[plane]/2; \
srcPtr += srcStride[plane]; \
}
if (isBE(c->dstFormat)) {
COPY8TO9_OR_10(AV_WB16);
} else {
COPY8TO9_OR_10(AV_WL16);
}
}
} else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
#define COPY16TO8(rfunc) \
DITHER_COPY(dstPtr, dstStride[plane], W8, \
srcPtr2, srcStride[plane]/2, rfunc, \
dither_8x8_256, 8);
if (isBE(c->srcFormat)) {
COPY16TO8(AV_RB16);
} else {
COPY16TO8(AV_RL16);
}
} else if(!is16BPS(c->srcFormat) && is16BPS(c->dstFormat)) {
for (i=0; i<height; i++) {
for (j=0; j<length; j++) {
dstPtr[ j<<1 ] = srcPtr[j];
dstPtr[(j<<1)+1] = srcPtr[j];
}
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
} else if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat)
&& isBE(c->srcFormat) != isBE(c->dstFormat)) {
for (i=0; i<height; i++) {
for (j=0; j<length; j++)
((uint16_t*)dstPtr)[j] = av_bswap16(((const uint16_t*)srcPtr)[j]);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
} else if (dstStride[plane] == srcStride[plane] &&
srcStride[plane] > 0 && srcStride[plane] == length) {
memcpy(dst[plane] + dstStride[plane]*y, src[plane],
height*dstStride[plane]);
} else {
if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
length*=2;
for (i=0; i<height; i++) {
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
}
}
}
return srcSliceH;
}
| {
"code": [
" dither_8x8_1, 1); \\",
" dither_8x8_1, 1); \\",
" dither_8x8_3, 2); \\",
" dither_8x8_128, 7); \\",
" dither_8x8_64, 6); \\",
" dither_8x8_256, 8);"
],
"line_no": [
131,
131,
185,
221,
229,
301
]
} | static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[], int VAR_2[], int VAR_3,
int VAR_4, uint8_t* VAR_5[], int VAR_6[])
{
int VAR_7, VAR_8, VAR_9;
for (VAR_7=0; VAR_7<4; VAR_7++) {
int VAR_10= (VAR_7==0 || VAR_7==3) ? VAR_0->srcW : -((-VAR_0->srcW )>>VAR_0->chrDstHSubSample);
int VAR_11= (VAR_7==0 || VAR_7==3) ? VAR_3: -((-VAR_3)>>VAR_0->chrDstVSubSample);
int VAR_12= (VAR_7==0 || VAR_7==3) ? VAR_4: -((-VAR_4)>>VAR_0->chrDstVSubSample);
const uint8_t *VAR_13= VAR_1[VAR_7];
uint8_t *dstPtr= VAR_5[VAR_7] + VAR_6[VAR_7]*VAR_11;
if (!VAR_5[VAR_7]) continue;
if (VAR_7 == 1 && !VAR_5[2]) continue;
if (!VAR_1[VAR_7] || (VAR_7 == 1 && !VAR_1[2])) {
if(is16BPS(VAR_0->dstFormat))
VAR_10*=2;
fillPlane(VAR_5[VAR_7], VAR_6[VAR_7], VAR_10, VAR_12, VAR_11, (VAR_7==3) ? 255 : 128);
} else {
if(is9_OR_10BPS(VAR_0->srcFormat)) {
const int VAR_14 = av_pix_fmt_descriptors[VAR_0->srcFormat].comp[VAR_7].depth_minus1+1;
const int VAR_18 = av_pix_fmt_descriptors[VAR_0->dstFormat].comp[VAR_7].depth_minus1+1;
const uint16_t *VAR_18 = (const uint16_t*)VAR_13;
if (is16BPS(VAR_0->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO16(rfunc, wfunc) \
for (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \
for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \
int VAR_18 = rfunc(&VAR_18[VAR_9]); \
wfunc(&dstPtr2[VAR_9], (VAR_18<<(16-VAR_14)) | (VAR_18>>(2*VAR_14-16))); \
} \
dstPtr2 += VAR_6[VAR_7]/2; \
VAR_18 += VAR_2[VAR_7]/2; \
}
if (isBE(VAR_0->dstFormat)) {
if (isBE(VAR_0->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WB16);
}
} else {
if (isBE(VAR_0->srcFormat)) {
COPY9_OR_10TO16(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO16(AV_RL16, AV_WL16);
}
}
} else if (is9_OR_10BPS(VAR_0->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
#define COPY9_OR_10TO9_OR_10(loop) \
for (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \
for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \
loop; \
} \
dstPtr2 += VAR_6[VAR_7]/2; \
VAR_18 += VAR_2[VAR_7]/2; \
}
#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \
if (VAR_18 > VAR_14) { \
COPY9_OR_10TO9_OR_10(int VAR_18 = rfunc(&VAR_18[VAR_9]); \
wfunc(&dstPtr2[VAR_9], (VAR_18 << 1) | (VAR_18 >> 9))); \
} else if (VAR_18 < VAR_14) { \
DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[VAR_9], rfunc(&VAR_18[VAR_9]))); \
}
if (isBE(VAR_0->dstFormat)) {
if (isBE(VAR_0->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WB16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WB16);
}
} else {
if (isBE(VAR_0->srcFormat)) {
COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WL16);
} else {
COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WL16);
}
}
} else {
#define W8(a, b) { *(a) = (b); }
#define COPY9_OR_10TO8(rfunc) \
if (VAR_14 == 9) { \
DITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_1, 1); \
} else { \
DITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_3, 2); \
}
if (isBE(VAR_0->srcFormat)) {
COPY9_OR_10TO8(AV_RB16);
} else {
COPY9_OR_10TO8(AV_RL16);
}
}
} else if(is9_OR_10BPS(VAR_0->dstFormat)) {
const int VAR_18 = av_pix_fmt_descriptors[VAR_0->dstFormat].comp[VAR_7].depth_minus1+1;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
if (is16BPS(VAR_0->srcFormat)) {
const uint16_t *VAR_18 = (const uint16_t*)VAR_13;
#define COPY16TO9_OR_10(rfunc, wfunc) \
if (VAR_18 == 9) { \
DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_128, 7); \
} else { \
DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_64, 6); \
}
if (isBE(VAR_0->dstFormat)) {
if (isBE(VAR_0->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WB16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WB16);
}
} else {
if (isBE(VAR_0->srcFormat)) {
COPY16TO9_OR_10(AV_RB16, AV_WL16);
} else {
COPY16TO9_OR_10(AV_RL16, AV_WL16);
}
}
} else {
#define COPY8TO9_OR_10(wfunc) \
for (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \
for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \
const int VAR_18 = VAR_13[VAR_9]; \
wfunc(&dstPtr2[VAR_9], (VAR_18<<(VAR_18-8)) | (VAR_18 >> (16-VAR_18))); \
} \
dstPtr2 += VAR_6[VAR_7]/2; \
VAR_13 += VAR_2[VAR_7]; \
}
if (isBE(VAR_0->dstFormat)) {
COPY8TO9_OR_10(AV_WB16);
} else {
COPY8TO9_OR_10(AV_WL16);
}
}
} else if(is16BPS(VAR_0->srcFormat) && !is16BPS(VAR_0->dstFormat)) {
const uint16_t *VAR_18 = (const uint16_t*)VAR_13;
#define COPY16TO8(rfunc) \
DITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \
VAR_18, VAR_2[VAR_7]/2, rfunc, \
dither_8x8_256, 8);
if (isBE(VAR_0->srcFormat)) {
COPY16TO8(AV_RB16);
} else {
COPY16TO8(AV_RL16);
}
} else if(!is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat)) {
for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {
for (VAR_9=0; VAR_9<VAR_10; VAR_9++) {
dstPtr[ VAR_9<<1 ] = VAR_13[VAR_9];
dstPtr[(VAR_9<<1)+1] = VAR_13[VAR_9];
}
VAR_13+= VAR_2[VAR_7];
dstPtr+= VAR_6[VAR_7];
}
} else if(is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat)
&& isBE(VAR_0->srcFormat) != isBE(VAR_0->dstFormat)) {
for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {
for (VAR_9=0; VAR_9<VAR_10; VAR_9++)
((uint16_t*)dstPtr)[VAR_9] = av_bswap16(((const uint16_t*)VAR_13)[VAR_9]);
VAR_13+= VAR_2[VAR_7];
dstPtr+= VAR_6[VAR_7];
}
} else if (VAR_6[VAR_7] == VAR_2[VAR_7] &&
VAR_2[VAR_7] > 0 && VAR_2[VAR_7] == VAR_10) {
memcpy(VAR_5[VAR_7] + VAR_6[VAR_7]*VAR_11, VAR_1[VAR_7],
VAR_12*VAR_6[VAR_7]);
} else {
if(is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat))
VAR_10*=2;
for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {
memcpy(dstPtr, VAR_13, VAR_10);
VAR_13+= VAR_2[VAR_7];
dstPtr+= VAR_6[VAR_7];
}
}
}
}
return VAR_4;
}
| [
"static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[], int VAR_2[], int VAR_3,\nint VAR_4, uint8_t* VAR_5[], int VAR_6[])\n{",
"int VAR_7, VAR_8, VAR_9;",
"for (VAR_7=0; VAR_7<4; VAR_7++) {",
"int VAR_10= (VAR_7==0 || VAR_7==3) ? VAR_0->srcW : -((-VAR_0->srcW )>>VAR_0->chrDstHSubSample);",
"int VAR_11= (VAR_7==0 || VAR_7==3) ? VAR_3: -((-VAR_3)>>VAR_0->chrDstVSubSample);",
"int VAR_12= (VAR_7==0 || VAR_7==3) ? VAR_4: -((-VAR_4)>>VAR_0->chrDstVSubSample);",
"const uint8_t *VAR_13= VAR_1[VAR_7];",
"uint8_t *dstPtr= VAR_5[VAR_7] + VAR_6[VAR_7]*VAR_11;",
"if (!VAR_5[VAR_7]) continue;",
"if (VAR_7 == 1 && !VAR_5[2]) continue;",
"if (!VAR_1[VAR_7] || (VAR_7 == 1 && !VAR_1[2])) {",
"if(is16BPS(VAR_0->dstFormat))\nVAR_10*=2;",
"fillPlane(VAR_5[VAR_7], VAR_6[VAR_7], VAR_10, VAR_12, VAR_11, (VAR_7==3) ? 255 : 128);",
"} else {",
"if(is9_OR_10BPS(VAR_0->srcFormat)) {",
"const int VAR_14 = av_pix_fmt_descriptors[VAR_0->srcFormat].comp[VAR_7].depth_minus1+1;",
"const int VAR_18 = av_pix_fmt_descriptors[VAR_0->dstFormat].comp[VAR_7].depth_minus1+1;",
"const uint16_t *VAR_18 = (const uint16_t*)VAR_13;",
"if (is16BPS(VAR_0->dstFormat)) {",
"uint16_t *dstPtr2 = (uint16_t*)dstPtr;",
"#define COPY9_OR_10TO16(rfunc, wfunc) \\\nfor (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \\",
"for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \\",
"int VAR_18 = rfunc(&VAR_18[VAR_9]); \\",
"wfunc(&dstPtr2[VAR_9], (VAR_18<<(16-VAR_14)) | (VAR_18>>(2*VAR_14-16))); \\",
"} \\",
"dstPtr2 += VAR_6[VAR_7]/2; \\",
"VAR_18 += VAR_2[VAR_7]/2; \\",
"}",
"if (isBE(VAR_0->dstFormat)) {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY9_OR_10TO16(AV_RB16, AV_WB16);",
"} else {",
"COPY9_OR_10TO16(AV_RL16, AV_WB16);",
"}",
"} else {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY9_OR_10TO16(AV_RB16, AV_WL16);",
"} else {",
"COPY9_OR_10TO16(AV_RL16, AV_WL16);",
"}",
"}",
"} else if (is9_OR_10BPS(VAR_0->dstFormat)) {",
"uint16_t *dstPtr2 = (uint16_t*)dstPtr;",
"#define COPY9_OR_10TO9_OR_10(loop) \\\nfor (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \\",
"for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \\",
"loop; \\",
"} \\",
"dstPtr2 += VAR_6[VAR_7]/2; \\",
"VAR_18 += VAR_2[VAR_7]/2; \\",
"}",
"#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \\\nif (VAR_18 > VAR_14) { \\",
"COPY9_OR_10TO9_OR_10(int VAR_18 = rfunc(&VAR_18[VAR_9]); \\",
"wfunc(&dstPtr2[VAR_9], (VAR_18 << 1) | (VAR_18 >> 9))); \\",
"} else if (VAR_18 < VAR_14) { \\",
"DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_1, 1); \\",
"} else { \\",
"COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[VAR_9], rfunc(&VAR_18[VAR_9]))); \\",
"}",
"if (isBE(VAR_0->dstFormat)) {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WB16);",
"} else {",
"COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WB16);",
"}",
"} else {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WL16);",
"} else {",
"COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WL16);",
"}",
"}",
"} else {",
"#define W8(a, b) { *(a) = (b); }",
"#define COPY9_OR_10TO8(rfunc) \\\nif (VAR_14 == 9) { \\",
"DITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_1, 1); \\",
"} else { \\",
"DITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_3, 2); \\",
"}",
"if (isBE(VAR_0->srcFormat)) {",
"COPY9_OR_10TO8(AV_RB16);",
"} else {",
"COPY9_OR_10TO8(AV_RL16);",
"}",
"}",
"} else if(is9_OR_10BPS(VAR_0->dstFormat)) {",
"const int VAR_18 = av_pix_fmt_descriptors[VAR_0->dstFormat].comp[VAR_7].depth_minus1+1;",
"uint16_t *dstPtr2 = (uint16_t*)dstPtr;",
"if (is16BPS(VAR_0->srcFormat)) {",
"const uint16_t *VAR_18 = (const uint16_t*)VAR_13;",
"#define COPY16TO9_OR_10(rfunc, wfunc) \\\nif (VAR_18 == 9) { \\",
"DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_128, 7); \\",
"} else { \\",
"DITHER_COPY(dstPtr2, VAR_6[VAR_7]/2, wfunc, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_64, 6); \\",
"}",
"if (isBE(VAR_0->dstFormat)) {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY16TO9_OR_10(AV_RB16, AV_WB16);",
"} else {",
"COPY16TO9_OR_10(AV_RL16, AV_WB16);",
"}",
"} else {",
"if (isBE(VAR_0->srcFormat)) {",
"COPY16TO9_OR_10(AV_RB16, AV_WL16);",
"} else {",
"COPY16TO9_OR_10(AV_RL16, AV_WL16);",
"}",
"}",
"} else {",
"#define COPY8TO9_OR_10(wfunc) \\\nfor (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) { \\",
"for (VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { \\",
"const int VAR_18 = VAR_13[VAR_9]; \\",
"wfunc(&dstPtr2[VAR_9], (VAR_18<<(VAR_18-8)) | (VAR_18 >> (16-VAR_18))); \\",
"} \\",
"dstPtr2 += VAR_6[VAR_7]/2; \\",
"VAR_13 += VAR_2[VAR_7]; \\",
"}",
"if (isBE(VAR_0->dstFormat)) {",
"COPY8TO9_OR_10(AV_WB16);",
"} else {",
"COPY8TO9_OR_10(AV_WL16);",
"}",
"}",
"} else if(is16BPS(VAR_0->srcFormat) && !is16BPS(VAR_0->dstFormat)) {",
"const uint16_t *VAR_18 = (const uint16_t*)VAR_13;",
"#define COPY16TO8(rfunc) \\\nDITHER_COPY(dstPtr, VAR_6[VAR_7], W8, \\\nVAR_18, VAR_2[VAR_7]/2, rfunc, \\\ndither_8x8_256, 8);",
"if (isBE(VAR_0->srcFormat)) {",
"COPY16TO8(AV_RB16);",
"} else {",
"COPY16TO8(AV_RL16);",
"}",
"} else if(!is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat)) {",
"for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {",
"for (VAR_9=0; VAR_9<VAR_10; VAR_9++) {",
"dstPtr[ VAR_9<<1 ] = VAR_13[VAR_9];",
"dstPtr[(VAR_9<<1)+1] = VAR_13[VAR_9];",
"}",
"VAR_13+= VAR_2[VAR_7];",
"dstPtr+= VAR_6[VAR_7];",
"}",
"} else if(is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat)",
"&& isBE(VAR_0->srcFormat) != isBE(VAR_0->dstFormat)) {",
"for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {",
"for (VAR_9=0; VAR_9<VAR_10; VAR_9++)",
"((uint16_t*)dstPtr)[VAR_9] = av_bswap16(((const uint16_t*)VAR_13)[VAR_9]);",
"VAR_13+= VAR_2[VAR_7];",
"dstPtr+= VAR_6[VAR_7];",
"}",
"} else if (VAR_6[VAR_7] == VAR_2[VAR_7] &&",
"VAR_2[VAR_7] > 0 && VAR_2[VAR_7] == VAR_10) {",
"memcpy(VAR_5[VAR_7] + VAR_6[VAR_7]*VAR_11, VAR_1[VAR_7],\nVAR_12*VAR_6[VAR_7]);",
"} else {",
"if(is16BPS(VAR_0->srcFormat) && is16BPS(VAR_0->dstFormat))\nVAR_10*=2;",
"for (VAR_8=0; VAR_8<VAR_12; VAR_8++) {",
"memcpy(dstPtr, VAR_13, VAR_10);",
"VAR_13+= VAR_2[VAR_7];",
"dstPtr+= VAR_6[VAR_7];",
"}",
"}",
"}",
"}",
"return VAR_4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173,
175,
177
],
[
179
],
[
181,
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213,
215
],
[
217,
219,
221
],
[
223
],
[
225,
227,
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297,
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
]
]
|
16,681 | static int nbd_co_receive_offset_data_payload(NBDClientSession *s,
uint64_t orig_offset,
QEMUIOVector *qiov, Error **errp)
{
QEMUIOVector sub_qiov;
uint64_t offset;
size_t data_size;
int ret;
NBDStructuredReplyChunk *chunk = &s->reply.structured;
assert(nbd_reply_is_structured(&s->reply));
if (chunk->length < sizeof(offset)) {
error_setg(errp, "Protocol error: invalid payload for "
"NBD_REPLY_TYPE_OFFSET_DATA");
return -EINVAL;
}
if (nbd_read(s->ioc, &offset, sizeof(offset), errp) < 0) {
return -EIO;
}
be64_to_cpus(&offset);
data_size = chunk->length - sizeof(offset);
if (offset < orig_offset || data_size > qiov->size ||
offset > orig_offset + qiov->size - data_size) {
error_setg(errp, "Protocol error: server sent chunk exceeding requested"
" region");
return -EINVAL;
}
qemu_iovec_init(&sub_qiov, qiov->niov);
qemu_iovec_concat(&sub_qiov, qiov, offset - orig_offset, data_size);
ret = qio_channel_readv_all(s->ioc, sub_qiov.iov, sub_qiov.niov, errp);
qemu_iovec_destroy(&sub_qiov);
return ret < 0 ? -EIO : 0;
}
| true | qemu | b4176cb314995ad225d6c2b531568801feb04f3f | static int nbd_co_receive_offset_data_payload(NBDClientSession *s,
uint64_t orig_offset,
QEMUIOVector *qiov, Error **errp)
{
QEMUIOVector sub_qiov;
uint64_t offset;
size_t data_size;
int ret;
NBDStructuredReplyChunk *chunk = &s->reply.structured;
assert(nbd_reply_is_structured(&s->reply));
if (chunk->length < sizeof(offset)) {
error_setg(errp, "Protocol error: invalid payload for "
"NBD_REPLY_TYPE_OFFSET_DATA");
return -EINVAL;
}
if (nbd_read(s->ioc, &offset, sizeof(offset), errp) < 0) {
return -EIO;
}
be64_to_cpus(&offset);
data_size = chunk->length - sizeof(offset);
if (offset < orig_offset || data_size > qiov->size ||
offset > orig_offset + qiov->size - data_size) {
error_setg(errp, "Protocol error: server sent chunk exceeding requested"
" region");
return -EINVAL;
}
qemu_iovec_init(&sub_qiov, qiov->niov);
qemu_iovec_concat(&sub_qiov, qiov, offset - orig_offset, data_size);
ret = qio_channel_readv_all(s->ioc, sub_qiov.iov, sub_qiov.niov, errp);
qemu_iovec_destroy(&sub_qiov);
return ret < 0 ? -EIO : 0;
}
| {
"code": [
" if (chunk->length < sizeof(offset)) {"
],
"line_no": [
25
]
} | static int FUNC_0(NBDClientSession *VAR_0,
uint64_t VAR_1,
QEMUIOVector *VAR_2, Error **VAR_3)
{
QEMUIOVector sub_qiov;
uint64_t offset;
size_t data_size;
int VAR_4;
NBDStructuredReplyChunk *chunk = &VAR_0->reply.structured;
assert(nbd_reply_is_structured(&VAR_0->reply));
if (chunk->length < sizeof(offset)) {
error_setg(VAR_3, "Protocol error: invalid payload for "
"NBD_REPLY_TYPE_OFFSET_DATA");
return -EINVAL;
}
if (nbd_read(VAR_0->ioc, &offset, sizeof(offset), VAR_3) < 0) {
return -EIO;
}
be64_to_cpus(&offset);
data_size = chunk->length - sizeof(offset);
if (offset < VAR_1 || data_size > VAR_2->size ||
offset > VAR_1 + VAR_2->size - data_size) {
error_setg(VAR_3, "Protocol error: server sent chunk exceeding requested"
" region");
return -EINVAL;
}
qemu_iovec_init(&sub_qiov, VAR_2->niov);
qemu_iovec_concat(&sub_qiov, VAR_2, offset - VAR_1, data_size);
VAR_4 = qio_channel_readv_all(VAR_0->ioc, sub_qiov.iov, sub_qiov.niov, VAR_3);
qemu_iovec_destroy(&sub_qiov);
return VAR_4 < 0 ? -EIO : 0;
}
| [
"static int FUNC_0(NBDClientSession *VAR_0,\nuint64_t VAR_1,\nQEMUIOVector *VAR_2, Error **VAR_3)\n{",
"QEMUIOVector sub_qiov;",
"uint64_t offset;",
"size_t data_size;",
"int VAR_4;",
"NBDStructuredReplyChunk *chunk = &VAR_0->reply.structured;",
"assert(nbd_reply_is_structured(&VAR_0->reply));",
"if (chunk->length < sizeof(offset)) {",
"error_setg(VAR_3, \"Protocol error: invalid payload for \"\n\"NBD_REPLY_TYPE_OFFSET_DATA\");",
"return -EINVAL;",
"}",
"if (nbd_read(VAR_0->ioc, &offset, sizeof(offset), VAR_3) < 0) {",
"return -EIO;",
"}",
"be64_to_cpus(&offset);",
"data_size = chunk->length - sizeof(offset);",
"if (offset < VAR_1 || data_size > VAR_2->size ||\noffset > VAR_1 + VAR_2->size - data_size) {",
"error_setg(VAR_3, \"Protocol error: server sent chunk exceeding requested\"\n\" region\");",
"return -EINVAL;",
"}",
"qemu_iovec_init(&sub_qiov, VAR_2->niov);",
"qemu_iovec_concat(&sub_qiov, VAR_2, offset - VAR_1, data_size);",
"VAR_4 = qio_channel_readv_all(VAR_0->ioc, sub_qiov.iov, sub_qiov.niov, VAR_3);",
"qemu_iovec_destroy(&sub_qiov);",
"return VAR_4 < 0 ? -EIO : 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
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
]
]
|
16,682 | void xen_pt_msi_disable(XenPCIPassthroughState *s)
{
XenPTMSI *msi = s->msi;
if (!msi) {
return;
}
xen_pt_msi_set_enable(s, false);
msi_msix_disable(s, msi_addr64(msi), msi->data, msi->pirq, false,
msi->initialized);
/* clear msi info */
msi->flags = 0;
msi->mapped = false;
msi->pirq = XEN_PT_UNASSIGNED_PIRQ;
}
| true | qemu | c976437c7dba9c7444fb41df45468968aaa326ad | void xen_pt_msi_disable(XenPCIPassthroughState *s)
{
XenPTMSI *msi = s->msi;
if (!msi) {
return;
}
xen_pt_msi_set_enable(s, false);
msi_msix_disable(s, msi_addr64(msi), msi->data, msi->pirq, false,
msi->initialized);
msi->flags = 0;
msi->mapped = false;
msi->pirq = XEN_PT_UNASSIGNED_PIRQ;
}
| {
"code": [
" msi->flags = 0;"
],
"line_no": [
29
]
} | void FUNC_0(XenPCIPassthroughState *VAR_0)
{
XenPTMSI *msi = VAR_0->msi;
if (!msi) {
return;
}
xen_pt_msi_set_enable(VAR_0, false);
msi_msix_disable(VAR_0, msi_addr64(msi), msi->data, msi->pirq, false,
msi->initialized);
msi->flags = 0;
msi->mapped = false;
msi->pirq = XEN_PT_UNASSIGNED_PIRQ;
}
| [
"void FUNC_0(XenPCIPassthroughState *VAR_0)\n{",
"XenPTMSI *msi = VAR_0->msi;",
"if (!msi) {",
"return;",
"}",
"xen_pt_msi_set_enable(VAR_0, false);",
"msi_msix_disable(VAR_0, msi_addr64(msi), msi->data, msi->pirq, false,\nmsi->initialized);",
"msi->flags = 0;",
"msi->mapped = false;",
"msi->pirq = XEN_PT_UNASSIGNED_PIRQ;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
29
],
[
31
],
[
33
],
[
35
]
]
|
16,683 | static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
int16_t *filter, int16_t *filterPos, long filterSize)
{
#ifdef HAVE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
if(filterSize==4) // Always true for upscaling, sometimes for down, too.
{
long counter= -2*dstW;
filter-= counter*2;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t" // we use 7 regs here ...
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 4), %%mm1\n\t"
"movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else if(filterSize==8)
{
long counter= -2*dstW;
filter-= counter*4;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t" // we use 7 regs here ...
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
"movd 4(%3, %%"REG_a"), %%mm4 \n\t"
"movd 4(%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm4 \n\t"
"pmaddwd %%mm2, %%mm5 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm5, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else
{
uint8_t *offset = src+filterSize;
long counter= -2*dstW;
// filter-= counter*filterSize/2;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %2, %%"REG_c" \n\t"
"movzwl (%%"REG_c", %0), %%eax \n\t"
"movzwl 2(%%"REG_c", %0), %%edx \n\t"
"mov %5, %%"REG_c" \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"2: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %6), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
"movd (%%"REG_c", %%"REG_d"), %%mm2\n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"paddd %%mm3, %%mm5 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"add $8, %1 \n\t"
"add $4, %%"REG_c" \n\t"
"cmp %4, %%"REG_c" \n\t"
" jb 2b \n\t"
"add %6, %1 \n\t"
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm5 \n\t"
"packssdw %%mm5, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"packssdw %%mm4, %%mm4 \n\t"
"mov %3, %%"REG_a" \n\t"
"movd %%mm4, (%%"REG_a", %0) \n\t"
"add $4, %0 \n\t"
" jnc 1b \n\t"
: "+r" (counter), "+r" (filter)
: "m" (filterPos), "m" (dst), "m"(offset),
"m" (src), "r" (filterSize*2)
: "%"REG_a, "%"REG_c, "%"REG_d
);
}
#else
#ifdef HAVE_ALTIVEC
hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
int i;
for(i=0; i<dstW; i++)
{
int j;
int srcPos= filterPos[i];
int val=0;
// printf("filterPos: %d\n", filterPos[i]);
for(j=0; j<filterSize; j++)
{
// printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]);
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
// filter += hFilterSize;
dst[i] = av_clip(val>>7, 0, (1<<15)-1); // the cubic equation does overflow ...
// dst[i] = val>>7;
}
#endif
#endif
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
int16_t *filter, int16_t *filterPos, long filterSize)
{
#ifdef HAVE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
if(filterSize==4)
{
long counter= -2*dstW;
filter-= counter*2;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 4), %%mm1\n\t"
"movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else if(filterSize==8)
{
long counter= -2*dstW;
filter-= counter*4;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
"movd 4(%3, %%"REG_a"), %%mm4 \n\t"
"movd 4(%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm4 \n\t"
"pmaddwd %%mm2, %%mm5 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm5, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else
{
uint8_t *offset = src+filterSize;
long counter= -2*dstW;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %2, %%"REG_c" \n\t"
"movzwl (%%"REG_c", %0), %%eax \n\t"
"movzwl 2(%%"REG_c", %0), %%edx \n\t"
"mov %5, %%"REG_c" \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"2: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %6), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
"movd (%%"REG_c", %%"REG_d"), %%mm2\n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"paddd %%mm3, %%mm5 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"add $8, %1 \n\t"
"add $4, %%"REG_c" \n\t"
"cmp %4, %%"REG_c" \n\t"
" jb 2b \n\t"
"add %6, %1 \n\t"
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm5 \n\t"
"packssdw %%mm5, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"packssdw %%mm4, %%mm4 \n\t"
"mov %3, %%"REG_a" \n\t"
"movd %%mm4, (%%"REG_a", %0) \n\t"
"add $4, %0 \n\t"
" jnc 1b \n\t"
: "+r" (counter), "+r" (filter)
: "m" (filterPos), "m" (dst), "m"(offset),
"m" (src), "r" (filterSize*2)
: "%"REG_a, "%"REG_c, "%"REG_d
);
}
#else
#ifdef HAVE_ALTIVEC
hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
int i;
for(i=0; i<dstW; i++)
{
int j;
int srcPos= filterPos[i];
int val=0;
for(j=0; j<filterSize; j++)
{
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
dst[i] = av_clip(val>>7, 0, (1<<15)-1);
}
#endif
#endif
}
| {
"code": [
"\t\tasm volatile(",
"\t\tasm volatile(",
"\tint i;",
"\tfor(i=0; i<dstW; i++)",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\tint i;",
"#endif",
"#endif",
"#endif",
"#endif",
"\tint i;",
"#endif",
"#endif",
"#endif",
"#endif",
"#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;",
"\t\t\t\t int16_t *filter, int16_t *filterPos, long filterSize)",
"\tassert(filterSize % 4 == 0 && filterSize>0);",
"\t\tlong counter= -2*dstW;",
"\t\tfilter-= counter*2;",
"\t\tfilterPos-= counter/2;",
"\t\tdst-= counter/2;",
"\t\tasm volatile(",
"\t\t\t\"push %%\"REG_b\" \t\t\\n\\t\"",
"#endif",
"\t\t\t\"pxor %%mm7, %%mm7\t\t\\n\\t\"",
"\t\t\t\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"",
"\t\t\t\"mov %%\"REG_a\", %%\"REG_BP\"\t\\n\\t\"",
"\t\t\tASMALIGN(4)",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\"movzwl (%2, %%\"REG_BP\"), %%eax\t\\n\\t\"",
"\t\t\t\"movzwl 2(%2, %%\"REG_BP\"), %%ebx\\n\\t\"",
"\t\t\t\"movq (%1, %%\"REG_BP\", 4), %%mm1\\n\\t\"",
"\t\t\t\"movq 8(%1, %%\"REG_BP\", 4), %%mm3\\n\\t\"",
"\t\t\t\"movd (%3, %%\"REG_a\"), %%mm0\t\\n\\t\"",
"\t\t\t\"movd (%3, %%\"REG_b\"), %%mm2\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm0\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm3\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm3, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm0, %%mm0\t\t\\n\\t\"",
"\t\t\t\"movd %%mm0, (%4, %%\"REG_BP\")\t\\n\\t\"",
"\t\t\t\"add $4, %%\"REG_BP\"\t\t\\n\\t\"",
"\t\t\t\" jnc 1b\t\t\t\\n\\t\"",
"\t\t\t\"pop %%\"REG_BP\"\t\t\t\\n\\t\"",
"\t\t\t\"pop %%\"REG_b\" \t\t\\n\\t\"",
"\t\t\t: \"+a\" (counter)",
"\t\t\t: \"c\" (filter), \"d\" (filterPos), \"S\" (src), \"D\" (dst)",
"\t\t\t: \"%\"REG_b",
"#endif",
"\t\t);",
"\telse if(filterSize==8)",
"\t\tlong counter= -2*dstW;",
"\t\tfilter-= counter*4;",
"\t\tfilterPos-= counter/2;",
"\t\tdst-= counter/2;",
"\t\tasm volatile(",
"\t\t\t\"push %%\"REG_b\" \t\t\\n\\t\"",
"#endif",
"\t\t\t\"pxor %%mm7, %%mm7\t\t\\n\\t\"",
"\t\t\t\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"",
"\t\t\t\"mov %%\"REG_a\", %%\"REG_BP\"\t\\n\\t\"",
"\t\t\tASMALIGN(4)",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\"movzwl (%2, %%\"REG_BP\"), %%eax\t\\n\\t\"",
"\t\t\t\"movzwl 2(%2, %%\"REG_BP\"), %%ebx\\n\\t\"",
"\t\t\t\"movq (%1, %%\"REG_BP\", 8), %%mm1\\n\\t\"",
"\t\t\t\"movq 16(%1, %%\"REG_BP\", 8), %%mm3\\n\\t\"",
"\t\t\t\"movd (%3, %%\"REG_a\"), %%mm0\t\\n\\t\"",
"\t\t\t\"movd (%3, %%\"REG_b\"), %%mm2\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"",
"\t\t\t\"movq 8(%1, %%\"REG_BP\", 8), %%mm1\\n\\t\"",
"\t\t\t\"movq 24(%1, %%\"REG_BP\", 8), %%mm5\\n\\t\"",
"\t\t\t\"movd 4(%3, %%\"REG_a\"), %%mm4\t\\n\\t\"",
"\t\t\t\"movd 4(%3, %%\"REG_b\"), %%mm2\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm1, %%mm4\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm2, %%mm5\t\t\\n\\t\"",
"\t\t\t\"paddd %%mm4, %%mm0\t\t\\n\\t\"",
"\t\t\t\"paddd %%mm5, %%mm3\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm0\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm3\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm3, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm0, %%mm0\t\t\\n\\t\"",
"\t\t\t\"movd %%mm0, (%4, %%\"REG_BP\")\t\\n\\t\"",
"\t\t\t\"add $4, %%\"REG_BP\"\t\t\\n\\t\"",
"\t\t\t\" jnc 1b\t\t\t\\n\\t\"",
"\t\t\t\"pop %%\"REG_BP\"\t\t\t\\n\\t\"",
"\t\t\t\"pop %%\"REG_b\" \t\t\\n\\t\"",
"\t\t\t: \"+a\" (counter)",
"\t\t\t: \"c\" (filter), \"d\" (filterPos), \"S\" (src), \"D\" (dst)",
"\t\t\t: \"%\"REG_b",
"#endif",
"\t\t);",
"\t\tuint8_t *offset = src+filterSize;",
"\t\tlong counter= -2*dstW;",
"\t\tfilterPos-= counter/2;",
"\t\tdst-= counter/2;",
"\t\tasm volatile(",
"\t\t\t\"pxor %%mm7, %%mm7\t\t\\n\\t\"",
"\t\t\t\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"",
"\t\t\tASMALIGN(4)",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\"mov %2, %%\"REG_c\"\t\t\\n\\t\"",
"\t\t\t\"movzwl (%%\"REG_c\", %0), %%eax\t\\n\\t\"",
"\t\t\t\"movzwl 2(%%\"REG_c\", %0), %%edx\t\\n\\t\"",
"\t\t\t\"mov %5, %%\"REG_c\"\t\t\\n\\t\"",
"\t\t\t\"pxor %%mm4, %%mm4\t\t\\n\\t\"",
"\t\t\t\"pxor %%mm5, %%mm5\t\t\\n\\t\"",
"\t\t\t\"2:\t\t\t\t\\n\\t\"",
"\t\t\t\"movq (%1), %%mm1\t\t\\n\\t\"",
"\t\t\t\"movq (%1, %6), %%mm3\t\t\\n\\t\"",
"\t\t\t\"movd (%%\"REG_c\", %%\"REG_a\"), %%mm0\\n\\t\"",
"\t\t\t\"movd (%%\"REG_c\", %%\"REG_d\"), %%mm2\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"",
"\t\t\t\"paddd %%mm3, %%mm5\t\t\\n\\t\"",
"\t\t\t\"paddd %%mm0, %%mm4\t\t\\n\\t\"",
"\t\t\t\"add $8, %1\t\t\t\\n\\t\"",
"\t\t\t\"add $4, %%\"REG_c\"\t\t\\n\\t\"",
"\t\t\t\"cmp %4, %%\"REG_c\"\t\t\\n\\t\"",
"\t\t\t\" jb 2b\t\t\t\t\\n\\t\"",
"\t\t\t\"add %6, %1\t\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm4\t\t\\n\\t\"",
"\t\t\t\"psrad $8, %%mm5\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm5, %%mm4\t\t\\n\\t\"",
"\t\t\t\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"",
"\t\t\t\"packssdw %%mm4, %%mm4\t\t\\n\\t\"",
"\t\t\t\"mov %3, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"movd %%mm4, (%%\"REG_a\", %0)\t\\n\\t\"",
"\t\t\t\"add $4, %0\t\t\t\\n\\t\"",
"\t\t\t\" jnc 1b\t\t\t\\n\\t\"",
"\t\t\t: \"+r\" (counter), \"+r\" (filter)",
"\t\t\t: \"m\" (filterPos), \"m\" (dst), \"m\"(offset),",
"\t\t\t \"m\" (src), \"r\" (filterSize*2)",
"\t\t\t: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d",
"\t\t);",
"\thScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);",
"\tint i;",
"\tfor(i=0; i<dstW; i++)",
"\t\tint j;",
"\t\tint srcPos= filterPos[i];",
"\t\tint val=0;",
"\t\tfor(j=0; j<filterSize; j++)",
"\t\t\tval += ((int)src[srcPos + j])*filter[filterSize*i + j];",
"\tint i;",
"\t\tasm volatile(",
"#endif",
"\t\t\t\"pxor %%mm7, %%mm7\t\t\\n\\t\"",
"#endif",
"\t\t);",
"#endif",
"\t\t);",
"\tint i;",
"\tint i;",
"\t\tasm volatile(",
"#endif",
"\t\t\t\"pxor %%mm7, %%mm7\t\t\\n\\t\"",
"#endif",
"\t\t);",
"#endif",
"\t\t);",
"\tint i;",
"#endif"
],
"line_no": [
23,
23,
327,
329,
29,
29,
29,
29,
29,
327,
29,
29,
29,
29,
327,
29,
29,
29,
29,
29,
327,
327,
29,
327,
327,
29,
327,
327,
29,
29,
327,
29,
29,
29,
29,
327,
29,
327,
327,
327,
327,
327,
327,
327,
327,
327,
327,
327,
327,
327,
327,
3,
9,
15,
17,
19,
21,
23,
27,
29,
31,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
81,
85,
89,
91,
95,
29,
99,
103,
15,
109,
19,
21,
23,
27,
29,
31,
33,
37,
39,
41,
43,
45,
139,
141,
51,
53,
55,
57,
59,
61,
157,
159,
161,
163,
165,
57,
169,
171,
173,
175,
63,
65,
67,
69,
71,
73,
75,
77,
81,
85,
89,
91,
95,
29,
99,
223,
15,
19,
21,
23,
31,
33,
39,
41,
243,
245,
247,
249,
251,
253,
255,
257,
259,
261,
263,
55,
57,
59,
61,
273,
275,
277,
279,
281,
283,
285,
287,
289,
291,
293,
295,
297,
299,
301,
77,
307,
309,
311,
313,
99,
323,
327,
329,
333,
335,
337,
341,
347,
327,
23,
29,
31,
29,
99,
29,
99,
327,
327,
23,
29,
31,
29,
99,
29,
99,
327,
29
]
} | static inline void FUNC_0(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
int16_t *filter, int16_t *filterPos, long filterSize)
{
#ifdef HAVE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
if(filterSize==4)
{
long counter= -2*dstW;
filter-= counter*2;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 4), %%mm1\n\t"
"movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else if(filterSize==8)
{
long counter= -2*dstW;
filter-= counter*4;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
"movd 4(%3, %%"REG_a"), %%mm4 \n\t"
"movd 4(%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm4 \n\t"
"pmaddwd %%mm2, %%mm5 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm5, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else
{
uint8_t *offset = src+filterSize;
long counter= -2*dstW;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %2, %%"REG_c" \n\t"
"movzwl (%%"REG_c", %0), %%eax \n\t"
"movzwl 2(%%"REG_c", %0), %%edx \n\t"
"mov %5, %%"REG_c" \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"2: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %6), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
"movd (%%"REG_c", %%"REG_d"), %%mm2\n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"paddd %%mm3, %%mm5 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"add $8, %1 \n\t"
"add $4, %%"REG_c" \n\t"
"cmp %4, %%"REG_c" \n\t"
" jb 2b \n\t"
"add %6, %1 \n\t"
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm5 \n\t"
"packssdw %%mm5, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"packssdw %%mm4, %%mm4 \n\t"
"mov %3, %%"REG_a" \n\t"
"movd %%mm4, (%%"REG_a", %0) \n\t"
"add $4, %0 \n\t"
" jnc 1b \n\t"
: "+r" (counter), "+r" (filter)
: "m" (filterPos), "m" (dst), "m"(offset),
"m" (src), "r" (filterSize*2)
: "%"REG_a, "%"REG_c, "%"REG_d
);
}
#else
#ifdef HAVE_ALTIVEC
hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
int VAR_0;
for(VAR_0=0; VAR_0<dstW; VAR_0++)
{
int j;
int srcPos= filterPos[VAR_0];
int val=0;
for(j=0; j<filterSize; j++)
{
val += ((int)src[srcPos + j])*filter[filterSize*VAR_0 + j];
}
dst[VAR_0] = av_clip(val>>7, 0, (1<<15)-1);
}
#endif
#endif
}
| [
"static inline void FUNC_0(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,\nint16_t *filter, int16_t *filterPos, long filterSize)\n{",
"#ifdef HAVE_MMX\nassert(filterSize % 4 == 0 && filterSize>0);",
"if(filterSize==4)\n{",
"long counter= -2*dstW;",
"filter-= counter*2;",
"filterPos-= counter/2;",
"dst-= counter/2;",
"asm volatile(\n#if defined(PIC)\n\"push %%\"REG_b\" \t\t\\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"\n\"push %%\"REG_BP\"\t\t\\n\\t\"\n\"mov %%\"REG_a\", %%\"REG_BP\"\t\\n\\t\"\nASMALIGN(4)\n\"1:\t\t\t\t\\n\\t\"\n\"movzwl (%2, %%\"REG_BP\"), %%eax\t\\n\\t\"\n\"movzwl 2(%2, %%\"REG_BP\"), %%ebx\\n\\t\"\n\"movq (%1, %%\"REG_BP\", 4), %%mm1\\n\\t\"\n\"movq 8(%1, %%\"REG_BP\", 4), %%mm3\\n\\t\"\n\"movd (%3, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movd (%3, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm0, %%mm0\t\t\\n\\t\"\n\"movd %%mm0, (%4, %%\"REG_BP\")\t\\n\\t\"\n\"add $4, %%\"REG_BP\"\t\t\\n\\t\"\n\" jnc 1b\t\t\t\\n\\t\"\n\"pop %%\"REG_BP\"\t\t\t\\n\\t\"\n#if defined(PIC)\n\"pop %%\"REG_b\" \t\t\\n\\t\"\n#endif\n: \"+a\" (counter)\n: \"c\" (filter), \"d\" (filterPos), \"S\" (src), \"D\" (dst)\n#if !defined(PIC)\n: \"%\"REG_b\n#endif\n);",
"}",
"else if(filterSize==8)\n{",
"long counter= -2*dstW;",
"filter-= counter*4;",
"filterPos-= counter/2;",
"dst-= counter/2;",
"asm volatile(\n#if defined(PIC)\n\"push %%\"REG_b\" \t\t\\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"\n\"push %%\"REG_BP\"\t\t\\n\\t\"\n\"mov %%\"REG_a\", %%\"REG_BP\"\t\\n\\t\"\nASMALIGN(4)\n\"1:\t\t\t\t\\n\\t\"\n\"movzwl (%2, %%\"REG_BP\"), %%eax\t\\n\\t\"\n\"movzwl 2(%2, %%\"REG_BP\"), %%ebx\\n\\t\"\n\"movq (%1, %%\"REG_BP\", 8), %%mm1\\n\\t\"\n\"movq 16(%1, %%\"REG_BP\", 8), %%mm3\\n\\t\"\n\"movd (%3, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movd (%3, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"movq 8(%1, %%\"REG_BP\", 8), %%mm1\\n\\t\"\n\"movq 24(%1, %%\"REG_BP\", 8), %%mm5\\n\\t\"\n\"movd 4(%3, %%\"REG_a\"), %%mm4\t\\n\\t\"\n\"movd 4(%3, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm1, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm5\t\t\\n\\t\"\n\"paddd %%mm4, %%mm0\t\t\\n\\t\"\n\"paddd %%mm5, %%mm3\t\t\\n\\t\"\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm0, %%mm0\t\t\\n\\t\"\n\"movd %%mm0, (%4, %%\"REG_BP\")\t\\n\\t\"\n\"add $4, %%\"REG_BP\"\t\t\\n\\t\"\n\" jnc 1b\t\t\t\\n\\t\"\n\"pop %%\"REG_BP\"\t\t\t\\n\\t\"\n#if defined(PIC)\n\"pop %%\"REG_b\" \t\t\\n\\t\"\n#endif\n: \"+a\" (counter)\n: \"c\" (filter), \"d\" (filterPos), \"S\" (src), \"D\" (dst)\n#if !defined(PIC)\n: \"%\"REG_b\n#endif\n);",
"}",
"else\n{",
"uint8_t *offset = src+filterSize;",
"long counter= -2*dstW;",
"filterPos-= counter/2;",
"dst-= counter/2;",
"asm volatile(\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"movq \"MANGLE(w02)\", %%mm6\t\\n\\t\"\nASMALIGN(4)\n\"1:\t\t\t\t\\n\\t\"\n\"mov %2, %%\"REG_c\"\t\t\\n\\t\"\n\"movzwl (%%\"REG_c\", %0), %%eax\t\\n\\t\"\n\"movzwl 2(%%\"REG_c\", %0), %%edx\t\\n\\t\"\n\"mov %5, %%\"REG_c\"\t\t\\n\\t\"\n\"pxor %%mm4, %%mm4\t\t\\n\\t\"\n\"pxor %%mm5, %%mm5\t\t\\n\\t\"\n\"2:\t\t\t\t\\n\\t\"\n\"movq (%1), %%mm1\t\t\\n\\t\"\n\"movq (%1, %6), %%mm3\t\t\\n\\t\"\n\"movd (%%\"REG_c\", %%\"REG_a\"), %%mm0\\n\\t\"\n\"movd (%%\"REG_c\", %%\"REG_d\"), %%mm2\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm1, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"paddd %%mm3, %%mm5\t\t\\n\\t\"\n\"paddd %%mm0, %%mm4\t\t\\n\\t\"\n\"add $8, %1\t\t\t\\n\\t\"\n\"add $4, %%\"REG_c\"\t\t\\n\\t\"\n\"cmp %4, %%\"REG_c\"\t\t\\n\\t\"\n\" jb 2b\t\t\t\t\\n\\t\"\n\"add %6, %1\t\t\t\\n\\t\"\n\"psrad $8, %%mm4\t\t\\n\\t\"\n\"psrad $8, %%mm5\t\t\\n\\t\"\n\"packssdw %%mm5, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"\n\"packssdw %%mm4, %%mm4\t\t\\n\\t\"\n\"mov %3, %%\"REG_a\"\t\t\\n\\t\"\n\"movd %%mm4, (%%\"REG_a\", %0)\t\\n\\t\"\n\"add $4, %0\t\t\t\\n\\t\"\n\" jnc 1b\t\t\t\\n\\t\"\n: \"+r\" (counter), \"+r\" (filter)\n: \"m\" (filterPos), \"m\" (dst), \"m\"(offset),\n\"m\" (src), \"r\" (filterSize*2)\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d\n);",
"}",
"#else\n#ifdef HAVE_ALTIVEC\nhScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);",
"#else\nint VAR_0;",
"for(VAR_0=0; VAR_0<dstW; VAR_0++)",
"{",
"int j;",
"int srcPos= filterPos[VAR_0];",
"int val=0;",
"for(j=0; j<filterSize; j++)",
"{",
"val += ((int)src[srcPos + j])*filter[filterSize*VAR_0 + j];",
"}",
"dst[VAR_0] = av_clip(val>>7, 0, (1<<15)-1);",
"}",
"#endif\n#endif\n}"
]
| [
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
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,
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,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
179,
181,
183,
185,
187,
189,
191,
193,
197,
199,
201,
203,
205,
207,
209,
211,
213,
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233,
235,
237,
239,
241,
243,
245,
247,
249,
251,
253,
255,
257,
259,
261,
263,
265,
267,
269,
271,
273,
275,
277,
279,
281,
283,
285,
287,
289,
291,
293,
295,
297,
299,
301,
303,
307,
309,
311,
313,
315
],
[
317
],
[
319,
321,
323
],
[
325,
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
341
],
[
343
],
[
347
],
[
349
],
[
353
],
[
357
],
[
359,
361,
363
]
]
|
16,684 | static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
/* copy prev frame */
for(i = 0; i < height; i++)
memcpy(refdata + (i * width), dst + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
/* motion compensation */
while((code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
/* get block size by index */
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
/* extract motion vector */
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
/* check motion vector */
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y > orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
/* do motion compensation */
me_plane = refdata + (filled + me_x) + (height - me_y) * width;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * width)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0) /* end-of-picture code */
break;
if(code > 0xE0) { /* run code: 0xE1..0xFF */
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
code &= 0x1F;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) { /* skip code: 0x80..0xBF */
int skip;
code &= 0x3F;
/* codes 0x80 and 0x81 are actually escape codes,
skip value minus constant is in the next byte */
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
/* zero code treated as one-pixel skip */
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| true | FFmpeg | bba9d8bdfb208b0ec2ccf182530347151ee3528b | static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
for(i = 0; i < height; i++)
memcpy(refdata + (i * width), dst + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
while((code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y > orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
me_plane = refdata + (filled + me_x) + (height - me_y) * width;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * width)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0)
break;
if(code > 0xE0) {
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) {
code &= 0x1F;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) {
int skip;
code &= 0x3F;
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| {
"code": [
" (height - me_y - me_h < 0) || (height - me_y > orig_height) ||",
" av_log(NULL, AV_LOG_ERROR, \"Bogus motion vector (%i,%i), block size %ix%i at %i,%i\\n\","
],
"line_no": [
101,
105
]
} | static void FUNC_0(QpegContext *VAR_0, uint8_t *VAR_1,
int VAR_2, int VAR_3, int VAR_4,
int VAR_5, const uint8_t *VAR_6,
uint8_t *VAR_7)
{
int VAR_8, VAR_9;
int VAR_10;
int VAR_11 = 0;
int VAR_12;
for(VAR_8 = 0; VAR_8 < VAR_4; VAR_8++)
memcpy(VAR_7 + (VAR_8 * VAR_3), VAR_1 + (VAR_8 * VAR_2), VAR_3);
VAR_12 = VAR_4;
VAR_4--;
VAR_1 = VAR_1 + VAR_4 * VAR_2;
while ((bytestream2_get_bytes_left(&VAR_0->buffer) > 0) && (VAR_4 >= 0)) {
VAR_10 = bytestream2_get_byte(&VAR_0->buffer);
if(VAR_5) {
while((VAR_10 & 0xF0) == 0xF0) {
if(VAR_5 == 1) {
int VAR_13;
int VAR_14, VAR_15, VAR_16, VAR_17;
uint8_t *me_plane;
int VAR_18, VAR_19;
VAR_13 = VAR_10 & 0xF;
VAR_14 = qpeg_table_w[VAR_13];
VAR_15 = qpeg_table_h[VAR_13];
VAR_18 = bytestream2_get_byte(&VAR_0->buffer);
VAR_19 = VAR_18 >> 4;
if(VAR_19 > 7)
VAR_19 -= 16;
VAR_16 = VAR_19;
VAR_19 = VAR_18 & 0xF;
if(VAR_19 > 7)
VAR_19 -= 16;
VAR_17 = VAR_19;
if ((VAR_16 + VAR_11 < 0) || (VAR_16 + VAR_14 + VAR_11 > VAR_3) ||
(VAR_4 - VAR_17 - VAR_15 < 0) || (VAR_4 - VAR_17 > VAR_12) ||
(VAR_11 + VAR_14 > VAR_3) || (VAR_4 - VAR_15 < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%VAR_8,%VAR_8), block size %ix%VAR_8 at %VAR_8,%VAR_8\n",
VAR_16, VAR_17, VAR_14, VAR_15, VAR_11, VAR_4);
else {
me_plane = VAR_7 + (VAR_11 + VAR_16) + (VAR_4 - VAR_17) * VAR_3;
for(VAR_9 = 0; VAR_9 < VAR_15; VAR_9++) {
for(VAR_8 = 0; VAR_8 < VAR_14; VAR_8++)
VAR_1[VAR_11 + VAR_8 - (VAR_9 * VAR_2)] = me_plane[VAR_8 - (VAR_9 * VAR_3)];
}
}
}
VAR_10 = bytestream2_get_byte(&VAR_0->buffer);
}
}
if(VAR_10 == 0xE0)
break;
if(VAR_10 > 0xE0) {
int VAR_20;
VAR_10 &= 0x1F;
VAR_20 = bytestream2_get_byte(&VAR_0->buffer);
for(VAR_8 = 0; VAR_8 <= VAR_10; VAR_8++) {
VAR_1[VAR_11++] = VAR_20;
if(VAR_11 >= VAR_3) {
VAR_11 = 0;
VAR_1 -= VAR_2;
VAR_4--;
if (VAR_4 < 0)
break;
}
}
} else if(VAR_10 >= 0xC0) {
VAR_10 &= 0x1F;
for(VAR_8 = 0; VAR_8 <= VAR_10; VAR_8++) {
VAR_1[VAR_11++] = bytestream2_get_byte(&VAR_0->buffer);
if(VAR_11 >= VAR_3) {
VAR_11 = 0;
VAR_1 -= VAR_2;
VAR_4--;
if (VAR_4 < 0)
break;
}
}
} else if(VAR_10 >= 0x80) {
int VAR_21;
VAR_10 &= 0x3F;
if(!VAR_10)
VAR_21 = bytestream2_get_byte(&VAR_0->buffer) + 64;
else if(VAR_10 == 1)
VAR_21 = bytestream2_get_byte(&VAR_0->buffer) + 320;
else
VAR_21 = VAR_10;
VAR_11 += VAR_21;
while( VAR_11 >= VAR_3) {
VAR_11 -= VAR_3;
VAR_1 -= VAR_2;
VAR_4--;
if(VAR_4 < 0)
break;
}
} else {
if(VAR_10) {
VAR_1[VAR_11++] = VAR_6[VAR_10 & 0x7F];
}
else
VAR_11++;
if(VAR_11 >= VAR_3) {
VAR_11 = 0;
VAR_1 -= VAR_2;
VAR_4--;
}
}
}
}
| [
"static void FUNC_0(QpegContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, int VAR_3, int VAR_4,\nint VAR_5, const uint8_t *VAR_6,\nuint8_t *VAR_7)\n{",
"int VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11 = 0;",
"int VAR_12;",
"for(VAR_8 = 0; VAR_8 < VAR_4; VAR_8++)",
"memcpy(VAR_7 + (VAR_8 * VAR_3), VAR_1 + (VAR_8 * VAR_2), VAR_3);",
"VAR_12 = VAR_4;",
"VAR_4--;",
"VAR_1 = VAR_1 + VAR_4 * VAR_2;",
"while ((bytestream2_get_bytes_left(&VAR_0->buffer) > 0) && (VAR_4 >= 0)) {",
"VAR_10 = bytestream2_get_byte(&VAR_0->buffer);",
"if(VAR_5) {",
"while((VAR_10 & 0xF0) == 0xF0) {",
"if(VAR_5 == 1) {",
"int VAR_13;",
"int VAR_14, VAR_15, VAR_16, VAR_17;",
"uint8_t *me_plane;",
"int VAR_18, VAR_19;",
"VAR_13 = VAR_10 & 0xF;",
"VAR_14 = qpeg_table_w[VAR_13];",
"VAR_15 = qpeg_table_h[VAR_13];",
"VAR_18 = bytestream2_get_byte(&VAR_0->buffer);",
"VAR_19 = VAR_18 >> 4;",
"if(VAR_19 > 7)\nVAR_19 -= 16;",
"VAR_16 = VAR_19;",
"VAR_19 = VAR_18 & 0xF;",
"if(VAR_19 > 7)\nVAR_19 -= 16;",
"VAR_17 = VAR_19;",
"if ((VAR_16 + VAR_11 < 0) || (VAR_16 + VAR_14 + VAR_11 > VAR_3) ||\n(VAR_4 - VAR_17 - VAR_15 < 0) || (VAR_4 - VAR_17 > VAR_12) ||\n(VAR_11 + VAR_14 > VAR_3) || (VAR_4 - VAR_15 < 0))\nav_log(NULL, AV_LOG_ERROR, \"Bogus motion vector (%VAR_8,%VAR_8), block size %ix%VAR_8 at %VAR_8,%VAR_8\\n\",\nVAR_16, VAR_17, VAR_14, VAR_15, VAR_11, VAR_4);",
"else {",
"me_plane = VAR_7 + (VAR_11 + VAR_16) + (VAR_4 - VAR_17) * VAR_3;",
"for(VAR_9 = 0; VAR_9 < VAR_15; VAR_9++) {",
"for(VAR_8 = 0; VAR_8 < VAR_14; VAR_8++)",
"VAR_1[VAR_11 + VAR_8 - (VAR_9 * VAR_2)] = me_plane[VAR_8 - (VAR_9 * VAR_3)];",
"}",
"}",
"}",
"VAR_10 = bytestream2_get_byte(&VAR_0->buffer);",
"}",
"}",
"if(VAR_10 == 0xE0)\nbreak;",
"if(VAR_10 > 0xE0) {",
"int VAR_20;",
"VAR_10 &= 0x1F;",
"VAR_20 = bytestream2_get_byte(&VAR_0->buffer);",
"for(VAR_8 = 0; VAR_8 <= VAR_10; VAR_8++) {",
"VAR_1[VAR_11++] = VAR_20;",
"if(VAR_11 >= VAR_3) {",
"VAR_11 = 0;",
"VAR_1 -= VAR_2;",
"VAR_4--;",
"if (VAR_4 < 0)\nbreak;",
"}",
"}",
"} else if(VAR_10 >= 0xC0) {",
"VAR_10 &= 0x1F;",
"for(VAR_8 = 0; VAR_8 <= VAR_10; VAR_8++) {",
"VAR_1[VAR_11++] = bytestream2_get_byte(&VAR_0->buffer);",
"if(VAR_11 >= VAR_3) {",
"VAR_11 = 0;",
"VAR_1 -= VAR_2;",
"VAR_4--;",
"if (VAR_4 < 0)\nbreak;",
"}",
"}",
"} else if(VAR_10 >= 0x80) {",
"int VAR_21;",
"VAR_10 &= 0x3F;",
"if(!VAR_10)\nVAR_21 = bytestream2_get_byte(&VAR_0->buffer) + 64;",
"else if(VAR_10 == 1)\nVAR_21 = bytestream2_get_byte(&VAR_0->buffer) + 320;",
"else\nVAR_21 = VAR_10;",
"VAR_11 += VAR_21;",
"while( VAR_11 >= VAR_3) {",
"VAR_11 -= VAR_3;",
"VAR_1 -= VAR_2;",
"VAR_4--;",
"if(VAR_4 < 0)\nbreak;",
"}",
"} else {",
"if(VAR_10) {",
"VAR_1[VAR_11++] = VAR_6[VAR_10 & 0x7F];",
"}",
"else\nVAR_11++;",
"if(VAR_11 >= VAR_3) {",
"VAR_11 = 0;",
"VAR_1 -= VAR_2;",
"VAR_4--;",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
73
],
[
77
],
[
79,
81
],
[
83
],
[
87
],
[
89,
91
],
[
93
],
[
99,
101,
103,
105,
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135,
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
207,
209
],
[
211,
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
]
]
|
16,686 | static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int height) {
unsigned char *dst_end = dst + width*height;
int size,size1,size2,offset,run;
unsigned char *dst_start = dst;
if (src[0] & 0x01)
src += 5;
else
src += 2;
if (src+3>src_end)
return -1;
size = AV_RB24(src);
src += 3;
while(size>0 && src<src_end) {
/* determine size1 and size2 */
size1 = (src[0] & 3);
if ( src[0] & 0x80 ) { // 1
if (src[0] & 0x40 ) { // 11
if ( src[0] & 0x20 ) { // 111
if ( src[0] < 0xFC ) // !(111111)
size1 = (((src[0] & 31) + 1) << 2);
src++;
size2 = 0;
} else { // 110
offset = ((src[0] & 0x10) << 12) + AV_RB16(&src[1]) + 1;
size2 = ((src[0] & 0xC) << 6) + src[3] + 5;
src += 4;
}
} else { // 10
size1 = ( ( src[1] & 0xC0) >> 6 );
offset = (AV_RB16(&src[1]) & 0x3FFF) + 1;
size2 = (src[0] & 0x3F) + 4;
src += 3;
}
} else { // 0
offset = ((src[0] & 0x60) << 3) + src[1] + 1;
size2 = ((src[0] & 0x1C) >> 2) + 3;
src += 2;
}
/* fetch strip from src */
if (size1>src_end-src)
break;
if (size1>0) {
size -= size1;
run = FFMIN(size1, dst_end-dst);
memcpy(dst, src, run);
dst += run;
src += run;
}
if (size2>0) {
if (dst-dst_start<offset)
return 0;
size -= size2;
run = FFMIN(size2, dst_end-dst);
av_memcpy_backptr(dst, offset, run);
dst += run;
}
}
return 0;
}
| true | FFmpeg | decae20f3662650ecb9602c0c760af275a1e7db3 | static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int height) {
unsigned char *dst_end = dst + width*height;
int size,size1,size2,offset,run;
unsigned char *dst_start = dst;
if (src[0] & 0x01)
src += 5;
else
src += 2;
if (src+3>src_end)
return -1;
size = AV_RB24(src);
src += 3;
while(size>0 && src<src_end) {
size1 = (src[0] & 3);
if ( src[0] & 0x80 ) {
if (src[0] & 0x40 ) { 1
if ( src[0] & 0x20 ) { 11
if ( src[0] < 0xFC )
size1 = (((src[0] & 31) + 1) << 2);
src++;
size2 = 0;
} else { 10
offset = ((src[0] & 0x10) << 12) + AV_RB16(&src[1]) + 1;
size2 = ((src[0] & 0xC) << 6) + src[3] + 5;
src += 4;
}
} else { 0
size1 = ( ( src[1] & 0xC0) >> 6 );
offset = (AV_RB16(&src[1]) & 0x3FFF) + 1;
size2 = (src[0] & 0x3F) + 4;
src += 3;
}
} else {
offset = ((src[0] & 0x60) << 3) + src[1] + 1;
size2 = ((src[0] & 0x1C) >> 2) + 3;
src += 2;
}
if (size1>src_end-src)
break;
if (size1>0) {
size -= size1;
run = FFMIN(size1, dst_end-dst);
memcpy(dst, src, run);
dst += run;
src += run;
}
if (size2>0) {
if (dst-dst_start<offset)
return 0;
size -= size2;
run = FFMIN(size2, dst_end-dst);
av_memcpy_backptr(dst, offset, run);
dst += run;
}
}
return 0;
}
| {
"code": [
" int size,size1,size2,offset,run;"
],
"line_no": [
5
]
} | static int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1, unsigned char *VAR_2, int VAR_3, int VAR_4) {
unsigned char *VAR_5 = VAR_2 + VAR_3*VAR_4;
int VAR_6,VAR_7,VAR_8,VAR_9,VAR_10;
unsigned char *VAR_11 = VAR_2;
if (VAR_0[0] & 0x01)
VAR_0 += 5;
else
VAR_0 += 2;
if (VAR_0+3>VAR_1)
return -1;
VAR_6 = AV_RB24(VAR_0);
VAR_0 += 3;
while(VAR_6>0 && VAR_0<VAR_1) {
VAR_7 = (VAR_0[0] & 3);
if ( VAR_0[0] & 0x80 ) {
if (VAR_0[0] & 0x40 ) { 1
if ( VAR_0[0] & 0x20 ) { 11
if ( VAR_0[0] < 0xFC )
VAR_7 = (((VAR_0[0] & 31) + 1) << 2);
VAR_0++;
VAR_8 = 0;
} else { 10
VAR_9 = ((VAR_0[0] & 0x10) << 12) + AV_RB16(&VAR_0[1]) + 1;
VAR_8 = ((VAR_0[0] & 0xC) << 6) + VAR_0[3] + 5;
VAR_0 += 4;
}
} else { 0
VAR_7 = ( ( VAR_0[1] & 0xC0) >> 6 );
VAR_9 = (AV_RB16(&VAR_0[1]) & 0x3FFF) + 1;
VAR_8 = (VAR_0[0] & 0x3F) + 4;
VAR_0 += 3;
}
} else {
VAR_9 = ((VAR_0[0] & 0x60) << 3) + VAR_0[1] + 1;
VAR_8 = ((VAR_0[0] & 0x1C) >> 2) + 3;
VAR_0 += 2;
}
if (VAR_7>VAR_1-VAR_0)
break;
if (VAR_7>0) {
VAR_6 -= VAR_7;
VAR_10 = FFMIN(VAR_7, VAR_5-VAR_2);
memcpy(VAR_2, VAR_0, VAR_10);
VAR_2 += VAR_10;
VAR_0 += VAR_10;
}
if (VAR_8>0) {
if (VAR_2-VAR_11<VAR_9)
return 0;
VAR_6 -= VAR_8;
VAR_10 = FFMIN(VAR_8, VAR_5-VAR_2);
av_memcpy_backptr(VAR_2, VAR_9, VAR_10);
VAR_2 += VAR_10;
}
}
return 0;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1, unsigned char *VAR_2, int VAR_3, int VAR_4) {",
"unsigned char *VAR_5 = VAR_2 + VAR_3*VAR_4;",
"int VAR_6,VAR_7,VAR_8,VAR_9,VAR_10;",
"unsigned char *VAR_11 = VAR_2;",
"if (VAR_0[0] & 0x01)\nVAR_0 += 5;",
"else\nVAR_0 += 2;",
"if (VAR_0+3>VAR_1)\nreturn -1;",
"VAR_6 = AV_RB24(VAR_0);",
"VAR_0 += 3;",
"while(VAR_6>0 && VAR_0<VAR_1) {",
"VAR_7 = (VAR_0[0] & 3);",
"if ( VAR_0[0] & 0x80 ) {",
"if (VAR_0[0] & 0x40 ) { 1",
"if ( VAR_0[0] & 0x20 ) { 11",
"if ( VAR_0[0] < 0xFC )\nVAR_7 = (((VAR_0[0] & 31) + 1) << 2);",
"VAR_0++;",
"VAR_8 = 0;",
"} else { 10",
"VAR_9 = ((VAR_0[0] & 0x10) << 12) + AV_RB16(&VAR_0[1]) + 1;",
"VAR_8 = ((VAR_0[0] & 0xC) << 6) + VAR_0[3] + 5;",
"VAR_0 += 4;",
"}",
"} else { 0",
"VAR_7 = ( ( VAR_0[1] & 0xC0) >> 6 );",
"VAR_9 = (AV_RB16(&VAR_0[1]) & 0x3FFF) + 1;",
"VAR_8 = (VAR_0[0] & 0x3F) + 4;",
"VAR_0 += 3;",
"}",
"} else {",
"VAR_9 = ((VAR_0[0] & 0x60) << 3) + VAR_0[1] + 1;",
"VAR_8 = ((VAR_0[0] & 0x1C) >> 2) + 3;",
"VAR_0 += 2;",
"}",
"if (VAR_7>VAR_1-VAR_0)\nbreak;",
"if (VAR_7>0) {",
"VAR_6 -= VAR_7;",
"VAR_10 = FFMIN(VAR_7, VAR_5-VAR_2);",
"memcpy(VAR_2, VAR_0, VAR_10);",
"VAR_2 += VAR_10;",
"VAR_0 += VAR_10;",
"}",
"if (VAR_8>0) {",
"if (VAR_2-VAR_11<VAR_9)\nreturn 0;",
"VAR_6 -= VAR_8;",
"VAR_10 = FFMIN(VAR_8, VAR_5-VAR_2);",
"av_memcpy_backptr(VAR_2, VAR_9, VAR_10);",
"VAR_2 += VAR_10;",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
]
]
|
16,687 | void qmp_block_resize(bool has_device, const char *device,
bool has_node_name, const char *node_name,
int64_t size, Error **errp)
{
Error *local_err = NULL;
BlockDriverState *bs;
int ret;
bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
if (!bdrv_is_first_non_filter(bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "resize");
if (size < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
/* complete all in-flight operations before resizing the device */
bdrv_drain_all();
ret = bdrv_truncate(bs, size);
switch (ret) {
case 0:
break;
case -ENOMEDIUM:
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
break;
case -ENOTSUP:
error_set(errp, QERR_UNSUPPORTED);
break;
case -EACCES:
error_set(errp, QERR_DEVICE_IS_READ_ONLY, device);
break;
case -EBUSY:
break;
default:
error_setg_errno(errp, -ret, "Could not resize");
break; | true | qemu | 9c75e168bc388094c04aabb6fc59c91abe06e81c | void qmp_block_resize(bool has_device, const char *device,
bool has_node_name, const char *node_name,
int64_t size, Error **errp)
{
Error *local_err = NULL;
BlockDriverState *bs;
int ret;
bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
if (!bdrv_is_first_non_filter(bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "resize");
if (size < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
bdrv_drain_all();
ret = bdrv_truncate(bs, size);
switch (ret) {
case 0:
break;
case -ENOMEDIUM:
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
break;
case -ENOTSUP:
error_set(errp, QERR_UNSUPPORTED);
break;
case -EACCES:
error_set(errp, QERR_DEVICE_IS_READ_ONLY, device);
break;
case -EBUSY:
break;
default:
error_setg_errno(errp, -ret, "Could not resize");
break; | {
"code": [],
"line_no": []
} | void FUNC_0(bool VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
int64_t VAR_4, Error **VAR_5)
{
Error *local_err = NULL;
BlockDriverState *bs;
int VAR_6;
bs = bdrv_lookup_bs(VAR_0 ? VAR_1 : NULL,
VAR_2 ? VAR_3 : NULL,
&local_err);
if (local_err) {
error_propagate(VAR_5, local_err);
if (!bdrv_is_first_non_filter(bs)) {
error_set(VAR_5, QERR_FEATURE_DISABLED, "resize");
if (VAR_4 < 0) {
error_set(VAR_5, QERR_INVALID_PARAMETER_VALUE, "VAR_4", "a >0 VAR_4");
bdrv_drain_all();
VAR_6 = bdrv_truncate(bs, VAR_4);
switch (VAR_6) {
case 0:
break;
case -ENOMEDIUM:
error_set(VAR_5, QERR_DEVICE_HAS_NO_MEDIUM, VAR_1);
break;
case -ENOTSUP:
error_set(VAR_5, QERR_UNSUPPORTED);
break;
case -EACCES:
error_set(VAR_5, QERR_DEVICE_IS_READ_ONLY, VAR_1);
break;
case -EBUSY:
break;
default:
error_setg_errno(VAR_5, -VAR_6, "Could not resize");
break; | [
"void FUNC_0(bool VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nint64_t VAR_4, Error **VAR_5)\n{",
"Error *local_err = NULL;",
"BlockDriverState *bs;",
"int VAR_6;",
"bs = bdrv_lookup_bs(VAR_0 ? VAR_1 : NULL,\nVAR_2 ? VAR_3 : NULL,\n&local_err);",
"if (local_err) {",
"error_propagate(VAR_5, local_err);",
"if (!bdrv_is_first_non_filter(bs)) {",
"error_set(VAR_5, QERR_FEATURE_DISABLED, \"resize\");",
"if (VAR_4 < 0) {",
"error_set(VAR_5, QERR_INVALID_PARAMETER_VALUE, \"VAR_4\", \"a >0 VAR_4\");",
"bdrv_drain_all();",
"VAR_6 = bdrv_truncate(bs, VAR_4);",
"switch (VAR_6) {",
"case 0:\nbreak;",
"case -ENOMEDIUM:\nerror_set(VAR_5, QERR_DEVICE_HAS_NO_MEDIUM, VAR_1);",
"break;",
"case -ENOTSUP:\nerror_set(VAR_5, QERR_UNSUPPORTED);",
"break;",
"case -EACCES:\nerror_set(VAR_5, QERR_DEVICE_IS_READ_ONLY, VAR_1);",
"break;",
"case -EBUSY:\nbreak;",
"default:\nerror_setg_errno(VAR_5, -VAR_6, \"Could not resize\");",
"break;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8,
9,
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
18
],
[
19
],
[
20
],
[
21,
22
],
[
23,
24
],
[
25
],
[
26,
27
],
[
28
],
[
29,
30
],
[
31
],
[
32,
33
],
[
34,
35
],
[
36
]
]
|
16,688 | static int32_t bmdma_prepare_buf(IDEDMA *dma, int32_t limit)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} prd;
int l, len;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
/* end of table (with a fail safe of one page) */
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {
return s->sg.size;
}
pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
bm->cur_addr += 8;
prd.addr = le32_to_cpu(prd.addr);
prd.size = le32_to_cpu(prd.size);
len = prd.size & 0xfffe;
if (len == 0)
len = 0x10000;
bm->cur_prd_len = len;
bm->cur_prd_addr = prd.addr;
bm->cur_prd_last = (prd.size & 0x80000000);
}
l = bm->cur_prd_len;
if (l > 0) {
uint64_t sg_len;
/* Don't add extra bytes to the SGList; consume any remaining
* PRDs from the guest, but ignore them. */
sg_len = MIN(limit - s->sg.size, bm->cur_prd_len);
if (sg_len) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, sg_len);
}
/* Note: We limit the max transfer to be 2GiB.
* This should accommodate the largest ATA transaction
* for LBA48 (65,536 sectors) and 32K sector sizes. */
if (s->sg.size > INT32_MAX) {
error_report("IDE: sglist describes more than 2GiB.");
break;
}
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
s->io_buffer_size += l;
}
}
qemu_sglist_destroy(&s->sg);
s->io_buffer_size = 0;
return -1;
}
| true | qemu | 9fbf0fa81fca8f527669dd4fa72662d66e7d6329 | static int32_t bmdma_prepare_buf(IDEDMA *dma, int32_t limit)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} prd;
int l, len;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {
return s->sg.size;
}
pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
bm->cur_addr += 8;
prd.addr = le32_to_cpu(prd.addr);
prd.size = le32_to_cpu(prd.size);
len = prd.size & 0xfffe;
if (len == 0)
len = 0x10000;
bm->cur_prd_len = len;
bm->cur_prd_addr = prd.addr;
bm->cur_prd_last = (prd.size & 0x80000000);
}
l = bm->cur_prd_len;
if (l > 0) {
uint64_t sg_len;
sg_len = MIN(limit - s->sg.size, bm->cur_prd_len);
if (sg_len) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, sg_len);
}
if (s->sg.size > INT32_MAX) {
error_report("IDE: sglist describes more than 2GiB.");
break;
}
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
s->io_buffer_size += l;
}
}
qemu_sglist_destroy(&s->sg);
s->io_buffer_size = 0;
return -1;
}
| {
"code": [
" if (s->sg.size > INT32_MAX) {",
" error_report(\"IDE: sglist describes more than 2GiB.\");",
" break;"
],
"line_no": [
93,
95,
97
]
} | static int32_t FUNC_0(IDEDMA *dma, int32_t limit)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} VAR_0;
int VAR_1, VAR_2;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {
return s->sg.size;
}
pci_dma_read(pci_dev, bm->cur_addr, &VAR_0, 8);
bm->cur_addr += 8;
VAR_0.addr = le32_to_cpu(VAR_0.addr);
VAR_0.size = le32_to_cpu(VAR_0.size);
VAR_2 = VAR_0.size & 0xfffe;
if (VAR_2 == 0)
VAR_2 = 0x10000;
bm->cur_prd_len = VAR_2;
bm->cur_prd_addr = VAR_0.addr;
bm->cur_prd_last = (VAR_0.size & 0x80000000);
}
VAR_1 = bm->cur_prd_len;
if (VAR_1 > 0) {
uint64_t sg_len;
sg_len = MIN(limit - s->sg.size, bm->cur_prd_len);
if (sg_len) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, sg_len);
}
if (s->sg.size > INT32_MAX) {
error_report("IDE: sglist describes more than 2GiB.");
break;
}
bm->cur_prd_addr += VAR_1;
bm->cur_prd_len -= VAR_1;
s->io_buffer_size += VAR_1;
}
}
qemu_sglist_destroy(&s->sg);
s->io_buffer_size = 0;
return -1;
}
| [
"static int32_t FUNC_0(IDEDMA *dma, int32_t limit)\n{",
"BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);",
"IDEState *s = bmdma_active_if(bm);",
"PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);",
"struct {",
"uint32_t addr;",
"uint32_t size;",
"} VAR_0;",
"int VAR_1, VAR_2;",
"pci_dma_sglist_init(&s->sg, pci_dev,\ns->nsector / (BMDMA_PAGE_SIZE / 512) + 1);",
"s->io_buffer_size = 0;",
"for(;;) {",
"if (bm->cur_prd_len == 0) {",
"if (bm->cur_prd_last ||\n(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {",
"return s->sg.size;",
"}",
"pci_dma_read(pci_dev, bm->cur_addr, &VAR_0, 8);",
"bm->cur_addr += 8;",
"VAR_0.addr = le32_to_cpu(VAR_0.addr);",
"VAR_0.size = le32_to_cpu(VAR_0.size);",
"VAR_2 = VAR_0.size & 0xfffe;",
"if (VAR_2 == 0)\nVAR_2 = 0x10000;",
"bm->cur_prd_len = VAR_2;",
"bm->cur_prd_addr = VAR_0.addr;",
"bm->cur_prd_last = (VAR_0.size & 0x80000000);",
"}",
"VAR_1 = bm->cur_prd_len;",
"if (VAR_1 > 0) {",
"uint64_t sg_len;",
"sg_len = MIN(limit - s->sg.size, bm->cur_prd_len);",
"if (sg_len) {",
"qemu_sglist_add(&s->sg, bm->cur_prd_addr, sg_len);",
"}",
"if (s->sg.size > INT32_MAX) {",
"error_report(\"IDE: sglist describes more than 2GiB.\");",
"break;",
"}",
"bm->cur_prd_addr += VAR_1;",
"bm->cur_prd_len -= VAR_1;",
"s->io_buffer_size += VAR_1;",
"}",
"}",
"qemu_sglist_destroy(&s->sg);",
"s->io_buffer_size = 0;",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
77
],
[
79
],
[
81
],
[
83
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
]
]
|
16,689 | static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc,
uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height, long lumStride, long chromStride)
{
/* Y Plane */
memcpy(ydst, ysrc, width*height);
/* XXX: implement upscaling for U,V */
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc,
uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height, long lumStride, long chromStride)
{
memcpy(ydst, ysrc, width*height);
}
| {
"code": [
"\tuint8_t *ydst, uint8_t *udst, uint8_t *vdst,",
"\tlong width, long height, long lumStride, long chromStride)",
"\tmemcpy(ydst, ysrc, width*height);"
],
"line_no": [
3,
5,
11
]
} | static inline void FUNC_0(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc,
uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height, long lumStride, long chromStride)
{
memcpy(ydst, ysrc, width*height);
}
| [
"static inline void FUNC_0(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc,\nuint8_t *ydst, uint8_t *udst, uint8_t *vdst,\nlong width, long height, long lumStride, long chromStride)\n{",
"memcpy(ydst, ysrc, width*height);",
"}"
]
| [
1,
1,
0
]
| [
[
1,
3,
5,
7
],
[
11
],
[
17
]
]
|
16,690 | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len)
{
assert(qiov->nalloc != -1);
if (qiov->niov == qiov->nalloc) {
qiov->nalloc = 2 * qiov->nalloc + 1;
qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));
}
qiov->iov[qiov->niov].iov_base = base;
qiov->iov[qiov->niov].iov_len = len;
qiov->size += len;
++qiov->niov;
}
| true | qemu | e1cf5582644ef63528993fb2b88dd3b43b9914c6 | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len)
{
assert(qiov->nalloc != -1);
if (qiov->niov == qiov->nalloc) {
qiov->nalloc = 2 * qiov->nalloc + 1;
qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));
}
qiov->iov[qiov->niov].iov_base = base;
qiov->iov[qiov->niov].iov_len = len;
qiov->size += len;
++qiov->niov;
}
| {
"code": [
" qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));"
],
"line_no": [
13
]
} | void FUNC_0(QEMUIOVector *VAR_0, void *VAR_1, size_t VAR_2)
{
assert(VAR_0->nalloc != -1);
if (VAR_0->niov == VAR_0->nalloc) {
VAR_0->nalloc = 2 * VAR_0->nalloc + 1;
VAR_0->iov = g_realloc(VAR_0->iov, VAR_0->nalloc * sizeof(struct iovec));
}
VAR_0->iov[VAR_0->niov].iov_base = VAR_1;
VAR_0->iov[VAR_0->niov].iov_len = VAR_2;
VAR_0->size += VAR_2;
++VAR_0->niov;
}
| [
"void FUNC_0(QEMUIOVector *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"assert(VAR_0->nalloc != -1);",
"if (VAR_0->niov == VAR_0->nalloc) {",
"VAR_0->nalloc = 2 * VAR_0->nalloc + 1;",
"VAR_0->iov = g_realloc(VAR_0->iov, VAR_0->nalloc * sizeof(struct iovec));",
"}",
"VAR_0->iov[VAR_0->niov].iov_base = VAR_1;",
"VAR_0->iov[VAR_0->niov].iov_len = VAR_2;",
"VAR_0->size += VAR_2;",
"++VAR_0->niov;",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
16,691 | int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
{
if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
if (s->sh.dependent_slice_segment_flag == 0 ||
(s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]))
cabac_init_state(s);
if (!s->sh.first_slice_in_pic_flag &&
s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else if (s->sh.dependent_slice_segment_flag == 1)
load_states(s);
}
}
} else {
if (s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
}
cabac_init_state(s);
}
if (s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
get_cabac_terminate(&s->HEVClc->cc);
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
}
if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else
load_states(s);
}
}
}
return 0;
}
| true | FFmpeg | 4ff94558f23a5de43aed4ca3429963dd1d995250 | int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
{
if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
if (s->sh.dependent_slice_segment_flag == 0 ||
(s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]))
cabac_init_state(s);
if (!s->sh.first_slice_in_pic_flag &&
s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else if (s->sh.dependent_slice_segment_flag == 1)
load_states(s);
}
}
} else {
if (s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
}
cabac_init_state(s);
}
if (s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
get_cabac_terminate(&s->HEVClc->cc);
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else {
int ret = cabac_init_decoder(s);
if (ret < 0)
return ret;
}
if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else
load_states(s);
}
}
}
return 0;
}
| {
"code": [
" cabac_reinit(s->HEVClc);",
" int ret = cabac_init_decoder(s);",
" if (ret < 0)",
" return ret;",
" cabac_reinit(s->HEVClc);",
" int ret = cabac_init_decoder(s);",
" if (ret < 0)",
" return ret;"
],
"line_no": [
49,
53,
55,
57,
73,
77,
79,
81
]
} | int FUNC_0(HEVCContext *VAR_0, int VAR_1)
{
if (VAR_1 == VAR_0->ps.pps->ctb_addr_rs_to_ts[VAR_0->sh.slice_ctb_addr_rs]) {
int VAR_3 = cabac_init_decoder(VAR_0);
if (VAR_3 < 0)
return VAR_3;
if (VAR_0->sh.dependent_slice_segment_flag == 0 ||
(VAR_0->ps.pps->tiles_enabled_flag &&
VAR_0->ps.pps->tile_id[VAR_1] != VAR_0->ps.pps->tile_id[VAR_1 - 1]))
cabac_init_state(VAR_0);
if (!VAR_0->sh.first_slice_in_pic_flag &&
VAR_0->ps.pps->entropy_coding_sync_enabled_flag) {
if (VAR_1 % VAR_0->ps.sps->ctb_width == 0) {
if (VAR_0->ps.sps->ctb_width == 1)
cabac_init_state(VAR_0);
else if (VAR_0->sh.dependent_slice_segment_flag == 1)
load_states(VAR_0);
}
}
} else {
if (VAR_0->ps.pps->tiles_enabled_flag &&
VAR_0->ps.pps->tile_id[VAR_1] != VAR_0->ps.pps->tile_id[VAR_1 - 1]) {
if (VAR_0->threads_number == 1)
cabac_reinit(VAR_0->HEVClc);
else {
int VAR_3 = cabac_init_decoder(VAR_0);
if (VAR_3 < 0)
return VAR_3;
}
cabac_init_state(VAR_0);
}
if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag) {
if (VAR_1 % VAR_0->ps.sps->ctb_width == 0) {
get_cabac_terminate(&VAR_0->HEVClc->cc);
if (VAR_0->threads_number == 1)
cabac_reinit(VAR_0->HEVClc);
else {
int VAR_3 = cabac_init_decoder(VAR_0);
if (VAR_3 < 0)
return VAR_3;
}
if (VAR_0->ps.sps->ctb_width == 1)
cabac_init_state(VAR_0);
else
load_states(VAR_0);
}
}
}
return 0;
}
| [
"int FUNC_0(HEVCContext *VAR_0, int VAR_1)\n{",
"if (VAR_1 == VAR_0->ps.pps->ctb_addr_rs_to_ts[VAR_0->sh.slice_ctb_addr_rs]) {",
"int VAR_3 = cabac_init_decoder(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"if (VAR_0->sh.dependent_slice_segment_flag == 0 ||\n(VAR_0->ps.pps->tiles_enabled_flag &&\nVAR_0->ps.pps->tile_id[VAR_1] != VAR_0->ps.pps->tile_id[VAR_1 - 1]))\ncabac_init_state(VAR_0);",
"if (!VAR_0->sh.first_slice_in_pic_flag &&\nVAR_0->ps.pps->entropy_coding_sync_enabled_flag) {",
"if (VAR_1 % VAR_0->ps.sps->ctb_width == 0) {",
"if (VAR_0->ps.sps->ctb_width == 1)\ncabac_init_state(VAR_0);",
"else if (VAR_0->sh.dependent_slice_segment_flag == 1)\nload_states(VAR_0);",
"}",
"}",
"} else {",
"if (VAR_0->ps.pps->tiles_enabled_flag &&\nVAR_0->ps.pps->tile_id[VAR_1] != VAR_0->ps.pps->tile_id[VAR_1 - 1]) {",
"if (VAR_0->threads_number == 1)\ncabac_reinit(VAR_0->HEVClc);",
"else {",
"int VAR_3 = cabac_init_decoder(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"}",
"cabac_init_state(VAR_0);",
"}",
"if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag) {",
"if (VAR_1 % VAR_0->ps.sps->ctb_width == 0) {",
"get_cabac_terminate(&VAR_0->HEVClc->cc);",
"if (VAR_0->threads_number == 1)\ncabac_reinit(VAR_0->HEVClc);",
"else {",
"int VAR_3 = cabac_init_decoder(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"}",
"if (VAR_0->ps.sps->ctb_width == 1)\ncabac_init_state(VAR_0);",
"else\nload_states(VAR_0);",
"}",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15,
17,
19
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
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
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.