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
|
---|---|---|---|---|---|---|---|---|---|---|
15,194 | static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
{
PowerPCCPU *cpu = POWERPC_CPU(dev);
CPUPPCState *env = &cpu->env;
int i;
for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
if (env->opcodes[i] != &invalid_handler) {
g_free(env->opcodes[i]);
}
}
}
| false | qemu | 81f194dd69756677cc36ff0827bf970f0f048914 | static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
{
PowerPCCPU *cpu = POWERPC_CPU(dev);
CPUPPCState *env = &cpu->env;
int i;
for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
if (env->opcodes[i] != &invalid_handler) {
g_free(env->opcodes[i]);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
PowerPCCPU *cpu = POWERPC_CPU(VAR_0);
CPUPPCState *env = &cpu->env;
int VAR_2;
for (VAR_2 = 0; VAR_2 < PPC_CPU_OPCODES_LEN; VAR_2++) {
if (env->opcodes[VAR_2] != &invalid_handler) {
g_free(env->opcodes[VAR_2]);
}
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"PowerPCCPU *cpu = POWERPC_CPU(VAR_0);",
"CPUPPCState *env = &cpu->env;",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < PPC_CPU_OPCODES_LEN; VAR_2++) {",
"if (env->opcodes[VAR_2] != &invalid_handler) {",
"g_free(env->opcodes[VAR_2]);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
15,195 | static void xen_exit_notifier(Notifier *n, void *data)
{
XenIOState *state = container_of(n, XenIOState, exit);
xc_evtchn_close(state->xce_handle);
xs_daemon_close(state->xenstore);
}
| false | qemu | a2db2a1edd06a50b8a862c654cf993368cf9f1d9 | static void xen_exit_notifier(Notifier *n, void *data)
{
XenIOState *state = container_of(n, XenIOState, exit);
xc_evtchn_close(state->xce_handle);
xs_daemon_close(state->xenstore);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Notifier *VAR_0, void *VAR_1)
{
XenIOState *state = container_of(VAR_0, XenIOState, exit);
xc_evtchn_close(state->xce_handle);
xs_daemon_close(state->xenstore);
}
| [
"static void FUNC_0(Notifier *VAR_0, void *VAR_1)\n{",
"XenIOState *state = container_of(VAR_0, XenIOState, exit);",
"xc_evtchn_close(state->xce_handle);",
"xs_daemon_close(state->xenstore);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
15,196 | static void avc_loopfilter_cb_or_cr_inter_edge_ver_msa(uint8_t *data,
uint8_t bs0, uint8_t bs1,
uint8_t bs2, uint8_t bs3,
uint8_t tc0, uint8_t tc1,
uint8_t tc2, uint8_t tc3,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
uint8_t *src;
uint16_t out0, out1, out2, out3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than, is_less_than_beta, is_less_than_alpha;
v16u8 p0, q0;
v8i16 p0_r = { 0 };
v8i16 q0_r = { 0 };
v16u8 p1_org, p0_org, q0_org, q1_org;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
v16u8 is_bs_greater_than0;
v8i16 tc_r, negate_tc_r;
v16i8 negate_tc, sign_negate_tc;
v16i8 zero = { 0 };
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v8i16 tmp1, tmp_vec, bs = { 0 };
v8i16 tc = { 0 };
tmp_vec = (v8i16) __msa_fill_b(bs0);
bs = __msa_insve_h(bs, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs1);
bs = __msa_insve_h(bs, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs2);
bs = __msa_insve_h(bs, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs3);
bs = __msa_insve_h(bs, 3, tmp_vec);
if (!__msa_test_bz_v((v16u8) bs)) {
tmp_vec = (v8i16) __msa_fill_b(tc0);
tc = __msa_insve_h(tc, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc1);
tc = __msa_insve_h(tc, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc2);
tc = __msa_insve_h(tc, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc3);
tc = __msa_insve_h(tc, 3, tmp_vec);
is_bs_greater_than0 = (v16u8) (zero < (v16i8) bs);
LOAD_8VECS_UB((data - 2), img_width,
row0, row1, row2, row3, row4, row5, row6, row7);
TRANSPOSE8x4_B_UB(row0, row1, row2, row3,
row4, row5, row6, row7,
p1_org, p0_org, q0_org, q1_org);
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_bs_greater_than0 & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_tc_r, tc_r, p0_r, q0_r);
p0 = (v16u8) __msa_pckev_b(zero, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b(zero, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
tmp1 = (v8i16) __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
src = data - 1;
out0 = __msa_copy_u_h(tmp1, 0);
out1 = __msa_copy_u_h(tmp1, 1);
out2 = __msa_copy_u_h(tmp1, 2);
out3 = __msa_copy_u_h(tmp1, 3);
STORE_HWORD(src, out0);
src += img_width;
STORE_HWORD(src, out1);
src += img_width;
STORE_HWORD(src, out2);
src += img_width;
STORE_HWORD(src, out3);
out0 = __msa_copy_u_h(tmp1, 4);
out1 = __msa_copy_u_h(tmp1, 5);
out2 = __msa_copy_u_h(tmp1, 6);
out3 = __msa_copy_u_h(tmp1, 7);
src += img_width;
STORE_HWORD(src, out0);
src += img_width;
STORE_HWORD(src, out1);
src += img_width;
STORE_HWORD(src, out2);
src += img_width;
STORE_HWORD(src, out3);
}
}
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | static void avc_loopfilter_cb_or_cr_inter_edge_ver_msa(uint8_t *data,
uint8_t bs0, uint8_t bs1,
uint8_t bs2, uint8_t bs3,
uint8_t tc0, uint8_t tc1,
uint8_t tc2, uint8_t tc3,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
uint8_t *src;
uint16_t out0, out1, out2, out3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than, is_less_than_beta, is_less_than_alpha;
v16u8 p0, q0;
v8i16 p0_r = { 0 };
v8i16 q0_r = { 0 };
v16u8 p1_org, p0_org, q0_org, q1_org;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
v16u8 is_bs_greater_than0;
v8i16 tc_r, negate_tc_r;
v16i8 negate_tc, sign_negate_tc;
v16i8 zero = { 0 };
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v8i16 tmp1, tmp_vec, bs = { 0 };
v8i16 tc = { 0 };
tmp_vec = (v8i16) __msa_fill_b(bs0);
bs = __msa_insve_h(bs, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs1);
bs = __msa_insve_h(bs, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs2);
bs = __msa_insve_h(bs, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(bs3);
bs = __msa_insve_h(bs, 3, tmp_vec);
if (!__msa_test_bz_v((v16u8) bs)) {
tmp_vec = (v8i16) __msa_fill_b(tc0);
tc = __msa_insve_h(tc, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc1);
tc = __msa_insve_h(tc, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc2);
tc = __msa_insve_h(tc, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(tc3);
tc = __msa_insve_h(tc, 3, tmp_vec);
is_bs_greater_than0 = (v16u8) (zero < (v16i8) bs);
LOAD_8VECS_UB((data - 2), img_width,
row0, row1, row2, row3, row4, row5, row6, row7);
TRANSPOSE8x4_B_UB(row0, row1, row2, row3,
row4, row5, row6, row7,
p1_org, p0_org, q0_org, q1_org);
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_bs_greater_than0 & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_tc_r, tc_r, p0_r, q0_r);
p0 = (v16u8) __msa_pckev_b(zero, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b(zero, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
tmp1 = (v8i16) __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
src = data - 1;
out0 = __msa_copy_u_h(tmp1, 0);
out1 = __msa_copy_u_h(tmp1, 1);
out2 = __msa_copy_u_h(tmp1, 2);
out3 = __msa_copy_u_h(tmp1, 3);
STORE_HWORD(src, out0);
src += img_width;
STORE_HWORD(src, out1);
src += img_width;
STORE_HWORD(src, out2);
src += img_width;
STORE_HWORD(src, out3);
out0 = __msa_copy_u_h(tmp1, 4);
out1 = __msa_copy_u_h(tmp1, 5);
out2 = __msa_copy_u_h(tmp1, 6);
out3 = __msa_copy_u_h(tmp1, 7);
src += img_width;
STORE_HWORD(src, out0);
src += img_width;
STORE_HWORD(src, out1);
src += img_width;
STORE_HWORD(src, out2);
src += img_width;
STORE_HWORD(src, out3);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0,
uint8_t VAR_1, uint8_t VAR_2,
uint8_t VAR_3, uint8_t VAR_4,
uint8_t VAR_5, uint8_t VAR_6,
uint8_t VAR_7, uint8_t VAR_8,
uint8_t VAR_9,
uint8_t VAR_10,
uint32_t VAR_11)
{
uint8_t *src;
uint16_t out0, out1, out2, out3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than, is_less_than_beta, is_less_than_alpha;
v16u8 p0, q0;
v8i16 p0_r = { 0 };
v8i16 q0_r = { 0 };
v16u8 p1_org, p0_org, q0_org, q1_org;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
v16u8 is_bs_greater_than0;
v8i16 tc_r, negate_tc_r;
v16i8 negate_tc, sign_negate_tc;
v16i8 zero = { 0 };
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v8i16 tmp1, tmp_vec, bs = { 0 };
v8i16 tc = { 0 };
tmp_vec = (v8i16) __msa_fill_b(VAR_1);
bs = __msa_insve_h(bs, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_2);
bs = __msa_insve_h(bs, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_3);
bs = __msa_insve_h(bs, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_4);
bs = __msa_insve_h(bs, 3, tmp_vec);
if (!__msa_test_bz_v((v16u8) bs)) {
tmp_vec = (v8i16) __msa_fill_b(VAR_5);
tc = __msa_insve_h(tc, 0, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_6);
tc = __msa_insve_h(tc, 1, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_7);
tc = __msa_insve_h(tc, 2, tmp_vec);
tmp_vec = (v8i16) __msa_fill_b(VAR_8);
tc = __msa_insve_h(tc, 3, tmp_vec);
is_bs_greater_than0 = (v16u8) (zero < (v16i8) bs);
LOAD_8VECS_UB((VAR_0 - 2), VAR_11,
row0, row1, row2, row3, row4, row5, row6, row7);
TRANSPOSE8x4_B_UB(row0, row1, row2, row3,
row4, row5, row6, row7,
p1_org, p0_org, q0_org, q1_org);
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(VAR_9);
beta = (v16u8) __msa_fill_b(VAR_10);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_bs_greater_than0 & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_tc_r, tc_r, p0_r, q0_r);
p0 = (v16u8) __msa_pckev_b(zero, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b(zero, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
tmp1 = (v8i16) __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
src = VAR_0 - 1;
out0 = __msa_copy_u_h(tmp1, 0);
out1 = __msa_copy_u_h(tmp1, 1);
out2 = __msa_copy_u_h(tmp1, 2);
out3 = __msa_copy_u_h(tmp1, 3);
STORE_HWORD(src, out0);
src += VAR_11;
STORE_HWORD(src, out1);
src += VAR_11;
STORE_HWORD(src, out2);
src += VAR_11;
STORE_HWORD(src, out3);
out0 = __msa_copy_u_h(tmp1, 4);
out1 = __msa_copy_u_h(tmp1, 5);
out2 = __msa_copy_u_h(tmp1, 6);
out3 = __msa_copy_u_h(tmp1, 7);
src += VAR_11;
STORE_HWORD(src, out0);
src += VAR_11;
STORE_HWORD(src, out1);
src += VAR_11;
STORE_HWORD(src, out2);
src += VAR_11;
STORE_HWORD(src, out3);
}
}
}
| [
"static void FUNC_0(uint8_t *VAR_0,\nuint8_t VAR_1, uint8_t VAR_2,\nuint8_t VAR_3, uint8_t VAR_4,\nuint8_t VAR_5, uint8_t VAR_6,\nuint8_t VAR_7, uint8_t VAR_8,\nuint8_t VAR_9,\nuint8_t VAR_10,\nuint32_t VAR_11)\n{",
"uint8_t *src;",
"uint16_t out0, out1, out2, out3;",
"v16u8 alpha, beta;",
"v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;",
"v16u8 is_less_than, is_less_than_beta, is_less_than_alpha;",
"v16u8 p0, q0;",
"v8i16 p0_r = { 0 };",
"v8i16 q0_r = { 0 };",
"v16u8 p1_org, p0_org, q0_org, q1_org;",
"v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;",
"v16u8 is_bs_greater_than0;",
"v8i16 tc_r, negate_tc_r;",
"v16i8 negate_tc, sign_negate_tc;",
"v16i8 zero = { 0 };",
"v16u8 row0, row1, row2, row3, row4, row5, row6, row7;",
"v8i16 tmp1, tmp_vec, bs = { 0 };",
"v8i16 tc = { 0 };",
"tmp_vec = (v8i16) __msa_fill_b(VAR_1);",
"bs = __msa_insve_h(bs, 0, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_2);",
"bs = __msa_insve_h(bs, 1, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_3);",
"bs = __msa_insve_h(bs, 2, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_4);",
"bs = __msa_insve_h(bs, 3, tmp_vec);",
"if (!__msa_test_bz_v((v16u8) bs)) {",
"tmp_vec = (v8i16) __msa_fill_b(VAR_5);",
"tc = __msa_insve_h(tc, 0, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_6);",
"tc = __msa_insve_h(tc, 1, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_7);",
"tc = __msa_insve_h(tc, 2, tmp_vec);",
"tmp_vec = (v8i16) __msa_fill_b(VAR_8);",
"tc = __msa_insve_h(tc, 3, tmp_vec);",
"is_bs_greater_than0 = (v16u8) (zero < (v16i8) bs);",
"LOAD_8VECS_UB((VAR_0 - 2), VAR_11,\nrow0, row1, row2, row3, row4, row5, row6, row7);",
"TRANSPOSE8x4_B_UB(row0, row1, row2, row3,\nrow4, row5, row6, row7,\np1_org, p0_org, q0_org, q1_org);",
"p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);",
"p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);",
"q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);",
"alpha = (v16u8) __msa_fill_b(VAR_9);",
"beta = (v16u8) __msa_fill_b(VAR_10);",
"is_less_than_alpha = (p0_asub_q0 < alpha);",
"is_less_than_beta = (p1_asub_p0 < beta);",
"is_less_than = is_less_than_beta & is_less_than_alpha;",
"is_less_than_beta = (q1_asub_q0 < beta);",
"is_less_than = is_less_than_beta & is_less_than;",
"is_less_than = is_bs_greater_than0 & is_less_than;",
"is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);",
"if (!__msa_test_bz_v(is_less_than)) {",
"p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);",
"p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);",
"q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);",
"q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);",
"negate_tc = zero - (v16i8) tc;",
"sign_negate_tc = __msa_clti_s_b(negate_tc, 0);",
"negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);",
"tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);",
"AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,\nnegate_tc_r, tc_r, p0_r, q0_r);",
"p0 = (v16u8) __msa_pckev_b(zero, (v16i8) p0_r);",
"q0 = (v16u8) __msa_pckev_b(zero, (v16i8) q0_r);",
"p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);",
"q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);",
"tmp1 = (v8i16) __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);",
"src = VAR_0 - 1;",
"out0 = __msa_copy_u_h(tmp1, 0);",
"out1 = __msa_copy_u_h(tmp1, 1);",
"out2 = __msa_copy_u_h(tmp1, 2);",
"out3 = __msa_copy_u_h(tmp1, 3);",
"STORE_HWORD(src, out0);",
"src += VAR_11;",
"STORE_HWORD(src, out1);",
"src += VAR_11;",
"STORE_HWORD(src, out2);",
"src += VAR_11;",
"STORE_HWORD(src, out3);",
"out0 = __msa_copy_u_h(tmp1, 4);",
"out1 = __msa_copy_u_h(tmp1, 5);",
"out2 = __msa_copy_u_h(tmp1, 6);",
"out3 = __msa_copy_u_h(tmp1, 7);",
"src += VAR_11;",
"STORE_HWORD(src, out0);",
"src += VAR_11;",
"STORE_HWORD(src, out1);",
"src += VAR_11;",
"STORE_HWORD(src, out2);",
"src += VAR_11;",
"STORE_HWORD(src, out3);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97,
99
],
[
103,
105,
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
161
],
[
165
],
[
169,
171
],
[
175
],
[
177
],
[
181
],
[
183
],
[
187
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
]
]
|
15,197 | static int mov_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
MOVMuxContext *mov = s->priv_data;
AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
int i, ret, hint_track = 0, tmcd_track = 0;
mov->fc = s;
/* Default mode == MP4 */
mov->mode = MODE_MP4;
if (s->oformat) {
if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
}
if (s->flags & AVFMT_FLAG_BITEXACT)
mov->exact = 1;
if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
/* Set the FRAGMENT flag if any of the fragmentation methods are
* enabled. */
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
/* Set other implicit flags immediately */
if (mov->mode == MODE_ISM)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF |
FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_DASH)
mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_DEFAULT_BASE_MOOF;
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
if (mov->use_editlist < 0) {
mov->use_editlist = 1;
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
// If we can avoid needing an edit list by shifting the
// tracks, prefer that over (trying to) write edit lists
// in fragmented output.
if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO ||
s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)
mov->use_editlist = 0;
}
}
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist)
av_log(s, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n");
if (!mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO)
s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;
/* Clear the omit_tfhd_offset flag if default_base_moof is set;
* if the latter is set that's enough and omit_tfhd_offset doesn't
* add anything extra on top of that. */
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET;
if (mov->frag_interleave &&
mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) {
av_log(s, AV_LOG_ERROR,
"Sample interleaving in fragments is mutually exclusive with "
"omit_tfhd_offset and separate_moof\n");
return AVERROR(EINVAL);
}
/* Non-seekable output is ok if using fragmentation. If ism_lookahead
* is enabled, we don't support non-seekable output at all. */
if (!s->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return AVERROR(EINVAL);
}
if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_identification(pb, s)) < 0)
return ret;
}
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Add hint tracks for each audio and video stream */
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
if (mov->mode == MODE_MOV) {
tmcd_track = mov->nb_streams;
/* +1 tmcd track for each video stream with a timecode */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
(global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0)))
mov->nb_meta_tmcd++;
}
/* check if there is already a tmcd track to remux */
if (mov->nb_meta_tmcd) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track "
"so timecode metadata are now ignored\n");
mov->nb_meta_tmcd = 0;
}
}
}
mov->nb_streams += mov->nb_meta_tmcd;
}
// Reserve an extra stream for chapters for the case where chapters
// are written in the trailer
mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->st = st;
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(s, track);
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, "
"codec not currently supported in container\n",
avcodec_get_name(st->codec->codec_id), i);
ret = AVERROR(EINVAL);
goto error;
}
/* If hinting of this track is enabled by a later hint track,
* this is updated. */
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
track->end_pts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
ret = AVERROR(EINVAL);
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
if (mov->video_track_timescale) {
track->timescale = mov->video_track_timescale;
} else {
track->timescale = st->time_base.den;
while(track->timescale < 10000)
track->timescale *= 2;
}
if (st->codec->width > 65535 || st->codec->height > 65535) {
av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height);
ret = AVERROR(EINVAL);
goto error;
}
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(s, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
track->audio_vbr = 1;
}else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
st->codec->codec_id == AV_CODEC_ID_ILBC){
if (!st->codec->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
ret = AVERROR(EINVAL);
goto error;
}
track->sample_size = st->codec->block_align;
}else if (st->codec->frame_size > 1){ /* assume compressed audio */
track->audio_vbr = 1;
}else{
track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
if (st->codec->codec_id == AV_CODEC_ID_ILBC ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n",
i, track->enc->sample_rate);
ret = AVERROR(EINVAL);
goto error;
} else {
av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n",
i, track->enc->sample_rate);
}
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->time_base.den;
} else {
track->timescale = MOV_TIMESCALE;
}
if (!track->height)
track->height = st->codec->height;
/* The ism specific timescale isn't mandatory, but is assumed by
* some tools, such as mp4split. */
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
/* copy extradata if it exists */
if (st->codec->extradata_size) {
if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_create_dvd_sub_decoder_specific_info(track, st);
else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data) {
ret = AVERROR(ENOMEM);
goto error;
}
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
}
for (i = 0; i < s->nb_streams; i++) {
int j;
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
track->enc->channel_layout != AV_CH_LAYOUT_MONO)
continue;
for (j = 0; j < s->nb_streams; j++) {
AVStream *stj= s->streams[j];
MOVTrack *trackj= &mov->tracks[j];
if (j == i)
continue;
if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
trackj->enc->channel_layout != AV_CH_LAYOUT_MONO ||
trackj->language != track->language ||
trackj->tag != track->tag
)
continue;
track->multichannel_as_mono++;
}
}
enable_tracks(s);
if (mov->reserved_moov_size){
mov->reserved_moov_pos= avio_tell(pb);
if (mov->reserved_moov_size > 0)
avio_skip(pb, mov->reserved_moov_size);
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
/* If no fragmentation options have been set, set a default. */
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;
} else {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080; // 1970 based -> 1904 based
if (mov->chapter_track)
if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Initialize the hint tracks for each audio and video stream */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0)
goto error;
hint_track++;
}
}
}
if (mov->nb_meta_tmcd) {
/* Initialize the tmcd tracks */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
t = global_tcr;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!t)
t = av_dict_get(st->metadata, "timecode", NULL, 0);
if (!t)
continue;
if ((ret = mov_create_timecode_track(s, tmcd_track, i, t->value)) < 0)
goto error;
tmcd_track++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
return ret;
mov->moov_written = 1;
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
}
return 0;
error:
mov_free(s);
return ret;
}
| false | FFmpeg | f98c3ec5c68d14d7c93c2f9775be4583f7905554 | static int mov_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
MOVMuxContext *mov = s->priv_data;
AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
int i, ret, hint_track = 0, tmcd_track = 0;
mov->fc = s;
mov->mode = MODE_MP4;
if (s->oformat) {
if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
}
if (s->flags & AVFMT_FLAG_BITEXACT)
mov->exact = 1;
if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
if (mov->mode == MODE_ISM)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF |
FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_DASH)
mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_DEFAULT_BASE_MOOF;
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
if (mov->use_editlist < 0) {
mov->use_editlist = 1;
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO ||
s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)
mov->use_editlist = 0;
}
}
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist)
av_log(s, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n");
if (!mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO)
s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET;
if (mov->frag_interleave &&
mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) {
av_log(s, AV_LOG_ERROR,
"Sample interleaving in fragments is mutually exclusive with "
"omit_tfhd_offset and separate_moof\n");
return AVERROR(EINVAL);
}
if (!s->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return AVERROR(EINVAL);
}
if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_identification(pb, s)) < 0)
return ret;
}
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
if (mov->mode == MODE_MOV) {
tmcd_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
(global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0)))
mov->nb_meta_tmcd++;
}
if (mov->nb_meta_tmcd) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track "
"so timecode metadata are now ignored\n");
mov->nb_meta_tmcd = 0;
}
}
}
mov->nb_streams += mov->nb_meta_tmcd;
}
mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->st = st;
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(s, track);
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, "
"codec not currently supported in container\n",
avcodec_get_name(st->codec->codec_id), i);
ret = AVERROR(EINVAL);
goto error;
}
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
track->end_pts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
ret = AVERROR(EINVAL);
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
if (mov->video_track_timescale) {
track->timescale = mov->video_track_timescale;
} else {
track->timescale = st->time_base.den;
while(track->timescale < 10000)
track->timescale *= 2;
}
if (st->codec->width > 65535 || st->codec->height > 65535) {
av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height);
ret = AVERROR(EINVAL);
goto error;
}
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(s, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
track->audio_vbr = 1;
}else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
st->codec->codec_id == AV_CODEC_ID_ILBC){
if (!st->codec->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
ret = AVERROR(EINVAL);
goto error;
}
track->sample_size = st->codec->block_align;
}else if (st->codec->frame_size > 1){
track->audio_vbr = 1;
}else{
track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
if (st->codec->codec_id == AV_CODEC_ID_ILBC ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n",
i, track->enc->sample_rate);
ret = AVERROR(EINVAL);
goto error;
} else {
av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n",
i, track->enc->sample_rate);
}
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->time_base.den;
} else {
track->timescale = MOV_TIMESCALE;
}
if (!track->height)
track->height = st->codec->height;
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
if (st->codec->extradata_size) {
if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_create_dvd_sub_decoder_specific_info(track, st);
else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data) {
ret = AVERROR(ENOMEM);
goto error;
}
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
}
for (i = 0; i < s->nb_streams; i++) {
int j;
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
track->enc->channel_layout != AV_CH_LAYOUT_MONO)
continue;
for (j = 0; j < s->nb_streams; j++) {
AVStream *stj= s->streams[j];
MOVTrack *trackj= &mov->tracks[j];
if (j == i)
continue;
if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
trackj->enc->channel_layout != AV_CH_LAYOUT_MONO ||
trackj->language != track->language ||
trackj->tag != track->tag
)
continue;
track->multichannel_as_mono++;
}
}
enable_tracks(s);
if (mov->reserved_moov_size){
mov->reserved_moov_pos= avio_tell(pb);
if (mov->reserved_moov_size > 0)
avio_skip(pb, mov->reserved_moov_size);
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;
} else {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080;
if (mov->chapter_track)
if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0)
goto error;
hint_track++;
}
}
}
if (mov->nb_meta_tmcd) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
t = global_tcr;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!t)
t = av_dict_get(st->metadata, "timecode", NULL, 0);
if (!t)
continue;
if ((ret = mov_create_timecode_track(s, tmcd_track, i, t->value)) < 0)
goto error;
tmcd_track++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
return ret;
mov->moov_written = 1;
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
}
return 0;
error:
mov_free(s);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVIOContext *pb = VAR_0->pb;
MOVMuxContext *mov = VAR_0->priv_data;
AVDictionaryEntry *t, *global_tcr = av_dict_get(VAR_0->metadata, "timecode", NULL, 0);
int VAR_1, VAR_2, VAR_3 = 0, VAR_4 = 0;
mov->fc = VAR_0;
mov->mode = MODE_MP4;
if (VAR_0->oformat) {
if (!strcmp("3gp", VAR_0->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", VAR_0->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", VAR_0->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", VAR_0->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",VAR_0->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",VAR_0->oformat->name)) mov->mode = MODE_ISM;
else if (!strcmp("f4v", VAR_0->oformat->name)) mov->mode = MODE_F4V;
}
if (VAR_0->flags & AVFMT_FLAG_BITEXACT)
mov->exact = 1;
if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
if (mov->mode == MODE_ISM)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF |
FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_DASH)
mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_DEFAULT_BASE_MOOF;
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
if (mov->use_editlist < 0) {
mov->use_editlist = 1;
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if (VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO ||
VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)
mov->use_editlist = 0;
}
}
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist)
av_log(VAR_0, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n");
if (!mov->use_editlist && VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO)
VAR_0->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET;
if (mov->frag_interleave &&
mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) {
av_log(VAR_0, AV_LOG_ERROR,
"Sample interleaving in fragments is mutually exclusive with "
"omit_tfhd_offset and separate_moof\n");
return AVERROR(EINVAL);
}
if (!VAR_0->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(VAR_0, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return AVERROR(EINVAL);
}
if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((VAR_2 = mov_write_identification(pb, VAR_0)) < 0)
return VAR_2;
}
mov->nb_streams = VAR_0->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && VAR_0->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
VAR_3 = mov->nb_streams;
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
if (mov->mode == MODE_MOV) {
VAR_4 = mov->nb_streams;
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
(global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0)))
mov->nb_meta_tmcd++;
}
if (mov->nb_meta_tmcd) {
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
av_log(VAR_0, AV_LOG_WARNING, "You requested a copy of the original timecode track "
"so timecode metadata are now ignored\n");
mov->nb_meta_tmcd = 0;
}
}
}
mov->nb_streams += mov->nb_meta_tmcd;
}
mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st= VAR_0->streams[VAR_1];
MOVTrack *track= &mov->tracks[VAR_1];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->st = st;
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(VAR_0, track);
if (!track->tag) {
av_log(VAR_0, AV_LOG_ERROR, "Could not find tag for codec %VAR_0 in stream #%d, "
"codec not currently supported in container\n",
avcodec_get_name(st->codec->codec_id), VAR_1);
VAR_2 = AVERROR(EINVAL);
goto error;
}
track->VAR_3 = -1;
track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
track->end_pts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(VAR_0, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
VAR_2 = AVERROR(EINVAL);
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
if (mov->video_track_timescale) {
track->timescale = mov->video_track_timescale;
} else {
track->timescale = st->time_base.den;
while(track->timescale < 10000)
track->timescale *= 2;
}
if (st->codec->width > 65535 || st->codec->height > 65535) {
av_log(VAR_0, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height);
VAR_2 = AVERROR(EINVAL);
goto error;
}
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(VAR_0, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
av_log(VAR_0, AV_LOG_WARNING, "track %d: codec frame size is not set\n", VAR_1);
track->audio_vbr = 1;
}else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
st->codec->codec_id == AV_CODEC_ID_ILBC){
if (!st->codec->block_align) {
av_log(VAR_0, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", VAR_1);
VAR_2 = AVERROR(EINVAL);
goto error;
}
track->sample_size = st->codec->block_align;
}else if (st->codec->frame_size > 1){
track->audio_vbr = 1;
}else{
track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
if (st->codec->codec_id == AV_CODEC_ID_ILBC ||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(VAR_0, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n",
VAR_1, track->enc->sample_rate);
VAR_2 = AVERROR(EINVAL);
goto error;
} else {
av_log(VAR_0, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n",
VAR_1, track->enc->sample_rate);
}
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->time_base.den;
} else {
track->timescale = MOV_TIMESCALE;
}
if (!track->height)
track->height = st->codec->height;
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
if (st->codec->extradata_size) {
if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_create_dvd_sub_decoder_specific_info(track, st);
else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data) {
VAR_2 = AVERROR(ENOMEM);
goto error;
}
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
}
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
int j;
AVStream *st= VAR_0->streams[VAR_1];
MOVTrack *track= &mov->tracks[VAR_1];
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
track->enc->channel_layout != AV_CH_LAYOUT_MONO)
continue;
for (j = 0; j < VAR_0->nb_streams; j++) {
AVStream *stj= VAR_0->streams[j];
MOVTrack *trackj= &mov->tracks[j];
if (j == VAR_1)
continue;
if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
trackj->enc->channel_layout != AV_CH_LAYOUT_MONO ||
trackj->language != track->language ||
trackj->tag != track->tag
)
continue;
track->multichannel_as_mono++;
}
}
enable_tracks(VAR_0);
if (mov->reserved_moov_size){
mov->reserved_moov_pos= avio_tell(pb);
if (mov->reserved_moov_size > 0)
avio_skip(pb, mov->reserved_moov_size);
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;
} else {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(VAR_0->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080;
if (mov->chapter_track)
if ((VAR_2 = mov_create_chapter_track(VAR_0, mov->chapter_track)) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((VAR_2 = ff_mov_init_hinting(VAR_0, VAR_3, VAR_1)) < 0)
goto error;
VAR_3++;
}
}
}
if (mov->nb_meta_tmcd) {
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
t = global_tcr;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!t)
t = av_dict_get(st->metadata, "timecode", NULL, 0);
if (!t)
continue;
if ((VAR_2 = mov_create_timecode_track(VAR_0, VAR_4, VAR_1, t->value)) < 0)
goto error;
VAR_4++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((VAR_2 = mov_write_moov_tag(pb, mov, VAR_0)) < 0)
return VAR_2;
mov->moov_written = 1;
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
}
return 0;
error:
mov_free(VAR_0);
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVIOContext *pb = VAR_0->pb;",
"MOVMuxContext *mov = VAR_0->priv_data;",
"AVDictionaryEntry *t, *global_tcr = av_dict_get(VAR_0->metadata, \"timecode\", NULL, 0);",
"int VAR_1, VAR_2, VAR_3 = 0, VAR_4 = 0;",
"mov->fc = VAR_0;",
"mov->mode = MODE_MP4;",
"if (VAR_0->oformat) {",
"if (!strcmp(\"3gp\", VAR_0->oformat->name)) mov->mode = MODE_3GP;",
"else if (!strcmp(\"3g2\", VAR_0->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;",
"else if (!strcmp(\"mov\", VAR_0->oformat->name)) mov->mode = MODE_MOV;",
"else if (!strcmp(\"psp\", VAR_0->oformat->name)) mov->mode = MODE_PSP;",
"else if (!strcmp(\"ipod\",VAR_0->oformat->name)) mov->mode = MODE_IPOD;",
"else if (!strcmp(\"ismv\",VAR_0->oformat->name)) mov->mode = MODE_ISM;",
"else if (!strcmp(\"f4v\", VAR_0->oformat->name)) mov->mode = MODE_F4V;",
"}",
"if (VAR_0->flags & AVFMT_FLAG_BITEXACT)\nmov->exact = 1;",
"if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)\nmov->flags |= FF_MOV_FLAG_EMPTY_MOOV;",
"if (mov->max_fragment_duration || mov->max_fragment_size ||\nmov->flags & (FF_MOV_FLAG_EMPTY_MOOV |\nFF_MOV_FLAG_FRAG_KEYFRAME |\nFF_MOV_FLAG_FRAG_CUSTOM))\nmov->flags |= FF_MOV_FLAG_FRAGMENT;",
"if (mov->mode == MODE_ISM)\nmov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF |\nFF_MOV_FLAG_FRAGMENT;",
"if (mov->flags & FF_MOV_FLAG_DASH)\nmov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |\nFF_MOV_FLAG_DEFAULT_BASE_MOOF;",
"if (mov->flags & FF_MOV_FLAG_FASTSTART) {",
"mov->reserved_moov_size = -1;",
"}",
"if (mov->use_editlist < 0) {",
"mov->use_editlist = 1;",
"if (mov->flags & FF_MOV_FLAG_FRAGMENT &&\n!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {",
"if (VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO ||\nVAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)\nmov->use_editlist = 0;",
"}",
"}",
"if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&\n!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist)\nav_log(VAR_0, AV_LOG_WARNING, \"No meaningful edit list will be written when using empty_moov without delay_moov\\n\");",
"if (!mov->use_editlist && VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO)\nVAR_0->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;",
"if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&\nmov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)\nmov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET;",
"if (mov->frag_interleave &&\nmov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Sample interleaving in fragments is mutually exclusive with \"\n\"omit_tfhd_offset and separate_moof\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (!VAR_0->pb->seekable &&\n(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"muxer does not support non seekable output\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {",
"if ((VAR_2 = mov_write_identification(pb, VAR_0)) < 0)\nreturn VAR_2;",
"}",
"mov->nb_streams = VAR_0->nb_streams;",
"if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && VAR_0->nb_chapters)\nmov->chapter_track = mov->nb_streams++;",
"if (mov->flags & FF_MOV_FLAG_RTP_HINT) {",
"VAR_3 = mov->nb_streams;",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||\nst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"mov->nb_streams++;",
"}",
"}",
"}",
"if (mov->mode == MODE_MOV) {",
"VAR_4 = mov->nb_streams;",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n(global_tcr || av_dict_get(st->metadata, \"timecode\", NULL, 0)))\nmov->nb_meta_tmcd++;",
"}",
"if (mov->nb_meta_tmcd) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_tag == MKTAG('t','m','c','d')) {",
"av_log(VAR_0, AV_LOG_WARNING, \"You requested a copy of the original timecode track \"\n\"so timecode metadata are now ignored\\n\");",
"mov->nb_meta_tmcd = 0;",
"}",
"}",
"}",
"mov->nb_streams += mov->nb_meta_tmcd;",
"}",
"mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));",
"if (!mov->tracks)\nreturn AVERROR(ENOMEM);",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st= VAR_0->streams[VAR_1];",
"MOVTrack *track= &mov->tracks[VAR_1];",
"AVDictionaryEntry *lang = av_dict_get(st->metadata, \"language\", NULL,0);",
"track->st = st;",
"track->enc = st->codec;",
"track->language = ff_mov_iso639_to_lang(lang?lang->value:\"und\", mov->mode!=MODE_MOV);",
"if (track->language < 0)\ntrack->language = 0;",
"track->mode = mov->mode;",
"track->tag = mov_find_codec_tag(VAR_0, track);",
"if (!track->tag) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not find tag for codec %VAR_0 in stream #%d, \"\n\"codec not currently supported in container\\n\",\navcodec_get_name(st->codec->codec_id), VAR_1);",
"VAR_2 = AVERROR(EINVAL);",
"goto error;",
"}",
"track->VAR_3 = -1;",
"track->start_dts = AV_NOPTS_VALUE;",
"track->start_cts = AV_NOPTS_VALUE;",
"track->end_pts = AV_NOPTS_VALUE;",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||\ntrack->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||\ntrack->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {",
"if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"D-10/IMX must use 720x608 or 720x512 video resolution\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto error;",
"}",
"track->height = track->tag >> 24 == 'n' ? 486 : 576;",
"}",
"if (mov->video_track_timescale) {",
"track->timescale = mov->video_track_timescale;",
"} else {",
"track->timescale = st->time_base.den;",
"while(track->timescale < 10000)\ntrack->timescale *= 2;",
"}",
"if (st->codec->width > 65535 || st->codec->height > 65535) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Resolution %dx%d too large for mov/mp4\\n\", st->codec->width, st->codec->height);",
"VAR_2 = AVERROR(EINVAL);",
"goto error;",
"}",
"if (track->mode == MODE_MOV && track->timescale > 100000)\nav_log(VAR_0, AV_LOG_WARNING,\n\"WARNING codec timebase is very high. If duration is too long,\\n\"\n\"file may not be playable by quicktime. Specify a shorter timebase\\n\"\n\"or choose different container.\\n\");",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"track->timescale = st->codec->sample_rate;",
"if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {",
"av_log(VAR_0, AV_LOG_WARNING, \"track %d: codec frame size is not set\\n\", VAR_1);",
"track->audio_vbr = 1;",
"}else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||",
"st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||\nst->codec->codec_id == AV_CODEC_ID_ILBC){",
"if (!st->codec->block_align) {",
"av_log(VAR_0, AV_LOG_ERROR, \"track %d: codec block align is not set for adpcm\\n\", VAR_1);",
"VAR_2 = AVERROR(EINVAL);",
"goto error;",
"}",
"track->sample_size = st->codec->block_align;",
"}else if (st->codec->frame_size > 1){",
"track->audio_vbr = 1;",
"}else{",
"track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;",
"}",
"if (st->codec->codec_id == AV_CODEC_ID_ILBC ||\nst->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {",
"track->audio_vbr = 1;",
"}",
"if (track->mode != MODE_MOV &&\ntrack->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {",
"if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\\n\",\nVAR_1, track->enc->sample_rate);",
"VAR_2 = AVERROR(EINVAL);",
"goto error;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"track %d: muxing mp3 at %dhz is not standard in MP4\\n\",\nVAR_1, track->enc->sample_rate);",
"}",
"}",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"track->timescale = st->time_base.den;",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {",
"track->timescale = st->time_base.den;",
"} else {",
"track->timescale = MOV_TIMESCALE;",
"}",
"if (!track->height)\ntrack->height = st->codec->height;",
"if (mov->mode == MODE_ISM)\ntrack->timescale = 10000000;",
"avpriv_set_pts_info(st, 64, 1, track->timescale);",
"if (st->codec->extradata_size) {",
"if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)\nmov_create_dvd_sub_decoder_specific_info(track, st);",
"else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {",
"track->vos_len = st->codec->extradata_size;",
"track->vos_data = av_malloc(track->vos_len);",
"if (!track->vos_data) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto error;",
"}",
"memcpy(track->vos_data, st->codec->extradata, track->vos_len);",
"}",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"int j;",
"AVStream *st= VAR_0->streams[VAR_1];",
"MOVTrack *track= &mov->tracks[VAR_1];",
"if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||\ntrack->enc->channel_layout != AV_CH_LAYOUT_MONO)\ncontinue;",
"for (j = 0; j < VAR_0->nb_streams; j++) {",
"AVStream *stj= VAR_0->streams[j];",
"MOVTrack *trackj= &mov->tracks[j];",
"if (j == VAR_1)\ncontinue;",
"if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO ||\ntrackj->enc->channel_layout != AV_CH_LAYOUT_MONO ||\ntrackj->language != track->language ||\ntrackj->tag != track->tag\n)\ncontinue;",
"track->multichannel_as_mono++;",
"}",
"}",
"enable_tracks(VAR_0);",
"if (mov->reserved_moov_size){",
"mov->reserved_moov_pos= avio_tell(pb);",
"if (mov->reserved_moov_size > 0)\navio_skip(pb, mov->reserved_moov_size);",
"}",
"if (mov->flags & FF_MOV_FLAG_FRAGMENT) {",
"if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |\nFF_MOV_FLAG_FRAG_CUSTOM)) &&\n!mov->max_fragment_duration && !mov->max_fragment_size)\nmov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;",
"} else {",
"if (mov->flags & FF_MOV_FLAG_FASTSTART)\nmov->reserved_moov_pos = avio_tell(pb);",
"mov_write_mdat_tag(pb, mov);",
"}",
"if (t = av_dict_get(VAR_0->metadata, \"creation_time\", NULL, 0))\nmov->time = ff_iso8601_to_unix_time(t->value);",
"if (mov->time)\nmov->time += 0x7C25B080;",
"if (mov->chapter_track)\nif ((VAR_2 = mov_create_chapter_track(VAR_0, mov->chapter_track)) < 0)\ngoto error;",
"if (mov->flags & FF_MOV_FLAG_RTP_HINT) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||\nst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if ((VAR_2 = ff_mov_init_hinting(VAR_0, VAR_3, VAR_1)) < 0)\ngoto error;",
"VAR_3++;",
"}",
"}",
"}",
"if (mov->nb_meta_tmcd) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"t = global_tcr;",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (!t)\nt = av_dict_get(st->metadata, \"timecode\", NULL, 0);",
"if (!t)\ncontinue;",
"if ((VAR_2 = mov_create_timecode_track(VAR_0, VAR_4, VAR_1, t->value)) < 0)\ngoto error;",
"VAR_4++;",
"}",
"}",
"}",
"avio_flush(pb);",
"if (mov->flags & FF_MOV_FLAG_ISML)\nmov_write_isml_manifest(pb, mov);",
"if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&\n!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {",
"if ((VAR_2 = mov_write_moov_tag(pb, mov, VAR_0)) < 0)\nreturn VAR_2;",
"mov->moov_written = 1;",
"if (mov->flags & FF_MOV_FLAG_FASTSTART)\nmov->reserved_moov_pos = avio_tell(pb);",
"}",
"return 0;",
"error:\nmov_free(VAR_0);",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
51,
53
],
[
61,
63,
65,
67,
69
],
[
75,
77,
79
],
[
81,
83,
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101,
103
],
[
111,
113,
115
],
[
117
],
[
119
],
[
121,
123,
125
],
[
129,
131
],
[
141,
143,
145
],
[
149,
151
],
[
153,
155,
157
],
[
159
],
[
161
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183,
185
],
[
187
],
[
191
],
[
193,
195
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235,
237,
239
],
[
241
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
279
],
[
281,
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
313,
315,
317
],
[
319
],
[
321
],
[
323
],
[
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,
387,
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431,
433
],
[
435
],
[
437
],
[
439,
441
],
[
443
],
[
445,
447
],
[
449
],
[
451
],
[
453
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
485,
487
],
[
491
],
[
497
],
[
499,
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
527
],
[
529
],
[
531
],
[
533
],
[
537,
539,
541
],
[
545
],
[
547
],
[
549
],
[
551,
553
],
[
557,
559,
561,
563,
565,
567
],
[
569
],
[
571
],
[
573
],
[
577
],
[
583
],
[
585
],
[
587,
589
],
[
591
],
[
595
],
[
599,
601,
603,
605
],
[
607
],
[
609,
611
],
[
613
],
[
615
],
[
619,
621
],
[
623,
625
],
[
629,
631,
633
],
[
637
],
[
641
],
[
643
],
[
645,
647
],
[
649,
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
663
],
[
667
],
[
669
],
[
671
],
[
675
],
[
677,
679
],
[
681,
683
],
[
685,
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
699
],
[
703,
705
],
[
709,
711
],
[
713,
715
],
[
717
],
[
719,
721
],
[
723
],
[
727
],
[
729,
731
],
[
733
],
[
735
]
]
|
15,199 | static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
{
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
unsigned int div_blocks[32]; ///< block sizes.
unsigned int c;
unsigned int js_blocks[2];
uint32_t bs_info = 0;
int ret;
// skip the size of the ra unit if present in the frame
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
skip_bits_long(gb, 32);
if (sconf->mc_coding && sconf->joint_stereo) {
ctx->js_switch = get_bits1(gb);
align_get_bits(gb);
if (!sconf->mc_coding || ctx->js_switch) {
int independent_bs = !sconf->joint_stereo;
for (c = 0; c < avctx->channels; c++) {
js_blocks[0] = 0;
js_blocks[1] = 0;
get_block_sizes(ctx, div_blocks, &bs_info);
// if joint_stereo and block_switching is set, independent decoding
// is signaled via the first bit of bs_info
if (sconf->joint_stereo && sconf->block_switching)
if (bs_info >> 31)
independent_bs = 2;
// if this is the last channel, it has to be decoded independently
if (c == avctx->channels - 1)
independent_bs = 1;
if (independent_bs) {
ret = decode_blocks_ind(ctx, ra_frame, c,
div_blocks, js_blocks);
if (ret < 0)
return ret;
independent_bs--;
} else {
ret = decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
if (ret < 0)
return ret;
c++;
// store carryover raw samples
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
} else { // multi-channel coding
ALSBlockData bd = { 0 };
int b, ret;
int *reverted_channels = ctx->reverted_channels;
unsigned int offset = 0;
for (c = 0; c < avctx->channels; c++)
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
bd.ra_block = ra_frame;
bd.prev_raw_samples = ctx->prev_raw_samples;
get_block_sizes(ctx, div_blocks, &bs_info);
for (b = 0; b < ctx->num_blocks; b++) {
bd.block_length = div_blocks[b];
if (bd.block_length <= 0) {
av_log(ctx->avctx, AV_LOG_WARNING,
"Invalid block length %u in channel data!\n",
bd.block_length);
continue;
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
bd.raw_other = NULL;
if ((ret = read_block(ctx, &bd)) < 0)
return ret;
if ((ret = read_channel_data(ctx, ctx->chan_data[c], c)) < 0)
return ret;
for (c = 0; c < avctx->channels; c++) {
ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,
reverted_channels, offset, c);
if (ret < 0)
return ret;
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
if ((ret = decode_block(ctx, &bd)) < 0)
return ret;
memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));
offset += div_blocks[b];
bd.ra_block = 0;
// store carryover raw samples
for (c = 0; c < avctx->channels; c++)
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
// TODO: read_diff_float_data
return 0; | true | FFmpeg | c2657633187e325a439e3297fd9ccd0522ab2e39 | static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
{
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
unsigned int div_blocks[32];
unsigned int c;
unsigned int js_blocks[2];
uint32_t bs_info = 0;
int ret;
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
skip_bits_long(gb, 32);
if (sconf->mc_coding && sconf->joint_stereo) {
ctx->js_switch = get_bits1(gb);
align_get_bits(gb);
if (!sconf->mc_coding || ctx->js_switch) {
int independent_bs = !sconf->joint_stereo;
for (c = 0; c < avctx->channels; c++) {
js_blocks[0] = 0;
js_blocks[1] = 0;
get_block_sizes(ctx, div_blocks, &bs_info);
if (sconf->joint_stereo && sconf->block_switching)
if (bs_info >> 31)
independent_bs = 2;
if (c == avctx->channels - 1)
independent_bs = 1;
if (independent_bs) {
ret = decode_blocks_ind(ctx, ra_frame, c,
div_blocks, js_blocks);
if (ret < 0)
return ret;
independent_bs--;
} else {
ret = decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
if (ret < 0)
return ret;
c++;
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
} else {
ALSBlockData bd = { 0 };
int b, ret;
int *reverted_channels = ctx->reverted_channels;
unsigned int offset = 0;
for (c = 0; c < avctx->channels; c++)
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
bd.ra_block = ra_frame;
bd.prev_raw_samples = ctx->prev_raw_samples;
get_block_sizes(ctx, div_blocks, &bs_info);
for (b = 0; b < ctx->num_blocks; b++) {
bd.block_length = div_blocks[b];
if (bd.block_length <= 0) {
av_log(ctx->avctx, AV_LOG_WARNING,
"Invalid block length %u in channel data!\n",
bd.block_length);
continue;
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
bd.raw_other = NULL;
if ((ret = read_block(ctx, &bd)) < 0)
return ret;
if ((ret = read_channel_data(ctx, ctx->chan_data[c], c)) < 0)
return ret;
for (c = 0; c < avctx->channels; c++) {
ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,
reverted_channels, offset, c);
if (ret < 0)
return ret;
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
if ((ret = decode_block(ctx, &bd)) < 0)
return ret;
memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));
offset += div_blocks[b];
bd.ra_block = 0;
for (c = 0; c < avctx->channels; c++)
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(ALSDecContext *VAR_0, unsigned int VAR_1)
{
ALSSpecificConfig *sconf = &VAR_0->sconf;
AVCodecContext *avctx = VAR_0->avctx;
GetBitContext *gb = &VAR_0->gb;
unsigned int VAR_2[32];
unsigned int VAR_3;
unsigned int VAR_4[2];
uint32_t bs_info = 0;
int VAR_5;
if (sconf->ra_flag == RA_FLAG_FRAMES && VAR_1)
skip_bits_long(gb, 32);
if (sconf->mc_coding && sconf->joint_stereo) {
VAR_0->js_switch = get_bits1(gb);
align_get_bits(gb);
if (!sconf->mc_coding || VAR_0->js_switch) {
int VAR_6 = !sconf->joint_stereo;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {
VAR_4[0] = 0;
VAR_4[1] = 0;
get_block_sizes(VAR_0, VAR_2, &bs_info);
if (sconf->joint_stereo && sconf->block_switching)
if (bs_info >> 31)
VAR_6 = 2;
if (VAR_3 == avctx->channels - 1)
VAR_6 = 1;
if (VAR_6) {
VAR_5 = decode_blocks_ind(VAR_0, VAR_1, VAR_3,
VAR_2, VAR_4);
if (VAR_5 < 0)
return VAR_5;
VAR_6--;
} else {
VAR_5 = decode_blocks(VAR_0, VAR_1, VAR_3, VAR_2, VAR_4);
if (VAR_5 < 0)
return VAR_5;
VAR_3++;
memmove(VAR_0->raw_samples[VAR_3] - sconf->max_order,
VAR_0->raw_samples[VAR_3] - sconf->max_order + sconf->frame_length,
sizeof(*VAR_0->raw_samples[VAR_3]) * sconf->max_order);
} else {
ALSBlockData bd = { 0 };
int b, VAR_5;
int *reverted_channels = VAR_0->reverted_channels;
unsigned int offset = 0;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++)
if (VAR_0->chan_data[VAR_3] < VAR_0->chan_data_buffer) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
bd.ra_block = VAR_1;
bd.prev_raw_samples = VAR_0->prev_raw_samples;
get_block_sizes(VAR_0, VAR_2, &bs_info);
for (b = 0; b < VAR_0->num_blocks; b++) {
bd.block_length = VAR_2[b];
if (bd.block_length <= 0) {
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Invalid block length %u in channel data!\n",
bd.block_length);
continue;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {
bd.const_block = VAR_0->const_block + VAR_3;
bd.shift_lsbs = VAR_0->shift_lsbs + VAR_3;
bd.opt_order = VAR_0->opt_order + VAR_3;
bd.store_prev_samples = VAR_0->store_prev_samples + VAR_3;
bd.use_ltp = VAR_0->use_ltp + VAR_3;
bd.ltp_lag = VAR_0->ltp_lag + VAR_3;
bd.ltp_gain = VAR_0->ltp_gain[VAR_3];
bd.lpc_cof = VAR_0->lpc_cof[VAR_3];
bd.quant_cof = VAR_0->quant_cof[VAR_3];
bd.raw_samples = VAR_0->raw_samples[VAR_3] + offset;
bd.raw_other = NULL;
if ((VAR_5 = read_block(VAR_0, &bd)) < 0)
return VAR_5;
if ((VAR_5 = read_channel_data(VAR_0, VAR_0->chan_data[VAR_3], VAR_3)) < 0)
return VAR_5;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {
VAR_5 = revert_channel_correlation(VAR_0, &bd, VAR_0->chan_data,
reverted_channels, offset, VAR_3);
if (VAR_5 < 0)
return VAR_5;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {
bd.const_block = VAR_0->const_block + VAR_3;
bd.shift_lsbs = VAR_0->shift_lsbs + VAR_3;
bd.opt_order = VAR_0->opt_order + VAR_3;
bd.store_prev_samples = VAR_0->store_prev_samples + VAR_3;
bd.use_ltp = VAR_0->use_ltp + VAR_3;
bd.ltp_lag = VAR_0->ltp_lag + VAR_3;
bd.ltp_gain = VAR_0->ltp_gain[VAR_3];
bd.lpc_cof = VAR_0->lpc_cof[VAR_3];
bd.quant_cof = VAR_0->quant_cof[VAR_3];
bd.raw_samples = VAR_0->raw_samples[VAR_3] + offset;
if ((VAR_5 = decode_block(VAR_0, &bd)) < 0)
return VAR_5;
memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));
offset += VAR_2[b];
bd.ra_block = 0;
for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++)
memmove(VAR_0->raw_samples[VAR_3] - sconf->max_order,
VAR_0->raw_samples[VAR_3] - sconf->max_order + sconf->frame_length,
sizeof(*VAR_0->raw_samples[VAR_3]) * sconf->max_order);
return 0; | [
"static int FUNC_0(ALSDecContext *VAR_0, unsigned int VAR_1)\n{",
"ALSSpecificConfig *sconf = &VAR_0->sconf;",
"AVCodecContext *avctx = VAR_0->avctx;",
"GetBitContext *gb = &VAR_0->gb;",
"unsigned int VAR_2[32];",
"unsigned int VAR_3;",
"unsigned int VAR_4[2];",
"uint32_t bs_info = 0;",
"int VAR_5;",
"if (sconf->ra_flag == RA_FLAG_FRAMES && VAR_1)\nskip_bits_long(gb, 32);",
"if (sconf->mc_coding && sconf->joint_stereo) {",
"VAR_0->js_switch = get_bits1(gb);",
"align_get_bits(gb);",
"if (!sconf->mc_coding || VAR_0->js_switch) {",
"int VAR_6 = !sconf->joint_stereo;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {",
"VAR_4[0] = 0;",
"VAR_4[1] = 0;",
"get_block_sizes(VAR_0, VAR_2, &bs_info);",
"if (sconf->joint_stereo && sconf->block_switching)\nif (bs_info >> 31)\nVAR_6 = 2;",
"if (VAR_3 == avctx->channels - 1)\nVAR_6 = 1;",
"if (VAR_6) {",
"VAR_5 = decode_blocks_ind(VAR_0, VAR_1, VAR_3,\nVAR_2, VAR_4);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_6--;",
"} else {",
"VAR_5 = decode_blocks(VAR_0, VAR_1, VAR_3, VAR_2, VAR_4);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_3++;",
"memmove(VAR_0->raw_samples[VAR_3] - sconf->max_order,\nVAR_0->raw_samples[VAR_3] - sconf->max_order + sconf->frame_length,\nsizeof(*VAR_0->raw_samples[VAR_3]) * sconf->max_order);",
"} else {",
"ALSBlockData bd = { 0 };",
"int b, VAR_5;",
"int *reverted_channels = VAR_0->reverted_channels;",
"unsigned int offset = 0;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++)",
"if (VAR_0->chan_data[VAR_3] < VAR_0->chan_data_buffer) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid channel data.\\n\");",
"memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);",
"bd.ra_block = VAR_1;",
"bd.prev_raw_samples = VAR_0->prev_raw_samples;",
"get_block_sizes(VAR_0, VAR_2, &bs_info);",
"for (b = 0; b < VAR_0->num_blocks; b++) {",
"bd.block_length = VAR_2[b];",
"if (bd.block_length <= 0) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Invalid block length %u in channel data!\\n\",\nbd.block_length);",
"continue;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {",
"bd.const_block = VAR_0->const_block + VAR_3;",
"bd.shift_lsbs = VAR_0->shift_lsbs + VAR_3;",
"bd.opt_order = VAR_0->opt_order + VAR_3;",
"bd.store_prev_samples = VAR_0->store_prev_samples + VAR_3;",
"bd.use_ltp = VAR_0->use_ltp + VAR_3;",
"bd.ltp_lag = VAR_0->ltp_lag + VAR_3;",
"bd.ltp_gain = VAR_0->ltp_gain[VAR_3];",
"bd.lpc_cof = VAR_0->lpc_cof[VAR_3];",
"bd.quant_cof = VAR_0->quant_cof[VAR_3];",
"bd.raw_samples = VAR_0->raw_samples[VAR_3] + offset;",
"bd.raw_other = NULL;",
"if ((VAR_5 = read_block(VAR_0, &bd)) < 0)\nreturn VAR_5;",
"if ((VAR_5 = read_channel_data(VAR_0, VAR_0->chan_data[VAR_3], VAR_3)) < 0)\nreturn VAR_5;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {",
"VAR_5 = revert_channel_correlation(VAR_0, &bd, VAR_0->chan_data,\nreverted_channels, offset, VAR_3);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++) {",
"bd.const_block = VAR_0->const_block + VAR_3;",
"bd.shift_lsbs = VAR_0->shift_lsbs + VAR_3;",
"bd.opt_order = VAR_0->opt_order + VAR_3;",
"bd.store_prev_samples = VAR_0->store_prev_samples + VAR_3;",
"bd.use_ltp = VAR_0->use_ltp + VAR_3;",
"bd.ltp_lag = VAR_0->ltp_lag + VAR_3;",
"bd.ltp_gain = VAR_0->ltp_gain[VAR_3];",
"bd.lpc_cof = VAR_0->lpc_cof[VAR_3];",
"bd.quant_cof = VAR_0->quant_cof[VAR_3];",
"bd.raw_samples = VAR_0->raw_samples[VAR_3] + offset;",
"if ((VAR_5 = decode_block(VAR_0, &bd)) < 0)\nreturn VAR_5;",
"memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));",
"offset += VAR_2[b];",
"bd.ra_block = 0;",
"for (VAR_3 = 0; VAR_3 < avctx->channels; VAR_3++)",
"memmove(VAR_0->raw_samples[VAR_3] - sconf->max_order,\nVAR_0->raw_samples[VAR_3] - sconf->max_order + sconf->frame_length,\nsizeof(*VAR_0->raw_samples[VAR_3]) * sconf->max_order);",
"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
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
12,
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
25,
26,
27
],
[
29,
30
],
[
31
],
[
32,
33
],
[
34,
35
],
[
36
],
[
37
],
[
38
],
[
39,
40
],
[
41
],
[
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
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97,
98
],
[
99
],
[
100
],
[
101
],
[
103
],
[
104,
105,
106
],
[
108
]
]
|
15,200 | int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){
int dst_index, i;
int index= c->index;
int frac= c->frac;
int dst_incr_frac= c->dst_incr % c->src_incr;
int dst_incr= c->dst_incr / c->src_incr;
int compensation_distance= c->compensation_distance;
if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
int64_t index2= ((int64_t)index)<<32;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
for(dst_index=0; dst_index < dst_size; dst_index++){
dst[dst_index] = src[index2>>32];
index2 += incr;
}
frac += dst_index * dst_incr_frac;
index += dst_index * dst_incr;
index += frac / c->src_incr;
frac %= c->src_incr;
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
int sample_index= index >> c->phase_shift;
FELEM2 val=0;
if(sample_index < 0){
for(i=0; i<c->filter_length; i++)
val += src[FFABS(sample_index + i) % src_size] * filter[i];
}else if(sample_index + c->filter_length > src_size){
break;
}else if(c->linear){
FELEM2 v2=0;
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
}
val+=(v2-val)*(FELEML)frac / c->src_incr;
}else{
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
}
}
#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
dst[dst_index] = av_clip_int16(lrintf(val));
#else
val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
#endif
frac += dst_incr_frac;
index += dst_incr;
if(frac >= c->src_incr){
frac -= c->src_incr;
index++;
}
if(dst_index + 1 == compensation_distance){
compensation_distance= 0;
dst_incr_frac= c->ideal_dst_incr % c->src_incr;
dst_incr= c->ideal_dst_incr / c->src_incr;
}
}
}
*consumed= FFMAX(index, 0) >> c->phase_shift;
if(index>=0) index &= c->phase_mask;
if(compensation_distance){
compensation_distance -= dst_index;
assert(compensation_distance > 0);
}
if(update_ctx){
c->frac= frac;
c->index= index;
c->dst_incr= dst_incr_frac + c->src_incr*dst_incr;
c->compensation_distance= compensation_distance;
}
#if 0
if(update_ctx && !c->compensation_distance){
#undef rand
av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2);
av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance);
}
#endif
return dst_index;
}
| true | FFmpeg | 1b9ca38d9d06d319fffd61d27e4eb385d6572ba8 | int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){
int dst_index, i;
int index= c->index;
int frac= c->frac;
int dst_incr_frac= c->dst_incr % c->src_incr;
int dst_incr= c->dst_incr / c->src_incr;
int compensation_distance= c->compensation_distance;
if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
int64_t index2= ((int64_t)index)<<32;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
for(dst_index=0; dst_index < dst_size; dst_index++){
dst[dst_index] = src[index2>>32];
index2 += incr;
}
frac += dst_index * dst_incr_frac;
index += dst_index * dst_incr;
index += frac / c->src_incr;
frac %= c->src_incr;
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
int sample_index= index >> c->phase_shift;
FELEM2 val=0;
if(sample_index < 0){
for(i=0; i<c->filter_length; i++)
val += src[FFABS(sample_index + i) % src_size] * filter[i];
}else if(sample_index + c->filter_length > src_size){
break;
}else if(c->linear){
FELEM2 v2=0;
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
}
val+=(v2-val)*(FELEML)frac / c->src_incr;
}else{
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
}
}
#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
dst[dst_index] = av_clip_int16(lrintf(val));
#else
val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
#endif
frac += dst_incr_frac;
index += dst_incr;
if(frac >= c->src_incr){
frac -= c->src_incr;
index++;
}
if(dst_index + 1 == compensation_distance){
compensation_distance= 0;
dst_incr_frac= c->ideal_dst_incr % c->src_incr;
dst_incr= c->ideal_dst_incr / c->src_incr;
}
}
}
*consumed= FFMAX(index, 0) >> c->phase_shift;
if(index>=0) index &= c->phase_mask;
if(compensation_distance){
compensation_distance -= dst_index;
assert(compensation_distance > 0);
}
if(update_ctx){
c->frac= frac;
c->index= index;
c->dst_incr= dst_incr_frac + c->src_incr*dst_incr;
c->compensation_distance= compensation_distance;
}
#if 0
if(update_ctx && !c->compensation_distance){
#undef rand
av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2);
av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance);
}
#endif
return dst_index;
}
| {
"code": [
" frac += dst_index * dst_incr_frac;",
" index += frac / c->src_incr;",
" frac %= c->src_incr;",
" frac += dst_index * dst_incr_frac;",
" index += frac / c->src_incr;",
" frac %= c->src_incr;"
],
"line_no": [
35,
39,
41,
35,
39,
41
]
} | int FUNC_0(AVResampleContext *VAR_0, short *VAR_1, const short *VAR_2, int *VAR_3, int VAR_4, int VAR_5, int VAR_6){
int VAR_7, VAR_8;
int VAR_9= VAR_0->VAR_9;
int VAR_10= VAR_0->VAR_10;
int VAR_11= VAR_0->VAR_12 % VAR_0->src_incr;
int VAR_12= VAR_0->VAR_12 / VAR_0->src_incr;
int VAR_13= VAR_0->VAR_13;
if(VAR_13 == 0 && VAR_0->filter_length == 1 && VAR_0->phase_shift==0){
int64_t index2= ((int64_t)VAR_9)<<32;
int64_t incr= (1LL<<32) * VAR_0->VAR_12 / VAR_0->src_incr;
VAR_5= FFMIN(VAR_5, (VAR_4-1-VAR_9) * (int64_t)VAR_0->src_incr / VAR_0->VAR_12);
for(VAR_7=0; VAR_7 < VAR_5; VAR_7++){
VAR_1[VAR_7] = VAR_2[index2>>32];
index2 += incr;
}
VAR_10 += VAR_7 * VAR_11;
VAR_9 += VAR_7 * VAR_12;
VAR_9 += VAR_10 / VAR_0->src_incr;
VAR_10 %= VAR_0->src_incr;
}else{
for(VAR_7=0; VAR_7 < VAR_5; VAR_7++){
FELEM *filter= VAR_0->filter_bank + VAR_0->filter_length*(VAR_9 & VAR_0->phase_mask);
int VAR_14= VAR_9 >> VAR_0->phase_shift;
FELEM2 val=0;
if(VAR_14 < 0){
for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++)
val += VAR_2[FFABS(VAR_14 + VAR_8) % VAR_4] * filter[VAR_8];
}else if(VAR_14 + VAR_0->filter_length > VAR_4){
break;
}else if(VAR_0->linear){
FELEM2 v2=0;
for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++){
val += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8];
v2 += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8 + VAR_0->filter_length];
}
val+=(v2-val)*(FELEML)VAR_10 / VAR_0->src_incr;
}else{
for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++){
val += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8];
}
}
#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
VAR_1[VAR_7] = av_clip_int16(lrintf(val));
#else
val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
VAR_1[VAR_7] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
#endif
VAR_10 += VAR_11;
VAR_9 += VAR_12;
if(VAR_10 >= VAR_0->src_incr){
VAR_10 -= VAR_0->src_incr;
VAR_9++;
}
if(VAR_7 + 1 == VAR_13){
VAR_13= 0;
VAR_11= VAR_0->ideal_dst_incr % VAR_0->src_incr;
VAR_12= VAR_0->ideal_dst_incr / VAR_0->src_incr;
}
}
}
*VAR_3= FFMAX(VAR_9, 0) >> VAR_0->phase_shift;
if(VAR_9>=0) VAR_9 &= VAR_0->phase_mask;
if(VAR_13){
VAR_13 -= VAR_7;
assert(VAR_13 > 0);
}
if(VAR_6){
VAR_0->VAR_10= VAR_10;
VAR_0->VAR_9= VAR_9;
VAR_0->VAR_12= VAR_11 + VAR_0->src_incr*VAR_12;
VAR_0->VAR_13= VAR_13;
}
#if 0
if(VAR_6 && !VAR_0->VAR_13){
#undef rand
av_resample_compensate(VAR_0, rand() % (8000*2) - 8000, 8000*2);
av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", VAR_0->VAR_12, VAR_0->ideal_dst_incr, VAR_0->VAR_13);
}
#endif
return VAR_7;
}
| [
"int FUNC_0(AVResampleContext *VAR_0, short *VAR_1, const short *VAR_2, int *VAR_3, int VAR_4, int VAR_5, int VAR_6){",
"int VAR_7, VAR_8;",
"int VAR_9= VAR_0->VAR_9;",
"int VAR_10= VAR_0->VAR_10;",
"int VAR_11= VAR_0->VAR_12 % VAR_0->src_incr;",
"int VAR_12= VAR_0->VAR_12 / VAR_0->src_incr;",
"int VAR_13= VAR_0->VAR_13;",
"if(VAR_13 == 0 && VAR_0->filter_length == 1 && VAR_0->phase_shift==0){",
"int64_t index2= ((int64_t)VAR_9)<<32;",
"int64_t incr= (1LL<<32) * VAR_0->VAR_12 / VAR_0->src_incr;",
"VAR_5= FFMIN(VAR_5, (VAR_4-1-VAR_9) * (int64_t)VAR_0->src_incr / VAR_0->VAR_12);",
"for(VAR_7=0; VAR_7 < VAR_5; VAR_7++){",
"VAR_1[VAR_7] = VAR_2[index2>>32];",
"index2 += incr;",
"}",
"VAR_10 += VAR_7 * VAR_11;",
"VAR_9 += VAR_7 * VAR_12;",
"VAR_9 += VAR_10 / VAR_0->src_incr;",
"VAR_10 %= VAR_0->src_incr;",
"}else{",
"for(VAR_7=0; VAR_7 < VAR_5; VAR_7++){",
"FELEM *filter= VAR_0->filter_bank + VAR_0->filter_length*(VAR_9 & VAR_0->phase_mask);",
"int VAR_14= VAR_9 >> VAR_0->phase_shift;",
"FELEM2 val=0;",
"if(VAR_14 < 0){",
"for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++)",
"val += VAR_2[FFABS(VAR_14 + VAR_8) % VAR_4] * filter[VAR_8];",
"}else if(VAR_14 + VAR_0->filter_length > VAR_4){",
"break;",
"}else if(VAR_0->linear){",
"FELEM2 v2=0;",
"for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++){",
"val += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8];",
"v2 += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8 + VAR_0->filter_length];",
"}",
"val+=(v2-val)*(FELEML)VAR_10 / VAR_0->src_incr;",
"}else{",
"for(VAR_8=0; VAR_8<VAR_0->filter_length; VAR_8++){",
"val += VAR_2[VAR_14 + VAR_8] * (FELEM2)filter[VAR_8];",
"}",
"}",
"#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE\nVAR_1[VAR_7] = av_clip_int16(lrintf(val));",
"#else\nval = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;",
"VAR_1[VAR_7] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;",
"#endif\nVAR_10 += VAR_11;",
"VAR_9 += VAR_12;",
"if(VAR_10 >= VAR_0->src_incr){",
"VAR_10 -= VAR_0->src_incr;",
"VAR_9++;",
"}",
"if(VAR_7 + 1 == VAR_13){",
"VAR_13= 0;",
"VAR_11= VAR_0->ideal_dst_incr % VAR_0->src_incr;",
"VAR_12= VAR_0->ideal_dst_incr / VAR_0->src_incr;",
"}",
"}",
"}",
"*VAR_3= FFMAX(VAR_9, 0) >> VAR_0->phase_shift;",
"if(VAR_9>=0) VAR_9 &= VAR_0->phase_mask;",
"if(VAR_13){",
"VAR_13 -= VAR_7;",
"assert(VAR_13 > 0);",
"}",
"if(VAR_6){",
"VAR_0->VAR_10= VAR_10;",
"VAR_0->VAR_9= VAR_9;",
"VAR_0->VAR_12= VAR_11 + VAR_0->src_incr*VAR_12;",
"VAR_0->VAR_13= VAR_13;",
"}",
"#if 0\nif(VAR_6 && !VAR_0->VAR_13){",
"#undef rand\nav_resample_compensate(VAR_0, rand() % (8000*2) - 8000, 8000*2);",
"av_log(NULL, AV_LOG_DEBUG, \"%d %d %d\\n\", VAR_0->VAR_12, VAR_0->ideal_dst_incr, VAR_0->VAR_13);",
"}",
"#endif\nreturn VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163,
165
],
[
167
],
[
169
],
[
171,
175
],
[
177
]
]
|
15,202 | static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
{
STM32F205State *s = STM32F205_SOC(dev_soc);
DeviceState *syscfgdev, *usartdev, *timerdev;
SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
qemu_irq *pic;
Error *err = NULL;
int i;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
memory_region_init_ram(flash, NULL, "STM32F205.flash", FLASH_SIZE,
&error_abort);
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
flash, 0, FLASH_SIZE);
vmstate_register_ram_global(flash);
memory_region_set_readonly(flash, true);
memory_region_set_readonly(flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
memory_region_add_subregion(system_memory, 0, flash_alias);
memory_region_init_ram(sram, NULL, "STM32F205.sram", SRAM_SIZE,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
pic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,
s->kernel_filename, s->cpu_model);
/* System configuration controller */
syscfgdev = DEVICE(&s->syscfg);
object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
syscfgbusdev = SYS_BUS_DEVICE(syscfgdev);
sysbus_mmio_map(syscfgbusdev, 0, 0x40013800);
sysbus_connect_irq(syscfgbusdev, 0, pic[71]);
/* Attach UART (uses USART registers) and USART controllers */
for (i = 0; i < STM_NUM_USARTS; i++) {
usartdev = DEVICE(&(s->usart[i]));
object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
usartbusdev = SYS_BUS_DEVICE(usartdev);
sysbus_mmio_map(usartbusdev, 0, usart_addr[i]);
sysbus_connect_irq(usartbusdev, 0, pic[usart_irq[i]]);
}
/* Timer 2 to 5 */
for (i = 0; i < STM_NUM_TIMERS; i++) {
timerdev = DEVICE(&(s->timer[i]));
qdev_prop_set_uint64(timerdev, "clock-frequency", 1000000000);
object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
timerbusdev = SYS_BUS_DEVICE(timerdev);
sysbus_mmio_map(timerbusdev, 0, timer_addr[i]);
sysbus_connect_irq(timerbusdev, 0, pic[timer_irq[i]]);
}
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
{
STM32F205State *s = STM32F205_SOC(dev_soc);
DeviceState *syscfgdev, *usartdev, *timerdev;
SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
qemu_irq *pic;
Error *err = NULL;
int i;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
memory_region_init_ram(flash, NULL, "STM32F205.flash", FLASH_SIZE,
&error_abort);
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
flash, 0, FLASH_SIZE);
vmstate_register_ram_global(flash);
memory_region_set_readonly(flash, true);
memory_region_set_readonly(flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
memory_region_add_subregion(system_memory, 0, flash_alias);
memory_region_init_ram(sram, NULL, "STM32F205.sram", SRAM_SIZE,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
pic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,
s->kernel_filename, s->cpu_model);
syscfgdev = DEVICE(&s->syscfg);
object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
syscfgbusdev = SYS_BUS_DEVICE(syscfgdev);
sysbus_mmio_map(syscfgbusdev, 0, 0x40013800);
sysbus_connect_irq(syscfgbusdev, 0, pic[71]);
for (i = 0; i < STM_NUM_USARTS; i++) {
usartdev = DEVICE(&(s->usart[i]));
object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
usartbusdev = SYS_BUS_DEVICE(usartdev);
sysbus_mmio_map(usartbusdev, 0, usart_addr[i]);
sysbus_connect_irq(usartbusdev, 0, pic[usart_irq[i]]);
}
for (i = 0; i < STM_NUM_TIMERS; i++) {
timerdev = DEVICE(&(s->timer[i]));
qdev_prop_set_uint64(timerdev, "clock-frequency", 1000000000);
object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
timerbusdev = SYS_BUS_DEVICE(timerdev);
sysbus_mmio_map(timerbusdev, 0, timer_addr[i]);
sysbus_connect_irq(timerbusdev, 0, pic[timer_irq[i]]);
}
}
| {
"code": [
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);"
],
"line_no": [
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
STM32F205State *s = STM32F205_SOC(VAR_0);
DeviceState *syscfgdev, *usartdev, *timerdev;
SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
qemu_irq *pic;
Error *err = NULL;
int VAR_2;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
memory_region_init_ram(flash, NULL, "STM32F205.flash", FLASH_SIZE,
&error_abort);
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
flash, 0, FLASH_SIZE);
vmstate_register_ram_global(flash);
memory_region_set_readonly(flash, true);
memory_region_set_readonly(flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
memory_region_add_subregion(system_memory, 0, flash_alias);
memory_region_init_ram(sram, NULL, "STM32F205.sram", SRAM_SIZE,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
pic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,
s->kernel_filename, s->cpu_model);
syscfgdev = DEVICE(&s->syscfg);
object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
syscfgbusdev = SYS_BUS_DEVICE(syscfgdev);
sysbus_mmio_map(syscfgbusdev, 0, 0x40013800);
sysbus_connect_irq(syscfgbusdev, 0, pic[71]);
for (VAR_2 = 0; VAR_2 < STM_NUM_USARTS; VAR_2++) {
usartdev = DEVICE(&(s->usart[VAR_2]));
object_property_set_bool(OBJECT(&s->usart[VAR_2]), true, "realized", &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
usartbusdev = SYS_BUS_DEVICE(usartdev);
sysbus_mmio_map(usartbusdev, 0, usart_addr[VAR_2]);
sysbus_connect_irq(usartbusdev, 0, pic[usart_irq[VAR_2]]);
}
for (VAR_2 = 0; VAR_2 < STM_NUM_TIMERS; VAR_2++) {
timerdev = DEVICE(&(s->timer[VAR_2]));
qdev_prop_set_uint64(timerdev, "clock-frequency", 1000000000);
object_property_set_bool(OBJECT(&s->timer[VAR_2]), true, "realized", &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
timerbusdev = SYS_BUS_DEVICE(timerdev);
sysbus_mmio_map(timerbusdev, 0, timer_addr[VAR_2]);
sysbus_connect_irq(timerbusdev, 0, pic[timer_irq[VAR_2]]);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"STM32F205State *s = STM32F205_SOC(VAR_0);",
"DeviceState *syscfgdev, *usartdev, *timerdev;",
"SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;",
"qemu_irq *pic;",
"Error *err = NULL;",
"int VAR_2;",
"MemoryRegion *system_memory = get_system_memory();",
"MemoryRegion *sram = g_new(MemoryRegion, 1);",
"MemoryRegion *flash = g_new(MemoryRegion, 1);",
"MemoryRegion *flash_alias = g_new(MemoryRegion, 1);",
"memory_region_init_ram(flash, NULL, \"STM32F205.flash\", FLASH_SIZE,\n&error_abort);",
"memory_region_init_alias(flash_alias, NULL, \"STM32F205.flash.alias\",\nflash, 0, FLASH_SIZE);",
"vmstate_register_ram_global(flash);",
"memory_region_set_readonly(flash, true);",
"memory_region_set_readonly(flash_alias, true);",
"memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);",
"memory_region_add_subregion(system_memory, 0, flash_alias);",
"memory_region_init_ram(sram, NULL, \"STM32F205.sram\", SRAM_SIZE,\n&error_abort);",
"vmstate_register_ram_global(sram);",
"memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);",
"pic = armv7m_init(get_system_memory(), FLASH_SIZE, 96,\ns->kernel_filename, s->cpu_model);",
"syscfgdev = DEVICE(&s->syscfg);",
"object_property_set_bool(OBJECT(&s->syscfg), true, \"realized\", &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"syscfgbusdev = SYS_BUS_DEVICE(syscfgdev);",
"sysbus_mmio_map(syscfgbusdev, 0, 0x40013800);",
"sysbus_connect_irq(syscfgbusdev, 0, pic[71]);",
"for (VAR_2 = 0; VAR_2 < STM_NUM_USARTS; VAR_2++) {",
"usartdev = DEVICE(&(s->usart[VAR_2]));",
"object_property_set_bool(OBJECT(&s->usart[VAR_2]), true, \"realized\", &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"usartbusdev = SYS_BUS_DEVICE(usartdev);",
"sysbus_mmio_map(usartbusdev, 0, usart_addr[VAR_2]);",
"sysbus_connect_irq(usartbusdev, 0, pic[usart_irq[VAR_2]]);",
"}",
"for (VAR_2 = 0; VAR_2 < STM_NUM_TIMERS; VAR_2++) {",
"timerdev = DEVICE(&(s->timer[VAR_2]));",
"qdev_prop_set_uint64(timerdev, \"clock-frequency\", 1000000000);",
"object_property_set_bool(OBJECT(&s->timer[VAR_2]), true, \"realized\", &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"timerbusdev = SYS_BUS_DEVICE(timerdev);",
"sysbus_mmio_map(timerbusdev, 0, timer_addr[VAR_2]);",
"sysbus_connect_irq(timerbusdev, 0, pic[timer_irq[VAR_2]]);",
"}",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33,
35
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
65,
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
]
]
|
15,203 | static int cmp_int(const void *p1, const void *p2)
{
int left = *(const int *)p1;
int right = *(const int *)p2;
return ((left > right) - (left < right));
}
| true | FFmpeg | 92e483f8ed70d88d4f64337f65bae212502735d4 | static int cmp_int(const void *p1, const void *p2)
{
int left = *(const int *)p1;
int right = *(const int *)p2;
return ((left > right) - (left < right));
}
| {
"code": [
" int left = *(const int *)p1;",
" return ((left > right) - (left < right));"
],
"line_no": [
5,
11
]
} | static int FUNC_0(const void *VAR_0, const void *VAR_1)
{
int VAR_2 = *(const int *)VAR_0;
int VAR_3 = *(const int *)VAR_1;
return ((VAR_2 > VAR_3) - (VAR_2 < VAR_3));
}
| [
"static int FUNC_0(const void *VAR_0, const void *VAR_1)\n{",
"int VAR_2 = *(const int *)VAR_0;",
"int VAR_3 = *(const int *)VAR_1;",
"return ((VAR_2 > VAR_3) - (VAR_2 < VAR_3));",
"}"
]
| [
0,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
]
]
|
15,205 | static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
const CodecMime *mime = ff_id3v2_mime_tags;
enum CodecID id = CODEC_ID_NONE;
uint8_t mimetype[64], *desc = NULL, *data = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int type, width, height;
int len, ret = 0;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
/* read the picture type */
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
ret = AVERROR_INVALIDDATA;
goto fail;
}
/* picture mimetype */
len = avio_rb32(pb);
if (len <= 0 ||
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
while (mime->id != CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
ret = AVERROR_INVALIDDATA;
goto fail;
}
/* picture description */
len = avio_rb32(pb);
if (len > 0) {
if (!(desc = av_malloc(len + 1))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
}
/* picture metadata */
width = avio_rb32(pb);
height = avio_rb32(pb);
avio_skip(pb, 8);
/* picture data */
len = avio_rb32(pb);
if (len <= 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_malloc(len))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.data = data;
st->attached_pic.size = len;
st->attached_pic.destruct = av_destruct_packet;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_freep(&desc);
av_freep(&data);
av_freep(&pb);
return ret;
}
| true | FFmpeg | dba5b06ead6bbec8fd1207d778240188182c8361 | static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
const CodecMime *mime = ff_id3v2_mime_tags;
enum CodecID id = CODEC_ID_NONE;
uint8_t mimetype[64], *desc = NULL, *data = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int type, width, height;
int len, ret = 0;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
ret = AVERROR_INVALIDDATA;
goto fail;
}
len = avio_rb32(pb);
if (len <= 0 ||
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
while (mime->id != CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
ret = AVERROR_INVALIDDATA;
goto fail;
}
len = avio_rb32(pb);
if (len > 0) {
if (!(desc = av_malloc(len + 1))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
}
width = avio_rb32(pb);
height = avio_rb32(pb);
avio_skip(pb, 8);
len = avio_rb32(pb);
if (len <= 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_malloc(len))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.data = data;
st->attached_pic.size = len;
st->attached_pic.destruct = av_destruct_packet;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_freep(&desc);
av_freep(&data);
av_freep(&pb);
return ret;
}
| {
"code": [
" st = avformat_new_stream(s, NULL);",
" if (!st)",
" return AVERROR(ENOMEM);"
],
"line_no": [
21,
23,
25
]
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
const CodecMime *VAR_3 = ff_id3v2_mime_tags;
enum CodecID VAR_4 = CODEC_ID_NONE;
uint8_t mimetype[64], *desc = NULL, *data = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int VAR_5, VAR_6, VAR_7;
int VAR_8, VAR_9 = 0;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
pb = avio_alloc_context(VAR_1, VAR_2, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
VAR_5 = avio_rb32(pb);
if (VAR_5 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || VAR_5 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid picture VAR_5: %d.\n", VAR_5);
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
VAR_8 = avio_rb32(pb);
if (VAR_8 <= 0 ||
avio_read(pb, mimetype, FFMIN(VAR_8, sizeof(mimetype) - 1)) != VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[VAR_8] = 0;
while (VAR_3->VAR_4 != CODEC_ID_NONE) {
if (!strncmp(VAR_3->str, mimetype, sizeof(mimetype))) {
VAR_4 = VAR_3->VAR_4;
break;
}
VAR_3++;
}
if (VAR_4 == CODEC_ID_NONE) {
av_log(VAR_0, AV_LOG_ERROR, "Unknown attached picture mimetype: %VAR_0.\n",
mimetype);
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
VAR_8 = avio_rb32(pb);
if (VAR_8 > 0) {
if (!(desc = av_malloc(VAR_8 + 1))) {
VAR_9 = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, VAR_8) != VAR_8) {
VAR_9 = AVERROR(EIO);
goto fail;
}
desc[VAR_8] = 0;
}
VAR_6 = avio_rb32(pb);
VAR_7 = avio_rb32(pb);
avio_skip(pb, 8);
VAR_8 = avio_rb32(pb);
if (VAR_8 <= 0) {
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_malloc(VAR_8))) {
VAR_9 = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data, VAR_8) != VAR_8) {
VAR_9 = AVERROR(EIO);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.data = data;
st->attached_pic.size = VAR_8;
st->attached_pic.destruct = av_destruct_packet;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = VAR_4;
st->codec->VAR_6 = VAR_6;
st->codec->VAR_7 = VAR_7;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[VAR_5], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_freep(&desc);
av_freep(&data);
av_freep(&pb);
return VAR_9;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"const CodecMime *VAR_3 = ff_id3v2_mime_tags;",
"enum CodecID VAR_4 = CODEC_ID_NONE;",
"uint8_t mimetype[64], *desc = NULL, *data = NULL;",
"AVIOContext *pb = NULL;",
"AVStream *st;",
"int VAR_5, VAR_6, VAR_7;",
"int VAR_8, VAR_9 = 0;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"pb = avio_alloc_context(VAR_1, VAR_2, 0, NULL, NULL, NULL, NULL);",
"if (!pb)\nreturn AVERROR(ENOMEM);",
"VAR_5 = avio_rb32(pb);",
"if (VAR_5 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || VAR_5 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid picture VAR_5: %d.\\n\", VAR_5);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 <= 0 ||\navio_read(pb, mimetype, FFMIN(VAR_8, sizeof(mimetype) - 1)) != VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not read mimetype from an attached \"\n\"picture.\\n\");",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"mimetype[VAR_8] = 0;",
"while (VAR_3->VAR_4 != CODEC_ID_NONE) {",
"if (!strncmp(VAR_3->str, mimetype, sizeof(mimetype))) {",
"VAR_4 = VAR_3->VAR_4;",
"break;",
"}",
"VAR_3++;",
"}",
"if (VAR_4 == CODEC_ID_NONE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown attached picture mimetype: %VAR_0.\\n\",\nmimetype);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 > 0) {",
"if (!(desc = av_malloc(VAR_8 + 1))) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (avio_read(pb, desc, VAR_8) != VAR_8) {",
"VAR_9 = AVERROR(EIO);",
"goto fail;",
"}",
"desc[VAR_8] = 0;",
"}",
"VAR_6 = avio_rb32(pb);",
"VAR_7 = avio_rb32(pb);",
"avio_skip(pb, 8);",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 <= 0) {",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (!(data = av_malloc(VAR_8))) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (avio_read(pb, data, VAR_8) != VAR_8) {",
"VAR_9 = AVERROR(EIO);",
"goto fail;",
"}",
"av_init_packet(&st->attached_pic);",
"st->attached_pic.data = data;",
"st->attached_pic.size = VAR_8;",
"st->attached_pic.destruct = av_destruct_packet;",
"st->attached_pic.stream_index = st->index;",
"st->attached_pic.flags |= AV_PKT_FLAG_KEY;",
"st->disposition |= AV_DISPOSITION_ATTACHED_PIC;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = VAR_4;",
"st->codec->VAR_6 = VAR_6;",
"st->codec->VAR_7 = VAR_7;",
"av_dict_set(&st->metadata, \"comment\", ff_id3v2_picture_types[VAR_5], 0);",
"if (desc)\nav_dict_set(&st->metadata, \"title\", desc, AV_DICT_DONT_STRDUP_VAL);",
"av_freep(&pb);",
"return 0;",
"fail:\nav_freep(&desc);",
"av_freep(&data);",
"av_freep(&pb);",
"return VAR_9;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
31,
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
205
],
[
209
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
225
]
]
|
15,207 | void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, Error **errp)
{
error_setg(errp, "AioContext polling is not implemented on Windows");
}
| true | qemu | 82a41186941c419afde977f477f19c545b40c1c5 | void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, Error **errp)
{
error_setg(errp, "AioContext polling is not implemented on Windows");
}
| {
"code": [
"void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, Error **errp)",
"void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, Error **errp)"
],
"line_no": [
1,
1
]
} | void FUNC_0(AioContext *VAR_0, int64_t VAR_1, Error **VAR_2)
{
error_setg(VAR_2, "AioContext polling is not implemented on Windows");
}
| [
"void FUNC_0(AioContext *VAR_0, int64_t VAR_1, Error **VAR_2)\n{",
"error_setg(VAR_2, \"AioContext polling is not implemented on Windows\");",
"}"
]
| [
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
15,208 | static void host_memory_backend_set_prealloc(Object *obj, bool value,
Error **errp)
{
Error *local_err = NULL;
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
if (backend->force_prealloc) {
if (value) {
error_setg(errp,
"remove -mem-prealloc to use the prealloc property");
return;
}
}
if (!memory_region_size(&backend->mr)) {
backend->prealloc = value;
return;
}
if (value && !backend->prealloc) {
int fd = memory_region_get_fd(&backend->mr);
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
os_mem_prealloc(fd, ptr, sz, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
backend->prealloc = true;
}
}
| true | qemu | 1e356fc14beaa3ece6c0e961bd479af58be3198b | static void host_memory_backend_set_prealloc(Object *obj, bool value,
Error **errp)
{
Error *local_err = NULL;
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
if (backend->force_prealloc) {
if (value) {
error_setg(errp,
"remove -mem-prealloc to use the prealloc property");
return;
}
}
if (!memory_region_size(&backend->mr)) {
backend->prealloc = value;
return;
}
if (value && !backend->prealloc) {
int fd = memory_region_get_fd(&backend->mr);
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
os_mem_prealloc(fd, ptr, sz, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
backend->prealloc = true;
}
}
| {
"code": [
" os_mem_prealloc(fd, ptr, sz, &local_err);"
],
"line_no": [
49
]
} | static void FUNC_0(Object *VAR_0, bool VAR_1,
Error **VAR_2)
{
Error *local_err = NULL;
HostMemoryBackend *backend = MEMORY_BACKEND(VAR_0);
if (backend->force_prealloc) {
if (VAR_1) {
error_setg(VAR_2,
"remove -mem-prealloc to use the prealloc property");
return;
}
}
if (!memory_region_size(&backend->mr)) {
backend->prealloc = VAR_1;
return;
}
if (VAR_1 && !backend->prealloc) {
int VAR_3 = memory_region_get_fd(&backend->mr);
void *VAR_4 = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
os_mem_prealloc(VAR_3, VAR_4, sz, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
return;
}
backend->prealloc = true;
}
}
| [
"static void FUNC_0(Object *VAR_0, bool VAR_1,\nError **VAR_2)\n{",
"Error *local_err = NULL;",
"HostMemoryBackend *backend = MEMORY_BACKEND(VAR_0);",
"if (backend->force_prealloc) {",
"if (VAR_1) {",
"error_setg(VAR_2,\n\"remove -mem-prealloc to use the prealloc property\");",
"return;",
"}",
"}",
"if (!memory_region_size(&backend->mr)) {",
"backend->prealloc = VAR_1;",
"return;",
"}",
"if (VAR_1 && !backend->prealloc) {",
"int VAR_3 = memory_region_get_fd(&backend->mr);",
"void *VAR_4 = memory_region_get_ram_ptr(&backend->mr);",
"uint64_t sz = memory_region_size(&backend->mr);",
"os_mem_prealloc(VAR_3, VAR_4, sz, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"return;",
"}",
"backend->prealloc = true;",
"}",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
]
|
15,210 | void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
AVPacketList **next_point, *this_pktl;
this_pktl = av_mallocz(sizeof(AVPacketList));
this_pktl->pkt= *pkt;
pkt->destruct= NULL; // do not free original but only the copy
av_dup_packet(&this_pktl->pkt); // duplicate the packet if it uses non-alloced memory
if(s->streams[pkt->stream_index]->last_in_packet_buffer){
next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
}else
next_point = &s->packet_buffer;
if(*next_point){
if(compare(s, &s->packet_buffer_end->pkt, pkt)){
while(!compare(s, &(*next_point)->pkt, pkt)){
next_point= &(*next_point)->next;
}
goto next_non_null;
}else{
next_point = &(s->packet_buffer_end->next);
}
}
assert(!*next_point);
s->packet_buffer_end= this_pktl;
next_non_null:
this_pktl->next= *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer=
*next_point= this_pktl;
}
| true | FFmpeg | 4d7c71c36467331f1e0c0f17af9f371d33308a9c | void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
AVPacketList **next_point, *this_pktl;
this_pktl = av_mallocz(sizeof(AVPacketList));
this_pktl->pkt= *pkt;
pkt->destruct= NULL;
av_dup_packet(&this_pktl->pkt);
if(s->streams[pkt->stream_index]->last_in_packet_buffer){
next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
}else
next_point = &s->packet_buffer;
if(*next_point){
if(compare(s, &s->packet_buffer_end->pkt, pkt)){
while(!compare(s, &(*next_point)->pkt, pkt)){
next_point= &(*next_point)->next;
}
goto next_non_null;
}else{
next_point = &(s->packet_buffer_end->next);
}
}
assert(!*next_point);
s->packet_buffer_end= this_pktl;
next_non_null:
this_pktl->next= *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer=
*next_point= this_pktl;
}
| {
"code": [
"void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,",
"void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,"
],
"line_no": [
1,
1
]
} | VAR_4voidVAR_4 VAR_4ff_interleave_add_packetVAR_4(VAR_4AVFormatContextVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVPacketVAR_4 *VAR_4VAR_1VAR_4,
VAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFormatContextVAR_4 *, VAR_4AVPacketVAR_4 *, VAR_4AVPacketVAR_4 *))
{
VAR_4AVPacketListVAR_4 **VAR_4next_pointVAR_4, *VAR_4this_pktlVAR_4;
VAR_4this_pktlVAR_4 = VAR_4av_malloczVAR_4(VAR_4sizeofVAR_4(VAR_4AVPacketListVAR_4));
VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4= *VAR_4VAR_1VAR_4;
VAR_4VAR_1VAR_4->VAR_4destructVAR_4= VAR_4NULLVAR_4;
VAR_4av_dup_packetVAR_4(&VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4);
VAR_4ifVAR_4(VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4){
VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4->VAR_4nextVAR_4);
}VAR_4elseVAR_4
VAR_4next_pointVAR_4 = &VAR_4VAR_0VAR_4->VAR_4packet_bufferVAR_4;
VAR_4ifVAR_4(*VAR_4next_pointVAR_4){
VAR_4ifVAR_4(VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)){
VAR_4whileVAR_4(!VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &(*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)){
VAR_4next_pointVAR_4= &(*VAR_4next_pointVAR_4)->VAR_4nextVAR_4;
}
VAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;
}VAR_4elseVAR_4{
VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4->VAR_4nextVAR_4);
}
}
VAR_4assertVAR_4(!*VAR_4next_pointVAR_4);
VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4= VAR_4this_pktlVAR_4;
VAR_4next_non_nullVAR_4:
VAR_4this_pktlVAR_4->VAR_4nextVAR_4= *VAR_4next_pointVAR_4;
VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4=
*VAR_4next_pointVAR_4= VAR_4this_pktlVAR_4;
}
| [
"VAR_4voidVAR_4 VAR_4ff_interleave_add_packetVAR_4(VAR_4AVFormatContextVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVPacketVAR_4 *VAR_4VAR_1VAR_4,\nVAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFormatContextVAR_4 *, VAR_4AVPacketVAR_4 *, VAR_4AVPacketVAR_4 *))\n{",
"VAR_4AVPacketListVAR_4 **VAR_4next_pointVAR_4, *VAR_4this_pktlVAR_4;",
"VAR_4this_pktlVAR_4 = VAR_4av_malloczVAR_4(VAR_4sizeofVAR_4(VAR_4AVPacketListVAR_4));",
"VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4= *VAR_4VAR_1VAR_4;",
"VAR_4VAR_1VAR_4->VAR_4destructVAR_4= VAR_4NULLVAR_4;",
"VAR_4av_dup_packetVAR_4(&VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4);",
"VAR_4ifVAR_4(VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4){",
"VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4->VAR_4nextVAR_4);",
"}VAR_4elseVAR_4",
"VAR_4next_pointVAR_4 = &VAR_4VAR_0VAR_4->VAR_4packet_bufferVAR_4;",
"VAR_4ifVAR_4(*VAR_4next_pointVAR_4){",
"VAR_4ifVAR_4(VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)){",
"VAR_4whileVAR_4(!VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &(*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)){",
"VAR_4next_pointVAR_4= &(*VAR_4next_pointVAR_4)->VAR_4nextVAR_4;",
"}",
"VAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;",
"}VAR_4elseVAR_4{",
"VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4->VAR_4nextVAR_4);",
"}",
"}",
"VAR_4assertVAR_4(!*VAR_4next_pointVAR_4);",
"VAR_4VAR_0VAR_4->VAR_4packet_buffer_endVAR_4= VAR_4this_pktlVAR_4;",
"VAR_4next_non_nullVAR_4:\nVAR_4this_pktlVAR_4->VAR_4nextVAR_4= *VAR_4next_pointVAR_4;",
"VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4=\n*VAR_4next_pointVAR_4= VAR_4this_pktlVAR_4;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
61
],
[
65,
67
],
[
69
]
]
|
15,211 | static void read_partition(uint8_t *p, struct partition_record *r)
{
r->bootable = p[0];
r->start_head = p[1];
r->start_cylinder = p[3] | ((p[2] << 2) & 0x0300);
r->start_sector = p[2] & 0x3f;
r->system = p[4];
r->end_head = p[5];
r->end_cylinder = p[7] | ((p[6] << 2) & 0x300);
r->end_sector = p[6] & 0x3f;
r->start_sector_abs = p[8] | p[9] << 8 | p[10] << 16 | p[11] << 24;
r->nb_sectors_abs = p[12] | p[13] << 8 | p[14] << 16 | p[15] << 24;
}
| true | qemu | ac97393dc7c4761af6104fb8fca5f600899f687b | static void read_partition(uint8_t *p, struct partition_record *r)
{
r->bootable = p[0];
r->start_head = p[1];
r->start_cylinder = p[3] | ((p[2] << 2) & 0x0300);
r->start_sector = p[2] & 0x3f;
r->system = p[4];
r->end_head = p[5];
r->end_cylinder = p[7] | ((p[6] << 2) & 0x300);
r->end_sector = p[6] & 0x3f;
r->start_sector_abs = p[8] | p[9] << 8 | p[10] << 16 | p[11] << 24;
r->nb_sectors_abs = p[12] | p[13] << 8 | p[14] << 16 | p[15] << 24;
}
| {
"code": [
" r->start_sector_abs = p[8] | p[9] << 8 | p[10] << 16 | p[11] << 24;",
" r->nb_sectors_abs = p[12] | p[13] << 8 | p[14] << 16 | p[15] << 24;"
],
"line_no": [
21,
23
]
} | static void FUNC_0(uint8_t *VAR_0, struct partition_record *VAR_1)
{
VAR_1->bootable = VAR_0[0];
VAR_1->start_head = VAR_0[1];
VAR_1->start_cylinder = VAR_0[3] | ((VAR_0[2] << 2) & 0x0300);
VAR_1->start_sector = VAR_0[2] & 0x3f;
VAR_1->system = VAR_0[4];
VAR_1->end_head = VAR_0[5];
VAR_1->end_cylinder = VAR_0[7] | ((VAR_0[6] << 2) & 0x300);
VAR_1->end_sector = VAR_0[6] & 0x3f;
VAR_1->start_sector_abs = VAR_0[8] | VAR_0[9] << 8 | VAR_0[10] << 16 | VAR_0[11] << 24;
VAR_1->nb_sectors_abs = VAR_0[12] | VAR_0[13] << 8 | VAR_0[14] << 16 | VAR_0[15] << 24;
}
| [
"static void FUNC_0(uint8_t *VAR_0, struct partition_record *VAR_1)\n{",
"VAR_1->bootable = VAR_0[0];",
"VAR_1->start_head = VAR_0[1];",
"VAR_1->start_cylinder = VAR_0[3] | ((VAR_0[2] << 2) & 0x0300);",
"VAR_1->start_sector = VAR_0[2] & 0x3f;",
"VAR_1->system = VAR_0[4];",
"VAR_1->end_head = VAR_0[5];",
"VAR_1->end_cylinder = VAR_0[7] | ((VAR_0[6] << 2) & 0x300);",
"VAR_1->end_sector = VAR_0[6] & 0x3f;",
"VAR_1->start_sector_abs = VAR_0[8] | VAR_0[9] << 8 | VAR_0[10] << 16 | VAR_0[11] << 24;",
"VAR_1->nb_sectors_abs = VAR_0[12] | VAR_0[13] << 8 | VAR_0[14] << 16 | VAR_0[15] << 24;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
15,212 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
DxaDecContext * const c = avctx->priv_data;
uint8_t *outptr, *srcptr, *tmpptr;
unsigned long dsize;
int i, j, compr, ret;
int stride;
int pc = 0;
GetByteContext gb;
bytestream2_init(&gb, avpkt->data, avpkt->size);
/* make the palette available on the way out */
if (bytestream2_peek_le32(&gb) == MKTAG('C','M','A','P')) {
bytestream2_skip(&gb, 4);
for(i = 0; i < 256; i++){
c->pal[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
pc = 1;
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
memcpy(frame->data[1], c->pal, AVPALETTE_SIZE);
frame->palette_has_changed = pc;
outptr = frame->data[0];
srcptr = c->decomp_buf;
tmpptr = c->prev->data[0];
stride = frame->linesize[0];
if (bytestream2_get_le32(&gb) == MKTAG('N','U','L','L'))
compr = -1;
else
compr = bytestream2_get_byte(&gb);
dsize = c->dsize;
if (compr != 4 && compr != -1) {
bytestream2_skip(&gb, 4);
if (uncompress(c->decomp_buf, &dsize, avpkt->data + bytestream2_tell(&gb),
bytestream2_get_bytes_left(&gb)) != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_UNKNOWN;
}
memset(c->decomp_buf + dsize, 0, DECOMP_BUF_PADDING);
}
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "compr:%2d, dsize:%d\n", compr, (int)dsize);
switch(compr){
case -1:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->prev->data[0])
memcpy(frame->data[0], c->prev->data[0], frame->linesize[0] * avctx->height);
else{ // Should happen only when first frame is 'NULL'
memset(frame->data[0], 0, frame->linesize[0] * avctx->height);
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
}
break;
case 2:
case 4:
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
for (j = 0; j < avctx->height; j++) {
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 3:
case 5:
if (!tmpptr) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
if (!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL))
return AVERROR_INVALIDDATA;
}
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
for (j = 0; j < avctx->height; j++) {
if(tmpptr){
for(i = 0; i < avctx->width; i++)
outptr[i] = srcptr[i] ^ tmpptr[i];
tmpptr += stride;
}else
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 12: // ScummVM coding
case 13:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (!c->prev->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame\n");
return AVERROR_INVALIDDATA;
}
decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
av_frame_unref(c->prev);
if ((ret = av_frame_ref(c->prev, frame)) < 0)
return ret;
*got_frame = 1;
/* always report that the buffer was completely consumed */
return avpkt->size;
}
| true | FFmpeg | 5a5c1b244281c3edcffca322b0c664ed620b1e24 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
DxaDecContext * const c = avctx->priv_data;
uint8_t *outptr, *srcptr, *tmpptr;
unsigned long dsize;
int i, j, compr, ret;
int stride;
int pc = 0;
GetByteContext gb;
bytestream2_init(&gb, avpkt->data, avpkt->size);
if (bytestream2_peek_le32(&gb) == MKTAG('C','M','A','P')) {
bytestream2_skip(&gb, 4);
for(i = 0; i < 256; i++){
c->pal[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
pc = 1;
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
memcpy(frame->data[1], c->pal, AVPALETTE_SIZE);
frame->palette_has_changed = pc;
outptr = frame->data[0];
srcptr = c->decomp_buf;
tmpptr = c->prev->data[0];
stride = frame->linesize[0];
if (bytestream2_get_le32(&gb) == MKTAG('N','U','L','L'))
compr = -1;
else
compr = bytestream2_get_byte(&gb);
dsize = c->dsize;
if (compr != 4 && compr != -1) {
bytestream2_skip(&gb, 4);
if (uncompress(c->decomp_buf, &dsize, avpkt->data + bytestream2_tell(&gb),
bytestream2_get_bytes_left(&gb)) != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_UNKNOWN;
}
memset(c->decomp_buf + dsize, 0, DECOMP_BUF_PADDING);
}
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "compr:%2d, dsize:%d\n", compr, (int)dsize);
switch(compr){
case -1:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->prev->data[0])
memcpy(frame->data[0], c->prev->data[0], frame->linesize[0] * avctx->height);
else{
memset(frame->data[0], 0, frame->linesize[0] * avctx->height);
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
}
break;
case 2:
case 4:
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
for (j = 0; j < avctx->height; j++) {
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 3:
case 5:
if (!tmpptr) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
if (!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL))
return AVERROR_INVALIDDATA;
}
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
for (j = 0; j < avctx->height; j++) {
if(tmpptr){
for(i = 0; i < avctx->width; i++)
outptr[i] = srcptr[i] ^ tmpptr[i];
tmpptr += stride;
}else
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 12:
case 13:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (!c->prev->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame\n");
return AVERROR_INVALIDDATA;
}
decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
av_frame_unref(c->prev);
if ((ret = av_frame_ref(c->prev, frame)) < 0)
return ret;
*got_frame = 1;
return avpkt->size;
}
| {
"code": [
" decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);"
],
"line_no": [
203
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
DxaDecContext * const c = VAR_0->priv_data;
uint8_t *outptr, *srcptr, *tmpptr;
unsigned long VAR_4;
int VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9;
int VAR_10 = 0;
GetByteContext gb;
bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);
if (bytestream2_peek_le32(&gb) == MKTAG('C','M','A','P')) {
bytestream2_skip(&gb, 4);
for(VAR_5 = 0; VAR_5 < 256; VAR_5++){
c->pal[VAR_5] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
VAR_10 = 1;
}
if ((VAR_8 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return VAR_8;
memcpy(frame->VAR_1[1], c->pal, AVPALETTE_SIZE);
frame->palette_has_changed = VAR_10;
outptr = frame->VAR_1[0];
srcptr = c->decomp_buf;
tmpptr = c->prev->VAR_1[0];
VAR_9 = frame->linesize[0];
if (bytestream2_get_le32(&gb) == MKTAG('N','U','L','L'))
VAR_7 = -1;
else
VAR_7 = bytestream2_get_byte(&gb);
VAR_4 = c->VAR_4;
if (VAR_7 != 4 && VAR_7 != -1) {
bytestream2_skip(&gb, 4);
if (uncompress(c->decomp_buf, &VAR_4, VAR_3->VAR_1 + bytestream2_tell(&gb),
bytestream2_get_bytes_left(&gb)) != Z_OK) {
av_log(VAR_0, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_UNKNOWN;
}
memset(c->decomp_buf + VAR_4, 0, DECOMP_BUF_PADDING);
}
if (VAR_0->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0, AV_LOG_DEBUG, "VAR_7:%2d, VAR_4:%d\n", VAR_7, (int)VAR_4);
switch(VAR_7){
case -1:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->prev->VAR_1[0])
memcpy(frame->VAR_1[0], c->prev->VAR_1[0], frame->linesize[0] * VAR_0->height);
else{
memset(frame->VAR_1[0], 0, frame->linesize[0] * VAR_0->height);
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
}
break;
case 2:
case 4:
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {
memcpy(outptr, srcptr, VAR_0->width);
outptr += VAR_9;
srcptr += VAR_0->width;
}
break;
case 3:
case 5:
if (!tmpptr) {
av_log(VAR_0, AV_LOG_ERROR, "Missing reference frame.\n");
if (!(VAR_0->flags2 & CODEC_FLAG2_SHOW_ALL))
return AVERROR_INVALIDDATA;
}
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {
if(tmpptr){
for(VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++)
outptr[VAR_5] = srcptr[VAR_5] ^ tmpptr[VAR_5];
tmpptr += VAR_9;
}else
memcpy(outptr, srcptr, VAR_0->width);
outptr += VAR_9;
srcptr += VAR_0->width;
}
break;
case 12:
case 13:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (!c->prev->VAR_1[0]) {
av_log(VAR_0, AV_LOG_ERROR, "Missing reference frame\n");
return AVERROR_INVALIDDATA;
}
decode_13(VAR_0, c, frame->VAR_1[0], frame->linesize[0], srcptr, c->prev->VAR_1[0]);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", VAR_7);
return AVERROR_INVALIDDATA;
}
av_frame_unref(c->prev);
if ((VAR_8 = av_frame_ref(c->prev, frame)) < 0)
return VAR_8;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"DxaDecContext * const c = VAR_0->priv_data;",
"uint8_t *outptr, *srcptr, *tmpptr;",
"unsigned long VAR_4;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"int VAR_10 = 0;",
"GetByteContext gb;",
"bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);",
"if (bytestream2_peek_le32(&gb) == MKTAG('C','M','A','P')) {",
"bytestream2_skip(&gb, 4);",
"for(VAR_5 = 0; VAR_5 < 256; VAR_5++){",
"c->pal[VAR_5] = 0xFFU << 24 | bytestream2_get_be24(&gb);",
"}",
"VAR_10 = 1;",
"}",
"if ((VAR_8 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)\nreturn VAR_8;",
"memcpy(frame->VAR_1[1], c->pal, AVPALETTE_SIZE);",
"frame->palette_has_changed = VAR_10;",
"outptr = frame->VAR_1[0];",
"srcptr = c->decomp_buf;",
"tmpptr = c->prev->VAR_1[0];",
"VAR_9 = frame->linesize[0];",
"if (bytestream2_get_le32(&gb) == MKTAG('N','U','L','L'))\nVAR_7 = -1;",
"else\nVAR_7 = bytestream2_get_byte(&gb);",
"VAR_4 = c->VAR_4;",
"if (VAR_7 != 4 && VAR_7 != -1) {",
"bytestream2_skip(&gb, 4);",
"if (uncompress(c->decomp_buf, &VAR_4, VAR_3->VAR_1 + bytestream2_tell(&gb),\nbytestream2_get_bytes_left(&gb)) != Z_OK) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Uncompress failed!\\n\");",
"return AVERROR_UNKNOWN;",
"}",
"memset(c->decomp_buf + VAR_4, 0, DECOMP_BUF_PADDING);",
"}",
"if (VAR_0->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0, AV_LOG_DEBUG, \"VAR_7:%2d, VAR_4:%d\\n\", VAR_7, (int)VAR_4);",
"switch(VAR_7){",
"case -1:\nframe->key_frame = 0;",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"if (c->prev->VAR_1[0])\nmemcpy(frame->VAR_1[0], c->prev->VAR_1[0], frame->linesize[0] * VAR_0->height);",
"else{",
"memset(frame->VAR_1[0], 0, frame->linesize[0] * VAR_0->height);",
"frame->key_frame = 1;",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"}",
"break;",
"case 2:\ncase 4:\nframe->key_frame = 1;",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {",
"memcpy(outptr, srcptr, VAR_0->width);",
"outptr += VAR_9;",
"srcptr += VAR_0->width;",
"}",
"break;",
"case 3:\ncase 5:\nif (!tmpptr) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Missing reference frame.\\n\");",
"if (!(VAR_0->flags2 & CODEC_FLAG2_SHOW_ALL))\nreturn AVERROR_INVALIDDATA;",
"}",
"frame->key_frame = 0;",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {",
"if(tmpptr){",
"for(VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++)",
"outptr[VAR_5] = srcptr[VAR_5] ^ tmpptr[VAR_5];",
"tmpptr += VAR_9;",
"}else",
"memcpy(outptr, srcptr, VAR_0->width);",
"outptr += VAR_9;",
"srcptr += VAR_0->width;",
"}",
"break;",
"case 12:\ncase 13:\nframe->key_frame = 0;",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"if (!c->prev->VAR_1[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Missing reference frame\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"decode_13(VAR_0, c, frame->VAR_1[0], frame->linesize[0], srcptr, c->prev->VAR_1[0]);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown/unsupported compression type %d\\n\", VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"av_frame_unref(c->prev);",
"if ((VAR_8 = av_frame_ref(c->prev, frame)) < 0)\nreturn VAR_8;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187,
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
217
],
[
219,
221
],
[
225
],
[
231
],
[
233
]
]
|
15,213 | static void virtio_gpu_resource_destroy(VirtIOGPU *g,
struct virtio_gpu_simple_resource *res)
{
pixman_image_unref(res->image);
QTAILQ_REMOVE(&g->reslist, res, next);
g->hostmem -= res->hostmem;
g_free(res);
} | true | qemu | b8e23926c568f2e963af39028b71c472e3023793 | static void virtio_gpu_resource_destroy(VirtIOGPU *g,
struct virtio_gpu_simple_resource *res)
{
pixman_image_unref(res->image);
QTAILQ_REMOVE(&g->reslist, res, next);
g->hostmem -= res->hostmem;
g_free(res);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIOGPU *VAR_0,
struct virtio_gpu_simple_resource *VAR_1)
{
pixman_image_unref(VAR_1->image);
QTAILQ_REMOVE(&VAR_0->reslist, VAR_1, next);
VAR_0->hostmem -= VAR_1->hostmem;
g_free(VAR_1);
} | [
"static void FUNC_0(VirtIOGPU *VAR_0,\nstruct virtio_gpu_simple_resource *VAR_1)\n{",
"pixman_image_unref(VAR_1->image);",
"QTAILQ_REMOVE(&VAR_0->reslist, VAR_1, next);",
"VAR_0->hostmem -= VAR_1->hostmem;",
"g_free(VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
10
],
[
12
],
[
14
],
[
16
]
]
|
15,214 | void virtio_save(VirtIODevice *vdev, QEMUFile *f)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t guest_features_lo = (vdev->guest_features & 0xffffffff);
int i;
if (k->save_config) {
k->save_config(qbus->parent, f);
}
qemu_put_8s(f, &vdev->status);
qemu_put_8s(f, &vdev->isr);
qemu_put_be16s(f, &vdev->queue_sel);
qemu_put_be32s(f, &guest_features_lo);
qemu_put_be32(f, vdev->config_len);
qemu_put_buffer(f, vdev->config, vdev->config_len);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
}
qemu_put_be32(f, i);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
qemu_put_be32(f, vdev->vq[i].vring.num);
if (k->has_variable_vring_alignment) {
qemu_put_be32(f, vdev->vq[i].vring.align);
}
/* XXX virtio-1 devices */
qemu_put_be64(f, vdev->vq[i].vring.desc);
qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
if (k->save_queue) {
k->save_queue(qbus->parent, i, f);
}
}
if (vdc->save != NULL) {
vdc->save(vdev, f);
}
if (vdc->vmsd) {
vmstate_save_state(f, vdc->vmsd, vdev, NULL);
}
/* Subsections */
vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
}
| true | qemu | 874adf45dbfbae2810423527d777ba37bc5ca974 | void virtio_save(VirtIODevice *vdev, QEMUFile *f)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t guest_features_lo = (vdev->guest_features & 0xffffffff);
int i;
if (k->save_config) {
k->save_config(qbus->parent, f);
}
qemu_put_8s(f, &vdev->status);
qemu_put_8s(f, &vdev->isr);
qemu_put_be16s(f, &vdev->queue_sel);
qemu_put_be32s(f, &guest_features_lo);
qemu_put_be32(f, vdev->config_len);
qemu_put_buffer(f, vdev->config, vdev->config_len);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
}
qemu_put_be32(f, i);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
qemu_put_be32(f, vdev->vq[i].vring.num);
if (k->has_variable_vring_alignment) {
qemu_put_be32(f, vdev->vq[i].vring.align);
}
qemu_put_be64(f, vdev->vq[i].vring.desc);
qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
if (k->save_queue) {
k->save_queue(qbus->parent, i, f);
}
}
if (vdc->save != NULL) {
vdc->save(vdev, f);
}
if (vdc->vmsd) {
vmstate_save_state(f, vdc->vmsd, vdev, NULL);
}
vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0);
uint32_t guest_features_lo = (VAR_0->guest_features & 0xffffffff);
int VAR_2;
if (k->save_config) {
k->save_config(qbus->parent, VAR_1);
}
qemu_put_8s(VAR_1, &VAR_0->status);
qemu_put_8s(VAR_1, &VAR_0->isr);
qemu_put_be16s(VAR_1, &VAR_0->queue_sel);
qemu_put_be32s(VAR_1, &guest_features_lo);
qemu_put_be32(VAR_1, VAR_0->config_len);
qemu_put_buffer(VAR_1, VAR_0->config, VAR_0->config_len);
for (VAR_2 = 0; VAR_2 < VIRTIO_QUEUE_MAX; VAR_2++) {
if (VAR_0->vq[VAR_2].vring.num == 0)
break;
}
qemu_put_be32(VAR_1, VAR_2);
for (VAR_2 = 0; VAR_2 < VIRTIO_QUEUE_MAX; VAR_2++) {
if (VAR_0->vq[VAR_2].vring.num == 0)
break;
qemu_put_be32(VAR_1, VAR_0->vq[VAR_2].vring.num);
if (k->has_variable_vring_alignment) {
qemu_put_be32(VAR_1, VAR_0->vq[VAR_2].vring.align);
}
qemu_put_be64(VAR_1, VAR_0->vq[VAR_2].vring.desc);
qemu_put_be16s(VAR_1, &VAR_0->vq[VAR_2].last_avail_idx);
if (k->save_queue) {
k->save_queue(qbus->parent, VAR_2, VAR_1);
}
}
if (vdc->save != NULL) {
vdc->save(VAR_0, VAR_1);
}
if (vdc->vmsd) {
vmstate_save_state(VAR_1, vdc->vmsd, VAR_0, NULL);
}
vmstate_save_state(VAR_1, &vmstate_virtio, VAR_0, NULL);
}
| [
"void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)\n{",
"BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));",
"VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);",
"VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0);",
"uint32_t guest_features_lo = (VAR_0->guest_features & 0xffffffff);",
"int VAR_2;",
"if (k->save_config) {",
"k->save_config(qbus->parent, VAR_1);",
"}",
"qemu_put_8s(VAR_1, &VAR_0->status);",
"qemu_put_8s(VAR_1, &VAR_0->isr);",
"qemu_put_be16s(VAR_1, &VAR_0->queue_sel);",
"qemu_put_be32s(VAR_1, &guest_features_lo);",
"qemu_put_be32(VAR_1, VAR_0->config_len);",
"qemu_put_buffer(VAR_1, VAR_0->config, VAR_0->config_len);",
"for (VAR_2 = 0; VAR_2 < VIRTIO_QUEUE_MAX; VAR_2++) {",
"if (VAR_0->vq[VAR_2].vring.num == 0)\nbreak;",
"}",
"qemu_put_be32(VAR_1, VAR_2);",
"for (VAR_2 = 0; VAR_2 < VIRTIO_QUEUE_MAX; VAR_2++) {",
"if (VAR_0->vq[VAR_2].vring.num == 0)\nbreak;",
"qemu_put_be32(VAR_1, VAR_0->vq[VAR_2].vring.num);",
"if (k->has_variable_vring_alignment) {",
"qemu_put_be32(VAR_1, VAR_0->vq[VAR_2].vring.align);",
"}",
"qemu_put_be64(VAR_1, VAR_0->vq[VAR_2].vring.desc);",
"qemu_put_be16s(VAR_1, &VAR_0->vq[VAR_2].last_avail_idx);",
"if (k->save_queue) {",
"k->save_queue(qbus->parent, VAR_2, VAR_1);",
"}",
"}",
"if (vdc->save != NULL) {",
"vdc->save(VAR_0, VAR_1);",
"}",
"if (vdc->vmsd) {",
"vmstate_save_state(VAR_1, vdc->vmsd, VAR_0, NULL);",
"}",
"vmstate_save_state(VAR_1, &vmstate_virtio, VAR_0, 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,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
103
],
[
105
]
]
|
15,215 | static void virtio_blk_dma_restart_cb(void *opaque, int running,
RunState state)
{
VirtIOBlock *s = opaque;
if (!running)
return;
if (!s->bh) {
s->bh = qemu_bh_new(virtio_blk_dma_restart_bh, s);
qemu_bh_schedule(s->bh);
}
}
| true | qemu | 392808b49b6aee066d0c1d200e72fc3dc11c9d0f | static void virtio_blk_dma_restart_cb(void *opaque, int running,
RunState state)
{
VirtIOBlock *s = opaque;
if (!running)
return;
if (!s->bh) {
s->bh = qemu_bh_new(virtio_blk_dma_restart_bh, s);
qemu_bh_schedule(s->bh);
}
}
| {
"code": [
" if (!running)"
],
"line_no": [
11
]
} | static void FUNC_0(void *VAR_0, int VAR_1,
RunState VAR_2)
{
VirtIOBlock *s = VAR_0;
if (!VAR_1)
return;
if (!s->bh) {
s->bh = qemu_bh_new(virtio_blk_dma_restart_bh, s);
qemu_bh_schedule(s->bh);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1,\nRunState VAR_2)\n{",
"VirtIOBlock *s = VAR_0;",
"if (!VAR_1)\nreturn;",
"if (!s->bh) {",
"s->bh = qemu_bh_new(virtio_blk_dma_restart_bh, s);",
"qemu_bh_schedule(s->bh);",
"}",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
15,216 | static char *json_escape_str(const char *s)
{
static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
char *ret, *p;
int i, len = 0;
// compute the length of the escaped string
for (i = 0; s[i]; i++) {
if (strchr(json_escape, s[i])) len += 2; // simple escape
else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars
else len += 1; // char copy
}
p = ret = av_malloc(len + 1);
if (!p)
return NULL;
for (i = 0; s[i]; i++) {
char *q = strchr(json_escape, s[i]);
if (q) {
*p++ = '\\';
*p++ = json_subst[q - json_escape];
} else if ((unsigned char)s[i] < 32) {
snprintf(p, 7, "\\u00%02x", s[i] & 0xff);
p += 6;
} else {
*p++ = s[i];
}
}
*p = 0;
return ret;
}
| true | FFmpeg | 2f3b028c7117e03267ea7f88d0d612e70f1afc06 | static char *json_escape_str(const char *s)
{
static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
char *ret, *p;
int i, len = 0;
for (i = 0; s[i]; i++) {
if (strchr(json_escape, s[i])) len += 2;
else if ((unsigned char)s[i] < 32) len += 6;
else len += 1;
}
p = ret = av_malloc(len + 1);
if (!p)
return NULL;
for (i = 0; s[i]; i++) {
char *q = strchr(json_escape, s[i]);
if (q) {
*p++ = '\\';
*p++ = json_subst[q - json_escape];
} else if ((unsigned char)s[i] < 32) {
snprintf(p, 7, "\\u00%02x", s[i] & 0xff);
p += 6;
} else {
*p++ = s[i];
}
}
*p = 0;
return ret;
}
| {
"code": [
"static char *json_escape_str(const char *s)",
" char *ret, *p;",
" int i, len = 0;",
" for (i = 0; s[i]; i++) {",
" p = ret = av_malloc(len + 1);",
" if (!p)",
" return NULL;",
" for (i = 0; s[i]; i++) {",
" char *q = strchr(json_escape, s[i]);",
" if (q) {",
" *p++ = '\\\\';",
" *p++ = json_subst[q - json_escape];",
" } else if ((unsigned char)s[i] < 32) {",
" snprintf(p, 7, \"\\\\u00%02x\", s[i] & 0xff);",
" p += 6;",
" *p++ = s[i];",
" *p = 0;",
" return ret;"
],
"line_no": [
1,
9,
11,
17,
29,
31,
33,
17,
37,
39,
41,
43,
45,
47,
49,
53,
59,
61
]
} | static char *FUNC_0(const char *VAR_0)
{
static const char VAR_1[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
static const char VAR_2[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
char *VAR_3, *VAR_4;
int VAR_5, VAR_6 = 0;
for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {
if (strchr(VAR_1, VAR_0[VAR_5])) VAR_6 += 2;
else if ((unsigned char)VAR_0[VAR_5] < 32) VAR_6 += 6;
else VAR_6 += 1;
}
VAR_4 = VAR_3 = av_malloc(VAR_6 + 1);
if (!VAR_4)
return NULL;
for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {
char *VAR_7 = strchr(VAR_1, VAR_0[VAR_5]);
if (VAR_7) {
*VAR_4++ = '\\';
*VAR_4++ = VAR_2[VAR_7 - VAR_1];
} else if ((unsigned char)VAR_0[VAR_5] < 32) {
snprintf(VAR_4, 7, "\\u00%02x", VAR_0[VAR_5] & 0xff);
VAR_4 += 6;
} else {
*VAR_4++ = VAR_0[VAR_5];
}
}
*VAR_4 = 0;
return VAR_3;
}
| [
"static char *FUNC_0(const char *VAR_0)\n{",
"static const char VAR_1[] = {'\"', '\\\\', '\\b', '\\f', '\\n', '\\r', '\\t', 0};",
"static const char VAR_2[] = {'\"', '\\\\', 'b', 'f', 'n', 'r', 't', 0};",
"char *VAR_3, *VAR_4;",
"int VAR_5, VAR_6 = 0;",
"for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {",
"if (strchr(VAR_1, VAR_0[VAR_5])) VAR_6 += 2;",
"else if ((unsigned char)VAR_0[VAR_5] < 32) VAR_6 += 6;",
"else VAR_6 += 1;",
"}",
"VAR_4 = VAR_3 = av_malloc(VAR_6 + 1);",
"if (!VAR_4)\nreturn NULL;",
"for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {",
"char *VAR_7 = strchr(VAR_1, VAR_0[VAR_5]);",
"if (VAR_7) {",
"*VAR_4++ = '\\\\';",
"*VAR_4++ = VAR_2[VAR_7 - VAR_1];",
"} else if ((unsigned char)VAR_0[VAR_5] < 32) {",
"snprintf(VAR_4, 7, \"\\\\u00%02x\", VAR_0[VAR_5] & 0xff);",
"VAR_4 += 6;",
"} else {",
"*VAR_4++ = VAR_0[VAR_5];",
"}",
"}",
"*VAR_4 = 0;",
"return VAR_3;",
"}"
]
| [
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
]
|
15,218 | static int gif_image_write_header(ByteIOContext *pb,
int width, int height, uint32_t *palette)
{
int i;
unsigned int v;
put_tag(pb, "GIF");
put_tag(pb, "89a");
put_le16(pb, width);
put_le16(pb, height);
put_byte(pb, 0xf7); /* flags: global clut, 256 entries */
put_byte(pb, 0x1f); /* background color index */
put_byte(pb, 0); /* aspect ratio */
/* the global palette */
if (!palette) {
put_buffer(pb, (unsigned char *)gif_clut, 216*3);
for(i=0;i<((256-216)*3);i++)
put_byte(pb, 0);
} else {
for(i=0;i<256;i++) {
v = palette[i];
put_byte(pb, (v >> 16) & 0xff);
put_byte(pb, (v >> 8) & 0xff);
put_byte(pb, (v) & 0xff);
}
}
/* application extension header */
/* XXX: not really sure what to put in here... */
#ifdef GIF_ADD_APP_HEADER
put_byte(pb, 0x21);
put_byte(pb, 0xff);
put_byte(pb, 0x0b);
put_tag(pb, "NETSCAPE2.0");
put_byte(pb, 0x03);
put_byte(pb, 0x01);
put_byte(pb, 0x00);
put_byte(pb, 0x00);
#endif
return 0;
}
| false | FFmpeg | 8108551a5c4c4c9696582c73d000f94b12cd95a5 | static int gif_image_write_header(ByteIOContext *pb,
int width, int height, uint32_t *palette)
{
int i;
unsigned int v;
put_tag(pb, "GIF");
put_tag(pb, "89a");
put_le16(pb, width);
put_le16(pb, height);
put_byte(pb, 0xf7);
put_byte(pb, 0x1f);
put_byte(pb, 0);
if (!palette) {
put_buffer(pb, (unsigned char *)gif_clut, 216*3);
for(i=0;i<((256-216)*3);i++)
put_byte(pb, 0);
} else {
for(i=0;i<256;i++) {
v = palette[i];
put_byte(pb, (v >> 16) & 0xff);
put_byte(pb, (v >> 8) & 0xff);
put_byte(pb, (v) & 0xff);
}
}
#ifdef GIF_ADD_APP_HEADER
put_byte(pb, 0x21);
put_byte(pb, 0xff);
put_byte(pb, 0x0b);
put_tag(pb, "NETSCAPE2.0");
put_byte(pb, 0x03);
put_byte(pb, 0x01);
put_byte(pb, 0x00);
put_byte(pb, 0x00);
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ByteIOContext *VAR_0,
int VAR_1, int VAR_2, uint32_t *VAR_3)
{
int VAR_4;
unsigned int VAR_5;
put_tag(VAR_0, "GIF");
put_tag(VAR_0, "89a");
put_le16(VAR_0, VAR_1);
put_le16(VAR_0, VAR_2);
put_byte(VAR_0, 0xf7);
put_byte(VAR_0, 0x1f);
put_byte(VAR_0, 0);
if (!VAR_3) {
put_buffer(VAR_0, (unsigned char *)gif_clut, 216*3);
for(VAR_4=0;VAR_4<((256-216)*3);VAR_4++)
put_byte(VAR_0, 0);
} else {
for(VAR_4=0;VAR_4<256;VAR_4++) {
VAR_5 = VAR_3[VAR_4];
put_byte(VAR_0, (VAR_5 >> 16) & 0xff);
put_byte(VAR_0, (VAR_5 >> 8) & 0xff);
put_byte(VAR_0, (VAR_5) & 0xff);
}
}
#ifdef GIF_ADD_APP_HEADER
put_byte(VAR_0, 0x21);
put_byte(VAR_0, 0xff);
put_byte(VAR_0, 0x0b);
put_tag(VAR_0, "NETSCAPE2.0");
put_byte(VAR_0, 0x03);
put_byte(VAR_0, 0x01);
put_byte(VAR_0, 0x00);
put_byte(VAR_0, 0x00);
#endif
return 0;
}
| [
"static int FUNC_0(ByteIOContext *VAR_0,\nint VAR_1, int VAR_2, uint32_t *VAR_3)\n{",
"int VAR_4;",
"unsigned int VAR_5;",
"put_tag(VAR_0, \"GIF\");",
"put_tag(VAR_0, \"89a\");",
"put_le16(VAR_0, VAR_1);",
"put_le16(VAR_0, VAR_2);",
"put_byte(VAR_0, 0xf7);",
"put_byte(VAR_0, 0x1f);",
"put_byte(VAR_0, 0);",
"if (!VAR_3) {",
"put_buffer(VAR_0, (unsigned char *)gif_clut, 216*3);",
"for(VAR_4=0;VAR_4<((256-216)*3);VAR_4++)",
"put_byte(VAR_0, 0);",
"} else {",
"for(VAR_4=0;VAR_4<256;VAR_4++) {",
"VAR_5 = VAR_3[VAR_4];",
"put_byte(VAR_0, (VAR_5 >> 16) & 0xff);",
"put_byte(VAR_0, (VAR_5 >> 8) & 0xff);",
"put_byte(VAR_0, (VAR_5) & 0xff);",
"}",
"}",
"#ifdef GIF_ADD_APP_HEADER\nput_byte(VAR_0, 0x21);",
"put_byte(VAR_0, 0xff);",
"put_byte(VAR_0, 0x0b);",
"put_tag(VAR_0, \"NETSCAPE2.0\");",
"put_byte(VAR_0, 0x03);",
"put_byte(VAR_0, 0x01);",
"put_byte(VAR_0, 0x00);",
"put_byte(VAR_0, 0x00);",
"#endif\nreturn 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
]
]
|
15,220 | static int rscc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
RsccContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = data;
const uint8_t *pixels, *raw;
uint8_t *inflated_tiles = NULL;
int tiles_nb, packed_size, pixel_size = 0;
int i, ret = 0;
bytestream2_init(gbc, avpkt->data, avpkt->size);
/* Size check */
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
}
/* Read number of tiles, and allocate the array */
tiles_nb = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
tiles_nb * sizeof(*ctx->tiles));
if (!ctx->tiles) {
ret = AVERROR(ENOMEM);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb);
/* When there are more than 5 tiles, they are packed together with
* a size header. When that size does not match the number of tiles
* times the tile size, it means it needs to be inflated as well */
if (tiles_nb > 5) {
uLongf packed_tiles_size;
if (tiles_nb < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size);
/* If necessary, uncompress tiles, and hijack the bytestream reader */
if (packed_tiles_size != tiles_nb * TILE_SIZE) {
uLongf length = tiles_nb * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
ret = AVERROR(ENOMEM);
goto end;
}
ret = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
goto end;
}
/* Skip the compressed tile section in the main byte reader,
* and point it to read the newly uncompressed data */
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
}
}
/* Fill in array of tiles, keeping track of how many pixels are updated */
for (i = 0; i < tiles_nb; i++) {
ctx->tiles[i].x = bytestream2_get_le16(gbc);
ctx->tiles[i].w = bytestream2_get_le16(gbc);
ctx->tiles[i].y = bytestream2_get_le16(gbc);
ctx->tiles[i].h = bytestream2_get_le16(gbc);
pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
av_log(avctx, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
ret = AVERROR_INVALIDDATA;
goto end;
} else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
av_log(avctx, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
ret = AVERROR_INVALIDDATA;
goto end;
}
}
/* Reset the reader in case it had been modified before */
gbc = &ctx->gbc;
/* Extract how much pixel data the tiles contain */
if (pixel_size < 0x100)
packed_size = bytestream2_get_byte(gbc);
else if (pixel_size < 0x10000)
packed_size = bytestream2_get_le16(gbc);
else if (pixel_size < 0x1000000)
packed_size = bytestream2_get_le24(gbc);
else
packed_size = bytestream2_get_le32(gbc);
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
if (packed_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
/* Get pixels buffer, it may be deflated or just raw */
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
if (bytestream2_get_bytes_left(gbc) < packed_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
goto end;
}
pixels = ctx->inflated_buf;
}
/* Allocate when needed */
ret = ff_reget_buffer(avctx, ctx->reference);
if (ret < 0)
goto end;
/* Pointer to actual pixels, will be updated when data is consumed */
raw = pixels;
for (i = 0; i < tiles_nb; i++) {
uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
(avctx->height - ctx->tiles[i].y - 1) +
ctx->tiles[i].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].h);
raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
}
/* Frame is ready to be output */
ret = av_frame_ref(frame, ctx->reference);
if (ret < 0)
goto end;
/* Keyframe when the number of pixels updated matches the whole surface */
if (pixel_size == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt,
AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
}
memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE);
}
*got_frame = 1;
end:
av_free(inflated_tiles);
return ret;
}
| false | FFmpeg | 0f64b6cd22411f574cbc75cab3b6db7dba023ed6 | static int rscc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
RsccContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = data;
const uint8_t *pixels, *raw;
uint8_t *inflated_tiles = NULL;
int tiles_nb, packed_size, pixel_size = 0;
int i, ret = 0;
bytestream2_init(gbc, avpkt->data, avpkt->size);
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
}
tiles_nb = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
tiles_nb * sizeof(*ctx->tiles));
if (!ctx->tiles) {
ret = AVERROR(ENOMEM);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb);
if (tiles_nb > 5) {
uLongf packed_tiles_size;
if (tiles_nb < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size);
if (packed_tiles_size != tiles_nb * TILE_SIZE) {
uLongf length = tiles_nb * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
ret = AVERROR(ENOMEM);
goto end;
}
ret = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
goto end;
}
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
}
}
for (i = 0; i < tiles_nb; i++) {
ctx->tiles[i].x = bytestream2_get_le16(gbc);
ctx->tiles[i].w = bytestream2_get_le16(gbc);
ctx->tiles[i].y = bytestream2_get_le16(gbc);
ctx->tiles[i].h = bytestream2_get_le16(gbc);
pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
av_log(avctx, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
ret = AVERROR_INVALIDDATA;
goto end;
} else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
av_log(avctx, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
ret = AVERROR_INVALIDDATA;
goto end;
}
}
gbc = &ctx->gbc;
if (pixel_size < 0x100)
packed_size = bytestream2_get_byte(gbc);
else if (pixel_size < 0x10000)
packed_size = bytestream2_get_le16(gbc);
else if (pixel_size < 0x1000000)
packed_size = bytestream2_get_le24(gbc);
else
packed_size = bytestream2_get_le32(gbc);
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
if (packed_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
if (bytestream2_get_bytes_left(gbc) < packed_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size);
ret = AVERROR_INVALIDDATA;
goto end;
}
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
goto end;
}
pixels = ctx->inflated_buf;
}
ret = ff_reget_buffer(avctx, ctx->reference);
if (ret < 0)
goto end;
raw = pixels;
for (i = 0; i < tiles_nb; i++) {
uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
(avctx->height - ctx->tiles[i].y - 1) +
ctx->tiles[i].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].h);
raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
}
ret = av_frame_ref(frame, ctx->reference);
if (ret < 0)
goto end;
if (pixel_size == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt,
AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
}
memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE);
}
*got_frame = 1;
end:
av_free(inflated_tiles);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
RsccContext *ctx = VAR_0->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = VAR_1;
const uint8_t *VAR_4, *raw;
uint8_t *inflated_tiles = NULL;
int VAR_5, VAR_6, VAR_7 = 0;
int VAR_8, VAR_9 = 0;
bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->size);
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(VAR_0, AV_LOG_ERROR, "Packet too small (%d)\n", VAR_3->size);
return AVERROR_INVALIDDATA;
}
VAR_5 = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
VAR_5 * sizeof(*ctx->tiles));
if (!ctx->tiles) {
VAR_9 = AVERROR(ENOMEM);
goto end;
}
av_log(VAR_0, AV_LOG_DEBUG, "Frame with %d tiles.\n", VAR_5);
if (VAR_5 > 5) {
uLongf packed_tiles_size;
if (VAR_5 < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(VAR_0, "packed tiles of size %lu.\n", packed_tiles_size);
if (packed_tiles_size != VAR_5 * TILE_SIZE) {
uLongf length = VAR_5 * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
VAR_9 = AVERROR(ENOMEM);
goto end;
}
VAR_9 = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "Tile deflate error %d.\n", VAR_9);
VAR_9 = AVERROR_UNKNOWN;
goto end;
}
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
}
}
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {
ctx->tiles[VAR_8].x = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].w = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].y = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].h = bytestream2_get_le16(gbc);
VAR_7 += ctx->tiles[VAR_8].w * ctx->tiles[VAR_8].h * ctx->component_size;
ff_dlog(VAR_0, "tile %d orig(%d,%d) %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
if (ctx->tiles[VAR_8].w == 0 || ctx->tiles[VAR_8].h == 0) {
av_log(VAR_0, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
VAR_9 = AVERROR_INVALIDDATA;
goto end;
} else if (ctx->tiles[VAR_8].x + ctx->tiles[VAR_8].w > VAR_0->width ||
ctx->tiles[VAR_8].y + ctx->tiles[VAR_8].h > VAR_0->height) {
av_log(VAR_0, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
VAR_9 = AVERROR_INVALIDDATA;
goto end;
}
}
gbc = &ctx->gbc;
if (VAR_7 < 0x100)
VAR_6 = bytestream2_get_byte(gbc);
else if (VAR_7 < 0x10000)
VAR_6 = bytestream2_get_le16(gbc);
else if (VAR_7 < 0x1000000)
VAR_6 = bytestream2_get_le24(gbc);
else
VAR_6 = bytestream2_get_le32(gbc);
ff_dlog(VAR_0, "VAR_7 %d VAR_6 %d.\n", VAR_7, VAR_6);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid tile size %d\n", VAR_6);
VAR_9 = AVERROR_INVALIDDATA;
goto end;
}
if (VAR_7 == VAR_6) {
if (bytestream2_get_bytes_left(gbc) < VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Insufficient input for %d\n", VAR_7);
VAR_9 = AVERROR_INVALIDDATA;
goto end;
}
VAR_4 = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
if (bytestream2_get_bytes_left(gbc) < VAR_6) {
av_log(VAR_0, AV_LOG_ERROR, "Insufficient input for %d\n", VAR_6);
VAR_9 = AVERROR_INVALIDDATA;
goto end;
}
VAR_9 = uncompress(ctx->inflated_buf, &len, gbc->buffer, VAR_6);
if (VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "Pixel deflate error %d.\n", VAR_9);
VAR_9 = AVERROR_UNKNOWN;
goto end;
}
VAR_4 = ctx->inflated_buf;
}
VAR_9 = ff_reget_buffer(VAR_0, ctx->reference);
if (VAR_9 < 0)
goto end;
raw = VAR_4;
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {
uint8_t *dst = ctx->reference->VAR_1[0] + ctx->reference->linesize[0] *
(VAR_0->height - ctx->tiles[VAR_8].y - 1) +
ctx->tiles[VAR_8].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[VAR_8].w * ctx->component_size,
ctx->tiles[VAR_8].w * ctx->component_size,
ctx->tiles[VAR_8].h);
raw += ctx->tiles[VAR_8].w * ctx->component_size * ctx->tiles[VAR_8].h;
}
VAR_9 = av_frame_ref(frame, ctx->reference);
if (VAR_9 < 0)
goto end;
if (VAR_7 == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
}
if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3,
AV_PKT_DATA_PALETTE,
NULL);
if (VAR_10) {
frame->palette_has_changed = 1;
memcpy(ctx->VAR_10, VAR_10, AVPALETTE_SIZE);
}
memcpy (frame->VAR_1[1], ctx->VAR_10, AVPALETTE_SIZE);
}
*VAR_2 = 1;
end:
av_free(inflated_tiles);
return VAR_9;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"RsccContext *ctx = VAR_0->priv_data;",
"GetByteContext *gbc = &ctx->gbc;",
"GetByteContext tiles_gbc;",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4, *raw;",
"uint8_t *inflated_tiles = NULL;",
"int VAR_5, VAR_6, VAR_7 = 0;",
"int VAR_8, VAR_9 = 0;",
"bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->size);",
"if (bytestream2_get_bytes_left(gbc) < 12) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet too small (%d)\\n\", VAR_3->size);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_5 = bytestream2_get_le16(gbc);",
"av_fast_malloc(&ctx->tiles, &ctx->tiles_size,\nVAR_5 * sizeof(*ctx->tiles));",
"if (!ctx->tiles) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto end;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Frame with %d tiles.\\n\", VAR_5);",
"if (VAR_5 > 5) {",
"uLongf packed_tiles_size;",
"if (VAR_5 < 32)\npacked_tiles_size = bytestream2_get_byte(gbc);",
"else\npacked_tiles_size = bytestream2_get_le16(gbc);",
"ff_dlog(VAR_0, \"packed tiles of size %lu.\\n\", packed_tiles_size);",
"if (packed_tiles_size != VAR_5 * TILE_SIZE) {",
"uLongf length = VAR_5 * TILE_SIZE;",
"inflated_tiles = av_malloc(length);",
"if (!inflated_tiles) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto end;",
"}",
"VAR_9 = uncompress(inflated_tiles, &length,\ngbc->buffer, packed_tiles_size);",
"if (VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Tile deflate error %d.\\n\", VAR_9);",
"VAR_9 = AVERROR_UNKNOWN;",
"goto end;",
"}",
"bytestream2_skip(gbc, packed_tiles_size);",
"bytestream2_init(&tiles_gbc, inflated_tiles, length);",
"gbc = &tiles_gbc;",
"}",
"}",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {",
"ctx->tiles[VAR_8].x = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].w = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].y = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].h = bytestream2_get_le16(gbc);",
"VAR_7 += ctx->tiles[VAR_8].w * ctx->tiles[VAR_8].h * ctx->component_size;",
"ff_dlog(VAR_0, \"tile %d orig(%d,%d) %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"if (ctx->tiles[VAR_8].w == 0 || ctx->tiles[VAR_8].h == 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"invalid tile %d at (%d.%d) with size %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto end;",
"} else if (ctx->tiles[VAR_8].x + ctx->tiles[VAR_8].w > VAR_0->width ||",
"ctx->tiles[VAR_8].y + ctx->tiles[VAR_8].h > VAR_0->height) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"out of bounds tile %d at (%d.%d) with size %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto end;",
"}",
"}",
"gbc = &ctx->gbc;",
"if (VAR_7 < 0x100)\nVAR_6 = bytestream2_get_byte(gbc);",
"else if (VAR_7 < 0x10000)\nVAR_6 = bytestream2_get_le16(gbc);",
"else if (VAR_7 < 0x1000000)\nVAR_6 = bytestream2_get_le24(gbc);",
"else\nVAR_6 = bytestream2_get_le32(gbc);",
"ff_dlog(VAR_0, \"VAR_7 %d VAR_6 %d.\\n\", VAR_7, VAR_6);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid tile size %d\\n\", VAR_6);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto end;",
"}",
"if (VAR_7 == VAR_6) {",
"if (bytestream2_get_bytes_left(gbc) < VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Insufficient input for %d\\n\", VAR_7);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto end;",
"}",
"VAR_4 = gbc->buffer;",
"} else {",
"uLongf len = ctx->inflated_size;",
"if (bytestream2_get_bytes_left(gbc) < VAR_6) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Insufficient input for %d\\n\", VAR_6);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto end;",
"}",
"VAR_9 = uncompress(ctx->inflated_buf, &len, gbc->buffer, VAR_6);",
"if (VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Pixel deflate error %d.\\n\", VAR_9);",
"VAR_9 = AVERROR_UNKNOWN;",
"goto end;",
"}",
"VAR_4 = ctx->inflated_buf;",
"}",
"VAR_9 = ff_reget_buffer(VAR_0, ctx->reference);",
"if (VAR_9 < 0)\ngoto end;",
"raw = VAR_4;",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {",
"uint8_t *dst = ctx->reference->VAR_1[0] + ctx->reference->linesize[0] *\n(VAR_0->height - ctx->tiles[VAR_8].y - 1) +\nctx->tiles[VAR_8].x * ctx->component_size;",
"av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],\nraw, ctx->tiles[VAR_8].w * ctx->component_size,\nctx->tiles[VAR_8].w * ctx->component_size,\nctx->tiles[VAR_8].h);",
"raw += ctx->tiles[VAR_8].w * ctx->component_size * ctx->tiles[VAR_8].h;",
"}",
"VAR_9 = av_frame_ref(frame, ctx->reference);",
"if (VAR_9 < 0)\ngoto end;",
"if (VAR_7 == ctx->inflated_size) {",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"frame->key_frame = 1;",
"} else {",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"}",
"if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {",
"const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3,\nAV_PKT_DATA_PALETTE,\nNULL);",
"if (VAR_10) {",
"frame->palette_has_changed = 1;",
"memcpy(ctx->VAR_10, VAR_10, AVPALETTE_SIZE);",
"}",
"memcpy (frame->VAR_1[1], ctx->VAR_10, AVPALETTE_SIZE);",
"}",
"*VAR_2 = 1;",
"end:\nav_free(inflated_tiles);",
"return VAR_9;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
69
],
[
71
],
[
75,
77
],
[
79,
81
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
157,
159,
161
],
[
165
],
[
167,
169,
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185,
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
203
],
[
209,
211
],
[
213,
215
],
[
217,
219
],
[
221,
223
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
293
],
[
295,
297
],
[
303
],
[
305
],
[
307,
309,
311
],
[
313,
315,
317,
319
],
[
321
],
[
323
],
[
329
],
[
331,
333
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353,
355,
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375,
377
],
[
379
],
[
381
]
]
|
15,221 | static int parse_frame_header(DCACoreDecoder *s)
{
DCACoreFrameHeader h = { 0 };
int err = avpriv_dca_parse_core_frame_header(&s->gb, &h);
if (err < 0) {
switch (err) {
case DCA_PARSE_ERROR_DEFICIT_SAMPLES:
av_log(s->avctx, AV_LOG_ERROR, "Deficit samples are not supported\n");
return h.normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_PCM_BLOCKS:
av_log(s->avctx, AV_LOG_ERROR, "Unsupported number of PCM sample blocks (%d)\n", h.npcmblocks);
return (h.npcmblocks < 6 || h.normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_FRAME_SIZE:
av_log(s->avctx, AV_LOG_ERROR, "Invalid core frame size (%d bytes)\n", h.frame_size);
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_AMODE:
av_log(s->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", h.audio_mode);
return AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_SAMPLE_RATE:
av_log(s->avctx, AV_LOG_ERROR, "Invalid core audio sampling frequency\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_RESERVED_BIT:
av_log(s->avctx, AV_LOG_ERROR, "Reserved bit set\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_LFE_FLAG:
av_log(s->avctx, AV_LOG_ERROR, "Invalid low frequency effects flag\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_PCM_RES:
av_log(s->avctx, AV_LOG_ERROR, "Invalid source PCM resolution\n");
return AVERROR_INVALIDDATA;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown core frame header error\n");
return AVERROR_INVALIDDATA;
}
}
s->crc_present = h.crc_present;
s->npcmblocks = h.npcmblocks;
s->frame_size = h.frame_size;
s->audio_mode = h.audio_mode;
s->sample_rate = avpriv_dca_sample_rates[h.sr_code];
s->bit_rate = ff_dca_bit_rates[h.br_code];
s->drc_present = h.drc_present;
s->ts_present = h.ts_present;
s->aux_present = h.aux_present;
s->ext_audio_type = h.ext_audio_type;
s->ext_audio_present = h.ext_audio_present;
s->sync_ssf = h.sync_ssf;
s->lfe_present = h.lfe_present;
s->predictor_history = h.predictor_history;
s->filter_perfect = h.filter_perfect;
s->source_pcm_res = ff_dca_bits_per_sample[h.pcmr_code];
s->es_format = h.pcmr_code & 1;
s->sumdiff_front = h.sumdiff_front;
s->sumdiff_surround = h.sumdiff_surround;
return 0;
}
| false | FFmpeg | 7c9d2ad45f4e46ad2c3b2e93051efbe1e0d0529e | static int parse_frame_header(DCACoreDecoder *s)
{
DCACoreFrameHeader h = { 0 };
int err = avpriv_dca_parse_core_frame_header(&s->gb, &h);
if (err < 0) {
switch (err) {
case DCA_PARSE_ERROR_DEFICIT_SAMPLES:
av_log(s->avctx, AV_LOG_ERROR, "Deficit samples are not supported\n");
return h.normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_PCM_BLOCKS:
av_log(s->avctx, AV_LOG_ERROR, "Unsupported number of PCM sample blocks (%d)\n", h.npcmblocks);
return (h.npcmblocks < 6 || h.normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_FRAME_SIZE:
av_log(s->avctx, AV_LOG_ERROR, "Invalid core frame size (%d bytes)\n", h.frame_size);
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_AMODE:
av_log(s->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", h.audio_mode);
return AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_SAMPLE_RATE:
av_log(s->avctx, AV_LOG_ERROR, "Invalid core audio sampling frequency\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_RESERVED_BIT:
av_log(s->avctx, AV_LOG_ERROR, "Reserved bit set\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_LFE_FLAG:
av_log(s->avctx, AV_LOG_ERROR, "Invalid low frequency effects flag\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_PCM_RES:
av_log(s->avctx, AV_LOG_ERROR, "Invalid source PCM resolution\n");
return AVERROR_INVALIDDATA;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown core frame header error\n");
return AVERROR_INVALIDDATA;
}
}
s->crc_present = h.crc_present;
s->npcmblocks = h.npcmblocks;
s->frame_size = h.frame_size;
s->audio_mode = h.audio_mode;
s->sample_rate = avpriv_dca_sample_rates[h.sr_code];
s->bit_rate = ff_dca_bit_rates[h.br_code];
s->drc_present = h.drc_present;
s->ts_present = h.ts_present;
s->aux_present = h.aux_present;
s->ext_audio_type = h.ext_audio_type;
s->ext_audio_present = h.ext_audio_present;
s->sync_ssf = h.sync_ssf;
s->lfe_present = h.lfe_present;
s->predictor_history = h.predictor_history;
s->filter_perfect = h.filter_perfect;
s->source_pcm_res = ff_dca_bits_per_sample[h.pcmr_code];
s->es_format = h.pcmr_code & 1;
s->sumdiff_front = h.sumdiff_front;
s->sumdiff_surround = h.sumdiff_surround;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DCACoreDecoder *VAR_0)
{
DCACoreFrameHeader h = { 0 };
int VAR_1 = avpriv_dca_parse_core_frame_header(&VAR_0->gb, &h);
if (VAR_1 < 0) {
switch (VAR_1) {
case DCA_PARSE_ERROR_DEFICIT_SAMPLES:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Deficit samples are not supported\n");
return h.normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_PCM_BLOCKS:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unsupported number of PCM sample blocks (%d)\n", h.npcmblocks);
return (h.npcmblocks < 6 || h.normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_FRAME_SIZE:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid core frame size (%d bytes)\n", h.frame_size);
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_AMODE:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", h.audio_mode);
return AVERROR_PATCHWELCOME;
case DCA_PARSE_ERROR_SAMPLE_RATE:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid core audio sampling frequency\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_RESERVED_BIT:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Reserved bit set\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_LFE_FLAG:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid low frequency effects flag\n");
return AVERROR_INVALIDDATA;
case DCA_PARSE_ERROR_PCM_RES:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid source PCM resolution\n");
return AVERROR_INVALIDDATA;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown core frame header error\n");
return AVERROR_INVALIDDATA;
}
}
VAR_0->crc_present = h.crc_present;
VAR_0->npcmblocks = h.npcmblocks;
VAR_0->frame_size = h.frame_size;
VAR_0->audio_mode = h.audio_mode;
VAR_0->sample_rate = avpriv_dca_sample_rates[h.sr_code];
VAR_0->bit_rate = ff_dca_bit_rates[h.br_code];
VAR_0->drc_present = h.drc_present;
VAR_0->ts_present = h.ts_present;
VAR_0->aux_present = h.aux_present;
VAR_0->ext_audio_type = h.ext_audio_type;
VAR_0->ext_audio_present = h.ext_audio_present;
VAR_0->sync_ssf = h.sync_ssf;
VAR_0->lfe_present = h.lfe_present;
VAR_0->predictor_history = h.predictor_history;
VAR_0->filter_perfect = h.filter_perfect;
VAR_0->source_pcm_res = ff_dca_bits_per_sample[h.pcmr_code];
VAR_0->es_format = h.pcmr_code & 1;
VAR_0->sumdiff_front = h.sumdiff_front;
VAR_0->sumdiff_surround = h.sumdiff_surround;
return 0;
}
| [
"static int FUNC_0(DCACoreDecoder *VAR_0)\n{",
"DCACoreFrameHeader h = { 0 };",
"int VAR_1 = avpriv_dca_parse_core_frame_header(&VAR_0->gb, &h);",
"if (VAR_1 < 0) {",
"switch (VAR_1) {",
"case DCA_PARSE_ERROR_DEFICIT_SAMPLES:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Deficit samples are not supported\\n\");",
"return h.normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;",
"case DCA_PARSE_ERROR_PCM_BLOCKS:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unsupported number of PCM sample blocks (%d)\\n\", h.npcmblocks);",
"return (h.npcmblocks < 6 || h.normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME;",
"case DCA_PARSE_ERROR_FRAME_SIZE:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid core frame size (%d bytes)\\n\", h.frame_size);",
"return AVERROR_INVALIDDATA;",
"case DCA_PARSE_ERROR_AMODE:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unsupported audio channel arrangement (%d)\\n\", h.audio_mode);",
"return AVERROR_PATCHWELCOME;",
"case DCA_PARSE_ERROR_SAMPLE_RATE:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid core audio sampling frequency\\n\");",
"return AVERROR_INVALIDDATA;",
"case DCA_PARSE_ERROR_RESERVED_BIT:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Reserved bit set\\n\");",
"return AVERROR_INVALIDDATA;",
"case DCA_PARSE_ERROR_LFE_FLAG:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid low frequency effects flag\\n\");",
"return AVERROR_INVALIDDATA;",
"case DCA_PARSE_ERROR_PCM_RES:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid source PCM resolution\\n\");",
"return AVERROR_INVALIDDATA;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown core frame header error\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"VAR_0->crc_present = h.crc_present;",
"VAR_0->npcmblocks = h.npcmblocks;",
"VAR_0->frame_size = h.frame_size;",
"VAR_0->audio_mode = h.audio_mode;",
"VAR_0->sample_rate = avpriv_dca_sample_rates[h.sr_code];",
"VAR_0->bit_rate = ff_dca_bit_rates[h.br_code];",
"VAR_0->drc_present = h.drc_present;",
"VAR_0->ts_present = h.ts_present;",
"VAR_0->aux_present = h.aux_present;",
"VAR_0->ext_audio_type = h.ext_audio_type;",
"VAR_0->ext_audio_present = h.ext_audio_present;",
"VAR_0->sync_ssf = h.sync_ssf;",
"VAR_0->lfe_present = h.lfe_present;",
"VAR_0->predictor_history = h.predictor_history;",
"VAR_0->filter_perfect = h.filter_perfect;",
"VAR_0->source_pcm_res = ff_dca_bits_per_sample[h.pcmr_code];",
"VAR_0->es_format = h.pcmr_code & 1;",
"VAR_0->sumdiff_front = h.sumdiff_front;",
"VAR_0->sumdiff_surround = h.sumdiff_surround;",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
47,
49
],
[
51
],
[
55,
57
],
[
59
],
[
63,
65
],
[
67
],
[
71,
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
]
]
|
15,223 | static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pad_idx)
{
OutputFile *of = output_files[ost->file_index];
AVFilterGraph *graph = (*last_filter)->graph;
AVFilterContext *ctx;
const AVFilter *trim;
const char *name = ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "trim" : "atrim";
char filter_name[128];
int ret = 0;
if (of->recording_time == INT64_MAX && !of->start_time)
return 0;
trim = avfilter_get_by_name(name);
if (!trim) {
av_log(NULL, AV_LOG_ERROR, "%s filter not present, cannot limit "
"recording time.\n", name);
return AVERROR_FILTER_NOT_FOUND;
}
snprintf(filter_name, sizeof(filter_name), "%s for output stream %d:%d",
name, ost->file_index, ost->index);
ctx = avfilter_graph_alloc_filter(graph, trim, filter_name);
if (!ctx)
return AVERROR(ENOMEM);
if (of->recording_time != INT64_MAX) {
ret = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (ret >= 0 && of->start_time) {
ret = av_opt_set_double(ctx, "start", (double)of->start_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name);
return ret;
}
ret = avfilter_init_str(ctx, NULL);
if (ret < 0)
return ret;
ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
if (ret < 0)
return ret;
*last_filter = ctx;
*pad_idx = 0;
return 0;
}
| false | FFmpeg | 56ee3f9de7b9f6090d599a27d33a392890a2f7b8 | static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pad_idx)
{
OutputFile *of = output_files[ost->file_index];
AVFilterGraph *graph = (*last_filter)->graph;
AVFilterContext *ctx;
const AVFilter *trim;
const char *name = ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "trim" : "atrim";
char filter_name[128];
int ret = 0;
if (of->recording_time == INT64_MAX && !of->start_time)
return 0;
trim = avfilter_get_by_name(name);
if (!trim) {
av_log(NULL, AV_LOG_ERROR, "%s filter not present, cannot limit "
"recording time.\n", name);
return AVERROR_FILTER_NOT_FOUND;
}
snprintf(filter_name, sizeof(filter_name), "%s for output stream %d:%d",
name, ost->file_index, ost->index);
ctx = avfilter_graph_alloc_filter(graph, trim, filter_name);
if (!ctx)
return AVERROR(ENOMEM);
if (of->recording_time != INT64_MAX) {
ret = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (ret >= 0 && of->start_time) {
ret = av_opt_set_double(ctx, "start", (double)of->start_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name);
return ret;
}
ret = avfilter_init_str(ctx, NULL);
if (ret < 0)
return ret;
ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
if (ret < 0)
return ret;
*last_filter = ctx;
*pad_idx = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OutputStream *VAR_0, AVFilterContext **VAR_1, int *VAR_2)
{
OutputFile *of = output_files[VAR_0->file_index];
AVFilterGraph *graph = (*VAR_1)->graph;
AVFilterContext *ctx;
const AVFilter *VAR_3;
const char *VAR_4 = VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "VAR_3" : "atrim";
char VAR_5[128];
int VAR_6 = 0;
if (of->recording_time == INT64_MAX && !of->start_time)
return 0;
VAR_3 = avfilter_get_by_name(VAR_4);
if (!VAR_3) {
av_log(NULL, AV_LOG_ERROR, "%s filter not present, cannot limit "
"recording time.\n", VAR_4);
return AVERROR_FILTER_NOT_FOUND;
}
snprintf(VAR_5, sizeof(VAR_5), "%s for output stream %d:%d",
VAR_4, VAR_0->file_index, VAR_0->index);
ctx = avfilter_graph_alloc_filter(graph, VAR_3, VAR_5);
if (!ctx)
return AVERROR(ENOMEM);
if (of->recording_time != INT64_MAX) {
VAR_6 = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (VAR_6 >= 0 && of->start_time) {
VAR_6 = av_opt_set_double(ctx, "start", (double)of->start_time / 1e6,
AV_OPT_SEARCH_CHILDREN);
}
if (VAR_6 < 0) {
av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", VAR_4);
return VAR_6;
}
VAR_6 = avfilter_init_str(ctx, NULL);
if (VAR_6 < 0)
return VAR_6;
VAR_6 = avfilter_link(*VAR_1, *VAR_2, ctx, 0);
if (VAR_6 < 0)
return VAR_6;
*VAR_1 = ctx;
*VAR_2 = 0;
return 0;
}
| [
"static int FUNC_0(OutputStream *VAR_0, AVFilterContext **VAR_1, int *VAR_2)\n{",
"OutputFile *of = output_files[VAR_0->file_index];",
"AVFilterGraph *graph = (*VAR_1)->graph;",
"AVFilterContext *ctx;",
"const AVFilter *VAR_3;",
"const char *VAR_4 = VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO ? \"VAR_3\" : \"atrim\";",
"char VAR_5[128];",
"int VAR_6 = 0;",
"if (of->recording_time == INT64_MAX && !of->start_time)\nreturn 0;",
"VAR_3 = avfilter_get_by_name(VAR_4);",
"if (!VAR_3) {",
"av_log(NULL, AV_LOG_ERROR, \"%s filter not present, cannot limit \"\n\"recording time.\\n\", VAR_4);",
"return AVERROR_FILTER_NOT_FOUND;",
"}",
"snprintf(VAR_5, sizeof(VAR_5), \"%s for output stream %d:%d\",\nVAR_4, VAR_0->file_index, VAR_0->index);",
"ctx = avfilter_graph_alloc_filter(graph, VAR_3, VAR_5);",
"if (!ctx)\nreturn AVERROR(ENOMEM);",
"if (of->recording_time != INT64_MAX) {",
"VAR_6 = av_opt_set_double(ctx, \"duration\", (double)of->recording_time / 1e6,\nAV_OPT_SEARCH_CHILDREN);",
"}",
"if (VAR_6 >= 0 && of->start_time) {",
"VAR_6 = av_opt_set_double(ctx, \"start\", (double)of->start_time / 1e6,\nAV_OPT_SEARCH_CHILDREN);",
"}",
"if (VAR_6 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"Error configuring the %s filter\", VAR_4);",
"return VAR_6;",
"}",
"VAR_6 = avfilter_init_str(ctx, NULL);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"VAR_6 = avfilter_link(*VAR_1, *VAR_2, ctx, 0);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"*VAR_1 = ctx;",
"*VAR_2 = 0;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
47,
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
]
]
|
15,224 | static int add_doubles_metadata(const uint8_t **buf, int count,
const char *name, const char *sep,
TiffContext *s)
{
char *ap;
int i;
double *dp = av_malloc(count * sizeof(double));
if (!dp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
dp[i] = tget_double(buf, s->le);
ap = doubles2str(dp, count, sep);
av_freep(&dp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| false | FFmpeg | 1ec83d9a9e472f485897ac92bad9631d551a8c5b | static int add_doubles_metadata(const uint8_t **buf, int count,
const char *name, const char *sep,
TiffContext *s)
{
char *ap;
int i;
double *dp = av_malloc(count * sizeof(double));
if (!dp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
dp[i] = tget_double(buf, s->le);
ap = doubles2str(dp, count, sep);
av_freep(&dp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t **VAR_0, int VAR_1,
const char *VAR_2, const char *VAR_3,
TiffContext *VAR_4)
{
char *VAR_5;
int VAR_6;
double *VAR_7 = av_malloc(VAR_1 * sizeof(double));
if (!VAR_7)
return AVERROR(ENOMEM);
for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++)
VAR_7[VAR_6] = tget_double(VAR_0, VAR_4->le);
VAR_5 = doubles2str(VAR_7, VAR_1, VAR_3);
av_freep(&VAR_7);
if (!VAR_5)
return AVERROR(ENOMEM);
av_dict_set(&VAR_4->picture.metadata, VAR_2, VAR_5, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| [
"static int FUNC_0(const uint8_t **VAR_0, int VAR_1,\nconst char *VAR_2, const char *VAR_3,\nTiffContext *VAR_4)\n{",
"char *VAR_5;",
"int VAR_6;",
"double *VAR_7 = av_malloc(VAR_1 * sizeof(double));",
"if (!VAR_7)\nreturn AVERROR(ENOMEM);",
"for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++)",
"VAR_7[VAR_6] = tget_double(VAR_0, VAR_4->le);",
"VAR_5 = doubles2str(VAR_7, VAR_1, VAR_3);",
"av_freep(&VAR_7);",
"if (!VAR_5)\nreturn AVERROR(ENOMEM);",
"av_dict_set(&VAR_4->picture.metadata, VAR_2, VAR_5, AV_DICT_DONT_STRDUP_VAL);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
]
]
|
15,228 | static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,
void *dest)
{
uint8_t buf[512];
if (s->blk_cur) {
if (blk_read(s->blk_cur, s->secs_cur + (sec >> 5), buf, 1) < 0) {
return 1;
}
memcpy(dest, buf + ((sec & 31) << 4), secn << 4);
} else if (sec + secn > s->secs_cur) {
return 1;
} else {
memcpy(dest, s->current + (s->secs_cur << 9) + (sec << 4), secn << 4);
}
return 0;
}
| true | qemu | 441692ddd8321d5e0f09b163e86410e578d87236 | static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,
void *dest)
{
uint8_t buf[512];
if (s->blk_cur) {
if (blk_read(s->blk_cur, s->secs_cur + (sec >> 5), buf, 1) < 0) {
return 1;
}
memcpy(dest, buf + ((sec & 31) << 4), secn << 4);
} else if (sec + secn > s->secs_cur) {
return 1;
} else {
memcpy(dest, s->current + (s->secs_cur << 9) + (sec << 4), secn << 4);
}
return 0;
}
| {
"code": [
" if (blk_read(s->blk_cur, s->secs_cur + (sec >> 5), buf, 1) < 0) {"
],
"line_no": [
13
]
} | static inline int FUNC_0(OneNANDState *VAR_0, int VAR_1, int VAR_2,
void *VAR_3)
{
uint8_t buf[512];
if (VAR_0->blk_cur) {
if (blk_read(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5), buf, 1) < 0) {
return 1;
}
memcpy(VAR_3, buf + ((VAR_1 & 31) << 4), VAR_2 << 4);
} else if (VAR_1 + VAR_2 > VAR_0->secs_cur) {
return 1;
} else {
memcpy(VAR_3, VAR_0->current + (VAR_0->secs_cur << 9) + (VAR_1 << 4), VAR_2 << 4);
}
return 0;
}
| [
"static inline int FUNC_0(OneNANDState *VAR_0, int VAR_1, int VAR_2,\nvoid *VAR_3)\n{",
"uint8_t buf[512];",
"if (VAR_0->blk_cur) {",
"if (blk_read(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5), buf, 1) < 0) {",
"return 1;",
"}",
"memcpy(VAR_3, buf + ((VAR_1 & 31) << 4), VAR_2 << 4);",
"} else if (VAR_1 + VAR_2 > VAR_0->secs_cur) {",
"return 1;",
"} else {",
"memcpy(VAR_3, VAR_0->current + (VAR_0->secs_cur << 9) + (VAR_1 << 4), VAR_2 << 4);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
]
|
15,229 | X264_init(AVCodecContext *avctx)
{
X264Context *x4 = avctx->priv_data;
x264_param_default(&x4->params);
x4->params.pf_log = X264_log;
x4->params.p_log_private = avctx;
x4->params.i_keyint_max = avctx->gop_size;
x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;
else{
if(avctx->crf){
x4->params.rc.i_rc_method = X264_RC_CRF;
x4->params.rc.f_rf_constant = avctx->crf;
}else if(avctx->cqp > -1){
x4->params.rc.i_rc_method = X264_RC_CQP;
x4->params.rc.i_qp_constant = avctx->cqp;
}
}
// if neither crf nor cqp modes are selected we have to enable the RC
// we do it this way because we cannot check if the bitrate has been set
if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;
x4->params.i_bframe = avctx->max_b_frames;
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
x4->params.b_bframe_adaptive = avctx->b_frame_strategy;
x4->params.i_bframe_bias = avctx->bframebias;
x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
x4->params.i_keyint_min = avctx->keyint_min;
if(x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
x4->params.rc.i_qp_min = avctx->qmin;
x4->params.rc.i_qp_max = avctx->qmax;
x4->params.rc.i_qp_step = avctx->max_qdiff;
x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
x4->params.rc.f_complexity_blur = avctx->complexityblur;
x4->params.i_frame_reference = avctx->refs;
x4->params.i_width = avctx->width;
x4->params.i_height = avctx->height;
x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
x4->params.i_fps_num = avctx->time_base.den;
x4->params.i_fps_den = avctx->time_base.num;
x4->params.analyse.inter = 0;
if(avctx->partitions){
if(avctx->partitions & X264_PART_I4X4)
x4->params.analyse.inter |= X264_ANALYSE_I4x4;
if(avctx->partitions & X264_PART_I8X8)
x4->params.analyse.inter |= X264_ANALYSE_I8x8;
if(avctx->partitions & X264_PART_P8X8)
x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
if(avctx->partitions & X264_PART_P4X4)
x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
if(avctx->partitions & X264_PART_B8X8)
x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
}
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
if(avctx->me_method == ME_EPZS)
x4->params.analyse.i_me_method = X264_ME_DIA;
else if(avctx->me_method == ME_HEX)
x4->params.analyse.i_me_method = X264_ME_HEX;
else if(avctx->me_method == ME_UMH)
x4->params.analyse.i_me_method = X264_ME_UMH;
else if(avctx->me_method == ME_FULL)
x4->params.analyse.i_me_method = X264_ME_ESA;
else if(avctx->me_method == ME_TESA)
x4->params.analyse.i_me_method = X264_ME_TESA;
else x4->params.analyse.i_me_method = X264_ME_HEX;
x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
x4->params.analyse.b_bidir_me = avctx->bidir_refine > 0;
x4->params.analyse.b_bframe_rdo = avctx->flags2 & CODEC_FLAG2_BRDO;
x4->params.analyse.b_mixed_references =
avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
x4->params.analyse.i_trellis = avctx->trellis;
x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if(avctx->level > 0) x4->params.i_level_idc = avctx->level;
x4->params.rc.f_rate_tolerance =
(float)avctx->bit_rate_tolerance/avctx->bit_rate;
if((avctx->rc_buffer_size != 0) &&
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)){
x4->params.rc.f_vbv_buffer_init =
(float)avctx->rc_initial_buffer_occupancy/avctx->rc_buffer_size;
}
else x4->params.rc.f_vbv_buffer_init = 0.9;
x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
x4->params.rc.psz_rc_eq = avctx->rc_eq;
x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
x4->params.i_log_level = X264_LOG_DEBUG;
x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
x4->params.i_threads = avctx->thread_count;
x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
x4->params.b_repeat_headers = 0;
}
x4->enc = x264_encoder_open(&x4->params);
if(!x4->enc)
return -1;
avctx->coded_frame = &x4->out_pic;
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
x264_nal_t *nal;
int nnal, i, s = 0;
x264_encoder_headers(x4->enc, &nal, &nnal);
/* 5 bytes NAL header + worst case escaping */
for(i = 0; i < nnal; i++)
s += 5 + nal[i].i_payload * 4 / 3;
avctx->extradata = av_malloc(s);
avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
}
return 0;
}
| true | FFmpeg | d4be08e0c9fc9ed2862e952a489ef6a8943b5e5d | X264_init(AVCodecContext *avctx)
{
X264Context *x4 = avctx->priv_data;
x264_param_default(&x4->params);
x4->params.pf_log = X264_log;
x4->params.p_log_private = avctx;
x4->params.i_keyint_max = avctx->gop_size;
x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;
else{
if(avctx->crf){
x4->params.rc.i_rc_method = X264_RC_CRF;
x4->params.rc.f_rf_constant = avctx->crf;
}else if(avctx->cqp > -1){
x4->params.rc.i_rc_method = X264_RC_CQP;
x4->params.rc.i_qp_constant = avctx->cqp;
}
}
if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;
x4->params.i_bframe = avctx->max_b_frames;
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
x4->params.b_bframe_adaptive = avctx->b_frame_strategy;
x4->params.i_bframe_bias = avctx->bframebias;
x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
x4->params.i_keyint_min = avctx->keyint_min;
if(x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
x4->params.rc.i_qp_min = avctx->qmin;
x4->params.rc.i_qp_max = avctx->qmax;
x4->params.rc.i_qp_step = avctx->max_qdiff;
x4->params.rc.f_qcompress = avctx->qcompress;
x4->params.rc.f_qblur = avctx->qblur;
x4->params.rc.f_complexity_blur = avctx->complexityblur;
x4->params.i_frame_reference = avctx->refs;
x4->params.i_width = avctx->width;
x4->params.i_height = avctx->height;
x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
x4->params.i_fps_num = avctx->time_base.den;
x4->params.i_fps_den = avctx->time_base.num;
x4->params.analyse.inter = 0;
if(avctx->partitions){
if(avctx->partitions & X264_PART_I4X4)
x4->params.analyse.inter |= X264_ANALYSE_I4x4;
if(avctx->partitions & X264_PART_I8X8)
x4->params.analyse.inter |= X264_ANALYSE_I8x8;
if(avctx->partitions & X264_PART_P8X8)
x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
if(avctx->partitions & X264_PART_P4X4)
x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
if(avctx->partitions & X264_PART_B8X8)
x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
}
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
if(avctx->me_method == ME_EPZS)
x4->params.analyse.i_me_method = X264_ME_DIA;
else if(avctx->me_method == ME_HEX)
x4->params.analyse.i_me_method = X264_ME_HEX;
else if(avctx->me_method == ME_UMH)
x4->params.analyse.i_me_method = X264_ME_UMH;
else if(avctx->me_method == ME_FULL)
x4->params.analyse.i_me_method = X264_ME_ESA;
else if(avctx->me_method == ME_TESA)
x4->params.analyse.i_me_method = X264_ME_TESA;
else x4->params.analyse.i_me_method = X264_ME_HEX;
x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
x4->params.analyse.b_bidir_me = avctx->bidir_refine > 0;
x4->params.analyse.b_bframe_rdo = avctx->flags2 & CODEC_FLAG2_BRDO;
x4->params.analyse.b_mixed_references =
avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
x4->params.analyse.i_trellis = avctx->trellis;
x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
if(avctx->level > 0) x4->params.i_level_idc = avctx->level;
x4->params.rc.f_rate_tolerance =
(float)avctx->bit_rate_tolerance/avctx->bit_rate;
if((avctx->rc_buffer_size != 0) &&
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)){
x4->params.rc.f_vbv_buffer_init =
(float)avctx->rc_initial_buffer_occupancy/avctx->rc_buffer_size;
}
else x4->params.rc.f_vbv_buffer_init = 0.9;
x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
x4->params.rc.psz_rc_eq = avctx->rc_eq;
x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
x4->params.i_log_level = X264_LOG_DEBUG;
x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
x4->params.i_threads = avctx->thread_count;
x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
x4->params.b_repeat_headers = 0;
}
x4->enc = x264_encoder_open(&x4->params);
if(!x4->enc)
return -1;
avctx->coded_frame = &x4->out_pic;
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
x264_nal_t *nal;
int nnal, i, s = 0;
x264_encoder_headers(x4->enc, &nal, &nnal);
for(i = 0; i < nnal; i++)
s += 5 + nal[i].i_payload * 4 / 3;
avctx->extradata = av_malloc(s);
avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
}
return 0;
}
| {
"code": [
" x4->params.rc.psz_rc_eq = avctx->rc_eq;"
],
"line_no": [
245
]
} | FUNC_0(AVCodecContext *VAR_0)
{
X264Context *x4 = VAR_0->priv_data;
x264_param_default(&x4->params);
x4->params.pf_log = X264_log;
x4->params.p_log_private = VAR_0;
x4->params.i_keyint_max = VAR_0->gop_size;
x4->params.rc.i_bitrate = VAR_0->bit_rate / 1000;
x4->params.rc.i_vbv_buffer_size = VAR_0->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = VAR_0->rc_max_rate / 1000;
x4->params.rc.b_stat_write = VAR_0->flags & CODEC_FLAG_PASS1;
if(VAR_0->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;
else{
if(VAR_0->crf){
x4->params.rc.i_rc_method = X264_RC_CRF;
x4->params.rc.f_rf_constant = VAR_0->crf;
}else if(VAR_0->cqp > -1){
x4->params.rc.i_rc_method = X264_RC_CQP;
x4->params.rc.i_qp_constant = VAR_0->cqp;
}
}
if(!(VAR_0->crf || (VAR_0->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;
x4->params.i_bframe = VAR_0->max_b_frames;
x4->params.b_cabac = VAR_0->coder_type == FF_CODER_TYPE_AC;
x4->params.b_bframe_adaptive = VAR_0->b_frame_strategy;
x4->params.i_bframe_bias = VAR_0->bframebias;
x4->params.b_bframe_pyramid = VAR_0->flags2 & CODEC_FLAG2_BPYRAMID;
VAR_0->has_b_frames= VAR_0->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!VAR_0->max_b_frames;
x4->params.i_keyint_min = VAR_0->keyint_min;
if(x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
x4->params.i_scenecut_threshold = VAR_0->scenechange_threshold;
x4->params.b_deblocking_filter = VAR_0->flags & CODEC_FLAG_LOOP_FILTER;
x4->params.i_deblocking_filter_alphac0 = VAR_0->deblockalpha;
x4->params.i_deblocking_filter_beta = VAR_0->deblockbeta;
x4->params.rc.i_qp_min = VAR_0->qmin;
x4->params.rc.i_qp_max = VAR_0->qmax;
x4->params.rc.i_qp_step = VAR_0->max_qdiff;
x4->params.rc.f_qcompress = VAR_0->qcompress;
x4->params.rc.f_qblur = VAR_0->qblur;
x4->params.rc.f_complexity_blur = VAR_0->complexityblur;
x4->params.i_frame_reference = VAR_0->refs;
x4->params.i_width = VAR_0->width;
x4->params.i_height = VAR_0->height;
x4->params.vui.i_sar_width = VAR_0->sample_aspect_ratio.num;
x4->params.vui.i_sar_height = VAR_0->sample_aspect_ratio.den;
x4->params.i_fps_num = VAR_0->time_base.den;
x4->params.i_fps_den = VAR_0->time_base.num;
x4->params.analyse.inter = 0;
if(VAR_0->partitions){
if(VAR_0->partitions & X264_PART_I4X4)
x4->params.analyse.inter |= X264_ANALYSE_I4x4;
if(VAR_0->partitions & X264_PART_I8X8)
x4->params.analyse.inter |= X264_ANALYSE_I8x8;
if(VAR_0->partitions & X264_PART_P8X8)
x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
if(VAR_0->partitions & X264_PART_P4X4)
x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
if(VAR_0->partitions & X264_PART_B8X8)
x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
}
x4->params.analyse.i_direct_mv_pred = VAR_0->directpred;
x4->params.analyse.b_weighted_bipred = VAR_0->flags2 & CODEC_FLAG2_WPRED;
if(VAR_0->me_method == ME_EPZS)
x4->params.analyse.i_me_method = X264_ME_DIA;
else if(VAR_0->me_method == ME_HEX)
x4->params.analyse.i_me_method = X264_ME_HEX;
else if(VAR_0->me_method == ME_UMH)
x4->params.analyse.i_me_method = X264_ME_UMH;
else if(VAR_0->me_method == ME_FULL)
x4->params.analyse.i_me_method = X264_ME_ESA;
else if(VAR_0->me_method == ME_TESA)
x4->params.analyse.i_me_method = X264_ME_TESA;
else x4->params.analyse.i_me_method = X264_ME_HEX;
x4->params.analyse.i_me_range = VAR_0->me_range;
x4->params.analyse.i_subpel_refine = VAR_0->me_subpel_quality;
x4->params.analyse.b_bidir_me = VAR_0->bidir_refine > 0;
x4->params.analyse.b_bframe_rdo = VAR_0->flags2 & CODEC_FLAG2_BRDO;
x4->params.analyse.b_mixed_references =
VAR_0->flags2 & CODEC_FLAG2_MIXED_REFS;
x4->params.analyse.b_chroma_me = VAR_0->me_cmp & FF_CMP_CHROMA;
x4->params.analyse.b_transform_8x8 = VAR_0->flags2 & CODEC_FLAG2_8X8DCT;
x4->params.analyse.b_fast_pskip = VAR_0->flags2 & CODEC_FLAG2_FASTPSKIP;
x4->params.analyse.i_trellis = VAR_0->trellis;
x4->params.analyse.i_noise_reduction = VAR_0->noise_reduction;
if(VAR_0->level > 0) x4->params.i_level_idc = VAR_0->level;
x4->params.rc.f_rate_tolerance =
(float)VAR_0->bit_rate_tolerance/VAR_0->bit_rate;
if((VAR_0->rc_buffer_size != 0) &&
(VAR_0->rc_initial_buffer_occupancy <= VAR_0->rc_buffer_size)){
x4->params.rc.f_vbv_buffer_init =
(float)VAR_0->rc_initial_buffer_occupancy/VAR_0->rc_buffer_size;
}
else x4->params.rc.f_vbv_buffer_init = 0.9;
x4->params.rc.f_ip_factor = 1/fabs(VAR_0->i_quant_factor);
x4->params.rc.f_pb_factor = VAR_0->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = VAR_0->chromaoffset;
x4->params.rc.psz_rc_eq = VAR_0->rc_eq;
x4->params.analyse.b_psnr = VAR_0->flags & CODEC_FLAG_PSNR;
x4->params.i_log_level = X264_LOG_DEBUG;
x4->params.b_aud = VAR_0->flags2 & CODEC_FLAG2_AUD;
x4->params.i_threads = VAR_0->thread_count;
x4->params.b_interlaced = VAR_0->flags & CODEC_FLAG_INTERLACED_DCT;
if(VAR_0->flags & CODEC_FLAG_GLOBAL_HEADER){
x4->params.b_repeat_headers = 0;
}
x4->enc = x264_encoder_open(&x4->params);
if(!x4->enc)
return -1;
VAR_0->coded_frame = &x4->out_pic;
if(VAR_0->flags & CODEC_FLAG_GLOBAL_HEADER){
x264_nal_t *nal;
int VAR_1, VAR_2, VAR_3 = 0;
x264_encoder_headers(x4->enc, &nal, &VAR_1);
for(VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)
VAR_3 += 5 + nal[VAR_2].i_payload * 4 / 3;
VAR_0->extradata = av_malloc(VAR_3);
VAR_0->extradata_size = encode_nals(VAR_0->extradata, VAR_3, nal, VAR_1);
}
return 0;
}
| [
"FUNC_0(AVCodecContext *VAR_0)\n{",
"X264Context *x4 = VAR_0->priv_data;",
"x264_param_default(&x4->params);",
"x4->params.pf_log = X264_log;",
"x4->params.p_log_private = VAR_0;",
"x4->params.i_keyint_max = VAR_0->gop_size;",
"x4->params.rc.i_bitrate = VAR_0->bit_rate / 1000;",
"x4->params.rc.i_vbv_buffer_size = VAR_0->rc_buffer_size / 1000;",
"x4->params.rc.i_vbv_max_bitrate = VAR_0->rc_max_rate / 1000;",
"x4->params.rc.b_stat_write = VAR_0->flags & CODEC_FLAG_PASS1;",
"if(VAR_0->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;",
"else{",
"if(VAR_0->crf){",
"x4->params.rc.i_rc_method = X264_RC_CRF;",
"x4->params.rc.f_rf_constant = VAR_0->crf;",
"}else if(VAR_0->cqp > -1){",
"x4->params.rc.i_rc_method = X264_RC_CQP;",
"x4->params.rc.i_qp_constant = VAR_0->cqp;",
"}",
"}",
"if(!(VAR_0->crf || (VAR_0->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;",
"x4->params.i_bframe = VAR_0->max_b_frames;",
"x4->params.b_cabac = VAR_0->coder_type == FF_CODER_TYPE_AC;",
"x4->params.b_bframe_adaptive = VAR_0->b_frame_strategy;",
"x4->params.i_bframe_bias = VAR_0->bframebias;",
"x4->params.b_bframe_pyramid = VAR_0->flags2 & CODEC_FLAG2_BPYRAMID;",
"VAR_0->has_b_frames= VAR_0->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!VAR_0->max_b_frames;",
"x4->params.i_keyint_min = VAR_0->keyint_min;",
"if(x4->params.i_keyint_min > x4->params.i_keyint_max)\nx4->params.i_keyint_min = x4->params.i_keyint_max;",
"x4->params.i_scenecut_threshold = VAR_0->scenechange_threshold;",
"x4->params.b_deblocking_filter = VAR_0->flags & CODEC_FLAG_LOOP_FILTER;",
"x4->params.i_deblocking_filter_alphac0 = VAR_0->deblockalpha;",
"x4->params.i_deblocking_filter_beta = VAR_0->deblockbeta;",
"x4->params.rc.i_qp_min = VAR_0->qmin;",
"x4->params.rc.i_qp_max = VAR_0->qmax;",
"x4->params.rc.i_qp_step = VAR_0->max_qdiff;",
"x4->params.rc.f_qcompress = VAR_0->qcompress;",
"x4->params.rc.f_qblur = VAR_0->qblur;",
"x4->params.rc.f_complexity_blur = VAR_0->complexityblur;",
"x4->params.i_frame_reference = VAR_0->refs;",
"x4->params.i_width = VAR_0->width;",
"x4->params.i_height = VAR_0->height;",
"x4->params.vui.i_sar_width = VAR_0->sample_aspect_ratio.num;",
"x4->params.vui.i_sar_height = VAR_0->sample_aspect_ratio.den;",
"x4->params.i_fps_num = VAR_0->time_base.den;",
"x4->params.i_fps_den = VAR_0->time_base.num;",
"x4->params.analyse.inter = 0;",
"if(VAR_0->partitions){",
"if(VAR_0->partitions & X264_PART_I4X4)\nx4->params.analyse.inter |= X264_ANALYSE_I4x4;",
"if(VAR_0->partitions & X264_PART_I8X8)\nx4->params.analyse.inter |= X264_ANALYSE_I8x8;",
"if(VAR_0->partitions & X264_PART_P8X8)\nx4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;",
"if(VAR_0->partitions & X264_PART_P4X4)\nx4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;",
"if(VAR_0->partitions & X264_PART_B8X8)\nx4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;",
"}",
"x4->params.analyse.i_direct_mv_pred = VAR_0->directpred;",
"x4->params.analyse.b_weighted_bipred = VAR_0->flags2 & CODEC_FLAG2_WPRED;",
"if(VAR_0->me_method == ME_EPZS)\nx4->params.analyse.i_me_method = X264_ME_DIA;",
"else if(VAR_0->me_method == ME_HEX)\nx4->params.analyse.i_me_method = X264_ME_HEX;",
"else if(VAR_0->me_method == ME_UMH)\nx4->params.analyse.i_me_method = X264_ME_UMH;",
"else if(VAR_0->me_method == ME_FULL)\nx4->params.analyse.i_me_method = X264_ME_ESA;",
"else if(VAR_0->me_method == ME_TESA)\nx4->params.analyse.i_me_method = X264_ME_TESA;",
"else x4->params.analyse.i_me_method = X264_ME_HEX;",
"x4->params.analyse.i_me_range = VAR_0->me_range;",
"x4->params.analyse.i_subpel_refine = VAR_0->me_subpel_quality;",
"x4->params.analyse.b_bidir_me = VAR_0->bidir_refine > 0;",
"x4->params.analyse.b_bframe_rdo = VAR_0->flags2 & CODEC_FLAG2_BRDO;",
"x4->params.analyse.b_mixed_references =\nVAR_0->flags2 & CODEC_FLAG2_MIXED_REFS;",
"x4->params.analyse.b_chroma_me = VAR_0->me_cmp & FF_CMP_CHROMA;",
"x4->params.analyse.b_transform_8x8 = VAR_0->flags2 & CODEC_FLAG2_8X8DCT;",
"x4->params.analyse.b_fast_pskip = VAR_0->flags2 & CODEC_FLAG2_FASTPSKIP;",
"x4->params.analyse.i_trellis = VAR_0->trellis;",
"x4->params.analyse.i_noise_reduction = VAR_0->noise_reduction;",
"if(VAR_0->level > 0) x4->params.i_level_idc = VAR_0->level;",
"x4->params.rc.f_rate_tolerance =\n(float)VAR_0->bit_rate_tolerance/VAR_0->bit_rate;",
"if((VAR_0->rc_buffer_size != 0) &&\n(VAR_0->rc_initial_buffer_occupancy <= VAR_0->rc_buffer_size)){",
"x4->params.rc.f_vbv_buffer_init =\n(float)VAR_0->rc_initial_buffer_occupancy/VAR_0->rc_buffer_size;",
"}",
"else x4->params.rc.f_vbv_buffer_init = 0.9;",
"x4->params.rc.f_ip_factor = 1/fabs(VAR_0->i_quant_factor);",
"x4->params.rc.f_pb_factor = VAR_0->b_quant_factor;",
"x4->params.analyse.i_chroma_qp_offset = VAR_0->chromaoffset;",
"x4->params.rc.psz_rc_eq = VAR_0->rc_eq;",
"x4->params.analyse.b_psnr = VAR_0->flags & CODEC_FLAG_PSNR;",
"x4->params.i_log_level = X264_LOG_DEBUG;",
"x4->params.b_aud = VAR_0->flags2 & CODEC_FLAG2_AUD;",
"x4->params.i_threads = VAR_0->thread_count;",
"x4->params.b_interlaced = VAR_0->flags & CODEC_FLAG_INTERLACED_DCT;",
"if(VAR_0->flags & CODEC_FLAG_GLOBAL_HEADER){",
"x4->params.b_repeat_headers = 0;",
"}",
"x4->enc = x264_encoder_open(&x4->params);",
"if(!x4->enc)\nreturn -1;",
"VAR_0->coded_frame = &x4->out_pic;",
"if(VAR_0->flags & CODEC_FLAG_GLOBAL_HEADER){",
"x264_nal_t *nal;",
"int VAR_1, VAR_2, VAR_3 = 0;",
"x264_encoder_headers(x4->enc, &nal, &VAR_1);",
"for(VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)",
"VAR_3 += 5 + nal[VAR_2].i_payload * 4 / 3;",
"VAR_0->extradata = av_malloc(VAR_3);",
"VAR_0->extradata_size = encode_nals(VAR_0->extradata, VAR_3, nal, VAR_1);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
155
],
[
159
],
[
163,
165
],
[
167,
169
],
[
171,
173
],
[
175,
177
],
[
179,
181
],
[
183
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
215
],
[
219,
221
],
[
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
259
],
[
263
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277,
279
],
[
283
],
[
287
],
[
289
],
[
291
],
[
295
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
]
]
|
15,230 | int configure_filtergraph(FilterGraph *fg)
{
AVFilterInOut *inputs, *outputs, *cur;
int ret, i, simple = !fg->graph_desc;
const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
fg->graph_desc;
avfilter_graph_free(&fg->graph);
if (!(fg->graph = avfilter_graph_alloc()))
return AVERROR(ENOMEM);
if (simple) {
OutputStream *ost = fg->outputs[0]->ost;
char args[512];
AVDictionaryEntry *e = NULL;
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
args[0] = '\0';
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
AV_DICT_IGNORE_SUFFIX))) {
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
}
if (strlen(args))
args[strlen(args) - 1] = '\0';
fg->graph->resample_lavr_opts = av_strdup(args);
}
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
return ret;
if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have "
"exactly one input and output.\n", graph_desc);
return AVERROR(EINVAL);
}
for (cur = inputs, i = 0; cur; cur = cur->next, i++)
if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0)
return ret;
avfilter_inout_free(&inputs);
for (cur = outputs, i = 0; cur; cur = cur->next, i++)
configure_output_filter(fg, fg->outputs[i], cur);
avfilter_inout_free(&outputs);
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
return ret;
return 0;
}
| true | FFmpeg | 8b830ee9a26d47b138f12a82085cdb372f407f1e | int configure_filtergraph(FilterGraph *fg)
{
AVFilterInOut *inputs, *outputs, *cur;
int ret, i, simple = !fg->graph_desc;
const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
fg->graph_desc;
avfilter_graph_free(&fg->graph);
if (!(fg->graph = avfilter_graph_alloc()))
return AVERROR(ENOMEM);
if (simple) {
OutputStream *ost = fg->outputs[0]->ost;
char args[512];
AVDictionaryEntry *e = NULL;
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
args[0] = '\0';
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
AV_DICT_IGNORE_SUFFIX))) {
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
}
if (strlen(args))
args[strlen(args) - 1] = '\0';
fg->graph->resample_lavr_opts = av_strdup(args);
}
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
return ret;
if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have "
"exactly one input and output.\n", graph_desc);
return AVERROR(EINVAL);
}
for (cur = inputs, i = 0; cur; cur = cur->next, i++)
if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0)
return ret;
avfilter_inout_free(&inputs);
for (cur = outputs, i = 0; cur; cur = cur->next, i++)
configure_output_filter(fg, fg->outputs[i], cur);
avfilter_inout_free(&outputs);
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
return ret;
return 0;
}
| {
"code": [
" for (cur = outputs, i = 0; cur; cur = cur->next, i++)",
" configure_output_filter(fg, fg->outputs[i], cur);"
],
"line_no": [
87,
89
]
} | int FUNC_0(FilterGraph *VAR_0)
{
AVFilterInOut *inputs, *outputs, *cur;
int VAR_1, VAR_2, VAR_3 = !VAR_0->VAR_4;
const char *VAR_4 = VAR_3 ? VAR_0->outputs[0]->ost->avfilter :
VAR_0->VAR_4;
avfilter_graph_free(&VAR_0->graph);
if (!(VAR_0->graph = avfilter_graph_alloc()))
return AVERROR(ENOMEM);
if (VAR_3) {
OutputStream *ost = VAR_0->outputs[0]->ost;
char VAR_5[512];
AVDictionaryEntry *e = NULL;
snprintf(VAR_5, sizeof(VAR_5), "flags=0x%X", (unsigned)ost->sws_flags);
VAR_0->graph->scale_sws_opts = av_strdup(VAR_5);
VAR_5[0] = '\0';
while ((e = av_dict_get(VAR_0->outputs[0]->ost->resample_opts, "", e,
AV_DICT_IGNORE_SUFFIX))) {
av_strlcatf(VAR_5, sizeof(VAR_5), "%s=%s:", e->key, e->value);
}
if (strlen(VAR_5))
VAR_5[strlen(VAR_5) - 1] = '\0';
VAR_0->graph->resample_lavr_opts = av_strdup(VAR_5);
}
if ((VAR_1 = avfilter_graph_parse2(VAR_0->graph, VAR_4, &inputs, &outputs)) < 0)
return VAR_1;
if (VAR_3 && (!inputs || inputs->next || !outputs || outputs->next)) {
av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have "
"exactly one input and output.\n", VAR_4);
return AVERROR(EINVAL);
}
for (cur = inputs, VAR_2 = 0; cur; cur = cur->next, VAR_2++)
if ((VAR_1 = configure_input_filter(VAR_0, VAR_0->inputs[VAR_2], cur)) < 0)
return VAR_1;
avfilter_inout_free(&inputs);
for (cur = outputs, VAR_2 = 0; cur; cur = cur->next, VAR_2++)
configure_output_filter(VAR_0, VAR_0->outputs[VAR_2], cur);
avfilter_inout_free(&outputs);
if ((VAR_1 = avfilter_graph_config(VAR_0->graph, NULL)) < 0)
return VAR_1;
return 0;
}
| [
"int FUNC_0(FilterGraph *VAR_0)\n{",
"AVFilterInOut *inputs, *outputs, *cur;",
"int VAR_1, VAR_2, VAR_3 = !VAR_0->VAR_4;",
"const char *VAR_4 = VAR_3 ? VAR_0->outputs[0]->ost->avfilter :\nVAR_0->VAR_4;",
"avfilter_graph_free(&VAR_0->graph);",
"if (!(VAR_0->graph = avfilter_graph_alloc()))\nreturn AVERROR(ENOMEM);",
"if (VAR_3) {",
"OutputStream *ost = VAR_0->outputs[0]->ost;",
"char VAR_5[512];",
"AVDictionaryEntry *e = NULL;",
"snprintf(VAR_5, sizeof(VAR_5), \"flags=0x%X\", (unsigned)ost->sws_flags);",
"VAR_0->graph->scale_sws_opts = av_strdup(VAR_5);",
"VAR_5[0] = '\\0';",
"while ((e = av_dict_get(VAR_0->outputs[0]->ost->resample_opts, \"\", e,\nAV_DICT_IGNORE_SUFFIX))) {",
"av_strlcatf(VAR_5, sizeof(VAR_5), \"%s=%s:\", e->key, e->value);",
"}",
"if (strlen(VAR_5))\nVAR_5[strlen(VAR_5) - 1] = '\\0';",
"VAR_0->graph->resample_lavr_opts = av_strdup(VAR_5);",
"}",
"if ((VAR_1 = avfilter_graph_parse2(VAR_0->graph, VAR_4, &inputs, &outputs)) < 0)\nreturn VAR_1;",
"if (VAR_3 && (!inputs || inputs->next || !outputs || outputs->next)) {",
"av_log(NULL, AV_LOG_ERROR, \"Simple filtergraph '%s' does not have \"\n\"exactly one input and output.\\n\", VAR_4);",
"return AVERROR(EINVAL);",
"}",
"for (cur = inputs, VAR_2 = 0; cur; cur = cur->next, VAR_2++)",
"if ((VAR_1 = configure_input_filter(VAR_0, VAR_0->inputs[VAR_2], cur)) < 0)\nreturn VAR_1;",
"avfilter_inout_free(&inputs);",
"for (cur = outputs, VAR_2 = 0; cur; cur = cur->next, VAR_2++)",
"configure_output_filter(VAR_0, VAR_0->outputs[VAR_2], cur);",
"avfilter_inout_free(&outputs);",
"if ((VAR_1 = avfilter_graph_config(VAR_0->graph, NULL)) < 0)\nreturn VAR_1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
59,
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
79,
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
101
],
[
103
]
]
|
15,231 | inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(isGray(srcFormat))
{
return;
}
#ifdef HAVE_MMX
// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else // Fast Bilinear upscale / crap downscale
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %1, %%"REG_D" \n\t" // buf1
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
// printf("%d %d %d\n", dstWidth, i, srcW);
dst[i] = src1[srcW-1]*128;
dst[i+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
int xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_b", %%"REG_b" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // 2*xalpha
ASMALIGN16
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t" //src[xx]
"movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"movzbl (%5, %%"REG_b"), %%edi \n\t" //src[xx]
"movzbl 1(%5, %%"REG_b"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
"adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
/* GCC-3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC-4.0 */
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
} //if MMX2 can't be used
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif
}
}
| true | FFmpeg | 065ee1ec325ed7d34acf13d0bf319c1c6b457e21 | inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(isGray(srcFormat))
{
return;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
dst[i] = src1[srcW-1]*128;
dst[i+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
int xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"movzbl (%5, %%"REG_b"), %%edi \n\t"
"movzbl 1(%5, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
}
| {
"code": [
"\tint xInc_mask = xInc & 0xffff; "
],
"line_no": [
281
]
} | inline static void FUNC_0(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_UYVY)
{
FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR32)
{
FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR24)
{
FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR16)
{
FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_BGR15)
{
FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB32)
{
FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(srcFormat==IMGFMT_RGB24)
{
FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if(isGray(srcFormat))
{
return;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
FUNC_0(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int VAR_0;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--)
{
dst[VAR_0] = src1[srcW-1]*128;
dst[VAR_0+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
int xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_b"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"movzbl (%5, %%"REG_b"), %%edi \n\t"
"movzbl 1(%5, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int VAR_0;
unsigned int VAR_1=0;
for(VAR_0=0;VAR_0<dstWidth;VAR_0++)
{
register unsigned int xx=VAR_1>>16;
register unsigned int xalpha=(VAR_1&0xFFFF)>>9;
dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[VAR_0+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
VAR_1+=xInc;
}
#endif
}
}
| [
"inline static void FUNC_0(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,\nint srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,\nint16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,\nint srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,\nint32_t *mmx2FilterPos)\n{",
"if(srcFormat==IMGFMT_YUY2)\n{",
"FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_UYVY)\n{",
"FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_BGR32)\n{",
"FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_BGR24)\n{",
"FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_BGR16)\n{",
"FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_BGR15)\n{",
"FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_RGB32)\n{",
"FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(srcFormat==IMGFMT_RGB24)\n{",
"FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if(isGray(srcFormat))\n{",
"return;",
"}",
"#ifdef HAVE_MMX\nif(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))\n#else\nif(!(flags&SWS_FAST_BILINEAR))\n#endif\n{",
"FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"FUNC_0(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"}",
"else\n{",
"#if defined(ARCH_X86) || defined(ARCH_X86_64)\n#ifdef HAVE_MMX2\nint VAR_0;",
"if(canMMX2BeUsed)\n{",
"asm volatile(\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"mov %0, %%\"REG_c\"\t\t\\n\\t\"\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"mov %2, %%\"REG_d\"\t\t\\n\\t\"\n\"mov %3, %%\"REG_b\"\t\t\\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\nPREFETCH\" (%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 32(%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 64(%%\"REG_c\")\t\t\\n\\t\"\n#ifdef ARCH_X86_64\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi\t\\n\\t\"\\\n\"call *%4\t\t\t\\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi\\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\"\t\\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\"\t\\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\\\n#else\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi\t\\n\\t\"\\\n\"call *%4\t\t\t\\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\"\\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\"\t\\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\\\n#endif\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\n\"mov %5, %%\"REG_c\"\t\t\\n\\t\"\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"add $4096, %%\"REG_D\"\t\t\\n\\t\"\nPREFETCH\" (%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 32(%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 64(%%\"REG_c\")\t\t\\n\\t\"\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n:: \"m\" (src1), \"m\" (dst), \"m\" (mmx2Filter), \"m\" (mmx2FilterPos),\n\"m\" (funnyUVCode), \"m\" (src2)\n: \"%\"REG_a, \"%\"REG_b, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n);",
"for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--)",
"{",
"dst[VAR_0] = src1[srcW-1]*128;",
"dst[VAR_0+2048] = src2[srcW-1]*128;",
"}",
"}",
"else\n{",
"#endif\nlong xInc_shr16 = (long) (xInc >> 16);",
"int xInc_mask = xInc & 0xffff;",
"asm volatile(\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\n\"xor %%\"REG_b\", %%\"REG_b\"\t\t\\n\\t\"\n\"xorl %%ecx, %%ecx\t\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\n\"mov %0, %%\"REG_S\"\t\t\\n\\t\"\n\"movzbl (%%\"REG_S\", %%\"REG_b\"), %%edi\t\\n\\t\"\n\"movzbl 1(%%\"REG_S\", %%\"REG_b\"), %%esi\t\\n\\t\"\n\"subl %%edi, %%esi\t\t\\n\\t\" - src[xx]\n\"imull %%ecx, %%esi\t\t\\n\\t\"\n\"shll $16, %%edi\t\t\\n\\t\"\n\"addl %%edi, %%esi\t\t\\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"shrl $9, %%esi\t\t\t\\n\\t\"\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2)\\n\\t\"\n\"movzbl (%5, %%\"REG_b\"), %%edi\t\\n\\t\"\n\"movzbl 1(%5, %%\"REG_b\"), %%esi\t\\n\\t\"\n\"subl %%edi, %%esi\t\t\\n\\t\" - src[xx]\n\"imull %%ecx, %%esi\t\t\\n\\t\"\n\"shll $16, %%edi\t\t\\n\\t\"\n\"addl %%edi, %%esi\t\t\\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"shrl $9, %%esi\t\t\t\\n\\t\"\n\"movw %%si, 4096(%%\"REG_D\", %%\"REG_a\", 2)\\n\\t\"\n\"addw %4, %%cx\t\t\t\\n\\t\"\n\"adc %3, %%\"REG_b\"\t\t\\n\\t\"\n\"add $1, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %2, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))\n:: \"m\" (src1), \"m\" (dst), \"g\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#endif\n\"r\" (src2)\n: \"%\"REG_a, \"%\"REG_b, \"%ecx\", \"%\"REG_D, \"%esi\"\n);",
"#ifdef HAVE_MMX2\n}",
"#endif\n#else\nint VAR_0;",
"unsigned int VAR_1=0;",
"for(VAR_0=0;VAR_0<dstWidth;VAR_0++)",
"{",
"register unsigned int xx=VAR_1>>16;",
"register unsigned int xalpha=(VAR_1&0xFFFF)>>9;",
"dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);",
"dst[VAR_0+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);",
"VAR_1+=xInc;",
"}",
"#endif\n}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
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
],
[
119,
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,
175,
179,
181,
183,
185,
187,
189,
191,
195,
199,
201,
203,
205,
207,
209,
213,
217,
219,
221,
223,
225,
227,
229,
231,
233,
235,
237,
241,
243,
245,
247,
251,
253,
255,
257
],
[
259
],
[
261
],
[
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,
317,
319,
321,
323,
325,
327,
329,
331,
333,
337,
339,
341,
343,
345,
353,
355,
357,
359,
361,
363,
365,
367
],
[
369,
371
],
[
373,
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
401
],
[
403
],
[
405,
407
],
[
409
]
]
|
15,232 | static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
char *buffer;
int ret;
if (strncmp(name, "user.virtfs.", 12) == 0) {
/*
* Don't allow fetch of user.virtfs namesapce
* in case of mapped security
*/
errno = EACCES;
return -1;
}
buffer = rpath(ctx, path);
ret = lsetxattr(buffer, name, value, size, flags);
g_free(buffer);
return ret;
}
| true | qemu | 3e36aba757f76673007a80b3cd56a4062c2e3462 | static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
char *buffer;
int ret;
if (strncmp(name, "user.virtfs.", 12) == 0) {
errno = EACCES;
return -1;
}
buffer = rpath(ctx, path);
ret = lsetxattr(buffer, name, value, size, flags);
g_free(buffer);
return ret;
}
| {
"code": [
" char *buffer;",
" int ret;",
" buffer = rpath(ctx, path);",
" g_free(buffer);",
" return ret;",
" char *buffer;",
" int ret;",
" buffer = rpath(ctx, path);",
" g_free(buffer);",
" return ret;",
" char *buffer;",
" int ret;",
" buffer = rpath(ctx, path);",
" ret = lsetxattr(buffer, name, value, size, flags);",
" g_free(buffer);",
" return ret;",
" char *buffer;",
" buffer = rpath(ctx, path);",
" ret = lsetxattr(buffer, name, value, size, flags);",
" g_free(buffer);"
],
"line_no": [
7,
9,
29,
33,
35,
7,
9,
29,
33,
35,
7,
9,
29,
31,
33,
35,
7,
29,
31,
33
]
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1, const char *VAR_2,
void *VAR_3, size_t VAR_4, int VAR_5)
{
char *VAR_6;
int VAR_7;
if (strncmp(VAR_2, "user.virtfs.", 12) == 0) {
errno = EACCES;
return -1;
}
VAR_6 = rpath(VAR_0, VAR_1);
VAR_7 = lsetxattr(VAR_6, VAR_2, VAR_3, VAR_4, VAR_5);
g_free(VAR_6);
return VAR_7;
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1, const char *VAR_2,\nvoid *VAR_3, size_t VAR_4, int VAR_5)\n{",
"char *VAR_6;",
"int VAR_7;",
"if (strncmp(VAR_2, \"user.virtfs.\", 12) == 0) {",
"errno = EACCES;",
"return -1;",
"}",
"VAR_6 = rpath(VAR_0, VAR_1);",
"VAR_7 = lsetxattr(VAR_6, VAR_2, VAR_3, VAR_4, VAR_5);",
"g_free(VAR_6);",
"return VAR_7;",
"}"
]
| [
0,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
]
|
15,233 | static void gen_tlbiva(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(ctx->opcode)]);
tcg_temp_free(t0);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_tlbiva(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(ctx->opcode)]);
tcg_temp_free(t0);
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
15,
7,
13,
15,
7,
13,
15,
7,
15,
5,
9,
13,
29,
5,
9,
13,
29,
29,
5,
9,
13,
7,
13,
15,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
13,
29,
7,
15,
29,
7,
13,
15,
29,
7,
15,
29,
7,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
13,
29,
13,
29,
13,
29,
13,
29,
5,
7,
9,
13,
15,
29,
7,
13,
15,
29,
5,
7,
9,
13,
15,
29,
5,
7,
9,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
5,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29,
7,
13,
15,
29
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(VAR_0, t0);
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);
tcg_temp_free(t0);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nTCGv t0;",
"if (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"t0 = tcg_temp_new();",
"gen_addr_reg_index(VAR_0, t0);",
"gen_helper_tlbiva(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);",
"tcg_temp_free(t0);",
"#endif\n}"
]
| [
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1
]
| [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
]
]
|
15,234 | static void hdcd_reset(hdcd_state_t *state, unsigned rate)
{
int i;
state->window = 0;
state->readahead = 32;
state->arg = 0;
state->control = 0;
state->running_gain = 0;
state->sustain = 0;
state->sustain_reset = rate * 10;
state->code_counterA = 0;
state->code_counterA_almost = 0;
state->code_counterB = 0;
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
state->count_sustain_expired = -1;
}
| false | FFmpeg | d574e22659bd51cdf16723a204fef65a9e783f1d | static void hdcd_reset(hdcd_state_t *state, unsigned rate)
{
int i;
state->window = 0;
state->readahead = 32;
state->arg = 0;
state->control = 0;
state->running_gain = 0;
state->sustain = 0;
state->sustain_reset = rate * 10;
state->code_counterA = 0;
state->code_counterA_almost = 0;
state->code_counterB = 0;
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
state->count_sustain_expired = -1;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(hdcd_state_t *VAR_0, unsigned VAR_1)
{
int VAR_2;
VAR_0->window = 0;
VAR_0->readahead = 32;
VAR_0->arg = 0;
VAR_0->control = 0;
VAR_0->running_gain = 0;
VAR_0->sustain = 0;
VAR_0->sustain_reset = VAR_1 * 10;
VAR_0->code_counterA = 0;
VAR_0->code_counterA_almost = 0;
VAR_0->code_counterB = 0;
VAR_0->code_counterB_checkfails = 0;
VAR_0->code_counterC = 0;
VAR_0->code_counterC_unmatched = 0;
VAR_0->count_peak_extend = 0;
VAR_0->count_transient_filter = 0;
for(VAR_2 = 0; VAR_2 < 16; VAR_2++) VAR_0->gain_counts[VAR_2] = 0;
VAR_0->max_gain = 0;
VAR_0->count_sustain_expired = -1;
}
| [
"static void FUNC_0(hdcd_state_t *VAR_0, unsigned VAR_1)\n{",
"int VAR_2;",
"VAR_0->window = 0;",
"VAR_0->readahead = 32;",
"VAR_0->arg = 0;",
"VAR_0->control = 0;",
"VAR_0->running_gain = 0;",
"VAR_0->sustain = 0;",
"VAR_0->sustain_reset = VAR_1 * 10;",
"VAR_0->code_counterA = 0;",
"VAR_0->code_counterA_almost = 0;",
"VAR_0->code_counterB = 0;",
"VAR_0->code_counterB_checkfails = 0;",
"VAR_0->code_counterC = 0;",
"VAR_0->code_counterC_unmatched = 0;",
"VAR_0->count_peak_extend = 0;",
"VAR_0->count_transient_filter = 0;",
"for(VAR_2 = 0; VAR_2 < 16; VAR_2++) VAR_0->gain_counts[VAR_2] = 0;",
"VAR_0->max_gain = 0;",
"VAR_0->count_sustain_expired = -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
]
|
15,235 | static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
{
AResampleContext *aresample = inlink->dst->priv;
const int n_in = insamplesref->nb_samples;
int64_t delay;
int n_out = n_in * aresample->ratio + 32;
AVFilterLink *const outlink = inlink->dst->outputs[0];
AVFrame *outsamplesref;
int ret;
delay = swr_get_delay(aresample->swr, outlink->sample_rate);
if (delay > 0)
n_out += FFMIN(delay, FFMAX(4096, n_out));
outsamplesref = ff_get_audio_buffer(outlink, n_out);
if(!outsamplesref)
return AVERROR(ENOMEM);
av_frame_copy_props(outsamplesref, insamplesref);
outsamplesref->format = outlink->format;
av_frame_set_channels(outsamplesref, outlink->channels);
outsamplesref->channel_layout = outlink->channel_layout;
outsamplesref->sample_rate = outlink->sample_rate;
if(insamplesref->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts =
outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate);
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
(void *)insamplesref->extended_data, n_in);
if (n_out <= 0) {
av_frame_free(&outsamplesref);
av_frame_free(&insamplesref);
return 0;
}
aresample->more_data = outsamplesref->nb_samples == n_out; // Indicate that there is probably more data in our buffers
outsamplesref->nb_samples = n_out;
ret = ff_filter_frame(outlink, outsamplesref);
aresample->req_fullfilled= 1;
av_frame_free(&insamplesref);
return ret;
}
| false | FFmpeg | 4982130d5a7babcb4b2e208fca2c745de7e10658 | static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
{
AResampleContext *aresample = inlink->dst->priv;
const int n_in = insamplesref->nb_samples;
int64_t delay;
int n_out = n_in * aresample->ratio + 32;
AVFilterLink *const outlink = inlink->dst->outputs[0];
AVFrame *outsamplesref;
int ret;
delay = swr_get_delay(aresample->swr, outlink->sample_rate);
if (delay > 0)
n_out += FFMIN(delay, FFMAX(4096, n_out));
outsamplesref = ff_get_audio_buffer(outlink, n_out);
if(!outsamplesref)
return AVERROR(ENOMEM);
av_frame_copy_props(outsamplesref, insamplesref);
outsamplesref->format = outlink->format;
av_frame_set_channels(outsamplesref, outlink->channels);
outsamplesref->channel_layout = outlink->channel_layout;
outsamplesref->sample_rate = outlink->sample_rate;
if(insamplesref->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts =
outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate);
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
(void *)insamplesref->extended_data, n_in);
if (n_out <= 0) {
av_frame_free(&outsamplesref);
av_frame_free(&insamplesref);
return 0;
}
aresample->more_data = outsamplesref->nb_samples == n_out;
outsamplesref->nb_samples = n_out;
ret = ff_filter_frame(outlink, outsamplesref);
aresample->req_fullfilled= 1;
av_frame_free(&insamplesref);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{
AResampleContext *aresample = VAR_0->dst->priv;
const int VAR_2 = VAR_1->nb_samples;
int64_t delay;
int VAR_3 = VAR_2 * aresample->ratio + 32;
AVFilterLink *const outlink = VAR_0->dst->outputs[0];
AVFrame *outsamplesref;
int VAR_4;
delay = swr_get_delay(aresample->swr, outlink->sample_rate);
if (delay > 0)
VAR_3 += FFMIN(delay, FFMAX(4096, VAR_3));
outsamplesref = ff_get_audio_buffer(outlink, VAR_3);
if(!outsamplesref)
return AVERROR(ENOMEM);
av_frame_copy_props(outsamplesref, VAR_1);
outsamplesref->format = outlink->format;
av_frame_set_channels(outsamplesref, outlink->channels);
outsamplesref->channel_layout = outlink->channel_layout;
outsamplesref->sample_rate = outlink->sample_rate;
if(VAR_1->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(VAR_1->pts, VAR_0->time_base.num * (int64_t)outlink->sample_rate * VAR_0->sample_rate, VAR_0->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts =
outsamplesref->pts = ROUNDED_DIV(outpts, VAR_0->sample_rate);
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
VAR_3 = swr_convert(aresample->swr, outsamplesref->extended_data, VAR_3,
(void *)VAR_1->extended_data, VAR_2);
if (VAR_3 <= 0) {
av_frame_free(&outsamplesref);
av_frame_free(&VAR_1);
return 0;
}
aresample->more_data = outsamplesref->nb_samples == VAR_3;
outsamplesref->nb_samples = VAR_3;
VAR_4 = ff_filter_frame(outlink, outsamplesref);
aresample->req_fullfilled= 1;
av_frame_free(&VAR_1);
return VAR_4;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)\n{",
"AResampleContext *aresample = VAR_0->dst->priv;",
"const int VAR_2 = VAR_1->nb_samples;",
"int64_t delay;",
"int VAR_3 = VAR_2 * aresample->ratio + 32;",
"AVFilterLink *const outlink = VAR_0->dst->outputs[0];",
"AVFrame *outsamplesref;",
"int VAR_4;",
"delay = swr_get_delay(aresample->swr, outlink->sample_rate);",
"if (delay > 0)\nVAR_3 += FFMIN(delay, FFMAX(4096, VAR_3));",
"outsamplesref = ff_get_audio_buffer(outlink, VAR_3);",
"if(!outsamplesref)\nreturn AVERROR(ENOMEM);",
"av_frame_copy_props(outsamplesref, VAR_1);",
"outsamplesref->format = outlink->format;",
"av_frame_set_channels(outsamplesref, outlink->channels);",
"outsamplesref->channel_layout = outlink->channel_layout;",
"outsamplesref->sample_rate = outlink->sample_rate;",
"if(VAR_1->pts != AV_NOPTS_VALUE) {",
"int64_t inpts = av_rescale(VAR_1->pts, VAR_0->time_base.num * (int64_t)outlink->sample_rate * VAR_0->sample_rate, VAR_0->time_base.den);",
"int64_t outpts= swr_next_pts(aresample->swr, inpts);",
"aresample->next_pts =\noutsamplesref->pts = ROUNDED_DIV(outpts, VAR_0->sample_rate);",
"} else {",
"outsamplesref->pts = AV_NOPTS_VALUE;",
"}",
"VAR_3 = swr_convert(aresample->swr, outsamplesref->extended_data, VAR_3,\n(void *)VAR_1->extended_data, VAR_2);",
"if (VAR_3 <= 0) {",
"av_frame_free(&outsamplesref);",
"av_frame_free(&VAR_1);",
"return 0;",
"}",
"aresample->more_data = outsamplesref->nb_samples == VAR_3;",
"outsamplesref->nb_samples = VAR_3;",
"VAR_4 = ff_filter_frame(outlink, outsamplesref);",
"aresample->req_fullfilled= 1;",
"av_frame_free(&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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
]
|
15,236 | int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int samples_in_chunk = 0;
int size = pkt->size, ret = 0;
uint8_t *reformatted_data = NULL;
if (trk->entry) {
int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts;
if (duration < 0 || duration > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
duration, pkt->dts
);
pkt->dts = trk->cluster[trk->entry - 1].dts + 1;
pkt->pts = AV_NOPTS_VALUE;
}
if (pkt->duration < 0) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration);
return AVERROR(EINVAL);
}
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
int ret;
if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
if (mov->frag_interleave && mov->fragments > 0) {
if (trk->entry - trk->entries_flushed >= mov->frag_interleave) {
if ((ret = mov_flush_fragment_interleaving(s, trk)) < 0)
return ret;
}
}
if (!trk->mdat_buf) {
if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0)
return ret;
}
pb = trk->mdat_buf;
} else {
if (!mov->mdat_buf) {
if ((ret = avio_open_dyn_buf(&mov->mdat_buf)) < 0)
return ret;
}
pb = mov->mdat_buf;
}
}
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
/* We must find out how many AMR blocks there are in one packet */
static const uint16_t packed_size[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
int len = 0;
while (len < size && samples_in_chunk < 100) {
len += packed_size[(pkt->data[len] >> 3) & 0x0F];
samples_in_chunk++;
}
if (samples_in_chunk > 1) {
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
} else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
samples_in_chunk = enc->frame_size;
} else if (trk->sample_size)
samples_in_chunk = size / trk->sample_size;
else
samples_in_chunk = 1;
/* copy extradata if it exists */
if (trk->vos_len == 0 && enc->extradata_size > 0 &&
!TAG_IS_AVCI(trk->tag) &&
(enc->codec_id != AV_CODEC_ID_DNXHD)) {
trk->vos_len = enc->extradata_size;
trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, enc->extradata, trk->vos_len);
}
if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
"use the audio bitstream filter 'aac_adtstoasc' to fix it "
"('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
return -1;
}
av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
}
if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {
/* from x264 or from bytestream h264 */
/* nal reformating needed */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data,
&size);
avio_write(pb, reformatted_data, size);
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
size = ff_mov_cenc_avc_parse_nal_units(&trk->cenc, pb, pkt->data, size);
if (size < 0) {
ret = size;
goto err;
}
} else {
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
}
}
} else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
/* extradata is Annex B, assume the bitstream is too and convert it */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL);
avio_write(pb, reformatted_data, size);
} else {
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
}
#if CONFIG_AC3_PARSER
} else if (enc->codec_id == AV_CODEC_ID_EAC3) {
size = handle_eac3(mov, pkt, trk);
if (size < 0)
return size;
else if (!size)
goto end;
avio_write(pb, pkt->data, size);
#endif
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) {
int nal_size_length = (enc->extradata[4] & 0x3) + 1;
ret = ff_mov_cenc_avc_write_nal_units(s, &trk->cenc, nal_size_length, pb, pkt->data, size);
} else {
ret = ff_mov_cenc_write_packet(&trk->cenc, pb, pkt->data, size);
}
if (ret) {
goto err;
}
} else {
avio_write(pb, pkt->data, size);
}
}
if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
/* copy frame to create needed atoms */
trk->vos_len = size;
trk->vos_data = av_malloc(size);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, pkt->data, size);
}
if (trk->entry >= trk->cluster_capacity) {
unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
if (av_reallocp_array(&trk->cluster, new_capacity,
sizeof(*trk->cluster))) {
ret = AVERROR(ENOMEM);
goto err;
}
trk->cluster_capacity = new_capacity;
}
trk->cluster[trk->entry].pos = avio_tell(pb) - size;
trk->cluster[trk->entry].samples_in_chunk = samples_in_chunk;
trk->cluster[trk->entry].chunkNum = 0;
trk->cluster[trk->entry].size = size;
trk->cluster[trk->entry].entries = samples_in_chunk;
trk->cluster[trk->entry].dts = pkt->dts;
if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {
if (!trk->frag_discont) {
/* First packet of a new fragment. We already wrote the duration
* of the last packet of the previous fragment based on track_duration,
* which might not exactly match our dts. Therefore adjust the dts
* of this packet to be what the previous packets duration implies. */
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
/* We also may have written the pts and the corresponding duration
* in sidx/tfrf/tfxd tags; make sure the sidx pts and duration match up with
* the next fragment. This means the cts of the first sample must
* be the same in all fragments. */
if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
/* New fragment, but discontinuous from previous fragments.
* Pretend the duration sum of the earlier fragments is
* pkt->dts - trk->start_dts. */
trk->frag_start = pkt->dts - trk->start_dts;
trk->end_pts = AV_NOPTS_VALUE;
trk->frag_discont = 0;
}
}
if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist &&
s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
/* Not using edit lists and shifting the first track to start from zero.
* If the other streams start from a later timestamp, we won't be able
* to signal the difference in starting time without an edit list.
* Thus move the timestamp for this first sample to 0, increasing
* its duration instead. */
trk->cluster[trk->entry].dts = trk->start_dts = 0;
}
if (trk->start_dts == AV_NOPTS_VALUE) {
trk->start_dts = pkt->dts;
if (trk->frag_discont) {
if (mov->use_editlist) {
/* Pretend the whole stream started at pts=0, with earlier fragments
* already written. If the stream started at pts=0, the duration sum
* of earlier fragments would have been pkt->pts. */
trk->frag_start = pkt->pts;
trk->start_dts = pkt->dts - pkt->pts;
} else {
/* Pretend the whole stream started at dts=0, with earlier fragments
* already written, with a duration summing up to pkt->dts. */
trk->frag_start = pkt->dts;
trk->start_dts = 0;
}
trk->frag_discont = 0;
} else if (pkt->dts && mov->moov_written)
av_log(s, AV_LOG_WARNING,
"Track %d starts with a nonzero dts %"PRId64", while the moov "
"already has been written. Set the delay_moov flag to handle "
"this case.\n",
pkt->stream_index, pkt->dts);
}
trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
trk->last_sample_is_subtitle_end = 0;
if (pkt->pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_WARNING, "pts has no value\n");
pkt->pts = pkt->dts;
}
if (pkt->dts != pkt->pts)
trk->flags |= MOV_TRACK_CTTS;
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].flags = 0;
if (trk->start_cts == AV_NOPTS_VALUE)
trk->start_cts = pkt->pts - pkt->dts;
if (trk->end_pts == AV_NOPTS_VALUE)
trk->end_pts = trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts + pkt->duration;
else
trk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts +
pkt->duration);
if (enc->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(pkt, trk);
} else if (pkt->flags & AV_PKT_FLAG_KEY) {
if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
trk->entry > 0) { // force sync sample for the first key frame
mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags);
if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
trk->flags |= MOV_TRACK_STPS;
} else {
trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE;
}
if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE)
trk->has_keyframes++;
}
trk->entry++;
trk->sample_count += samples_in_chunk;
mov->mdat_size += size;
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
reformatted_data, size);
end:
err:
av_free(reformatted_data);
return ret;
}
| false | FFmpeg | 6e249466cc6bd5b17d6e8cbd9a84a636cc92fd60 | int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int samples_in_chunk = 0;
int size = pkt->size, ret = 0;
uint8_t *reformatted_data = NULL;
if (trk->entry) {
int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts;
if (duration < 0 || duration > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
duration, pkt->dts
);
pkt->dts = trk->cluster[trk->entry - 1].dts + 1;
pkt->pts = AV_NOPTS_VALUE;
}
if (pkt->duration < 0) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration);
return AVERROR(EINVAL);
}
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
int ret;
if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
if (mov->frag_interleave && mov->fragments > 0) {
if (trk->entry - trk->entries_flushed >= mov->frag_interleave) {
if ((ret = mov_flush_fragment_interleaving(s, trk)) < 0)
return ret;
}
}
if (!trk->mdat_buf) {
if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0)
return ret;
}
pb = trk->mdat_buf;
} else {
if (!mov->mdat_buf) {
if ((ret = avio_open_dyn_buf(&mov->mdat_buf)) < 0)
return ret;
}
pb = mov->mdat_buf;
}
}
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
static const uint16_t packed_size[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
int len = 0;
while (len < size && samples_in_chunk < 100) {
len += packed_size[(pkt->data[len] >> 3) & 0x0F];
samples_in_chunk++;
}
if (samples_in_chunk > 1) {
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
} else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
samples_in_chunk = enc->frame_size;
} else if (trk->sample_size)
samples_in_chunk = size / trk->sample_size;
else
samples_in_chunk = 1;
if (trk->vos_len == 0 && enc->extradata_size > 0 &&
!TAG_IS_AVCI(trk->tag) &&
(enc->codec_id != AV_CODEC_ID_DNXHD)) {
trk->vos_len = enc->extradata_size;
trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, enc->extradata, trk->vos_len);
}
if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
"use the audio bitstream filter 'aac_adtstoasc' to fix it "
"('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
return -1;
}
av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
}
if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data,
&size);
avio_write(pb, reformatted_data, size);
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
size = ff_mov_cenc_avc_parse_nal_units(&trk->cenc, pb, pkt->data, size);
if (size < 0) {
ret = size;
goto err;
}
} else {
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
}
}
} else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL);
avio_write(pb, reformatted_data, size);
} else {
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
}
#if CONFIG_AC3_PARSER
} else if (enc->codec_id == AV_CODEC_ID_EAC3) {
size = handle_eac3(mov, pkt, trk);
if (size < 0)
return size;
else if (!size)
goto end;
avio_write(pb, pkt->data, size);
#endif
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) {
int nal_size_length = (enc->extradata[4] & 0x3) + 1;
ret = ff_mov_cenc_avc_write_nal_units(s, &trk->cenc, nal_size_length, pb, pkt->data, size);
} else {
ret = ff_mov_cenc_write_packet(&trk->cenc, pb, pkt->data, size);
}
if (ret) {
goto err;
}
} else {
avio_write(pb, pkt->data, size);
}
}
if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
trk->vos_len = size;
trk->vos_data = av_malloc(size);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, pkt->data, size);
}
if (trk->entry >= trk->cluster_capacity) {
unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
if (av_reallocp_array(&trk->cluster, new_capacity,
sizeof(*trk->cluster))) {
ret = AVERROR(ENOMEM);
goto err;
}
trk->cluster_capacity = new_capacity;
}
trk->cluster[trk->entry].pos = avio_tell(pb) - size;
trk->cluster[trk->entry].samples_in_chunk = samples_in_chunk;
trk->cluster[trk->entry].chunkNum = 0;
trk->cluster[trk->entry].size = size;
trk->cluster[trk->entry].entries = samples_in_chunk;
trk->cluster[trk->entry].dts = pkt->dts;
if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {
if (!trk->frag_discont) {
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
trk->frag_start = pkt->dts - trk->start_dts;
trk->end_pts = AV_NOPTS_VALUE;
trk->frag_discont = 0;
}
}
if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist &&
s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
trk->cluster[trk->entry].dts = trk->start_dts = 0;
}
if (trk->start_dts == AV_NOPTS_VALUE) {
trk->start_dts = pkt->dts;
if (trk->frag_discont) {
if (mov->use_editlist) {
trk->frag_start = pkt->pts;
trk->start_dts = pkt->dts - pkt->pts;
} else {
trk->frag_start = pkt->dts;
trk->start_dts = 0;
}
trk->frag_discont = 0;
} else if (pkt->dts && mov->moov_written)
av_log(s, AV_LOG_WARNING,
"Track %d starts with a nonzero dts %"PRId64", while the moov "
"already has been written. Set the delay_moov flag to handle "
"this case.\n",
pkt->stream_index, pkt->dts);
}
trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
trk->last_sample_is_subtitle_end = 0;
if (pkt->pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_WARNING, "pts has no value\n");
pkt->pts = pkt->dts;
}
if (pkt->dts != pkt->pts)
trk->flags |= MOV_TRACK_CTTS;
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].flags = 0;
if (trk->start_cts == AV_NOPTS_VALUE)
trk->start_cts = pkt->pts - pkt->dts;
if (trk->end_pts == AV_NOPTS_VALUE)
trk->end_pts = trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts + pkt->duration;
else
trk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts +
pkt->duration);
if (enc->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(pkt, trk);
} else if (pkt->flags & AV_PKT_FLAG_KEY) {
if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
trk->entry > 0) {
mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags);
if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
trk->flags |= MOV_TRACK_STPS;
} else {
trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE;
}
if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE)
trk->has_keyframes++;
}
trk->entry++;
trk->sample_count += samples_in_chunk;
mov->mdat_size += size;
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
reformatted_data, size);
end:
err:
av_free(reformatted_data);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
MOVMuxContext *mov = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
MOVTrack *trk = &mov->tracks[VAR_1->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int VAR_2 = 0;
int VAR_3 = VAR_1->VAR_3, VAR_5 = 0;
uint8_t *reformatted_data = NULL;
if (trk->entry) {
int64_t duration = VAR_1->dts - trk->cluster[trk->entry - 1].dts;
if (duration < 0 || duration > INT_MAX) {
av_log(VAR_0, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
duration, VAR_1->dts
);
VAR_1->dts = trk->cluster[trk->entry - 1].dts + 1;
VAR_1->pts = AV_NOPTS_VALUE;
}
if (VAR_1->duration < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", VAR_1->duration);
return AVERROR(EINVAL);
}
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
int VAR_5;
if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
if (mov->frag_interleave && mov->fragments > 0) {
if (trk->entry - trk->entries_flushed >= mov->frag_interleave) {
if ((VAR_5 = mov_flush_fragment_interleaving(VAR_0, trk)) < 0)
return VAR_5;
}
}
if (!trk->mdat_buf) {
if ((VAR_5 = avio_open_dyn_buf(&trk->mdat_buf)) < 0)
return VAR_5;
}
pb = trk->mdat_buf;
} else {
if (!mov->mdat_buf) {
if ((VAR_5 = avio_open_dyn_buf(&mov->mdat_buf)) < 0)
return VAR_5;
}
pb = mov->mdat_buf;
}
}
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
static const uint16_t VAR_5[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
int VAR_6 = 0;
while (VAR_6 < VAR_3 && VAR_2 < 100) {
VAR_6 += VAR_5[(VAR_1->data[VAR_6] >> 3) & 0x0F];
VAR_2++;
}
if (VAR_2 > 1) {
av_log(VAR_0, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
} else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
VAR_2 = enc->frame_size;
} else if (trk->sample_size)
VAR_2 = VAR_3 / trk->sample_size;
else
VAR_2 = 1;
if (trk->vos_len == 0 && enc->extradata_size > 0 &&
!TAG_IS_AVCI(trk->tag) &&
(enc->codec_id != AV_CODEC_ID_DNXHD)) {
trk->vos_len = enc->extradata_size;
trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) {
VAR_5 = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, enc->extradata, trk->vos_len);
}
if (enc->codec_id == AV_CODEC_ID_AAC && VAR_1->VAR_3 > 2 &&
(AV_RB16(VAR_1->data) & 0xfff0) == 0xfff0) {
if (!VAR_0->streams[VAR_1->stream_index]->nb_frames) {
av_log(VAR_0, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
"use the audio bitstream filter 'aac_adtstoasc' to fix it "
"('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
return -1;
}
av_log(VAR_0, AV_LOG_WARNING, "aac bitstream error\n");
}
if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_avc_parse_nal_units_buf(VAR_1->data, &reformatted_data,
&VAR_3);
avio_write(pb, reformatted_data, VAR_3);
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
VAR_3 = ff_mov_cenc_avc_parse_nal_units(&trk->cenc, pb, VAR_1->data, VAR_3);
if (VAR_3 < 0) {
VAR_5 = VAR_3;
goto err;
}
} else {
VAR_3 = ff_avc_parse_nal_units(pb, VAR_1->data, VAR_1->VAR_3);
}
}
} else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
ff_hevc_annexb2mp4_buf(VAR_1->data, &reformatted_data, &VAR_3, 0, NULL);
avio_write(pb, reformatted_data, VAR_3);
} else {
VAR_3 = ff_hevc_annexb2mp4(pb, VAR_1->data, VAR_1->VAR_3, 0, NULL);
}
#if CONFIG_AC3_PARSER
} else if (enc->codec_id == AV_CODEC_ID_EAC3) {
VAR_3 = handle_eac3(mov, VAR_1, trk);
if (VAR_3 < 0)
return VAR_3;
else if (!VAR_3)
goto end;
avio_write(pb, VAR_1->data, VAR_3);
#endif
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) {
int VAR_7 = (enc->extradata[4] & 0x3) + 1;
VAR_5 = ff_mov_cenc_avc_write_nal_units(VAR_0, &trk->cenc, VAR_7, pb, VAR_1->data, VAR_3);
} else {
VAR_5 = ff_mov_cenc_write_packet(&trk->cenc, pb, VAR_1->data, VAR_3);
}
if (VAR_5) {
goto err;
}
} else {
avio_write(pb, VAR_1->data, VAR_3);
}
}
if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
trk->vos_len = VAR_3;
trk->vos_data = av_malloc(VAR_3);
if (!trk->vos_data) {
VAR_5 = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, VAR_1->data, VAR_3);
}
if (trk->entry >= trk->cluster_capacity) {
unsigned VAR_8 = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
if (av_reallocp_array(&trk->cluster, VAR_8,
sizeof(*trk->cluster))) {
VAR_5 = AVERROR(ENOMEM);
goto err;
}
trk->cluster_capacity = VAR_8;
}
trk->cluster[trk->entry].pos = avio_tell(pb) - VAR_3;
trk->cluster[trk->entry].VAR_2 = VAR_2;
trk->cluster[trk->entry].chunkNum = 0;
trk->cluster[trk->entry].VAR_3 = VAR_3;
trk->cluster[trk->entry].entries = VAR_2;
trk->cluster[trk->entry].dts = VAR_1->dts;
if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {
if (!trk->frag_discont) {
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
mov->mode == MODE_ISM)
VAR_1->pts = VAR_1->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
trk->frag_start = VAR_1->dts - trk->start_dts;
trk->end_pts = AV_NOPTS_VALUE;
trk->frag_discont = 0;
}
}
if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist &&
VAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
trk->cluster[trk->entry].dts = trk->start_dts = 0;
}
if (trk->start_dts == AV_NOPTS_VALUE) {
trk->start_dts = VAR_1->dts;
if (trk->frag_discont) {
if (mov->use_editlist) {
trk->frag_start = VAR_1->pts;
trk->start_dts = VAR_1->dts - VAR_1->pts;
} else {
trk->frag_start = VAR_1->dts;
trk->start_dts = 0;
}
trk->frag_discont = 0;
} else if (VAR_1->dts && mov->moov_written)
av_log(VAR_0, AV_LOG_WARNING,
"Track %d starts with a nonzero dts %"PRId64", while the moov "
"already has been written. Set the delay_moov flag to handle "
"this case.\n",
VAR_1->stream_index, VAR_1->dts);
}
trk->track_duration = VAR_1->dts - trk->start_dts + VAR_1->duration;
trk->last_sample_is_subtitle_end = 0;
if (VAR_1->pts == AV_NOPTS_VALUE) {
av_log(VAR_0, AV_LOG_WARNING, "pts has no value\n");
VAR_1->pts = VAR_1->dts;
}
if (VAR_1->dts != VAR_1->pts)
trk->flags |= MOV_TRACK_CTTS;
trk->cluster[trk->entry].cts = VAR_1->pts - VAR_1->dts;
trk->cluster[trk->entry].flags = 0;
if (trk->start_cts == AV_NOPTS_VALUE)
trk->start_cts = VAR_1->pts - VAR_1->dts;
if (trk->end_pts == AV_NOPTS_VALUE)
trk->end_pts = trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts + VAR_1->duration;
else
trk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts +
trk->cluster[trk->entry].cts +
VAR_1->duration);
if (enc->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(VAR_1, trk);
} else if (VAR_1->flags & AV_PKT_FLAG_KEY) {
if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
trk->entry > 0) {
mov_parse_mpeg2_frame(VAR_1, &trk->cluster[trk->entry].flags);
if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
trk->flags |= MOV_TRACK_STPS;
} else {
trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE;
}
if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE)
trk->has_keyframes++;
}
trk->entry++;
trk->sample_count += VAR_2;
mov->mdat_size += VAR_3;
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
ff_mov_add_hinted_packet(VAR_0, VAR_1, trk->hint_track, trk->entry,
reformatted_data, VAR_3);
end:
err:
av_free(reformatted_data);
return VAR_5;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"MOVMuxContext *mov = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"MOVTrack *trk = &mov->tracks[VAR_1->stream_index];",
"AVCodecContext *enc = trk->enc;",
"unsigned int VAR_2 = 0;",
"int VAR_3 = VAR_1->VAR_3, VAR_5 = 0;",
"uint8_t *reformatted_data = NULL;",
"if (trk->entry) {",
"int64_t duration = VAR_1->dts - trk->cluster[trk->entry - 1].dts;",
"if (duration < 0 || duration > INT_MAX) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Application provided duration: %\"PRId64\" / timestamp: %\"PRId64\" is out of range for mov/mp4 format\\n\",\nduration, VAR_1->dts\n);",
"VAR_1->dts = trk->cluster[trk->entry - 1].dts + 1;",
"VAR_1->pts = AV_NOPTS_VALUE;",
"}",
"if (VAR_1->duration < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Application provided duration: %\"PRId64\" is invalid\\n\", VAR_1->duration);",
"return AVERROR(EINVAL);",
"}",
"}",
"if (mov->flags & FF_MOV_FLAG_FRAGMENT) {",
"int VAR_5;",
"if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {",
"if (mov->frag_interleave && mov->fragments > 0) {",
"if (trk->entry - trk->entries_flushed >= mov->frag_interleave) {",
"if ((VAR_5 = mov_flush_fragment_interleaving(VAR_0, trk)) < 0)\nreturn VAR_5;",
"}",
"}",
"if (!trk->mdat_buf) {",
"if ((VAR_5 = avio_open_dyn_buf(&trk->mdat_buf)) < 0)\nreturn VAR_5;",
"}",
"pb = trk->mdat_buf;",
"} else {",
"if (!mov->mdat_buf) {",
"if ((VAR_5 = avio_open_dyn_buf(&mov->mdat_buf)) < 0)\nreturn VAR_5;",
"}",
"pb = mov->mdat_buf;",
"}",
"}",
"if (enc->codec_id == AV_CODEC_ID_AMR_NB) {",
"static const uint16_t VAR_5[16] =\n{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};",
"int VAR_6 = 0;",
"while (VAR_6 < VAR_3 && VAR_2 < 100) {",
"VAR_6 += VAR_5[(VAR_1->data[VAR_6] >> 3) & 0x0F];",
"VAR_2++;",
"}",
"if (VAR_2 > 1) {",
"av_log(VAR_0, AV_LOG_ERROR, \"fatal error, input is not a single packet, implement a AVParser for it\\n\");",
"return -1;",
"}",
"} else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS ||",
"enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {",
"VAR_2 = enc->frame_size;",
"} else if (trk->sample_size)",
"VAR_2 = VAR_3 / trk->sample_size;",
"else\nVAR_2 = 1;",
"if (trk->vos_len == 0 && enc->extradata_size > 0 &&\n!TAG_IS_AVCI(trk->tag) &&\n(enc->codec_id != AV_CODEC_ID_DNXHD)) {",
"trk->vos_len = enc->extradata_size;",
"trk->vos_data = av_malloc(trk->vos_len);",
"if (!trk->vos_data) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto err;",
"}",
"memcpy(trk->vos_data, enc->extradata, trk->vos_len);",
"}",
"if (enc->codec_id == AV_CODEC_ID_AAC && VAR_1->VAR_3 > 2 &&\n(AV_RB16(VAR_1->data) & 0xfff0) == 0xfff0) {",
"if (!VAR_0->streams[VAR_1->stream_index]->nb_frames) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Malformed AAC bitstream detected: \"\n\"use the audio bitstream filter 'aac_adtstoasc' to fix it \"\n\"('-bsf:a aac_adtstoasc' option with ffmpeg)\\n\");",
"return -1;",
"}",
"av_log(VAR_0, AV_LOG_WARNING, \"aac bitstream error\\n\");",
"}",
"if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {",
"if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {",
"ff_avc_parse_nal_units_buf(VAR_1->data, &reformatted_data,\n&VAR_3);",
"avio_write(pb, reformatted_data, VAR_3);",
"} else {",
"if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {",
"VAR_3 = ff_mov_cenc_avc_parse_nal_units(&trk->cenc, pb, VAR_1->data, VAR_3);",
"if (VAR_3 < 0) {",
"VAR_5 = VAR_3;",
"goto err;",
"}",
"} else {",
"VAR_3 = ff_avc_parse_nal_units(pb, VAR_1->data, VAR_1->VAR_3);",
"}",
"}",
"} else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&",
"(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {",
"if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {",
"ff_hevc_annexb2mp4_buf(VAR_1->data, &reformatted_data, &VAR_3, 0, NULL);",
"avio_write(pb, reformatted_data, VAR_3);",
"} else {",
"VAR_3 = ff_hevc_annexb2mp4(pb, VAR_1->data, VAR_1->VAR_3, 0, NULL);",
"}",
"#if CONFIG_AC3_PARSER\n} else if (enc->codec_id == AV_CODEC_ID_EAC3) {",
"VAR_3 = handle_eac3(mov, VAR_1, trk);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"else if (!VAR_3)\ngoto end;",
"avio_write(pb, VAR_1->data, VAR_3);",
"#endif\n} else {",
"if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {",
"if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) {",
"int VAR_7 = (enc->extradata[4] & 0x3) + 1;",
"VAR_5 = ff_mov_cenc_avc_write_nal_units(VAR_0, &trk->cenc, VAR_7, pb, VAR_1->data, VAR_3);",
"} else {",
"VAR_5 = ff_mov_cenc_write_packet(&trk->cenc, pb, VAR_1->data, VAR_3);",
"}",
"if (VAR_5) {",
"goto err;",
"}",
"} else {",
"avio_write(pb, VAR_1->data, VAR_3);",
"}",
"}",
"if ((enc->codec_id == AV_CODEC_ID_DNXHD ||\nenc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {",
"trk->vos_len = VAR_3;",
"trk->vos_data = av_malloc(VAR_3);",
"if (!trk->vos_data) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto err;",
"}",
"memcpy(trk->vos_data, VAR_1->data, VAR_3);",
"}",
"if (trk->entry >= trk->cluster_capacity) {",
"unsigned VAR_8 = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);",
"if (av_reallocp_array(&trk->cluster, VAR_8,\nsizeof(*trk->cluster))) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto err;",
"}",
"trk->cluster_capacity = VAR_8;",
"}",
"trk->cluster[trk->entry].pos = avio_tell(pb) - VAR_3;",
"trk->cluster[trk->entry].VAR_2 = VAR_2;",
"trk->cluster[trk->entry].chunkNum = 0;",
"trk->cluster[trk->entry].VAR_3 = VAR_3;",
"trk->cluster[trk->entry].entries = VAR_2;",
"trk->cluster[trk->entry].dts = VAR_1->dts;",
"if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {",
"if (!trk->frag_discont) {",
"trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;",
"if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||\nmov->mode == MODE_ISM)\nVAR_1->pts = VAR_1->dts + trk->end_pts - trk->cluster[trk->entry].dts;",
"} else {",
"trk->frag_start = VAR_1->dts - trk->start_dts;",
"trk->end_pts = AV_NOPTS_VALUE;",
"trk->frag_discont = 0;",
"}",
"}",
"if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist &&\nVAR_0->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {",
"trk->cluster[trk->entry].dts = trk->start_dts = 0;",
"}",
"if (trk->start_dts == AV_NOPTS_VALUE) {",
"trk->start_dts = VAR_1->dts;",
"if (trk->frag_discont) {",
"if (mov->use_editlist) {",
"trk->frag_start = VAR_1->pts;",
"trk->start_dts = VAR_1->dts - VAR_1->pts;",
"} else {",
"trk->frag_start = VAR_1->dts;",
"trk->start_dts = 0;",
"}",
"trk->frag_discont = 0;",
"} else if (VAR_1->dts && mov->moov_written)",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Track %d starts with a nonzero dts %\"PRId64\", while the moov \"\n\"already has been written. Set the delay_moov flag to handle \"\n\"this case.\\n\",\nVAR_1->stream_index, VAR_1->dts);",
"}",
"trk->track_duration = VAR_1->dts - trk->start_dts + VAR_1->duration;",
"trk->last_sample_is_subtitle_end = 0;",
"if (VAR_1->pts == AV_NOPTS_VALUE) {",
"av_log(VAR_0, AV_LOG_WARNING, \"pts has no value\\n\");",
"VAR_1->pts = VAR_1->dts;",
"}",
"if (VAR_1->dts != VAR_1->pts)\ntrk->flags |= MOV_TRACK_CTTS;",
"trk->cluster[trk->entry].cts = VAR_1->pts - VAR_1->dts;",
"trk->cluster[trk->entry].flags = 0;",
"if (trk->start_cts == AV_NOPTS_VALUE)\ntrk->start_cts = VAR_1->pts - VAR_1->dts;",
"if (trk->end_pts == AV_NOPTS_VALUE)\ntrk->end_pts = trk->cluster[trk->entry].dts +\ntrk->cluster[trk->entry].cts + VAR_1->duration;",
"else\ntrk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts +\ntrk->cluster[trk->entry].cts +\nVAR_1->duration);",
"if (enc->codec_id == AV_CODEC_ID_VC1) {",
"mov_parse_vc1_frame(VAR_1, trk);",
"} else if (VAR_1->flags & AV_PKT_FLAG_KEY) {",
"if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&\ntrk->entry > 0) {",
"mov_parse_mpeg2_frame(VAR_1, &trk->cluster[trk->entry].flags);",
"if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)\ntrk->flags |= MOV_TRACK_STPS;",
"} else {",
"trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE;",
"}",
"if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE)\ntrk->has_keyframes++;",
"}",
"trk->entry++;",
"trk->sample_count += VAR_2;",
"mov->mdat_size += VAR_3;",
"if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)\nff_mov_add_hinted_packet(VAR_0, VAR_1, trk->hint_track, trk->entry,\nreformatted_data, VAR_3);",
"end:\nerr:\nav_free(reformatted_data);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103,
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
145,
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
295,
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
363
],
[
373,
375,
377
],
[
379
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399,
401
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
431
],
[
433
],
[
435
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451,
453,
455,
457,
459
],
[
461
],
[
463
],
[
465
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485,
487
],
[
489,
491,
493
],
[
495,
497,
499,
501
],
[
505
],
[
507
],
[
509
],
[
511,
513
],
[
515
],
[
517,
519
],
[
521
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
541,
543,
545
],
[
549,
551,
555
],
[
557
],
[
559
]
]
|
15,237 | static int decode_cabac_mb_chroma_pre_mode( H264Context *h) {
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx = 0;
/* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */
if( h->slice_table[mba_xy] == h->slice_num && h->chroma_pred_mode_table[mba_xy] != 0 )
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && h->chroma_pred_mode_table[mbb_xy] != 0 )
ctx++;
if( get_cabac( &h->cabac, &h->cabac_state[64+ctx] ) == 0 )
return 0;
if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 )
return 1;
if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 )
return 2;
else
return 3;
}
| false | FFmpeg | 851ded8918c977d8160c6617b69604f758cabf50 | static int decode_cabac_mb_chroma_pre_mode( H264Context *h) {
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx = 0;
if( h->slice_table[mba_xy] == h->slice_num && h->chroma_pred_mode_table[mba_xy] != 0 )
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && h->chroma_pred_mode_table[mbb_xy] != 0 )
ctx++;
if( get_cabac( &h->cabac, &h->cabac_state[64+ctx] ) == 0 )
return 0;
if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 )
return 1;
if( get_cabac( &h->cabac, &h->cabac_state[64+3] ) == 0 )
return 2;
else
return 3;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0( H264Context *VAR_0) {
const int VAR_1 = VAR_0->left_mb_xy[0];
const int VAR_2 = VAR_0->top_mb_xy;
int VAR_3 = 0;
if( VAR_0->slice_table[VAR_1] == VAR_0->slice_num && VAR_0->chroma_pred_mode_table[VAR_1] != 0 )
VAR_3++;
if( VAR_0->slice_table[VAR_2] == VAR_0->slice_num && VAR_0->chroma_pred_mode_table[VAR_2] != 0 )
VAR_3++;
if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+VAR_3] ) == 0 )
return 0;
if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+3] ) == 0 )
return 1;
if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+3] ) == 0 )
return 2;
else
return 3;
}
| [
"static int FUNC_0( H264Context *VAR_0) {",
"const int VAR_1 = VAR_0->left_mb_xy[0];",
"const int VAR_2 = VAR_0->top_mb_xy;",
"int VAR_3 = 0;",
"if( VAR_0->slice_table[VAR_1] == VAR_0->slice_num && VAR_0->chroma_pred_mode_table[VAR_1] != 0 )\nVAR_3++;",
"if( VAR_0->slice_table[VAR_2] == VAR_0->slice_num && VAR_0->chroma_pred_mode_table[VAR_2] != 0 )\nVAR_3++;",
"if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+VAR_3] ) == 0 )\nreturn 0;",
"if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+3] ) == 0 )\nreturn 1;",
"if( get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[64+3] ) == 0 )\nreturn 2;",
"else\nreturn 3;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
9
],
[
15,
17
],
[
21,
23
],
[
27,
29
],
[
33,
35
],
[
37,
39
],
[
41,
43
],
[
45
]
]
|
15,238 | static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
AacPsyContext *pctx;
float bark;
int i, j, g, start;
float prev, minscale, minath;
ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));
pctx = (AacPsyContext*) ctx->model_priv_data;
minath = ath(3410, ATH_ADD);
for (j = 0; j < 2; j++) {
AacPsyCoeffs *coeffs = &pctx->psy_coef[j];
float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f);
i = 0;
prev = 0.0;
for (g = 0; g < ctx->num_bands[j]; g++) {
i += ctx->bands[j][g];
bark = calc_bark((i-1) * line_to_frequency);
coeffs->barks[g] = (bark + prev) / 2.0;
prev = bark;
}
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);
coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI);
}
start = 0;
for (g = 0; g < ctx->num_bands[j]; g++) {
minscale = ath(start * line_to_frequency, ATH_ADD);
for (i = 1; i < ctx->bands[j][g]; i++)
minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
coeffs->ath[g] = minscale - minath;
start += ctx->bands[j][g];
}
}
pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);
lame_window_init(pctx, ctx->avctx);
return 0;
}
| false | FFmpeg | b7c96769c52a312c6f6abe43f5d8c83701118a0b | static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
AacPsyContext *pctx;
float bark;
int i, j, g, start;
float prev, minscale, minath;
ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));
pctx = (AacPsyContext*) ctx->model_priv_data;
minath = ath(3410, ATH_ADD);
for (j = 0; j < 2; j++) {
AacPsyCoeffs *coeffs = &pctx->psy_coef[j];
float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f);
i = 0;
prev = 0.0;
for (g = 0; g < ctx->num_bands[j]; g++) {
i += ctx->bands[j][g];
bark = calc_bark((i-1) * line_to_frequency);
coeffs->barks[g] = (bark + prev) / 2.0;
prev = bark;
}
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);
coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI);
}
start = 0;
for (g = 0; g < ctx->num_bands[j]; g++) {
minscale = ath(start * line_to_frequency, ATH_ADD);
for (i = 1; i < ctx->bands[j][g]; i++)
minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
coeffs->ath[g] = minscale - minath;
start += ctx->bands[j][g];
}
}
pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);
lame_window_init(pctx, ctx->avctx);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(FFPsyContext *ctx) {
AacPsyContext *pctx;
float VAR_0;
int VAR_1, VAR_2, VAR_3, VAR_4;
float VAR_5, VAR_6, VAR_7;
ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));
pctx = (AacPsyContext*) ctx->model_priv_data;
VAR_7 = ath(3410, ATH_ADD);
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
AacPsyCoeffs *coeffs = &pctx->psy_coef[VAR_2];
float VAR_8 = ctx->avctx->sample_rate / (VAR_2 ? 256.f : 2048.0f);
VAR_1 = 0;
VAR_5 = 0.0;
for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2]; VAR_3++) {
VAR_1 += ctx->bands[VAR_2][VAR_3];
VAR_0 = calc_bark((VAR_1-1) * VAR_8);
coeffs->barks[VAR_3] = (VAR_0 + VAR_5) / 2.0;
VAR_5 = VAR_0;
}
for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2] - 1; VAR_3++) {
coeffs->spread_low[VAR_3] = pow(10.0, -(coeffs->barks[VAR_3+1] - coeffs->barks[VAR_3]) * PSY_3GPP_SPREAD_LOW);
coeffs->spread_hi [VAR_3] = pow(10.0, -(coeffs->barks[VAR_3+1] - coeffs->barks[VAR_3]) * PSY_3GPP_SPREAD_HI);
}
VAR_4 = 0;
for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2]; VAR_3++) {
VAR_6 = ath(VAR_4 * VAR_8, ATH_ADD);
for (VAR_1 = 1; VAR_1 < ctx->bands[VAR_2][VAR_3]; VAR_1++)
VAR_6 = FFMIN(VAR_6, ath((VAR_4 + VAR_1) * VAR_8, ATH_ADD));
coeffs->ath[VAR_3] = VAR_6 - VAR_7;
VAR_4 += ctx->bands[VAR_2][VAR_3];
}
}
pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);
lame_window_init(pctx, ctx->avctx);
return 0;
}
| [
"static av_cold int FUNC_0(FFPsyContext *ctx) {",
"AacPsyContext *pctx;",
"float VAR_0;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"float VAR_5, VAR_6, VAR_7;",
"ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));",
"pctx = (AacPsyContext*) ctx->model_priv_data;",
"VAR_7 = ath(3410, ATH_ADD);",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"AacPsyCoeffs *coeffs = &pctx->psy_coef[VAR_2];",
"float VAR_8 = ctx->avctx->sample_rate / (VAR_2 ? 256.f : 2048.0f);",
"VAR_1 = 0;",
"VAR_5 = 0.0;",
"for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2]; VAR_3++) {",
"VAR_1 += ctx->bands[VAR_2][VAR_3];",
"VAR_0 = calc_bark((VAR_1-1) * VAR_8);",
"coeffs->barks[VAR_3] = (VAR_0 + VAR_5) / 2.0;",
"VAR_5 = VAR_0;",
"}",
"for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2] - 1; VAR_3++) {",
"coeffs->spread_low[VAR_3] = pow(10.0, -(coeffs->barks[VAR_3+1] - coeffs->barks[VAR_3]) * PSY_3GPP_SPREAD_LOW);",
"coeffs->spread_hi [VAR_3] = pow(10.0, -(coeffs->barks[VAR_3+1] - coeffs->barks[VAR_3]) * PSY_3GPP_SPREAD_HI);",
"}",
"VAR_4 = 0;",
"for (VAR_3 = 0; VAR_3 < ctx->num_bands[VAR_2]; VAR_3++) {",
"VAR_6 = ath(VAR_4 * VAR_8, ATH_ADD);",
"for (VAR_1 = 1; VAR_1 < ctx->bands[VAR_2][VAR_3]; VAR_1++)",
"VAR_6 = FFMIN(VAR_6, ath((VAR_4 + VAR_1) * VAR_8, ATH_ADD));",
"coeffs->ath[VAR_3] = VAR_6 - VAR_7;",
"VAR_4 += ctx->bands[VAR_2][VAR_3];",
"}",
"}",
"pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);",
"lame_window_init(pctx, ctx->avctx);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
79
],
[
81
]
]
|
15,240 | static void test_tco_second_timeout_reset(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(16);
QDict *ad;
td.args = "-watchdog-action reset";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "reset"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| true | qemu | 34779e8c3991f7fcd74b2045478abcef67dbeb15 | static void test_tco_second_timeout_reset(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(16);
QDict *ad;
td.args = "-watchdog-action reset";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "reset"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| {
"code": [
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();"
],
"line_no": [
45,
45,
45,
45,
45,
45,
45,
45,
45,
45,
45
]
} | static void FUNC_0(void)
{
TestData td;
const uint16_t VAR_0 = TCO_SECS_TO_TICKS(16);
QDict *ad;
td.args = "-watchdog-action reset";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(VAR_0 * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "reset"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"TestData td;",
"const uint16_t VAR_0 = TCO_SECS_TO_TICKS(16);",
"QDict *ad;",
"td.args = \"-watchdog-action reset\";",
"td.noreboot = false;",
"test_init(&td);",
"stop_tco(&td);",
"clear_tco_status(&td);",
"reset_on_second_timeout(true);",
"set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));",
"load_tco(&td);",
"start_tco(&td);",
"clock_step(VAR_0 * TCO_TICK_NSEC * 2);",
"ad = get_watchdog_action();",
"g_assert(!strcmp(qdict_get_str(ad, \"action\"), \"reset\"));",
"QDECREF(ad);",
"stop_tco(&td);",
"qtest_end();",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
]
|
15,241 | static void e1000e_macreg_write(e1000e_device *d, uint32_t reg, uint32_t val)
{
qpci_io_writel(d->pci_dev, d->mac_regs + reg, val);
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static void e1000e_macreg_write(e1000e_device *d, uint32_t reg, uint32_t val)
{
qpci_io_writel(d->pci_dev, d->mac_regs + reg, val);
}
| {
"code": [
" qpci_io_writel(d->pci_dev, d->mac_regs + reg, val);"
],
"line_no": [
5
]
} | static void FUNC_0(e1000e_device *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
qpci_io_writel(VAR_0->pci_dev, VAR_0->mac_regs + VAR_1, VAR_2);
}
| [
"static void FUNC_0(e1000e_device *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"qpci_io_writel(VAR_0->pci_dev, VAR_0->mac_regs + VAR_1, VAR_2);",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
15,242 | static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direction)
{
FDrive *cur_drv = get_cur_drv(fdctrl);
if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) {
/* Command parameters done */
if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x40) {
fdctrl->fifo[0] = fdctrl->fifo[1];
fdctrl->fifo[2] = 0;
fdctrl->fifo[3] = 0;
fdctrl_set_fifo(fdctrl, 4);
} else {
fdctrl_reset_fifo(fdctrl);
}
} else if (fdctrl->data_len > 7) {
/* ERROR */
fdctrl->fifo[0] = 0x80 |
(cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
fdctrl_set_fifo(fdctrl, 1);
}
}
| true | qemu | e907746266721f305d67bc0718795fedee2e824c | static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direction)
{
FDrive *cur_drv = get_cur_drv(fdctrl);
if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) {
if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x40) {
fdctrl->fifo[0] = fdctrl->fifo[1];
fdctrl->fifo[2] = 0;
fdctrl->fifo[3] = 0;
fdctrl_set_fifo(fdctrl, 4);
} else {
fdctrl_reset_fifo(fdctrl);
}
} else if (fdctrl->data_len > 7) {
fdctrl->fifo[0] = 0x80 |
(cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
fdctrl_set_fifo(fdctrl, 1);
}
}
| {
"code": [
" if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) {",
" if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x40) {"
],
"line_no": [
9,
13
]
} | static void FUNC_0(FDCtrl *VAR_0, int VAR_1)
{
FDrive *cur_drv = get_cur_drv(VAR_0);
if (VAR_0->fifo[VAR_0->data_pos - 1] & 0x80) {
if (VAR_0->fifo[VAR_0->data_pos - 1] & 0x40) {
VAR_0->fifo[0] = VAR_0->fifo[1];
VAR_0->fifo[2] = 0;
VAR_0->fifo[3] = 0;
fdctrl_set_fifo(VAR_0, 4);
} else {
fdctrl_reset_fifo(VAR_0);
}
} else if (VAR_0->data_len > 7) {
VAR_0->fifo[0] = 0x80 |
(cur_drv->head << 2) | GET_CUR_DRV(VAR_0);
fdctrl_set_fifo(VAR_0, 1);
}
}
| [
"static void FUNC_0(FDCtrl *VAR_0, int VAR_1)\n{",
"FDrive *cur_drv = get_cur_drv(VAR_0);",
"if (VAR_0->fifo[VAR_0->data_pos - 1] & 0x80) {",
"if (VAR_0->fifo[VAR_0->data_pos - 1] & 0x40) {",
"VAR_0->fifo[0] = VAR_0->fifo[1];",
"VAR_0->fifo[2] = 0;",
"VAR_0->fifo[3] = 0;",
"fdctrl_set_fifo(VAR_0, 4);",
"} else {",
"fdctrl_reset_fifo(VAR_0);",
"}",
"} else if (VAR_0->data_len > 7) {",
"VAR_0->fifo[0] = 0x80 |\n(cur_drv->head << 2) | GET_CUR_DRV(VAR_0);",
"fdctrl_set_fifo(VAR_0, 1);",
"}",
"}"
]
| [
0,
0,
1,
1,
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
],
[
33,
35
],
[
37
],
[
39
],
[
41
]
]
|
15,243 | uint64_t helper_addqv(CPUAlphaState *env, uint64_t op1, uint64_t op2)
{
uint64_t tmp = op1;
op1 += op2;
if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return op1;
}
| true | qemu | 4d1628e832dfc6ec02b0d196f6cc250aaa7bf3b3 | uint64_t helper_addqv(CPUAlphaState *env, uint64_t op1, uint64_t op2)
{
uint64_t tmp = op1;
op1 += op2;
if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return op1;
}
| {
"code": [
"uint64_t helper_addqv(CPUAlphaState *env, uint64_t op1, uint64_t op2)",
" uint64_t tmp = op1;",
" op1 += op2;",
" if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {",
" return op1;",
" uint64_t tmp = op1;",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" return op1;",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);"
],
"line_no": [
1,
5,
7,
9,
15,
5,
11,
15,
11,
11,
11,
11
]
} | uint64_t FUNC_0(CPUAlphaState *env, uint64_t op1, uint64_t op2)
{
uint64_t tmp = op1;
op1 += op2;
if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return op1;
}
| [
"uint64_t FUNC_0(CPUAlphaState *env, uint64_t op1, uint64_t op2)\n{",
"uint64_t tmp = op1;",
"op1 += op2;",
"if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {",
"arith_excp(env, GETPC(), EXC_M_IOV, 0);",
"}",
"return op1;",
"}"
]
| [
1,
1,
1,
1,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
15,244 | pvscsi_on_cmd_setup_msg_ring(PVSCSIState *s)
{
PVSCSICmdDescSetupMsgRing *rc =
(PVSCSICmdDescSetupMsgRing *) s->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_MSG_RING");
if (!s->use_msg) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
if (s->rings_info_valid) {
pvscsi_ring_init_msg(&s->rings, rc);
s->msg_ring_info_valid = TRUE;
}
return sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(uint32_t);
}
| true | qemu | 3e831b40e015ba34dfb55ff11f767001839425ff | pvscsi_on_cmd_setup_msg_ring(PVSCSIState *s)
{
PVSCSICmdDescSetupMsgRing *rc =
(PVSCSICmdDescSetupMsgRing *) s->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_MSG_RING");
if (!s->use_msg) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
if (s->rings_info_valid) {
pvscsi_ring_init_msg(&s->rings, rc);
s->msg_ring_info_valid = TRUE;
}
return sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(uint32_t);
}
| {
"code": [
" pvscsi_ring_init_msg(&s->rings, rc);"
],
"line_no": [
25
]
} | FUNC_0(PVSCSIState *VAR_0)
{
PVSCSICmdDescSetupMsgRing *rc =
(PVSCSICmdDescSetupMsgRing *) VAR_0->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_MSG_RING");
if (!VAR_0->use_msg) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
if (VAR_0->rings_info_valid) {
pvscsi_ring_init_msg(&VAR_0->rings, rc);
VAR_0->msg_ring_info_valid = TRUE;
}
return sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(uint32_t);
}
| [
"FUNC_0(PVSCSIState *VAR_0)\n{",
"PVSCSICmdDescSetupMsgRing *rc =\n(PVSCSICmdDescSetupMsgRing *) VAR_0->curr_cmd_data;",
"trace_pvscsi_on_cmd_arrived(\"PVSCSI_CMD_SETUP_MSG_RING\");",
"if (!VAR_0->use_msg) {",
"return PVSCSI_COMMAND_PROCESSING_FAILED;",
"}",
"if (VAR_0->rings_info_valid) {",
"pvscsi_ring_init_msg(&VAR_0->rings, rc);",
"VAR_0->msg_ring_info_valid = TRUE;",
"}",
"return sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(uint32_t);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
]
|
15,246 | dispatcher_wait(Dispatcher *dispr, uint32_t timeout)
{
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
fd_set fdset = dispr->fdset;
/* wait until some of sockets become readable. */
int rc = select(dispr->max_sock + 1, &fdset, 0, 0, &tv);
if (rc == -1) {
vubr_die("select");
}
/* Timeout */
if (rc == 0) {
return 0;
}
/* Now call callback for every ready socket. */
int sock;
for (sock = 0; sock < dispr->max_sock + 1; sock++)
if (FD_ISSET(sock, &fdset)) {
Event *e = &dispr->events[sock];
e->callback(sock, e->ctx);
}
return 0;
}
| true | qemu | 6d0b908a628a7086fa855c68b217cc1e2a5c4c19 | dispatcher_wait(Dispatcher *dispr, uint32_t timeout)
{
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
fd_set fdset = dispr->fdset;
int rc = select(dispr->max_sock + 1, &fdset, 0, 0, &tv);
if (rc == -1) {
vubr_die("select");
}
if (rc == 0) {
return 0;
}
int sock;
for (sock = 0; sock < dispr->max_sock + 1; sock++)
if (FD_ISSET(sock, &fdset)) {
Event *e = &dispr->events[sock];
e->callback(sock, e->ctx);
}
return 0;
}
| {
"code": [
" for (sock = 0; sock < dispr->max_sock + 1; sock++)",
" if (FD_ISSET(sock, &fdset)) {"
],
"line_no": [
47,
49
]
} | FUNC_0(Dispatcher *VAR_0, uint32_t VAR_1)
{
struct timeval VAR_2;
VAR_2.tv_sec = VAR_1 / 1000000;
VAR_2.tv_usec = VAR_1 % 1000000;
fd_set fdset = VAR_0->fdset;
int VAR_3 = select(VAR_0->max_sock + 1, &fdset, 0, 0, &VAR_2);
if (VAR_3 == -1) {
vubr_die("select");
}
if (VAR_3 == 0) {
return 0;
}
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_0->max_sock + 1; VAR_4++)
if (FD_ISSET(VAR_4, &fdset)) {
Event *e = &VAR_0->events[VAR_4];
e->callback(VAR_4, e->ctx);
}
return 0;
}
| [
"FUNC_0(Dispatcher *VAR_0, uint32_t VAR_1)\n{",
"struct timeval VAR_2;",
"VAR_2.tv_sec = VAR_1 / 1000000;",
"VAR_2.tv_usec = VAR_1 % 1000000;",
"fd_set fdset = VAR_0->fdset;",
"int VAR_3 = select(VAR_0->max_sock + 1, &fdset, 0, 0, &VAR_2);",
"if (VAR_3 == -1) {",
"vubr_die(\"select\");",
"}",
"if (VAR_3 == 0) {",
"return 0;",
"}",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_0->max_sock + 1; VAR_4++)",
"if (FD_ISSET(VAR_4, &fdset)) {",
"Event *e = &VAR_0->events[VAR_4];",
"e->callback(VAR_4, e->ctx);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
]
|
15,247 | int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res)
{
if (bs->drv->bdrv_check == NULL) {
return -ENOTSUP;
}
memset(res, 0, sizeof(*res));
res->corruptions = bs->drv->bdrv_check(bs);
return res->corruptions < 0 ? res->corruptions : 0;
}
| true | qemu | 9ac228e02cf16202547e7025ef300369e0db7781 | int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res)
{
if (bs->drv->bdrv_check == NULL) {
return -ENOTSUP;
}
memset(res, 0, sizeof(*res));
res->corruptions = bs->drv->bdrv_check(bs);
return res->corruptions < 0 ? res->corruptions : 0;
}
| {
"code": [
" res->corruptions = bs->drv->bdrv_check(bs);",
" return res->corruptions < 0 ? res->corruptions : 0;"
],
"line_no": [
15,
17
]
} | int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1)
{
if (VAR_0->drv->FUNC_0 == NULL) {
return -ENOTSUP;
}
memset(VAR_1, 0, sizeof(*VAR_1));
VAR_1->corruptions = VAR_0->drv->FUNC_0(VAR_0);
return VAR_1->corruptions < 0 ? VAR_1->corruptions : 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1)\n{",
"if (VAR_0->drv->FUNC_0 == NULL) {",
"return -ENOTSUP;",
"}",
"memset(VAR_1, 0, sizeof(*VAR_1));",
"VAR_1->corruptions = VAR_0->drv->FUNC_0(VAR_0);",
"return VAR_1->corruptions < 0 ? VAR_1->corruptions : 0;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
15,248 | static int nsv_parse_NSVf_header(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int av_unused file_size;
unsigned int size;
int64_t duration;
int strings_size;
int table_entries;
int table_entries_used;
av_dlog(s, "%s()\n", __FUNCTION__);
nsv->state = NSV_UNSYNC; /* in case we fail */
size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
//s->file_size = (uint32_t)avio_rl32(pb);
file_size = (uint32_t)avio_rl32(pb);
av_dlog(s, "NSV NSVf chunk_size %u\n", size);
av_dlog(s, "NSV NSVf file_size %u\n", file_size);
nsv->duration = duration = avio_rl32(pb); /* in ms */
av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration);
// XXX: store it in AVStreams
strings_size = avio_rl32(pb);
table_entries = avio_rl32(pb);
table_entries_used = avio_rl32(pb);
av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
strings_size, table_entries, table_entries_used);
if (pb->eof_reached)
return -1;
av_dlog(s, "NSV got header; filepos %"PRId64"\n", avio_tell(pb));
if (strings_size > 0) {
char *strings; /* last byte will be '\0' to play safe with str*() */
char *p, *endp;
char *token, *value;
char quote;
p = strings = av_mallocz(strings_size + 1);
endp = strings + strings_size;
avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++; /* strip out spaces */
if (p >= endp-2)
break;
token = p;
p = strchr(p, '=');
if (!p || p >= endp-2)
break;
*p++ = '\0';
quote = *p++;
value = p;
p = strchr(p, quote);
if (!p || p >= endp)
break;
*p++ = '\0';
av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
av_dict_set(&s->metadata, token, value, 0);
}
av_free(strings);
}
if (pb->eof_reached)
return -1;
av_dlog(s, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb));
if (table_entries_used > 0) {
int i;
nsv->index_entries = table_entries_used;
if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t))
return -1;
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
for(i=0;i<table_entries_used;i++)
nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
if(table_entries > table_entries_used &&
avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
for(i=0;i<table_entries_used;i++) {
nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
av_dlog(s, "NSV got index; filepos %"PRId64"\n", avio_tell(pb));
#ifdef DEBUG_DUMP_INDEX
#define V(v) ((v<0x20 || v > 127)?'.':v)
/* dump index */
av_dlog(s, "NSV %d INDEX ENTRIES:\n", table_entries);
av_dlog(s, "NSV [dataoffset][fileoffset]\n", table_entries);
for (i = 0; i < table_entries; i++) {
unsigned char b[8];
avio_seek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
avio_read(pb, b, 8);
av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i],
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) );
}
//avio_seek(pb, size, SEEK_SET); /* go back to end of header */
#undef V
#endif
avio_seek(pb, nsv->base_offset + size, SEEK_SET); /* required for dumbdriving-271.nsv (2 extra bytes) */
if (pb->eof_reached)
return -1;
nsv->state = NSV_HAS_READ_NSVF;
return 0;
}
| true | FFmpeg | 8fd8a48263ff1437f9d02d7e78dc63efb9b5ed3a | static int nsv_parse_NSVf_header(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int av_unused file_size;
unsigned int size;
int64_t duration;
int strings_size;
int table_entries;
int table_entries_used;
av_dlog(s, "%s()\n", __FUNCTION__);
nsv->state = NSV_UNSYNC;
size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
file_size = (uint32_t)avio_rl32(pb);
av_dlog(s, "NSV NSVf chunk_size %u\n", size);
av_dlog(s, "NSV NSVf file_size %u\n", file_size);
nsv->duration = duration = avio_rl32(pb);
av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration);
strings_size = avio_rl32(pb);
table_entries = avio_rl32(pb);
table_entries_used = avio_rl32(pb);
av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
strings_size, table_entries, table_entries_used);
if (pb->eof_reached)
return -1;
av_dlog(s, "NSV got header; filepos %"PRId64"\n", avio_tell(pb));
if (strings_size > 0) {
char *strings;
char *p, *endp;
char *token, *value;
char quote;
p = strings = av_mallocz(strings_size + 1);
endp = strings + strings_size;
avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++;
if (p >= endp-2)
break;
token = p;
p = strchr(p, '=');
if (!p || p >= endp-2)
break;
*p++ = '\0';
quote = *p++;
value = p;
p = strchr(p, quote);
if (!p || p >= endp)
break;
*p++ = '\0';
av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
av_dict_set(&s->metadata, token, value, 0);
}
av_free(strings);
}
if (pb->eof_reached)
return -1;
av_dlog(s, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb));
if (table_entries_used > 0) {
int i;
nsv->index_entries = table_entries_used;
if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t))
return -1;
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
for(i=0;i<table_entries_used;i++)
nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
if(table_entries > table_entries_used &&
avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
for(i=0;i<table_entries_used;i++) {
nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
av_dlog(s, "NSV got index; filepos %"PRId64"\n", avio_tell(pb));
#ifdef DEBUG_DUMP_INDEX
#define V(v) ((v<0x20 || v > 127)?'.':v)
av_dlog(s, "NSV %d INDEX ENTRIES:\n", table_entries);
av_dlog(s, "NSV [dataoffset][fileoffset]\n", table_entries);
for (i = 0; i < table_entries; i++) {
unsigned char b[8];
avio_seek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
avio_read(pb, b, 8);
av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i],
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) );
}
#undef V
#endif
avio_seek(pb, nsv->base_offset + size, SEEK_SET);
if (pb->eof_reached)
return -1;
nsv->state = NSV_HAS_READ_NSVF;
return 0;
}
| {
"code": [
" p = strings = av_mallocz(strings_size + 1);"
],
"line_no": [
91
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
NSVContext *nsv = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
unsigned int VAR_1 file_size;
unsigned int VAR_2;
int64_t duration;
int VAR_3;
int VAR_4;
int VAR_5;
av_dlog(VAR_0, "%VAR_0()\n", __FUNCTION__);
nsv->state = NSV_UNSYNC;
VAR_2 = avio_rl32(pb);
if (VAR_2 < 28)
return -1;
nsv->NSVf_end = VAR_2;
file_size = (uint32_t)avio_rl32(pb);
av_dlog(VAR_0, "NSV NSVf chunk_size %u\n", VAR_2);
av_dlog(VAR_0, "NSV NSVf file_size %u\n", file_size);
nsv->duration = duration = avio_rl32(pb);
av_dlog(VAR_0, "NSV NSVf duration %"PRId64" ms\n", duration);
VAR_3 = avio_rl32(pb);
VAR_4 = avio_rl32(pb);
VAR_5 = avio_rl32(pb);
av_dlog(VAR_0, "NSV NSVf info-VAR_6 VAR_2: %d, table entries: %d, bis %d\n",
VAR_3, VAR_4, VAR_5);
if (pb->eof_reached)
return -1;
av_dlog(VAR_0, "NSV got header; filepos %"PRId64"\n", avio_tell(pb));
if (VAR_3 > 0) {
char *VAR_6;
char *VAR_7, *VAR_8;
char *VAR_9, *VAR_10;
char VAR_11;
VAR_7 = VAR_6 = av_mallocz(VAR_3 + 1);
VAR_8 = VAR_6 + VAR_3;
avio_read(pb, VAR_6, VAR_3);
while (VAR_7 < VAR_8) {
while (*VAR_7 == ' ')
VAR_7++;
if (VAR_7 >= VAR_8-2)
break;
VAR_9 = VAR_7;
VAR_7 = strchr(VAR_7, '=');
if (!VAR_7 || VAR_7 >= VAR_8-2)
break;
*VAR_7++ = '\0';
VAR_11 = *VAR_7++;
VAR_10 = VAR_7;
VAR_7 = strchr(VAR_7, VAR_11);
if (!VAR_7 || VAR_7 >= VAR_8)
break;
*VAR_7++ = '\0';
av_dlog(VAR_0, "NSV NSVf INFO: %VAR_0='%VAR_0'\n", VAR_9, VAR_10);
av_dict_set(&VAR_0->metadata, VAR_9, VAR_10, 0);
}
av_free(VAR_6);
}
if (pb->eof_reached)
return -1;
av_dlog(VAR_0, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb));
if (VAR_5 > 0) {
int VAR_12;
nsv->index_entries = VAR_5;
if((unsigned)VAR_5 >= UINT_MAX / sizeof(uint32_t))
return -1;
nsv->nsvs_file_offset = av_malloc((unsigned)VAR_5 * sizeof(uint32_t));
for(VAR_12=0;VAR_12<VAR_5;VAR_12++)
nsv->nsvs_file_offset[VAR_12] = avio_rl32(pb) + VAR_2;
if(VAR_4 > VAR_5 &&
avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)VAR_5*sizeof(uint32_t));
for(VAR_12=0;VAR_12<VAR_5;VAR_12++) {
nsv->nsvs_timestamps[VAR_12] = avio_rl32(pb);
}
}
}
av_dlog(VAR_0, "NSV got index; filepos %"PRId64"\n", avio_tell(pb));
#ifdef DEBUG_DUMP_INDEX
#define V(v) ((v<0x20 || v > 127)?'.':v)
av_dlog(VAR_0, "NSV %d INDEX ENTRIES:\n", VAR_4);
av_dlog(VAR_0, "NSV [dataoffset][fileoffset]\n", VAR_4);
for (VAR_12 = 0; VAR_12 < VAR_4; VAR_12++) {
unsigned char b[8];
avio_seek(pb, VAR_2 + nsv->nsvs_file_offset[VAR_12], SEEK_SET);
avio_read(pb, b, 8);
av_dlog(VAR_0, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[VAR_12], VAR_2 + nsv->nsvs_file_offset[VAR_12],
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) );
}
#undef V
#endif
avio_seek(pb, nsv->base_offset + VAR_2, SEEK_SET);
if (pb->eof_reached)
return -1;
nsv->state = NSV_HAS_READ_NSVF;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"NSVContext *nsv = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned int VAR_1 file_size;",
"unsigned int VAR_2;",
"int64_t duration;",
"int VAR_3;",
"int VAR_4;",
"int VAR_5;",
"av_dlog(VAR_0, \"%VAR_0()\\n\", __FUNCTION__);",
"nsv->state = NSV_UNSYNC;",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 < 28)\nreturn -1;",
"nsv->NSVf_end = VAR_2;",
"file_size = (uint32_t)avio_rl32(pb);",
"av_dlog(VAR_0, \"NSV NSVf chunk_size %u\\n\", VAR_2);",
"av_dlog(VAR_0, \"NSV NSVf file_size %u\\n\", file_size);",
"nsv->duration = duration = avio_rl32(pb);",
"av_dlog(VAR_0, \"NSV NSVf duration %\"PRId64\" ms\\n\", duration);",
"VAR_3 = avio_rl32(pb);",
"VAR_4 = avio_rl32(pb);",
"VAR_5 = avio_rl32(pb);",
"av_dlog(VAR_0, \"NSV NSVf info-VAR_6 VAR_2: %d, table entries: %d, bis %d\\n\",\nVAR_3, VAR_4, VAR_5);",
"if (pb->eof_reached)\nreturn -1;",
"av_dlog(VAR_0, \"NSV got header; filepos %\"PRId64\"\\n\", avio_tell(pb));",
"if (VAR_3 > 0) {",
"char *VAR_6;",
"char *VAR_7, *VAR_8;",
"char *VAR_9, *VAR_10;",
"char VAR_11;",
"VAR_7 = VAR_6 = av_mallocz(VAR_3 + 1);",
"VAR_8 = VAR_6 + VAR_3;",
"avio_read(pb, VAR_6, VAR_3);",
"while (VAR_7 < VAR_8) {",
"while (*VAR_7 == ' ')\nVAR_7++;",
"if (VAR_7 >= VAR_8-2)\nbreak;",
"VAR_9 = VAR_7;",
"VAR_7 = strchr(VAR_7, '=');",
"if (!VAR_7 || VAR_7 >= VAR_8-2)\nbreak;",
"*VAR_7++ = '\\0';",
"VAR_11 = *VAR_7++;",
"VAR_10 = VAR_7;",
"VAR_7 = strchr(VAR_7, VAR_11);",
"if (!VAR_7 || VAR_7 >= VAR_8)\nbreak;",
"*VAR_7++ = '\\0';",
"av_dlog(VAR_0, \"NSV NSVf INFO: %VAR_0='%VAR_0'\\n\", VAR_9, VAR_10);",
"av_dict_set(&VAR_0->metadata, VAR_9, VAR_10, 0);",
"}",
"av_free(VAR_6);",
"}",
"if (pb->eof_reached)\nreturn -1;",
"av_dlog(VAR_0, \"NSV got infos; filepos %\"PRId64\"\\n\", avio_tell(pb));",
"if (VAR_5 > 0) {",
"int VAR_12;",
"nsv->index_entries = VAR_5;",
"if((unsigned)VAR_5 >= UINT_MAX / sizeof(uint32_t))\nreturn -1;",
"nsv->nsvs_file_offset = av_malloc((unsigned)VAR_5 * sizeof(uint32_t));",
"for(VAR_12=0;VAR_12<VAR_5;VAR_12++)",
"nsv->nsvs_file_offset[VAR_12] = avio_rl32(pb) + VAR_2;",
"if(VAR_4 > VAR_5 &&\navio_rl32(pb) == MKTAG('T','O','C','2')) {",
"nsv->nsvs_timestamps = av_malloc((unsigned)VAR_5*sizeof(uint32_t));",
"for(VAR_12=0;VAR_12<VAR_5;VAR_12++) {",
"nsv->nsvs_timestamps[VAR_12] = avio_rl32(pb);",
"}",
"}",
"}",
"av_dlog(VAR_0, \"NSV got index; filepos %\"PRId64\"\\n\", avio_tell(pb));",
"#ifdef DEBUG_DUMP_INDEX\n#define V(v) ((v<0x20 || v > 127)?'.':v)\nav_dlog(VAR_0, \"NSV %d INDEX ENTRIES:\\n\", VAR_4);",
"av_dlog(VAR_0, \"NSV [dataoffset][fileoffset]\\n\", VAR_4);",
"for (VAR_12 = 0; VAR_12 < VAR_4; VAR_12++) {",
"unsigned char b[8];",
"avio_seek(pb, VAR_2 + nsv->nsvs_file_offset[VAR_12], SEEK_SET);",
"avio_read(pb, b, 8);",
"av_dlog(VAR_0, \"NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x\"\n\"%c%c%c%c%c%c%c%c\\n\",\nnsv->nsvs_file_offset[VAR_12], VAR_2 + nsv->nsvs_file_offset[VAR_12],\nb[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],\nV(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) );",
"}",
"#undef V\n#endif\navio_seek(pb, nsv->base_offset + VAR_2, SEEK_SET);",
"if (pb->eof_reached)\nreturn -1;",
"nsv->state = NSV_HAS_READ_NSVF;",
"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,
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
],
[
19
],
[
23
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
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
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
191,
193,
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211,
213,
215,
217
],
[
219
],
[
223,
225,
229
],
[
233,
235
],
[
237
],
[
239
],
[
241
]
]
|
15,250 | static int flac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
FLACContext *s = avctx->priv_data;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples_16 = data;
int32_t *samples_32 = data;
int alloc_data_size= *data_size;
*data_size=0;
if (s->max_framesize == 0) {
s->max_framesize= FFMAX(4, buf_size); // should hopefully be enough for the first header
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if (1 && s->max_framesize) { //FIXME truncated
if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
input_buf_size= buf_size;
if (s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
return -1;
if (s->allocated_bitstream_size < s->bitstream_size + buf_size)
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
if (s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],
buf, buf_size);
buf= &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size= buf_size;
if (buf_size < s->max_framesize && input_buf_size) {
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size*8);
if (metadata_parse(s))
goto end;
tmp = show_bits(&s->gb, 16);
if ((tmp & 0xFFFE) != 0xFFF8) {
av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
while (get_bits_count(&s->gb)/8+2 < buf_size && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end; // we may not have enough bits left to decode a frame, so try next time
}
skip_bits(&s->gb, 16);
if (decode_frame(s, alloc_data_size) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
#define DECORRELATE(left, right)\
assert(s->channels == 2);\
for (i = 0; i < s->blocksize; i++) {\
int a= s->decoded[0][i];\
int b= s->decoded[1][i];\
if (s->is32) {\
*samples_32++ = (left) << s->sample_shift;\
*samples_32++ = (right) << s->sample_shift;\
} else {\
*samples_16++ = (left) << s->sample_shift;\
*samples_16++ = (right) << s->sample_shift;\
}\
}\
break;
switch (s->decorrelation) {
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++) {
for (i = 0; i < s->channels; i++) {
if (s->is32)
*samples_32++ = s->decoded[i][j] << s->sample_shift;
else
*samples_16++ = s->decoded[i][j] << s->sample_shift;
}
}
break;
case LEFT_SIDE:
DECORRELATE(a,a-b)
case RIGHT_SIDE:
DECORRELATE(a+b,b)
case MID_SIDE:
DECORRELATE( (a-=b>>1) + b, a)
}
*data_size = s->blocksize * s->channels * (s->is32 ? 4 : 2);
end:
i= (get_bits_count(&s->gb)+7)/8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| false | FFmpeg | 55a727383bab266b757b642aabaa2b066c14e7c7 | static int flac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
FLACContext *s = avctx->priv_data;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples_16 = data;
int32_t *samples_32 = data;
int alloc_data_size= *data_size;
*data_size=0;
if (s->max_framesize == 0) {
s->max_framesize= FFMAX(4, buf_size);
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if (1 && s->max_framesize) {
if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
input_buf_size= buf_size;
if (s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
return -1;
if (s->allocated_bitstream_size < s->bitstream_size + buf_size)
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
if (s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],
buf, buf_size);
buf= &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size= buf_size;
if (buf_size < s->max_framesize && input_buf_size) {
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size*8);
if (metadata_parse(s))
goto end;
tmp = show_bits(&s->gb, 16);
if ((tmp & 0xFFFE) != 0xFFF8) {
av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
while (get_bits_count(&s->gb)/8+2 < buf_size && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end;
}
skip_bits(&s->gb, 16);
if (decode_frame(s, alloc_data_size) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
#define DECORRELATE(left, right)\
assert(s->channels == 2);\
for (i = 0; i < s->blocksize; i++) {\
int a= s->decoded[0][i];\
int b= s->decoded[1][i];\
if (s->is32) {\
*samples_32++ = (left) << s->sample_shift;\
*samples_32++ = (right) << s->sample_shift;\
} else {\
*samples_16++ = (left) << s->sample_shift;\
*samples_16++ = (right) << s->sample_shift;\
}\
}\
break;
switch (s->decorrelation) {
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++) {
for (i = 0; i < s->channels; i++) {
if (s->is32)
*samples_32++ = s->decoded[i][j] << s->sample_shift;
else
*samples_16++ = s->decoded[i][j] << s->sample_shift;
}
}
break;
case LEFT_SIDE:
DECORRELATE(a,a-b)
case RIGHT_SIDE:
DECORRELATE(a+b,b)
case MID_SIDE:
DECORRELATE( (a-=b>>1) + b, a)
}
*data_size = s->blocksize * s->channels * (s->is32 ? 4 : 2);
end:
i= (get_bits_count(&s->gb)+7)/8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
const uint8_t *VAR_3, int VAR_4)
{
FLACContext *s = VAR_0->priv_data;
int VAR_5 = 0, VAR_6, VAR_7 = 0, VAR_8 = 0;
int16_t *samples_16 = VAR_1;
int32_t *samples_32 = VAR_1;
int VAR_9= *VAR_2;
*VAR_2=0;
if (s->max_framesize == 0) {
s->max_framesize= FFMAX(4, VAR_4);
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if (1 && s->max_framesize) {
if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
VAR_4= FFMIN(VAR_4, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
VAR_8= VAR_4;
if (s->bitstream_size + VAR_4 < VAR_4 || s->bitstream_index + s->bitstream_size + VAR_4 < s->bitstream_index)
return -1;
if (s->allocated_bitstream_size < s->bitstream_size + VAR_4)
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + VAR_4);
if (s->bitstream_index + s->bitstream_size + VAR_4 > s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],
VAR_3, VAR_4);
VAR_3= &s->bitstream[s->bitstream_index];
VAR_4 += s->bitstream_size;
s->bitstream_size= VAR_4;
if (VAR_4 < s->max_framesize && VAR_8) {
return VAR_8;
}
}
init_get_bits(&s->gb, VAR_3, VAR_4*8);
if (metadata_parse(s))
goto end;
VAR_5 = show_bits(&s->gb, 16);
if ((VAR_5 & 0xFFFE) != 0xFFF8) {
av_log(s->VAR_0, AV_LOG_ERROR, "FRAME HEADER not here\n");
while (get_bits_count(&s->gb)/8+2 < VAR_4 && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end;
}
skip_bits(&s->gb, 16);
if (decode_frame(s, VAR_9) < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
#define DECORRELATE(left, right)\
assert(s->channels == 2);\
for (VAR_6 = 0; VAR_6 < s->blocksize; VAR_6++) {\
int a= s->decoded[0][VAR_6];\
int b= s->decoded[1][VAR_6];\
if (s->is32) {\
*samples_32++ = (left) << s->sample_shift;\
*samples_32++ = (right) << s->sample_shift;\
} else {\
*samples_16++ = (left) << s->sample_shift;\
*samples_16++ = (right) << s->sample_shift;\
}\
}\
break;
switch (s->decorrelation) {
case INDEPENDENT:
for (VAR_7 = 0; VAR_7 < s->blocksize; VAR_7++) {
for (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {
if (s->is32)
*samples_32++ = s->decoded[VAR_6][VAR_7] << s->sample_shift;
else
*samples_16++ = s->decoded[VAR_6][VAR_7] << s->sample_shift;
}
}
break;
case LEFT_SIDE:
DECORRELATE(a,a-b)
case RIGHT_SIDE:
DECORRELATE(a+b,b)
case MID_SIDE:
DECORRELATE( (a-=b>>1) + b, a)
}
*VAR_2 = s->blocksize * s->channels * (s->is32 ? 4 : 2);
end:
VAR_6= (get_bits_count(&s->gb)+7)/8;
if (VAR_6 > VAR_4) {
av_log(s->VAR_0, AV_LOG_ERROR, "overread: %d\n", VAR_6 - VAR_4);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if (s->bitstream_size) {
s->bitstream_index += VAR_6;
s->bitstream_size -= VAR_6;
return VAR_8;
} else
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{",
"FLACContext *s = VAR_0->priv_data;",
"int VAR_5 = 0, VAR_6, VAR_7 = 0, VAR_8 = 0;",
"int16_t *samples_16 = VAR_1;",
"int32_t *samples_32 = VAR_1;",
"int VAR_9= *VAR_2;",
"*VAR_2=0;",
"if (s->max_framesize == 0) {",
"s->max_framesize= FFMAX(4, VAR_4);",
"s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);",
"}",
"if (1 && s->max_framesize) {",
"if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))\nVAR_4= FFMIN(VAR_4, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));",
"VAR_8= VAR_4;",
"if (s->bitstream_size + VAR_4 < VAR_4 || s->bitstream_index + s->bitstream_size + VAR_4 < s->bitstream_index)\nreturn -1;",
"if (s->allocated_bitstream_size < s->bitstream_size + VAR_4)\ns->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + VAR_4);",
"if (s->bitstream_index + s->bitstream_size + VAR_4 > s->allocated_bitstream_size) {",
"memmove(s->bitstream, &s->bitstream[s->bitstream_index],\ns->bitstream_size);",
"s->bitstream_index=0;",
"}",
"memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],\nVAR_3, VAR_4);",
"VAR_3= &s->bitstream[s->bitstream_index];",
"VAR_4 += s->bitstream_size;",
"s->bitstream_size= VAR_4;",
"if (VAR_4 < s->max_framesize && VAR_8) {",
"return VAR_8;",
"}",
"}",
"init_get_bits(&s->gb, VAR_3, VAR_4*8);",
"if (metadata_parse(s))\ngoto end;",
"VAR_5 = show_bits(&s->gb, 16);",
"if ((VAR_5 & 0xFFFE) != 0xFFF8) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"FRAME HEADER not here\\n\");",
"while (get_bits_count(&s->gb)/8+2 < VAR_4 && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)\nskip_bits(&s->gb, 8);",
"goto end;",
"}",
"skip_bits(&s->gb, 16);",
"if (decode_frame(s, VAR_9) < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"decode_frame() failed\\n\");",
"s->bitstream_size=0;",
"s->bitstream_index=0;",
"return -1;",
"}",
"#define DECORRELATE(left, right)\\\nassert(s->channels == 2);\\",
"for (VAR_6 = 0; VAR_6 < s->blocksize; VAR_6++) {\\",
"int a= s->decoded[0][VAR_6];\\",
"int b= s->decoded[1][VAR_6];\\",
"if (s->is32) {\\",
"*samples_32++ = (left) << s->sample_shift;\\",
"*samples_32++ = (right) << s->sample_shift;\\",
"} else {\\",
"*samples_16++ = (left) << s->sample_shift;\\",
"*samples_16++ = (right) << s->sample_shift;\\",
"}\\",
"}\\",
"break;",
"switch (s->decorrelation) {",
"case INDEPENDENT:\nfor (VAR_7 = 0; VAR_7 < s->blocksize; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {",
"if (s->is32)\n*samples_32++ = s->decoded[VAR_6][VAR_7] << s->sample_shift;",
"else\n*samples_16++ = s->decoded[VAR_6][VAR_7] << s->sample_shift;",
"}",
"}",
"break;",
"case LEFT_SIDE:\nDECORRELATE(a,a-b)\ncase RIGHT_SIDE:\nDECORRELATE(a+b,b)\ncase MID_SIDE:\nDECORRELATE( (a-=b>>1) + b, a)\n}",
"*VAR_2 = s->blocksize * s->channels * (s->is32 ? 4 : 2);",
"end:\nVAR_6= (get_bits_count(&s->gb)+7)/8;",
"if (VAR_6 > VAR_4) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"overread: %d\\n\", VAR_6 - VAR_4);",
"s->bitstream_size=0;",
"s->bitstream_index=0;",
"return -1;",
"}",
"if (s->bitstream_size) {",
"s->bitstream_index += VAR_6;",
"s->bitstream_size -= VAR_6;",
"return VAR_8;",
"} else",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
45,
47
],
[
51,
53
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181,
183,
185,
187,
189,
191,
193
],
[
197
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
]
]
|
15,251 | static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
CFHDContext *s = avctx->priv_data;
GetByteContext gb;
ThreadFrame frame = { .f = data };
AVFrame *pic = data;
int ret = 0, i, j, planes, plane, got_buffer = 0;
int16_t *coeff_data;
s->coded_format = AV_PIX_FMT_YUV422P10;
init_frame_defaults(s);
planes = av_pix_fmt_count_planes(s->coded_format);
bytestream2_init(&gb, avpkt->data, avpkt->size);
while (bytestream2_get_bytes_left(&gb) > 4) {
/* Bit weird but implement the tag parsing as the spec says */
uint16_t tagu = bytestream2_get_be16(&gb);
int16_t tag = (int16_t)tagu;
int8_t tag8 = (int8_t)(tagu >> 8);
uint16_t abstag = abs(tag);
int8_t abs_tag8 = abs(tag8);
uint16_t data = bytestream2_get_be16(&gb);
if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data);
} else if (tag == 20) {
av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
s->coded_width = data;
} else if (tag == 21) {
av_log(avctx, AV_LOG_DEBUG, "Height %"PRIu16"\n", data);
s->coded_height = data;
} else if (tag == 101) {
av_log(avctx, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n", data);
if (data < 1 || data > 31) {
av_log(avctx, AV_LOG_ERROR, "Bits per component %d is invalid\n", data);
ret = AVERROR(EINVAL);
break;
}
s->bpc = data;
} else if (tag == 12) {
av_log(avctx, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", data);
s->channel_cnt = data;
if (data > 4) {
av_log(avctx, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", data);
ret = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 14) {
av_log(avctx, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", data);
if (data != SUBBAND_COUNT) {
av_log(avctx, AV_LOG_ERROR, "Subband Count of %"PRIu16" is unsupported\n", data);
ret = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 62) {
s->channel_num = data;
av_log(avctx, AV_LOG_DEBUG, "Channel number %"PRIu16"\n", data);
if (s->channel_num >= planes) {
av_log(avctx, AV_LOG_ERROR, "Invalid channel number\n");
ret = AVERROR(EINVAL);
break;
}
init_plane_defaults(s);
} else if (tag == 48) {
if (s->subband_num != 0 && data == 1) // hack
s->level++;
av_log(avctx, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", data);
s->subband_num = data;
if (s->level >= DWT_LEVELS) {
av_log(avctx, AV_LOG_ERROR, "Invalid level\n");
ret = AVERROR(EINVAL);
break;
}
if (s->subband_num > 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid subband number\n");
ret = AVERROR(EINVAL);
break;
}
} else if (tag == 51) {
av_log(avctx, AV_LOG_DEBUG, "Subband number actual %"PRIu16"\n", data);
s->subband_num_actual = data;
if (s->subband_num_actual >= 10) {
av_log(avctx, AV_LOG_ERROR, "Invalid subband number actual\n");
ret = AVERROR(EINVAL);
break;
}
} else if (tag == 35)
av_log(avctx, AV_LOG_DEBUG, "Lowpass precision bits: %"PRIu16"\n", data);
else if (tag == 53) {
s->quantisation = data;
av_log(avctx, AV_LOG_DEBUG, "Quantisation: %"PRIu16"\n", data);
} else if (tag == 109) {
s->prescale_shift[0] = (data >> 0) & 0x7;
s->prescale_shift[1] = (data >> 3) & 0x7;
s->prescale_shift[2] = (data >> 6) & 0x7;
av_log(avctx, AV_LOG_DEBUG, "Prescale shift (VC-5): %x\n", data);
} else if (tag == 27) {
av_log(avctx, AV_LOG_DEBUG, "Lowpass width %"PRIu16"\n", data);
if (data < 3 || data > s->plane[s->channel_num].band[0][0].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid lowpass width\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[0][0].width = data;
s->plane[s->channel_num].band[0][0].stride = data;
} else if (tag == 28) {
av_log(avctx, AV_LOG_DEBUG, "Lowpass height %"PRIu16"\n", data);
if (data < 3 || data > s->plane[s->channel_num].band[0][0].height) {
av_log(avctx, AV_LOG_ERROR, "Invalid lowpass height\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[0][0].height = data;
} else if (tag == 1)
av_log(avctx, AV_LOG_DEBUG, "Sample type? %"PRIu16"\n", data);
else if (tag == 10) {
if (data != 0) {
avpriv_report_missing_feature(avctx, "Transform type of %"PRIu16, data);
ret = AVERROR_PATCHWELCOME;
break;
}
av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data);
} else if (abstag >= 0x4000 && abstag <= 0x40ff) {
av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 4, tag < 0 ? "optional" : "required");
bytestream2_skipu(&gb, data * 4);
} else if (tag == 23) {
av_log(avctx, AV_LOG_DEBUG, "Skip frame\n");
avpriv_report_missing_feature(avctx, "Skip frame");
ret = AVERROR_PATCHWELCOME;
break;
} else if (tag == 2) {
av_log(avctx, AV_LOG_DEBUG, "tag=2 header - skipping %i tag/value pairs\n", data);
if (data > bytestream2_get_bytes_left(&gb) / 4) {
av_log(avctx, AV_LOG_ERROR, "too many tag/value pairs (%d)\n", data);
ret = AVERROR_INVALIDDATA;
break;
}
for (i = 0; i < data; i++) {
uint16_t tag2 = bytestream2_get_be16(&gb);
uint16_t val2 = bytestream2_get_be16(&gb);
av_log(avctx, AV_LOG_DEBUG, "Tag/Value = %x %x\n", tag2, val2);
}
} else if (tag == 41) {
av_log(avctx, AV_LOG_DEBUG, "Highpass width %i channel %i level %i subband %i\n", data, s->channel_num, s->level, s->subband_num);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass width\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].width = data;
s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);
} else if (tag == 42) {
av_log(avctx, AV_LOG_DEBUG, "Highpass height %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass height\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].height = data;
} else if (tag == 49) {
av_log(avctx, AV_LOG_DEBUG, "Highpass width2 %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass width2\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].width = data;
s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);
} else if (tag == 50) {
av_log(avctx, AV_LOG_DEBUG, "Highpass height2 %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass height2\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].height = data;
} else if (tag == 71) {
s->codebook = data;
av_log(avctx, AV_LOG_DEBUG, "Codebook %i\n", s->codebook);
} else if (tag == 72) {
s->codebook = data;
av_log(avctx, AV_LOG_DEBUG, "Other codebook? %i\n", s->codebook);
} else if (tag == 70) {
av_log(avctx, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %i\n", data);
if (!(data == 10 || data == 12)) {
av_log(avctx, AV_LOG_ERROR, "Invalid bits per channel\n");
ret = AVERROR(EINVAL);
break;
}
s->bpc = data;
} else if (tag == 84) {
av_log(avctx, AV_LOG_DEBUG, "Sample format? %i\n", data);
if (data == 1)
s->coded_format = AV_PIX_FMT_YUV422P10;
else if (data == 3)
s->coded_format = AV_PIX_FMT_GBRP12;
else if (data == 4)
s->coded_format = AV_PIX_FMT_GBRAP12;
else {
avpriv_report_missing_feature(avctx, "Sample format of %"PRIu16, data);
ret = AVERROR_PATCHWELCOME;
break;
}
planes = av_pix_fmt_count_planes(s->coded_format);
} else
av_log(avctx, AV_LOG_DEBUG, "Unknown tag %i data %x\n", tag, data);
/* Some kind of end of header tag */
if (tag == 4 && data == 0x1a4a && s->coded_width && s->coded_height &&
s->coded_format != AV_PIX_FMT_NONE) {
if (s->a_width != s->coded_width || s->a_height != s->coded_height ||
s->a_format != s->coded_format) {
free_buffers(avctx);
if ((ret = alloc_buffers(avctx)) < 0) {
free_buffers(avctx);
return ret;
}
}
ret = ff_set_dimensions(avctx, s->coded_width, s->coded_height);
if (ret < 0)
return ret;
frame.f->width =
frame.f->height = 0;
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
s->coded_width = 0;
s->coded_height = 0;
s->coded_format = AV_PIX_FMT_NONE;
got_buffer = 1;
}
coeff_data = s->plane[s->channel_num].subband[s->subband_num_actual];
/* Lowpass coefficients */
if (tag == 4 && data == 0xf0f && s->a_width && s->a_height) {
int lowpass_height = s->plane[s->channel_num].band[0][0].height;
int lowpass_width = s->plane[s->channel_num].band[0][0].width;
int lowpass_a_height = s->plane[s->channel_num].band[0][0].a_height;
int lowpass_a_width = s->plane[s->channel_num].band[0][0].a_width;
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
lowpass_a_width * lowpass_a_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) {
av_log(avctx, AV_LOG_ERROR, "Too many lowpass coefficients\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Start of lowpass coeffs component %d height:%d, width:%d\n", s->channel_num, lowpass_height, lowpass_width);
for (i = 0; i < lowpass_height; i++) {
for (j = 0; j < lowpass_width; j++)
coeff_data[j] = bytestream2_get_be16u(&gb);
coeff_data += lowpass_width;
}
/* Align to mod-4 position to continue reading tags */
bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR);
/* Copy last line of coefficients if odd height */
if (lowpass_height & 1) {
memcpy(&coeff_data[lowpass_height * lowpass_width],
&coeff_data[(lowpass_height - 1) * lowpass_width],
lowpass_width * sizeof(*coeff_data));
}
av_log(avctx, AV_LOG_DEBUG, "Lowpass coefficients %d\n", lowpass_width * lowpass_height);
}
if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) {
int highpass_height = s->plane[s->channel_num].band[s->level][s->subband_num].height;
int highpass_width = s->plane[s->channel_num].band[s->level][s->subband_num].width;
int highpass_a_width = s->plane[s->channel_num].band[s->level][s->subband_num].a_width;
int highpass_a_height = s->plane[s->channel_num].band[s->level][s->subband_num].a_height;
int highpass_stride = s->plane[s->channel_num].band[s->level][s->subband_num].stride;
int expected;
int a_expected = highpass_a_height * highpass_a_width;
int level, run, coeff;
int count = 0, bytes;
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficients\n");
ret = AVERROR(EINVAL);
goto end;
}
expected = highpass_height * highpass_stride;
av_log(avctx, AV_LOG_DEBUG, "Start subband coeffs plane %i level %i codebook %i expected %i\n", s->channel_num, s->level, s->codebook, expected);
init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8);
{
OPEN_READER(re, &s->gb);
if (!s->codebook) {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, s->table_9_rl_vlc,
VLC_BITS, 3, 1);
/* escape */
if (level == 64)
break;
count += run;
if (count > expected)
break;
coeff = dequant_and_decompand(level, s->quantisation);
for (i = 0; i < run; i++)
*coeff_data++ = coeff;
}
} else {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, s->table_18_rl_vlc,
VLC_BITS, 3, 1);
/* escape */
if (level == 255 && run == 2)
break;
count += run;
if (count > expected)
break;
coeff = dequant_and_decompand(level, s->quantisation);
for (i = 0; i < run; i++)
*coeff_data++ = coeff;
}
}
CLOSE_READER(re, &s->gb);
}
if (count > expected) {
av_log(avctx, AV_LOG_ERROR, "Escape codeword not found, probably corrupt data\n");
ret = AVERROR(EINVAL);
goto end;
}
bytes = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4);
if (bytes > bytestream2_get_bytes_left(&gb)) {
av_log(avctx, AV_LOG_ERROR, "Bitstream overread error\n");
ret = AVERROR(EINVAL);
goto end;
} else
bytestream2_seek(&gb, bytes, SEEK_CUR);
av_log(avctx, AV_LOG_DEBUG, "End subband coeffs %i extra %i\n", count, count - expected);
s->codebook = 0;
/* Copy last line of coefficients if odd height */
if (highpass_height & 1) {
memcpy(&coeff_data[highpass_height * highpass_stride],
&coeff_data[(highpass_height - 1) * highpass_stride],
highpass_stride * sizeof(*coeff_data));
}
}
}
if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE ||
s->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
planes = av_pix_fmt_count_planes(avctx->pix_fmt);
for (plane = 0; plane < planes && !ret; plane++) {
/* level 1 */
int lowpass_height = s->plane[plane].band[0][0].height;
int lowpass_width = s->plane[plane].band[0][0].width;
int highpass_stride = s->plane[plane].band[0][1].stride;
int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
int16_t *low, *high, *output, *dst;
if (lowpass_height > s->plane[plane].band[0][0].a_height || lowpass_width > s->plane[plane].band[0][0].a_width ||
!highpass_stride || s->plane[plane].band[0][1].width > s->plane[plane].band[0][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[2];
output = s->plane[plane].l_h[0];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[1];
high = s->plane[plane].subband[3];
output = s->plane[plane].l_h[1];
for (i = 0; i < lowpass_width; i++) {
// note the stride of "low" is highpass_stride
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].l_h[0];
high = s->plane[plane].l_h[1];
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter(output, low, high, lowpass_width);
low += lowpass_width;
high += lowpass_width;
output += lowpass_width * 2;
}
if (s->bpc == 12) {
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
for (j = 0; j < lowpass_width * 2; j++)
output[j] *= 4;
output += lowpass_width * 2;
}
}
/* level 2 */
lowpass_height = s->plane[plane].band[1][1].height;
lowpass_width = s->plane[plane].band[1][1].width;
highpass_stride = s->plane[plane].band[1][1].stride;
if (lowpass_height > s->plane[plane].band[1][1].a_height || lowpass_width > s->plane[plane].band[1][1].a_width ||
!highpass_stride || s->plane[plane].band[1][1].width > s->plane[plane].band[1][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[5];
output = s->plane[plane].l_h[3];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[4];
high = s->plane[plane].subband[6];
output = s->plane[plane].l_h[4];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].l_h[3];
high = s->plane[plane].l_h[4];
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter(output, low, high, lowpass_width);
low += lowpass_width;
high += lowpass_width;
output += lowpass_width * 2;
}
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
for (j = 0; j < lowpass_width * 2; j++)
output[j] *= 4;
output += lowpass_width * 2;
}
/* level 3 */
lowpass_height = s->plane[plane].band[2][1].height;
lowpass_width = s->plane[plane].band[2][1].width;
highpass_stride = s->plane[plane].band[2][1].stride;
if (lowpass_height > s->plane[plane].band[2][1].a_height || lowpass_width > s->plane[plane].band[2][1].a_width ||
!highpass_stride || s->plane[plane].band[2][1].width > s->plane[plane].band[2][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[8];
output = s->plane[plane].l_h[6];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[7];
high = s->plane[plane].subband[9];
output = s->plane[plane].l_h[7];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
dst = (int16_t *)pic->data[act_plane];
low = s->plane[plane].l_h[6];
high = s->plane[plane].l_h[7];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
low += lowpass_width;
high += lowpass_width;
dst += pic->linesize[act_plane] / 2;
}
}
end:
if (ret < 0)
return ret;
*got_frame = 1;
return avpkt->size;
}
| false | FFmpeg | 47c93657249f1a4bc8a7aaf2f9f3a33510bee38c | static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
CFHDContext *s = avctx->priv_data;
GetByteContext gb;
ThreadFrame frame = { .f = data };
AVFrame *pic = data;
int ret = 0, i, j, planes, plane, got_buffer = 0;
int16_t *coeff_data;
s->coded_format = AV_PIX_FMT_YUV422P10;
init_frame_defaults(s);
planes = av_pix_fmt_count_planes(s->coded_format);
bytestream2_init(&gb, avpkt->data, avpkt->size);
while (bytestream2_get_bytes_left(&gb) > 4) {
uint16_t tagu = bytestream2_get_be16(&gb);
int16_t tag = (int16_t)tagu;
int8_t tag8 = (int8_t)(tagu >> 8);
uint16_t abstag = abs(tag);
int8_t abs_tag8 = abs(tag8);
uint16_t data = bytestream2_get_be16(&gb);
if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data);
} else if (tag == 20) {
av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
s->coded_width = data;
} else if (tag == 21) {
av_log(avctx, AV_LOG_DEBUG, "Height %"PRIu16"\n", data);
s->coded_height = data;
} else if (tag == 101) {
av_log(avctx, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n", data);
if (data < 1 || data > 31) {
av_log(avctx, AV_LOG_ERROR, "Bits per component %d is invalid\n", data);
ret = AVERROR(EINVAL);
break;
}
s->bpc = data;
} else if (tag == 12) {
av_log(avctx, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", data);
s->channel_cnt = data;
if (data > 4) {
av_log(avctx, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", data);
ret = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 14) {
av_log(avctx, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", data);
if (data != SUBBAND_COUNT) {
av_log(avctx, AV_LOG_ERROR, "Subband Count of %"PRIu16" is unsupported\n", data);
ret = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 62) {
s->channel_num = data;
av_log(avctx, AV_LOG_DEBUG, "Channel number %"PRIu16"\n", data);
if (s->channel_num >= planes) {
av_log(avctx, AV_LOG_ERROR, "Invalid channel number\n");
ret = AVERROR(EINVAL);
break;
}
init_plane_defaults(s);
} else if (tag == 48) {
if (s->subband_num != 0 && data == 1)
s->level++;
av_log(avctx, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", data);
s->subband_num = data;
if (s->level >= DWT_LEVELS) {
av_log(avctx, AV_LOG_ERROR, "Invalid level\n");
ret = AVERROR(EINVAL);
break;
}
if (s->subband_num > 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid subband number\n");
ret = AVERROR(EINVAL);
break;
}
} else if (tag == 51) {
av_log(avctx, AV_LOG_DEBUG, "Subband number actual %"PRIu16"\n", data);
s->subband_num_actual = data;
if (s->subband_num_actual >= 10) {
av_log(avctx, AV_LOG_ERROR, "Invalid subband number actual\n");
ret = AVERROR(EINVAL);
break;
}
} else if (tag == 35)
av_log(avctx, AV_LOG_DEBUG, "Lowpass precision bits: %"PRIu16"\n", data);
else if (tag == 53) {
s->quantisation = data;
av_log(avctx, AV_LOG_DEBUG, "Quantisation: %"PRIu16"\n", data);
} else if (tag == 109) {
s->prescale_shift[0] = (data >> 0) & 0x7;
s->prescale_shift[1] = (data >> 3) & 0x7;
s->prescale_shift[2] = (data >> 6) & 0x7;
av_log(avctx, AV_LOG_DEBUG, "Prescale shift (VC-5): %x\n", data);
} else if (tag == 27) {
av_log(avctx, AV_LOG_DEBUG, "Lowpass width %"PRIu16"\n", data);
if (data < 3 || data > s->plane[s->channel_num].band[0][0].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid lowpass width\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[0][0].width = data;
s->plane[s->channel_num].band[0][0].stride = data;
} else if (tag == 28) {
av_log(avctx, AV_LOG_DEBUG, "Lowpass height %"PRIu16"\n", data);
if (data < 3 || data > s->plane[s->channel_num].band[0][0].height) {
av_log(avctx, AV_LOG_ERROR, "Invalid lowpass height\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[0][0].height = data;
} else if (tag == 1)
av_log(avctx, AV_LOG_DEBUG, "Sample type? %"PRIu16"\n", data);
else if (tag == 10) {
if (data != 0) {
avpriv_report_missing_feature(avctx, "Transform type of %"PRIu16, data);
ret = AVERROR_PATCHWELCOME;
break;
}
av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data);
} else if (abstag >= 0x4000 && abstag <= 0x40ff) {
av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 4, tag < 0 ? "optional" : "required");
bytestream2_skipu(&gb, data * 4);
} else if (tag == 23) {
av_log(avctx, AV_LOG_DEBUG, "Skip frame\n");
avpriv_report_missing_feature(avctx, "Skip frame");
ret = AVERROR_PATCHWELCOME;
break;
} else if (tag == 2) {
av_log(avctx, AV_LOG_DEBUG, "tag=2 header - skipping %i tag/value pairs\n", data);
if (data > bytestream2_get_bytes_left(&gb) / 4) {
av_log(avctx, AV_LOG_ERROR, "too many tag/value pairs (%d)\n", data);
ret = AVERROR_INVALIDDATA;
break;
}
for (i = 0; i < data; i++) {
uint16_t tag2 = bytestream2_get_be16(&gb);
uint16_t val2 = bytestream2_get_be16(&gb);
av_log(avctx, AV_LOG_DEBUG, "Tag/Value = %x %x\n", tag2, val2);
}
} else if (tag == 41) {
av_log(avctx, AV_LOG_DEBUG, "Highpass width %i channel %i level %i subband %i\n", data, s->channel_num, s->level, s->subband_num);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass width\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].width = data;
s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);
} else if (tag == 42) {
av_log(avctx, AV_LOG_DEBUG, "Highpass height %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass height\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].height = data;
} else if (tag == 49) {
av_log(avctx, AV_LOG_DEBUG, "Highpass width2 %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass width2\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].width = data;
s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);
} else if (tag == 50) {
av_log(avctx, AV_LOG_DEBUG, "Highpass height2 %i\n", data);
if (data < 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid highpass height2\n");
ret = AVERROR(EINVAL);
break;
}
s->plane[s->channel_num].band[s->level][s->subband_num].height = data;
} else if (tag == 71) {
s->codebook = data;
av_log(avctx, AV_LOG_DEBUG, "Codebook %i\n", s->codebook);
} else if (tag == 72) {
s->codebook = data;
av_log(avctx, AV_LOG_DEBUG, "Other codebook? %i\n", s->codebook);
} else if (tag == 70) {
av_log(avctx, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %i\n", data);
if (!(data == 10 || data == 12)) {
av_log(avctx, AV_LOG_ERROR, "Invalid bits per channel\n");
ret = AVERROR(EINVAL);
break;
}
s->bpc = data;
} else if (tag == 84) {
av_log(avctx, AV_LOG_DEBUG, "Sample format? %i\n", data);
if (data == 1)
s->coded_format = AV_PIX_FMT_YUV422P10;
else if (data == 3)
s->coded_format = AV_PIX_FMT_GBRP12;
else if (data == 4)
s->coded_format = AV_PIX_FMT_GBRAP12;
else {
avpriv_report_missing_feature(avctx, "Sample format of %"PRIu16, data);
ret = AVERROR_PATCHWELCOME;
break;
}
planes = av_pix_fmt_count_planes(s->coded_format);
} else
av_log(avctx, AV_LOG_DEBUG, "Unknown tag %i data %x\n", tag, data);
if (tag == 4 && data == 0x1a4a && s->coded_width && s->coded_height &&
s->coded_format != AV_PIX_FMT_NONE) {
if (s->a_width != s->coded_width || s->a_height != s->coded_height ||
s->a_format != s->coded_format) {
free_buffers(avctx);
if ((ret = alloc_buffers(avctx)) < 0) {
free_buffers(avctx);
return ret;
}
}
ret = ff_set_dimensions(avctx, s->coded_width, s->coded_height);
if (ret < 0)
return ret;
frame.f->width =
frame.f->height = 0;
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
s->coded_width = 0;
s->coded_height = 0;
s->coded_format = AV_PIX_FMT_NONE;
got_buffer = 1;
}
coeff_data = s->plane[s->channel_num].subband[s->subband_num_actual];
if (tag == 4 && data == 0xf0f && s->a_width && s->a_height) {
int lowpass_height = s->plane[s->channel_num].band[0][0].height;
int lowpass_width = s->plane[s->channel_num].band[0][0].width;
int lowpass_a_height = s->plane[s->channel_num].band[0][0].a_height;
int lowpass_a_width = s->plane[s->channel_num].band[0][0].a_width;
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
lowpass_a_width * lowpass_a_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) {
av_log(avctx, AV_LOG_ERROR, "Too many lowpass coefficients\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Start of lowpass coeffs component %d height:%d, width:%d\n", s->channel_num, lowpass_height, lowpass_width);
for (i = 0; i < lowpass_height; i++) {
for (j = 0; j < lowpass_width; j++)
coeff_data[j] = bytestream2_get_be16u(&gb);
coeff_data += lowpass_width;
}
bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR);
if (lowpass_height & 1) {
memcpy(&coeff_data[lowpass_height * lowpass_width],
&coeff_data[(lowpass_height - 1) * lowpass_width],
lowpass_width * sizeof(*coeff_data));
}
av_log(avctx, AV_LOG_DEBUG, "Lowpass coefficients %d\n", lowpass_width * lowpass_height);
}
if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) {
int highpass_height = s->plane[s->channel_num].band[s->level][s->subband_num].height;
int highpass_width = s->plane[s->channel_num].band[s->level][s->subband_num].width;
int highpass_a_width = s->plane[s->channel_num].band[s->level][s->subband_num].a_width;
int highpass_a_height = s->plane[s->channel_num].band[s->level][s->subband_num].a_height;
int highpass_stride = s->plane[s->channel_num].band[s->level][s->subband_num].stride;
int expected;
int a_expected = highpass_a_height * highpass_a_width;
int level, run, coeff;
int count = 0, bytes;
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficients\n");
ret = AVERROR(EINVAL);
goto end;
}
expected = highpass_height * highpass_stride;
av_log(avctx, AV_LOG_DEBUG, "Start subband coeffs plane %i level %i codebook %i expected %i\n", s->channel_num, s->level, s->codebook, expected);
init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8);
{
OPEN_READER(re, &s->gb);
if (!s->codebook) {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, s->table_9_rl_vlc,
VLC_BITS, 3, 1);
if (level == 64)
break;
count += run;
if (count > expected)
break;
coeff = dequant_and_decompand(level, s->quantisation);
for (i = 0; i < run; i++)
*coeff_data++ = coeff;
}
} else {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, s->table_18_rl_vlc,
VLC_BITS, 3, 1);
if (level == 255 && run == 2)
break;
count += run;
if (count > expected)
break;
coeff = dequant_and_decompand(level, s->quantisation);
for (i = 0; i < run; i++)
*coeff_data++ = coeff;
}
}
CLOSE_READER(re, &s->gb);
}
if (count > expected) {
av_log(avctx, AV_LOG_ERROR, "Escape codeword not found, probably corrupt data\n");
ret = AVERROR(EINVAL);
goto end;
}
bytes = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4);
if (bytes > bytestream2_get_bytes_left(&gb)) {
av_log(avctx, AV_LOG_ERROR, "Bitstream overread error\n");
ret = AVERROR(EINVAL);
goto end;
} else
bytestream2_seek(&gb, bytes, SEEK_CUR);
av_log(avctx, AV_LOG_DEBUG, "End subband coeffs %i extra %i\n", count, count - expected);
s->codebook = 0;
if (highpass_height & 1) {
memcpy(&coeff_data[highpass_height * highpass_stride],
&coeff_data[(highpass_height - 1) * highpass_stride],
highpass_stride * sizeof(*coeff_data));
}
}
}
if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE ||
s->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
if (!got_buffer) {
av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");
ret = AVERROR(EINVAL);
goto end;
}
planes = av_pix_fmt_count_planes(avctx->pix_fmt);
for (plane = 0; plane < planes && !ret; plane++) {
int lowpass_height = s->plane[plane].band[0][0].height;
int lowpass_width = s->plane[plane].band[0][0].width;
int highpass_stride = s->plane[plane].band[0][1].stride;
int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
int16_t *low, *high, *output, *dst;
if (lowpass_height > s->plane[plane].band[0][0].a_height || lowpass_width > s->plane[plane].band[0][0].a_width ||
!highpass_stride || s->plane[plane].band[0][1].width > s->plane[plane].band[0][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[2];
output = s->plane[plane].l_h[0];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[1];
high = s->plane[plane].subband[3];
output = s->plane[plane].l_h[1];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].l_h[0];
high = s->plane[plane].l_h[1];
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter(output, low, high, lowpass_width);
low += lowpass_width;
high += lowpass_width;
output += lowpass_width * 2;
}
if (s->bpc == 12) {
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
for (j = 0; j < lowpass_width * 2; j++)
output[j] *= 4;
output += lowpass_width * 2;
}
}
lowpass_height = s->plane[plane].band[1][1].height;
lowpass_width = s->plane[plane].band[1][1].width;
highpass_stride = s->plane[plane].band[1][1].stride;
if (lowpass_height > s->plane[plane].band[1][1].a_height || lowpass_width > s->plane[plane].band[1][1].a_width ||
!highpass_stride || s->plane[plane].band[1][1].width > s->plane[plane].band[1][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[5];
output = s->plane[plane].l_h[3];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[4];
high = s->plane[plane].subband[6];
output = s->plane[plane].l_h[4];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].l_h[3];
high = s->plane[plane].l_h[4];
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter(output, low, high, lowpass_width);
low += lowpass_width;
high += lowpass_width;
output += lowpass_width * 2;
}
output = s->plane[plane].subband[0];
for (i = 0; i < lowpass_height * 2; i++) {
for (j = 0; j < lowpass_width * 2; j++)
output[j] *= 4;
output += lowpass_width * 2;
}
lowpass_height = s->plane[plane].band[2][1].height;
lowpass_width = s->plane[plane].band[2][1].width;
highpass_stride = s->plane[plane].band[2][1].stride;
if (lowpass_height > s->plane[plane].band[2][1].a_height || lowpass_width > s->plane[plane].band[2][1].a_width ||
!highpass_stride || s->plane[plane].band[2][1].width > s->plane[plane].band[2][1].a_width) {
av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
ret = AVERROR(EINVAL);
goto end;
}
av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[8];
output = s->plane[plane].l_h[6];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
low = s->plane[plane].subband[7];
high = s->plane[plane].subband[9];
output = s->plane[plane].l_h[7];
for (i = 0; i < lowpass_width; i++) {
vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
low++;
high++;
output++;
}
dst = (int16_t *)pic->data[act_plane];
low = s->plane[plane].l_h[6];
high = s->plane[plane].l_h[7];
for (i = 0; i < lowpass_height * 2; i++) {
horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
low += lowpass_width;
high += lowpass_width;
dst += pic->linesize[act_plane] / 2;
}
}
end:
if (ret < 0)
return ret;
*got_frame = 1;
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
CFHDContext *s = VAR_0->priv_data;
GetByteContext gb;
ThreadFrame frame = { .f = VAR_1 };
AVFrame *pic = VAR_1;
int VAR_4 = 0, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 0;
int16_t *coeff_data;
s->coded_format = AV_PIX_FMT_YUV422P10;
init_frame_defaults(s);
VAR_7 = av_pix_fmt_count_planes(s->coded_format);
bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);
while (bytestream2_get_bytes_left(&gb) > 4) {
uint16_t tagu = bytestream2_get_be16(&gb);
int16_t tag = (int16_t)tagu;
int8_t tag8 = (int8_t)(tagu >> 8);
uint16_t abstag = abs(tag);
int8_t abs_tag8 = abs(tag8);
uint16_t VAR_1 = bytestream2_get_be16(&gb);
if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
av_log(VAR_0, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | VAR_1);
} else if (tag == 20) {
av_log(VAR_0, AV_LOG_DEBUG, "Width %"PRIu16"\n", VAR_1);
s->coded_width = VAR_1;
} else if (tag == 21) {
av_log(VAR_0, AV_LOG_DEBUG, "Height %"PRIu16"\n", VAR_1);
s->coded_height = VAR_1;
} else if (tag == 101) {
av_log(VAR_0, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n", VAR_1);
if (VAR_1 < 1 || VAR_1 > 31) {
av_log(VAR_0, AV_LOG_ERROR, "Bits per component %d is invalid\n", VAR_1);
VAR_4 = AVERROR(EINVAL);
break;
}
s->bpc = VAR_1;
} else if (tag == 12) {
av_log(VAR_0, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", VAR_1);
s->channel_cnt = VAR_1;
if (VAR_1 > 4) {
av_log(VAR_0, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", VAR_1);
VAR_4 = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 14) {
av_log(VAR_0, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", VAR_1);
if (VAR_1 != SUBBAND_COUNT) {
av_log(VAR_0, AV_LOG_ERROR, "Subband Count of %"PRIu16" is unsupported\n", VAR_1);
VAR_4 = AVERROR_PATCHWELCOME;
break;
}
} else if (tag == 62) {
s->channel_num = VAR_1;
av_log(VAR_0, AV_LOG_DEBUG, "Channel number %"PRIu16"\n", VAR_1);
if (s->channel_num >= VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid channel number\n");
VAR_4 = AVERROR(EINVAL);
break;
}
init_plane_defaults(s);
} else if (tag == 48) {
if (s->subband_num != 0 && VAR_1 == 1)
s->VAR_21++;
av_log(VAR_0, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", VAR_1);
s->subband_num = VAR_1;
if (s->VAR_21 >= DWT_LEVELS) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_21\n");
VAR_4 = AVERROR(EINVAL);
break;
}
if (s->subband_num > 3) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid subband number\n");
VAR_4 = AVERROR(EINVAL);
break;
}
} else if (tag == 51) {
av_log(VAR_0, AV_LOG_DEBUG, "Subband number actual %"PRIu16"\n", VAR_1);
s->subband_num_actual = VAR_1;
if (s->subband_num_actual >= 10) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid subband number actual\n");
VAR_4 = AVERROR(EINVAL);
break;
}
} else if (tag == 35)
av_log(VAR_0, AV_LOG_DEBUG, "Lowpass precision bits: %"PRIu16"\n", VAR_1);
else if (tag == 53) {
s->quantisation = VAR_1;
av_log(VAR_0, AV_LOG_DEBUG, "Quantisation: %"PRIu16"\n", VAR_1);
} else if (tag == 109) {
s->prescale_shift[0] = (VAR_1 >> 0) & 0x7;
s->prescale_shift[1] = (VAR_1 >> 3) & 0x7;
s->prescale_shift[2] = (VAR_1 >> 6) & 0x7;
av_log(VAR_0, AV_LOG_DEBUG, "Prescale shift (VC-5): %x\n", VAR_1);
} else if (tag == 27) {
av_log(VAR_0, AV_LOG_DEBUG, "Lowpass width %"PRIu16"\n", VAR_1);
if (VAR_1 < 3 || VAR_1 > s->VAR_8[s->channel_num].band[0][0].a_width) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid lowpass width\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[0][0].width = VAR_1;
s->VAR_8[s->channel_num].band[0][0].stride = VAR_1;
} else if (tag == 28) {
av_log(VAR_0, AV_LOG_DEBUG, "Lowpass height %"PRIu16"\n", VAR_1);
if (VAR_1 < 3 || VAR_1 > s->VAR_8[s->channel_num].band[0][0].height) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid lowpass height\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[0][0].height = VAR_1;
} else if (tag == 1)
av_log(VAR_0, AV_LOG_DEBUG, "Sample type? %"PRIu16"\n", VAR_1);
else if (tag == 10) {
if (VAR_1 != 0) {
avpriv_report_missing_feature(VAR_0, "Transform type of %"PRIu16, VAR_1);
VAR_4 = AVERROR_PATCHWELCOME;
break;
}
av_log(VAR_0, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", VAR_1);
} else if (abstag >= 0x4000 && abstag <= 0x40ff) {
av_log(VAR_0, AV_LOG_DEBUG, "Small chunk length %d %s\n", VAR_1 * 4, tag < 0 ? "optional" : "required");
bytestream2_skipu(&gb, VAR_1 * 4);
} else if (tag == 23) {
av_log(VAR_0, AV_LOG_DEBUG, "Skip frame\n");
avpriv_report_missing_feature(VAR_0, "Skip frame");
VAR_4 = AVERROR_PATCHWELCOME;
break;
} else if (tag == 2) {
av_log(VAR_0, AV_LOG_DEBUG, "tag=2 header - skipping %VAR_5 tag/value pairs\n", VAR_1);
if (VAR_1 > bytestream2_get_bytes_left(&gb) / 4) {
av_log(VAR_0, AV_LOG_ERROR, "too many tag/value pairs (%d)\n", VAR_1);
VAR_4 = AVERROR_INVALIDDATA;
break;
}
for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {
uint16_t tag2 = bytestream2_get_be16(&gb);
uint16_t val2 = bytestream2_get_be16(&gb);
av_log(VAR_0, AV_LOG_DEBUG, "Tag/Value = %x %x\n", tag2, val2);
}
} else if (tag == 41) {
av_log(VAR_0, AV_LOG_DEBUG, "Highpass width %VAR_5 channel %VAR_5 VAR_21 %VAR_5 subband %VAR_5\n", VAR_1, s->channel_num, s->VAR_21, s->subband_num);
if (VAR_1 < 3) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid highpass width\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width = VAR_1;
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride = FFALIGN(VAR_1, 8);
} else if (tag == 42) {
av_log(VAR_0, AV_LOG_DEBUG, "Highpass height %VAR_5\n", VAR_1);
if (VAR_1 < 3) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid highpass height\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height = VAR_1;
} else if (tag == 49) {
av_log(VAR_0, AV_LOG_DEBUG, "Highpass width2 %VAR_5\n", VAR_1);
if (VAR_1 < 3) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid highpass width2\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width = VAR_1;
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride = FFALIGN(VAR_1, 8);
} else if (tag == 50) {
av_log(VAR_0, AV_LOG_DEBUG, "Highpass height2 %VAR_5\n", VAR_1);
if (VAR_1 < 3) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid highpass height2\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height = VAR_1;
} else if (tag == 71) {
s->codebook = VAR_1;
av_log(VAR_0, AV_LOG_DEBUG, "Codebook %VAR_5\n", s->codebook);
} else if (tag == 72) {
s->codebook = VAR_1;
av_log(VAR_0, AV_LOG_DEBUG, "Other codebook? %VAR_5\n", s->codebook);
} else if (tag == 70) {
av_log(VAR_0, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %VAR_5\n", VAR_1);
if (!(VAR_1 == 10 || VAR_1 == 12)) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid bits per channel\n");
VAR_4 = AVERROR(EINVAL);
break;
}
s->bpc = VAR_1;
} else if (tag == 84) {
av_log(VAR_0, AV_LOG_DEBUG, "Sample format? %VAR_5\n", VAR_1);
if (VAR_1 == 1)
s->coded_format = AV_PIX_FMT_YUV422P10;
else if (VAR_1 == 3)
s->coded_format = AV_PIX_FMT_GBRP12;
else if (VAR_1 == 4)
s->coded_format = AV_PIX_FMT_GBRAP12;
else {
avpriv_report_missing_feature(VAR_0, "Sample format of %"PRIu16, VAR_1);
VAR_4 = AVERROR_PATCHWELCOME;
break;
}
VAR_7 = av_pix_fmt_count_planes(s->coded_format);
} else
av_log(VAR_0, AV_LOG_DEBUG, "Unknown tag %VAR_5 VAR_1 %x\n", tag, VAR_1);
if (tag == 4 && VAR_1 == 0x1a4a && s->coded_width && s->coded_height &&
s->coded_format != AV_PIX_FMT_NONE) {
if (s->a_width != s->coded_width || s->a_height != s->coded_height ||
s->a_format != s->coded_format) {
free_buffers(VAR_0);
if ((VAR_4 = alloc_buffers(VAR_0)) < 0) {
free_buffers(VAR_0);
return VAR_4;
}
}
VAR_4 = ff_set_dimensions(VAR_0, s->coded_width, s->coded_height);
if (VAR_4 < 0)
return VAR_4;
frame.f->width =
frame.f->height = 0;
if ((VAR_4 = ff_thread_get_buffer(VAR_0, &frame, 0)) < 0)
return VAR_4;
s->coded_width = 0;
s->coded_height = 0;
s->coded_format = AV_PIX_FMT_NONE;
VAR_9 = 1;
}
coeff_data = s->VAR_8[s->channel_num].subband[s->subband_num_actual];
if (tag == 4 && VAR_1 == 0xf0f && s->a_width && s->a_height) {
int VAR_26 = s->VAR_8[s->channel_num].band[0][0].height;
int VAR_26 = s->VAR_8[s->channel_num].band[0][0].width;
int VAR_12 = s->VAR_8[s->channel_num].band[0][0].a_height;
int VAR_13 = s->VAR_8[s->channel_num].band[0][0].a_width;
if (!VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "No end of header tag found\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
if (VAR_26 > VAR_12 || VAR_26 > VAR_13 ||
VAR_13 * VAR_12 * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) {
av_log(VAR_0, AV_LOG_ERROR, "Too many lowpass coefficients\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
av_log(VAR_0, AV_LOG_DEBUG, "Start of lowpass coeffs component %d height:%d, width:%d\n", s->channel_num, VAR_26, VAR_26);
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_26; VAR_6++)
coeff_data[VAR_6] = bytestream2_get_be16u(&gb);
coeff_data += VAR_26;
}
bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR);
if (VAR_26 & 1) {
memcpy(&coeff_data[VAR_26 * VAR_26],
&coeff_data[(VAR_26 - 1) * VAR_26],
VAR_26 * sizeof(*coeff_data));
}
av_log(VAR_0, AV_LOG_DEBUG, "Lowpass coefficients %d\n", VAR_26 * VAR_26);
}
if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) {
int VAR_14 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height;
int VAR_15 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width;
int VAR_16 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].a_width;
int VAR_17 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].a_height;
int VAR_26 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride;
int VAR_19;
int VAR_20 = VAR_17 * VAR_16;
int VAR_21, VAR_22, VAR_23;
int VAR_24 = 0, VAR_25;
if (!VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "No end of header tag found\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
if (VAR_14 > VAR_17 || VAR_15 > VAR_16 || VAR_20 < VAR_14 * (uint64_t)VAR_26) {
av_log(VAR_0, AV_LOG_ERROR, "Too many highpass coefficients\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
VAR_19 = VAR_14 * VAR_26;
av_log(VAR_0, AV_LOG_DEBUG, "Start subband coeffs VAR_8 %VAR_5 VAR_21 %VAR_5 codebook %VAR_5 VAR_19 %VAR_5\n", s->channel_num, s->VAR_21, s->codebook, VAR_19);
init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8);
{
OPEN_READER(re, &s->gb);
if (!s->codebook) {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(VAR_21, VAR_22, re, &s->gb, s->table_9_rl_vlc,
VLC_BITS, 3, 1);
if (VAR_21 == 64)
break;
VAR_24 += VAR_22;
if (VAR_24 > VAR_19)
break;
VAR_23 = dequant_and_decompand(VAR_21, s->quantisation);
for (VAR_5 = 0; VAR_5 < VAR_22; VAR_5++)
*coeff_data++ = VAR_23;
}
} else {
while (1) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(VAR_21, VAR_22, re, &s->gb, s->table_18_rl_vlc,
VLC_BITS, 3, 1);
if (VAR_21 == 255 && VAR_22 == 2)
break;
VAR_24 += VAR_22;
if (VAR_24 > VAR_19)
break;
VAR_23 = dequant_and_decompand(VAR_21, s->quantisation);
for (VAR_5 = 0; VAR_5 < VAR_22; VAR_5++)
*coeff_data++ = VAR_23;
}
}
CLOSE_READER(re, &s->gb);
}
if (VAR_24 > VAR_19) {
av_log(VAR_0, AV_LOG_ERROR, "Escape codeword not found, probably corrupt VAR_1\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
VAR_25 = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4);
if (VAR_25 > bytestream2_get_bytes_left(&gb)) {
av_log(VAR_0, AV_LOG_ERROR, "Bitstream overread error\n");
VAR_4 = AVERROR(EINVAL);
goto end;
} else
bytestream2_seek(&gb, VAR_25, SEEK_CUR);
av_log(VAR_0, AV_LOG_DEBUG, "End subband coeffs %VAR_5 extra %VAR_5\n", VAR_24, VAR_24 - VAR_19);
s->codebook = 0;
if (VAR_14 & 1) {
memcpy(&coeff_data[VAR_14 * VAR_26],
&coeff_data[(VAR_14 - 1) * VAR_26],
VAR_26 * sizeof(*coeff_data));
}
}
}
if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE ||
s->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid dimensions\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
if (!VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "No end of header tag found\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
VAR_7 = av_pix_fmt_count_planes(VAR_0->pix_fmt);
for (VAR_8 = 0; VAR_8 < VAR_7 && !VAR_4; VAR_8++) {
int VAR_26 = s->VAR_8[VAR_8].band[0][0].height;
int VAR_26 = s->VAR_8[VAR_8].band[0][0].width;
int VAR_26 = s->VAR_8[VAR_8].band[0][1].stride;
int VAR_26 = VAR_8 == 1 ? 2 : VAR_8 == 2 ? 1 : VAR_8;
int16_t *low, *high, *output, *dst;
if (VAR_26 > s->VAR_8[VAR_8].band[0][0].a_height || VAR_26 > s->VAR_8[VAR_8].band[0][0].a_width ||
!VAR_26 || s->VAR_8[VAR_8].band[0][1].width > s->VAR_8[VAR_8].band[0][1].a_width) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_8 dimensions\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
av_log(VAR_0, AV_LOG_DEBUG, "Decoding VAR_21 1 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\n", VAR_8, VAR_26, VAR_26, VAR_26);
low = s->VAR_8[VAR_8].subband[0];
high = s->VAR_8[VAR_8].subband[2];
output = s->VAR_8[VAR_8].l_h[0];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
low = s->VAR_8[VAR_8].subband[1];
high = s->VAR_8[VAR_8].subband[3];
output = s->VAR_8[VAR_8].l_h[1];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
low = s->VAR_8[VAR_8].l_h[0];
high = s->VAR_8[VAR_8].l_h[1];
output = s->VAR_8[VAR_8].subband[0];
for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {
horiz_filter(output, low, high, VAR_26);
low += VAR_26;
high += VAR_26;
output += VAR_26 * 2;
}
if (s->bpc == 12) {
output = s->VAR_8[VAR_8].subband[0];
for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_26 * 2; VAR_6++)
output[VAR_6] *= 4;
output += VAR_26 * 2;
}
}
VAR_26 = s->VAR_8[VAR_8].band[1][1].height;
VAR_26 = s->VAR_8[VAR_8].band[1][1].width;
VAR_26 = s->VAR_8[VAR_8].band[1][1].stride;
if (VAR_26 > s->VAR_8[VAR_8].band[1][1].a_height || VAR_26 > s->VAR_8[VAR_8].band[1][1].a_width ||
!VAR_26 || s->VAR_8[VAR_8].band[1][1].width > s->VAR_8[VAR_8].band[1][1].a_width) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_8 dimensions\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
av_log(VAR_0, AV_LOG_DEBUG, "Level 2 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\n", VAR_8, VAR_26, VAR_26, VAR_26);
low = s->VAR_8[VAR_8].subband[0];
high = s->VAR_8[VAR_8].subband[5];
output = s->VAR_8[VAR_8].l_h[3];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
low = s->VAR_8[VAR_8].subband[4];
high = s->VAR_8[VAR_8].subband[6];
output = s->VAR_8[VAR_8].l_h[4];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
low = s->VAR_8[VAR_8].l_h[3];
high = s->VAR_8[VAR_8].l_h[4];
output = s->VAR_8[VAR_8].subband[0];
for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {
horiz_filter(output, low, high, VAR_26);
low += VAR_26;
high += VAR_26;
output += VAR_26 * 2;
}
output = s->VAR_8[VAR_8].subband[0];
for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_26 * 2; VAR_6++)
output[VAR_6] *= 4;
output += VAR_26 * 2;
}
VAR_26 = s->VAR_8[VAR_8].band[2][1].height;
VAR_26 = s->VAR_8[VAR_8].band[2][1].width;
VAR_26 = s->VAR_8[VAR_8].band[2][1].stride;
if (VAR_26 > s->VAR_8[VAR_8].band[2][1].a_height || VAR_26 > s->VAR_8[VAR_8].band[2][1].a_width ||
!VAR_26 || s->VAR_8[VAR_8].band[2][1].width > s->VAR_8[VAR_8].band[2][1].a_width) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_8 dimensions\n");
VAR_4 = AVERROR(EINVAL);
goto end;
}
av_log(VAR_0, AV_LOG_DEBUG, "Level 3 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\n", VAR_8, VAR_26, VAR_26, VAR_26);
low = s->VAR_8[VAR_8].subband[0];
high = s->VAR_8[VAR_8].subband[8];
output = s->VAR_8[VAR_8].l_h[6];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
low = s->VAR_8[VAR_8].subband[7];
high = s->VAR_8[VAR_8].subband[9];
output = s->VAR_8[VAR_8].l_h[7];
for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {
vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);
low++;
high++;
output++;
}
dst = (int16_t *)pic->VAR_1[VAR_26];
low = s->VAR_8[VAR_8].l_h[6];
high = s->VAR_8[VAR_8].l_h[7];
for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {
horiz_filter_clip(dst, low, high, VAR_26, s->bpc);
low += VAR_26;
high += VAR_26;
dst += pic->linesize[VAR_26] / 2;
}
}
end:
if (VAR_4 < 0)
return VAR_4;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"CFHDContext *s = VAR_0->priv_data;",
"GetByteContext gb;",
"ThreadFrame frame = { .f = VAR_1 };",
"AVFrame *pic = VAR_1;",
"int VAR_4 = 0, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 0;",
"int16_t *coeff_data;",
"s->coded_format = AV_PIX_FMT_YUV422P10;",
"init_frame_defaults(s);",
"VAR_7 = av_pix_fmt_count_planes(s->coded_format);",
"bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);",
"while (bytestream2_get_bytes_left(&gb) > 4) {",
"uint16_t tagu = bytestream2_get_be16(&gb);",
"int16_t tag = (int16_t)tagu;",
"int8_t tag8 = (int8_t)(tagu >> 8);",
"uint16_t abstag = abs(tag);",
"int8_t abs_tag8 = abs(tag8);",
"uint16_t VAR_1 = bytestream2_get_be16(&gb);",
"if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"large len %x\\n\", ((tagu & 0xff) << 16) | VAR_1);",
"} else if (tag == 20) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Width %\"PRIu16\"\\n\", VAR_1);",
"s->coded_width = VAR_1;",
"} else if (tag == 21) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Height %\"PRIu16\"\\n\", VAR_1);",
"s->coded_height = VAR_1;",
"} else if (tag == 101) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Bits per component: %\"PRIu16\"\\n\", VAR_1);",
"if (VAR_1 < 1 || VAR_1 > 31) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Bits per component %d is invalid\\n\", VAR_1);",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->bpc = VAR_1;",
"} else if (tag == 12) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Channel Count: %\"PRIu16\"\\n\", VAR_1);",
"s->channel_cnt = VAR_1;",
"if (VAR_1 > 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Channel Count of %\"PRIu16\" is unsupported\\n\", VAR_1);",
"VAR_4 = AVERROR_PATCHWELCOME;",
"break;",
"}",
"} else if (tag == 14) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Subband Count: %\"PRIu16\"\\n\", VAR_1);",
"if (VAR_1 != SUBBAND_COUNT) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Subband Count of %\"PRIu16\" is unsupported\\n\", VAR_1);",
"VAR_4 = AVERROR_PATCHWELCOME;",
"break;",
"}",
"} else if (tag == 62) {",
"s->channel_num = VAR_1;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Channel number %\"PRIu16\"\\n\", VAR_1);",
"if (s->channel_num >= VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid channel number\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"init_plane_defaults(s);",
"} else if (tag == 48) {",
"if (s->subband_num != 0 && VAR_1 == 1)\ns->VAR_21++;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Subband number %\"PRIu16\"\\n\", VAR_1);",
"s->subband_num = VAR_1;",
"if (s->VAR_21 >= DWT_LEVELS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_21\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"if (s->subband_num > 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid subband number\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"} else if (tag == 51) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Subband number actual %\"PRIu16\"\\n\", VAR_1);",
"s->subband_num_actual = VAR_1;",
"if (s->subband_num_actual >= 10) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid subband number actual\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"} else if (tag == 35)",
"av_log(VAR_0, AV_LOG_DEBUG, \"Lowpass precision bits: %\"PRIu16\"\\n\", VAR_1);",
"else if (tag == 53) {",
"s->quantisation = VAR_1;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Quantisation: %\"PRIu16\"\\n\", VAR_1);",
"} else if (tag == 109) {",
"s->prescale_shift[0] = (VAR_1 >> 0) & 0x7;",
"s->prescale_shift[1] = (VAR_1 >> 3) & 0x7;",
"s->prescale_shift[2] = (VAR_1 >> 6) & 0x7;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Prescale shift (VC-5): %x\\n\", VAR_1);",
"} else if (tag == 27) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Lowpass width %\"PRIu16\"\\n\", VAR_1);",
"if (VAR_1 < 3 || VAR_1 > s->VAR_8[s->channel_num].band[0][0].a_width) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid lowpass width\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[0][0].width = VAR_1;",
"s->VAR_8[s->channel_num].band[0][0].stride = VAR_1;",
"} else if (tag == 28) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Lowpass height %\"PRIu16\"\\n\", VAR_1);",
"if (VAR_1 < 3 || VAR_1 > s->VAR_8[s->channel_num].band[0][0].height) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid lowpass height\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[0][0].height = VAR_1;",
"} else if (tag == 1)",
"av_log(VAR_0, AV_LOG_DEBUG, \"Sample type? %\"PRIu16\"\\n\", VAR_1);",
"else if (tag == 10) {",
"if (VAR_1 != 0) {",
"avpriv_report_missing_feature(VAR_0, \"Transform type of %\"PRIu16, VAR_1);",
"VAR_4 = AVERROR_PATCHWELCOME;",
"break;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Transform-type? %\"PRIu16\"\\n\", VAR_1);",
"} else if (abstag >= 0x4000 && abstag <= 0x40ff) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Small chunk length %d %s\\n\", VAR_1 * 4, tag < 0 ? \"optional\" : \"required\");",
"bytestream2_skipu(&gb, VAR_1 * 4);",
"} else if (tag == 23) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Skip frame\\n\");",
"avpriv_report_missing_feature(VAR_0, \"Skip frame\");",
"VAR_4 = AVERROR_PATCHWELCOME;",
"break;",
"} else if (tag == 2) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"tag=2 header - skipping %VAR_5 tag/value pairs\\n\", VAR_1);",
"if (VAR_1 > bytestream2_get_bytes_left(&gb) / 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"too many tag/value pairs (%d)\\n\", VAR_1);",
"VAR_4 = AVERROR_INVALIDDATA;",
"break;",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {",
"uint16_t tag2 = bytestream2_get_be16(&gb);",
"uint16_t val2 = bytestream2_get_be16(&gb);",
"av_log(VAR_0, AV_LOG_DEBUG, \"Tag/Value = %x %x\\n\", tag2, val2);",
"}",
"} else if (tag == 41) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Highpass width %VAR_5 channel %VAR_5 VAR_21 %VAR_5 subband %VAR_5\\n\", VAR_1, s->channel_num, s->VAR_21, s->subband_num);",
"if (VAR_1 < 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid highpass width\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width = VAR_1;",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride = FFALIGN(VAR_1, 8);",
"} else if (tag == 42) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Highpass height %VAR_5\\n\", VAR_1);",
"if (VAR_1 < 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid highpass height\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height = VAR_1;",
"} else if (tag == 49) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Highpass width2 %VAR_5\\n\", VAR_1);",
"if (VAR_1 < 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid highpass width2\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width = VAR_1;",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride = FFALIGN(VAR_1, 8);",
"} else if (tag == 50) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Highpass height2 %VAR_5\\n\", VAR_1);",
"if (VAR_1 < 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid highpass height2\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height = VAR_1;",
"} else if (tag == 71) {",
"s->codebook = VAR_1;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Codebook %VAR_5\\n\", s->codebook);",
"} else if (tag == 72) {",
"s->codebook = VAR_1;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Other codebook? %VAR_5\\n\", s->codebook);",
"} else if (tag == 70) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Subsampling or bit-depth flag? %VAR_5\\n\", VAR_1);",
"if (!(VAR_1 == 10 || VAR_1 == 12)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid bits per channel\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"break;",
"}",
"s->bpc = VAR_1;",
"} else if (tag == 84) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Sample format? %VAR_5\\n\", VAR_1);",
"if (VAR_1 == 1)\ns->coded_format = AV_PIX_FMT_YUV422P10;",
"else if (VAR_1 == 3)\ns->coded_format = AV_PIX_FMT_GBRP12;",
"else if (VAR_1 == 4)\ns->coded_format = AV_PIX_FMT_GBRAP12;",
"else {",
"avpriv_report_missing_feature(VAR_0, \"Sample format of %\"PRIu16, VAR_1);",
"VAR_4 = AVERROR_PATCHWELCOME;",
"break;",
"}",
"VAR_7 = av_pix_fmt_count_planes(s->coded_format);",
"} else",
"av_log(VAR_0, AV_LOG_DEBUG, \"Unknown tag %VAR_5 VAR_1 %x\\n\", tag, VAR_1);",
"if (tag == 4 && VAR_1 == 0x1a4a && s->coded_width && s->coded_height &&\ns->coded_format != AV_PIX_FMT_NONE) {",
"if (s->a_width != s->coded_width || s->a_height != s->coded_height ||\ns->a_format != s->coded_format) {",
"free_buffers(VAR_0);",
"if ((VAR_4 = alloc_buffers(VAR_0)) < 0) {",
"free_buffers(VAR_0);",
"return VAR_4;",
"}",
"}",
"VAR_4 = ff_set_dimensions(VAR_0, s->coded_width, s->coded_height);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"frame.f->width =\nframe.f->height = 0;",
"if ((VAR_4 = ff_thread_get_buffer(VAR_0, &frame, 0)) < 0)\nreturn VAR_4;",
"s->coded_width = 0;",
"s->coded_height = 0;",
"s->coded_format = AV_PIX_FMT_NONE;",
"VAR_9 = 1;",
"}",
"coeff_data = s->VAR_8[s->channel_num].subband[s->subband_num_actual];",
"if (tag == 4 && VAR_1 == 0xf0f && s->a_width && s->a_height) {",
"int VAR_26 = s->VAR_8[s->channel_num].band[0][0].height;",
"int VAR_26 = s->VAR_8[s->channel_num].band[0][0].width;",
"int VAR_12 = s->VAR_8[s->channel_num].band[0][0].a_height;",
"int VAR_13 = s->VAR_8[s->channel_num].band[0][0].a_width;",
"if (!VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No end of header tag found\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"if (VAR_26 > VAR_12 || VAR_26 > VAR_13 ||\nVAR_13 * VAR_12 * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Too many lowpass coefficients\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Start of lowpass coeffs component %d height:%d, width:%d\\n\", s->channel_num, VAR_26, VAR_26);",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_26; VAR_6++)",
"coeff_data[VAR_6] = bytestream2_get_be16u(&gb);",
"coeff_data += VAR_26;",
"}",
"bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR);",
"if (VAR_26 & 1) {",
"memcpy(&coeff_data[VAR_26 * VAR_26],\n&coeff_data[(VAR_26 - 1) * VAR_26],\nVAR_26 * sizeof(*coeff_data));",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Lowpass coefficients %d\\n\", VAR_26 * VAR_26);",
"}",
"if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) {",
"int VAR_14 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].height;",
"int VAR_15 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].width;",
"int VAR_16 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].a_width;",
"int VAR_17 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].a_height;",
"int VAR_26 = s->VAR_8[s->channel_num].band[s->VAR_21][s->subband_num].stride;",
"int VAR_19;",
"int VAR_20 = VAR_17 * VAR_16;",
"int VAR_21, VAR_22, VAR_23;",
"int VAR_24 = 0, VAR_25;",
"if (!VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No end of header tag found\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"if (VAR_14 > VAR_17 || VAR_15 > VAR_16 || VAR_20 < VAR_14 * (uint64_t)VAR_26) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Too many highpass coefficients\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"VAR_19 = VAR_14 * VAR_26;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Start subband coeffs VAR_8 %VAR_5 VAR_21 %VAR_5 codebook %VAR_5 VAR_19 %VAR_5\\n\", s->channel_num, s->VAR_21, s->codebook, VAR_19);",
"init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8);",
"{",
"OPEN_READER(re, &s->gb);",
"if (!s->codebook) {",
"while (1) {",
"UPDATE_CACHE(re, &s->gb);",
"GET_RL_VLC(VAR_21, VAR_22, re, &s->gb, s->table_9_rl_vlc,\nVLC_BITS, 3, 1);",
"if (VAR_21 == 64)\nbreak;",
"VAR_24 += VAR_22;",
"if (VAR_24 > VAR_19)\nbreak;",
"VAR_23 = dequant_and_decompand(VAR_21, s->quantisation);",
"for (VAR_5 = 0; VAR_5 < VAR_22; VAR_5++)",
"*coeff_data++ = VAR_23;",
"}",
"} else {",
"while (1) {",
"UPDATE_CACHE(re, &s->gb);",
"GET_RL_VLC(VAR_21, VAR_22, re, &s->gb, s->table_18_rl_vlc,\nVLC_BITS, 3, 1);",
"if (VAR_21 == 255 && VAR_22 == 2)\nbreak;",
"VAR_24 += VAR_22;",
"if (VAR_24 > VAR_19)\nbreak;",
"VAR_23 = dequant_and_decompand(VAR_21, s->quantisation);",
"for (VAR_5 = 0; VAR_5 < VAR_22; VAR_5++)",
"*coeff_data++ = VAR_23;",
"}",
"}",
"CLOSE_READER(re, &s->gb);",
"}",
"if (VAR_24 > VAR_19) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Escape codeword not found, probably corrupt VAR_1\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"VAR_25 = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4);",
"if (VAR_25 > bytestream2_get_bytes_left(&gb)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Bitstream overread error\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"} else",
"bytestream2_seek(&gb, VAR_25, SEEK_CUR);",
"av_log(VAR_0, AV_LOG_DEBUG, \"End subband coeffs %VAR_5 extra %VAR_5\\n\", VAR_24, VAR_24 - VAR_19);",
"s->codebook = 0;",
"if (VAR_14 & 1) {",
"memcpy(&coeff_data[VAR_14 * VAR_26],\n&coeff_data[(VAR_14 - 1) * VAR_26],\nVAR_26 * sizeof(*coeff_data));",
"}",
"}",
"}",
"if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE ||\ns->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid dimensions\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"if (!VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No end of header tag found\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"VAR_7 = av_pix_fmt_count_planes(VAR_0->pix_fmt);",
"for (VAR_8 = 0; VAR_8 < VAR_7 && !VAR_4; VAR_8++) {",
"int VAR_26 = s->VAR_8[VAR_8].band[0][0].height;",
"int VAR_26 = s->VAR_8[VAR_8].band[0][0].width;",
"int VAR_26 = s->VAR_8[VAR_8].band[0][1].stride;",
"int VAR_26 = VAR_8 == 1 ? 2 : VAR_8 == 2 ? 1 : VAR_8;",
"int16_t *low, *high, *output, *dst;",
"if (VAR_26 > s->VAR_8[VAR_8].band[0][0].a_height || VAR_26 > s->VAR_8[VAR_8].band[0][0].a_width ||\n!VAR_26 || s->VAR_8[VAR_8].band[0][1].width > s->VAR_8[VAR_8].band[0][1].a_width) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_8 dimensions\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Decoding VAR_21 1 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\\n\", VAR_8, VAR_26, VAR_26, VAR_26);",
"low = s->VAR_8[VAR_8].subband[0];",
"high = s->VAR_8[VAR_8].subband[2];",
"output = s->VAR_8[VAR_8].l_h[0];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"low = s->VAR_8[VAR_8].subband[1];",
"high = s->VAR_8[VAR_8].subband[3];",
"output = s->VAR_8[VAR_8].l_h[1];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"low = s->VAR_8[VAR_8].l_h[0];",
"high = s->VAR_8[VAR_8].l_h[1];",
"output = s->VAR_8[VAR_8].subband[0];",
"for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {",
"horiz_filter(output, low, high, VAR_26);",
"low += VAR_26;",
"high += VAR_26;",
"output += VAR_26 * 2;",
"}",
"if (s->bpc == 12) {",
"output = s->VAR_8[VAR_8].subband[0];",
"for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_26 * 2; VAR_6++)",
"output[VAR_6] *= 4;",
"output += VAR_26 * 2;",
"}",
"}",
"VAR_26 = s->VAR_8[VAR_8].band[1][1].height;",
"VAR_26 = s->VAR_8[VAR_8].band[1][1].width;",
"VAR_26 = s->VAR_8[VAR_8].band[1][1].stride;",
"if (VAR_26 > s->VAR_8[VAR_8].band[1][1].a_height || VAR_26 > s->VAR_8[VAR_8].band[1][1].a_width ||\n!VAR_26 || s->VAR_8[VAR_8].band[1][1].width > s->VAR_8[VAR_8].band[1][1].a_width) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_8 dimensions\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Level 2 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\\n\", VAR_8, VAR_26, VAR_26, VAR_26);",
"low = s->VAR_8[VAR_8].subband[0];",
"high = s->VAR_8[VAR_8].subband[5];",
"output = s->VAR_8[VAR_8].l_h[3];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"low = s->VAR_8[VAR_8].subband[4];",
"high = s->VAR_8[VAR_8].subband[6];",
"output = s->VAR_8[VAR_8].l_h[4];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"low = s->VAR_8[VAR_8].l_h[3];",
"high = s->VAR_8[VAR_8].l_h[4];",
"output = s->VAR_8[VAR_8].subband[0];",
"for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {",
"horiz_filter(output, low, high, VAR_26);",
"low += VAR_26;",
"high += VAR_26;",
"output += VAR_26 * 2;",
"}",
"output = s->VAR_8[VAR_8].subband[0];",
"for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_26 * 2; VAR_6++)",
"output[VAR_6] *= 4;",
"output += VAR_26 * 2;",
"}",
"VAR_26 = s->VAR_8[VAR_8].band[2][1].height;",
"VAR_26 = s->VAR_8[VAR_8].band[2][1].width;",
"VAR_26 = s->VAR_8[VAR_8].band[2][1].stride;",
"if (VAR_26 > s->VAR_8[VAR_8].band[2][1].a_height || VAR_26 > s->VAR_8[VAR_8].band[2][1].a_width ||\n!VAR_26 || s->VAR_8[VAR_8].band[2][1].width > s->VAR_8[VAR_8].band[2][1].a_width) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_8 dimensions\\n\");",
"VAR_4 = AVERROR(EINVAL);",
"goto end;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Level 3 VAR_8 %VAR_5 %VAR_5 %VAR_5 %VAR_5\\n\", VAR_8, VAR_26, VAR_26, VAR_26);",
"low = s->VAR_8[VAR_8].subband[0];",
"high = s->VAR_8[VAR_8].subband[8];",
"output = s->VAR_8[VAR_8].l_h[6];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"low = s->VAR_8[VAR_8].subband[7];",
"high = s->VAR_8[VAR_8].subband[9];",
"output = s->VAR_8[VAR_8].l_h[7];",
"for (VAR_5 = 0; VAR_5 < VAR_26; VAR_5++) {",
"vert_filter(output, VAR_26, low, VAR_26, high, VAR_26, VAR_26);",
"low++;",
"high++;",
"output++;",
"}",
"dst = (int16_t *)pic->VAR_1[VAR_26];",
"low = s->VAR_8[VAR_8].l_h[6];",
"high = s->VAR_8[VAR_8].l_h[7];",
"for (VAR_5 = 0; VAR_5 < VAR_26 * 2; VAR_5++) {",
"horiz_filter_clip(dst, low, high, VAR_26, s->bpc);",
"low += VAR_26;",
"high += VAR_26;",
"dst += pic->linesize[VAR_26] / 2;",
"}",
"}",
"end:\nif (VAR_4 < 0)\nreturn VAR_4;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
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
],
[
387,
389
],
[
391,
393
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
419,
421
],
[
423,
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441,
443
],
[
445,
447
],
[
451,
453
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497,
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
511
],
[
513
],
[
515
],
[
517
],
[
521
],
[
523
],
[
529
],
[
535
],
[
537,
539,
541
],
[
543
],
[
547
],
[
549
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
601
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617,
619
],
[
625,
627
],
[
631
],
[
635,
637
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655,
657
],
[
663,
665
],
[
669
],
[
673,
675
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725
],
[
731
],
[
733,
735,
737
],
[
739
],
[
741
],
[
743
],
[
747,
749
],
[
751
],
[
753
],
[
755
],
[
757
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
773
],
[
775
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
791,
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
805
],
[
809
],
[
811
],
[
813
],
[
815
],
[
817
],
[
819
],
[
821
],
[
823
],
[
825
],
[
829
],
[
831
],
[
833
],
[
837
],
[
841
],
[
843
],
[
845
],
[
847
],
[
849
],
[
853
],
[
855
],
[
857
],
[
859
],
[
861
],
[
863
],
[
865
],
[
867
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879
],
[
883
],
[
885
],
[
887
],
[
893
],
[
895
],
[
897
],
[
901,
903
],
[
905
],
[
907
],
[
909
],
[
911
],
[
915
],
[
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929
],
[
931
],
[
933
],
[
935
],
[
939
],
[
941
],
[
943
],
[
945
],
[
947
],
[
949
],
[
951
],
[
953
],
[
955
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975
],
[
979
],
[
981
],
[
983
],
[
985
],
[
989
],
[
991
],
[
997
],
[
999
],
[
1001
],
[
1005,
1007
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1019
],
[
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033
],
[
1035
],
[
1037
],
[
1039
],
[
1043
],
[
1045
],
[
1047
],
[
1049
],
[
1051
],
[
1053
],
[
1055
],
[
1057
],
[
1059
],
[
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1075
],
[
1077
],
[
1079
],
[
1081
],
[
1087,
1089,
1091
],
[
1095
],
[
1097
],
[
1099
]
]
|
15,253 | static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
{
vector signed short src0, src1, src2, src3, src4, src5, src6, src7;
vector signed int s0, s1, s2, s3, s4, s5, s6, s7;
vector signed int s8, s9, sA, sB, sC, sD, sE, sF;
vector signed int t0, t1, t2, t3, t4, t5, t6, t7;
const vector signed int vec_64 = vec_sl(vec_splat_s32(4), vec_splat_u32(4));
const vector unsigned int vec_7 = vec_splat_u32(7);
const vector unsigned int vec_4 = vec_splat_u32(4);
const vector signed int vec_4s = vec_splat_s32(4);
const vector unsigned int vec_3 = vec_splat_u32(3);
const vector unsigned int vec_2 = vec_splat_u32(2);
const vector signed int vec_1s = vec_splat_s32(1);
const vector unsigned int vec_1 = vec_splat_u32(1);
src0 = vec_ld( 0, block);
src1 = vec_ld( 16, block);
src2 = vec_ld( 32, block);
src3 = vec_ld( 48, block);
src4 = vec_ld( 64, block);
src5 = vec_ld( 80, block);
src6 = vec_ld( 96, block);
src7 = vec_ld(112, block);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, vec_4s);
SHIFT_HOR8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, vec_4s);
SHIFT_HOR8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
TRANSPOSE8(src0, src1, src2, src3, src4, src5, src6, src7);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, vec_64);
SHIFT_VERT8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, vec_64);
SHIFT_VERT8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
vec_st(src0, 0, block);
vec_st(src1, 16, block);
vec_st(src2, 32, block);
vec_st(src3, 48, block);
vec_st(src4, 64, block);
vec_st(src5, 80, block);
vec_st(src6, 96, block);
vec_st(src7,112, block);
}
| false | FFmpeg | 6a786b15c34765ec00be3cd808dafbb041fd5881 | static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
{
vector signed short src0, src1, src2, src3, src4, src5, src6, src7;
vector signed int s0, s1, s2, s3, s4, s5, s6, s7;
vector signed int s8, s9, sA, sB, sC, sD, sE, sF;
vector signed int t0, t1, t2, t3, t4, t5, t6, t7;
const vector signed int vec_64 = vec_sl(vec_splat_s32(4), vec_splat_u32(4));
const vector unsigned int vec_7 = vec_splat_u32(7);
const vector unsigned int vec_4 = vec_splat_u32(4);
const vector signed int vec_4s = vec_splat_s32(4);
const vector unsigned int vec_3 = vec_splat_u32(3);
const vector unsigned int vec_2 = vec_splat_u32(2);
const vector signed int vec_1s = vec_splat_s32(1);
const vector unsigned int vec_1 = vec_splat_u32(1);
src0 = vec_ld( 0, block);
src1 = vec_ld( 16, block);
src2 = vec_ld( 32, block);
src3 = vec_ld( 48, block);
src4 = vec_ld( 64, block);
src5 = vec_ld( 80, block);
src6 = vec_ld( 96, block);
src7 = vec_ld(112, block);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, vec_4s);
SHIFT_HOR8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, vec_4s);
SHIFT_HOR8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
TRANSPOSE8(src0, src1, src2, src3, src4, src5, src6, src7);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, vec_64);
SHIFT_VERT8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, vec_64);
SHIFT_VERT8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
vec_st(src0, 0, block);
vec_st(src1, 16, block);
vec_st(src2, 32, block);
vec_st(src3, 48, block);
vec_st(src4, 64, block);
vec_st(src5, 80, block);
vec_st(src6, 96, block);
vec_st(src7,112, block);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DCTELEM VAR_0[64])
{
vector signed short src0, src1, src2, src3, src4, src5, src6, src7;
vector signed int s0, s1, s2, s3, s4, s5, s6, s7;
vector signed int s8, s9, sA, sB, sC, sD, sE, sF;
vector signed int t0, t1, t2, t3, t4, t5, t6, t7;
const vector signed int VAR_1 = vec_sl(vec_splat_s32(4), vec_splat_u32(4));
const vector unsigned int VAR_2 = vec_splat_u32(7);
const vector unsigned int VAR_3 = vec_splat_u32(4);
const vector signed int VAR_4 = vec_splat_s32(4);
const vector unsigned int VAR_5 = vec_splat_u32(3);
const vector unsigned int VAR_6 = vec_splat_u32(2);
const vector signed int VAR_7 = vec_splat_s32(1);
const vector unsigned int VAR_8 = vec_splat_u32(1);
src0 = vec_ld( 0, VAR_0);
src1 = vec_ld( 16, VAR_0);
src2 = vec_ld( 32, VAR_0);
src3 = vec_ld( 48, VAR_0);
src4 = vec_ld( 64, VAR_0);
src5 = vec_ld( 80, VAR_0);
src6 = vec_ld( 96, VAR_0);
src7 = vec_ld(112, VAR_0);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, VAR_4);
SHIFT_HOR8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, VAR_4);
SHIFT_HOR8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
TRANSPOSE8(src0, src1, src2, src3, src4, src5, src6, src7);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
s3 = vec_unpackl(src3);
s4 = vec_unpackl(src4);
s5 = vec_unpackl(src5);
s6 = vec_unpackl(src6);
s7 = vec_unpackl(src7);
s8 = vec_unpackh(src0);
s9 = vec_unpackh(src1);
sA = vec_unpackh(src2);
sB = vec_unpackh(src3);
sC = vec_unpackh(src4);
sD = vec_unpackh(src5);
sE = vec_unpackh(src6);
sF = vec_unpackh(src7);
STEP8(s0, s1, s2, s3, s4, s5, s6, s7, VAR_1);
SHIFT_VERT8(s0, s1, s2, s3, s4, s5, s6, s7);
STEP8(s8, s9, sA, sB, sC, sD, sE, sF, VAR_1);
SHIFT_VERT8(s8, s9, sA, sB, sC, sD, sE, sF);
src0 = vec_pack(s8, s0);
src1 = vec_pack(s9, s1);
src2 = vec_pack(sA, s2);
src3 = vec_pack(sB, s3);
src4 = vec_pack(sC, s4);
src5 = vec_pack(sD, s5);
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
vec_st(src0, 0, VAR_0);
vec_st(src1, 16, VAR_0);
vec_st(src2, 32, VAR_0);
vec_st(src3, 48, VAR_0);
vec_st(src4, 64, VAR_0);
vec_st(src5, 80, VAR_0);
vec_st(src6, 96, VAR_0);
vec_st(src7,112, VAR_0);
}
| [
"static void FUNC_0(DCTELEM VAR_0[64])\n{",
"vector signed short src0, src1, src2, src3, src4, src5, src6, src7;",
"vector signed int s0, s1, s2, s3, s4, s5, s6, s7;",
"vector signed int s8, s9, sA, sB, sC, sD, sE, sF;",
"vector signed int t0, t1, t2, t3, t4, t5, t6, t7;",
"const vector signed int VAR_1 = vec_sl(vec_splat_s32(4), vec_splat_u32(4));",
"const vector unsigned int VAR_2 = vec_splat_u32(7);",
"const vector unsigned int VAR_3 = vec_splat_u32(4);",
"const vector signed int VAR_4 = vec_splat_s32(4);",
"const vector unsigned int VAR_5 = vec_splat_u32(3);",
"const vector unsigned int VAR_6 = vec_splat_u32(2);",
"const vector signed int VAR_7 = vec_splat_s32(1);",
"const vector unsigned int VAR_8 = vec_splat_u32(1);",
"src0 = vec_ld( 0, VAR_0);",
"src1 = vec_ld( 16, VAR_0);",
"src2 = vec_ld( 32, VAR_0);",
"src3 = vec_ld( 48, VAR_0);",
"src4 = vec_ld( 64, VAR_0);",
"src5 = vec_ld( 80, VAR_0);",
"src6 = vec_ld( 96, VAR_0);",
"src7 = vec_ld(112, VAR_0);",
"s0 = vec_unpackl(src0);",
"s1 = vec_unpackl(src1);",
"s2 = vec_unpackl(src2);",
"s3 = vec_unpackl(src3);",
"s4 = vec_unpackl(src4);",
"s5 = vec_unpackl(src5);",
"s6 = vec_unpackl(src6);",
"s7 = vec_unpackl(src7);",
"s8 = vec_unpackh(src0);",
"s9 = vec_unpackh(src1);",
"sA = vec_unpackh(src2);",
"sB = vec_unpackh(src3);",
"sC = vec_unpackh(src4);",
"sD = vec_unpackh(src5);",
"sE = vec_unpackh(src6);",
"sF = vec_unpackh(src7);",
"STEP8(s0, s1, s2, s3, s4, s5, s6, s7, VAR_4);",
"SHIFT_HOR8(s0, s1, s2, s3, s4, s5, s6, s7);",
"STEP8(s8, s9, sA, sB, sC, sD, sE, sF, VAR_4);",
"SHIFT_HOR8(s8, s9, sA, sB, sC, sD, sE, sF);",
"src0 = vec_pack(s8, s0);",
"src1 = vec_pack(s9, s1);",
"src2 = vec_pack(sA, s2);",
"src3 = vec_pack(sB, s3);",
"src4 = vec_pack(sC, s4);",
"src5 = vec_pack(sD, s5);",
"src6 = vec_pack(sE, s6);",
"src7 = vec_pack(sF, s7);",
"TRANSPOSE8(src0, src1, src2, src3, src4, src5, src6, src7);",
"s0 = vec_unpackl(src0);",
"s1 = vec_unpackl(src1);",
"s2 = vec_unpackl(src2);",
"s3 = vec_unpackl(src3);",
"s4 = vec_unpackl(src4);",
"s5 = vec_unpackl(src5);",
"s6 = vec_unpackl(src6);",
"s7 = vec_unpackl(src7);",
"s8 = vec_unpackh(src0);",
"s9 = vec_unpackh(src1);",
"sA = vec_unpackh(src2);",
"sB = vec_unpackh(src3);",
"sC = vec_unpackh(src4);",
"sD = vec_unpackh(src5);",
"sE = vec_unpackh(src6);",
"sF = vec_unpackh(src7);",
"STEP8(s0, s1, s2, s3, s4, s5, s6, s7, VAR_1);",
"SHIFT_VERT8(s0, s1, s2, s3, s4, s5, s6, s7);",
"STEP8(s8, s9, sA, sB, sC, sD, sE, sF, VAR_1);",
"SHIFT_VERT8(s8, s9, sA, sB, sC, sD, sE, sF);",
"src0 = vec_pack(s8, s0);",
"src1 = vec_pack(s9, s1);",
"src2 = vec_pack(sA, s2);",
"src3 = vec_pack(sB, s3);",
"src4 = vec_pack(sC, s4);",
"src5 = vec_pack(sD, s5);",
"src6 = vec_pack(sE, s6);",
"src7 = vec_pack(sF, s7);",
"vec_st(src0, 0, VAR_0);",
"vec_st(src1, 16, VAR_0);",
"vec_st(src2, 32, VAR_0);",
"vec_st(src3, 48, VAR_0);",
"vec_st(src4, 64, VAR_0);",
"vec_st(src5, 80, VAR_0);",
"vec_st(src6, 96, VAR_0);",
"vec_st(src7,112, VAR_0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
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
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
]
]
|
15,254 | static int decode_tilehdr(WmallDecodeCtx *s)
{
uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 }; /* sum of samples for all currently known subframes of a channel */
uint8_t contains_subframe[WMALL_MAX_CHANNELS]; /* flag indicating if a channel contains the current subframe */
int channels_for_cur_subframe = s->num_channels; /* number of channels that contain the current subframe */
int fixed_channel_layout = 0; /* flag indicating that all channels use the same subfra2me offsets and sizes */
int min_channel_len = 0; /* smallest sum of samples (channels with this length will be processed first) */
int c, tile_aligned;
/* reset tiling information */
for (c = 0; c < s->num_channels; c++)
s->channel[c].num_subframes = 0;
tile_aligned = get_bits1(&s->gb);
if (s->max_num_subframes == 1 || tile_aligned)
fixed_channel_layout = 1;
/* loop until the frame data is split between the subframes */
do {
int subframe_len, in_use = 0;
/* check which channels contain the subframe */
for (c = 0; c < s->num_channels; c++) {
if (num_samples[c] == min_channel_len) {
if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
(min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
contains_subframe[c] = in_use = 1;
} else {
if (get_bits1(&s->gb))
contains_subframe[c] = in_use = 1;
}
} else
contains_subframe[c] = 0;
}
if (!in_use) {
av_log(s->avctx, AV_LOG_ERROR,
"Found empty subframe\n");
return AVERROR_INVALIDDATA;
}
/* get subframe length, subframe_len == 0 is not allowed */
if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0)
return AVERROR_INVALIDDATA;
/* add subframes to the individual channels and find new min_channel_len */
min_channel_len += subframe_len;
for (c = 0; c < s->num_channels; c++) {
WmallChannelCtx *chan = &s->channel[c];
if (contains_subframe[c]) {
if (chan->num_subframes >= MAX_SUBFRAMES) {
av_log(s->avctx, AV_LOG_ERROR,
"broken frame: num subframes > 31\n");
return AVERROR_INVALIDDATA;
}
chan->subframe_len[chan->num_subframes] = subframe_len;
num_samples[c] += subframe_len;
++chan->num_subframes;
if (num_samples[c] > s->samples_per_frame) {
av_log(s->avctx, AV_LOG_ERROR, "broken frame: "
"channel len(%d) > samples_per_frame(%d)\n",
num_samples[c], s->samples_per_frame);
return AVERROR_INVALIDDATA;
}
} else if (num_samples[c] <= min_channel_len) {
if (num_samples[c] < min_channel_len) {
channels_for_cur_subframe = 0;
min_channel_len = num_samples[c];
}
++channels_for_cur_subframe;
}
}
} while (min_channel_len < s->samples_per_frame);
for (c = 0; c < s->num_channels; c++) {
int i, offset = 0;
for (i = 0; i < s->channel[c].num_subframes; i++) {
s->channel[c].subframe_offsets[i] = offset;
offset += s->channel[c].subframe_len[i];
}
}
return 0;
}
| true | FFmpeg | e2742d6ad69595fd2af36adf0883e37701307f52 | static int decode_tilehdr(WmallDecodeCtx *s)
{
uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 };
uint8_t contains_subframe[WMALL_MAX_CHANNELS];
int channels_for_cur_subframe = s->num_channels;
int fixed_channel_layout = 0;
int min_channel_len = 0;
int c, tile_aligned;
for (c = 0; c < s->num_channels; c++)
s->channel[c].num_subframes = 0;
tile_aligned = get_bits1(&s->gb);
if (s->max_num_subframes == 1 || tile_aligned)
fixed_channel_layout = 1;
do {
int subframe_len, in_use = 0;
for (c = 0; c < s->num_channels; c++) {
if (num_samples[c] == min_channel_len) {
if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
(min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
contains_subframe[c] = in_use = 1;
} else {
if (get_bits1(&s->gb))
contains_subframe[c] = in_use = 1;
}
} else
contains_subframe[c] = 0;
}
if (!in_use) {
av_log(s->avctx, AV_LOG_ERROR,
"Found empty subframe\n");
return AVERROR_INVALIDDATA;
}
if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0)
return AVERROR_INVALIDDATA;
min_channel_len += subframe_len;
for (c = 0; c < s->num_channels; c++) {
WmallChannelCtx *chan = &s->channel[c];
if (contains_subframe[c]) {
if (chan->num_subframes >= MAX_SUBFRAMES) {
av_log(s->avctx, AV_LOG_ERROR,
"broken frame: num subframes > 31\n");
return AVERROR_INVALIDDATA;
}
chan->subframe_len[chan->num_subframes] = subframe_len;
num_samples[c] += subframe_len;
++chan->num_subframes;
if (num_samples[c] > s->samples_per_frame) {
av_log(s->avctx, AV_LOG_ERROR, "broken frame: "
"channel len(%d) > samples_per_frame(%d)\n",
num_samples[c], s->samples_per_frame);
return AVERROR_INVALIDDATA;
}
} else if (num_samples[c] <= min_channel_len) {
if (num_samples[c] < min_channel_len) {
channels_for_cur_subframe = 0;
min_channel_len = num_samples[c];
}
++channels_for_cur_subframe;
}
}
} while (min_channel_len < s->samples_per_frame);
for (c = 0; c < s->num_channels; c++) {
int i, offset = 0;
for (i = 0; i < s->channel[c].num_subframes; i++) {
s->channel[c].subframe_offsets[i] = offset;
offset += s->channel[c].subframe_len[i];
}
}
return 0;
}
| {
"code": [
" contains_subframe[c] = in_use = 1;",
" if (get_bits1(&s->gb))",
" contains_subframe[c] = in_use = 1;"
],
"line_no": [
53,
57,
59
]
} | static int FUNC_0(WmallDecodeCtx *VAR_0)
{
uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 };
uint8_t contains_subframe[WMALL_MAX_CHANNELS];
int VAR_1 = VAR_0->num_channels;
int VAR_2 = 0;
int VAR_3 = 0;
int VAR_4, VAR_5;
for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++)
VAR_0->channel[VAR_4].num_subframes = 0;
VAR_5 = get_bits1(&VAR_0->gb);
if (VAR_0->max_num_subframes == 1 || VAR_5)
VAR_2 = 1;
do {
int VAR_6, VAR_7 = 0;
for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {
if (num_samples[VAR_4] == VAR_3) {
if (VAR_2 || VAR_1 == 1 ||
(VAR_3 == VAR_0->samples_per_frame - VAR_0->min_samples_per_subframe)) {
contains_subframe[VAR_4] = VAR_7 = 1;
} else {
if (get_bits1(&VAR_0->gb))
contains_subframe[VAR_4] = VAR_7 = 1;
}
} else
contains_subframe[VAR_4] = 0;
}
if (!VAR_7) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Found empty subframe\n");
return AVERROR_INVALIDDATA;
}
if ((VAR_6 = decode_subframe_length(VAR_0, VAR_3)) <= 0)
return AVERROR_INVALIDDATA;
VAR_3 += VAR_6;
for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {
WmallChannelCtx *chan = &VAR_0->channel[VAR_4];
if (contains_subframe[VAR_4]) {
if (chan->num_subframes >= MAX_SUBFRAMES) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"broken frame: num subframes > 31\n");
return AVERROR_INVALIDDATA;
}
chan->VAR_6[chan->num_subframes] = VAR_6;
num_samples[VAR_4] += VAR_6;
++chan->num_subframes;
if (num_samples[VAR_4] > VAR_0->samples_per_frame) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "broken frame: "
"channel len(%d) > samples_per_frame(%d)\n",
num_samples[VAR_4], VAR_0->samples_per_frame);
return AVERROR_INVALIDDATA;
}
} else if (num_samples[VAR_4] <= VAR_3) {
if (num_samples[VAR_4] < VAR_3) {
VAR_1 = 0;
VAR_3 = num_samples[VAR_4];
}
++VAR_1;
}
}
} while (VAR_3 < VAR_0->samples_per_frame);
for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {
int i, offset = 0;
for (i = 0; i < VAR_0->channel[VAR_4].num_subframes; i++) {
VAR_0->channel[VAR_4].subframe_offsets[i] = offset;
offset += VAR_0->channel[VAR_4].VAR_6[i];
}
}
return 0;
}
| [
"static int FUNC_0(WmallDecodeCtx *VAR_0)\n{",
"uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 };",
"uint8_t contains_subframe[WMALL_MAX_CHANNELS];",
"int VAR_1 = VAR_0->num_channels;",
"int VAR_2 = 0;",
"int VAR_3 = 0;",
"int VAR_4, VAR_5;",
"for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++)",
"VAR_0->channel[VAR_4].num_subframes = 0;",
"VAR_5 = get_bits1(&VAR_0->gb);",
"if (VAR_0->max_num_subframes == 1 || VAR_5)\nVAR_2 = 1;",
"do {",
"int VAR_6, VAR_7 = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {",
"if (num_samples[VAR_4] == VAR_3) {",
"if (VAR_2 || VAR_1 == 1 ||\n(VAR_3 == VAR_0->samples_per_frame - VAR_0->min_samples_per_subframe)) {",
"contains_subframe[VAR_4] = VAR_7 = 1;",
"} else {",
"if (get_bits1(&VAR_0->gb))\ncontains_subframe[VAR_4] = VAR_7 = 1;",
"}",
"} else",
"contains_subframe[VAR_4] = 0;",
"}",
"if (!VAR_7) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Found empty subframe\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if ((VAR_6 = decode_subframe_length(VAR_0, VAR_3)) <= 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_3 += VAR_6;",
"for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {",
"WmallChannelCtx *chan = &VAR_0->channel[VAR_4];",
"if (contains_subframe[VAR_4]) {",
"if (chan->num_subframes >= MAX_SUBFRAMES) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"broken frame: num subframes > 31\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"chan->VAR_6[chan->num_subframes] = VAR_6;",
"num_samples[VAR_4] += VAR_6;",
"++chan->num_subframes;",
"if (num_samples[VAR_4] > VAR_0->samples_per_frame) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"broken frame: \"\n\"channel len(%d) > samples_per_frame(%d)\\n\",\nnum_samples[VAR_4], VAR_0->samples_per_frame);",
"return AVERROR_INVALIDDATA;",
"}",
"} else if (num_samples[VAR_4] <= VAR_3) {",
"if (num_samples[VAR_4] < VAR_3) {",
"VAR_1 = 0;",
"VAR_3 = num_samples[VAR_4];",
"}",
"++VAR_1;",
"}",
"}",
"} while (VAR_3 < VAR_0->samples_per_frame);",
"for (VAR_4 = 0; VAR_4 < VAR_0->num_channels; VAR_4++) {",
"int i, offset = 0;",
"for (i = 0; i < VAR_0->channel[VAR_4].num_subframes; i++) {",
"VAR_0->channel[VAR_4].subframe_offsets[i] = offset;",
"offset += VAR_0->channel[VAR_4].VAR_6[i];",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
85,
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
]
]
|
15,255 | uart_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
XilinxUARTLite *s = opaque;
uint32_t value = val64;
unsigned char ch = value;
addr >>= 2;
switch (addr)
{
case R_STATUS:
hw_error("write to UART STATUS?\n");
break;
case R_CTRL:
if (value & CONTROL_RST_RX) {
s->rx_fifo_pos = 0;
s->rx_fifo_len = 0;
}
s->regs[addr] = value;
break;
case R_TX:
if (s->chr)
qemu_chr_fe_write(s->chr, &ch, 1);
s->regs[addr] = value;
/* hax. */
s->regs[R_STATUS] |= STATUS_IE;
break;
default:
DUART(printf("%s addr=%x v=%x\n", __func__, addr, value));
if (addr < ARRAY_SIZE(s->regs))
s->regs[addr] = value;
break;
}
uart_update_status(s);
uart_update_irq(s);
}
| true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | uart_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
XilinxUARTLite *s = opaque;
uint32_t value = val64;
unsigned char ch = value;
addr >>= 2;
switch (addr)
{
case R_STATUS:
hw_error("write to UART STATUS?\n");
break;
case R_CTRL:
if (value & CONTROL_RST_RX) {
s->rx_fifo_pos = 0;
s->rx_fifo_len = 0;
}
s->regs[addr] = value;
break;
case R_TX:
if (s->chr)
qemu_chr_fe_write(s->chr, &ch, 1);
s->regs[addr] = value;
s->regs[R_STATUS] |= STATUS_IE;
break;
default:
DUART(printf("%s addr=%x v=%x\n", __func__, addr, value));
if (addr < ARRAY_SIZE(s->regs))
s->regs[addr] = value;
break;
}
uart_update_status(s);
uart_update_irq(s);
}
| {
"code": [
" qemu_chr_fe_write(s->chr, &ch, 1);",
" qemu_chr_fe_write(s->chr, &ch, 1);"
],
"line_no": [
49,
49
]
} | FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned int VAR_3)
{
XilinxUARTLite *s = VAR_0;
uint32_t value = VAR_2;
unsigned char VAR_4 = value;
VAR_1 >>= 2;
switch (VAR_1)
{
case R_STATUS:
hw_error("write to UART STATUS?\n");
break;
case R_CTRL:
if (value & CONTROL_RST_RX) {
s->rx_fifo_pos = 0;
s->rx_fifo_len = 0;
}
s->regs[VAR_1] = value;
break;
case R_TX:
if (s->chr)
qemu_chr_fe_write(s->chr, &VAR_4, 1);
s->regs[VAR_1] = value;
s->regs[R_STATUS] |= STATUS_IE;
break;
default:
DUART(printf("%s VAR_1=%x v=%x\n", __func__, VAR_1, value));
if (VAR_1 < ARRAY_SIZE(s->regs))
s->regs[VAR_1] = value;
break;
}
uart_update_status(s);
uart_update_irq(s);
}
| [
"FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{",
"XilinxUARTLite *s = VAR_0;",
"uint32_t value = VAR_2;",
"unsigned char VAR_4 = value;",
"VAR_1 >>= 2;",
"switch (VAR_1)\n{",
"case R_STATUS:\nhw_error(\"write to UART STATUS?\\n\");",
"break;",
"case R_CTRL:\nif (value & CONTROL_RST_RX) {",
"s->rx_fifo_pos = 0;",
"s->rx_fifo_len = 0;",
"}",
"s->regs[VAR_1] = value;",
"break;",
"case R_TX:\nif (s->chr)\nqemu_chr_fe_write(s->chr, &VAR_4, 1);",
"s->regs[VAR_1] = value;",
"s->regs[R_STATUS] |= STATUS_IE;",
"break;",
"default:\nDUART(printf(\"%s VAR_1=%x v=%x\\n\", __func__, VAR_1, value));",
"if (VAR_1 < ARRAY_SIZE(s->regs))\ns->regs[VAR_1] = value;",
"break;",
"}",
"uart_update_status(s);",
"uart_update_irq(s);",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47,
49
],
[
53
],
[
59
],
[
61
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
]
]
|
15,256 | static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts)
{
CharDriverState *chr = qemu_chr_find(opts->chardev);
VhostUserChardevProps props;
if (chr == NULL) {
error_report("chardev \"%s\" not found", opts->chardev);
return NULL;
}
/* inspect chardev opts */
memset(&props, 0, sizeof(props));
if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) {
return NULL;
}
if (!props.is_socket || !props.is_unix) {
error_report("chardev \"%s\" is not a unix socket",
opts->chardev);
return NULL;
}
qemu_chr_fe_claim_no_fail(chr);
return chr;
}
| true | qemu | 8190483196148f765c65785876f7b893d64b6cdd | static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts)
{
CharDriverState *chr = qemu_chr_find(opts->chardev);
VhostUserChardevProps props;
if (chr == NULL) {
error_report("chardev \"%s\" not found", opts->chardev);
return NULL;
}
memset(&props, 0, sizeof(props));
if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) {
return NULL;
}
if (!props.is_socket || !props.is_unix) {
error_report("chardev \"%s\" is not a unix socket",
opts->chardev);
return NULL;
}
qemu_chr_fe_claim_no_fail(chr);
return chr;
}
| {
"code": [
"static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts)",
" error_report(\"chardev \\\"%s\\\" not found\", opts->chardev);",
" if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) {",
" error_report(\"chardev \\\"%s\\\" is not a unix socket\",",
" opts->chardev);"
],
"line_no": [
1,
13,
25,
35,
37
]
} | static CharDriverState *FUNC_0(const NetdevVhostUserOptions *opts)
{
CharDriverState *chr = qemu_chr_find(opts->chardev);
VhostUserChardevProps props;
if (chr == NULL) {
error_report("chardev \"%s\" not found", opts->chardev);
return NULL;
}
memset(&props, 0, sizeof(props));
if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) {
return NULL;
}
if (!props.is_socket || !props.is_unix) {
error_report("chardev \"%s\" is not a unix socket",
opts->chardev);
return NULL;
}
qemu_chr_fe_claim_no_fail(chr);
return chr;
}
| [
"static CharDriverState *FUNC_0(const NetdevVhostUserOptions *opts)\n{",
"CharDriverState *chr = qemu_chr_find(opts->chardev);",
"VhostUserChardevProps props;",
"if (chr == NULL) {",
"error_report(\"chardev \\\"%s\\\" not found\", opts->chardev);",
"return NULL;",
"}",
"memset(&props, 0, sizeof(props));",
"if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) {",
"return NULL;",
"}",
"if (!props.is_socket || !props.is_unix) {",
"error_report(\"chardev \\\"%s\\\" is not a unix socket\",\nopts->chardev);",
"return NULL;",
"}",
"qemu_chr_fe_claim_no_fail(chr);",
"return chr;",
"}"
]
| [
1,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
]
]
|
15,257 | static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
// AVStream *st = s->streams[0];
size= MP3_PACKET_SIZE;
ret= av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
if (ret <= 0) {
if(ret<0)
return ret;
return AVERROR_EOF;
}
if (ret > ID3v1_TAG_SIZE &&
memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], "TAG", 3) == 0)
ret -= ID3v1_TAG_SIZE;
/* note: we need to modify the packet size here to handle the last
packet */
pkt->size = ret;
return ret;
} | true | FFmpeg | 7effbee66cf457c62f795d9b9ed3a1110b364b89 | static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
size= MP3_PACKET_SIZE;
ret= av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
if (ret <= 0) {
if(ret<0)
return ret;
return AVERROR_EOF;
}
if (ret > ID3v1_TAG_SIZE &&
memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], "TAG", 3) == 0)
ret -= ID3v1_TAG_SIZE;
pkt->size = ret;
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2, VAR_3;
VAR_3= MP3_PACKET_SIZE;
VAR_2= av_get_packet(VAR_0->pb, VAR_1, VAR_3);
VAR_1->stream_index = 0;
if (VAR_2 <= 0) {
if(VAR_2<0)
return VAR_2;
return AVERROR_EOF;
}
if (VAR_2 > ID3v1_TAG_SIZE &&
memcmp(&VAR_1->data[VAR_2 - ID3v1_TAG_SIZE], "TAG", 3) == 0)
VAR_2 -= ID3v1_TAG_SIZE;
VAR_1->VAR_3 = VAR_2;
return VAR_2;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2, VAR_3;",
"VAR_3= MP3_PACKET_SIZE;",
"VAR_2= av_get_packet(VAR_0->pb, VAR_1, VAR_3);",
"VAR_1->stream_index = 0;",
"if (VAR_2 <= 0) {",
"if(VAR_2<0)\nreturn VAR_2;",
"return AVERROR_EOF;",
"}",
"if (VAR_2 > ID3v1_TAG_SIZE &&\nmemcmp(&VAR_1->data[VAR_2 - ID3v1_TAG_SIZE], \"TAG\", 3) == 0)\nVAR_2 -= ID3v1_TAG_SIZE;",
"VAR_1->VAR_3 = VAR_2;",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
15
],
[
20
],
[
22
],
[
24,
26
],
[
28
],
[
30
],
[
34,
36,
38
],
[
46
],
[
48
],
[
50
]
]
|
15,259 | static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *const p = data;
int compressed, xmin, ymin, xmax, ymax;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *bufstart = buf;
uint8_t *scanline;
int ret = -1;
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = buf[2];
xmin = AV_RL16(buf + 4);
ymin = AV_RL16(buf + 6);
xmax = AV_RL16(buf + 8);
ymax = AV_RL16(buf + 10);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bits_per_pixel = buf[3];
bytes_per_line = AV_RL16(buf + 66);
nplanes = buf[65];
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
(!compressed && bytes_per_scanline > buf_size / h)) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes << 8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
buf += 128;
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
ptr[3 * x] = scanline[x];
ptr[3 * x + 1] = scanline[x + bytes_per_line];
ptr[3 * x + 2] = scanline[x + (bytes_per_line << 1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769;
if (buf_size < 769) {
av_log(avctx, AV_LOG_ERROR, "File is too short\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
for (y = 0; y < h; y++, ptr += stride) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (buf != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
buf = palstart;
}
if (*buf++ != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
} else if (nplanes == 1) { /* all packed formats, max. 16 colors */
GetBitContext s;
for (y = 0; y < h; y++) {
init_get_bits(&s, scanline, bytes_per_scanline << 3);
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else { /* planar, 4, 8 or 16 colors */
int i;
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
int m = 0x80 >> (x & 7), v = 0;
for (i = nplanes - 1; i >= 0; i--) {
v <<= 1;
v += !!(scanline[i * bytes_per_line + (x >> 3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&buf, (uint32_t *)p->data[1], 256);
} else if (bits_per_pixel < 8) {
const uint8_t *palette = bufstart + 16;
pcx_palette(&palette, (uint32_t *)p->data[1], 16);
}
*got_frame = 1;
ret = buf - bufstart;
end:
av_free(scanline);
return ret;
}
| true | FFmpeg | 15ee419b7abaf17f8c662c145fe93d3dbf43282b | static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *const p = data;
int compressed, xmin, ymin, xmax, ymax;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *bufstart = buf;
uint8_t *scanline;
int ret = -1;
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = buf[2];
xmin = AV_RL16(buf + 4);
ymin = AV_RL16(buf + 6);
xmax = AV_RL16(buf + 8);
ymax = AV_RL16(buf + 10);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bits_per_pixel = buf[3];
bytes_per_line = AV_RL16(buf + 66);
nplanes = buf[65];
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
(!compressed && bytes_per_scanline > buf_size / h)) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes << 8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
buf += 128;
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
ptr[3 * x] = scanline[x];
ptr[3 * x + 1] = scanline[x + bytes_per_line];
ptr[3 * x + 2] = scanline[x + (bytes_per_line << 1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769;
if (buf_size < 769) {
av_log(avctx, AV_LOG_ERROR, "File is too short\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
for (y = 0; y < h; y++, ptr += stride) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (buf != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
buf = palstart;
}
if (*buf++ != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
} else if (nplanes == 1) {
GetBitContext s;
for (y = 0; y < h; y++) {
init_get_bits(&s, scanline, bytes_per_scanline << 3);
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else {
int i;
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
int m = 0x80 >> (x & 7), v = 0;
for (i = nplanes - 1; i >= 0; i--) {
v <<= 1;
v += !!(scanline[i * bytes_per_line + (x >> 3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&buf, (uint32_t *)p->data[1], 256);
} else if (bits_per_pixel < 8) {
const uint8_t *palette = bufstart + 16;
pcx_palette(&palette, (uint32_t *)p->data[1], 16);
}
*got_frame = 1;
ret = buf - bufstart;
end:
av_free(scanline);
return ret;
}
| {
"code": [
" scanline = av_malloc(bytes_per_scanline);"
],
"line_no": [
157
]
} | 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;
AVFrame *const p = VAR_1;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
unsigned int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18,
VAR_19;
uint8_t *ptr;
const uint8_t *VAR_20 = VAR_4 + VAR_5;
const uint8_t *VAR_21 = VAR_4;
uint8_t *scanline;
int VAR_22 = -1;
if (VAR_4[0] != 0x0a || VAR_4[1] > 5) {
av_log(VAR_0, AV_LOG_ERROR, "this is not PCX encoded VAR_1\n");
return AVERROR_INVALIDDATA;
}
VAR_6 = VAR_4[2];
VAR_7 = AV_RL16(VAR_4 + 4);
VAR_8 = AV_RL16(VAR_4 + 6);
VAR_9 = AV_RL16(VAR_4 + 8);
VAR_10 = AV_RL16(VAR_4 + 10);
if (VAR_9 < VAR_7 || VAR_10 < VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
VAR_11 = VAR_9 - VAR_7 + 1;
VAR_12 = VAR_10 - VAR_8 + 1;
VAR_13 = VAR_4[3];
VAR_14 = AV_RL16(VAR_4 + 66);
VAR_15 = VAR_4[65];
VAR_19 = VAR_15 * VAR_14;
if (VAR_19 < (VAR_11 * VAR_13 * VAR_15 + 7) / 8 ||
(!VAR_6 && VAR_19 > VAR_5 / VAR_12)) {
av_log(VAR_0, AV_LOG_ERROR, "PCX VAR_1 is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((VAR_15 << 8) + VAR_13) {
case 0x0308:
VAR_0->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
VAR_0->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
VAR_4 += 128;
if ((VAR_22 = ff_set_dimensions(VAR_0, VAR_11, VAR_12)) < 0)
return VAR_22;
if ((VAR_22 = ff_get_buffer(VAR_0, p, 0)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_22;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->VAR_1[0];
VAR_16 = p->linesize[0];
scanline = av_malloc(VAR_19);
if (!scanline)
return AVERROR(ENOMEM);
if (VAR_15 == 3 && VAR_13 == 8) {
for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {
VAR_4 = pcx_rle_decode(VAR_4, VAR_20,
scanline, VAR_19, VAR_6);
for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++) {
ptr[3 * VAR_18] = scanline[VAR_18];
ptr[3 * VAR_18 + 1] = scanline[VAR_18 + VAR_14];
ptr[3 * VAR_18 + 2] = scanline[VAR_18 + (VAR_14 << 1)];
}
ptr += VAR_16;
}
} else if (VAR_15 == 1 && VAR_13 == 8) {
const uint8_t *VAR_23 = VAR_21 + VAR_5 - 769;
if (VAR_5 < 769) {
av_log(VAR_0, AV_LOG_ERROR, "File is too short\n");
VAR_22 = VAR_0->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : VAR_5;
goto end;
}
for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++, ptr += VAR_16) {
VAR_4 = pcx_rle_decode(VAR_4, VAR_20,
scanline, VAR_19, VAR_6);
memcpy(ptr, scanline, VAR_11);
}
if (VAR_4 != VAR_23) {
av_log(VAR_0, AV_LOG_WARNING, "image VAR_1 possibly corrupted\n");
VAR_4 = VAR_23;
}
if (*VAR_4++ != 12) {
av_log(VAR_0, AV_LOG_ERROR, "expected VAR_27 after image VAR_1\n");
VAR_22 = VAR_0->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : VAR_5;
goto end;
}
} else if (VAR_15 == 1) {
GetBitContext s;
for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {
init_get_bits(&s, scanline, VAR_19 << 3);
VAR_4 = pcx_rle_decode(VAR_4, VAR_20,
scanline, VAR_19, VAR_6);
for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++)
ptr[VAR_18] = get_bits(&s, VAR_13);
ptr += VAR_16;
}
} else {
int VAR_24;
for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {
VAR_4 = pcx_rle_decode(VAR_4, VAR_20,
scanline, VAR_19, VAR_6);
for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++) {
int VAR_25 = 0x80 >> (VAR_18 & 7), VAR_26 = 0;
for (VAR_24 = VAR_15 - 1; VAR_24 >= 0; VAR_24--) {
VAR_26 <<= 1;
VAR_26 += !!(scanline[VAR_24 * VAR_14 + (VAR_18 >> 3)] & VAR_25);
}
ptr[VAR_18] = VAR_26;
}
ptr += VAR_16;
}
}
if (VAR_15 == 1 && VAR_13 == 8) {
pcx_palette(&VAR_4, (uint32_t *)p->VAR_1[1], 256);
} else if (VAR_13 < 8) {
const uint8_t *VAR_27 = VAR_21 + 16;
pcx_palette(&VAR_27, (uint32_t *)p->VAR_1[1], 16);
}
*VAR_2 = 1;
VAR_22 = VAR_4 - VAR_21;
end:
av_free(scanline);
return VAR_22;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AVFrame *const p = VAR_1;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"unsigned int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18,\nVAR_19;",
"uint8_t *ptr;",
"const uint8_t *VAR_20 = VAR_4 + VAR_5;",
"const uint8_t *VAR_21 = VAR_4;",
"uint8_t *scanline;",
"int VAR_22 = -1;",
"if (VAR_4[0] != 0x0a || VAR_4[1] > 5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"this is not PCX encoded VAR_1\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_6 = VAR_4[2];",
"VAR_7 = AV_RL16(VAR_4 + 4);",
"VAR_8 = AV_RL16(VAR_4 + 6);",
"VAR_9 = AV_RL16(VAR_4 + 8);",
"VAR_10 = AV_RL16(VAR_4 + 10);",
"if (VAR_9 < VAR_7 || VAR_10 < VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid image dimensions\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = VAR_9 - VAR_7 + 1;",
"VAR_12 = VAR_10 - VAR_8 + 1;",
"VAR_13 = VAR_4[3];",
"VAR_14 = AV_RL16(VAR_4 + 66);",
"VAR_15 = VAR_4[65];",
"VAR_19 = VAR_15 * VAR_14;",
"if (VAR_19 < (VAR_11 * VAR_13 * VAR_15 + 7) / 8 ||\n(!VAR_6 && VAR_19 > VAR_5 / VAR_12)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"PCX VAR_1 is corrupted\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"switch ((VAR_15 << 8) + VAR_13) {",
"case 0x0308:\nVAR_0->pix_fmt = AV_PIX_FMT_RGB24;",
"break;",
"case 0x0108:\ncase 0x0104:\ncase 0x0102:\ncase 0x0101:\ncase 0x0401:\ncase 0x0301:\ncase 0x0201:\nVAR_0->pix_fmt = AV_PIX_FMT_PAL8;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid PCX file\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_4 += 128;",
"if ((VAR_22 = ff_set_dimensions(VAR_0, VAR_11, VAR_12)) < 0)\nreturn VAR_22;",
"if ((VAR_22 = ff_get_buffer(VAR_0, p, 0)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_22;",
"}",
"p->pict_type = AV_PICTURE_TYPE_I;",
"ptr = p->VAR_1[0];",
"VAR_16 = p->linesize[0];",
"scanline = av_malloc(VAR_19);",
"if (!scanline)\nreturn AVERROR(ENOMEM);",
"if (VAR_15 == 3 && VAR_13 == 8) {",
"for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {",
"VAR_4 = pcx_rle_decode(VAR_4, VAR_20,\nscanline, VAR_19, VAR_6);",
"for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++) {",
"ptr[3 * VAR_18] = scanline[VAR_18];",
"ptr[3 * VAR_18 + 1] = scanline[VAR_18 + VAR_14];",
"ptr[3 * VAR_18 + 2] = scanline[VAR_18 + (VAR_14 << 1)];",
"}",
"ptr += VAR_16;",
"}",
"} else if (VAR_15 == 1 && VAR_13 == 8) {",
"const uint8_t *VAR_23 = VAR_21 + VAR_5 - 769;",
"if (VAR_5 < 769) {",
"av_log(VAR_0, AV_LOG_ERROR, \"File is too short\\n\");",
"VAR_22 = VAR_0->err_recognition & AV_EF_EXPLODE ?\nAVERROR_INVALIDDATA : VAR_5;",
"goto end;",
"}",
"for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++, ptr += VAR_16) {",
"VAR_4 = pcx_rle_decode(VAR_4, VAR_20,\nscanline, VAR_19, VAR_6);",
"memcpy(ptr, scanline, VAR_11);",
"}",
"if (VAR_4 != VAR_23) {",
"av_log(VAR_0, AV_LOG_WARNING, \"image VAR_1 possibly corrupted\\n\");",
"VAR_4 = VAR_23;",
"}",
"if (*VAR_4++ != 12) {",
"av_log(VAR_0, AV_LOG_ERROR, \"expected VAR_27 after image VAR_1\\n\");",
"VAR_22 = VAR_0->err_recognition & AV_EF_EXPLODE ?\nAVERROR_INVALIDDATA : VAR_5;",
"goto end;",
"}",
"} else if (VAR_15 == 1) {",
"GetBitContext s;",
"for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {",
"init_get_bits(&s, scanline, VAR_19 << 3);",
"VAR_4 = pcx_rle_decode(VAR_4, VAR_20,\nscanline, VAR_19, VAR_6);",
"for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++)",
"ptr[VAR_18] = get_bits(&s, VAR_13);",
"ptr += VAR_16;",
"}",
"} else {",
"int VAR_24;",
"for (VAR_17 = 0; VAR_17 < VAR_12; VAR_17++) {",
"VAR_4 = pcx_rle_decode(VAR_4, VAR_20,\nscanline, VAR_19, VAR_6);",
"for (VAR_18 = 0; VAR_18 < VAR_11; VAR_18++) {",
"int VAR_25 = 0x80 >> (VAR_18 & 7), VAR_26 = 0;",
"for (VAR_24 = VAR_15 - 1; VAR_24 >= 0; VAR_24--) {",
"VAR_26 <<= 1;",
"VAR_26 += !!(scanline[VAR_24 * VAR_14 + (VAR_18 >> 3)] & VAR_25);",
"}",
"ptr[VAR_18] = VAR_26;",
"}",
"ptr += VAR_16;",
"}",
"}",
"if (VAR_15 == 1 && VAR_13 == 8) {",
"pcx_palette(&VAR_4, (uint32_t *)p->VAR_1[1], 256);",
"} else if (VAR_13 < 8) {",
"const uint8_t *VAR_27 = VAR_21 + 16;",
"pcx_palette(&VAR_27, (uint32_t *)p->VAR_1[1], 16);",
"}",
"*VAR_2 = 1;",
"VAR_22 = VAR_4 - VAR_21;",
"end:\nav_free(scanline);",
"return VAR_22;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93,
95
],
[
97
],
[
99,
101,
103,
105,
107,
109,
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
127
],
[
131,
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
151
],
[
153
],
[
157
],
[
159,
161
],
[
165
],
[
167
],
[
169,
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255,
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277,
279
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
325
],
[
327,
329
],
[
331
],
[
333
]
]
|
15,261 | static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
// check if we have an audio packet cached
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
mkv->cur_audio_pkt.size = 0;
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Could not write cached audio packet ret:%d\n", ret);
return ret;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(s);
} else if (mkv->cluster_pos) {
end_ebml_master(pb, mkv->cluster);
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES, cuespos);
if (ret < 0) return ret;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
// update the duration
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
avio_seek(pb, currentpos, SEEK_SET);
}
end_ebml_master(pb, mkv->segment);
av_free(mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_destruct_packet(&mkv->cur_audio_pkt);
avio_flush(pb);
return 0;
}
| false | FFmpeg | bda5b6627a558cf10c4d09eeff264289a1370cc1 | static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
mkv->cur_audio_pkt.size = 0;
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Could not write cached audio packet ret:%d\n", ret);
return ret;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(s);
} else if (mkv->cluster_pos) {
end_ebml_master(pb, mkv->cluster);
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES, cuespos);
if (ret < 0) return ret;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
avio_seek(pb, currentpos, SEEK_SET);
}
end_ebml_master(pb, mkv->segment);
av_free(mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_destruct_packet(&mkv->cur_audio_pkt);
avio_flush(pb);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MatroskaMuxContext *mkv = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int64_t currentpos, cuespos;
int VAR_1;
if (mkv->cur_audio_pkt.size > 0) {
VAR_1 = mkv_write_packet_internal(VAR_0, &mkv->cur_audio_pkt);
mkv->cur_audio_pkt.size = 0;
if (VAR_1 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Could not write cached audio packet VAR_1:%d\n", VAR_1);
return VAR_1;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(VAR_0);
} else if (mkv->cluster_pos) {
end_ebml_master(pb, mkv->cluster);
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
cuespos = mkv_write_cues(pb, mkv->cues, VAR_0->nb_streams);
VAR_1 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES, cuespos);
if (VAR_1 < 0) return VAR_1;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
av_log(VAR_0, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
avio_seek(pb, currentpos, SEEK_SET);
}
end_ebml_master(pb, mkv->segment);
av_free(mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_destruct_packet(&mkv->cur_audio_pkt);
avio_flush(pb);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MatroskaMuxContext *mkv = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int64_t currentpos, cuespos;",
"int VAR_1;",
"if (mkv->cur_audio_pkt.size > 0) {",
"VAR_1 = mkv_write_packet_internal(VAR_0, &mkv->cur_audio_pkt);",
"mkv->cur_audio_pkt.size = 0;",
"if (VAR_1 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not write cached audio packet VAR_1:%d\\n\", VAR_1);",
"return VAR_1;",
"}",
"}",
"if (mkv->dyn_bc) {",
"end_ebml_master(mkv->dyn_bc, mkv->cluster);",
"mkv_flush_dynbuf(VAR_0);",
"} else if (mkv->cluster_pos) {",
"end_ebml_master(pb, mkv->cluster);",
"}",
"if (pb->seekable) {",
"if (mkv->cues->num_entries) {",
"cuespos = mkv_write_cues(pb, mkv->cues, VAR_0->nb_streams);",
"VAR_1 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES, cuespos);",
"if (VAR_1 < 0) return VAR_1;",
"}",
"mkv_write_seekhead(pb, mkv->main_seekhead);",
"av_log(VAR_0, AV_LOG_DEBUG, \"end duration = %\" PRIu64 \"\\n\", mkv->duration);",
"currentpos = avio_tell(pb);",
"avio_seek(pb, mkv->duration_offset, SEEK_SET);",
"put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);",
"avio_seek(pb, currentpos, SEEK_SET);",
"}",
"end_ebml_master(pb, mkv->segment);",
"av_free(mkv->tracks);",
"av_freep(&mkv->cues->entries);",
"av_freep(&mkv->cues);",
"av_destruct_packet(&mkv->cur_audio_pkt);",
"avio_flush(pb);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
]
|
15,263 | int is_adx(const unsigned char *buf,size_t bufsize)
{
int offset;
if (buf[0]!=0x80) return 0;
offset = (read_long(buf)^0x80000000)+4;
if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
return offset;
}
| true | FFmpeg | f19af812a32c1398d48c3550d11dbc6aafbb2bfc | int is_adx(const unsigned char *buf,size_t bufsize)
{
int offset;
if (buf[0]!=0x80) return 0;
offset = (read_long(buf)^0x80000000)+4;
if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
return offset;
}
| {
"code": [
"\tint\toffset;",
"\tif (buf[0]!=0x80) return 0;",
"\toffset = (read_long(buf)^0x80000000)+4;",
"\tif (bufsize<offset || memcmp(buf+offset-6,\"(c)CRI\",6)) return 0;",
"\treturn offset;",
"\treturn offset;"
],
"line_no": [
5,
9,
11,
13,
15,
15
]
} | int FUNC_0(const unsigned char *VAR_0,size_t VAR_1)
{
int VAR_2;
if (VAR_0[0]!=0x80) return 0;
VAR_2 = (read_long(VAR_0)^0x80000000)+4;
if (VAR_1<VAR_2 || memcmp(VAR_0+VAR_2-6,"(c)CRI",6)) return 0;
return VAR_2;
}
| [
"int FUNC_0(const unsigned char *VAR_0,size_t VAR_1)\n{",
"int\tVAR_2;",
"if (VAR_0[0]!=0x80) return 0;",
"VAR_2 = (read_long(VAR_0)^0x80000000)+4;",
"if (VAR_1<VAR_2 || memcmp(VAR_0+VAR_2-6,\"(c)CRI\",6)) return 0;",
"return VAR_2;",
"}"
]
| [
0,
1,
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
15,265 | rfc3986_parse_port(URI *uri, const char **str)
{
const char *cur = *str;
if (ISA_DIGIT(cur)) {
if (uri != NULL)
uri->port = 0;
while (ISA_DIGIT(cur)) {
if (uri != NULL)
uri->port = uri->port * 10 + (*cur - '0');
cur++;
}
*str = cur;
return(0);
}
return(1);
}
| true | qemu | 2b21233061696feed434317a70e0a8b74f956ec8 | rfc3986_parse_port(URI *uri, const char **str)
{
const char *cur = *str;
if (ISA_DIGIT(cur)) {
if (uri != NULL)
uri->port = 0;
while (ISA_DIGIT(cur)) {
if (uri != NULL)
uri->port = uri->port * 10 + (*cur - '0');
cur++;
}
*str = cur;
return(0);
}
return(1);
}
| {
"code": [
"\tif (uri != NULL)",
"\t uri->port = 0;",
"\twhile (ISA_DIGIT(cur)) {",
"\t if (uri != NULL)",
"\t\turi->port = uri->port * 10 + (*cur - '0');",
"\t cur++;",
"\t*str = cur;",
"\treturn(0);",
" return(1);"
],
"line_no": [
11,
13,
15,
17,
19,
21,
25,
27,
31
]
} | FUNC_0(URI *VAR_0, const char **VAR_1)
{
const char *VAR_2 = *VAR_1;
if (ISA_DIGIT(VAR_2)) {
if (VAR_0 != NULL)
VAR_0->port = 0;
while (ISA_DIGIT(VAR_2)) {
if (VAR_0 != NULL)
VAR_0->port = VAR_0->port * 10 + (*VAR_2 - '0');
VAR_2++;
}
*VAR_1 = VAR_2;
return(0);
}
return(1);
}
| [
"FUNC_0(URI *VAR_0, const char **VAR_1)\n{",
"const char *VAR_2 = *VAR_1;",
"if (ISA_DIGIT(VAR_2)) {",
"if (VAR_0 != NULL)\nVAR_0->port = 0;",
"while (ISA_DIGIT(VAR_2)) {",
"if (VAR_0 != NULL)\nVAR_0->port = VAR_0->port * 10 + (*VAR_2 - '0');",
"VAR_2++;",
"}",
"*VAR_1 = VAR_2;",
"return(0);",
"}",
"return(1);",
"}"
]
| [
0,
0,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
]
|
15,266 | static void encode_422_bitstream(HYuvContext *s, int count){
int i;
count/=2;
if(s->flags&CODEC_FLAG_PASS1){
for(i=0; i<count; i++){
s->stats[0][ s->temp[0][2*i ] ]++;
s->stats[1][ s->temp[1][ i ] ]++;
s->stats[0][ s->temp[0][2*i+1] ]++;
s->stats[2][ s->temp[2][ i ] ]++;
}
}else if(s->context){
for(i=0; i<count; i++){
s->stats[0][ s->temp[0][2*i ] ]++;
put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
s->stats[1][ s->temp[1][ i ] ]++;
put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
s->stats[0][ s->temp[0][2*i+1] ]++;
put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
s->stats[2][ s->temp[2][ i ] ]++;
put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
}
}else{
for(i=0; i<count; i++){
put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
}
}
}
| true | FFmpeg | 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 | static void encode_422_bitstream(HYuvContext *s, int count){
int i;
count/=2;
if(s->flags&CODEC_FLAG_PASS1){
for(i=0; i<count; i++){
s->stats[0][ s->temp[0][2*i ] ]++;
s->stats[1][ s->temp[1][ i ] ]++;
s->stats[0][ s->temp[0][2*i+1] ]++;
s->stats[2][ s->temp[2][ i ] ]++;
}
}else if(s->context){
for(i=0; i<count; i++){
s->stats[0][ s->temp[0][2*i ] ]++;
put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
s->stats[1][ s->temp[1][ i ] ]++;
put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
s->stats[0][ s->temp[0][2*i+1] ]++;
put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
s->stats[2][ s->temp[2][ i ] ]++;
put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
}
}else{
for(i=0; i<count; i++){
put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
}
}
}
| {
"code": [
"static void encode_422_bitstream(HYuvContext *s, int count){"
],
"line_no": [
1
]
} | static void FUNC_0(HYuvContext *VAR_0, int VAR_1){
int VAR_2;
VAR_1/=2;
if(VAR_0->flags&CODEC_FLAG_PASS1){
for(VAR_2=0; VAR_2<VAR_1; VAR_2++){
VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2 ] ]++;
VAR_0->stats[1][ VAR_0->temp[1][ VAR_2 ] ]++;
VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2+1] ]++;
VAR_0->stats[2][ VAR_0->temp[2][ VAR_2 ] ]++;
}
}else if(VAR_0->context){
for(VAR_2=0; VAR_2<VAR_1; VAR_2++){
VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2 ] ]++;
put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2 ] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2 ] ]);
VAR_0->stats[1][ VAR_0->temp[1][ VAR_2 ] ]++;
put_bits(&VAR_0->pb, VAR_0->len[1][ VAR_0->temp[1][ VAR_2 ] ], VAR_0->bits[1][ VAR_0->temp[1][ VAR_2 ] ]);
VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2+1] ]++;
put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2+1] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2+1] ]);
VAR_0->stats[2][ VAR_0->temp[2][ VAR_2 ] ]++;
put_bits(&VAR_0->pb, VAR_0->len[2][ VAR_0->temp[2][ VAR_2 ] ], VAR_0->bits[2][ VAR_0->temp[2][ VAR_2 ] ]);
}
}else{
for(VAR_2=0; VAR_2<VAR_1; VAR_2++){
put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2 ] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2 ] ]);
put_bits(&VAR_0->pb, VAR_0->len[1][ VAR_0->temp[1][ VAR_2 ] ], VAR_0->bits[1][ VAR_0->temp[1][ VAR_2 ] ]);
put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2+1] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2+1] ]);
put_bits(&VAR_0->pb, VAR_0->len[2][ VAR_0->temp[2][ VAR_2 ] ], VAR_0->bits[2][ VAR_0->temp[2][ VAR_2 ] ]);
}
}
}
| [
"static void FUNC_0(HYuvContext *VAR_0, int VAR_1){",
"int VAR_2;",
"VAR_1/=2;",
"if(VAR_0->flags&CODEC_FLAG_PASS1){",
"for(VAR_2=0; VAR_2<VAR_1; VAR_2++){",
"VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2 ] ]++;",
"VAR_0->stats[1][ VAR_0->temp[1][ VAR_2 ] ]++;",
"VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2+1] ]++;",
"VAR_0->stats[2][ VAR_0->temp[2][ VAR_2 ] ]++;",
"}",
"}else if(VAR_0->context){",
"for(VAR_2=0; VAR_2<VAR_1; VAR_2++){",
"VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2 ] ]++;",
"put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2 ] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2 ] ]);",
"VAR_0->stats[1][ VAR_0->temp[1][ VAR_2 ] ]++;",
"put_bits(&VAR_0->pb, VAR_0->len[1][ VAR_0->temp[1][ VAR_2 ] ], VAR_0->bits[1][ VAR_0->temp[1][ VAR_2 ] ]);",
"VAR_0->stats[0][ VAR_0->temp[0][2*VAR_2+1] ]++;",
"put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2+1] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2+1] ]);",
"VAR_0->stats[2][ VAR_0->temp[2][ VAR_2 ] ]++;",
"put_bits(&VAR_0->pb, VAR_0->len[2][ VAR_0->temp[2][ VAR_2 ] ], VAR_0->bits[2][ VAR_0->temp[2][ VAR_2 ] ]);",
"}",
"}else{",
"for(VAR_2=0; VAR_2<VAR_1; VAR_2++){",
"put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2 ] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2 ] ]);",
"put_bits(&VAR_0->pb, VAR_0->len[1][ VAR_0->temp[1][ VAR_2 ] ], VAR_0->bits[1][ VAR_0->temp[1][ VAR_2 ] ]);",
"put_bits(&VAR_0->pb, VAR_0->len[0][ VAR_0->temp[0][2*VAR_2+1] ], VAR_0->bits[0][ VAR_0->temp[0][2*VAR_2+1] ]);",
"put_bits(&VAR_0->pb, VAR_0->len[2][ VAR_0->temp[2][ VAR_2 ] ], VAR_0->bits[2][ VAR_0->temp[2][ VAR_2 ] ]);",
"}",
"}",
"}"
]
| [
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
],
[
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
]
]
|
15,267 | static int usb_net_handle_dataout(USBNetState *s, USBPacket *p)
{
int ret = p->len;
int sz = sizeof(s->out_buf) - s->out_ptr;
struct rndis_packet_msg_type *msg =
(struct rndis_packet_msg_type *) s->out_buf;
uint32_t len;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %u\n", p->len);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < p->len; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
if (sz > ret)
sz = ret;
memcpy(&s->out_buf[s->out_ptr], p->data, sz);
s->out_ptr += sz;
if (!is_rndis(s)) {
if (ret < 64) {
qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr);
s->out_ptr = 0;
}
return ret;
}
len = le32_to_cpu(msg->MessageLength);
if (s->out_ptr < 8 || s->out_ptr < len)
return ret;
if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);
uint32_t size = le32_to_cpu(msg->DataLength);
if (offs + size <= len)
qemu_send_packet(&s->nic->nc, s->out_buf + offs, size);
}
s->out_ptr -= len;
memmove(s->out_buf, &s->out_buf[len], s->out_ptr);
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_net_handle_dataout(USBNetState *s, USBPacket *p)
{
int ret = p->len;
int sz = sizeof(s->out_buf) - s->out_ptr;
struct rndis_packet_msg_type *msg =
(struct rndis_packet_msg_type *) s->out_buf;
uint32_t len;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %u\n", p->len);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < p->len; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
if (sz > ret)
sz = ret;
memcpy(&s->out_buf[s->out_ptr], p->data, sz);
s->out_ptr += sz;
if (!is_rndis(s)) {
if (ret < 64) {
qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr);
s->out_ptr = 0;
}
return ret;
}
len = le32_to_cpu(msg->MessageLength);
if (s->out_ptr < 8 || s->out_ptr < len)
return ret;
if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);
uint32_t size = le32_to_cpu(msg->DataLength);
if (offs + size <= len)
qemu_send_packet(&s->nic->nc, s->out_buf + offs, size);
}
s->out_ptr -= len;
memmove(s->out_buf, &s->out_buf[len], s->out_ptr);
return ret;
}
| {
"code": [
" int i;",
" fprintf(stderr, \":\");",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");",
" int i;",
" fprintf(stderr, \":\");",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");",
" int ret = p->len;",
" fprintf(stderr, \"usbnet: data out len %u\\n\", p->len);",
" int i;",
" fprintf(stderr, \":\");",
" for (i = 0; i < p->len; i++) {",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");",
" memcpy(&s->out_buf[s->out_ptr], p->data, sz);"
],
"line_no": [
23,
25,
29,
31,
33,
37,
23,
25,
29,
31,
33,
37,
5,
19,
23,
25,
27,
29,
31,
33,
37,
49
]
} | static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)
{
int VAR_2 = VAR_1->len;
int VAR_3 = sizeof(VAR_0->out_buf) - VAR_0->out_ptr;
struct rndis_packet_msg_type *VAR_4 =
(struct rndis_packet_msg_type *) VAR_0->out_buf;
uint32_t len;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %u\n", VAR_1->len);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < VAR_1->len; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", VAR_1->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
if (VAR_3 > VAR_2)
VAR_3 = VAR_2;
memcpy(&VAR_0->out_buf[VAR_0->out_ptr], VAR_1->data, VAR_3);
VAR_0->out_ptr += VAR_3;
if (!is_rndis(VAR_0)) {
if (VAR_2 < 64) {
qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf, VAR_0->out_ptr);
VAR_0->out_ptr = 0;
}
return VAR_2;
}
len = le32_to_cpu(VAR_4->MessageLength);
if (VAR_0->out_ptr < 8 || VAR_0->out_ptr < len)
return VAR_2;
if (le32_to_cpu(VAR_4->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(VAR_4->DataOffset);
uint32_t size = le32_to_cpu(VAR_4->DataLength);
if (offs + size <= len)
qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf + offs, size);
}
VAR_0->out_ptr -= len;
memmove(VAR_0->out_buf, &VAR_0->out_buf[len], VAR_0->out_ptr);
return VAR_2;
}
| [
"static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)\n{",
"int VAR_2 = VAR_1->len;",
"int VAR_3 = sizeof(VAR_0->out_buf) - VAR_0->out_ptr;",
"struct rndis_packet_msg_type *VAR_4 =\n(struct rndis_packet_msg_type *) VAR_0->out_buf;",
"uint32_t len;",
"#ifdef TRAFFIC_DEBUG\nfprintf(stderr, \"usbnet: data out len %u\\n\", VAR_1->len);",
"{",
"int i;",
"fprintf(stderr, \":\");",
"for (i = 0; i < VAR_1->len; i++) {",
"if (!(i & 15))\nfprintf(stderr, \"\\n%04x:\", i);",
"fprintf(stderr, \" %02x\", VAR_1->data[i]);",
"}",
"fprintf(stderr, \"\\n\\n\");",
"}",
"#endif\nif (VAR_3 > VAR_2)\nVAR_3 = VAR_2;",
"memcpy(&VAR_0->out_buf[VAR_0->out_ptr], VAR_1->data, VAR_3);",
"VAR_0->out_ptr += VAR_3;",
"if (!is_rndis(VAR_0)) {",
"if (VAR_2 < 64) {",
"qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf, VAR_0->out_ptr);",
"VAR_0->out_ptr = 0;",
"}",
"return VAR_2;",
"}",
"len = le32_to_cpu(VAR_4->MessageLength);",
"if (VAR_0->out_ptr < 8 || VAR_0->out_ptr < len)\nreturn VAR_2;",
"if (le32_to_cpu(VAR_4->MessageType) == RNDIS_PACKET_MSG) {",
"uint32_t offs = 8 + le32_to_cpu(VAR_4->DataOffset);",
"uint32_t size = le32_to_cpu(VAR_4->DataLength);",
"if (offs + size <= len)\nqemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf + offs, size);",
"}",
"VAR_0->out_ptr -= len;",
"memmove(VAR_0->out_buf, &VAR_0->out_buf[len], VAR_0->out_ptr);",
"return VAR_2;",
"}"
]
| [
0,
1,
0,
0,
0,
1,
0,
1,
1,
1,
1,
1,
0,
1,
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,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
]
]
|
15,268 | static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit, real_islit;
TCGv va, vb, vc, tmp, tmp2;
TCGv_i32 t32;
DisasJumpType ret;
/* Decode all instruction fields */
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
real_islit = islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = DISAS_NEXT;
switch (opc) {
case 0x00:
/* CALL_PAL */
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
/* OPC01 */
goto invalid_opc;
case 0x02:
/* OPC02 */
goto invalid_opc;
case 0x03:
/* OPC03 */
goto invalid_opc;
case 0x04:
/* OPC04 */
goto invalid_opc;
case 0x05:
/* OPC05 */
goto invalid_opc;
case 0x06:
/* OPC06 */
goto invalid_opc;
case 0x07:
/* OPC07 */
goto invalid_opc;
case 0x09:
/* LDAH */
disp16 = (uint32_t)disp16 << 16;
/* fall through */
case 0x08:
/* LDA */
va = dest_gpr(ctx, ra);
/* It's worth special-casing immediate loads. */
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
/* LDBU */
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
/* LDQ_U */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
/* LDWU */
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
/* STW */
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
/* STB */
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
/* STQ_U */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
/* Special case ADDL as SEXTL. */
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
/* Special case SUBQ as NEGQ. */
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* ADDL */
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
/* S4ADDL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
/* SUBL */
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
/* S4SUBL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
/* CMPBGE */
if (ra == 31) {
/* Special case 0 >= X as X == 0. */
gen_helper_cmpbe0(vc, vb);
} else {
gen_helper_cmpbge(vc, va, vb);
}
break;
case 0x12:
/* S8ADDL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
/* S8SUBL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
/* CMPULT */
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
/* ADDQ */
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
/* S4ADDQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
/* SUBQ */
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
/* S4SUBQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
/* CMPEQ */
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
/* S8ADDQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
/* S8SUBQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
/* CMPULE */
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
/* ADDL/V */
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_add_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x49:
/* SUBL/V */
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_sub_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x4D:
/* CMPLT */
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
/* ADDQ/V */
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_eqv_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_add_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x69:
/* SUBQ/V */
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_xor_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x6D:
/* CMPLE */
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
/* Special case BIS as NOP. */
break;
}
if (ra == 31) {
/* Special case BIS as MOV. */
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
/* Special case ORNOT as NOT. */
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* AND */
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
/* BIC */
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
/* CMOVLBS */
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
/* CMOVLBC */
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
/* BIS */
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
/* CMOVEQ */
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
/* CMOVNE */
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
/* ORNOT */
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
/* XOR */
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
/* CMOVLT */
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
/* CMOVGE */
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
/* EQV */
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
/* AMASK */
REQUIRE_REG_31(ra);
tcg_gen_andi_i64(vc, vb, ~ctx->amask);
break;
case 0x64:
/* CMOVLE */
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
/* CMOVGT */
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
/* IMPLVER */
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
/* MSKBL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
/* EXTBL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
/* INSBL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
/* MSKWL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
/* EXTWL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
/* INSWL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
/* MSKLL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
/* EXTLL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
/* INSLL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
/* ZAP */
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
/* ZAPNOT */
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
/* MSKQL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
/* SRL */
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
/* EXTQL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
/* SLL */
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
/* INSQL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
/* SRA */
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
/* MSKWH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
/* INSWH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
/* EXTWH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
/* MSKLH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
/* INSLH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
/* EXTLH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
/* MSKQH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
/* INSQH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
/* EXTQH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* MULL */
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
/* MULQ */
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
/* UMULH */
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
/* MULL/V */
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_mul_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x60:
/* MULQ/V */
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_muls2_i64(vc, tmp, va, vb);
tcg_gen_sari_i64(tmp2, vc, 63);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_AMASK(FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) { /* fn11 & 0x3F */
case 0x04:
/* ITOFS */
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
/* SQRTF */
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
/* SQRTS */
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
/* ITOFF */
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
/* ITOFT */
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
/* SQRTG */
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
/* SQRTT */
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
/* VAX floating point */
/* XXX: rounding mode and trap are ignored (!) */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) { /* fn11 & 0x3F */
case 0x00:
/* ADDF */
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
/* SUBF */
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
/* MULF */
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
/* DIVF */
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
/* CVTDG -- TODO */
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
/* ADDG */
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
/* SUBG */
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
/* MULG */
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
/* DIVG */
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
/* CMPGEQ */
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
/* CMPGLT */
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
/* CMPGLE */
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
/* CVTGF */
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
/* CVTGD -- TODO */
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
/* CVTGQ */
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
/* CVTQF */
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
/* CVTQG */
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
/* IEEE floating-point */
switch (fpfn) { /* fn11 & 0x3F */
case 0x00:
/* ADDS */
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
/* SUBS */
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
/* MULS */
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
/* DIVS */
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
/* ADDT */
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
/* SUBT */
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
/* MULT */
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
/* DIVT */
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
/* CMPTUN */
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
/* CMPTEQ */
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
/* CMPTLT */
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
/* CMPTLE */
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
/* CVTST */
gen_cvtst(ctx, rb, rc, fn11);
} else {
/* CVTTS */
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
/* CVTTQ */
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
/* CVTQS */
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
/* CVTQT */
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
/* CVTLQ */
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
/* CPYS */
if (rc == 31) {
/* Special case CPYS as FNOP. */
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
/* Special case CPYS as FMOV. */
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
/* CPYSN */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
/* CPYSE */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
/* MT_FPCR */
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
/* Re-do the copy of the rounding mode to fp_status
the next time we use dynamic rounding. */
ctx->tb_rm = -1;
}
break;
case 0x025:
/* MF_FPCR */
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
/* FCMOVEQ */
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
/* FCMOVNE */
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
/* FCMOVLT */
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
/* FCMOVGE */
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
/* FCMOVLE */
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
/* FCMOVGT */
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030: /* CVTQL */
case 0x130: /* CVTQL/V */
case 0x530: /* CVTQL/SV */
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql(vc, cpu_env, vb);
gen_fp_exc_raise(rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
/* TRAPB */
/* No-op. */
break;
case 0x0400:
/* EXCB */
/* No-op. */
break;
case 0x4000:
/* MB */
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
case 0x4400:
/* WMB */
tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
break;
case 0x8000:
/* FETCH */
/* No-op */
break;
case 0xA000:
/* FETCH_M */
/* No-op */
break;
case 0xC000:
/* RPCC */
va = dest_gpr(ctx, ra);
if (ctx->base.tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = DISAS_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
/* RC */
gen_rx(ctx, ra, 0);
break;
case 0xE800:
/* ECB */
break;
case 0xF000:
/* RS */
gen_rx(ctx, ra, 1);
break;
case 0xF800:
/* WH64 */
/* No-op */
break;
case 0xFC00:
/* WH64EN */
/* No-op */
break;
default:
goto invalid_opc;
}
break;
case 0x19:
/* HW_MFPR (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
/* JMP, JSR, RET, JSR_COROUTINE. These only differ by the branch
prediction stack action, which of course we don't implement. */
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);
}
ret = DISAS_PC_UPDATED;
break;
case 0x1B:
/* HW_LD (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access (hw_ldl/p) */
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL);
break;
case 0x1:
/* Quadword physical access (hw_ldq/p) */
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEQ);
break;
case 0x2:
/* Longword physical access with lock (hw_ldl_l/p) */
gen_qemu_ldl_l(va, addr, MMU_PHYS_IDX);
break;
case 0x3:
/* Quadword physical access with lock (hw_ldq_l/p) */
gen_qemu_ldq_l(va, addr, MMU_PHYS_IDX);
break;
case 0x4:
/* Longword virtual PTE fetch (hw_ldl/v) */
goto invalid_opc;
case 0x5:
/* Quadword virtual PTE fetch (hw_ldq/v) */
goto invalid_opc;
break;
case 0x6:
/* Invalid */
goto invalid_opc;
case 0x7:
/* Invaliid */
goto invalid_opc;
case 0x8:
/* Longword virtual access (hw_ldl) */
goto invalid_opc;
case 0x9:
/* Quadword virtual access (hw_ldq) */
goto invalid_opc;
case 0xA:
/* Longword virtual access with protection check (hw_ldl/w) */
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
/* Quadword virtual access with protection check (hw_ldq/w) */
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
/* Longword virtual access with alt access mode (hw_ldl/a)*/
goto invalid_opc;
case 0xD:
/* Quadword virtual access with alt access mode (hw_ldq/a) */
goto invalid_opc;
case 0xE:
/* Longword virtual access with alternate access mode and
protection checks (hw_ldl/wa) */
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
/* Quadword virtual access with alternate access mode and
protection checks (hw_ldq/wa) */
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
/* FTOIT */
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
/* FTOIS */
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
/* SEXTB */
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
/* SEXTW */
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
/* CTPOP */
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctpop_i64(vc, vb);
break;
case 0x31:
/* PERR */
REQUIRE_AMASK(MVI);
REQUIRE_NO_LIT;
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
/* CTLZ */
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_clzi_i64(vc, vb, 64);
break;
case 0x33:
/* CTTZ */
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctzi_i64(vc, vb, 64);
break;
case 0x34:
/* UNPKBW */
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
/* UNPKBL */
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
/* PKWB */
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pkwb(vc, vb);
break;
case 0x37:
/* PKLB */
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pklb(vc, vb);
break;
case 0x38:
/* MINSB8 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
/* MINSW4 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
/* MINUB8 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
/* MINUW4 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
/* MAXUB8 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
/* MAXUW4 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
/* MAXSB8 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
/* MAXSW4 */
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
/* HW_MTPR (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
/* HW_RET (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
if (rb == 31) {
/* Pre-EV6 CPUs interpreted this as HW_REI, loading the return
address from EXC_ADDR. This turns out to be useful for our
emulation PALcode, so continue to accept it. */
ctx->lit = vb = tcg_temp_new();
tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));
} else {
vb = load_gpr(ctx, rb);
}
tcg_gen_movi_i64(cpu_lock_addr, -1);
tmp = tcg_temp_new();
tcg_gen_movi_i64(tmp, 0);
st_flag_byte(tmp, ENV_FLAG_RX_SHIFT);
tcg_gen_andi_i64(tmp, vb, 1);
st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
tcg_temp_free(tmp);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
/* Allow interrupts to be recognized right away. */
ret = DISAS_PC_UPDATED_NOCHAIN;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
/* HW_ST (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access */
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL);
tcg_temp_free(tmp);
break;
case 0x1:
/* Quadword physical access */
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEQ);
tcg_temp_free(tmp);
break;
case 0x2:
/* Longword physical access with lock */
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LESL);
break;
case 0x3:
/* Quadword physical access with lock */
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LEQ);
break;
case 0x4:
/* Longword virtual access */
goto invalid_opc;
case 0x5:
/* Quadword virtual access */
goto invalid_opc;
case 0x6:
/* Invalid */
goto invalid_opc;
case 0x7:
/* Invalid */
goto invalid_opc;
case 0x8:
/* Invalid */
goto invalid_opc;
case 0x9:
/* Invalid */
goto invalid_opc;
case 0xA:
/* Invalid */
goto invalid_opc;
case 0xB:
/* Invalid */
goto invalid_opc;
case 0xC:
/* Longword virtual access with alternate access mode */
goto invalid_opc;
case 0xD:
/* Quadword virtual access with alternate access mode */
goto invalid_opc;
case 0xE:
/* Invalid */
goto invalid_opc;
case 0xF:
/* Invalid */
goto invalid_opc;
}
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
/* LDF */
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
/* LDG */
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
/* LDS */
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
/* LDT */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
/* STF */
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
/* STG */
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
/* STS */
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
/* STT */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
/* LDL */
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
/* LDQ */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
/* LDL_L */
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
/* LDQ_L */
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
/* STL */
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
/* STQ */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
/* STL_C */
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LESL);
break;
case 0x2F:
/* STQ_C */
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LEQ);
break;
case 0x30:
/* BR */
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31: /* FBEQ */
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32: /* FBLT */
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33: /* FBLE */
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
/* BSR */
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35: /* FBNE */
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36: /* FBGE */
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37: /* FBGT */
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
/* BLBC */
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
/* BEQ */
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
/* BLT */
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
/* BLE */
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
/* BLBS */
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
/* BNE */
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
/* BGE */
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
/* BGT */
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit, real_islit;
TCGv va, vb, vc, tmp, tmp2;
TCGv_i32 t32;
DisasJumpType ret;
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
real_islit = islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = DISAS_NEXT;
switch (opc) {
case 0x00:
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x09:
disp16 = (uint32_t)disp16 << 16;
case 0x08:
va = dest_gpr(ctx, ra);
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
if (ra == 31) {
gen_helper_cmpbe0(vc, vb);
} else {
gen_helper_cmpbge(vc, va, vb);
}
break;
case 0x12:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_add_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x49:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_sub_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x4D:
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_eqv_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_add_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x69:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_xor_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x6D:
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
break;
}
if (ra == 31) {
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
REQUIRE_REG_31(ra);
tcg_gen_andi_i64(vc, vb, ~ctx->amask);
break;
case 0x64:
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_mul_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_muls2_i64(vc, tmp, va, vb);
tcg_gen_sari_i64(tmp2, vc, 63);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_AMASK(FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) {
case 0x04:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) {
case 0x00:
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
gen_cvtst(ctx, rb, rc, fn11);
} else {
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
if (rc == 31) {
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
ctx->tb_rm = -1;
}
break;
case 0x025:
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
case 0x130:
case 0x530:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql(vc, cpu_env, vb);
gen_fp_exc_raise(rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
break;
case 0x0400:
break;
case 0x4000:
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
case 0x4400:
tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
va = dest_gpr(ctx, ra);
if (ctx->base.tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = DISAS_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
gen_rx(ctx, ra, 0);
break;
case 0xE800:
break;
case 0xF000:
gen_rx(ctx, ra, 1);
break;
case 0xF800:
break;
case 0xFC00:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);
}
ret = DISAS_PC_UPDATED;
break;
case 0x1B:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL);
break;
case 0x1:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEQ);
break;
case 0x2:
gen_qemu_ldl_l(va, addr, MMU_PHYS_IDX);
break;
case 0x3:
gen_qemu_ldq_l(va, addr, MMU_PHYS_IDX);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctpop_i64(vc, vb);
break;
case 0x31:
REQUIRE_AMASK(MVI);
REQUIRE_NO_LIT;
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_clzi_i64(vc, vb, 64);
break;
case 0x33:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctzi_i64(vc, vb, 64);
break;
case 0x34:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pkwb(vc, vb);
break;
case 0x37:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pklb(vc, vb);
break;
case 0x38:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
if (rb == 31) {
ctx->lit = vb = tcg_temp_new();
tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));
} else {
vb = load_gpr(ctx, rb);
}
tcg_gen_movi_i64(cpu_lock_addr, -1);
tmp = tcg_temp_new();
tcg_gen_movi_i64(tmp, 0);
st_flag_byte(tmp, ENV_FLAG_RX_SHIFT);
tcg_gen_andi_i64(tmp, vb, 1);
st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
tcg_temp_free(tmp);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
ret = DISAS_PC_UPDATED_NOCHAIN;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
switch ((insn >> 12) & 0xF) {
case 0x0:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL);
tcg_temp_free(tmp);
break;
case 0x1:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEQ);
tcg_temp_free(tmp);
break;
case 0x2:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LESL);
break;
case 0x3:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LEQ);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LESL);
break;
case 0x2F:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LEQ);
break;
case 0x30:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31:
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32:
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33:
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35:
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36:
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37:
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| {
"code": [
" if (ctx->base.tb->cflags & CF_USE_ICOUNT) {"
],
"line_no": [
1859
]
} | static DisasJumpType FUNC_0(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit, real_islit;
TCGv va, vb, vc, tmp, tmp2;
TCGv_i32 t32;
DisasJumpType ret;
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
real_islit = islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = DISAS_NEXT;
switch (opc) {
case 0x00:
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x09:
disp16 = (uint32_t)disp16 << 16;
case 0x08:
va = dest_gpr(ctx, ra);
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
if (ra == 31) {
gen_helper_cmpbe0(vc, vb);
} else {
gen_helper_cmpbge(vc, va, vb);
}
break;
case 0x12:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_add_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x49:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_sub_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x4D:
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_eqv_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_add_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x69:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_xor_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x6D:
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
break;
}
if (ra == 31) {
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
REQUIRE_REG_31(ra);
tcg_gen_andi_i64(vc, vb, ~ctx->amask);
break;
case 0x64:
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_mul_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_muls2_i64(vc, tmp, va, vb);
tcg_gen_sari_i64(tmp2, vc, 63);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_AMASK(FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) {
case 0x04:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) {
case 0x00:
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
gen_cvtst(ctx, rb, rc, fn11);
} else {
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
if (rc == 31) {
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
ctx->tb_rm = -1;
}
break;
case 0x025:
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
case 0x130:
case 0x530:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql(vc, cpu_env, vb);
gen_fp_exc_raise(rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
break;
case 0x0400:
break;
case 0x4000:
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
case 0x4400:
tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
va = dest_gpr(ctx, ra);
if (ctx->base.tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = DISAS_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
gen_rx(ctx, ra, 0);
break;
case 0xE800:
break;
case 0xF000:
gen_rx(ctx, ra, 1);
break;
case 0xF800:
break;
case 0xFC00:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);
}
ret = DISAS_PC_UPDATED;
break;
case 0x1B:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL);
break;
case 0x1:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEQ);
break;
case 0x2:
gen_qemu_ldl_l(va, addr, MMU_PHYS_IDX);
break;
case 0x3:
gen_qemu_ldq_l(va, addr, MMU_PHYS_IDX);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctpop_i64(vc, vb);
break;
case 0x31:
REQUIRE_AMASK(MVI);
REQUIRE_NO_LIT;
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_clzi_i64(vc, vb, 64);
break;
case 0x33:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctzi_i64(vc, vb, 64);
break;
case 0x34:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pkwb(vc, vb);
break;
case 0x37:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pklb(vc, vb);
break;
case 0x38:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
if (rb == 31) {
ctx->lit = vb = tcg_temp_new();
tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));
} else {
vb = load_gpr(ctx, rb);
}
tcg_gen_movi_i64(cpu_lock_addr, -1);
tmp = tcg_temp_new();
tcg_gen_movi_i64(tmp, 0);
st_flag_byte(tmp, ENV_FLAG_RX_SHIFT);
tcg_gen_andi_i64(tmp, vb, 1);
st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
tcg_temp_free(tmp);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
ret = DISAS_PC_UPDATED_NOCHAIN;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
switch ((insn >> 12) & 0xF) {
case 0x0:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL);
tcg_temp_free(tmp);
break;
case 0x1:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEQ);
tcg_temp_free(tmp);
break;
case 0x2:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LESL);
break;
case 0x3:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LEQ);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LESL);
break;
case 0x2F:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LEQ);
break;
case 0x30:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31:
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32:
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33:
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35:
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36:
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37:
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| [
"static DisasJumpType FUNC_0(DisasContext *ctx, uint32_t insn)\n{",
"int32_t disp21, disp16, disp12 __attribute__((unused));",
"uint16_t fn11;",
"uint8_t opc, ra, rb, rc, fpfn, fn7, lit;",
"bool islit, real_islit;",
"TCGv va, vb, vc, tmp, tmp2;",
"TCGv_i32 t32;",
"DisasJumpType ret;",
"opc = extract32(insn, 26, 6);",
"ra = extract32(insn, 21, 5);",
"rb = extract32(insn, 16, 5);",
"rc = extract32(insn, 0, 5);",
"real_islit = islit = extract32(insn, 12, 1);",
"lit = extract32(insn, 13, 8);",
"disp21 = sextract32(insn, 0, 21);",
"disp16 = sextract32(insn, 0, 16);",
"disp12 = sextract32(insn, 0, 12);",
"fn11 = extract32(insn, 5, 11);",
"fpfn = extract32(insn, 5, 6);",
"fn7 = extract32(insn, 5, 7);",
"if (rb == 31 && !islit) {",
"islit = true;",
"lit = 0;",
"}",
"ret = DISAS_NEXT;",
"switch (opc) {",
"case 0x00:\nret = gen_call_pal(ctx, insn & 0x03ffffff);",
"break;",
"case 0x01:\ngoto invalid_opc;",
"case 0x02:\ngoto invalid_opc;",
"case 0x03:\ngoto invalid_opc;",
"case 0x04:\ngoto invalid_opc;",
"case 0x05:\ngoto invalid_opc;",
"case 0x06:\ngoto invalid_opc;",
"case 0x07:\ngoto invalid_opc;",
"case 0x09:\ndisp16 = (uint32_t)disp16 << 16;",
"case 0x08:\nva = dest_gpr(ctx, ra);",
"if (rb == 31) {",
"tcg_gen_movi_i64(va, disp16);",
"} else {",
"tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);",
"}",
"break;",
"case 0x0A:\nREQUIRE_AMASK(BWX);",
"gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0B:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);",
"break;",
"case 0x0C:\nREQUIRE_AMASK(BWX);",
"gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0D:\nREQUIRE_AMASK(BWX);",
"gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0E:\nREQUIRE_AMASK(BWX);",
"gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0F:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);",
"break;",
"case 0x10:\nvc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"if (ra == 31) {",
"if (fn7 == 0x00) {",
"tcg_gen_ext32s_i64(vc, vb);",
"break;",
"}",
"if (fn7 == 0x29) {",
"tcg_gen_neg_i64(vc, vb);",
"break;",
"}",
"}",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_add_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x02:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_add_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x09:\ntcg_gen_sub_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x0B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_sub_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x0F:\nif (ra == 31) {",
"gen_helper_cmpbe0(vc, vb);",
"} else {",
"gen_helper_cmpbge(vc, va, vb);",
"}",
"break;",
"case 0x12:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_add_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x1B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_sub_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x1D:\ntcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);",
"break;",
"case 0x20:\ntcg_gen_add_i64(vc, va, vb);",
"break;",
"case 0x22:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_add_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x29:\ntcg_gen_sub_i64(vc, va, vb);",
"break;",
"case 0x2B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_sub_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x2D:\ntcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);",
"break;",
"case 0x32:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_add_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x3B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_sub_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x3D:\ntcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);",
"break;",
"case 0x40:\ntmp = tcg_temp_new();",
"tcg_gen_ext32s_i64(tmp, va);",
"tcg_gen_ext32s_i64(vc, vb);",
"tcg_gen_add_i64(tmp, tmp, vc);",
"tcg_gen_ext32s_i64(vc, tmp);",
"gen_helper_check_overflow(cpu_env, vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x49:\ntmp = tcg_temp_new();",
"tcg_gen_ext32s_i64(tmp, va);",
"tcg_gen_ext32s_i64(vc, vb);",
"tcg_gen_sub_i64(tmp, tmp, vc);",
"tcg_gen_ext32s_i64(vc, tmp);",
"gen_helper_check_overflow(cpu_env, vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x4D:\ntcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);",
"break;",
"case 0x60:\ntmp = tcg_temp_new();",
"tmp2 = tcg_temp_new();",
"tcg_gen_eqv_i64(tmp, va, vb);",
"tcg_gen_mov_i64(tmp2, va);",
"tcg_gen_add_i64(vc, va, vb);",
"tcg_gen_xor_i64(tmp2, tmp2, vc);",
"tcg_gen_and_i64(tmp, tmp, tmp2);",
"tcg_gen_shri_i64(tmp, tmp, 63);",
"tcg_gen_movi_i64(tmp2, 0);",
"gen_helper_check_overflow(cpu_env, tmp, tmp2);",
"tcg_temp_free(tmp);",
"tcg_temp_free(tmp2);",
"break;",
"case 0x69:\ntmp = tcg_temp_new();",
"tmp2 = tcg_temp_new();",
"tcg_gen_xor_i64(tmp, va, vb);",
"tcg_gen_mov_i64(tmp2, va);",
"tcg_gen_sub_i64(vc, va, vb);",
"tcg_gen_xor_i64(tmp2, tmp2, vc);",
"tcg_gen_and_i64(tmp, tmp, tmp2);",
"tcg_gen_shri_i64(tmp, tmp, 63);",
"tcg_gen_movi_i64(tmp2, 0);",
"gen_helper_check_overflow(cpu_env, tmp, tmp2);",
"tcg_temp_free(tmp);",
"tcg_temp_free(tmp2);",
"break;",
"case 0x6D:\ntcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x11:\nif (fn7 == 0x20) {",
"if (rc == 31) {",
"break;",
"}",
"if (ra == 31) {",
"vc = dest_gpr(ctx, rc);",
"if (islit) {",
"tcg_gen_movi_i64(vc, lit);",
"} else {",
"tcg_gen_mov_i64(vc, load_gpr(ctx, rb));",
"}",
"break;",
"}",
"}",
"vc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"if (fn7 == 0x28 && ra == 31) {",
"tcg_gen_not_i64(vc, vb);",
"break;",
"}",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_and_i64(vc, va, vb);",
"break;",
"case 0x08:\ntcg_gen_andc_i64(vc, va, vb);",
"break;",
"case 0x14:\ntmp = tcg_temp_new();",
"tcg_gen_andi_i64(tmp, va, 1);",
"tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"tcg_temp_free(tmp);",
"break;",
"case 0x16:\ntmp = tcg_temp_new();",
"tcg_gen_andi_i64(tmp, va, 1);",
"tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"tcg_temp_free(tmp);",
"break;",
"case 0x20:\ntcg_gen_or_i64(vc, va, vb);",
"break;",
"case 0x24:\ntcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x26:\ntcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x28:\ntcg_gen_orc_i64(vc, va, vb);",
"break;",
"case 0x40:\ntcg_gen_xor_i64(vc, va, vb);",
"break;",
"case 0x44:\ntcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x46:\ntcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x48:\ntcg_gen_eqv_i64(vc, va, vb);",
"break;",
"case 0x61:\nREQUIRE_REG_31(ra);",
"tcg_gen_andi_i64(vc, vb, ~ctx->amask);",
"break;",
"case 0x64:\ntcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x66:\ntcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x6C:\nREQUIRE_REG_31(ra);",
"tcg_gen_movi_i64(vc, ctx->implver);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x12:\nvc = dest_gpr(ctx, rc);",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x02:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x06:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x0B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x12:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x16:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x1B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x22:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x26:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x2B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x30:\nif (islit) {",
"gen_zapnoti(vc, va, ~lit);",
"} else {",
"gen_helper_zap(vc, va, load_gpr(ctx, rb));",
"}",
"break;",
"case 0x31:\nif (islit) {",
"gen_zapnoti(vc, va, lit);",
"} else {",
"gen_helper_zapnot(vc, va, load_gpr(ctx, rb));",
"}",
"break;",
"case 0x32:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x34:\nif (islit) {",
"tcg_gen_shri_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_shr_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x36:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x39:\nif (islit) {",
"tcg_gen_shli_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_shl_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x3B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x3C:\nif (islit) {",
"tcg_gen_sari_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_sar_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x52:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x57:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x5A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x62:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x67:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x6A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x72:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x77:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x7A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x13:\nvc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_mul_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x20:\ntcg_gen_mul_i64(vc, va, vb);",
"break;",
"case 0x30:\ntmp = tcg_temp_new();",
"tcg_gen_mulu2_i64(tmp, vc, va, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x40:\ntmp = tcg_temp_new();",
"tcg_gen_ext32s_i64(tmp, va);",
"tcg_gen_ext32s_i64(vc, vb);",
"tcg_gen_mul_i64(tmp, tmp, vc);",
"tcg_gen_ext32s_i64(vc, tmp);",
"gen_helper_check_overflow(cpu_env, vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x60:\ntmp = tcg_temp_new();",
"tmp2 = tcg_temp_new();",
"tcg_gen_muls2_i64(vc, tmp, va, vb);",
"tcg_gen_sari_i64(tmp2, vc, 63);",
"gen_helper_check_overflow(cpu_env, tmp, tmp2);",
"tcg_temp_free(tmp);",
"tcg_temp_free(tmp2);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x14:\nREQUIRE_AMASK(FIX);",
"vc = dest_fpr(ctx, rc);",
"switch (fpfn) {",
"case 0x04:\nREQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_gpr(ctx, ra);",
"tcg_gen_extrl_i64_i32(t32, va);",
"gen_helper_memory_to_s(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"case 0x0A:\nREQUIRE_REG_31(ra);",
"vb = load_fpr(ctx, rb);",
"gen_helper_sqrtf(vc, cpu_env, vb);",
"break;",
"case 0x0B:\nREQUIRE_REG_31(ra);",
"gen_sqrts(ctx, rb, rc, fn11);",
"break;",
"case 0x14:\nREQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_gpr(ctx, ra);",
"tcg_gen_extrl_i64_i32(t32, va);",
"gen_helper_memory_to_f(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"case 0x24:\nREQUIRE_REG_31(rb);",
"va = load_gpr(ctx, ra);",
"tcg_gen_mov_i64(vc, va);",
"break;",
"case 0x2A:\nREQUIRE_REG_31(ra);",
"vb = load_fpr(ctx, rb);",
"gen_helper_sqrtg(vc, cpu_env, vb);",
"break;",
"case 0x02B:\nREQUIRE_REG_31(ra);",
"gen_sqrtt(ctx, rb, rc, fn11);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x15:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"switch (fpfn) {",
"case 0x00:\ngen_helper_addf(vc, cpu_env, va, vb);",
"break;",
"case 0x01:\ngen_helper_subf(vc, cpu_env, va, vb);",
"break;",
"case 0x02:\ngen_helper_mulf(vc, cpu_env, va, vb);",
"break;",
"case 0x03:\ngen_helper_divf(vc, cpu_env, va, vb);",
"break;",
"case 0x1E:\nREQUIRE_REG_31(ra);",
"goto invalid_opc;",
"case 0x20:\ngen_helper_addg(vc, cpu_env, va, vb);",
"break;",
"case 0x21:\ngen_helper_subg(vc, cpu_env, va, vb);",
"break;",
"case 0x22:\ngen_helper_mulg(vc, cpu_env, va, vb);",
"break;",
"case 0x23:\ngen_helper_divg(vc, cpu_env, va, vb);",
"break;",
"case 0x25:\ngen_helper_cmpgeq(vc, cpu_env, va, vb);",
"break;",
"case 0x26:\ngen_helper_cmpglt(vc, cpu_env, va, vb);",
"break;",
"case 0x27:\ngen_helper_cmpgle(vc, cpu_env, va, vb);",
"break;",
"case 0x2C:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtgf(vc, cpu_env, vb);",
"break;",
"case 0x2D:\nREQUIRE_REG_31(ra);",
"goto invalid_opc;",
"case 0x2F:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtgq(vc, cpu_env, vb);",
"break;",
"case 0x3C:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtqf(vc, cpu_env, vb);",
"break;",
"case 0x3E:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtqg(vc, cpu_env, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x16:\nswitch (fpfn) {",
"case 0x00:\ngen_adds(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x01:\ngen_subs(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x02:\ngen_muls(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x03:\ngen_divs(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x20:\ngen_addt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x21:\ngen_subt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x22:\ngen_mult(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x23:\ngen_divt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x24:\ngen_cmptun(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x25:\ngen_cmpteq(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x26:\ngen_cmptlt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x27:\ngen_cmptle(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x2C:\nREQUIRE_REG_31(ra);",
"if (fn11 == 0x2AC || fn11 == 0x6AC) {",
"gen_cvtst(ctx, rb, rc, fn11);",
"} else {",
"gen_cvtts(ctx, rb, rc, fn11);",
"}",
"break;",
"case 0x2F:\nREQUIRE_REG_31(ra);",
"gen_cvttq(ctx, rb, rc, fn11);",
"break;",
"case 0x3C:\nREQUIRE_REG_31(ra);",
"gen_cvtqs(ctx, rb, rc, fn11);",
"break;",
"case 0x3E:\nREQUIRE_REG_31(ra);",
"gen_cvtqt(ctx, rb, rc, fn11);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x17:\nswitch (fn11) {",
"case 0x010:\nREQUIRE_REG_31(ra);",
"vc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"gen_cvtlq(vc, vb);",
"break;",
"case 0x020:\nif (rc == 31) {",
"} else {",
"vc = dest_fpr(ctx, rc);",
"va = load_fpr(ctx, ra);",
"if (ra == rb) {",
"tcg_gen_mov_i64(vc, va);",
"} else {",
"vb = load_fpr(ctx, rb);",
"gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);",
"}",
"}",
"break;",
"case 0x021:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);",
"break;",
"case 0x022:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);",
"break;",
"case 0x024:\nva = load_fpr(ctx, ra);",
"gen_helper_store_fpcr(cpu_env, va);",
"if (ctx->tb_rm == QUAL_RM_D) {",
"ctx->tb_rm = -1;",
"}",
"break;",
"case 0x025:\nva = dest_fpr(ctx, ra);",
"gen_helper_load_fpcr(va, cpu_env);",
"break;",
"case 0x02A:\ngen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);",
"break;",
"case 0x02B:\ngen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);",
"break;",
"case 0x02C:\ngen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);",
"break;",
"case 0x02D:\ngen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);",
"break;",
"case 0x02E:\ngen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);",
"break;",
"case 0x02F:\ngen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);",
"break;",
"case 0x030:\ncase 0x130:\ncase 0x530:\nREQUIRE_REG_31(ra);",
"vc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"gen_helper_cvtql(vc, cpu_env, vb);",
"gen_fp_exc_raise(rc, fn11);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x18:\nswitch ((uint16_t)disp16) {",
"case 0x0000:\nbreak;",
"case 0x0400:\nbreak;",
"case 0x4000:\ntcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);",
"break;",
"case 0x4400:\ntcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);",
"break;",
"case 0x8000:\nbreak;",
"case 0xA000:\nbreak;",
"case 0xC000:\nva = dest_gpr(ctx, ra);",
"if (ctx->base.tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"gen_helper_load_pcc(va, cpu_env);",
"gen_io_end();",
"ret = DISAS_PC_STALE;",
"} else {",
"gen_helper_load_pcc(va, cpu_env);",
"}",
"break;",
"case 0xE000:\ngen_rx(ctx, ra, 0);",
"break;",
"case 0xE800:\nbreak;",
"case 0xF000:\ngen_rx(ctx, ra, 1);",
"break;",
"case 0xF800:\nbreak;",
"case 0xFC00:\nbreak;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x19:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);",
"va = dest_gpr(ctx, ra);",
"ret = gen_mfpr(ctx, va, insn & 0xffff);",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1A:\nvb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(cpu_pc, vb, ~3);",
"if (ra != 31) {",
"tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);",
"}",
"ret = DISAS_PC_UPDATED;",
"break;",
"case 0x1B:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);",
"{",
"TCGv addr = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"va = dest_gpr(ctx, ra);",
"tcg_gen_addi_i64(addr, vb, disp12);",
"switch ((insn >> 12) & 0xF) {",
"case 0x0:\ntcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL);",
"break;",
"case 0x1:\ntcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEQ);",
"break;",
"case 0x2:\ngen_qemu_ldl_l(va, addr, MMU_PHYS_IDX);",
"break;",
"case 0x3:\ngen_qemu_ldq_l(va, addr, MMU_PHYS_IDX);",
"break;",
"case 0x4:\ngoto invalid_opc;",
"case 0x5:\ngoto invalid_opc;",
"break;",
"case 0x6:\ngoto invalid_opc;",
"case 0x7:\ngoto invalid_opc;",
"case 0x8:\ngoto invalid_opc;",
"case 0x9:\ngoto invalid_opc;",
"case 0xA:\ntcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);",
"break;",
"case 0xB:\ntcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);",
"break;",
"case 0xC:\ngoto invalid_opc;",
"case 0xD:\ngoto invalid_opc;",
"case 0xE:\ntcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);",
"break;",
"case 0xF:\ntcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);",
"break;",
"}",
"tcg_temp_free(addr);",
"break;",
"}",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1C:\nvc = dest_gpr(ctx, rc);",
"if (fn7 == 0x70) {",
"REQUIRE_AMASK(FIX);",
"REQUIRE_REG_31(rb);",
"va = load_fpr(ctx, ra);",
"tcg_gen_mov_i64(vc, va);",
"break;",
"} else if (fn7 == 0x78) {",
"REQUIRE_AMASK(FIX);",
"REQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_fpr(ctx, ra);",
"gen_helper_s_to_memory(t32, va);",
"tcg_gen_ext_i32_i64(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"}",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"switch (fn7) {",
"case 0x00:\nREQUIRE_AMASK(BWX);",
"REQUIRE_REG_31(ra);",
"tcg_gen_ext8s_i64(vc, vb);",
"break;",
"case 0x01:\nREQUIRE_AMASK(BWX);",
"REQUIRE_REG_31(ra);",
"tcg_gen_ext16s_i64(vc, vb);",
"break;",
"case 0x30:\nREQUIRE_AMASK(CIX);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"tcg_gen_ctpop_i64(vc, vb);",
"break;",
"case 0x31:\nREQUIRE_AMASK(MVI);",
"REQUIRE_NO_LIT;",
"va = load_gpr(ctx, ra);",
"gen_helper_perr(vc, va, vb);",
"break;",
"case 0x32:\nREQUIRE_AMASK(CIX);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"tcg_gen_clzi_i64(vc, vb, 64);",
"break;",
"case 0x33:\nREQUIRE_AMASK(CIX);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"tcg_gen_ctzi_i64(vc, vb, 64);",
"break;",
"case 0x34:\nREQUIRE_AMASK(MVI);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"gen_helper_unpkbw(vc, vb);",
"break;",
"case 0x35:\nREQUIRE_AMASK(MVI);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"gen_helper_unpkbl(vc, vb);",
"break;",
"case 0x36:\nREQUIRE_AMASK(MVI);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"gen_helper_pkwb(vc, vb);",
"break;",
"case 0x37:\nREQUIRE_AMASK(MVI);",
"REQUIRE_REG_31(ra);",
"REQUIRE_NO_LIT;",
"gen_helper_pklb(vc, vb);",
"break;",
"case 0x38:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minsb8(vc, va, vb);",
"break;",
"case 0x39:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minsw4(vc, va, vb);",
"break;",
"case 0x3A:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minub8(vc, va, vb);",
"break;",
"case 0x3B:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minuw4(vc, va, vb);",
"break;",
"case 0x3C:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxub8(vc, va, vb);",
"break;",
"case 0x3D:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxuw4(vc, va, vb);",
"break;",
"case 0x3E:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxsb8(vc, va, vb);",
"break;",
"case 0x3F:\nREQUIRE_AMASK(MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxsw4(vc, va, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x1D:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);",
"vb = load_gpr(ctx, rb);",
"ret = gen_mtpr(ctx, vb, insn & 0xffff);",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1E:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);",
"if (rb == 31) {",
"ctx->lit = vb = tcg_temp_new();",
"tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));",
"} else {",
"vb = load_gpr(ctx, rb);",
"}",
"tcg_gen_movi_i64(cpu_lock_addr, -1);",
"tmp = tcg_temp_new();",
"tcg_gen_movi_i64(tmp, 0);",
"st_flag_byte(tmp, ENV_FLAG_RX_SHIFT);",
"tcg_gen_andi_i64(tmp, vb, 1);",
"st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);",
"tcg_temp_free(tmp);",
"tcg_gen_andi_i64(cpu_pc, vb, ~3);",
"ret = DISAS_PC_UPDATED_NOCHAIN;",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1F:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);",
"{",
"switch ((insn >> 12) & 0xF) {",
"case 0x0:\nva = load_gpr(ctx, ra);",
"vb = load_gpr(ctx, rb);",
"tmp = tcg_temp_new();",
"tcg_gen_addi_i64(tmp, vb, disp12);",
"tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL);",
"tcg_temp_free(tmp);",
"break;",
"case 0x1:\nva = load_gpr(ctx, ra);",
"vb = load_gpr(ctx, rb);",
"tmp = tcg_temp_new();",
"tcg_gen_addi_i64(tmp, vb, disp12);",
"tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEQ);",
"tcg_temp_free(tmp);",
"break;",
"case 0x2:\nret = gen_store_conditional(ctx, ra, rb, disp12,\nMMU_PHYS_IDX, MO_LESL);",
"break;",
"case 0x3:\nret = gen_store_conditional(ctx, ra, rb, disp12,\nMMU_PHYS_IDX, MO_LEQ);",
"break;",
"case 0x4:\ngoto invalid_opc;",
"case 0x5:\ngoto invalid_opc;",
"case 0x6:\ngoto invalid_opc;",
"case 0x7:\ngoto invalid_opc;",
"case 0x8:\ngoto invalid_opc;",
"case 0x9:\ngoto invalid_opc;",
"case 0xA:\ngoto invalid_opc;",
"case 0xB:\ngoto invalid_opc;",
"case 0xC:\ngoto invalid_opc;",
"case 0xD:\ngoto invalid_opc;",
"case 0xE:\ngoto invalid_opc;",
"case 0xF:\ngoto invalid_opc;",
"}",
"break;",
"}",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x20:\ngen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);",
"break;",
"case 0x21:\ngen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);",
"break;",
"case 0x22:\ngen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);",
"break;",
"case 0x23:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);",
"break;",
"case 0x24:\ngen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);",
"break;",
"case 0x25:\ngen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);",
"break;",
"case 0x26:\ngen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);",
"break;",
"case 0x27:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);",
"break;",
"case 0x28:\ngen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);",
"break;",
"case 0x29:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2A:\ngen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2B:\ngen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2C:\ngen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2D:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2E:\nret = gen_store_conditional(ctx, ra, rb, disp16,\nctx->mem_idx, MO_LESL);",
"break;",
"case 0x2F:\nret = gen_store_conditional(ctx, ra, rb, disp16,\nctx->mem_idx, MO_LEQ);",
"break;",
"case 0x30:\nret = gen_bdirect(ctx, ra, disp21);",
"break;",
"case 0x31:\nret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);",
"break;",
"case 0x32:\nret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);",
"break;",
"case 0x33:\nret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);",
"break;",
"case 0x34:\nret = gen_bdirect(ctx, ra, disp21);",
"break;",
"case 0x35:\nret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);",
"break;",
"case 0x36:\nret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);",
"break;",
"case 0x37:\nret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);",
"break;",
"case 0x38:\nret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);",
"break;",
"case 0x39:\nret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);",
"break;",
"case 0x3A:\nret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);",
"break;",
"case 0x3B:\nret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);",
"break;",
"case 0x3C:\nret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);",
"break;",
"case 0x3D:\nret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);",
"break;",
"case 0x3E:\nret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);",
"break;",
"case 0x3F:\nret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);",
"break;",
"invalid_opc:\nret = gen_invalid(ctx);",
"break;",
"}",
"return ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
71
],
[
73
],
[
75,
79
],
[
81,
85
],
[
87,
91
],
[
93,
97
],
[
99,
103
],
[
105,
109
],
[
111,
115
],
[
119,
123
],
[
127,
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
153
],
[
155
],
[
157
],
[
159,
163
],
[
165
],
[
167,
171
],
[
173
],
[
175
],
[
177,
181
],
[
183
],
[
185
],
[
187,
191
],
[
193
],
[
195
],
[
197,
201
],
[
203
],
[
207,
209
],
[
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245,
249
],
[
251
],
[
253
],
[
255,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
275
],
[
277
],
[
279
],
[
281,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297,
301
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
351
],
[
353
],
[
355,
359
],
[
361
],
[
363,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377,
381
],
[
383
],
[
385,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399,
403
],
[
405
],
[
407,
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435,
439
],
[
441
],
[
443,
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463,
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483,
487
],
[
489
],
[
491,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521,
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551,
555
],
[
557
],
[
559,
561
],
[
563
],
[
565
],
[
569,
571
],
[
573
],
[
577
],
[
579
],
[
581
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
605
],
[
607
],
[
611
],
[
615
],
[
617
],
[
619
],
[
623
],
[
625
],
[
627,
631
],
[
633
],
[
635,
639
],
[
641
],
[
643,
647
],
[
649
],
[
651,
653
],
[
655
],
[
657
],
[
659,
663
],
[
665
],
[
667,
669
],
[
671
],
[
673
],
[
675,
679
],
[
681
],
[
683,
687,
689
],
[
691
],
[
693,
697,
699
],
[
701
],
[
703,
707
],
[
709
],
[
711,
715
],
[
717
],
[
719,
723,
725
],
[
727
],
[
729,
733,
735
],
[
737
],
[
739,
743
],
[
745
],
[
747,
751
],
[
753
],
[
755
],
[
757,
761,
763
],
[
765
],
[
767,
771,
773
],
[
775
],
[
777,
781
],
[
783
],
[
785
],
[
787,
789
],
[
791
],
[
793
],
[
797,
799
],
[
801
],
[
803
],
[
805,
809
],
[
811
],
[
813,
817
],
[
819
],
[
821,
825
],
[
827
],
[
829,
833
],
[
835
],
[
837,
841
],
[
843
],
[
845,
849
],
[
851
],
[
853,
857
],
[
859
],
[
861,
865
],
[
867
],
[
869,
873
],
[
875
],
[
877,
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
893,
897
],
[
899
],
[
901
],
[
903
],
[
905
],
[
907
],
[
909,
913
],
[
915
],
[
917,
921
],
[
923
],
[
925
],
[
927
],
[
929
],
[
931
],
[
933
],
[
935
],
[
937
],
[
939
],
[
941,
945
],
[
947
],
[
949,
953
],
[
955
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
973,
977
],
[
979
],
[
981,
985
],
[
987
],
[
989
],
[
991
],
[
993
],
[
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005,
1009
],
[
1011
],
[
1013,
1017
],
[
1019
],
[
1021,
1025
],
[
1027
],
[
1029,
1033
],
[
1035
],
[
1037,
1041
],
[
1043
],
[
1045,
1049
],
[
1051
],
[
1053,
1057
],
[
1059
],
[
1061,
1065
],
[
1067
],
[
1069,
1073
],
[
1075
],
[
1077,
1079
],
[
1081
],
[
1083
],
[
1087,
1089
],
[
1091
],
[
1093
],
[
1095
],
[
1097,
1101
],
[
1103
],
[
1105
],
[
1107,
1111
],
[
1113
],
[
1115,
1119
],
[
1121
],
[
1123
],
[
1125
],
[
1127,
1131
],
[
1133
],
[
1135
],
[
1137
],
[
1139
],
[
1141
],
[
1143
],
[
1145
],
[
1147,
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1165
],
[
1167,
1169
],
[
1171
],
[
1173
],
[
1177,
1179
],
[
1181
],
[
1183
],
[
1185,
1189
],
[
1191
],
[
1193
],
[
1195
],
[
1197
],
[
1199
],
[
1201
],
[
1203,
1207
],
[
1209
],
[
1211
],
[
1213
],
[
1215,
1219
],
[
1221
],
[
1223
],
[
1225,
1229
],
[
1231
],
[
1233
],
[
1235
],
[
1237
],
[
1239
],
[
1241
],
[
1243,
1247
],
[
1249
],
[
1251
],
[
1253
],
[
1255,
1259
],
[
1261
],
[
1263
],
[
1265
],
[
1267,
1271
],
[
1273
],
[
1275
],
[
1277,
1279
],
[
1281
],
[
1283
],
[
1287,
1293
],
[
1295
],
[
1297
],
[
1299
],
[
1301,
1305
],
[
1307
],
[
1309,
1313
],
[
1315
],
[
1317,
1321
],
[
1323
],
[
1325,
1329
],
[
1331
],
[
1333,
1337
],
[
1339
],
[
1341,
1345
],
[
1347
],
[
1349,
1353
],
[
1355
],
[
1357,
1361
],
[
1363
],
[
1365,
1369
],
[
1371
],
[
1373,
1377
],
[
1379
],
[
1381,
1385
],
[
1387
],
[
1389,
1393
],
[
1395
],
[
1397,
1401
],
[
1403
],
[
1405
],
[
1407,
1411
],
[
1413
],
[
1415,
1419
],
[
1421
],
[
1423
],
[
1425,
1429
],
[
1431
],
[
1433
],
[
1435,
1439
],
[
1441
],
[
1443
],
[
1445,
1447
],
[
1449
],
[
1451
],
[
1455,
1459
],
[
1461,
1465
],
[
1467
],
[
1469,
1473
],
[
1475
],
[
1477,
1481
],
[
1483
],
[
1485,
1489
],
[
1491
],
[
1493,
1497
],
[
1499
],
[
1501,
1505
],
[
1507
],
[
1509,
1513
],
[
1515
],
[
1517,
1521
],
[
1523
],
[
1525,
1529
],
[
1531
],
[
1533,
1537
],
[
1539
],
[
1541,
1545
],
[
1547
],
[
1549,
1553
],
[
1555
],
[
1557,
1559
],
[
1561
],
[
1565
],
[
1567
],
[
1571
],
[
1573
],
[
1575
],
[
1577,
1581
],
[
1583
],
[
1585
],
[
1587,
1591
],
[
1593
],
[
1595
],
[
1597,
1601
],
[
1603
],
[
1605
],
[
1607,
1609
],
[
1611
],
[
1613
],
[
1617,
1619
],
[
1621,
1625
],
[
1627
],
[
1629
],
[
1631
],
[
1633
],
[
1635,
1639
],
[
1643
],
[
1645
],
[
1647
],
[
1649
],
[
1653
],
[
1655
],
[
1657
],
[
1659
],
[
1661
],
[
1663
],
[
1665
],
[
1667,
1671
],
[
1673
],
[
1675
],
[
1677
],
[
1679
],
[
1681,
1685
],
[
1687
],
[
1689
],
[
1691
],
[
1693
],
[
1695,
1699
],
[
1701
],
[
1703
],
[
1709
],
[
1711
],
[
1713
],
[
1715,
1719
],
[
1721
],
[
1723
],
[
1725,
1729
],
[
1731
],
[
1733,
1737
],
[
1739
],
[
1741,
1745
],
[
1747
],
[
1749,
1753
],
[
1755
],
[
1757,
1761
],
[
1763
],
[
1765,
1769
],
[
1771
],
[
1773,
1775,
1777,
1779
],
[
1781
],
[
1783
],
[
1785
],
[
1787
],
[
1789
],
[
1791,
1793
],
[
1795
],
[
1797
],
[
1801,
1803
],
[
1805,
1811
],
[
1813,
1819
],
[
1821,
1825
],
[
1827
],
[
1829,
1833
],
[
1835
],
[
1837,
1843
],
[
1845,
1851
],
[
1853,
1857
],
[
1859
],
[
1861
],
[
1863
],
[
1865
],
[
1867
],
[
1869
],
[
1871
],
[
1873
],
[
1875
],
[
1877,
1881
],
[
1883
],
[
1885,
1889
],
[
1891,
1895
],
[
1897
],
[
1899,
1905
],
[
1907,
1913
],
[
1915,
1917
],
[
1919
],
[
1921
],
[
1925,
1929,
1931
],
[
1933
],
[
1935
],
[
1937
],
[
1939,
1941
],
[
1943,
1947,
1953
],
[
1955
],
[
1957
],
[
1959
],
[
1961
],
[
1963
],
[
1965
],
[
1969,
1973,
1975
],
[
1977
],
[
1979
],
[
1981
],
[
1983
],
[
1987
],
[
1989
],
[
1991,
1995
],
[
1997
],
[
1999,
2003
],
[
2005
],
[
2007,
2011
],
[
2013
],
[
2015,
2019
],
[
2021
],
[
2023,
2027
],
[
2029,
2033
],
[
2035
],
[
2037,
2041
],
[
2043,
2047
],
[
2049,
2053
],
[
2055,
2059
],
[
2061,
2065
],
[
2067
],
[
2069,
2073
],
[
2075
],
[
2077,
2081
],
[
2083,
2087
],
[
2089,
2095
],
[
2097
],
[
2099,
2105
],
[
2107
],
[
2109
],
[
2111
],
[
2113
],
[
2115
],
[
2117,
2119
],
[
2121,
2125,
2127
],
[
2129
],
[
2133
],
[
2135
],
[
2137
],
[
2139
],
[
2141
],
[
2143
],
[
2147
],
[
2149
],
[
2151
],
[
2153
],
[
2155
],
[
2157
],
[
2159
],
[
2161
],
[
2163
],
[
2167
],
[
2169
],
[
2171,
2175
],
[
2177
],
[
2179
],
[
2181
],
[
2183,
2187
],
[
2189
],
[
2191
],
[
2193
],
[
2195,
2199
],
[
2201
],
[
2203
],
[
2205
],
[
2207
],
[
2209,
2213
],
[
2215
],
[
2217
],
[
2219
],
[
2221
],
[
2223,
2227
],
[
2229
],
[
2231
],
[
2233
],
[
2235
],
[
2237,
2241
],
[
2243
],
[
2245
],
[
2247
],
[
2249
],
[
2251,
2255
],
[
2257
],
[
2259
],
[
2261
],
[
2263
],
[
2265,
2269
],
[
2271
],
[
2273
],
[
2275
],
[
2277
],
[
2279,
2283
],
[
2285
],
[
2287
],
[
2289
],
[
2291
],
[
2293,
2297
],
[
2299
],
[
2301
],
[
2303
],
[
2305
],
[
2307,
2311
],
[
2313
],
[
2315
],
[
2317
],
[
2319,
2323
],
[
2325
],
[
2327
],
[
2329
],
[
2331,
2335
],
[
2337
],
[
2339
],
[
2341
],
[
2343,
2347
],
[
2349
],
[
2351
],
[
2353
],
[
2355,
2359
],
[
2361
],
[
2363
],
[
2365
],
[
2367,
2371
],
[
2373
],
[
2375
],
[
2377
],
[
2379,
2383
],
[
2385
],
[
2387
],
[
2389
],
[
2391,
2395
],
[
2397
],
[
2399
],
[
2401
],
[
2403,
2405
],
[
2407
],
[
2409
],
[
2413,
2417,
2419
],
[
2421
],
[
2423
],
[
2425
],
[
2427,
2429
],
[
2431,
2435,
2439,
2441
],
[
2443
],
[
2451
],
[
2453
],
[
2455
],
[
2457
],
[
2459
],
[
2461
],
[
2463
],
[
2465
],
[
2467
],
[
2469
],
[
2471
],
[
2473
],
[
2475
],
[
2479
],
[
2481
],
[
2483,
2485
],
[
2487,
2491,
2495,
2497
],
[
2499
],
[
2501
],
[
2503,
2507
],
[
2509
],
[
2511
],
[
2513
],
[
2515
],
[
2517
],
[
2519
],
[
2521,
2525
],
[
2527
],
[
2529
],
[
2531
],
[
2533
],
[
2535
],
[
2537
],
[
2539,
2543,
2545
],
[
2547
],
[
2549,
2553,
2555
],
[
2557
],
[
2559,
2563
],
[
2565,
2569
],
[
2571,
2575
],
[
2577,
2581
],
[
2583,
2587
],
[
2589,
2593
],
[
2595,
2599
],
[
2601,
2605
],
[
2607,
2611
],
[
2613,
2617
],
[
2619,
2623
],
[
2625,
2629
],
[
2631
],
[
2633
],
[
2635
],
[
2637,
2639
],
[
2641,
2643,
2647
],
[
2649
],
[
2651,
2655
],
[
2657
],
[
2659,
2663
],
[
2665
],
[
2667,
2671
],
[
2673
],
[
2675,
2679
],
[
2681
],
[
2683,
2687
],
[
2689
],
[
2691,
2695
],
[
2697
],
[
2699,
2703
],
[
2705
],
[
2707,
2711
],
[
2713
],
[
2715,
2719
],
[
2721
],
[
2723,
2727
],
[
2729
],
[
2731,
2735
],
[
2737
],
[
2739,
2743
],
[
2745
],
[
2747,
2751
],
[
2753
],
[
2755,
2759,
2761
],
[
2763
],
[
2765,
2769,
2771
],
[
2773
],
[
2775,
2779
],
[
2781
],
[
2783,
2785
],
[
2787
],
[
2789,
2791
],
[
2793
],
[
2795,
2797
],
[
2799
],
[
2801,
2805
],
[
2807
],
[
2809,
2811
],
[
2813
],
[
2815,
2817
],
[
2819
],
[
2821,
2823
],
[
2825
],
[
2827,
2831
],
[
2833
],
[
2835,
2839
],
[
2841
],
[
2843,
2847
],
[
2849
],
[
2851,
2855
],
[
2857
],
[
2859,
2863
],
[
2865
],
[
2867,
2871
],
[
2873
],
[
2875,
2879
],
[
2881
],
[
2883,
2887
],
[
2889
],
[
2891,
2893
],
[
2895
],
[
2897
],
[
2901
],
[
2903
]
]
|
15,269 | static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong avpn = args[2];
hwaddr hpte;
target_ulong v, r, rb;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
hpte = pte_index * HASH_PTE_SIZE_64;
v = ppc_hash64_load_hpte0(env, hpte);
r = ppc_hash64_load_hpte1(env, hpte);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {
return H_NOT_FOUND;
}
r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |
HPTE64_R_KEY_HI | HPTE64_R_KEY_LO);
r |= (flags << 55) & HPTE64_R_PP0;
r |= (flags << 48) & HPTE64_R_KEY_HI;
r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);
rb = compute_tlbie_rb(v, r, pte_index);
ppc_hash64_store_hpte0(env, hpte, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY);
ppc_tlb_invalidate_one(env, rb);
ppc_hash64_store_hpte1(env, hpte, r);
/* Don't need a memory barrier, due to qemu's global lock */
ppc_hash64_store_hpte0(env, hpte, v | HPTE64_V_HPTE_DIRTY);
return H_SUCCESS;
}
| true | qemu | f3c75d42adbba553eaf218a832d4fbea32c8f7b8 | static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong avpn = args[2];
hwaddr hpte;
target_ulong v, r, rb;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
hpte = pte_index * HASH_PTE_SIZE_64;
v = ppc_hash64_load_hpte0(env, hpte);
r = ppc_hash64_load_hpte1(env, hpte);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {
return H_NOT_FOUND;
}
r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |
HPTE64_R_KEY_HI | HPTE64_R_KEY_LO);
r |= (flags << 55) & HPTE64_R_PP0;
r |= (flags << 48) & HPTE64_R_KEY_HI;
r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);
rb = compute_tlbie_rb(v, r, pte_index);
ppc_hash64_store_hpte0(env, hpte, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY);
ppc_tlb_invalidate_one(env, rb);
ppc_hash64_store_hpte1(env, hpte, r);
ppc_hash64_store_hpte0(env, hpte, v | HPTE64_V_HPTE_DIRTY);
return H_SUCCESS;
}
| {
"code": [
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {"
],
"line_no": [
21,
21,
21
]
} | static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong avpn = args[2];
hwaddr hpte;
target_ulong v, r, rb;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
hpte = pte_index * HASH_PTE_SIZE_64;
v = ppc_hash64_load_hpte0(env, hpte);
r = ppc_hash64_load_hpte1(env, hpte);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {
return H_NOT_FOUND;
}
r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |
HPTE64_R_KEY_HI | HPTE64_R_KEY_LO);
r |= (flags << 55) & HPTE64_R_PP0;
r |= (flags << 48) & HPTE64_R_KEY_HI;
r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);
rb = compute_tlbie_rb(v, r, pte_index);
ppc_hash64_store_hpte0(env, hpte, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY);
ppc_tlb_invalidate_one(env, rb);
ppc_hash64_store_hpte1(env, hpte, r);
ppc_hash64_store_hpte0(env, hpte, v | HPTE64_V_HPTE_DIRTY);
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"CPUPPCState *env = &cpu->env;",
"target_ulong flags = args[0];",
"target_ulong pte_index = args[1];",
"target_ulong avpn = args[2];",
"hwaddr hpte;",
"target_ulong v, r, rb;",
"if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
"return H_PARAMETER;",
"}",
"hpte = pte_index * HASH_PTE_SIZE_64;",
"v = ppc_hash64_load_hpte0(env, hpte);",
"r = ppc_hash64_load_hpte1(env, hpte);",
"if ((v & HPTE64_V_VALID) == 0 ||\n((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {",
"return H_NOT_FOUND;",
"}",
"r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |\nHPTE64_R_KEY_HI | HPTE64_R_KEY_LO);",
"r |= (flags << 55) & HPTE64_R_PP0;",
"r |= (flags << 48) & HPTE64_R_KEY_HI;",
"r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);",
"rb = compute_tlbie_rb(v, r, pte_index);",
"ppc_hash64_store_hpte0(env, hpte, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY);",
"ppc_tlb_invalidate_one(env, rb);",
"ppc_hash64_store_hpte1(env, hpte, r);",
"ppc_hash64_store_hpte0(env, hpte, v | HPTE64_V_HPTE_DIRTY);",
"return H_SUCCESS;",
"}"
]
| [
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
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
]
]
|
15,270 | void do_op_602_mfrom (void)
{
if (likely(T0 < 602)) {
#ifdef USE_MFROM_ROM_TABLE
#include "mfrom_table.c"
T0 = mfrom_ROM_table[T0];
#else
double d;
/* Extremly decomposed:
* -T0 / 256
* T0 = 256 * log10(10 + 1.0) + 0.5
*/
d = T0;
d = float64_div(d, 256, &env->fp_status);
d = float64_chs(d);
d = exp10(d); // XXX: use float emulation function
d = float64_add(d, 1.0, &env->fp_status);
d = log10(d); // XXX: use float emulation function
d = float64_mul(d, 256, &env->fp_status);
d = float64_add(d, 0.5, &env->fp_status);
T0 = float64_round_to_int(d, &env->fp_status);
#endif
} else {
T0 = 0;
}
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void do_op_602_mfrom (void)
{
if (likely(T0 < 602)) {
#ifdef USE_MFROM_ROM_TABLE
#include "mfrom_table.c"
T0 = mfrom_ROM_table[T0];
#else
double d;
d = T0;
d = float64_div(d, 256, &env->fp_status);
d = float64_chs(d);
d = exp10(d);
d = float64_add(d, 1.0, &env->fp_status);
d = log10(d);
d = float64_mul(d, 256, &env->fp_status);
d = float64_add(d, 0.5, &env->fp_status);
T0 = float64_round_to_int(d, &env->fp_status);
#endif
} else {
T0 = 0;
}
}
| {
"code": [
"#else",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
"#endif",
"#ifdef USE_MFROM_ROM_TABLE",
"#else",
"#endif"
],
"line_no": [
13,
45,
45,
45,
45,
45,
45,
45,
45,
45,
45,
43,
7,
13,
43
]
} | void FUNC_0 (void)
{
if (likely(T0 < 602)) {
#ifdef USE_MFROM_ROM_TABLE
#include "mfrom_table.c"
T0 = mfrom_ROM_table[T0];
#else
double VAR_0;
VAR_0 = T0;
VAR_0 = float64_div(VAR_0, 256, &env->fp_status);
VAR_0 = float64_chs(VAR_0);
VAR_0 = exp10(VAR_0);
VAR_0 = float64_add(VAR_0, 1.0, &env->fp_status);
VAR_0 = log10(VAR_0);
VAR_0 = float64_mul(VAR_0, 256, &env->fp_status);
VAR_0 = float64_add(VAR_0, 0.5, &env->fp_status);
T0 = float64_round_to_int(VAR_0, &env->fp_status);
#endif
} else {
T0 = 0;
}
}
| [
"void FUNC_0 (void)\n{",
"if (likely(T0 < 602)) {",
"#ifdef USE_MFROM_ROM_TABLE\n#include \"mfrom_table.c\"\nT0 = mfrom_ROM_table[T0];",
"#else\ndouble VAR_0;",
"VAR_0 = T0;",
"VAR_0 = float64_div(VAR_0, 256, &env->fp_status);",
"VAR_0 = float64_chs(VAR_0);",
"VAR_0 = exp10(VAR_0);",
"VAR_0 = float64_add(VAR_0, 1.0, &env->fp_status);",
"VAR_0 = log10(VAR_0);",
"VAR_0 = float64_mul(VAR_0, 256, &env->fp_status);",
"VAR_0 = float64_add(VAR_0, 0.5, &env->fp_status);",
"T0 = float64_round_to_int(VAR_0, &env->fp_status);",
"#endif\n} else {",
"T0 = 0;",
"}",
"}"
]
| [
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13,
15
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
]
]
|
15,271 | static int mpc8_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb2, *gb = &gb2;
int i, j, k, ch, cnt, res, t;
Band *bands = c->bands;
int off, out_size;
int maxband, keyframe;
int last[2];
out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
if (*data_size < out_size) {
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
keyframe = c->cur_frame == 0;
if(keyframe){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, buf, buf_size * 8);
skip_bits(gb, c->last_bits_used & 7);
if(keyframe)
maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(maxband > 32) maxband -= 33;
}
c->last_max_band = maxband;
/* read subband indexes */
if(maxband){
last[0] = last[1] = 0;
for(i = maxband - 1; i >= 0; i--){
for(ch = 0; ch < 2; ch++){
last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];
if(last[ch] > 15) last[ch] -= 17;
bands[i].res[ch] = last[ch];
}
}
if(c->MSS){
int mask;
cnt = 0;
for(i = 0; i < maxband; i++)
if(bands[i].res[0] || bands[i].res[1])
cnt++;
t = mpc8_get_mod_golomb(gb, cnt);
mask = mpc8_get_mask(gb, cnt, t);
for(i = maxband - 1; i >= 0; i--)
if(bands[i].res[0] || bands[i].res[1]){
bands[i].msf = mask & 1;
mask >>= 1;
}
}
}
for(i = maxband; i < c->maxbands; i++)
bands[i].res[0] = bands[i].res[1] = 0;
if(keyframe){
for(i = 0; i < 32; i++)
c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;
}
for(i = 0; i < maxband; i++){
if(bands[i].res[0] || bands[i].res[1]){
cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;
if(cnt >= 0){
t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);
if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);
if(bands[i].res[1]) bands[i].scfi[1] = t & 3;
}
}
}
for(i = 0; i < maxband; i++){
for(ch = 0; ch < 2; ch++){
if(!bands[i].res[ch]) continue;
if(c->oldDSCF[ch][i]){
bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;
c->oldDSCF[ch][i] = 0;
}else{
t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(t == 64)
t += get_bits(gb, 6);
bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
}
for(j = 0; j < 2; j++){
if((bands[i].scfi[ch] << j) & 2)
bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
else{
t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(t == 31)
t = 64 + get_bits(gb, 6);
bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
}
}
}
}
for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){
for(ch = 0; ch < 2; ch++){
res = bands[i].res[ch];
switch(res){
case -1:
for(j = 0; j < SAMPLES_PER_BAND; j++)
c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){
cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
t = mpc8_get_mask(gb, 18, cnt);
for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
cnt = 6;//2*mpc8_thres[res]
for(j = 0; j < SAMPLES_PER_BAND; j += 3){
t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);
c->Q[ch][off + j + 0] = mpc8_idx50[t];
c->Q[ch][off + j + 1] = mpc8_idx51[t];
c->Q[ch][off + j + 2] = mpc8_idx52[t];
cnt = (cnt >> 1) + mpc8_huffq2[t];
}
break;
case 3:
case 4:
for(j = 0; j < SAMPLES_PER_BAND; j += 2){
t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
c->Q[ch][off + j + 1] = t >> 4;
c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
cnt = 2 * mpc8_thres[res];
for(j = 0; j < SAMPLES_PER_BAND; j++){
t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];
c->Q[ch][off + j] = t;
cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);
}
break;
default:
for(j = 0; j < SAMPLES_PER_BAND; j++){
c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(res != 9){
c->Q[ch][off + j] <<= res - 9;
c->Q[ch][off + j] |= get_bits(gb, res - 9);
}
c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*data_size = out_size;
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
} | true | FFmpeg | 9bd854b1ff342f82efa6d2ad4e8fefddce5fa731 | static int mpc8_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb2, *gb = &gb2;
int i, j, k, ch, cnt, res, t;
Band *bands = c->bands;
int off, out_size;
int maxband, keyframe;
int last[2];
out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
if (*data_size < out_size) {
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
keyframe = c->cur_frame == 0;
if(keyframe){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, buf, buf_size * 8);
skip_bits(gb, c->last_bits_used & 7);
if(keyframe)
maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(maxband > 32) maxband -= 33;
}
c->last_max_band = maxband;
if(maxband){
last[0] = last[1] = 0;
for(i = maxband - 1; i >= 0; i--){
for(ch = 0; ch < 2; ch++){
last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];
if(last[ch] > 15) last[ch] -= 17;
bands[i].res[ch] = last[ch];
}
}
if(c->MSS){
int mask;
cnt = 0;
for(i = 0; i < maxband; i++)
if(bands[i].res[0] || bands[i].res[1])
cnt++;
t = mpc8_get_mod_golomb(gb, cnt);
mask = mpc8_get_mask(gb, cnt, t);
for(i = maxband - 1; i >= 0; i--)
if(bands[i].res[0] || bands[i].res[1]){
bands[i].msf = mask & 1;
mask >>= 1;
}
}
}
for(i = maxband; i < c->maxbands; i++)
bands[i].res[0] = bands[i].res[1] = 0;
if(keyframe){
for(i = 0; i < 32; i++)
c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;
}
for(i = 0; i < maxband; i++){
if(bands[i].res[0] || bands[i].res[1]){
cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;
if(cnt >= 0){
t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);
if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);
if(bands[i].res[1]) bands[i].scfi[1] = t & 3;
}
}
}
for(i = 0; i < maxband; i++){
for(ch = 0; ch < 2; ch++){
if(!bands[i].res[ch]) continue;
if(c->oldDSCF[ch][i]){
bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;
c->oldDSCF[ch][i] = 0;
}else{
t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(t == 64)
t += get_bits(gb, 6);
bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
}
for(j = 0; j < 2; j++){
if((bands[i].scfi[ch] << j) & 2)
bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
else{
t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(t == 31)
t = 64 + get_bits(gb, 6);
bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
}
}
}
}
for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){
for(ch = 0; ch < 2; ch++){
res = bands[i].res[ch];
switch(res){
case -1:
for(j = 0; j < SAMPLES_PER_BAND; j++)
c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){
cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
t = mpc8_get_mask(gb, 18, cnt);
for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
cnt = 6;
for(j = 0; j < SAMPLES_PER_BAND; j += 3){
t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);
c->Q[ch][off + j + 0] = mpc8_idx50[t];
c->Q[ch][off + j + 1] = mpc8_idx51[t];
c->Q[ch][off + j + 2] = mpc8_idx52[t];
cnt = (cnt >> 1) + mpc8_huffq2[t];
}
break;
case 3:
case 4:
for(j = 0; j < SAMPLES_PER_BAND; j += 2){
t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
c->Q[ch][off + j + 1] = t >> 4;
c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
cnt = 2 * mpc8_thres[res];
for(j = 0; j < SAMPLES_PER_BAND; j++){
t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];
c->Q[ch][off + j] = t;
cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);
}
break;
default:
for(j = 0; j < SAMPLES_PER_BAND; j++){
c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(res != 9){
c->Q[ch][off + j] <<= res - 9;
c->Q[ch][off + j] |= get_bits(gb, res - 9);
}
c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*data_size = out_size;
return c->cur_frame ? c->last_bits_used >> 3 : 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;
MPCContext *c = VAR_0->priv_data;
GetBitContext gb2, *gb = &gb2;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
Band *bands = c->bands;
int VAR_13, VAR_14;
int VAR_15, VAR_16;
int VAR_17[2];
VAR_14 = MPC_FRAME_SIZE * 2 * VAR_0->channels;
if (*VAR_2 < VAR_14) {
av_log(VAR_0, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
VAR_16 = c->cur_frame == 0;
if(VAR_16){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, VAR_4, VAR_5 * 8);
skip_bits(gb, c->last_bits_used & 7);
if(VAR_16)
VAR_15 = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
VAR_15 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(VAR_15 > 32) VAR_15 -= 33;
}
c->last_max_band = VAR_15;
if(VAR_15){
VAR_17[0] = VAR_17[1] = 0;
for(VAR_6 = VAR_15 - 1; VAR_6 >= 0; VAR_6--){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
VAR_17[VAR_9] = get_vlc2(gb, res_vlc[VAR_17[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_17[VAR_9];
if(VAR_17[VAR_9] > 15) VAR_17[VAR_9] -= 17;
bands[VAR_6].VAR_11[VAR_9] = VAR_17[VAR_9];
}
}
if(c->MSS){
int VAR_18;
VAR_10 = 0;
for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++)
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])
VAR_10++;
VAR_12 = mpc8_get_mod_golomb(gb, VAR_10);
VAR_18 = mpc8_get_mask(gb, VAR_10, VAR_12);
for(VAR_6 = VAR_15 - 1; VAR_6 >= 0; VAR_6--)
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){
bands[VAR_6].msf = VAR_18 & 1;
VAR_18 >>= 1;
}
}
}
for(VAR_6 = VAR_15; VAR_6 < c->maxbands; VAR_6++)
bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0;
if(VAR_16){
for(VAR_6 = 0; VAR_6 < 32; VAR_6++)
c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1;
}
for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++){
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){
VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1;
if(VAR_10 >= 0){
VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1);
if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10);
if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3;
}
}
}
for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
if(!bands[VAR_6].VAR_11[VAR_9]) continue;
if(c->oldDSCF[VAR_9][VAR_6]){
bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6;
c->oldDSCF[VAR_9][VAR_6] = 0;
}else{
VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(VAR_12 == 64)
VAR_12 += get_bits(gb, 6);
bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6;
}
for(VAR_7 = 0; VAR_7 < 2; VAR_7++){
if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)
bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7];
else{
VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(VAR_12 == 31)
VAR_12 = 64 + get_bits(gb, 6);
bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6;
}
}
}
}
for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_15; VAR_6++, VAR_13 += SAMPLES_PER_BAND){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
VAR_11 = bands[VAR_6].VAR_11[VAR_9];
switch(VAR_11){
case -1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++)
c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){
VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
VAR_12 = mpc8_get_mask(gb, 18, VAR_10);
for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1)
c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
VAR_10 = 6;
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){
VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2);
c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12];
c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12];
c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12];
VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12];
}
break;
case 3:
case 4:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){
VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3];
c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4;
c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
VAR_10 = 2 * mpc8_thres[VAR_11];
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){
VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5];
c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12;
VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]);
}
break;
default:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){
c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(VAR_11 != 9){
c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9;
c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9);
}
c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, VAR_15, VAR_1, VAR_0->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*VAR_2 = VAR_14;
return c->cur_frame ? c->last_bits_used >> 3 : VAR_5;
} | [
"static int FUNC_0(AVCodecContext * VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MPCContext *c = VAR_0->priv_data;",
"GetBitContext gb2, *gb = &gb2;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"Band *bands = c->bands;",
"int VAR_13, VAR_14;",
"int VAR_15, VAR_16;",
"int VAR_17[2];",
"VAR_14 = MPC_FRAME_SIZE * 2 * VAR_0->channels;",
"if (*VAR_2 < VAR_14) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Output buffer is too small\\n\");",
"return AVERROR(EINVAL);",
"}",
"VAR_16 = c->cur_frame == 0;",
"if(VAR_16){",
"memset(c->Q, 0, sizeof(c->Q));",
"c->last_bits_used = 0;",
"}",
"init_get_bits(gb, VAR_4, VAR_5 * 8);",
"skip_bits(gb, c->last_bits_used & 7);",
"if(VAR_16)\nVAR_15 = mpc8_get_mod_golomb(gb, c->maxbands + 1);",
"else{",
"VAR_15 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);",
"if(VAR_15 > 32) VAR_15 -= 33;",
"}",
"c->last_max_band = VAR_15;",
"if(VAR_15){",
"VAR_17[0] = VAR_17[1] = 0;",
"for(VAR_6 = VAR_15 - 1; VAR_6 >= 0; VAR_6--){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"VAR_17[VAR_9] = get_vlc2(gb, res_vlc[VAR_17[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_17[VAR_9];",
"if(VAR_17[VAR_9] > 15) VAR_17[VAR_9] -= 17;",
"bands[VAR_6].VAR_11[VAR_9] = VAR_17[VAR_9];",
"}",
"}",
"if(c->MSS){",
"int VAR_18;",
"VAR_10 = 0;",
"for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++)",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])\nVAR_10++;",
"VAR_12 = mpc8_get_mod_golomb(gb, VAR_10);",
"VAR_18 = mpc8_get_mask(gb, VAR_10, VAR_12);",
"for(VAR_6 = VAR_15 - 1; VAR_6 >= 0; VAR_6--)",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){",
"bands[VAR_6].msf = VAR_18 & 1;",
"VAR_18 >>= 1;",
"}",
"}",
"}",
"for(VAR_6 = VAR_15; VAR_6 < c->maxbands; VAR_6++)",
"bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0;",
"if(VAR_16){",
"for(VAR_6 = 0; VAR_6 < 32; VAR_6++)",
"c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1;",
"}",
"for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++){",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){",
"VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1;",
"if(VAR_10 >= 0){",
"VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1);",
"if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10);",
"if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3;",
"}",
"}",
"}",
"for(VAR_6 = 0; VAR_6 < VAR_15; VAR_6++){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"if(!bands[VAR_6].VAR_11[VAR_9]) continue;",
"if(c->oldDSCF[VAR_9][VAR_6]){",
"bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6;",
"c->oldDSCF[VAR_9][VAR_6] = 0;",
"}else{",
"VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);",
"if(VAR_12 == 64)\nVAR_12 += get_bits(gb, 6);",
"bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6;",
"}",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++){",
"if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)\nbands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7];",
"else{",
"VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);",
"if(VAR_12 == 31)\nVAR_12 = 64 + get_bits(gb, 6);",
"bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6;",
"}",
"}",
"}",
"}",
"for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_15; VAR_6++, VAR_13 += SAMPLES_PER_BAND){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"VAR_11 = bands[VAR_6].VAR_11[VAR_9];",
"switch(VAR_11){",
"case -1:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++)",
"c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;",
"break;",
"case 0:\nbreak;",
"case 1:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){",
"VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);",
"VAR_12 = mpc8_get_mask(gb, 18, VAR_10);",
"for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1)",
"c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;",
"}",
"break;",
"case 2:\nVAR_10 = 6;",
"for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){",
"VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2);",
"c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12];",
"VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12];",
"}",
"break;",
"case 3:\ncase 4:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){",
"VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4;",
"c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF);",
"}",
"break;",
"case 5:\ncase 6:\ncase 7:\ncase 8:\nVAR_10 = 2 * mpc8_thres[VAR_11];",
"for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){",
"VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5];",
"c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12;",
"VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]);",
"}",
"break;",
"default:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){",
"c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);",
"if(VAR_11 != 9){",
"c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9;",
"c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9);",
"}",
"c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1;",
"}",
"}",
"}",
"}",
"ff_mpc_dequantize_and_synth(c, VAR_15, VAR_1, VAR_0->channels);",
"c->cur_frame++;",
"c->last_bits_used = get_bits_count(gb);",
"if(c->cur_frame >= c->frames)\nc->cur_frame = 0;",
"*VAR_2 = VAR_14;",
"return c->cur_frame ? c->last_bits_used >> 3 : 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
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
],
[
339
],
[
343
],
[
347
],
[
349,
351
],
[
353
],
[
357
],
[
359
]
]
|
15,272 | static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
{
BackupBlockJob *s = container_of(job, BackupBlockJob, common);
if (speed < 0) {
error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
}
| true | qemu | f3e4ce4af336f2ea306fa0f40ec1a5149864ca8c | static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
{
BackupBlockJob *s = container_of(job, BackupBlockJob, common);
if (speed < 0) {
error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
}
| {
"code": [
" ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);",
" ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);",
" ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);",
" ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);"
],
"line_no": [
17,
17,
17,
17
]
} | static void FUNC_0(BlockJob *VAR_0, int64_t VAR_1, Error **VAR_2)
{
BackupBlockJob *s = container_of(VAR_0, BackupBlockJob, common);
if (VAR_1 < 0) {
error_setg(VAR_2, QERR_INVALID_PARAMETER, "VAR_1");
return;
}
ratelimit_set_speed(&s->limit, VAR_1 / BDRV_SECTOR_SIZE, SLICE_TIME);
}
| [
"static void FUNC_0(BlockJob *VAR_0, int64_t VAR_1, Error **VAR_2)\n{",
"BackupBlockJob *s = container_of(VAR_0, BackupBlockJob, common);",
"if (VAR_1 < 0) {",
"error_setg(VAR_2, QERR_INVALID_PARAMETER, \"VAR_1\");",
"return;",
"}",
"ratelimit_set_speed(&s->limit, VAR_1 / BDRV_SECTOR_SIZE, SLICE_TIME);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
15,273 | static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
char *dom0;
xendev = xen_be_find_xendev(type, dom, dev);
if (xendev) {
return xendev;
}
/* init new xendev */
xendev = g_malloc0(ops->size);
xendev->type = type;
xendev->dom = dom;
xendev->dev = dev;
xendev->ops = ops;
dom0 = xs_get_domain_path(xenstore, 0);
snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",
dom0, xendev->type, xendev->dom, xendev->dev);
snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
xendev->type, xendev->dev);
free(dom0);
xendev->debug = debug;
xendev->local_port = -1;
xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);
if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open evtchn device\n");
g_free(xendev);
return NULL;
}
fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
xendev->gnttabdev = xen_xc_gnttab_open(NULL, 0);
if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open gnttab device\n");
xc_evtchn_close(xendev->evtchndev);
g_free(xendev);
return NULL;
}
} else {
xendev->gnttabdev = XC_HANDLER_INITIAL_VALUE;
}
QTAILQ_INSERT_TAIL(&xendevs, xendev, next);
if (xendev->ops->alloc) {
xendev->ops->alloc(xendev);
}
return xendev;
}
| true | qemu | 33876dfad64bc481f59c5e9ccf60db78624c4b93 | static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
char *dom0;
xendev = xen_be_find_xendev(type, dom, dev);
if (xendev) {
return xendev;
}
xendev = g_malloc0(ops->size);
xendev->type = type;
xendev->dom = dom;
xendev->dev = dev;
xendev->ops = ops;
dom0 = xs_get_domain_path(xenstore, 0);
snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",
dom0, xendev->type, xendev->dom, xendev->dev);
snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
xendev->type, xendev->dev);
free(dom0);
xendev->debug = debug;
xendev->local_port = -1;
xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);
if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open evtchn device\n");
g_free(xendev);
return NULL;
}
fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
xendev->gnttabdev = xen_xc_gnttab_open(NULL, 0);
if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open gnttab device\n");
xc_evtchn_close(xendev->evtchndev);
g_free(xendev);
return NULL;
}
} else {
xendev->gnttabdev = XC_HANDLER_INITIAL_VALUE;
}
QTAILQ_INSERT_TAIL(&xendevs, xendev, next);
if (xendev->ops->alloc) {
xendev->ops->alloc(xendev);
}
return xendev;
}
| {
"code": [
" char *dom0;",
" dom0 = xs_get_domain_path(xenstore, 0);",
" snprintf(xendev->be, sizeof(xendev->be), \"%s/backend/%s/%d/%d\",",
" dom0, xendev->type, xendev->dom, xendev->dev);",
" free(dom0);",
" dom0 = xs_get_domain_path(xenstore, 0);",
" free(dom0);",
" dom0 = xs_get_domain_path(xenstore, 0);",
" free(dom0);"
],
"line_no": [
9,
37,
39,
41,
47,
37,
47,
37,
47
]
} | static struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2,
struct XenDevOps *VAR_3)
{
struct XenDevice *VAR_4;
char *VAR_5;
VAR_4 = xen_be_find_xendev(VAR_0, VAR_1, VAR_2);
if (VAR_4) {
return VAR_4;
}
VAR_4 = g_malloc0(VAR_3->size);
VAR_4->VAR_0 = VAR_0;
VAR_4->VAR_1 = VAR_1;
VAR_4->VAR_2 = VAR_2;
VAR_4->VAR_3 = VAR_3;
VAR_5 = xs_get_domain_path(xenstore, 0);
snprintf(VAR_4->be, sizeof(VAR_4->be), "%s/backend/%s/%d/%d",
VAR_5, VAR_4->VAR_0, VAR_4->VAR_1, VAR_4->VAR_2);
snprintf(VAR_4->name, sizeof(VAR_4->name), "%s-%d",
VAR_4->VAR_0, VAR_4->VAR_2);
free(VAR_5);
VAR_4->debug = debug;
VAR_4->local_port = -1;
VAR_4->evtchndev = xen_xc_evtchn_open(NULL, 0);
if (VAR_4->evtchndev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open evtchn device\n");
g_free(VAR_4);
return NULL;
}
fcntl(xc_evtchn_fd(VAR_4->evtchndev), F_SETFD, FD_CLOEXEC);
if (VAR_3->flags & DEVOPS_FLAG_NEED_GNTDEV) {
VAR_4->gnttabdev = xen_xc_gnttab_open(NULL, 0);
if (VAR_4->gnttabdev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open gnttab device\n");
xc_evtchn_close(VAR_4->evtchndev);
g_free(VAR_4);
return NULL;
}
} else {
VAR_4->gnttabdev = XC_HANDLER_INITIAL_VALUE;
}
QTAILQ_INSERT_TAIL(&xendevs, VAR_4, next);
if (VAR_4->VAR_3->alloc) {
VAR_4->VAR_3->alloc(VAR_4);
}
return VAR_4;
}
| [
"static struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2,\nstruct XenDevOps *VAR_3)\n{",
"struct XenDevice *VAR_4;",
"char *VAR_5;",
"VAR_4 = xen_be_find_xendev(VAR_0, VAR_1, VAR_2);",
"if (VAR_4) {",
"return VAR_4;",
"}",
"VAR_4 = g_malloc0(VAR_3->size);",
"VAR_4->VAR_0 = VAR_0;",
"VAR_4->VAR_1 = VAR_1;",
"VAR_4->VAR_2 = VAR_2;",
"VAR_4->VAR_3 = VAR_3;",
"VAR_5 = xs_get_domain_path(xenstore, 0);",
"snprintf(VAR_4->be, sizeof(VAR_4->be), \"%s/backend/%s/%d/%d\",\nVAR_5, VAR_4->VAR_0, VAR_4->VAR_1, VAR_4->VAR_2);",
"snprintf(VAR_4->name, sizeof(VAR_4->name), \"%s-%d\",\nVAR_4->VAR_0, VAR_4->VAR_2);",
"free(VAR_5);",
"VAR_4->debug = debug;",
"VAR_4->local_port = -1;",
"VAR_4->evtchndev = xen_xc_evtchn_open(NULL, 0);",
"if (VAR_4->evtchndev == XC_HANDLER_INITIAL_VALUE) {",
"xen_be_printf(NULL, 0, \"can't open evtchn device\\n\");",
"g_free(VAR_4);",
"return NULL;",
"}",
"fcntl(xc_evtchn_fd(VAR_4->evtchndev), F_SETFD, FD_CLOEXEC);",
"if (VAR_3->flags & DEVOPS_FLAG_NEED_GNTDEV) {",
"VAR_4->gnttabdev = xen_xc_gnttab_open(NULL, 0);",
"if (VAR_4->gnttabdev == XC_HANDLER_INITIAL_VALUE) {",
"xen_be_printf(NULL, 0, \"can't open gnttab device\\n\");",
"xc_evtchn_close(VAR_4->evtchndev);",
"g_free(VAR_4);",
"return NULL;",
"}",
"} else {",
"VAR_4->gnttabdev = XC_HANDLER_INITIAL_VALUE;",
"}",
"QTAILQ_INSERT_TAIL(&xendevs, VAR_4, next);",
"if (VAR_4->VAR_3->alloc) {",
"VAR_4->VAR_3->alloc(VAR_4);",
"}",
"return VAR_4;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
]
]
|
15,274 | int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
AVFrame *extended_frame = NULL;
AVFrame *padded_frame = NULL;
int ret;
AVPacket user_pkt = *avpkt;
int needs_realloc = !user_pkt.data;
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
av_free_packet(avpkt);
av_init_packet(avpkt);
return 0;
}
/* ensure that extended_data is properly set */
if (frame && !frame->extended_data) {
if (av_sample_fmt_is_planar(avctx->sample_fmt) &&
avctx->channels > AV_NUM_DATA_POINTERS) {
av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, "
"with more than %d channels, but extended_data is not set.\n",
AV_NUM_DATA_POINTERS);
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
extended_frame = av_frame_alloc();
if (!extended_frame)
return AVERROR(ENOMEM);
memcpy(extended_frame, frame, sizeof(AVFrame));
extended_frame->extended_data = extended_frame->data;
frame = extended_frame;
}
/* extract audio service type metadata */
if (frame) {
AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_AUDIO_SERVICE_TYPE);
if (sd && sd->size >= sizeof(enum AVAudioServiceType))
avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data;
}
/* check for valid frame size */
if (frame) {
if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {
if (frame->nb_samples > avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
ret = AVERROR(EINVAL);
goto end;
}
} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
if (frame->nb_samples < avctx->frame_size &&
!avctx->internal->last_audio_frame) {
ret = pad_last_frame(avctx, &padded_frame, frame);
if (ret < 0)
goto end;
frame = padded_frame;
avctx->internal->last_audio_frame = 1;
}
if (frame->nb_samples != avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\n", frame->nb_samples, avctx->frame_size);
ret = AVERROR(EINVAL);
goto end;
}
}
}
ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
if (!ret) {
if (*got_packet_ptr) {
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
if (avpkt->pts == AV_NOPTS_VALUE)
avpkt->pts = frame->pts;
if (!avpkt->duration)
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
avpkt->dts = avpkt->pts;
} else {
avpkt->size = 0;
}
}
if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
needs_realloc = 0;
if (user_pkt.data) {
if (user_pkt.size >= avpkt->size) {
memcpy(user_pkt.data, avpkt->data, avpkt->size);
} else {
av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
avpkt->size = user_pkt.size;
ret = -1;
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
}
}
}
if (!ret) {
if (needs_realloc && avpkt->data) {
ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret >= 0)
avpkt->data = avpkt->buf->data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr) {
av_free_packet(avpkt);
av_init_packet(avpkt);
goto end;
}
/* NOTE: if we add any audio encoders which output non-keyframe packets,
* this needs to be moved to the encoders, but for now we can do it
* here to simplify things */
avpkt->flags |= AV_PKT_FLAG_KEY;
end:
av_frame_free(&padded_frame);
av_free(extended_frame);
#if FF_API_AUDIOENC_DELAY
avctx->delay = avctx->initial_padding;
#endif
return ret;
} | true | FFmpeg | 0c800b27611cadd64f46fd1bbd9dc8bb87fe168b | int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
AVFrame *extended_frame = NULL;
AVFrame *padded_frame = NULL;
int ret;
AVPacket user_pkt = *avpkt;
int needs_realloc = !user_pkt.data;
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
av_free_packet(avpkt);
av_init_packet(avpkt);
return 0;
}
if (frame && !frame->extended_data) {
if (av_sample_fmt_is_planar(avctx->sample_fmt) &&
avctx->channels > AV_NUM_DATA_POINTERS) {
av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, "
"with more than %d channels, but extended_data is not set.\n",
AV_NUM_DATA_POINTERS);
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
extended_frame = av_frame_alloc();
if (!extended_frame)
return AVERROR(ENOMEM);
memcpy(extended_frame, frame, sizeof(AVFrame));
extended_frame->extended_data = extended_frame->data;
frame = extended_frame;
}
if (frame) {
AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_AUDIO_SERVICE_TYPE);
if (sd && sd->size >= sizeof(enum AVAudioServiceType))
avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data;
}
if (frame) {
if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {
if (frame->nb_samples > avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
ret = AVERROR(EINVAL);
goto end;
}
} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
if (frame->nb_samples < avctx->frame_size &&
!avctx->internal->last_audio_frame) {
ret = pad_last_frame(avctx, &padded_frame, frame);
if (ret < 0)
goto end;
frame = padded_frame;
avctx->internal->last_audio_frame = 1;
}
if (frame->nb_samples != avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\n", frame->nb_samples, avctx->frame_size);
ret = AVERROR(EINVAL);
goto end;
}
}
}
ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
if (!ret) {
if (*got_packet_ptr) {
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
if (avpkt->pts == AV_NOPTS_VALUE)
avpkt->pts = frame->pts;
if (!avpkt->duration)
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
avpkt->dts = avpkt->pts;
} else {
avpkt->size = 0;
}
}
if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
needs_realloc = 0;
if (user_pkt.data) {
if (user_pkt.size >= avpkt->size) {
memcpy(user_pkt.data, avpkt->data, avpkt->size);
} else {
av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
avpkt->size = user_pkt.size;
ret = -1;
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
}
}
}
if (!ret) {
if (needs_realloc && avpkt->data) {
ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret >= 0)
avpkt->data = avpkt->buf->data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr) {
av_free_packet(avpkt);
av_init_packet(avpkt);
goto end;
}
avpkt->flags |= AV_PKT_FLAG_KEY;
end:
av_frame_free(&padded_frame);
av_free(extended_frame);
#if FF_API_AUDIOENC_DELAY
avctx->delay = avctx->initial_padding;
#endif
return ret;
} | {
"code": [],
"line_no": []
} | int VAR_0 avcodec_encode_audio2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
AVFrame *extended_frame = NULL;
AVFrame *padded_frame = NULL;
int ret;
AVPacket user_pkt = *avpkt;
int needs_realloc = !user_pkt.data;
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
av_free_packet(avpkt);
av_init_packet(avpkt);
return 0;
}
if (frame && !frame->extended_data) {
if (av_sample_fmt_is_planar(avctx->sample_fmt) &&
avctx->channels > AV_NUM_DATA_POINTERS) {
av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, "
"with more than %d channels, but extended_data is not set.\n",
AV_NUM_DATA_POINTERS);
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
extended_frame = av_frame_alloc();
if (!extended_frame)
return AVERROR(ENOMEM);
memcpy(extended_frame, frame, sizeof(AVFrame));
extended_frame->extended_data = extended_frame->data;
frame = extended_frame;
}
if (frame) {
AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_AUDIO_SERVICE_TYPE);
if (sd && sd->size >= sizeof(enum AVAudioServiceType))
avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data;
}
if (frame) {
if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {
if (frame->nb_samples > avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
ret = AVERROR(EINVAL);
goto end;
}
} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
if (frame->nb_samples < avctx->frame_size &&
!avctx->internal->last_audio_frame) {
ret = pad_last_frame(avctx, &padded_frame, frame);
if (ret < 0)
goto end;
frame = padded_frame;
avctx->internal->last_audio_frame = 1;
}
if (frame->nb_samples != avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\n", frame->nb_samples, avctx->frame_size);
ret = AVERROR(EINVAL);
goto end;
}
}
}
ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
if (!ret) {
if (*got_packet_ptr) {
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
if (avpkt->pts == AV_NOPTS_VALUE)
avpkt->pts = frame->pts;
if (!avpkt->duration)
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
avpkt->dts = avpkt->pts;
} else {
avpkt->size = 0;
}
}
if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
needs_realloc = 0;
if (user_pkt.data) {
if (user_pkt.size >= avpkt->size) {
memcpy(user_pkt.data, avpkt->data, avpkt->size);
} else {
av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
avpkt->size = user_pkt.size;
ret = -1;
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
}
}
}
if (!ret) {
if (needs_realloc && avpkt->data) {
ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret >= 0)
avpkt->data = avpkt->buf->data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr) {
av_free_packet(avpkt);
av_init_packet(avpkt);
goto end;
}
avpkt->flags |= AV_PKT_FLAG_KEY;
end:
av_frame_free(&padded_frame);
av_free(extended_frame);
#if FF_API_AUDIOENC_DELAY
avctx->delay = avctx->initial_padding;
#endif
return ret;
} | [
"int VAR_0 avcodec_encode_audio2(AVCodecContext *avctx,\nAVPacket *avpkt,\nconst AVFrame *frame,\nint *got_packet_ptr)\n{",
"AVFrame *extended_frame = NULL;",
"AVFrame *padded_frame = NULL;",
"int ret;",
"AVPacket user_pkt = *avpkt;",
"int needs_realloc = !user_pkt.data;",
"*got_packet_ptr = 0;",
"if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {",
"av_free_packet(avpkt);",
"av_init_packet(avpkt);",
"return 0;",
"}",
"if (frame && !frame->extended_data) {",
"if (av_sample_fmt_is_planar(avctx->sample_fmt) &&\navctx->channels > AV_NUM_DATA_POINTERS) {",
"av_log(avctx, AV_LOG_ERROR, \"Encoding to a planar sample format, \"\n\"with more than %d channels, but extended_data is not set.\\n\",\nAV_NUM_DATA_POINTERS);",
"return AVERROR(EINVAL);",
"}",
"av_log(avctx, AV_LOG_WARNING, \"extended_data is not set.\\n\");",
"extended_frame = av_frame_alloc();",
"if (!extended_frame)\nreturn AVERROR(ENOMEM);",
"memcpy(extended_frame, frame, sizeof(AVFrame));",
"extended_frame->extended_data = extended_frame->data;",
"frame = extended_frame;",
"}",
"if (frame) {",
"AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_AUDIO_SERVICE_TYPE);",
"if (sd && sd->size >= sizeof(enum AVAudioServiceType))\navctx->audio_service_type = *(enum AVAudioServiceType*)sd->data;",
"}",
"if (frame) {",
"if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {",
"if (frame->nb_samples > avctx->frame_size) {",
"av_log(avctx, AV_LOG_ERROR, \"more samples than frame size (avcodec_encode_audio2)\\n\");",
"ret = AVERROR(EINVAL);",
"goto end;",
"}",
"} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {",
"if (frame->nb_samples < avctx->frame_size &&\n!avctx->internal->last_audio_frame) {",
"ret = pad_last_frame(avctx, &padded_frame, frame);",
"if (ret < 0)\ngoto end;",
"frame = padded_frame;",
"avctx->internal->last_audio_frame = 1;",
"}",
"if (frame->nb_samples != avctx->frame_size) {",
"av_log(avctx, AV_LOG_ERROR, \"nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\\n\", frame->nb_samples, avctx->frame_size);",
"ret = AVERROR(EINVAL);",
"goto end;",
"}",
"}",
"}",
"ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);",
"if (!ret) {",
"if (*got_packet_ptr) {",
"if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {",
"if (avpkt->pts == AV_NOPTS_VALUE)\navpkt->pts = frame->pts;",
"if (!avpkt->duration)\navpkt->duration = ff_samples_to_time_base(avctx,\nframe->nb_samples);",
"}",
"avpkt->dts = avpkt->pts;",
"} else {",
"avpkt->size = 0;",
"}",
"}",
"if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {",
"needs_realloc = 0;",
"if (user_pkt.data) {",
"if (user_pkt.size >= avpkt->size) {",
"memcpy(user_pkt.data, avpkt->data, avpkt->size);",
"} else {",
"av_log(avctx, AV_LOG_ERROR, \"Provided packet is too small, needs to be %d\\n\", avpkt->size);",
"avpkt->size = user_pkt.size;",
"ret = -1;",
"}",
"avpkt->buf = user_pkt.buf;",
"avpkt->data = user_pkt.data;",
"#if FF_API_DESTRUCT_PACKET\nFF_DISABLE_DEPRECATION_WARNINGS\navpkt->destruct = user_pkt.destruct;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n} else {",
"if (av_dup_packet(avpkt) < 0) {",
"ret = AVERROR(ENOMEM);",
"}",
"}",
"}",
"if (!ret) {",
"if (needs_realloc && avpkt->data) {",
"ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (ret >= 0)\navpkt->data = avpkt->buf->data;",
"}",
"avctx->frame_number++;",
"}",
"if (ret < 0 || !*got_packet_ptr) {",
"av_free_packet(avpkt);",
"av_init_packet(avpkt);",
"goto end;",
"}",
"avpkt->flags |= AV_PKT_FLAG_KEY;",
"end:\nav_frame_free(&padded_frame);",
"av_free(extended_frame);",
"#if FF_API_AUDIOENC_DELAY\navctx->delay = avctx->initial_padding;",
"#endif\nreturn ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
36
],
[
37,
38
],
[
39
],
[
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
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91,
92,
93
],
[
94,
95,
96
],
[
97
],
[
98
],
[
99
],
[
100
],
[
101
],
[
102
],
[
103
],
[
104
],
[
105,
106
],
[
107
],
[
108
],
[
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
118
],
[
119,
120
],
[
121
],
[
122,
123
],
[
124,
125
],
[
126
]
]
|
15,275 | static int iff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
IffDemuxContext *iff = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int ret;
int64_t pos = avio_tell(pb);
if (pos >= iff->body_end)
return AVERROR_EOF;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->codec_tag == ID_MAUD) {
ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
} else {
ret = av_get_packet(pb, pkt, iff->body_size);
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t *buf;
if (av_new_packet(pkt, iff->body_size + 2) < 0) {
return AVERROR(ENOMEM);
}
buf = pkt->data;
bytestream_put_be16(&buf, 2);
ret = avio_read(pb, buf, iff->body_size);
} else {
av_assert0(0);
}
if (pos == iff->body_pos)
pkt->flags |= AV_PKT_FLAG_KEY;
if (ret < 0)
return ret;
pkt->stream_index = 0;
return ret;
} | true | FFmpeg | 2b31a9c613f95383d5106f8c1cbcee8eb291090f | static int iff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
IffDemuxContext *iff = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int ret;
int64_t pos = avio_tell(pb);
if (pos >= iff->body_end)
return AVERROR_EOF;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->codec_tag == ID_MAUD) {
ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
} else {
ret = av_get_packet(pb, pkt, iff->body_size);
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t *buf;
if (av_new_packet(pkt, iff->body_size + 2) < 0) {
return AVERROR(ENOMEM);
}
buf = pkt->data;
bytestream_put_be16(&buf, 2);
ret = avio_read(pb, buf, iff->body_size);
} else {
av_assert0(0);
}
if (pos == iff->body_pos)
pkt->flags |= AV_PKT_FLAG_KEY;
if (ret < 0)
return ret;
pkt->stream_index = 0;
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
IffDemuxContext *iff = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVStream *st = VAR_0->streams[0];
int VAR_2;
int64_t pos = avio_tell(pb);
if (pos >= iff->body_end)
return AVERROR_EOF;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->codec_tag == ID_MAUD) {
VAR_2 = av_get_packet(pb, VAR_1, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
} else {
VAR_2 = av_get_packet(pb, VAR_1, iff->body_size);
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t *buf;
if (av_new_packet(VAR_1, iff->body_size + 2) < 0) {
return AVERROR(ENOMEM);
}
buf = VAR_1->data;
bytestream_put_be16(&buf, 2);
VAR_2 = avio_read(pb, buf, iff->body_size);
} else {
av_assert0(0);
}
if (pos == iff->body_pos)
VAR_1->flags |= AV_PKT_FLAG_KEY;
if (VAR_2 < 0)
return VAR_2;
VAR_1->stream_index = 0;
return VAR_2;
} | [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"IffDemuxContext *iff = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *st = VAR_0->streams[0];",
"int VAR_2;",
"int64_t pos = avio_tell(pb);",
"if (pos >= iff->body_end)\nreturn AVERROR_EOF;",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if (st->codec->codec_tag == ID_MAUD) {",
"VAR_2 = av_get_packet(pb, VAR_1, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));",
"} else {",
"VAR_2 = av_get_packet(pb, VAR_1, iff->body_size);",
"}",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"uint8_t *buf;",
"if (av_new_packet(VAR_1, iff->body_size + 2) < 0) {",
"return AVERROR(ENOMEM);",
"}",
"buf = VAR_1->data;",
"bytestream_put_be16(&buf, 2);",
"VAR_2 = avio_read(pb, buf, iff->body_size);",
"} else {",
"av_assert0(0);",
"}",
"if (pos == iff->body_pos)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"if (VAR_2 < 0)\nreturn VAR_2;",
"VAR_1->stream_index = 0;",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
]
]
|
15,276 | static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
VirtIOBlockReq *req = s->rq;
while (req) {
qemu_put_sbyte(f, 1);
qemu_put_buffer(f, (unsigned char *)req->elem,
sizeof(VirtQueueElement));
req = req->next;
}
qemu_put_sbyte(f, 0);
}
| true | qemu | f897bf751fbd95e4015b95d202c706548586813a | static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
VirtIOBlockReq *req = s->rq;
while (req) {
qemu_put_sbyte(f, 1);
qemu_put_buffer(f, (unsigned char *)req->elem,
sizeof(VirtQueueElement));
req = req->next;
}
qemu_put_sbyte(f, 0);
}
| {
"code": [
" qemu_put_buffer(f, (unsigned char *)req->elem,"
],
"line_no": [
15
]
} | static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)
{
VirtIOBlock *s = VIRTIO_BLK(VAR_0);
VirtIOBlockReq *req = s->rq;
while (req) {
qemu_put_sbyte(VAR_1, 1);
qemu_put_buffer(VAR_1, (unsigned char *)req->elem,
sizeof(VirtQueueElement));
req = req->next;
}
qemu_put_sbyte(VAR_1, 0);
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)\n{",
"VirtIOBlock *s = VIRTIO_BLK(VAR_0);",
"VirtIOBlockReq *req = s->rq;",
"while (req) {",
"qemu_put_sbyte(VAR_1, 1);",
"qemu_put_buffer(VAR_1, (unsigned char *)req->elem,\nsizeof(VirtQueueElement));",
"req = req->next;",
"}",
"qemu_put_sbyte(VAR_1, 0);",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
15,277 | static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, long dstW, long dstY)
{
#ifdef HAVE_MMX
long dummy=0;
if(c->flags & SWS_ACCURATE_RND){
switch(c->dstFormat){
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX_ACCURATE
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}else{
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}
#endif
#ifdef HAVE_ALTIVEC
/* The following list of supported dstFormat values should
match what's found in the body of altivec_yuv2packedX() */
if(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||
c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)
altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
else
#endif
yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, long dstW, long dstY)
{
#ifdef HAVE_MMX
long dummy=0;
if(c->flags & SWS_ACCURATE_RND){
switch(c->dstFormat){
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t"
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX_ACCURATE
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}else{
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t"
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}
#endif
#ifdef HAVE_ALTIVEC
if(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||
c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)
altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
else
#endif
yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
}
| {
"code": [
"\t\t\t\t int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,",
"\t\t\t);",
"\t\t\t);",
"\t\t\t\t int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,",
"\t\t\t uint8_t *dest, long dstW, long dstY)",
" if(c->flags & SWS_ACCURATE_RND){",
" switch(c->dstFormat){",
" case PIX_FMT_RGB32:",
" YSCALEYUV2PACKEDX_ACCURATE",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\tWRITEBGR32(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
" case PIX_FMT_BGR24:",
" YSCALEYUV2PACKEDX_ACCURATE",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"add %4, %%\"REG_c\"\t\t\t\\n\\t\"",
"\t\t\t\tWRITEBGR24(%%REGc, %5, %%REGa)",
"\t\t\t:: \"r\" (&c->redDither),",
"\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),",
"\t\t\t \"r\" (dest), \"m\" (dstW)",
"\t\t\t: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S",
"\t\t\t);",
" case PIX_FMT_BGR555:",
" YSCALEYUV2PACKEDX_ACCURATE",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR15(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
" case PIX_FMT_BGR565:",
" YSCALEYUV2PACKEDX_ACCURATE",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR16(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
" case PIX_FMT_YUYV422:",
"\t\t\t\tYSCALEYUV2PACKEDX_ACCURATE",
"\t\t\t\t\"psraw $3, %%mm3\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm4\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm1\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm7\t\t\\n\\t\"",
"\t\t\t\tWRITEYUY2(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
"\tswitch(c->dstFormat)",
"\tcase PIX_FMT_RGB32:",
" YSCALEYUV2PACKEDX",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\tWRITEBGR32(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
"\tcase PIX_FMT_BGR24:",
" YSCALEYUV2PACKEDX",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"add %4, %%\"REG_c\"\t\t\t\\n\\t\"",
"\t\t\t\tWRITEBGR24(%%REGc, %5, %%REGa)",
"\t\t\t:: \"r\" (&c->redDither),",
"\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),",
"\t\t\t \"r\" (dest), \"m\" (dstW)",
"\t\t\t: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S",
"\t\t\t);",
"\tcase PIX_FMT_BGR555:",
" YSCALEYUV2PACKEDX",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR15(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
"\tcase PIX_FMT_BGR565:",
" YSCALEYUV2PACKEDX",
"\t\t\t\tYSCALEYUV2RGBX",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t\tWRITEBGR16(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
"\tcase PIX_FMT_YUYV422:",
"\t\t\t\tYSCALEYUV2PACKEDX",
"\t\t\t\t\"psraw $3, %%mm3\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm4\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm1\t\t\\n\\t\"",
"\t\t\t\t\"psraw $3, %%mm7\t\t\\n\\t\"",
"\t\t\t\tWRITEYUY2(%4, %5, %%REGa)",
" YSCALEYUV2PACKEDX_END",
"\t\tif(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||",
"\t\t c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||",
"\t\t c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)",
"\t\t\taltivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,",
"\t\t\t\t chrFilter, chrSrc, chrFilterSize,",
"\t\t\t\t dest, dstW, dstY);",
"#endif",
"\t\t\tyuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,",
"\t\t\t\t chrFilter, chrSrc, chrFilterSize,",
"\t\t\t\t dest, dstW, dstY);",
"\t\t\t);",
"#endif",
"\t\t\t);",
"\t\t\t);",
"\t\t\t);",
"#endif",
"\tswitch(c->dstFormat)",
"\tcase PIX_FMT_RGB32:",
"\t\t\t);",
"\tcase PIX_FMT_BGR24:",
"\t\t\t);",
"\tcase PIX_FMT_BGR555:",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\tcase PIX_FMT_BGR565:",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\tcase PIX_FMT_YUYV422:",
"\t\t\t);",
"\t\t\t);",
"\t\t\t);",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\t\t\t);",
"\t\t\t);",
"\t\t\t);",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"",
"\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"",
"#endif",
"\t\t\t);",
"\t\t\t);",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif"
],
"line_no": [
3,
55,
55,
3,
5,
13,
15,
17,
19,
21,
23,
27,
31,
19,
21,
39,
41,
47,
49,
51,
53,
55,
59,
19,
21,
69,
71,
73,
75,
79,
27,
85,
19,
21,
69,
97,
73,
75,
105,
27,
111,
113,
119,
121,
123,
125,
127,
27,
137,
141,
143,
21,
23,
27,
153,
143,
21,
39,
41,
47,
49,
51,
53,
55,
179,
143,
21,
69,
71,
73,
75,
79,
27,
205,
143,
21,
69,
97,
73,
75,
105,
27,
231,
233,
119,
121,
123,
125,
127,
27,
265,
267,
269,
271,
273,
275,
75,
281,
273,
275,
55,
75,
55,
55,
55,
75,
137,
141,
55,
153,
55,
179,
69,
71,
73,
75,
55,
205,
69,
97,
73,
75,
55,
231,
55,
55,
55,
69,
71,
73,
75,
55,
69,
97,
73,
75,
55,
55,
55,
55,
69,
71,
73,
75,
55,
69,
97,
73,
75,
55,
55,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75,
75
]
} | static inline void FUNC_0(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, long dstW, long dstY)
{
#ifdef HAVE_MMX
long dummy=0;
if(c->flags & SWS_ACCURATE_RND){
switch(c->dstFormat){
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t"
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX_ACCURATE
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}else{
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t"
"add %4, %%"REG_c" \n\t"
WRITEBGR24(%%REGc, %5, %%REGa)
:: "r" (&c->redDither),
"m" (dummy), "m" (dummy), "m" (dummy),
"r" (dest), "m" (dstW)
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
);
return;
case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX
"psraw $3, %%mm3 \n\t"
"psraw $3, %%mm4 \n\t"
"psraw $3, %%mm1 \n\t"
"psraw $3, %%mm7 \n\t"
WRITEYUY2(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END
return;
}
}
#endif
#ifdef HAVE_ALTIVEC
if(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||
c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)
altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
else
#endif
yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY);
}
| [
"static inline void FUNC_0(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,\nint16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,\nuint8_t *dest, long dstW, long dstY)\n{",
"#ifdef HAVE_MMX\nlong dummy=0;",
"if(c->flags & SWS_ACCURATE_RND){",
"switch(c->dstFormat){",
"case PIX_FMT_RGB32:\nYSCALEYUV2PACKEDX_ACCURATE\nYSCALEYUV2RGBX\nWRITEBGR32(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_BGR24:\nYSCALEYUV2PACKEDX_ACCURATE\nYSCALEYUV2RGBX\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_c\"\\n\\t\"\n\"add %4, %%\"REG_c\"\t\t\t\\n\\t\"\nWRITEBGR24(%%REGc, %5, %%REGa)\n:: \"r\" (&c->redDither),\n\"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\"r\" (dest), \"m\" (dstW)\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S\n);",
"return;",
"case PIX_FMT_BGR555:\nYSCALEYUV2PACKEDX_ACCURATE\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR15(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_BGR565:\nYSCALEYUV2PACKEDX_ACCURATE\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR16(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_YUYV422:\nYSCALEYUV2PACKEDX_ACCURATE\n\"psraw $3, %%mm3\t\t\\n\\t\"\n\"psraw $3, %%mm4\t\t\\n\\t\"\n\"psraw $3, %%mm1\t\t\\n\\t\"\n\"psraw $3, %%mm7\t\t\\n\\t\"\nWRITEYUY2(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"}",
"}else{",
"switch(c->dstFormat)\n{",
"case PIX_FMT_RGB32:\nYSCALEYUV2PACKEDX\nYSCALEYUV2RGBX\nWRITEBGR32(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_BGR24:\nYSCALEYUV2PACKEDX\nYSCALEYUV2RGBX\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_c\"\\n\\t\"\n\"add %4, %%\"REG_c\"\t\t\t\\n\\t\"\nWRITEBGR24(%%REGc, %5, %%REGa)\n:: \"r\" (&c->redDither),\n\"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\"r\" (dest), \"m\" (dstW)\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S\n);",
"return;",
"case PIX_FMT_BGR555:\nYSCALEYUV2PACKEDX\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR15(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_BGR565:\nYSCALEYUV2PACKEDX\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n#endif\nWRITEBGR16(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"case PIX_FMT_YUYV422:\nYSCALEYUV2PACKEDX\n\"psraw $3, %%mm3\t\t\\n\\t\"\n\"psraw $3, %%mm4\t\t\\n\\t\"\n\"psraw $3, %%mm1\t\t\\n\\t\"\n\"psraw $3, %%mm7\t\t\\n\\t\"\nWRITEYUY2(%4, %5, %%REGa)\nYSCALEYUV2PACKEDX_END\nreturn;",
"}",
"}",
"#endif\n#ifdef HAVE_ALTIVEC\nif(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||\nc->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||\nc->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)\naltivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,\nchrFilter, chrSrc, chrFilterSize,\ndest, dstW, dstY);",
"else\n#endif\nyuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,\nchrFilter, chrSrc, chrFilterSize,\ndest, dstW, dstY);",
"}"
]
| [
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
1,
0
]
| [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17,
19,
21,
23,
27,
29
],
[
31,
33,
35,
37,
39,
41,
47,
49,
51,
53,
55
],
[
57
],
[
59,
61,
63,
67,
69,
71,
73,
75,
79,
81,
83
],
[
85,
87,
89,
93,
95,
97,
99,
101,
105,
107,
109
],
[
111,
113,
119,
121,
123,
125,
127,
129,
131
],
[
133
],
[
135
],
[
137,
139
],
[
141,
143,
145,
147,
149,
151
],
[
153,
155,
157,
159,
161,
163,
167,
169,
171,
173,
175
],
[
177
],
[
179,
181,
183,
187,
189,
191,
193,
195,
199,
201,
203
],
[
205,
207,
209,
213,
215,
217,
219,
221,
225,
227,
229
],
[
231,
233,
239,
241,
243,
245,
247,
249,
251
],
[
253
],
[
255
],
[
257,
259,
265,
267,
269,
271,
273,
275
],
[
277,
279,
281,
283,
285
],
[
287
]
]
|
15,278 | static void virtio_net_save(QEMUFile *f, void *opaque)
{
VirtIONet *n = opaque;
virtio_save(&n->vdev, f);
qemu_put_buffer(f, n->mac, ETH_ALEN);
qemu_put_be32(f, n->tx_timer_active);
qemu_put_be32(f, n->mergeable_rx_bufs);
qemu_put_be16(f, n->status);
qemu_put_byte(f, n->promisc);
qemu_put_byte(f, n->allmulti);
qemu_put_be32(f, n->mac_table.in_use);
qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
qemu_put_be32(f, 0); /* vnet-hdr placeholder */
qemu_put_byte(f, n->mac_table.multi_overflow);
qemu_put_byte(f, n->mac_table.uni_overflow);
qemu_put_byte(f, n->alluni);
qemu_put_byte(f, n->nomulti);
qemu_put_byte(f, n->nouni);
qemu_put_byte(f, n->nobcast);
}
| true | qemu | 3a330134b3effa3494051763b38f12a24715d53a | static void virtio_net_save(QEMUFile *f, void *opaque)
{
VirtIONet *n = opaque;
virtio_save(&n->vdev, f);
qemu_put_buffer(f, n->mac, ETH_ALEN);
qemu_put_be32(f, n->tx_timer_active);
qemu_put_be32(f, n->mergeable_rx_bufs);
qemu_put_be16(f, n->status);
qemu_put_byte(f, n->promisc);
qemu_put_byte(f, n->allmulti);
qemu_put_be32(f, n->mac_table.in_use);
qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
qemu_put_be32(f, 0);
qemu_put_byte(f, n->mac_table.multi_overflow);
qemu_put_byte(f, n->mac_table.uni_overflow);
qemu_put_byte(f, n->alluni);
qemu_put_byte(f, n->nomulti);
qemu_put_byte(f, n->nouni);
qemu_put_byte(f, n->nobcast);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, void *VAR_1)
{
VirtIONet *n = VAR_1;
virtio_save(&n->vdev, VAR_0);
qemu_put_buffer(VAR_0, n->mac, ETH_ALEN);
qemu_put_be32(VAR_0, n->tx_timer_active);
qemu_put_be32(VAR_0, n->mergeable_rx_bufs);
qemu_put_be16(VAR_0, n->status);
qemu_put_byte(VAR_0, n->promisc);
qemu_put_byte(VAR_0, n->allmulti);
qemu_put_be32(VAR_0, n->mac_table.in_use);
qemu_put_buffer(VAR_0, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
qemu_put_buffer(VAR_0, (uint8_t *)n->vlans, MAX_VLAN >> 3);
qemu_put_be32(VAR_0, 0);
qemu_put_byte(VAR_0, n->mac_table.multi_overflow);
qemu_put_byte(VAR_0, n->mac_table.uni_overflow);
qemu_put_byte(VAR_0, n->alluni);
qemu_put_byte(VAR_0, n->nomulti);
qemu_put_byte(VAR_0, n->nouni);
qemu_put_byte(VAR_0, n->nobcast);
}
| [
"static void FUNC_0(QEMUFile *VAR_0, void *VAR_1)\n{",
"VirtIONet *n = VAR_1;",
"virtio_save(&n->vdev, VAR_0);",
"qemu_put_buffer(VAR_0, n->mac, ETH_ALEN);",
"qemu_put_be32(VAR_0, n->tx_timer_active);",
"qemu_put_be32(VAR_0, n->mergeable_rx_bufs);",
"qemu_put_be16(VAR_0, n->status);",
"qemu_put_byte(VAR_0, n->promisc);",
"qemu_put_byte(VAR_0, n->allmulti);",
"qemu_put_be32(VAR_0, n->mac_table.in_use);",
"qemu_put_buffer(VAR_0, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);",
"qemu_put_buffer(VAR_0, (uint8_t *)n->vlans, MAX_VLAN >> 3);",
"qemu_put_be32(VAR_0, 0);",
"qemu_put_byte(VAR_0, n->mac_table.multi_overflow);",
"qemu_put_byte(VAR_0, n->mac_table.uni_overflow);",
"qemu_put_byte(VAR_0, n->alluni);",
"qemu_put_byte(VAR_0, n->nomulti);",
"qemu_put_byte(VAR_0, n->nouni);",
"qemu_put_byte(VAR_0, n->nobcast);",
"}"
]
| [
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
]
|
15,280 | static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
if (buf_size < 256*3)
return AVERROR_INVALIDDATA;
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
return 256*3;
}
| true | FFmpeg | 29112db8c0f65886e69cbbd6f4e5c44d2d14d238 | static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
if (buf_size < 256*3)
return AVERROR_INVALIDDATA;
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
return 256*3;
}
| {
"code": [
"static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)",
" uint32_t * palette = (uint32_t *)frame->data[1];",
" if (buf_size < 256*3)",
" palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;",
" frame->palette_has_changed = 1;"
],
"line_no": [
1,
5,
11,
19,
23
]
} | static int FUNC_0(AVFrame * VAR_0, const uint8_t * VAR_1, int VAR_2)
{
uint32_t * palette = (uint32_t *)VAR_0->data[1];
int VAR_3;
if (VAR_2 < 256*3)
return AVERROR_INVALIDDATA;
for(VAR_3 = 0; VAR_3 < 256; VAR_3++){
palette[VAR_3] = AV_RB24(&VAR_1[VAR_3 * 3]) * 4;
}
VAR_0->palette_has_changed = 1;
return 256*3;
}
| [
"static int FUNC_0(AVFrame * VAR_0, const uint8_t * VAR_1, int VAR_2)\n{",
"uint32_t * palette = (uint32_t *)VAR_0->data[1];",
"int VAR_3;",
"if (VAR_2 < 256*3)\nreturn AVERROR_INVALIDDATA;",
"for(VAR_3 = 0; VAR_3 < 256; VAR_3++){",
"palette[VAR_3] = AV_RB24(&VAR_1[VAR_3 * 3]) * 4;",
"}",
"VAR_0->palette_has_changed = 1;",
"return 256*3;",
"}"
]
| [
1,
1,
0,
1,
0,
1,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
15,281 | static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)
{
int i[2] = { 0 };
int index = 0;
while (i[0] < len || i[1] < len) {
while (i[0] < len && !(in[i[0]] && (in[i[0]]->reference & sel)))
i[0]++;
while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3))))
i[1]++;
if (i[0] < len) {
in[i[0]]->pic_id = is_long ? i[0] : in[i[0]]->frame_num;
split_field_copy(&def[index++], in[i[0]++], sel, 1);
}
if (i[1] < len) {
in[i[1]]->pic_id = is_long ? i[1] : in[i[1]]->frame_num;
split_field_copy(&def[index++], in[i[1]++], sel ^ 3, 0);
}
}
return index;
}
| true | FFmpeg | 4d388c0cd05dd4de545e8ea333ab4de7d67ad12d | static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)
{
int i[2] = { 0 };
int index = 0;
while (i[0] < len || i[1] < len) {
while (i[0] < len && !(in[i[0]] && (in[i[0]]->reference & sel)))
i[0]++;
while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3))))
i[1]++;
if (i[0] < len) {
in[i[0]]->pic_id = is_long ? i[0] : in[i[0]]->frame_num;
split_field_copy(&def[index++], in[i[0]++], sel, 1);
}
if (i[1] < len) {
in[i[1]]->pic_id = is_long ? i[1] : in[i[1]]->frame_num;
split_field_copy(&def[index++], in[i[1]++], sel ^ 3, 0);
}
}
return index;
}
| {
"code": [
"static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)",
" while (i[0] < len || i[1] < len) {",
" if (i[0] < len) {",
" if (i[1] < len) {"
],
"line_no": [
1,
11,
21,
29
]
} | static int FUNC_0(Picture *VAR_0, Picture **VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
int VAR_5[2] = { 0 };
int VAR_6 = 0;
while (VAR_5[0] < VAR_2 || VAR_5[1] < VAR_2) {
while (VAR_5[0] < VAR_2 && !(VAR_1[VAR_5[0]] && (VAR_1[VAR_5[0]]->reference & VAR_4)))
VAR_5[0]++;
while (VAR_5[1] < VAR_2 && !(VAR_1[VAR_5[1]] && (VAR_1[VAR_5[1]]->reference & (VAR_4 ^ 3))))
VAR_5[1]++;
if (VAR_5[0] < VAR_2) {
VAR_1[VAR_5[0]]->pic_id = VAR_3 ? VAR_5[0] : VAR_1[VAR_5[0]]->frame_num;
split_field_copy(&VAR_0[VAR_6++], VAR_1[VAR_5[0]++], VAR_4, 1);
}
if (VAR_5[1] < VAR_2) {
VAR_1[VAR_5[1]]->pic_id = VAR_3 ? VAR_5[1] : VAR_1[VAR_5[1]]->frame_num;
split_field_copy(&VAR_0[VAR_6++], VAR_1[VAR_5[1]++], VAR_4 ^ 3, 0);
}
}
return VAR_6;
}
| [
"static int FUNC_0(Picture *VAR_0, Picture **VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5[2] = { 0 };",
"int VAR_6 = 0;",
"while (VAR_5[0] < VAR_2 || VAR_5[1] < VAR_2) {",
"while (VAR_5[0] < VAR_2 && !(VAR_1[VAR_5[0]] && (VAR_1[VAR_5[0]]->reference & VAR_4)))\nVAR_5[0]++;",
"while (VAR_5[1] < VAR_2 && !(VAR_1[VAR_5[1]] && (VAR_1[VAR_5[1]]->reference & (VAR_4 ^ 3))))\nVAR_5[1]++;",
"if (VAR_5[0] < VAR_2) {",
"VAR_1[VAR_5[0]]->pic_id = VAR_3 ? VAR_5[0] : VAR_1[VAR_5[0]]->frame_num;",
"split_field_copy(&VAR_0[VAR_6++], VAR_1[VAR_5[0]++], VAR_4, 1);",
"}",
"if (VAR_5[1] < VAR_2) {",
"VAR_1[VAR_5[1]]->pic_id = VAR_3 ? VAR_5[1] : VAR_1[VAR_5[1]]->frame_num;",
"split_field_copy(&VAR_0[VAR_6++], VAR_1[VAR_5[1]++], VAR_4 ^ 3, 0);",
"}",
"}",
"return VAR_6;",
"}"
]
| [
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
]
|
15,282 | 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_ms(rt_clock, vnc_refresh, vd);
vnc_dpy_resize(dcl, vd->ds);
vnc_refresh(vd);
}
}
| true | qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 | 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_ms(rt_clock, vnc_refresh, vd);
vnc_dpy_resize(dcl, vd->ds);
vnc_refresh(vd);
}
}
| {
"code": [
" vnc_dpy_resize(dcl, vd->ds);"
],
"line_no": [
11
]
} | 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_ms(rt_clock, vnc_refresh, VAR_0);
vnc_dpy_resize(dcl, 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_ms(rt_clock, vnc_refresh, VAR_0);",
"vnc_dpy_resize(dcl, VAR_0->ds);",
"vnc_refresh(VAR_0);",
"}",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
15,283 | static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int n, i, ch, st, pkt_size, ret;
const int16_t *samples;
int16_t **samples_p;
uint8_t *dst;
ADPCMEncodeContext *c = avctx->priv_data;
uint8_t *buf;
samples = (const int16_t *)frame->data[0];
samples_p = (int16_t **)frame->extended_data;
st = avctx->channels == 2;
if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 7) / 8;
else
pkt_size = avctx->block_align;
if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size)))
return ret;
dst = avpkt->data;
switch(avctx->codec->id) {
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int blocks, j;
blocks = (frame->nb_samples - 1) / 8;
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
status->prev_sample = samples_p[ch][0];
/* status->step_index = 0;
XXX: not sure how to init the state machine */
bytestream_put_le16(&dst, status->prev_sample);
*dst++ = status->step_index;
*dst++ = 0; /* unknown */
}
/* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, avctx->channels * blocks * 8, error);
for (ch = 0; ch < avctx->channels; ch++) {
adpcm_compress_trellis(avctx, &samples_p[ch][1],
buf + ch * blocks * 8, &c->status[ch],
blocks * 8, 1);
}
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
uint8_t *buf1 = buf + ch * blocks * 8 + i * 8;
for (j = 0; j < 8; j += 2)
*dst++ = buf1[j] | (buf1[j + 1] << 4);
}
}
av_free(buf);
} else {
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
const int16_t *smp = &samples_p[ch][1 + i * 8];
for (j = 0; j < 8; j += 2) {
uint8_t v = adpcm_ima_compress_sample(status, smp[j ]);
v |= adpcm_ima_compress_sample(status, smp[j + 1]) << 4;
*dst++ = v;
}
}
}
}
break;
}
case AV_CODEC_ID_ADPCM_IMA_QT:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);
put_bits(&pb, 7, status->step_index);
if (avctx->trellis > 0) {
uint8_t buf[64];
adpcm_compress_trellis(avctx, &samples_p[ch][1], buf, status,
64, 1);
for (i = 0; i < 64; i++)
put_bits(&pb, 4, buf[i ^ 1]);
} else {
for (i = 0; i < 64; i += 2) {
int t1, t2;
t1 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i ]);
t2 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i + 1]);
put_bits(&pb, 4, t2);
put_bits(&pb, 4, t1);
}
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
n = frame->nb_samples - 1;
// store AdpcmCodeSize
put_bits(&pb, 2, 2); // set 4-bit flash adpcm format
// init the encoder state
for (i = 0; i < avctx->channels; i++) {
// clip step so it fits 6 bits
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63);
put_sbits(&pb, 16, samples[i]);
put_bits(&pb, 6, c->status[i].step_index);
c->status[i].prev_sample = samples[i];
}
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
&c->status[0], n, avctx->channels);
if (avctx->channels == 2)
adpcm_compress_trellis(avctx, samples + avctx->channels + 1,
buf + n, &c->status[1], n,
avctx->channels);
for (i = 0; i < n; i++) {
put_bits(&pb, 4, buf[i]);
if (avctx->channels == 2)
put_bits(&pb, 4, buf[n + i]);
}
av_free(buf);
} else {
for (i = 1; i < frame->nb_samples; i++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
samples[avctx->channels * i]));
if (avctx->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
samples[2 * i + 1]));
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_MS:
for (i = 0; i < avctx->channels; i++) {
int predictor = 0;
*dst++ = predictor;
c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
}
for (i = 0; i < avctx->channels; i++) {
if (c->status[i].idelta < 16)
c->status[i].idelta = 16;
bytestream_put_le16(&dst, c->status[i].idelta);
}
for (i = 0; i < avctx->channels; i++)
c->status[i].sample2= *samples++;
for (i = 0; i < avctx->channels; i++) {
c->status[i].sample1 = *samples++;
bytestream_put_le16(&dst, c->status[i].sample1);
}
for (i = 0; i < avctx->channels; i++)
bytestream_put_le16(&dst, c->status[i].sample2);
if (avctx->trellis > 0) {
n = avctx->block_align - 7 * avctx->channels;
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = (buf[i] << 4) | buf[i + 1];
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = (buf[i] << 4) | buf[n + i];
}
av_free(buf);
} else {
for (i = 7 * avctx->channels; i < avctx->block_align; i++) {
int nibble;
nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;
nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);
*dst++ = nibble;
}
}
break;
case AV_CODEC_ID_ADPCM_YAMAHA:
n = frame->nb_samples / 2;
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
n *= 2;
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = buf[i] | (buf[i + 1] << 4);
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = buf[i] | (buf[n + i] << 4);
}
av_free(buf);
} else
for (n *= avctx->channels; n > 0; n--) {
int nibble;
nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
*dst++ = nibble;
}
break;
default:
return AVERROR(EINVAL);
}
avpkt->size = pkt_size;
*got_packet_ptr = 1;
return 0;
error:
return AVERROR(ENOMEM);
}
| false | FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int n, i, ch, st, pkt_size, ret;
const int16_t *samples;
int16_t **samples_p;
uint8_t *dst;
ADPCMEncodeContext *c = avctx->priv_data;
uint8_t *buf;
samples = (const int16_t *)frame->data[0];
samples_p = (int16_t **)frame->extended_data;
st = avctx->channels == 2;
if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 7) / 8;
else
pkt_size = avctx->block_align;
if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size)))
return ret;
dst = avpkt->data;
switch(avctx->codec->id) {
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int blocks, j;
blocks = (frame->nb_samples - 1) / 8;
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
status->prev_sample = samples_p[ch][0];
bytestream_put_le16(&dst, status->prev_sample);
*dst++ = status->step_index;
*dst++ = 0;
}
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, avctx->channels * blocks * 8, error);
for (ch = 0; ch < avctx->channels; ch++) {
adpcm_compress_trellis(avctx, &samples_p[ch][1],
buf + ch * blocks * 8, &c->status[ch],
blocks * 8, 1);
}
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
uint8_t *buf1 = buf + ch * blocks * 8 + i * 8;
for (j = 0; j < 8; j += 2)
*dst++ = buf1[j] | (buf1[j + 1] << 4);
}
}
av_free(buf);
} else {
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
const int16_t *smp = &samples_p[ch][1 + i * 8];
for (j = 0; j < 8; j += 2) {
uint8_t v = adpcm_ima_compress_sample(status, smp[j ]);
v |= adpcm_ima_compress_sample(status, smp[j + 1]) << 4;
*dst++ = v;
}
}
}
}
break;
}
case AV_CODEC_ID_ADPCM_IMA_QT:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);
put_bits(&pb, 7, status->step_index);
if (avctx->trellis > 0) {
uint8_t buf[64];
adpcm_compress_trellis(avctx, &samples_p[ch][1], buf, status,
64, 1);
for (i = 0; i < 64; i++)
put_bits(&pb, 4, buf[i ^ 1]);
} else {
for (i = 0; i < 64; i += 2) {
int t1, t2;
t1 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i ]);
t2 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i + 1]);
put_bits(&pb, 4, t2);
put_bits(&pb, 4, t1);
}
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
n = frame->nb_samples - 1;
put_bits(&pb, 2, 2);
for (i = 0; i < avctx->channels; i++) {
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63);
put_sbits(&pb, 16, samples[i]);
put_bits(&pb, 6, c->status[i].step_index);
c->status[i].prev_sample = samples[i];
}
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
&c->status[0], n, avctx->channels);
if (avctx->channels == 2)
adpcm_compress_trellis(avctx, samples + avctx->channels + 1,
buf + n, &c->status[1], n,
avctx->channels);
for (i = 0; i < n; i++) {
put_bits(&pb, 4, buf[i]);
if (avctx->channels == 2)
put_bits(&pb, 4, buf[n + i]);
}
av_free(buf);
} else {
for (i = 1; i < frame->nb_samples; i++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
samples[avctx->channels * i]));
if (avctx->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
samples[2 * i + 1]));
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_MS:
for (i = 0; i < avctx->channels; i++) {
int predictor = 0;
*dst++ = predictor;
c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
}
for (i = 0; i < avctx->channels; i++) {
if (c->status[i].idelta < 16)
c->status[i].idelta = 16;
bytestream_put_le16(&dst, c->status[i].idelta);
}
for (i = 0; i < avctx->channels; i++)
c->status[i].sample2= *samples++;
for (i = 0; i < avctx->channels; i++) {
c->status[i].sample1 = *samples++;
bytestream_put_le16(&dst, c->status[i].sample1);
}
for (i = 0; i < avctx->channels; i++)
bytestream_put_le16(&dst, c->status[i].sample2);
if (avctx->trellis > 0) {
n = avctx->block_align - 7 * avctx->channels;
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = (buf[i] << 4) | buf[i + 1];
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = (buf[i] << 4) | buf[n + i];
}
av_free(buf);
} else {
for (i = 7 * avctx->channels; i < avctx->block_align; i++) {
int nibble;
nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;
nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);
*dst++ = nibble;
}
}
break;
case AV_CODEC_ID_ADPCM_YAMAHA:
n = frame->nb_samples / 2;
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
n *= 2;
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = buf[i] | (buf[i + 1] << 4);
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = buf[i] | (buf[n + i] << 4);
}
av_free(buf);
} else
for (n *= avctx->channels; n > 0; n--) {
int nibble;
nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
*dst++ = nibble;
}
break;
default:
return AVERROR(EINVAL);
}
avpkt->size = pkt_size;
*got_packet_ptr = 1;
return 0;
error:
return AVERROR(ENOMEM);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
const int16_t *VAR_10;
int16_t **samples_p;
uint8_t *dst;
ADPCMEncodeContext *c = VAR_0->priv_data;
uint8_t *buf;
VAR_10 = (const int16_t *)VAR_2->data[0];
samples_p = (int16_t **)VAR_2->extended_data;
VAR_7 = VAR_0->channels == 2;
if (VAR_0->codec_id == AV_CODEC_ID_ADPCM_SWF)
VAR_8 = (2 + VAR_0->channels * (22 + 4 * (VAR_2->nb_samples - 1)) + 7) / 8;
else
VAR_8 = VAR_0->block_align;
if ((VAR_9 = ff_alloc_packet2(VAR_0, VAR_1, VAR_8)))
return VAR_9;
dst = VAR_1->data;
switch(VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int VAR_11, VAR_12;
VAR_11 = (VAR_2->nb_samples - 1) / 8;
for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
ADPCMChannelStatus *status = &c->status[VAR_6];
status->prev_sample = samples_p[VAR_6][0];
bytestream_put_le16(&dst, status->prev_sample);
*dst++ = status->step_index;
*dst++ = 0;
}
if (VAR_0->trellis > 0) {
FF_ALLOC_OR_GOTO(VAR_0, buf, VAR_0->channels * VAR_11 * 8, error);
for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
adpcm_compress_trellis(VAR_0, &samples_p[VAR_6][1],
buf + VAR_6 * VAR_11 * 8, &c->status[VAR_6],
VAR_11 * 8, 1);
}
for (VAR_5 = 0; VAR_5 < VAR_11; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
uint8_t *buf1 = buf + VAR_6 * VAR_11 * 8 + VAR_5 * 8;
for (VAR_12 = 0; VAR_12 < 8; VAR_12 += 2)
*dst++ = buf1[VAR_12] | (buf1[VAR_12 + 1] << 4);
}
}
av_free(buf);
} else {
for (VAR_5 = 0; VAR_5 < VAR_11; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
ADPCMChannelStatus *status = &c->status[VAR_6];
const int16_t *smp = &samples_p[VAR_6][1 + VAR_5 * 8];
for (VAR_12 = 0; VAR_12 < 8; VAR_12 += 2) {
uint8_t v = adpcm_ima_compress_sample(status, smp[VAR_12 ]);
v |= adpcm_ima_compress_sample(status, smp[VAR_12 + 1]) << 4;
*dst++ = v;
}
}
}
}
break;
}
case AV_CODEC_ID_ADPCM_IMA_QT:
{
PutBitContext pb;
init_put_bits(&pb, dst, VAR_8 * 8);
for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
ADPCMChannelStatus *status = &c->status[VAR_6];
put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);
put_bits(&pb, 7, status->step_index);
if (VAR_0->trellis > 0) {
uint8_t buf[64];
adpcm_compress_trellis(VAR_0, &samples_p[VAR_6][1], buf, status,
64, 1);
for (VAR_5 = 0; VAR_5 < 64; VAR_5++)
put_bits(&pb, 4, buf[VAR_5 ^ 1]);
} else {
for (VAR_5 = 0; VAR_5 < 64; VAR_5 += 2) {
int t1, t2;
t1 = adpcm_ima_qt_compress_sample(status, samples_p[VAR_6][VAR_5 ]);
t2 = adpcm_ima_qt_compress_sample(status, samples_p[VAR_6][VAR_5 + 1]);
put_bits(&pb, 4, t2);
put_bits(&pb, 4, t1);
}
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
PutBitContext pb;
init_put_bits(&pb, dst, VAR_8 * 8);
VAR_4 = VAR_2->nb_samples - 1;
put_bits(&pb, 2, 2);
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
c->status[VAR_5].step_index = av_clip(c->status[VAR_5].step_index, 0, 63);
put_sbits(&pb, 16, VAR_10[VAR_5]);
put_bits(&pb, 6, c->status[VAR_5].step_index);
c->status[VAR_5].prev_sample = VAR_10[VAR_5];
}
if (VAR_0->trellis > 0) {
FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4, error);
adpcm_compress_trellis(VAR_0, VAR_10 + VAR_0->channels, buf,
&c->status[0], VAR_4, VAR_0->channels);
if (VAR_0->channels == 2)
adpcm_compress_trellis(VAR_0, VAR_10 + VAR_0->channels + 1,
buf + VAR_4, &c->status[1], VAR_4,
VAR_0->channels);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
put_bits(&pb, 4, buf[VAR_5]);
if (VAR_0->channels == 2)
put_bits(&pb, 4, buf[VAR_4 + VAR_5]);
}
av_free(buf);
} else {
for (VAR_5 = 1; VAR_5 < VAR_2->nb_samples; VAR_5++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
VAR_10[VAR_0->channels * VAR_5]));
if (VAR_0->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
VAR_10[2 * VAR_5 + 1]));
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_MS:
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
int predictor = 0;
*dst++ = predictor;
c->status[VAR_5].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
c->status[VAR_5].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
}
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
if (c->status[VAR_5].idelta < 16)
c->status[VAR_5].idelta = 16;
bytestream_put_le16(&dst, c->status[VAR_5].idelta);
}
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++)
c->status[VAR_5].sample2= *VAR_10++;
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
c->status[VAR_5].sample1 = *VAR_10++;
bytestream_put_le16(&dst, c->status[VAR_5].sample1);
}
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++)
bytestream_put_le16(&dst, c->status[VAR_5].sample2);
if (VAR_0->trellis > 0) {
VAR_4 = VAR_0->block_align - 7 * VAR_0->channels;
FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4, error);
if (VAR_0->channels == 1) {
adpcm_compress_trellis(VAR_0, VAR_10, buf, &c->status[0], VAR_4,
VAR_0->channels);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5 += 2)
*dst++ = (buf[VAR_5] << 4) | buf[VAR_5 + 1];
} else {
adpcm_compress_trellis(VAR_0, VAR_10, buf,
&c->status[0], VAR_4, VAR_0->channels);
adpcm_compress_trellis(VAR_0, VAR_10 + 1, buf + VAR_4,
&c->status[1], VAR_4, VAR_0->channels);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)
*dst++ = (buf[VAR_5] << 4) | buf[VAR_4 + VAR_5];
}
av_free(buf);
} else {
for (VAR_5 = 7 * VAR_0->channels; VAR_5 < VAR_0->block_align; VAR_5++) {
int VAR_13;
VAR_13 = adpcm_ms_compress_sample(&c->status[ 0], *VAR_10++) << 4;
VAR_13 |= adpcm_ms_compress_sample(&c->status[VAR_7], *VAR_10++);
*dst++ = VAR_13;
}
}
break;
case AV_CODEC_ID_ADPCM_YAMAHA:
VAR_4 = VAR_2->nb_samples / 2;
if (VAR_0->trellis > 0) {
FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4 * 2, error);
VAR_4 *= 2;
if (VAR_0->channels == 1) {
adpcm_compress_trellis(VAR_0, VAR_10, buf, &c->status[0], VAR_4,
VAR_0->channels);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5 += 2)
*dst++ = buf[VAR_5] | (buf[VAR_5 + 1] << 4);
} else {
adpcm_compress_trellis(VAR_0, VAR_10, buf,
&c->status[0], VAR_4, VAR_0->channels);
adpcm_compress_trellis(VAR_0, VAR_10 + 1, buf + VAR_4,
&c->status[1], VAR_4, VAR_0->channels);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)
*dst++ = buf[VAR_5] | (buf[VAR_4 + VAR_5] << 4);
}
av_free(buf);
} else
for (VAR_4 *= VAR_0->channels; VAR_4 > 0; VAR_4--) {
int VAR_13;
VAR_13 = adpcm_yamaha_compress_sample(&c->status[ 0], *VAR_10++);
VAR_13 |= adpcm_yamaha_compress_sample(&c->status[VAR_7], *VAR_10++) << 4;
*dst++ = VAR_13;
}
break;
default:
return AVERROR(EINVAL);
}
VAR_1->size = VAR_8;
*VAR_3 = 1;
return 0;
error:
return AVERROR(ENOMEM);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"const int16_t *VAR_10;",
"int16_t **samples_p;",
"uint8_t *dst;",
"ADPCMEncodeContext *c = VAR_0->priv_data;",
"uint8_t *buf;",
"VAR_10 = (const int16_t *)VAR_2->data[0];",
"samples_p = (int16_t **)VAR_2->extended_data;",
"VAR_7 = VAR_0->channels == 2;",
"if (VAR_0->codec_id == AV_CODEC_ID_ADPCM_SWF)\nVAR_8 = (2 + VAR_0->channels * (22 + 4 * (VAR_2->nb_samples - 1)) + 7) / 8;",
"else\nVAR_8 = VAR_0->block_align;",
"if ((VAR_9 = ff_alloc_packet2(VAR_0, VAR_1, VAR_8)))\nreturn VAR_9;",
"dst = VAR_1->data;",
"switch(VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_IMA_WAV:\n{",
"int VAR_11, VAR_12;",
"VAR_11 = (VAR_2->nb_samples - 1) / 8;",
"for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"ADPCMChannelStatus *status = &c->status[VAR_6];",
"status->prev_sample = samples_p[VAR_6][0];",
"bytestream_put_le16(&dst, status->prev_sample);",
"*dst++ = status->step_index;",
"*dst++ = 0;",
"}",
"if (VAR_0->trellis > 0) {",
"FF_ALLOC_OR_GOTO(VAR_0, buf, VAR_0->channels * VAR_11 * 8, error);",
"for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"adpcm_compress_trellis(VAR_0, &samples_p[VAR_6][1],\nbuf + VAR_6 * VAR_11 * 8, &c->status[VAR_6],\nVAR_11 * 8, 1);",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_11; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"uint8_t *buf1 = buf + VAR_6 * VAR_11 * 8 + VAR_5 * 8;",
"for (VAR_12 = 0; VAR_12 < 8; VAR_12 += 2)",
"*dst++ = buf1[VAR_12] | (buf1[VAR_12 + 1] << 4);",
"}",
"}",
"av_free(buf);",
"} else {",
"for (VAR_5 = 0; VAR_5 < VAR_11; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"ADPCMChannelStatus *status = &c->status[VAR_6];",
"const int16_t *smp = &samples_p[VAR_6][1 + VAR_5 * 8];",
"for (VAR_12 = 0; VAR_12 < 8; VAR_12 += 2) {",
"uint8_t v = adpcm_ima_compress_sample(status, smp[VAR_12 ]);",
"v |= adpcm_ima_compress_sample(status, smp[VAR_12 + 1]) << 4;",
"*dst++ = v;",
"}",
"}",
"}",
"}",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_IMA_QT:\n{",
"PutBitContext pb;",
"init_put_bits(&pb, dst, VAR_8 * 8);",
"for (VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"ADPCMChannelStatus *status = &c->status[VAR_6];",
"put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);",
"put_bits(&pb, 7, status->step_index);",
"if (VAR_0->trellis > 0) {",
"uint8_t buf[64];",
"adpcm_compress_trellis(VAR_0, &samples_p[VAR_6][1], buf, status,\n64, 1);",
"for (VAR_5 = 0; VAR_5 < 64; VAR_5++)",
"put_bits(&pb, 4, buf[VAR_5 ^ 1]);",
"} else {",
"for (VAR_5 = 0; VAR_5 < 64; VAR_5 += 2) {",
"int t1, t2;",
"t1 = adpcm_ima_qt_compress_sample(status, samples_p[VAR_6][VAR_5 ]);",
"t2 = adpcm_ima_qt_compress_sample(status, samples_p[VAR_6][VAR_5 + 1]);",
"put_bits(&pb, 4, t2);",
"put_bits(&pb, 4, t1);",
"}",
"}",
"}",
"flush_put_bits(&pb);",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_SWF:\n{",
"PutBitContext pb;",
"init_put_bits(&pb, dst, VAR_8 * 8);",
"VAR_4 = VAR_2->nb_samples - 1;",
"put_bits(&pb, 2, 2);",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"c->status[VAR_5].step_index = av_clip(c->status[VAR_5].step_index, 0, 63);",
"put_sbits(&pb, 16, VAR_10[VAR_5]);",
"put_bits(&pb, 6, c->status[VAR_5].step_index);",
"c->status[VAR_5].prev_sample = VAR_10[VAR_5];",
"}",
"if (VAR_0->trellis > 0) {",
"FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4, error);",
"adpcm_compress_trellis(VAR_0, VAR_10 + VAR_0->channels, buf,\n&c->status[0], VAR_4, VAR_0->channels);",
"if (VAR_0->channels == 2)\nadpcm_compress_trellis(VAR_0, VAR_10 + VAR_0->channels + 1,\nbuf + VAR_4, &c->status[1], VAR_4,\nVAR_0->channels);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"put_bits(&pb, 4, buf[VAR_5]);",
"if (VAR_0->channels == 2)\nput_bits(&pb, 4, buf[VAR_4 + VAR_5]);",
"}",
"av_free(buf);",
"} else {",
"for (VAR_5 = 1; VAR_5 < VAR_2->nb_samples; VAR_5++) {",
"put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],\nVAR_10[VAR_0->channels * VAR_5]));",
"if (VAR_0->channels == 2)\nput_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],\nVAR_10[2 * VAR_5 + 1]));",
"}",
"}",
"flush_put_bits(&pb);",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_MS:\nfor (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"int predictor = 0;",
"*dst++ = predictor;",
"c->status[VAR_5].coeff1 = ff_adpcm_AdaptCoeff1[predictor];",
"c->status[VAR_5].coeff2 = ff_adpcm_AdaptCoeff2[predictor];",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"if (c->status[VAR_5].idelta < 16)\nc->status[VAR_5].idelta = 16;",
"bytestream_put_le16(&dst, c->status[VAR_5].idelta);",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++)",
"c->status[VAR_5].sample2= *VAR_10++;",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"c->status[VAR_5].sample1 = *VAR_10++;",
"bytestream_put_le16(&dst, c->status[VAR_5].sample1);",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++)",
"bytestream_put_le16(&dst, c->status[VAR_5].sample2);",
"if (VAR_0->trellis > 0) {",
"VAR_4 = VAR_0->block_align - 7 * VAR_0->channels;",
"FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4, error);",
"if (VAR_0->channels == 1) {",
"adpcm_compress_trellis(VAR_0, VAR_10, buf, &c->status[0], VAR_4,\nVAR_0->channels);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5 += 2)",
"*dst++ = (buf[VAR_5] << 4) | buf[VAR_5 + 1];",
"} else {",
"adpcm_compress_trellis(VAR_0, VAR_10, buf,\n&c->status[0], VAR_4, VAR_0->channels);",
"adpcm_compress_trellis(VAR_0, VAR_10 + 1, buf + VAR_4,\n&c->status[1], VAR_4, VAR_0->channels);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)",
"*dst++ = (buf[VAR_5] << 4) | buf[VAR_4 + VAR_5];",
"}",
"av_free(buf);",
"} else {",
"for (VAR_5 = 7 * VAR_0->channels; VAR_5 < VAR_0->block_align; VAR_5++) {",
"int VAR_13;",
"VAR_13 = adpcm_ms_compress_sample(&c->status[ 0], *VAR_10++) << 4;",
"VAR_13 |= adpcm_ms_compress_sample(&c->status[VAR_7], *VAR_10++);",
"*dst++ = VAR_13;",
"}",
"}",
"break;",
"case AV_CODEC_ID_ADPCM_YAMAHA:\nVAR_4 = VAR_2->nb_samples / 2;",
"if (VAR_0->trellis > 0) {",
"FF_ALLOC_OR_GOTO(VAR_0, buf, 2 * VAR_4 * 2, error);",
"VAR_4 *= 2;",
"if (VAR_0->channels == 1) {",
"adpcm_compress_trellis(VAR_0, VAR_10, buf, &c->status[0], VAR_4,\nVAR_0->channels);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5 += 2)",
"*dst++ = buf[VAR_5] | (buf[VAR_5 + 1] << 4);",
"} else {",
"adpcm_compress_trellis(VAR_0, VAR_10, buf,\n&c->status[0], VAR_4, VAR_0->channels);",
"adpcm_compress_trellis(VAR_0, VAR_10 + 1, buf + VAR_4,\n&c->status[1], VAR_4, VAR_0->channels);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)",
"*dst++ = buf[VAR_5] | (buf[VAR_4 + VAR_5] << 4);",
"}",
"av_free(buf);",
"} else",
"for (VAR_4 *= VAR_0->channels; VAR_4 > 0; VAR_4--) {",
"int VAR_13;",
"VAR_13 = adpcm_yamaha_compress_sample(&c->status[ 0], *VAR_10++);",
"VAR_13 |= adpcm_yamaha_compress_sample(&c->status[VAR_7], *VAR_10++) << 4;",
"*dst++ = VAR_13;",
"}",
"break;",
"default:\nreturn AVERROR(EINVAL);",
"}",
"VAR_1->size = VAR_8;",
"*VAR_3 = 1;",
"return 0;",
"error:\nreturn AVERROR(ENOMEM);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
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
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
209
],
[
215
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
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
],
[
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
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405,
407
],
[
409,
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
445
],
[
447
],
[
449
],
[
451,
453
],
[
455
]
]
|
15,284 | static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
TranslationBlock *tb,
int search_pc)
{
struct DisasContext ctx, *dc = &ctx;
uint16_t *gen_opc_end;
uint32_t pc_start;
int j, k;
uint32_t next_page_start;
int num_insns;
int max_insns;
qemu_log_try_set_file(stderr);
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->is_jmp = DISAS_NEXT;
dc->ppc = pc_start;
dc->pc = pc_start;
dc->flags = cpu->env.cpucfgr;
dc->mem_idx = cpu_mmu_index(&cpu->env);
dc->synced_flags = dc->tb_flags = tb->flags;
dc->delayed_branch = !!(dc->tb_flags & D_FLAG);
dc->singlestep_enabled = cpu->env.singlestep_enabled;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("-----------------------------------------\n");
log_cpu_state(&cpu->env, 0);
}
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
k = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_icount_start();
do {
check_breakpoint(cpu, dc);
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (k < j) {
k++;
while (k < j) {
tcg_ctx.gen_opc_instr_start[k++] = 0;
}
}
tcg_ctx.gen_opc_pc[k] = dc->pc;
tcg_ctx.gen_opc_instr_start[k] = 1;
tcg_ctx.gen_opc_icount[k] = num_insns;
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
dc->ppc = dc->pc - 4;
dc->npc = dc->pc + 4;
tcg_gen_movi_tl(cpu_ppc, dc->ppc);
tcg_gen_movi_tl(cpu_npc, dc->npc);
disas_openrisc_insn(dc, cpu);
dc->pc = dc->npc;
num_insns++;
/* delay slot */
if (dc->delayed_branch) {
dc->delayed_branch--;
if (!dc->delayed_branch) {
dc->tb_flags &= ~D_FLAG;
gen_sync_flags(dc);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
dc->is_jmp = DISAS_JUMP;
break;
}
}
} while (!dc->is_jmp
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !cpu->env.singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (dc->is_jmp == DISAS_NEXT) {
dc->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
if (unlikely(cpu->env.singlestep_enabled)) {
if (dc->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
gen_exception(dc, EXCP_DEBUG);
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
/* indicate that the hash table must be used
to find the next TB */
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
/* nothing more to generate */
break;
}
}
gen_icount_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
k++;
while (k <= j) {
tcg_ctx.gen_opc_instr_start[k++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
log_target_disas(&cpu->env, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, tcg_ctx.gen_opc_ptr -
tcg_ctx.gen_opc_buf);
}
#endif
}
| true | qemu | 632314c49ce20ee9c974f07544d9125fbbbfbe1b | static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
TranslationBlock *tb,
int search_pc)
{
struct DisasContext ctx, *dc = &ctx;
uint16_t *gen_opc_end;
uint32_t pc_start;
int j, k;
uint32_t next_page_start;
int num_insns;
int max_insns;
qemu_log_try_set_file(stderr);
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->is_jmp = DISAS_NEXT;
dc->ppc = pc_start;
dc->pc = pc_start;
dc->flags = cpu->env.cpucfgr;
dc->mem_idx = cpu_mmu_index(&cpu->env);
dc->synced_flags = dc->tb_flags = tb->flags;
dc->delayed_branch = !!(dc->tb_flags & D_FLAG);
dc->singlestep_enabled = cpu->env.singlestep_enabled;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("-----------------------------------------\n");
log_cpu_state(&cpu->env, 0);
}
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
k = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_icount_start();
do {
check_breakpoint(cpu, dc);
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (k < j) {
k++;
while (k < j) {
tcg_ctx.gen_opc_instr_start[k++] = 0;
}
}
tcg_ctx.gen_opc_pc[k] = dc->pc;
tcg_ctx.gen_opc_instr_start[k] = 1;
tcg_ctx.gen_opc_icount[k] = num_insns;
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
dc->ppc = dc->pc - 4;
dc->npc = dc->pc + 4;
tcg_gen_movi_tl(cpu_ppc, dc->ppc);
tcg_gen_movi_tl(cpu_npc, dc->npc);
disas_openrisc_insn(dc, cpu);
dc->pc = dc->npc;
num_insns++;
if (dc->delayed_branch) {
dc->delayed_branch--;
if (!dc->delayed_branch) {
dc->tb_flags &= ~D_FLAG;
gen_sync_flags(dc);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
dc->is_jmp = DISAS_JUMP;
break;
}
}
} while (!dc->is_jmp
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !cpu->env.singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (dc->is_jmp == DISAS_NEXT) {
dc->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
if (unlikely(cpu->env.singlestep_enabled)) {
if (dc->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
gen_exception(dc, EXCP_DEBUG);
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_icount_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
k++;
while (k <= j) {
tcg_ctx.gen_opc_instr_start[k++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
log_target_disas(&cpu->env, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, tcg_ctx.gen_opc_ptr -
tcg_ctx.gen_opc_buf);
}
#endif
}
| {
"code": [
" qemu_log_try_set_file(stderr);",
" qemu_log_try_set_file(stderr);",
" qemu_log_try_set_file(stderr);",
" qemu_log_try_set_file(stderr);"
],
"line_no": [
25,
25,
25,
25
]
} | static inline void FUNC_0(OpenRISCCPU *VAR_0,
TranslationBlock *VAR_1,
int VAR_2)
{
struct DisasContext VAR_3, *VAR_4 = &VAR_3;
uint16_t *gen_opc_end;
uint32_t pc_start;
int VAR_5, VAR_6;
uint32_t next_page_start;
int VAR_7;
int VAR_8;
qemu_log_try_set_file(stderr);
pc_start = VAR_1->pc;
VAR_4->VAR_1 = VAR_1;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
VAR_4->is_jmp = DISAS_NEXT;
VAR_4->ppc = pc_start;
VAR_4->pc = pc_start;
VAR_4->flags = VAR_0->env.cpucfgr;
VAR_4->mem_idx = cpu_mmu_index(&VAR_0->env);
VAR_4->synced_flags = VAR_4->tb_flags = VAR_1->flags;
VAR_4->delayed_branch = !!(VAR_4->tb_flags & D_FLAG);
VAR_4->singlestep_enabled = VAR_0->env.singlestep_enabled;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("-----------------------------------------\n");
log_cpu_state(&VAR_0->env, 0);
}
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
VAR_6 = -1;
VAR_7 = 0;
VAR_8 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_8 == 0) {
VAR_8 = CF_COUNT_MASK;
}
gen_icount_start();
do {
check_breakpoint(VAR_0, VAR_4);
if (VAR_2) {
VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (VAR_6 < VAR_5) {
VAR_6++;
while (VAR_6 < VAR_5) {
tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;
}
}
tcg_ctx.gen_opc_pc[VAR_6] = VAR_4->pc;
tcg_ctx.gen_opc_instr_start[VAR_6] = 1;
tcg_ctx.gen_opc_icount[VAR_6] = VAR_7;
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(VAR_4->pc);
}
if (VAR_7 + 1 == VAR_8 && (VAR_1->cflags & CF_LAST_IO)) {
gen_io_start();
}
VAR_4->ppc = VAR_4->pc - 4;
VAR_4->npc = VAR_4->pc + 4;
tcg_gen_movi_tl(cpu_ppc, VAR_4->ppc);
tcg_gen_movi_tl(cpu_npc, VAR_4->npc);
disas_openrisc_insn(VAR_4, VAR_0);
VAR_4->pc = VAR_4->npc;
VAR_7++;
if (VAR_4->delayed_branch) {
VAR_4->delayed_branch--;
if (!VAR_4->delayed_branch) {
VAR_4->tb_flags &= ~D_FLAG;
gen_sync_flags(VAR_4);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
VAR_4->is_jmp = DISAS_JUMP;
break;
}
}
} while (!VAR_4->is_jmp
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !VAR_0->env.singlestep_enabled
&& !singlestep
&& (VAR_4->pc < next_page_start)
&& VAR_7 < VAR_8);
if (VAR_1->cflags & CF_LAST_IO) {
gen_io_end();
}
if (VAR_4->is_jmp == DISAS_NEXT) {
VAR_4->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, VAR_4->pc);
}
if (unlikely(VAR_0->env.singlestep_enabled)) {
if (VAR_4->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, VAR_4->pc);
}
gen_exception(VAR_4, EXCP_DEBUG);
} else {
switch (VAR_4->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(VAR_4, 0, VAR_4->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_icount_end(VAR_1, VAR_7);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (VAR_2) {
VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
VAR_6++;
while (VAR_6 <= VAR_5) {
tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;
}
} else {
VAR_1->size = VAR_4->pc - pc_start;
VAR_1->icount = VAR_7;
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
log_target_disas(&VAR_0->env, pc_start, VAR_4->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%td\n",
VAR_4->pc - pc_start, tcg_ctx.gen_opc_ptr -
tcg_ctx.gen_opc_buf);
}
#endif
}
| [
"static inline void FUNC_0(OpenRISCCPU *VAR_0,\nTranslationBlock *VAR_1,\nint VAR_2)\n{",
"struct DisasContext VAR_3, *VAR_4 = &VAR_3;",
"uint16_t *gen_opc_end;",
"uint32_t pc_start;",
"int VAR_5, VAR_6;",
"uint32_t next_page_start;",
"int VAR_7;",
"int VAR_8;",
"qemu_log_try_set_file(stderr);",
"pc_start = VAR_1->pc;",
"VAR_4->VAR_1 = VAR_1;",
"gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;",
"VAR_4->is_jmp = DISAS_NEXT;",
"VAR_4->ppc = pc_start;",
"VAR_4->pc = pc_start;",
"VAR_4->flags = VAR_0->env.cpucfgr;",
"VAR_4->mem_idx = cpu_mmu_index(&VAR_0->env);",
"VAR_4->synced_flags = VAR_4->tb_flags = VAR_1->flags;",
"VAR_4->delayed_branch = !!(VAR_4->tb_flags & D_FLAG);",
"VAR_4->singlestep_enabled = VAR_0->env.singlestep_enabled;",
"if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"qemu_log(\"-----------------------------------------\\n\");",
"log_cpu_state(&VAR_0->env, 0);",
"}",
"next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;",
"VAR_6 = -1;",
"VAR_7 = 0;",
"VAR_8 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_8 == 0) {",
"VAR_8 = CF_COUNT_MASK;",
"}",
"gen_icount_start();",
"do {",
"check_breakpoint(VAR_0, VAR_4);",
"if (VAR_2) {",
"VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"if (VAR_6 < VAR_5) {",
"VAR_6++;",
"while (VAR_6 < VAR_5) {",
"tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;",
"}",
"}",
"tcg_ctx.gen_opc_pc[VAR_6] = VAR_4->pc;",
"tcg_ctx.gen_opc_instr_start[VAR_6] = 1;",
"tcg_ctx.gen_opc_icount[VAR_6] = VAR_7;",
"}",
"if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {",
"tcg_gen_debug_insn_start(VAR_4->pc);",
"}",
"if (VAR_7 + 1 == VAR_8 && (VAR_1->cflags & CF_LAST_IO)) {",
"gen_io_start();",
"}",
"VAR_4->ppc = VAR_4->pc - 4;",
"VAR_4->npc = VAR_4->pc + 4;",
"tcg_gen_movi_tl(cpu_ppc, VAR_4->ppc);",
"tcg_gen_movi_tl(cpu_npc, VAR_4->npc);",
"disas_openrisc_insn(VAR_4, VAR_0);",
"VAR_4->pc = VAR_4->npc;",
"VAR_7++;",
"if (VAR_4->delayed_branch) {",
"VAR_4->delayed_branch--;",
"if (!VAR_4->delayed_branch) {",
"VAR_4->tb_flags &= ~D_FLAG;",
"gen_sync_flags(VAR_4);",
"tcg_gen_mov_tl(cpu_pc, jmp_pc);",
"tcg_gen_mov_tl(cpu_npc, jmp_pc);",
"tcg_gen_movi_tl(jmp_pc, 0);",
"tcg_gen_exit_tb(0);",
"VAR_4->is_jmp = DISAS_JUMP;",
"break;",
"}",
"}",
"} while (!VAR_4->is_jmp",
"&& tcg_ctx.gen_opc_ptr < gen_opc_end\n&& !VAR_0->env.singlestep_enabled\n&& !singlestep\n&& (VAR_4->pc < next_page_start)\n&& VAR_7 < VAR_8);",
"if (VAR_1->cflags & CF_LAST_IO) {",
"gen_io_end();",
"}",
"if (VAR_4->is_jmp == DISAS_NEXT) {",
"VAR_4->is_jmp = DISAS_UPDATE;",
"tcg_gen_movi_tl(cpu_pc, VAR_4->pc);",
"}",
"if (unlikely(VAR_0->env.singlestep_enabled)) {",
"if (VAR_4->is_jmp == DISAS_NEXT) {",
"tcg_gen_movi_tl(cpu_pc, VAR_4->pc);",
"}",
"gen_exception(VAR_4, EXCP_DEBUG);",
"} else {",
"switch (VAR_4->is_jmp) {",
"case DISAS_NEXT:\ngen_goto_tb(VAR_4, 0, VAR_4->pc);",
"break;",
"default:\ncase DISAS_JUMP:\nbreak;",
"case DISAS_UPDATE:\ntcg_gen_exit_tb(0);",
"break;",
"case DISAS_TB_JUMP:\nbreak;",
"}",
"}",
"gen_icount_end(VAR_1, VAR_7);",
"*tcg_ctx.gen_opc_ptr = INDEX_op_end;",
"if (VAR_2) {",
"VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"VAR_6++;",
"while (VAR_6 <= VAR_5) {",
"tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;",
"}",
"} else {",
"VAR_1->size = VAR_4->pc - pc_start;",
"VAR_1->icount = VAR_7;",
"}",
"#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"qemu_log(\"\\n\");",
"log_target_disas(&VAR_0->env, pc_start, VAR_4->pc - pc_start, 0);",
"qemu_log(\"\\nisize=%d osize=%td\\n\",\nVAR_4->pc - pc_start, tcg_ctx.gen_opc_ptr -\ntcg_ctx.gen_opc_buf);",
"}",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175,
177,
179,
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219,
221,
223
],
[
225,
231
],
[
233
],
[
235,
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
273,
275
],
[
277
],
[
279
],
[
281,
283,
285
],
[
287
],
[
289,
291
]
]
|
15,285 | static int ism_write_header(AVFormatContext *s)
{
SmoothStreamingContext *c = s->priv_data;
int ret = 0, i;
AVOutputFormat *oformat;
mkdir(s->filename, 0777);
oformat = av_guess_format("ismv", NULL, NULL);
if (!oformat) {
ret = AVERROR_MUXER_NOT_FOUND;
goto fail;
}
c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
if (!c->streams) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char buf[10];
if (!s->streams[i]->codec->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate);
mkdir(os->dirname, 0777);
ctx = avformat_alloc_context();
if (!ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = s->interrupt_callback;
if (!(st = avformat_new_stream(ctx, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, s->streams[i]->codec);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
if (!ctx->pb) {
ret = AVERROR(ENOMEM);
goto fail;
}
snprintf(buf, sizeof(buf), "%d", c->lookahead_count);
av_dict_set(&opts, "ism_lookahead", buf, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
if ((ret = avformat_write_header(ctx, &opts)) < 0) {
goto fail;
}
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
s->streams[i]->time_base = st->time_base;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;
os->stream_type_tag = "video";
if (st->codec->codec_id == AV_CODEC_ID_H264) {
os->fourcc = "H264";
} else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
os->fourcc = "WVC1";
} else {
av_log(s, AV_LOG_ERROR, "Unsupported video codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
} else {
c->has_audio = 1;
os->stream_type_tag = "audio";
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
os->fourcc = "AACL";
os->audio_tag = 0xff;
} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
os->fourcc = "WMAP";
os->audio_tag = 0x0162;
} else {
av_log(s, AV_LOG_ERROR, "Unsupported audio codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
os->packet_size = st->codec->block_align ? st->codec->block_align : 4;
}
get_private_data(os);
}
if (!c->has_video && c->min_frag_duration <= 0) {
av_log(s, AV_LOG_WARNING, "no video stream and no min frag duration set\n");
ret = AVERROR(EINVAL);
}
ret = write_manifest(s, 0);
fail:
if (ret)
ism_free(s);
return ret;
}
| true | FFmpeg | 803e82276b3716bf6012ec69e8854dae14a4fd2b | static int ism_write_header(AVFormatContext *s)
{
SmoothStreamingContext *c = s->priv_data;
int ret = 0, i;
AVOutputFormat *oformat;
mkdir(s->filename, 0777);
oformat = av_guess_format("ismv", NULL, NULL);
if (!oformat) {
ret = AVERROR_MUXER_NOT_FOUND;
goto fail;
}
c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
if (!c->streams) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char buf[10];
if (!s->streams[i]->codec->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate);
mkdir(os->dirname, 0777);
ctx = avformat_alloc_context();
if (!ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = s->interrupt_callback;
if (!(st = avformat_new_stream(ctx, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, s->streams[i]->codec);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
if (!ctx->pb) {
ret = AVERROR(ENOMEM);
goto fail;
}
snprintf(buf, sizeof(buf), "%d", c->lookahead_count);
av_dict_set(&opts, "ism_lookahead", buf, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
if ((ret = avformat_write_header(ctx, &opts)) < 0) {
goto fail;
}
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
s->streams[i]->time_base = st->time_base;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;
os->stream_type_tag = "video";
if (st->codec->codec_id == AV_CODEC_ID_H264) {
os->fourcc = "H264";
} else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
os->fourcc = "WVC1";
} else {
av_log(s, AV_LOG_ERROR, "Unsupported video codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
} else {
c->has_audio = 1;
os->stream_type_tag = "audio";
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
os->fourcc = "AACL";
os->audio_tag = 0xff;
} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
os->fourcc = "WMAP";
os->audio_tag = 0x0162;
} else {
av_log(s, AV_LOG_ERROR, "Unsupported audio codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
os->packet_size = st->codec->block_align ? st->codec->block_align : 4;
}
get_private_data(os);
}
if (!c->has_video && c->min_frag_duration <= 0) {
av_log(s, AV_LOG_WARNING, "no video stream and no min frag duration set\n");
ret = AVERROR(EINVAL);
}
ret = write_manifest(s, 0);
fail:
if (ret)
ism_free(s);
return ret;
}
| {
"code": [
" mkdir(s->filename, 0777);",
" mkdir(s->filename, 0777);",
" mkdir(os->dirname, 0777);"
],
"line_no": [
13,
13,
67
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
SmoothStreamingContext *c = VAR_0->priv_data;
int VAR_1 = 0, VAR_2;
AVOutputFormat *oformat;
mkdir(VAR_0->filename, 0777);
oformat = av_guess_format("ismv", NULL, NULL);
if (!oformat) {
VAR_1 = AVERROR_MUXER_NOT_FOUND;
goto fail;
}
c->streams = av_mallocz(sizeof(*c->streams) * VAR_0->nb_streams);
if (!c->streams) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {
OutputStream *os = &c->streams[VAR_2];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char buf[10];
if (!VAR_0->streams[VAR_2]->codec->bit_rate) {
av_log(VAR_0, AV_LOG_ERROR, "No bit rate set for stream %d\n", VAR_2);
VAR_1 = AVERROR(EINVAL);
goto fail;
}
snprintf(os->dirname, sizeof(os->dirname), "%VAR_0/QualityLevels(%d)", VAR_0->filename, VAR_0->streams[VAR_2]->codec->bit_rate);
mkdir(os->dirname, 0777);
ctx = avformat_alloc_context();
if (!ctx) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = VAR_0->interrupt_callback;
if (!(st = avformat_new_stream(ctx, NULL))) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, VAR_0->streams[VAR_2]->codec);
st->sample_aspect_ratio = VAR_0->streams[VAR_2]->sample_aspect_ratio;
ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
if (!ctx->pb) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
snprintf(buf, sizeof(buf), "%d", c->lookahead_count);
av_dict_set(&opts, "ism_lookahead", buf, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
if ((VAR_1 = avformat_write_header(ctx, &opts)) < 0) {
goto fail;
}
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
VAR_0->streams[VAR_2]->time_base = st->time_base;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;
os->stream_type_tag = "video";
if (st->codec->codec_id == AV_CODEC_ID_H264) {
os->fourcc = "H264";
} else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
os->fourcc = "WVC1";
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported video codec\n");
VAR_1 = AVERROR(EINVAL);
goto fail;
}
} else {
c->has_audio = 1;
os->stream_type_tag = "audio";
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
os->fourcc = "AACL";
os->audio_tag = 0xff;
} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
os->fourcc = "WMAP";
os->audio_tag = 0x0162;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported audio codec\n");
VAR_1 = AVERROR(EINVAL);
goto fail;
}
os->packet_size = st->codec->block_align ? st->codec->block_align : 4;
}
get_private_data(os);
}
if (!c->has_video && c->min_frag_duration <= 0) {
av_log(VAR_0, AV_LOG_WARNING, "no video stream and no min frag duration set\n");
VAR_1 = AVERROR(EINVAL);
}
VAR_1 = write_manifest(VAR_0, 0);
fail:
if (VAR_1)
ism_free(VAR_0);
return VAR_1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"SmoothStreamingContext *c = VAR_0->priv_data;",
"int VAR_1 = 0, VAR_2;",
"AVOutputFormat *oformat;",
"mkdir(VAR_0->filename, 0777);",
"oformat = av_guess_format(\"ismv\", NULL, NULL);",
"if (!oformat) {",
"VAR_1 = AVERROR_MUXER_NOT_FOUND;",
"goto fail;",
"}",
"c->streams = av_mallocz(sizeof(*c->streams) * VAR_0->nb_streams);",
"if (!c->streams) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {",
"OutputStream *os = &c->streams[VAR_2];",
"AVFormatContext *ctx;",
"AVStream *st;",
"AVDictionary *opts = NULL;",
"char buf[10];",
"if (!VAR_0->streams[VAR_2]->codec->bit_rate) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No bit rate set for stream %d\\n\", VAR_2);",
"VAR_1 = AVERROR(EINVAL);",
"goto fail;",
"}",
"snprintf(os->dirname, sizeof(os->dirname), \"%VAR_0/QualityLevels(%d)\", VAR_0->filename, VAR_0->streams[VAR_2]->codec->bit_rate);",
"mkdir(os->dirname, 0777);",
"ctx = avformat_alloc_context();",
"if (!ctx) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"os->ctx = ctx;",
"ctx->oformat = oformat;",
"ctx->interrupt_callback = VAR_0->interrupt_callback;",
"if (!(st = avformat_new_stream(ctx, NULL))) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"avcodec_copy_context(st->codec, VAR_0->streams[VAR_2]->codec);",
"st->sample_aspect_ratio = VAR_0->streams[VAR_2]->sample_aspect_ratio;",
"ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);",
"if (!ctx->pb) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"snprintf(buf, sizeof(buf), \"%d\", c->lookahead_count);",
"av_dict_set(&opts, \"ism_lookahead\", buf, 0);",
"av_dict_set(&opts, \"movflags\", \"frag_custom\", 0);",
"if ((VAR_1 = avformat_write_header(ctx, &opts)) < 0) {",
"goto fail;",
"}",
"os->ctx_inited = 1;",
"avio_flush(ctx->pb);",
"av_dict_free(&opts);",
"VAR_0->streams[VAR_2]->time_base = st->time_base;",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"c->has_video = 1;",
"os->stream_type_tag = \"video\";",
"if (st->codec->codec_id == AV_CODEC_ID_H264) {",
"os->fourcc = \"H264\";",
"} else if (st->codec->codec_id == AV_CODEC_ID_VC1) {",
"os->fourcc = \"WVC1\";",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported video codec\\n\");",
"VAR_1 = AVERROR(EINVAL);",
"goto fail;",
"}",
"} else {",
"c->has_audio = 1;",
"os->stream_type_tag = \"audio\";",
"if (st->codec->codec_id == AV_CODEC_ID_AAC) {",
"os->fourcc = \"AACL\";",
"os->audio_tag = 0xff;",
"} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {",
"os->fourcc = \"WMAP\";",
"os->audio_tag = 0x0162;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported audio codec\\n\");",
"VAR_1 = AVERROR(EINVAL);",
"goto fail;",
"}",
"os->packet_size = st->codec->block_align ? st->codec->block_align : 4;",
"}",
"get_private_data(os);",
"}",
"if (!c->has_video && c->min_frag_duration <= 0) {",
"av_log(VAR_0, AV_LOG_WARNING, \"no video stream and no min frag duration set\\n\");",
"VAR_1 = AVERROR(EINVAL);",
"}",
"VAR_1 = write_manifest(VAR_0, 0);",
"fail:\nif (VAR_1)\nism_free(VAR_0);",
"return VAR_1;",
"}"
]
| [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
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
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209,
211,
213
],
[
215
],
[
217
]
]
|
15,286 | static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
int width, int thresh,
const uint16_t *dithers)
{
intptr_t x;
if (width & 3) {
x = width & ~3;
ff_gradfun_filter_line_c(dst + x, src + x, dc + x / 2, width - x, thresh, dithers);
width = x;
}
x = -width;
__asm__ volatile(
"movd %4, %%mm5 \n"
"pxor %%mm7, %%mm7 \n"
"pshufw $0, %%mm5, %%mm5 \n"
"movq %6, %%mm6 \n"
"movq %5, %%mm4 \n"
"1: \n"
"movd (%2,%0), %%mm0 \n"
"movd (%3,%0), %%mm1 \n"
"punpcklbw %%mm7, %%mm0 \n"
"punpcklwd %%mm1, %%mm1 \n"
"psllw $7, %%mm0 \n"
"pxor %%mm2, %%mm2 \n"
"psubw %%mm0, %%mm1 \n" // delta = dc - pix
"psubw %%mm1, %%mm2 \n"
"pmaxsw %%mm1, %%mm2 \n"
"pmulhuw %%mm5, %%mm2 \n" // m = abs(delta) * thresh >> 16
"psubw %%mm6, %%mm2 \n"
"pminsw %%mm7, %%mm2 \n" // m = -max(0, 127-m)
"pmullw %%mm2, %%mm2 \n"
"paddw %%mm4, %%mm0 \n" // pix += dither
"pmulhw %%mm2, %%mm1 \n"
"psllw $2, %%mm1 \n" // m = m*m*delta >> 14
"paddw %%mm1, %%mm0 \n" // pix += m
"psraw $7, %%mm0 \n"
"packuswb %%mm0, %%mm0 \n"
"movd %%mm0, (%1,%0) \n" // dst = clip(pix>>7)
"add $4, %0 \n"
"jl 1b \n"
"emms \n"
:"+r"(x)
:"r"(dst+width), "r"(src+width), "r"(dc+width/2),
"rm"(thresh), "m"(*dithers), "m"(*pw_7f)
:"memory"
);
}
| true | FFmpeg | 2d66fc543b01995d6146fc132a778d3e722ca665 | static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
int width, int thresh,
const uint16_t *dithers)
{
intptr_t x;
if (width & 3) {
x = width & ~3;
ff_gradfun_filter_line_c(dst + x, src + x, dc + x / 2, width - x, thresh, dithers);
width = x;
}
x = -width;
__asm__ volatile(
"movd %4, %%mm5 \n"
"pxor %%mm7, %%mm7 \n"
"pshufw $0, %%mm5, %%mm5 \n"
"movq %6, %%mm6 \n"
"movq %5, %%mm4 \n"
"1: \n"
"movd (%2,%0), %%mm0 \n"
"movd (%3,%0), %%mm1 \n"
"punpcklbw %%mm7, %%mm0 \n"
"punpcklwd %%mm1, %%mm1 \n"
"psllw $7, %%mm0 \n"
"pxor %%mm2, %%mm2 \n"
"psubw %%mm0, %%mm1 \n"
"psubw %%mm1, %%mm2 \n"
"pmaxsw %%mm1, %%mm2 \n"
"pmulhuw %%mm5, %%mm2 \n"
"psubw %%mm6, %%mm2 \n"
"pminsw %%mm7, %%mm2 \n"
"pmullw %%mm2, %%mm2 \n"
"paddw %%mm4, %%mm0 \n"
"pmulhw %%mm2, %%mm1 \n"
"psllw $2, %%mm1 \n"
"paddw %%mm1, %%mm0 \n"
"psraw $7, %%mm0 \n"
"packuswb %%mm0, %%mm0 \n"
"movd %%mm0, (%1,%0) \n"
"add $4, %0 \n"
"jl 1b \n"
"emms \n"
:"+r"(x)
:"r"(dst+width), "r"(src+width), "r"(dc+width/2),
"rm"(thresh), "m"(*dithers), "m"(*pw_7f)
:"memory"
);
}
| {
"code": [
" \"pmulhw %%mm2, %%mm1 \\n\""
],
"line_no": [
65
]
} | static void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, uint16_t *VAR_2,
int VAR_3, int VAR_4,
const uint16_t *VAR_5)
{
intptr_t x;
if (VAR_3 & 3) {
x = VAR_3 & ~3;
ff_gradfun_filter_line_c(VAR_0 + x, VAR_1 + x, VAR_2 + x / 2, VAR_3 - x, VAR_4, VAR_5);
VAR_3 = x;
}
x = -VAR_3;
__asm__ volatile(
"movd %4, %%mm5 \n"
"pxor %%mm7, %%mm7 \n"
"pshufw $0, %%mm5, %%mm5 \n"
"movq %6, %%mm6 \n"
"movq %5, %%mm4 \n"
"1: \n"
"movd (%2,%0), %%mm0 \n"
"movd (%3,%0), %%mm1 \n"
"punpcklbw %%mm7, %%mm0 \n"
"punpcklwd %%mm1, %%mm1 \n"
"psllw $7, %%mm0 \n"
"pxor %%mm2, %%mm2 \n"
"psubw %%mm0, %%mm1 \n"
"psubw %%mm1, %%mm2 \n"
"pmaxsw %%mm1, %%mm2 \n"
"pmulhuw %%mm5, %%mm2 \n"
"psubw %%mm6, %%mm2 \n"
"pminsw %%mm7, %%mm2 \n"
"pmullw %%mm2, %%mm2 \n"
"paddw %%mm4, %%mm0 \n"
"pmulhw %%mm2, %%mm1 \n"
"psllw $2, %%mm1 \n"
"paddw %%mm1, %%mm0 \n"
"psraw $7, %%mm0 \n"
"packuswb %%mm0, %%mm0 \n"
"movd %%mm0, (%1,%0) \n"
"add $4, %0 \n"
"jl 1b \n"
"emms \n"
:"+r"(x)
:"r"(VAR_0+VAR_3), "r"(VAR_1+VAR_3), "r"(VAR_2+VAR_3/2),
"rm"(VAR_4), "m"(*VAR_5), "m"(*pw_7f)
:"memory"
);
}
| [
"static void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, uint16_t *VAR_2,\nint VAR_3, int VAR_4,\nconst uint16_t *VAR_5)\n{",
"intptr_t x;",
"if (VAR_3 & 3) {",
"x = VAR_3 & ~3;",
"ff_gradfun_filter_line_c(VAR_0 + x, VAR_1 + x, VAR_2 + x / 2, VAR_3 - x, VAR_4, VAR_5);",
"VAR_3 = x;",
"}",
"x = -VAR_3;",
"__asm__ volatile(\n\"movd %4, %%mm5 \\n\"\n\"pxor %%mm7, %%mm7 \\n\"\n\"pshufw $0, %%mm5, %%mm5 \\n\"\n\"movq %6, %%mm6 \\n\"\n\"movq %5, %%mm4 \\n\"\n\"1: \\n\"\n\"movd (%2,%0), %%mm0 \\n\"\n\"movd (%3,%0), %%mm1 \\n\"\n\"punpcklbw %%mm7, %%mm0 \\n\"\n\"punpcklwd %%mm1, %%mm1 \\n\"\n\"psllw $7, %%mm0 \\n\"\n\"pxor %%mm2, %%mm2 \\n\"\n\"psubw %%mm0, %%mm1 \\n\"\n\"psubw %%mm1, %%mm2 \\n\"\n\"pmaxsw %%mm1, %%mm2 \\n\"\n\"pmulhuw %%mm5, %%mm2 \\n\"\n\"psubw %%mm6, %%mm2 \\n\"\n\"pminsw %%mm7, %%mm2 \\n\"\n\"pmullw %%mm2, %%mm2 \\n\"\n\"paddw %%mm4, %%mm0 \\n\"\n\"pmulhw %%mm2, %%mm1 \\n\"\n\"psllw $2, %%mm1 \\n\"\n\"paddw %%mm1, %%mm0 \\n\"\n\"psraw $7, %%mm0 \\n\"\n\"packuswb %%mm0, %%mm0 \\n\"\n\"movd %%mm0, (%1,%0) \\n\"\n\"add $4, %0 \\n\"\n\"jl 1b \\n\"\n\"emms \\n\"\n:\"+r\"(x)\n:\"r\"(VAR_0+VAR_3), \"r\"(VAR_1+VAR_3), \"r\"(VAR_2+VAR_3/2),\n\"rm\"(VAR_4), \"m\"(*VAR_5), \"m\"(*pw_7f)\n:\"memory\"\n);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93
]
]
|
15,287 | static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs, QDict *opts)
{
bdrv_refresh_filename(bs->backing->bs);
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename),
bs->backing->bs->filename);
| true | qemu | 18775ff32697ab6e1fd47989673bf1de54d0d942 | static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs, QDict *opts)
{
bdrv_refresh_filename(bs->backing->bs);
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename),
bs->backing->bs->filename);
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1)
{
bdrv_refresh_filename(VAR_0->backing->VAR_0);
pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
VAR_0->backing->VAR_0->filename);
| [
"static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1)\n{",
"bdrv_refresh_filename(VAR_0->backing->VAR_0);",
"pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\nVAR_0->backing->VAR_0->filename);"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
10
],
[
12,
14
]
]
|
15,289 | static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts)
{
int fd_out;
TFR(fd_out = open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (fd_out < 0)
return NULL;
return qemu_chr_open_fd(-1, fd_out);
}
| true | qemu | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 | static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts)
{
int fd_out;
TFR(fd_out = open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (fd_out < 0)
return NULL;
return qemu_chr_open_fd(-1, fd_out);
}
| {
"code": [
" TFR(fd_out = open(qemu_opt_get(opts, \"path\"),"
],
"line_no": [
9
]
} | static CharDriverState *FUNC_0(QemuOpts *opts)
{
int VAR_0;
TFR(VAR_0 = open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (VAR_0 < 0)
return NULL;
return qemu_chr_open_fd(-1, VAR_0);
}
| [
"static CharDriverState *FUNC_0(QemuOpts *opts)\n{",
"int VAR_0;",
"TFR(VAR_0 = open(qemu_opt_get(opts, \"path\"),\nO_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));",
"if (VAR_0 < 0)\nreturn NULL;",
"return qemu_chr_open_fd(-1, VAR_0);",
"}"
]
| [
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19
]
]
|
15,291 | static SchroBuffer *find_next_parse_unit(SchroParseUnitContext *parse_ctx)
{
SchroBuffer *enc_buf = NULL;
int next_pu_offset = 0;
unsigned char *in_buf;
if (parse_ctx->buf_size < 13 ||
parse_ctx->buf[0] != 'B' ||
parse_ctx->buf[1] != 'B' ||
parse_ctx->buf[2] != 'C' ||
parse_ctx->buf[3] != 'D')
return NULL;
next_pu_offset = (parse_ctx->buf[5] << 24) +
(parse_ctx->buf[6] << 16) +
(parse_ctx->buf[7] << 8) +
parse_ctx->buf[8];
if (next_pu_offset == 0 &&
SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))
next_pu_offset = 13;
if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
return NULL;
in_buf = av_malloc(next_pu_offset);
if (!in_buf) {
av_log(parse_ctx, AV_LOG_ERROR, "Unable to allocate input buffer\n");
return NULL;
}
memcpy(in_buf, parse_ctx->buf, next_pu_offset);
enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
enc_buf->free = libschroedinger_decode_buffer_free;
enc_buf->priv = in_buf;
parse_ctx->buf += next_pu_offset;
parse_ctx->buf_size -= next_pu_offset;
return enc_buf;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static SchroBuffer *find_next_parse_unit(SchroParseUnitContext *parse_ctx)
{
SchroBuffer *enc_buf = NULL;
int next_pu_offset = 0;
unsigned char *in_buf;
if (parse_ctx->buf_size < 13 ||
parse_ctx->buf[0] != 'B' ||
parse_ctx->buf[1] != 'B' ||
parse_ctx->buf[2] != 'C' ||
parse_ctx->buf[3] != 'D')
return NULL;
next_pu_offset = (parse_ctx->buf[5] << 24) +
(parse_ctx->buf[6] << 16) +
(parse_ctx->buf[7] << 8) +
parse_ctx->buf[8];
if (next_pu_offset == 0 &&
SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))
next_pu_offset = 13;
if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
return NULL;
in_buf = av_malloc(next_pu_offset);
if (!in_buf) {
av_log(parse_ctx, AV_LOG_ERROR, "Unable to allocate input buffer\n");
return NULL;
}
memcpy(in_buf, parse_ctx->buf, next_pu_offset);
enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
enc_buf->free = libschroedinger_decode_buffer_free;
enc_buf->priv = in_buf;
parse_ctx->buf += next_pu_offset;
parse_ctx->buf_size -= next_pu_offset;
return enc_buf;
}
| {
"code": [
" return NULL;",
" return NULL;",
"static SchroBuffer *find_next_parse_unit(SchroParseUnitContext *parse_ctx)",
" SchroBuffer *enc_buf = NULL;",
" int next_pu_offset = 0;",
" unsigned char *in_buf;",
" if (parse_ctx->buf_size < 13 ||",
" parse_ctx->buf[0] != 'B' ||",
" parse_ctx->buf[1] != 'B' ||",
" parse_ctx->buf[2] != 'C' ||",
" parse_ctx->buf[3] != 'D')",
" return NULL;",
" next_pu_offset = (parse_ctx->buf[5] << 24) +",
" (parse_ctx->buf[6] << 16) +",
" (parse_ctx->buf[7] << 8) +",
" parse_ctx->buf[8];",
" if (next_pu_offset == 0 &&",
" SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))",
" next_pu_offset = 13;",
" if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)",
" return NULL;",
" in_buf = av_malloc(next_pu_offset);",
" if (!in_buf) {",
" av_log(parse_ctx, AV_LOG_ERROR, \"Unable to allocate input buffer\\n\");",
" return NULL;",
" memcpy(in_buf, parse_ctx->buf, next_pu_offset);",
" enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);",
" enc_buf->free = libschroedinger_decode_buffer_free;",
" enc_buf->priv = in_buf;",
" parse_ctx->buf += next_pu_offset;",
" parse_ctx->buf_size -= next_pu_offset;",
" return enc_buf;"
],
"line_no": [
23,
23,
1,
5,
7,
9,
13,
15,
17,
19,
21,
23,
27,
29,
31,
33,
37,
39,
41,
45,
23,
51,
53,
55,
23,
63,
65,
67,
69,
73,
75,
79
]
} | static SchroBuffer *FUNC_0(SchroParseUnitContext *parse_ctx)
{
SchroBuffer *enc_buf = NULL;
int VAR_0 = 0;
unsigned char *VAR_1;
if (parse_ctx->buf_size < 13 ||
parse_ctx->buf[0] != 'B' ||
parse_ctx->buf[1] != 'B' ||
parse_ctx->buf[2] != 'C' ||
parse_ctx->buf[3] != 'D')
return NULL;
VAR_0 = (parse_ctx->buf[5] << 24) +
(parse_ctx->buf[6] << 16) +
(parse_ctx->buf[7] << 8) +
parse_ctx->buf[8];
if (VAR_0 == 0 &&
SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))
VAR_0 = 13;
if (VAR_0 <= 0 || parse_ctx->buf_size < VAR_0)
return NULL;
VAR_1 = av_malloc(VAR_0);
if (!VAR_1) {
av_log(parse_ctx, AV_LOG_ERROR, "Unable to allocate input buffer\n");
return NULL;
}
memcpy(VAR_1, parse_ctx->buf, VAR_0);
enc_buf = schro_buffer_new_with_data(VAR_1, VAR_0);
enc_buf->free = libschroedinger_decode_buffer_free;
enc_buf->priv = VAR_1;
parse_ctx->buf += VAR_0;
parse_ctx->buf_size -= VAR_0;
return enc_buf;
}
| [
"static SchroBuffer *FUNC_0(SchroParseUnitContext *parse_ctx)\n{",
"SchroBuffer *enc_buf = NULL;",
"int VAR_0 = 0;",
"unsigned char *VAR_1;",
"if (parse_ctx->buf_size < 13 ||\nparse_ctx->buf[0] != 'B' ||\nparse_ctx->buf[1] != 'B' ||\nparse_ctx->buf[2] != 'C' ||\nparse_ctx->buf[3] != 'D')\nreturn NULL;",
"VAR_0 = (parse_ctx->buf[5] << 24) +\n(parse_ctx->buf[6] << 16) +\n(parse_ctx->buf[7] << 8) +\nparse_ctx->buf[8];",
"if (VAR_0 == 0 &&\nSCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))\nVAR_0 = 13;",
"if (VAR_0 <= 0 || parse_ctx->buf_size < VAR_0)\nreturn NULL;",
"VAR_1 = av_malloc(VAR_0);",
"if (!VAR_1) {",
"av_log(parse_ctx, AV_LOG_ERROR, \"Unable to allocate input buffer\\n\");",
"return NULL;",
"}",
"memcpy(VAR_1, parse_ctx->buf, VAR_0);",
"enc_buf = schro_buffer_new_with_data(VAR_1, VAR_0);",
"enc_buf->free = libschroedinger_decode_buffer_free;",
"enc_buf->priv = VAR_1;",
"parse_ctx->buf += VAR_0;",
"parse_ctx->buf_size -= VAR_0;",
"return enc_buf;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15,
17,
19,
21,
23
],
[
27,
29,
31,
33
],
[
37,
39,
41
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
]
]
|
15,292 | static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform){
int i, mb_x, mb_y;
uint16_t buffer[2048][4];
int left[3], top[3], topleft[3];
const int linesize= s->linesize[0];
const int mask= (1<<s->bits)-1;
for(i=0; i<3; i++){
buffer[0][i]= 1 << (s->bits + point_transform - 1);
}
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
const int modified_predictor= mb_y ? predictor : 1;
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
}
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
if (s->restart_interval && !s->restart_count)
s->restart_count = s->restart_interval;
for(i=0;i<3;i++) {
int pred;
topleft[i]= top[i];
top[i]= buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
left[i]=
buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
}
}
if(s->rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else if(s->pegasus_rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else{
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+0] = buffer[mb_x][0];
ptr[4*mb_x+1] = buffer[mb_x][1];
ptr[4*mb_x+2] = buffer[mb_x][2];
}
}
}
return 0;
}
| true | FFmpeg | 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 | static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform){
int i, mb_x, mb_y;
uint16_t buffer[2048][4];
int left[3], top[3], topleft[3];
const int linesize= s->linesize[0];
const int mask= (1<<s->bits)-1;
for(i=0; i<3; i++){
buffer[0][i]= 1 << (s->bits + point_transform - 1);
}
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
const int modified_predictor= mb_y ? predictor : 1;
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
}
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
if (s->restart_interval && !s->restart_count)
s->restart_count = s->restart_interval;
for(i=0;i<3;i++) {
int pred;
topleft[i]= top[i];
top[i]= buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
left[i]=
buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
if(s->rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else if(s->pegasus_rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else{
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+0] = buffer[mb_x][0];
ptr[4*mb_x+1] = buffer[mb_x][1];
ptr[4*mb_x+2] = buffer[mb_x][2];
}
}
}
return 0;
}
| {
"code": [
" uint16_t buffer[2048][4];"
],
"line_no": [
5
]
} | static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2){
int VAR_3, VAR_4, VAR_5;
uint16_t buffer[2048][4];
int VAR_6[3], VAR_7[3], VAR_8[3];
const int VAR_9= VAR_0->VAR_9[0];
const int VAR_10= (1<<VAR_0->bits)-1;
for(VAR_3=0; VAR_3<3; VAR_3++){
buffer[0][VAR_3]= 1 << (VAR_0->bits + VAR_2 - 1);
}
for(VAR_5 = 0; VAR_5 < VAR_0->mb_height; VAR_5++) {
const int modified_predictor= VAR_5 ? VAR_1 : 1;
uint8_t *ptr = VAR_0->picture.data[0] + (VAR_9 * VAR_5);
if (VAR_0->interlaced && VAR_0->bottom_field)
ptr += VAR_9 >> 1;
for(VAR_3=0; VAR_3<3; VAR_3++){
VAR_7[VAR_3]= VAR_6[VAR_3]= VAR_8[VAR_3]= buffer[0][VAR_3];
}
for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {
if (VAR_0->restart_interval && !VAR_0->restart_count)
VAR_0->restart_count = VAR_0->restart_interval;
for(VAR_3=0;VAR_3<3;VAR_3++) {
int pred;
VAR_8[VAR_3]= VAR_7[VAR_3];
VAR_7[VAR_3]= buffer[VAR_4][VAR_3];
PREDICT(pred, VAR_8[VAR_3], VAR_7[VAR_3], VAR_6[VAR_3], modified_predictor);
VAR_6[VAR_3]=
buffer[VAR_4][VAR_3]= VAR_10 & (pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2));
}
if (VAR_0->restart_interval && !--VAR_0->restart_count) {
align_get_bits(&VAR_0->gb);
skip_bits(&VAR_0->gb, 16);
}
}
if(VAR_0->rct){
for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {
ptr[4*VAR_4+1] = buffer[VAR_4][0] - ((buffer[VAR_4][1] + buffer[VAR_4][2] - 0x200)>>2);
ptr[4*VAR_4+0] = buffer[VAR_4][1] + ptr[4*VAR_4+1];
ptr[4*VAR_4+2] = buffer[VAR_4][2] + ptr[4*VAR_4+1];
}
}else if(VAR_0->pegasus_rct){
for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {
ptr[4*VAR_4+1] = buffer[VAR_4][0] - ((buffer[VAR_4][1] + buffer[VAR_4][2])>>2);
ptr[4*VAR_4+0] = buffer[VAR_4][1] + ptr[4*VAR_4+1];
ptr[4*VAR_4+2] = buffer[VAR_4][2] + ptr[4*VAR_4+1];
}
}else{
for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {
ptr[4*VAR_4+0] = buffer[VAR_4][0];
ptr[4*VAR_4+1] = buffer[VAR_4][1];
ptr[4*VAR_4+2] = buffer[VAR_4][2];
}
}
}
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2){",
"int VAR_3, VAR_4, VAR_5;",
"uint16_t buffer[2048][4];",
"int VAR_6[3], VAR_7[3], VAR_8[3];",
"const int VAR_9= VAR_0->VAR_9[0];",
"const int VAR_10= (1<<VAR_0->bits)-1;",
"for(VAR_3=0; VAR_3<3; VAR_3++){",
"buffer[0][VAR_3]= 1 << (VAR_0->bits + VAR_2 - 1);",
"}",
"for(VAR_5 = 0; VAR_5 < VAR_0->mb_height; VAR_5++) {",
"const int modified_predictor= VAR_5 ? VAR_1 : 1;",
"uint8_t *ptr = VAR_0->picture.data[0] + (VAR_9 * VAR_5);",
"if (VAR_0->interlaced && VAR_0->bottom_field)\nptr += VAR_9 >> 1;",
"for(VAR_3=0; VAR_3<3; VAR_3++){",
"VAR_7[VAR_3]= VAR_6[VAR_3]= VAR_8[VAR_3]= buffer[0][VAR_3];",
"}",
"for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {",
"if (VAR_0->restart_interval && !VAR_0->restart_count)\nVAR_0->restart_count = VAR_0->restart_interval;",
"for(VAR_3=0;VAR_3<3;VAR_3++) {",
"int pred;",
"VAR_8[VAR_3]= VAR_7[VAR_3];",
"VAR_7[VAR_3]= buffer[VAR_4][VAR_3];",
"PREDICT(pred, VAR_8[VAR_3], VAR_7[VAR_3], VAR_6[VAR_3], modified_predictor);",
"VAR_6[VAR_3]=\nbuffer[VAR_4][VAR_3]= VAR_10 & (pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2));",
"}",
"if (VAR_0->restart_interval && !--VAR_0->restart_count) {",
"align_get_bits(&VAR_0->gb);",
"skip_bits(&VAR_0->gb, 16);",
"}",
"}",
"if(VAR_0->rct){",
"for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {",
"ptr[4*VAR_4+1] = buffer[VAR_4][0] - ((buffer[VAR_4][1] + buffer[VAR_4][2] - 0x200)>>2);",
"ptr[4*VAR_4+0] = buffer[VAR_4][1] + ptr[4*VAR_4+1];",
"ptr[4*VAR_4+2] = buffer[VAR_4][2] + ptr[4*VAR_4+1];",
"}",
"}else if(VAR_0->pegasus_rct){",
"for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {",
"ptr[4*VAR_4+1] = buffer[VAR_4][0] - ((buffer[VAR_4][1] + buffer[VAR_4][2])>>2);",
"ptr[4*VAR_4+0] = buffer[VAR_4][1] + ptr[4*VAR_4+1];",
"ptr[4*VAR_4+2] = buffer[VAR_4][2] + ptr[4*VAR_4+1];",
"}",
"}else{",
"for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {",
"ptr[4*VAR_4+0] = buffer[VAR_4][0];",
"ptr[4*VAR_4+1] = buffer[VAR_4][1];",
"ptr[4*VAR_4+2] = buffer[VAR_4][2];",
"}",
"}",
"}",
"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,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
65,
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
]
]
|
15,293 | static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,
int n, int qscale, int *overflow)
{
const uint8_t *scantable= ctx->intra_scantable.scantable;
const int *qmat = ctx->q_intra_matrix[qscale];
int last_non_zero = 0;
ctx->dsp.fdct(block);
// Divide by 4 with rounding, to compensate scaling of DCT coefficients
block[0] = (block[0] + 2) >> 2;
for (int i = 1; i < 64; ++i) {
int j = scantable[i];
int sign = block[j] >> 31;
int level = (block[j] ^ sign) - sign;
level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT;
block[j] = (level ^ sign) - sign;
if (level)
last_non_zero = i;
}
return last_non_zero;
}
| false | FFmpeg | e72f3d10f64f5c65a67aa21dcc79a85ee55e912e | static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,
int n, int qscale, int *overflow)
{
const uint8_t *scantable= ctx->intra_scantable.scantable;
const int *qmat = ctx->q_intra_matrix[qscale];
int last_non_zero = 0;
ctx->dsp.fdct(block);
block[0] = (block[0] + 2) >> 2;
for (int i = 1; i < 64; ++i) {
int j = scantable[i];
int sign = block[j] >> 31;
int level = (block[j] ^ sign) - sign;
level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT;
block[j] = (level ^ sign) - sign;
if (level)
last_non_zero = i;
}
return last_non_zero;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1,
int VAR_2, int VAR_3, int *VAR_4)
{
const uint8_t *VAR_5= VAR_0->intra_scantable.VAR_5;
const int *VAR_6 = VAR_0->q_intra_matrix[VAR_3];
int VAR_7 = 0;
VAR_0->dsp.fdct(VAR_1);
VAR_1[0] = (VAR_1[0] + 2) >> 2;
for (int VAR_8 = 1; VAR_8 < 64; ++VAR_8) {
int VAR_9 = VAR_5[VAR_8];
int VAR_10 = VAR_1[VAR_9] >> 31;
int VAR_11 = (VAR_1[VAR_9] ^ VAR_10) - VAR_10;
VAR_11 = VAR_11 * VAR_6[VAR_9] >> DNX10BIT_QMAT_SHIFT;
VAR_1[VAR_9] = (VAR_11 ^ VAR_10) - VAR_10;
if (VAR_11)
VAR_7 = VAR_8;
}
return VAR_7;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1,\nint VAR_2, int VAR_3, int *VAR_4)\n{",
"const uint8_t *VAR_5= VAR_0->intra_scantable.VAR_5;",
"const int *VAR_6 = VAR_0->q_intra_matrix[VAR_3];",
"int VAR_7 = 0;",
"VAR_0->dsp.fdct(VAR_1);",
"VAR_1[0] = (VAR_1[0] + 2) >> 2;",
"for (int VAR_8 = 1; VAR_8 < 64; ++VAR_8) {",
"int VAR_9 = VAR_5[VAR_8];",
"int VAR_10 = VAR_1[VAR_9] >> 31;",
"int VAR_11 = (VAR_1[VAR_9] ^ VAR_10) - VAR_10;",
"VAR_11 = VAR_11 * VAR_6[VAR_9] >> DNX10BIT_QMAT_SHIFT;",
"VAR_1[VAR_9] = (VAR_11 ^ VAR_10) - VAR_10;",
"if (VAR_11)\nVAR_7 = VAR_8;",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
45
],
[
47
]
]
|
15,294 | static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
int16_t (*mv_table)[2], int ref_index, int f_code)
{
MotionEstContext * const c= &s->me;
int mx = 0, my = 0, dmin = 0;
int P[10][2];
const int shift= 1+s->quarter_sample;
const int mot_stride = s->mb_stride;
const int mot_xy = mb_y*mot_stride + mb_x;
uint8_t * const mv_penalty= c->mv_penalty[f_code] + MAX_MV;
int mv_scale;
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= mv_penalty;
get_limits(s, 16*mb_x, 16*mb_y);
if (s->motion_est != FF_ME_ZERO) {
P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1];
if (P_LEFT[0] > (c->xmax << shift)) P_LEFT[0] = (c->xmax << shift);
/* special case for first line */
if (!s->first_slice_line) {
P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
if (P_TOP[1] > (c->ymax << shift)) P_TOP[1] = (c->ymax << shift);
if (P_TOPRIGHT[0] < (c->xmin << shift)) P_TOPRIGHT[0] = (c->xmin << shift);
if (P_TOPRIGHT[1] > (c->ymax << shift)) P_TOPRIGHT[1] = (c->ymax << shift);
P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
}
c->pred_x = P_LEFT[0];
c->pred_y = P_LEFT[1];
if(mv_table == s->b_forw_mv_table){
mv_scale= (s->pb_time<<16) / (s->pp_time<<shift);
}else{
mv_scale= ((s->pb_time - s->pp_time)<<16) / (s->pp_time<<shift);
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16);
}
dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, ref_index, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
dmin= get_mb_score(s, mx, my, 0, ref_index, 0, 16, 1);
// s->mb_type[mb_y*s->mb_width + mb_x]= mb_type;
mv_table[mot_xy][0]= mx;
mv_table[mot_xy][1]= my;
return dmin;
}
| false | FFmpeg | 5b4da8a38a5ed211df9504c85ce401c30af86b97 | static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
int16_t (*mv_table)[2], int ref_index, int f_code)
{
MotionEstContext * const c= &s->me;
int mx = 0, my = 0, dmin = 0;
int P[10][2];
const int shift= 1+s->quarter_sample;
const int mot_stride = s->mb_stride;
const int mot_xy = mb_y*mot_stride + mb_x;
uint8_t * const mv_penalty= c->mv_penalty[f_code] + MAX_MV;
int mv_scale;
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= mv_penalty;
get_limits(s, 16*mb_x, 16*mb_y);
if (s->motion_est != FF_ME_ZERO) {
P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1];
if (P_LEFT[0] > (c->xmax << shift)) P_LEFT[0] = (c->xmax << shift);
if (!s->first_slice_line) {
P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
if (P_TOP[1] > (c->ymax << shift)) P_TOP[1] = (c->ymax << shift);
if (P_TOPRIGHT[0] < (c->xmin << shift)) P_TOPRIGHT[0] = (c->xmin << shift);
if (P_TOPRIGHT[1] > (c->ymax << shift)) P_TOPRIGHT[1] = (c->ymax << shift);
P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
}
c->pred_x = P_LEFT[0];
c->pred_y = P_LEFT[1];
if(mv_table == s->b_forw_mv_table){
mv_scale= (s->pb_time<<16) / (s->pp_time<<shift);
}else{
mv_scale= ((s->pb_time - s->pp_time)<<16) / (s->pp_time<<shift);
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16);
}
dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, ref_index, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
dmin= get_mb_score(s, mx, my, 0, ref_index, 0, 16, 1);
mv_table[mot_xy][0]= mx;
mv_table[mot_xy][1]= my;
return dmin;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2,
VAR_3 (*mv_table)[2], int VAR_4, int VAR_5)
{
MotionEstContext * const c= &VAR_0->me;
int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0;
int VAR_9[10][2];
const int VAR_10= 1+VAR_0->quarter_sample;
const int VAR_11 = VAR_0->mb_stride;
const int VAR_12 = VAR_2*VAR_11 + VAR_1;
uint8_t * const mv_penalty= c->mv_penalty[VAR_5] + MAX_MV;
int VAR_13;
c->penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= mv_penalty;
get_limits(VAR_0, 16*VAR_1, 16*VAR_2);
if (VAR_0->motion_est != FF_ME_ZERO) {
P_LEFT[0] = mv_table[VAR_12 - 1][0];
P_LEFT[1] = mv_table[VAR_12 - 1][1];
if (P_LEFT[0] > (c->xmax << VAR_10)) P_LEFT[0] = (c->xmax << VAR_10);
if (!VAR_0->first_slice_line) {
P_TOP[0] = mv_table[VAR_12 - VAR_11 ][0];
P_TOP[1] = mv_table[VAR_12 - VAR_11 ][1];
P_TOPRIGHT[0] = mv_table[VAR_12 - VAR_11 + 1][0];
P_TOPRIGHT[1] = mv_table[VAR_12 - VAR_11 + 1][1];
if (P_TOP[1] > (c->ymax << VAR_10)) P_TOP[1] = (c->ymax << VAR_10);
if (P_TOPRIGHT[0] < (c->xmin << VAR_10)) P_TOPRIGHT[0] = (c->xmin << VAR_10);
if (P_TOPRIGHT[1] > (c->ymax << VAR_10)) P_TOPRIGHT[1] = (c->ymax << VAR_10);
P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
}
c->pred_x = P_LEFT[0];
c->pred_y = P_LEFT[1];
if(mv_table == VAR_0->b_forw_mv_table){
VAR_13= (VAR_0->pb_time<<16) / (VAR_0->pp_time<<VAR_10);
}else{
VAR_13= ((VAR_0->pb_time - VAR_0->pp_time)<<16) / (VAR_0->pp_time<<VAR_10);
}
VAR_8 = ff_epzs_motion_search(VAR_0, &VAR_6, &VAR_7, VAR_9, 0, VAR_4, VAR_0->p_mv_table, VAR_13, 0, 16);
}
VAR_8= c->sub_motion_search(VAR_0, &VAR_6, &VAR_7, VAR_8, 0, VAR_4, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
VAR_8= get_mb_score(VAR_0, VAR_6, VAR_7, 0, VAR_4, 0, 16, 1);
mv_table[VAR_12][0]= VAR_6;
mv_table[VAR_12][1]= VAR_7;
return VAR_8;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2,\nVAR_3 (*mv_table)[2], int VAR_4, int VAR_5)\n{",
"MotionEstContext * const c= &VAR_0->me;",
"int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0;",
"int VAR_9[10][2];",
"const int VAR_10= 1+VAR_0->quarter_sample;",
"const int VAR_11 = VAR_0->mb_stride;",
"const int VAR_12 = VAR_2*VAR_11 + VAR_1;",
"uint8_t * const mv_penalty= c->mv_penalty[VAR_5] + MAX_MV;",
"int VAR_13;",
"c->penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_cmp);",
"c->sub_penalty_factor= get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_sub_cmp);",
"c->mb_penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->mb_cmp);",
"c->current_mv_penalty= mv_penalty;",
"get_limits(VAR_0, 16*VAR_1, 16*VAR_2);",
"if (VAR_0->motion_est != FF_ME_ZERO) {",
"P_LEFT[0] = mv_table[VAR_12 - 1][0];",
"P_LEFT[1] = mv_table[VAR_12 - 1][1];",
"if (P_LEFT[0] > (c->xmax << VAR_10)) P_LEFT[0] = (c->xmax << VAR_10);",
"if (!VAR_0->first_slice_line) {",
"P_TOP[0] = mv_table[VAR_12 - VAR_11 ][0];",
"P_TOP[1] = mv_table[VAR_12 - VAR_11 ][1];",
"P_TOPRIGHT[0] = mv_table[VAR_12 - VAR_11 + 1][0];",
"P_TOPRIGHT[1] = mv_table[VAR_12 - VAR_11 + 1][1];",
"if (P_TOP[1] > (c->ymax << VAR_10)) P_TOP[1] = (c->ymax << VAR_10);",
"if (P_TOPRIGHT[0] < (c->xmin << VAR_10)) P_TOPRIGHT[0] = (c->xmin << VAR_10);",
"if (P_TOPRIGHT[1] > (c->ymax << VAR_10)) P_TOPRIGHT[1] = (c->ymax << VAR_10);",
"P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);",
"P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);",
"}",
"c->pred_x = P_LEFT[0];",
"c->pred_y = P_LEFT[1];",
"if(mv_table == VAR_0->b_forw_mv_table){",
"VAR_13= (VAR_0->pb_time<<16) / (VAR_0->pp_time<<VAR_10);",
"}else{",
"VAR_13= ((VAR_0->pb_time - VAR_0->pp_time)<<16) / (VAR_0->pp_time<<VAR_10);",
"}",
"VAR_8 = ff_epzs_motion_search(VAR_0, &VAR_6, &VAR_7, VAR_9, 0, VAR_4, VAR_0->p_mv_table, VAR_13, 0, 16);",
"}",
"VAR_8= c->sub_motion_search(VAR_0, &VAR_6, &VAR_7, VAR_8, 0, VAR_4, 0, 16);",
"if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)\nVAR_8= get_mb_score(VAR_0, VAR_6, VAR_7, 0, VAR_4, 0, 16, 1);",
"mv_table[VAR_12][0]= VAR_6;",
"mv_table[VAR_12][1]= VAR_7;",
"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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
105,
107
],
[
113
],
[
115
],
[
119
],
[
121
]
]
|
15,295 | static av_cold int XAVS_close(AVCodecContext *avctx)
{
XavsContext *x4 = avctx->priv_data;
av_freep(&avctx->extradata);
av_free(x4->sei);
av_freep(&x4->pts_buffer);
if (x4->enc)
xavs_encoder_close(x4->enc);
av_frame_free(&avctx->coded_frame);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int XAVS_close(AVCodecContext *avctx)
{
XavsContext *x4 = avctx->priv_data;
av_freep(&avctx->extradata);
av_free(x4->sei);
av_freep(&x4->pts_buffer);
if (x4->enc)
xavs_encoder_close(x4->enc);
av_frame_free(&avctx->coded_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
XavsContext *x4 = avctx->priv_data;
av_freep(&avctx->extradata);
av_free(x4->sei);
av_freep(&x4->pts_buffer);
if (x4->enc)
xavs_encoder_close(x4->enc);
av_frame_free(&avctx->coded_frame);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"XavsContext *x4 = avctx->priv_data;",
"av_freep(&avctx->extradata);",
"av_free(x4->sei);",
"av_freep(&x4->pts_buffer);",
"if (x4->enc)\nxavs_encoder_close(x4->enc);",
"av_frame_free(&avctx->coded_frame);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
27
],
[
29
]
]
|
15,297 | int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed)
{
int ret = 0;
VHDXHeader *hdr;
VHDXLogSequence logs = { 0 };
hdr = s->headers[s->curr_header];
*flushed = false;
/* s->log.hdr is freed in vhdx_close() */
if (s->log.hdr == NULL) {
s->log.hdr = qemu_blockalign(bs, sizeof(VHDXLogEntryHeader));
}
s->log.offset = hdr->log_offset;
s->log.length = hdr->log_length;
if (s->log.offset < VHDX_LOG_MIN_SIZE ||
s->log.offset % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
/* per spec, only log version of 0 is supported */
if (hdr->log_version != 0) {
ret = -EINVAL;
goto exit;
}
/* If either the log guid, or log length is zero,
* then a replay log is not present */
if (guid_eq(hdr->log_guid, zero_guid)) {
goto exit;
}
if (hdr->log_length == 0) {
goto exit;
}
if (hdr->log_length % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
/* The log is present, we need to find if and where there is an active
* sequence of valid entries present in the log. */
ret = vhdx_log_search(bs, s, &logs);
if (ret < 0) {
goto exit;
}
if (logs.valid) {
/* now flush the log */
ret = vhdx_log_flush(bs, s, &logs);
if (ret < 0) {
goto exit;
}
*flushed = true;
}
exit:
return ret;
}
| true | qemu | 7e30e6a6746b417c7e0dbc9af009560fbb63f336 | int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed)
{
int ret = 0;
VHDXHeader *hdr;
VHDXLogSequence logs = { 0 };
hdr = s->headers[s->curr_header];
*flushed = false;
if (s->log.hdr == NULL) {
s->log.hdr = qemu_blockalign(bs, sizeof(VHDXLogEntryHeader));
}
s->log.offset = hdr->log_offset;
s->log.length = hdr->log_length;
if (s->log.offset < VHDX_LOG_MIN_SIZE ||
s->log.offset % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
if (hdr->log_version != 0) {
ret = -EINVAL;
goto exit;
}
if (guid_eq(hdr->log_guid, zero_guid)) {
goto exit;
}
if (hdr->log_length == 0) {
goto exit;
}
if (hdr->log_length % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
ret = vhdx_log_search(bs, s, &logs);
if (ret < 0) {
goto exit;
}
if (logs.valid) {
ret = vhdx_log_flush(bs, s, &logs);
if (ret < 0) {
goto exit;
}
*flushed = true;
}
exit:
return ret;
}
| {
"code": [
"int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed)"
],
"line_no": [
1
]
} | int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1, bool *VAR_2)
{
int VAR_3 = 0;
VHDXHeader *hdr;
VHDXLogSequence logs = { 0 };
hdr = VAR_1->headers[VAR_1->curr_header];
*VAR_2 = false;
if (VAR_1->log.hdr == NULL) {
VAR_1->log.hdr = qemu_blockalign(VAR_0, sizeof(VHDXLogEntryHeader));
}
VAR_1->log.offset = hdr->log_offset;
VAR_1->log.length = hdr->log_length;
if (VAR_1->log.offset < VHDX_LOG_MIN_SIZE ||
VAR_1->log.offset % VHDX_LOG_MIN_SIZE) {
VAR_3 = -EINVAL;
goto exit;
}
if (hdr->log_version != 0) {
VAR_3 = -EINVAL;
goto exit;
}
if (guid_eq(hdr->log_guid, zero_guid)) {
goto exit;
}
if (hdr->log_length == 0) {
goto exit;
}
if (hdr->log_length % VHDX_LOG_MIN_SIZE) {
VAR_3 = -EINVAL;
goto exit;
}
VAR_3 = vhdx_log_search(VAR_0, VAR_1, &logs);
if (VAR_3 < 0) {
goto exit;
}
if (logs.valid) {
VAR_3 = vhdx_log_flush(VAR_0, VAR_1, &logs);
if (VAR_3 < 0) {
goto exit;
}
*VAR_2 = true;
}
exit:
return VAR_3;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1, bool *VAR_2)\n{",
"int VAR_3 = 0;",
"VHDXHeader *hdr;",
"VHDXLogSequence logs = { 0 };",
"hdr = VAR_1->headers[VAR_1->curr_header];",
"*VAR_2 = false;",
"if (VAR_1->log.hdr == NULL) {",
"VAR_1->log.hdr = qemu_blockalign(VAR_0, sizeof(VHDXLogEntryHeader));",
"}",
"VAR_1->log.offset = hdr->log_offset;",
"VAR_1->log.length = hdr->log_length;",
"if (VAR_1->log.offset < VHDX_LOG_MIN_SIZE ||\nVAR_1->log.offset % VHDX_LOG_MIN_SIZE) {",
"VAR_3 = -EINVAL;",
"goto exit;",
"}",
"if (hdr->log_version != 0) {",
"VAR_3 = -EINVAL;",
"goto exit;",
"}",
"if (guid_eq(hdr->log_guid, zero_guid)) {",
"goto exit;",
"}",
"if (hdr->log_length == 0) {",
"goto exit;",
"}",
"if (hdr->log_length % VHDX_LOG_MIN_SIZE) {",
"VAR_3 = -EINVAL;",
"goto exit;",
"}",
"VAR_3 = vhdx_log_search(VAR_0, VAR_1, &logs);",
"if (VAR_3 < 0) {",
"goto exit;",
"}",
"if (logs.valid) {",
"VAR_3 = vhdx_log_flush(VAR_0, VAR_1, &logs);",
"if (VAR_3 < 0) {",
"goto exit;",
"}",
"*VAR_2 = true;",
"}",
"exit:\nreturn 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129,
131
],
[
133
]
]
|
15,298 | QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
QCryptoCipherMode mode,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipher *cipher;
QCryptoCipherNettle *ctx;
uint8_t *rfbkey;
switch (mode) {
case QCRYPTO_CIPHER_MODE_ECB:
case QCRYPTO_CIPHER_MODE_CBC:
case QCRYPTO_CIPHER_MODE_XTS:
case QCRYPTO_CIPHER_MODE_CTR:
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
return NULL;
}
if (!qcrypto_cipher_validate_key_length(alg, mode, nkey, errp)) {
return NULL;
}
cipher = g_new0(QCryptoCipher, 1);
cipher->alg = alg;
cipher->mode = mode;
ctx = g_new0(QCryptoCipherNettle, 1);
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES_RFB:
ctx->ctx = g_new0(struct des_ctx, 1);
rfbkey = qcrypto_cipher_munge_des_rfb_key(key, nkey);
des_set_key(ctx->ctx, rfbkey);
g_free(rfbkey);
ctx->alg_encrypt_native = des_encrypt_native;
ctx->alg_decrypt_native = des_decrypt_native;
ctx->alg_encrypt_wrapper = des_encrypt_wrapper;
ctx->alg_decrypt_wrapper = des_decrypt_wrapper;
ctx->blocksize = DES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
ctx->ctx = g_new0(QCryptoNettleAES, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(QCryptoNettleAES, 1);
nkey /= 2;
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->enc,
nkey, key + nkey);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->dec,
nkey, key + nkey);
} else {
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
}
ctx->alg_encrypt_native = aes_encrypt_native;
ctx->alg_decrypt_native = aes_decrypt_native;
ctx->alg_encrypt_wrapper = aes_encrypt_wrapper;
ctx->alg_decrypt_wrapper = aes_decrypt_wrapper;
ctx->blocksize = AES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_CAST5_128:
ctx->ctx = g_new0(struct cast128_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct cast128_ctx, 1);
nkey /= 2;
cast5_set_key(ctx->ctx, nkey, key);
cast5_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
cast5_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = cast128_encrypt_native;
ctx->alg_decrypt_native = cast128_decrypt_native;
ctx->alg_encrypt_wrapper = cast128_encrypt_wrapper;
ctx->alg_decrypt_wrapper = cast128_decrypt_wrapper;
ctx->blocksize = CAST128_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
ctx->ctx = g_new0(struct serpent_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct serpent_ctx, 1);
nkey /= 2;
serpent_set_key(ctx->ctx, nkey, key);
serpent_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
serpent_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = serpent_encrypt_native;
ctx->alg_decrypt_native = serpent_decrypt_native;
ctx->alg_encrypt_wrapper = serpent_encrypt_wrapper;
ctx->alg_decrypt_wrapper = serpent_decrypt_wrapper;
ctx->blocksize = SERPENT_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
ctx->ctx = g_new0(struct twofish_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct twofish_ctx, 1);
nkey /= 2;
twofish_set_key(ctx->ctx, nkey, key);
twofish_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
twofish_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = twofish_encrypt_native;
ctx->alg_decrypt_native = twofish_decrypt_native;
ctx->alg_encrypt_wrapper = twofish_encrypt_wrapper;
ctx->alg_decrypt_wrapper = twofish_decrypt_wrapper;
ctx->blocksize = TWOFISH_BLOCK_SIZE;
break;
default:
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
goto error;
}
if (mode == QCRYPTO_CIPHER_MODE_XTS &&
ctx->blocksize != XTS_BLOCK_SIZE) {
error_setg(errp, "Cipher block size %zu must equal XTS block size %d",
ctx->blocksize, XTS_BLOCK_SIZE);
goto error;
}
ctx->iv = g_new0(uint8_t, ctx->blocksize);
cipher->opaque = ctx;
return cipher;
error:
g_free(cipher);
g_free(ctx);
return NULL;
}
| true | qemu | d4c64800bbe1332328695a551b84ae68590c90fd | QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
QCryptoCipherMode mode,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipher *cipher;
QCryptoCipherNettle *ctx;
uint8_t *rfbkey;
switch (mode) {
case QCRYPTO_CIPHER_MODE_ECB:
case QCRYPTO_CIPHER_MODE_CBC:
case QCRYPTO_CIPHER_MODE_XTS:
case QCRYPTO_CIPHER_MODE_CTR:
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
return NULL;
}
if (!qcrypto_cipher_validate_key_length(alg, mode, nkey, errp)) {
return NULL;
}
cipher = g_new0(QCryptoCipher, 1);
cipher->alg = alg;
cipher->mode = mode;
ctx = g_new0(QCryptoCipherNettle, 1);
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES_RFB:
ctx->ctx = g_new0(struct des_ctx, 1);
rfbkey = qcrypto_cipher_munge_des_rfb_key(key, nkey);
des_set_key(ctx->ctx, rfbkey);
g_free(rfbkey);
ctx->alg_encrypt_native = des_encrypt_native;
ctx->alg_decrypt_native = des_decrypt_native;
ctx->alg_encrypt_wrapper = des_encrypt_wrapper;
ctx->alg_decrypt_wrapper = des_decrypt_wrapper;
ctx->blocksize = DES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
ctx->ctx = g_new0(QCryptoNettleAES, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(QCryptoNettleAES, 1);
nkey /= 2;
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->enc,
nkey, key + nkey);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->dec,
nkey, key + nkey);
} else {
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
}
ctx->alg_encrypt_native = aes_encrypt_native;
ctx->alg_decrypt_native = aes_decrypt_native;
ctx->alg_encrypt_wrapper = aes_encrypt_wrapper;
ctx->alg_decrypt_wrapper = aes_decrypt_wrapper;
ctx->blocksize = AES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_CAST5_128:
ctx->ctx = g_new0(struct cast128_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct cast128_ctx, 1);
nkey /= 2;
cast5_set_key(ctx->ctx, nkey, key);
cast5_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
cast5_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = cast128_encrypt_native;
ctx->alg_decrypt_native = cast128_decrypt_native;
ctx->alg_encrypt_wrapper = cast128_encrypt_wrapper;
ctx->alg_decrypt_wrapper = cast128_decrypt_wrapper;
ctx->blocksize = CAST128_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
ctx->ctx = g_new0(struct serpent_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct serpent_ctx, 1);
nkey /= 2;
serpent_set_key(ctx->ctx, nkey, key);
serpent_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
serpent_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = serpent_encrypt_native;
ctx->alg_decrypt_native = serpent_decrypt_native;
ctx->alg_encrypt_wrapper = serpent_encrypt_wrapper;
ctx->alg_decrypt_wrapper = serpent_decrypt_wrapper;
ctx->blocksize = SERPENT_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
ctx->ctx = g_new0(struct twofish_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct twofish_ctx, 1);
nkey /= 2;
twofish_set_key(ctx->ctx, nkey, key);
twofish_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
twofish_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = twofish_encrypt_native;
ctx->alg_decrypt_native = twofish_decrypt_native;
ctx->alg_encrypt_wrapper = twofish_encrypt_wrapper;
ctx->alg_decrypt_wrapper = twofish_decrypt_wrapper;
ctx->blocksize = TWOFISH_BLOCK_SIZE;
break;
default:
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
goto error;
}
if (mode == QCRYPTO_CIPHER_MODE_XTS &&
ctx->blocksize != XTS_BLOCK_SIZE) {
error_setg(errp, "Cipher block size %zu must equal XTS block size %d",
ctx->blocksize, XTS_BLOCK_SIZE);
goto error;
}
ctx->iv = g_new0(uint8_t, ctx->blocksize);
cipher->opaque = ctx;
return cipher;
error:
g_free(cipher);
g_free(ctx);
return NULL;
}
| {
"code": [
" cipher->opaque = ctx;",
" g_free(cipher);",
" g_free(ctx);"
],
"line_no": [
321,
331,
333
]
} | QCryptoCipher *FUNC_0(QCryptoCipherAlgorithm alg,
QCryptoCipherMode mode,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipher *cipher;
QCryptoCipherNettle *ctx;
uint8_t *rfbkey;
switch (mode) {
case QCRYPTO_CIPHER_MODE_ECB:
case QCRYPTO_CIPHER_MODE_CBC:
case QCRYPTO_CIPHER_MODE_XTS:
case QCRYPTO_CIPHER_MODE_CTR:
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
return NULL;
}
if (!qcrypto_cipher_validate_key_length(alg, mode, nkey, errp)) {
return NULL;
}
cipher = g_new0(QCryptoCipher, 1);
cipher->alg = alg;
cipher->mode = mode;
ctx = g_new0(QCryptoCipherNettle, 1);
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES_RFB:
ctx->ctx = g_new0(struct des_ctx, 1);
rfbkey = qcrypto_cipher_munge_des_rfb_key(key, nkey);
des_set_key(ctx->ctx, rfbkey);
g_free(rfbkey);
ctx->alg_encrypt_native = des_encrypt_native;
ctx->alg_decrypt_native = des_decrypt_native;
ctx->alg_encrypt_wrapper = des_encrypt_wrapper;
ctx->alg_decrypt_wrapper = des_decrypt_wrapper;
ctx->blocksize = DES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
ctx->ctx = g_new0(QCryptoNettleAES, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(QCryptoNettleAES, 1);
nkey /= 2;
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->enc,
nkey, key + nkey);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->dec,
nkey, key + nkey);
} else {
aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,
nkey, key);
aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,
nkey, key);
}
ctx->alg_encrypt_native = aes_encrypt_native;
ctx->alg_decrypt_native = aes_decrypt_native;
ctx->alg_encrypt_wrapper = aes_encrypt_wrapper;
ctx->alg_decrypt_wrapper = aes_decrypt_wrapper;
ctx->blocksize = AES_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_CAST5_128:
ctx->ctx = g_new0(struct cast128_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct cast128_ctx, 1);
nkey /= 2;
cast5_set_key(ctx->ctx, nkey, key);
cast5_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
cast5_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = cast128_encrypt_native;
ctx->alg_decrypt_native = cast128_decrypt_native;
ctx->alg_encrypt_wrapper = cast128_encrypt_wrapper;
ctx->alg_decrypt_wrapper = cast128_decrypt_wrapper;
ctx->blocksize = CAST128_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
ctx->ctx = g_new0(struct serpent_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct serpent_ctx, 1);
nkey /= 2;
serpent_set_key(ctx->ctx, nkey, key);
serpent_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
serpent_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = serpent_encrypt_native;
ctx->alg_decrypt_native = serpent_decrypt_native;
ctx->alg_encrypt_wrapper = serpent_encrypt_wrapper;
ctx->alg_decrypt_wrapper = serpent_decrypt_wrapper;
ctx->blocksize = SERPENT_BLOCK_SIZE;
break;
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
ctx->ctx = g_new0(struct twofish_ctx, 1);
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
ctx->ctx_tweak = g_new0(struct twofish_ctx, 1);
nkey /= 2;
twofish_set_key(ctx->ctx, nkey, key);
twofish_set_key(ctx->ctx_tweak, nkey, key + nkey);
} else {
twofish_set_key(ctx->ctx, nkey, key);
}
ctx->alg_encrypt_native = twofish_encrypt_native;
ctx->alg_decrypt_native = twofish_decrypt_native;
ctx->alg_encrypt_wrapper = twofish_encrypt_wrapper;
ctx->alg_decrypt_wrapper = twofish_decrypt_wrapper;
ctx->blocksize = TWOFISH_BLOCK_SIZE;
break;
default:
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
goto error;
}
if (mode == QCRYPTO_CIPHER_MODE_XTS &&
ctx->blocksize != XTS_BLOCK_SIZE) {
error_setg(errp, "Cipher block size %zu must equal XTS block size %d",
ctx->blocksize, XTS_BLOCK_SIZE);
goto error;
}
ctx->iv = g_new0(uint8_t, ctx->blocksize);
cipher->opaque = ctx;
return cipher;
error:
g_free(cipher);
g_free(ctx);
return NULL;
}
| [
"QCryptoCipher *FUNC_0(QCryptoCipherAlgorithm alg,\nQCryptoCipherMode mode,\nconst uint8_t *key, size_t nkey,\nError **errp)\n{",
"QCryptoCipher *cipher;",
"QCryptoCipherNettle *ctx;",
"uint8_t *rfbkey;",
"switch (mode) {",
"case QCRYPTO_CIPHER_MODE_ECB:\ncase QCRYPTO_CIPHER_MODE_CBC:\ncase QCRYPTO_CIPHER_MODE_XTS:\ncase QCRYPTO_CIPHER_MODE_CTR:\nbreak;",
"default:\nerror_setg(errp, \"Unsupported cipher mode %s\",\nQCryptoCipherMode_lookup[mode]);",
"return NULL;",
"}",
"if (!qcrypto_cipher_validate_key_length(alg, mode, nkey, errp)) {",
"return NULL;",
"}",
"cipher = g_new0(QCryptoCipher, 1);",
"cipher->alg = alg;",
"cipher->mode = mode;",
"ctx = g_new0(QCryptoCipherNettle, 1);",
"switch (alg) {",
"case QCRYPTO_CIPHER_ALG_DES_RFB:\nctx->ctx = g_new0(struct des_ctx, 1);",
"rfbkey = qcrypto_cipher_munge_des_rfb_key(key, nkey);",
"des_set_key(ctx->ctx, rfbkey);",
"g_free(rfbkey);",
"ctx->alg_encrypt_native = des_encrypt_native;",
"ctx->alg_decrypt_native = des_decrypt_native;",
"ctx->alg_encrypt_wrapper = des_encrypt_wrapper;",
"ctx->alg_decrypt_wrapper = des_decrypt_wrapper;",
"ctx->blocksize = DES_BLOCK_SIZE;",
"break;",
"case QCRYPTO_CIPHER_ALG_AES_128:\ncase QCRYPTO_CIPHER_ALG_AES_192:\ncase QCRYPTO_CIPHER_ALG_AES_256:\nctx->ctx = g_new0(QCryptoNettleAES, 1);",
"if (mode == QCRYPTO_CIPHER_MODE_XTS) {",
"ctx->ctx_tweak = g_new0(QCryptoNettleAES, 1);",
"nkey /= 2;",
"aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,\nnkey, key);",
"aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,\nnkey, key);",
"aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->enc,\nnkey, key + nkey);",
"aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx_tweak)->dec,\nnkey, key + nkey);",
"} else {",
"aes_set_encrypt_key(&((QCryptoNettleAES *)ctx->ctx)->enc,\nnkey, key);",
"aes_set_decrypt_key(&((QCryptoNettleAES *)ctx->ctx)->dec,\nnkey, key);",
"}",
"ctx->alg_encrypt_native = aes_encrypt_native;",
"ctx->alg_decrypt_native = aes_decrypt_native;",
"ctx->alg_encrypt_wrapper = aes_encrypt_wrapper;",
"ctx->alg_decrypt_wrapper = aes_decrypt_wrapper;",
"ctx->blocksize = AES_BLOCK_SIZE;",
"break;",
"case QCRYPTO_CIPHER_ALG_CAST5_128:\nctx->ctx = g_new0(struct cast128_ctx, 1);",
"if (mode == QCRYPTO_CIPHER_MODE_XTS) {",
"ctx->ctx_tweak = g_new0(struct cast128_ctx, 1);",
"nkey /= 2;",
"cast5_set_key(ctx->ctx, nkey, key);",
"cast5_set_key(ctx->ctx_tweak, nkey, key + nkey);",
"} else {",
"cast5_set_key(ctx->ctx, nkey, key);",
"}",
"ctx->alg_encrypt_native = cast128_encrypt_native;",
"ctx->alg_decrypt_native = cast128_decrypt_native;",
"ctx->alg_encrypt_wrapper = cast128_encrypt_wrapper;",
"ctx->alg_decrypt_wrapper = cast128_decrypt_wrapper;",
"ctx->blocksize = CAST128_BLOCK_SIZE;",
"break;",
"case QCRYPTO_CIPHER_ALG_SERPENT_128:\ncase QCRYPTO_CIPHER_ALG_SERPENT_192:\ncase QCRYPTO_CIPHER_ALG_SERPENT_256:\nctx->ctx = g_new0(struct serpent_ctx, 1);",
"if (mode == QCRYPTO_CIPHER_MODE_XTS) {",
"ctx->ctx_tweak = g_new0(struct serpent_ctx, 1);",
"nkey /= 2;",
"serpent_set_key(ctx->ctx, nkey, key);",
"serpent_set_key(ctx->ctx_tweak, nkey, key + nkey);",
"} else {",
"serpent_set_key(ctx->ctx, nkey, key);",
"}",
"ctx->alg_encrypt_native = serpent_encrypt_native;",
"ctx->alg_decrypt_native = serpent_decrypt_native;",
"ctx->alg_encrypt_wrapper = serpent_encrypt_wrapper;",
"ctx->alg_decrypt_wrapper = serpent_decrypt_wrapper;",
"ctx->blocksize = SERPENT_BLOCK_SIZE;",
"break;",
"case QCRYPTO_CIPHER_ALG_TWOFISH_128:\ncase QCRYPTO_CIPHER_ALG_TWOFISH_192:\ncase QCRYPTO_CIPHER_ALG_TWOFISH_256:\nctx->ctx = g_new0(struct twofish_ctx, 1);",
"if (mode == QCRYPTO_CIPHER_MODE_XTS) {",
"ctx->ctx_tweak = g_new0(struct twofish_ctx, 1);",
"nkey /= 2;",
"twofish_set_key(ctx->ctx, nkey, key);",
"twofish_set_key(ctx->ctx_tweak, nkey, key + nkey);",
"} else {",
"twofish_set_key(ctx->ctx, nkey, key);",
"}",
"ctx->alg_encrypt_native = twofish_encrypt_native;",
"ctx->alg_decrypt_native = twofish_decrypt_native;",
"ctx->alg_encrypt_wrapper = twofish_encrypt_wrapper;",
"ctx->alg_decrypt_wrapper = twofish_decrypt_wrapper;",
"ctx->blocksize = TWOFISH_BLOCK_SIZE;",
"break;",
"default:\nerror_setg(errp, \"Unsupported cipher algorithm %s\",\nQCryptoCipherAlgorithm_lookup[alg]);",
"goto error;",
"}",
"if (mode == QCRYPTO_CIPHER_MODE_XTS &&\nctx->blocksize != XTS_BLOCK_SIZE) {",
"error_setg(errp, \"Cipher block size %zu must equal XTS block size %d\",\nctx->blocksize, XTS_BLOCK_SIZE);",
"goto error;",
"}",
"ctx->iv = g_new0(uint8_t, ctx->blocksize);",
"cipher->opaque = ctx;",
"return cipher;",
"error:\ng_free(cipher);",
"g_free(ctx);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23,
25,
27,
29
],
[
31,
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
93,
95,
97,
99
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
115,
117
],
[
121,
123
],
[
125,
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159,
161
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
201,
203,
205,
207
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
247,
249,
251,
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
293,
295,
297
],
[
299
],
[
301
],
[
305,
307
],
[
309,
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
325
],
[
329,
331
],
[
333
],
[
335
],
[
337
]
]
|
15,299 | static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "minf");
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
mov_write_smhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) {
mov_write_gmhd_tag(pb, track);
} else {
mov_write_nmhd_tag(pb);
}
} else if (track->tag == MKTAG('r','t','p',' ')) {
mov_write_hmhd_tag(pb);
} else if (track->tag == MKTAG('t','m','c','d')) {
mov_write_gmhd_tag(pb, track);
}
if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
mov_write_hdlr_tag(pb, NULL);
mov_write_dinf_tag(pb);
mov_write_stbl_tag(pb, track);
return update_size(pb, pos);
}
| true | FFmpeg | da048c6d24729d3bab6ccb0ac340ea129e3e88d5 | static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0);
ffio_wfourcc(pb, "minf");
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
mov_write_smhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) {
mov_write_gmhd_tag(pb, track);
} else {
mov_write_nmhd_tag(pb);
}
} else if (track->tag == MKTAG('r','t','p',' ')) {
mov_write_hmhd_tag(pb);
} else if (track->tag == MKTAG('t','m','c','d')) {
mov_write_gmhd_tag(pb, track);
}
if (track->mode == MODE_MOV)
mov_write_hdlr_tag(pb, NULL);
mov_write_dinf_tag(pb);
mov_write_stbl_tag(pb, track);
return update_size(pb, pos);
}
| {
"code": [
" mov_write_stbl_tag(pb, track);"
],
"line_no": [
47
]
} | static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)
{
int64_t pos = avio_tell(VAR_0);
avio_wb32(VAR_0, 0);
ffio_wfourcc(VAR_0, "minf");
if (VAR_1->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(VAR_0);
else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO)
mov_write_smhd_tag(VAR_0);
else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (VAR_1->tag == MKTAG('t','e','x','t') || is_clcp_track(VAR_1)) {
mov_write_gmhd_tag(VAR_0, VAR_1);
} else {
mov_write_nmhd_tag(VAR_0);
}
} else if (VAR_1->tag == MKTAG('r','t','p',' ')) {
mov_write_hmhd_tag(VAR_0);
} else if (VAR_1->tag == MKTAG('t','m','c','d')) {
mov_write_gmhd_tag(VAR_0, VAR_1);
}
if (VAR_1->mode == MODE_MOV)
mov_write_hdlr_tag(VAR_0, NULL);
mov_write_dinf_tag(VAR_0);
mov_write_stbl_tag(VAR_0, VAR_1);
return update_size(VAR_0, pos);
}
| [
"static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)\n{",
"int64_t pos = avio_tell(VAR_0);",
"avio_wb32(VAR_0, 0);",
"ffio_wfourcc(VAR_0, \"minf\");",
"if (VAR_1->enc->codec_type == AVMEDIA_TYPE_VIDEO)\nmov_write_vmhd_tag(VAR_0);",
"else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO)\nmov_write_smhd_tag(VAR_0);",
"else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"if (VAR_1->tag == MKTAG('t','e','x','t') || is_clcp_track(VAR_1)) {",
"mov_write_gmhd_tag(VAR_0, VAR_1);",
"} else {",
"mov_write_nmhd_tag(VAR_0);",
"}",
"} else if (VAR_1->tag == MKTAG('r','t','p',' ')) {",
"mov_write_hmhd_tag(VAR_0);",
"} else if (VAR_1->tag == MKTAG('t','m','c','d')) {",
"mov_write_gmhd_tag(VAR_0, VAR_1);",
"}",
"if (VAR_1->mode == MODE_MOV)\nmov_write_hdlr_tag(VAR_0, NULL);",
"mov_write_dinf_tag(VAR_0);",
"mov_write_stbl_tag(VAR_0, VAR_1);",
"return update_size(VAR_0, pos);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
]
]
|
15,300 | static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
{
const AVPixFmtDescriptor *desc;
mfxSession session = NULL;
int iopattern = 0;
mfxVideoParam param = { { 0 } };
int frame_width = avctx->coded_width;
int frame_height = avctx->coded_height;
int ret;
desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!desc)
return AVERROR_BUG;
if (!q->async_fifo) {
q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
(sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));
if (!q->async_fifo)
return AVERROR(ENOMEM);
}
if (avctx->pix_fmt == AV_PIX_FMT_QSV && avctx->hwaccel_context) {
AVQSVContext *user_ctx = avctx->hwaccel_context;
session = user_ctx->session;
iopattern = user_ctx->iopattern;
q->ext_buffers = user_ctx->ext_buffers;
q->nb_ext_buffers = user_ctx->nb_ext_buffers;
}
if (avctx->hw_frames_ctx) {
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
if (!iopattern) {
if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
}
frame_width = frames_hwctx->surfaces[0].Info.Width;
frame_height = frames_hwctx->surfaces[0].Info.Height;
}
if (!iopattern)
iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
q->iopattern = iopattern;
ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
return ret;
}
ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
if (ret < 0)
return ret;
param.mfx.CodecId = ret;
param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, avctx->profile);
param.mfx.CodecLevel = avctx->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : avctx->level;
param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth;
param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8;
param.mfx.FrameInfo.FourCC = q->fourcc;
param.mfx.FrameInfo.Width = frame_width;
param.mfx.FrameInfo.Height = frame_height;
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
switch (avctx->field_order) {
case AV_FIELD_PROGRESSIVE:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
break;
case AV_FIELD_TT:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
break;
case AV_FIELD_BB:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
break;
default:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
break;
}
param.IOPattern = q->iopattern;
param.AsyncDepth = q->async_depth;
param.ExtParam = q->ext_buffers;
param.NumExtParam = q->nb_ext_buffers;
ret = MFXVideoDECODE_Init(q->session, ¶m);
if (ret < 0)
return ff_qsv_print_error(avctx, ret,
"Error initializing the MFX video decoder");
q->frame_info = param.mfx.FrameInfo;
return 0;
}
| true | FFmpeg | 76167140a91c081a0cf9d0abcaa4da18d1bacadb | static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
{
const AVPixFmtDescriptor *desc;
mfxSession session = NULL;
int iopattern = 0;
mfxVideoParam param = { { 0 } };
int frame_width = avctx->coded_width;
int frame_height = avctx->coded_height;
int ret;
desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!desc)
return AVERROR_BUG;
if (!q->async_fifo) {
q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
(sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));
if (!q->async_fifo)
return AVERROR(ENOMEM);
}
if (avctx->pix_fmt == AV_PIX_FMT_QSV && avctx->hwaccel_context) {
AVQSVContext *user_ctx = avctx->hwaccel_context;
session = user_ctx->session;
iopattern = user_ctx->iopattern;
q->ext_buffers = user_ctx->ext_buffers;
q->nb_ext_buffers = user_ctx->nb_ext_buffers;
}
if (avctx->hw_frames_ctx) {
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
if (!iopattern) {
if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
}
frame_width = frames_hwctx->surfaces[0].Info.Width;
frame_height = frames_hwctx->surfaces[0].Info.Height;
}
if (!iopattern)
iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
q->iopattern = iopattern;
ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
return ret;
}
ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
if (ret < 0)
return ret;
param.mfx.CodecId = ret;
param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, avctx->profile);
param.mfx.CodecLevel = avctx->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : avctx->level;
param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth;
param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8;
param.mfx.FrameInfo.FourCC = q->fourcc;
param.mfx.FrameInfo.Width = frame_width;
param.mfx.FrameInfo.Height = frame_height;
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
switch (avctx->field_order) {
case AV_FIELD_PROGRESSIVE:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
break;
case AV_FIELD_TT:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
break;
case AV_FIELD_BB:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
break;
default:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
break;
}
param.IOPattern = q->iopattern;
param.AsyncDepth = q->async_depth;
param.ExtParam = q->ext_buffers;
param.NumExtParam = q->nb_ext_buffers;
ret = MFXVideoDECODE_Init(q->session, ¶m);
if (ret < 0)
return ff_qsv_print_error(avctx, ret,
"Error initializing the MFX video decoder");
q->frame_info = param.mfx.FrameInfo;
return 0;
}
| {
"code": [
" mfxVideoParam param = { { 0 } };"
],
"line_no": [
11
]
} | static int FUNC_0(AVCodecContext *VAR_0, QSVContext *VAR_1)
{
const AVPixFmtDescriptor *VAR_2;
mfxSession session = NULL;
int VAR_3 = 0;
mfxVideoParam param = { { 0 } };
int VAR_4 = VAR_0->coded_width;
int VAR_5 = VAR_0->coded_height;
int VAR_6;
VAR_2 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);
if (!VAR_2)
return AVERROR_BUG;
if (!VAR_1->async_fifo) {
VAR_1->async_fifo = av_fifo_alloc((1 + VAR_1->async_depth) *
(sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));
if (!VAR_1->async_fifo)
return AVERROR(ENOMEM);
}
if (VAR_0->pix_fmt == AV_PIX_FMT_QSV && VAR_0->hwaccel_context) {
AVQSVContext *user_ctx = VAR_0->hwaccel_context;
session = user_ctx->session;
VAR_3 = user_ctx->VAR_3;
VAR_1->ext_buffers = user_ctx->ext_buffers;
VAR_1->nb_ext_buffers = user_ctx->nb_ext_buffers;
}
if (VAR_0->hw_frames_ctx) {
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_0->hw_frames_ctx->data;
AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
if (!VAR_3) {
if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
VAR_3 = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
VAR_3 = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
}
VAR_4 = frames_hwctx->surfaces[0].Info.Width;
VAR_5 = frames_hwctx->surfaces[0].Info.Height;
}
if (!VAR_3)
VAR_3 = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
VAR_1->VAR_3 = VAR_3;
VAR_6 = qsv_init_session(VAR_0, VAR_1, session, VAR_0->hw_frames_ctx);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error initializing an MFX session\n");
return VAR_6;
}
VAR_6 = ff_qsv_codec_id_to_mfx(VAR_0->codec_id);
if (VAR_6 < 0)
return VAR_6;
param.mfx.CodecId = VAR_6;
param.mfx.CodecProfile = ff_qsv_profile_to_mfx(VAR_0->codec_id, VAR_0->profile);
param.mfx.CodecLevel = VAR_0->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : VAR_0->level;
param.mfx.FrameInfo.BitDepthLuma = VAR_2->comp[0].depth;
param.mfx.FrameInfo.BitDepthChroma = VAR_2->comp[0].depth;
param.mfx.FrameInfo.Shift = VAR_2->comp[0].depth > 8;
param.mfx.FrameInfo.FourCC = VAR_1->fourcc;
param.mfx.FrameInfo.Width = VAR_4;
param.mfx.FrameInfo.Height = VAR_5;
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
switch (VAR_0->field_order) {
case AV_FIELD_PROGRESSIVE:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
break;
case AV_FIELD_TT:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
break;
case AV_FIELD_BB:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
break;
default:
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
break;
}
param.IOPattern = VAR_1->VAR_3;
param.AsyncDepth = VAR_1->async_depth;
param.ExtParam = VAR_1->ext_buffers;
param.NumExtParam = VAR_1->nb_ext_buffers;
VAR_6 = MFXVideoDECODE_Init(VAR_1->session, ¶m);
if (VAR_6 < 0)
return ff_qsv_print_error(VAR_0, VAR_6,
"Error initializing the MFX video decoder");
VAR_1->frame_info = param.mfx.FrameInfo;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, QSVContext *VAR_1)\n{",
"const AVPixFmtDescriptor *VAR_2;",
"mfxSession session = NULL;",
"int VAR_3 = 0;",
"mfxVideoParam param = { { 0 } };",
"int VAR_4 = VAR_0->coded_width;",
"int VAR_5 = VAR_0->coded_height;",
"int VAR_6;",
"VAR_2 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);",
"if (!VAR_2)\nreturn AVERROR_BUG;",
"if (!VAR_1->async_fifo) {",
"VAR_1->async_fifo = av_fifo_alloc((1 + VAR_1->async_depth) *\n(sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));",
"if (!VAR_1->async_fifo)\nreturn AVERROR(ENOMEM);",
"}",
"if (VAR_0->pix_fmt == AV_PIX_FMT_QSV && VAR_0->hwaccel_context) {",
"AVQSVContext *user_ctx = VAR_0->hwaccel_context;",
"session = user_ctx->session;",
"VAR_3 = user_ctx->VAR_3;",
"VAR_1->ext_buffers = user_ctx->ext_buffers;",
"VAR_1->nb_ext_buffers = user_ctx->nb_ext_buffers;",
"}",
"if (VAR_0->hw_frames_ctx) {",
"AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_0->hw_frames_ctx->data;",
"AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;",
"if (!VAR_3) {",
"if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)\nVAR_3 = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;",
"else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)\nVAR_3 = MFX_IOPATTERN_OUT_VIDEO_MEMORY;",
"}",
"VAR_4 = frames_hwctx->surfaces[0].Info.Width;",
"VAR_5 = frames_hwctx->surfaces[0].Info.Height;",
"}",
"if (!VAR_3)\nVAR_3 = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;",
"VAR_1->VAR_3 = VAR_3;",
"VAR_6 = qsv_init_session(VAR_0, VAR_1, session, VAR_0->hw_frames_ctx);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error initializing an MFX session\\n\");",
"return VAR_6;",
"}",
"VAR_6 = ff_qsv_codec_id_to_mfx(VAR_0->codec_id);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"param.mfx.CodecId = VAR_6;",
"param.mfx.CodecProfile = ff_qsv_profile_to_mfx(VAR_0->codec_id, VAR_0->profile);",
"param.mfx.CodecLevel = VAR_0->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : VAR_0->level;",
"param.mfx.FrameInfo.BitDepthLuma = VAR_2->comp[0].depth;",
"param.mfx.FrameInfo.BitDepthChroma = VAR_2->comp[0].depth;",
"param.mfx.FrameInfo.Shift = VAR_2->comp[0].depth > 8;",
"param.mfx.FrameInfo.FourCC = VAR_1->fourcc;",
"param.mfx.FrameInfo.Width = VAR_4;",
"param.mfx.FrameInfo.Height = VAR_5;",
"param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;",
"switch (VAR_0->field_order) {",
"case AV_FIELD_PROGRESSIVE:\nparam.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;",
"break;",
"case AV_FIELD_TT:\nparam.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;",
"break;",
"case AV_FIELD_BB:\nparam.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;",
"break;",
"default:\nparam.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;",
"break;",
"}",
"param.IOPattern = VAR_1->VAR_3;",
"param.AsyncDepth = VAR_1->async_depth;",
"param.ExtParam = VAR_1->ext_buffers;",
"param.NumExtParam = VAR_1->nb_ext_buffers;",
"VAR_6 = MFXVideoDECODE_Init(VAR_1->session, ¶m);",
"if (VAR_6 < 0)\nreturn ff_qsv_print_error(VAR_0, VAR_6,\n\"Error initializing the MFX video decoder\");",
"VAR_1->frame_info = param.mfx.FrameInfo;",
"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,
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
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143,
145
],
[
147
],
[
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183,
185,
187
],
[
191
],
[
195
],
[
197
]
]
|
15,302 | static void ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride,
const uint8_t *table)
{
int i;
int j;
int out = 0;
int c;
int t;
/* first line contain absolute values, other lines contain deltas */
while (out < width){
c = ir2_get_code(&ctx->gb);
if(c > 0x80) { /* we have a run */
c -= 0x80;
for (i = 0; i < c * 2; i++)
dst[out++] = 0x80;
} else { /* copy two values from table */
dst[out++] = table[c * 2];
dst[out++] = table[(c * 2) + 1];
}
}
dst += stride;
for (j = 1; j < height; j++){
out = 0;
while (out < width){
c = ir2_get_code(&ctx->gb);
if(c > 0x80) { /* we have a skip */
c -= 0x80;
for (i = 0; i < c * 2; i++) {
dst[out] = dst[out - stride];
out++;
}
} else { /* add two deltas from table */
t = dst[out - stride] + (table[c * 2] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
t = dst[out - stride] + (table[(c * 2) + 1] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
}
}
dst += stride;
}
}
| true | FFmpeg | f707a5ebba734597b1ff0810931b55b630077ab3 | static void ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride,
const uint8_t *table)
{
int i;
int j;
int out = 0;
int c;
int t;
while (out < width){
c = ir2_get_code(&ctx->gb);
if(c > 0x80) {
c -= 0x80;
for (i = 0; i < c * 2; i++)
dst[out++] = 0x80;
} else {
dst[out++] = table[c * 2];
dst[out++] = table[(c * 2) + 1];
}
}
dst += stride;
for (j = 1; j < height; j++){
out = 0;
while (out < width){
c = ir2_get_code(&ctx->gb);
if(c > 0x80) {
c -= 0x80;
for (i = 0; i < c * 2; i++) {
dst[out] = dst[out - stride];
out++;
}
} else {
t = dst[out - stride] + (table[c * 2] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
t = dst[out - stride] + (table[(c * 2) + 1] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
}
}
dst += stride;
}
}
| {
"code": [
"static void ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride,"
],
"line_no": [
1
]
} | static void FUNC_0(Ir2Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, int VAR_4,
const uint8_t *VAR_5)
{
int VAR_6;
int VAR_7;
int VAR_8 = 0;
int VAR_9;
int VAR_10;
while (VAR_8 < VAR_1){
VAR_9 = ir2_get_code(&VAR_0->gb);
if(VAR_9 > 0x80) {
VAR_9 -= 0x80;
for (VAR_6 = 0; VAR_6 < VAR_9 * 2; VAR_6++)
VAR_3[VAR_8++] = 0x80;
} else {
VAR_3[VAR_8++] = VAR_5[VAR_9 * 2];
VAR_3[VAR_8++] = VAR_5[(VAR_9 * 2) + 1];
}
}
VAR_3 += VAR_4;
for (VAR_7 = 1; VAR_7 < VAR_2; VAR_7++){
VAR_8 = 0;
while (VAR_8 < VAR_1){
VAR_9 = ir2_get_code(&VAR_0->gb);
if(VAR_9 > 0x80) {
VAR_9 -= 0x80;
for (VAR_6 = 0; VAR_6 < VAR_9 * 2; VAR_6++) {
VAR_3[VAR_8] = VAR_3[VAR_8 - VAR_4];
VAR_8++;
}
} else {
VAR_10 = VAR_3[VAR_8 - VAR_4] + (VAR_5[VAR_9 * 2] - 128);
CLAMP_TO_BYTE(VAR_10);
VAR_3[VAR_8] = VAR_10;
VAR_8++;
VAR_10 = VAR_3[VAR_8 - VAR_4] + (VAR_5[(VAR_9 * 2) + 1] - 128);
CLAMP_TO_BYTE(VAR_10);
VAR_3[VAR_8] = VAR_10;
VAR_8++;
}
}
VAR_3 += VAR_4;
}
}
| [
"static void FUNC_0(Ir2Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, int VAR_4,\nconst uint8_t *VAR_5)\n{",
"int VAR_6;",
"int VAR_7;",
"int VAR_8 = 0;",
"int VAR_9;",
"int VAR_10;",
"while (VAR_8 < VAR_1){",
"VAR_9 = ir2_get_code(&VAR_0->gb);",
"if(VAR_9 > 0x80) {",
"VAR_9 -= 0x80;",
"for (VAR_6 = 0; VAR_6 < VAR_9 * 2; VAR_6++)",
"VAR_3[VAR_8++] = 0x80;",
"} else {",
"VAR_3[VAR_8++] = VAR_5[VAR_9 * 2];",
"VAR_3[VAR_8++] = VAR_5[(VAR_9 * 2) + 1];",
"}",
"}",
"VAR_3 += VAR_4;",
"for (VAR_7 = 1; VAR_7 < VAR_2; VAR_7++){",
"VAR_8 = 0;",
"while (VAR_8 < VAR_1){",
"VAR_9 = ir2_get_code(&VAR_0->gb);",
"if(VAR_9 > 0x80) {",
"VAR_9 -= 0x80;",
"for (VAR_6 = 0; VAR_6 < VAR_9 * 2; VAR_6++) {",
"VAR_3[VAR_8] = VAR_3[VAR_8 - VAR_4];",
"VAR_8++;",
"}",
"} else {",
"VAR_10 = VAR_3[VAR_8 - VAR_4] + (VAR_5[VAR_9 * 2] - 128);",
"CLAMP_TO_BYTE(VAR_10);",
"VAR_3[VAR_8] = VAR_10;",
"VAR_8++;",
"VAR_10 = VAR_3[VAR_8 - VAR_4] + (VAR_5[(VAR_9 * 2) + 1] - 128);",
"CLAMP_TO_BYTE(VAR_10);",
"VAR_3[VAR_8] = VAR_10;",
"VAR_8++;",
"}",
"}",
"VAR_3 += VAR_4;",
"}",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
]
]
|
15,303 | int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu)
{
if (cap_has_mp_state) {
struct kvm_mp_state mp_state = {
.mp_state =
cpu->powered_off ? KVM_MP_STATE_STOPPED : KVM_MP_STATE_RUNNABLE
};
int ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MP_STATE, &mp_state);
if (ret) {
fprintf(stderr, "%s: failed to set MP_STATE %d/%s\n",
__func__, ret, strerror(-ret));
return -1;
}
}
return 0;
}
| true | qemu | 062ba099e01ff1474be98c0a4f3da351efab5d9d | int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu)
{
if (cap_has_mp_state) {
struct kvm_mp_state mp_state = {
.mp_state =
cpu->powered_off ? KVM_MP_STATE_STOPPED : KVM_MP_STATE_RUNNABLE
};
int ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MP_STATE, &mp_state);
if (ret) {
fprintf(stderr, "%s: failed to set MP_STATE %d/%s\n",
__func__, ret, strerror(-ret));
return -1;
}
}
return 0;
}
| {
"code": [
" .mp_state =",
" cpu->powered_off ? KVM_MP_STATE_STOPPED : KVM_MP_STATE_RUNNABLE"
],
"line_no": [
9,
11
]
} | int FUNC_0(ARMCPU *VAR_0)
{
if (cap_has_mp_state) {
struct kvm_mp_state VAR_1 = {
.VAR_1 =
VAR_0->powered_off ? KVM_MP_STATE_STOPPED : KVM_MP_STATE_RUNNABLE
};
int VAR_2 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_SET_MP_STATE, &VAR_1);
if (VAR_2) {
fprintf(stderr, "%s: failed to set MP_STATE %d/%s\n",
__func__, VAR_2, strerror(-VAR_2));
return -1;
}
}
return 0;
}
| [
"int FUNC_0(ARMCPU *VAR_0)\n{",
"if (cap_has_mp_state) {",
"struct kvm_mp_state VAR_1 = {",
".VAR_1 =\nVAR_0->powered_off ? KVM_MP_STATE_STOPPED : KVM_MP_STATE_RUNNABLE\n};",
"int VAR_2 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_SET_MP_STATE, &VAR_1);",
"if (VAR_2) {",
"fprintf(stderr, \"%s: failed to set MP_STATE %d/%s\\n\",\n__func__, VAR_2, strerror(-VAR_2));",
"return -1;",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
]
]
|
15,304 | void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
bool assign, bool set_handler)
{
if (assign && set_handler) {
aio_set_event_notifier(ctx, &vq->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
}
if (!assign) {
/* Test and clear notifier before after disabling event,
* in case poll callback didn't have time to run. */
virtio_queue_host_notifier_read(&vq->host_notifier);
}
}
| true | qemu | 344dc16fae0cb6a011aa5befffc8e7d520b11d5d | void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
bool assign, bool set_handler)
{
if (assign && set_handler) {
aio_set_event_notifier(ctx, &vq->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
}
if (!assign) {
virtio_queue_host_notifier_read(&vq->host_notifier);
}
}
| {
"code": [
" virtio_queue_host_notifier_read);",
" virtio_queue_host_notifier_read(&vq->host_notifier);"
],
"line_no": [
11,
25
]
} | void FUNC_0(VirtQueue *VAR_0, AioContext *VAR_1,
bool VAR_2, bool VAR_3)
{
if (VAR_2 && VAR_3) {
aio_set_event_notifier(VAR_1, &VAR_0->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
aio_set_event_notifier(VAR_1, &VAR_0->host_notifier, true, NULL);
}
if (!VAR_2) {
virtio_queue_host_notifier_read(&VAR_0->host_notifier);
}
}
| [
"void FUNC_0(VirtQueue *VAR_0, AioContext *VAR_1,\nbool VAR_2, bool VAR_3)\n{",
"if (VAR_2 && VAR_3) {",
"aio_set_event_notifier(VAR_1, &VAR_0->host_notifier, true,\nvirtio_queue_host_notifier_read);",
"} else {",
"aio_set_event_notifier(VAR_1, &VAR_0->host_notifier, true, NULL);",
"}",
"if (!VAR_2) {",
"virtio_queue_host_notifier_read(&VAR_0->host_notifier);",
"}",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
]
]
|
15,305 | av_cold int swr_init(struct SwrContext *s){
int ret;
char l1[1024], l2[1024];
clear_context(s);
if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
return AVERROR(EINVAL);
}
if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
return AVERROR(EINVAL);
}
s->out.ch_count = s-> user_out_ch_count;
s-> in.ch_count = s-> user_in_ch_count;
s->used_ch_count = s->user_used_ch_count;
s-> in_ch_layout = s-> user_in_ch_layout;
s->out_ch_layout = s->user_out_ch_layout;
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
s->in_ch_layout = 0;
}
if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Output channel layout 0x%"PRIx64" is invalid or unsupported.\n", s->out_ch_layout);
s->out_ch_layout = 0;
}
switch(s->engine){
#if CONFIG_LIBSOXR
case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
#endif
case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;
default:
av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n");
return AVERROR(EINVAL);
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
s-> in_ch_layout= 0;
}
if(!s-> in_ch_layout)
s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);
if(!s->out_ch_layout)
s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 ||
s->rematrix_custom;
if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){
if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){
s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
}else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P
&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P
&& !s->rematrix
&& s->engine != SWR_ENGINE_SOXR){
s->int_sample_fmt= AV_SAMPLE_FMT_S32P;
}else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){
s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
}else{
av_log(s, AV_LOG_DEBUG, "Using double precision mode\n");
s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;
}
}
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&&s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&&s->int_sample_fmt != AV_SAMPLE_FMT_DBLP){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT/DBL is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
return AVERROR(EINVAL);
}
set_audiodata_fmt(&s-> in, s-> in_sample_fmt);
set_audiodata_fmt(&s->out, s->out_sample_fmt);
if (s->firstpts_in_samples != AV_NOPTS_VALUE) {
if (!s->async && s->min_compensation >= FLT_MAX/2)
s->async = 1;
s->firstpts =
s->outpts = s->firstpts_in_samples * s->out_sample_rate;
} else
s->firstpts = AV_NOPTS_VALUE;
if (s->async) {
if (s->min_compensation >= FLT_MAX/2)
s->min_compensation = 0.001;
if (s->async > 1.0001) {
s->max_soft_compensation = s->async / (double) s->in_sample_rate;
}
}
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby);
if (!s->resample) {
av_log(s, AV_LOG_ERROR, "Failed to initilaize resampler\n");
return AVERROR(ENOMEM);
}
}else
s->resampler->free(&s->resample);
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&& s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&& s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&& s->int_sample_fmt != AV_SAMPLE_FMT_DBLP
&& s->resample){
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16/s32/flt/dbl\n");
return -1;
}
#define RSC 1 //FIXME finetune
if(!s-> in.ch_count)
s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(!s->out.ch_count)
s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
if(!s-> in.ch_count){
av_assert0(!s->in_ch_layout);
av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
return -1;
}
av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
return AVERROR(EINVAL);
}
if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
return AVERROR(EINVAL);
}
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
"but there is not enough information to do it\n", l1, l2);
return -1;
}
av_assert0(s->used_ch_count);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->in_buffer= s->in;
s->silence = s->in;
s->drop_temp= s->out;
if(!s->resample && !s->rematrix && !s->channel_map && !s->dither.method){
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
return 0;
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
if (!s->in_convert || !s->out_convert)
return AVERROR(ENOMEM);
s->postin= s->in;
s->preout= s->out;
s->midbuf= s->in;
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count= s->used_ch_count;
if(s->resample)
s->in_buffer.ch_count= s->used_ch_count;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
if(s->resample)
s->in_buffer.ch_count = s->out.ch_count;
}
set_audiodata_fmt(&s->postin, s->int_sample_fmt);
set_audiodata_fmt(&s->midbuf, s->int_sample_fmt);
set_audiodata_fmt(&s->preout, s->int_sample_fmt);
if(s->resample){
set_audiodata_fmt(&s->in_buffer, s->int_sample_fmt);
}
if ((ret = swri_dither_init(s, s->out_sample_fmt, s->int_sample_fmt)) < 0)
return ret;
if(s->rematrix || s->dither.method)
return swri_rematrix_init(s);
return 0;
}
| true | FFmpeg | c3f87f7545d42520921bc448b9fbd7324c574e49 | av_cold int swr_init(struct SwrContext *s){
int ret;
char l1[1024], l2[1024];
clear_context(s);
if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
return AVERROR(EINVAL);
}
if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
return AVERROR(EINVAL);
}
s->out.ch_count = s-> user_out_ch_count;
s-> in.ch_count = s-> user_in_ch_count;
s->used_ch_count = s->user_used_ch_count;
s-> in_ch_layout = s-> user_in_ch_layout;
s->out_ch_layout = s->user_out_ch_layout;
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
s->in_ch_layout = 0;
}
if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Output channel layout 0x%"PRIx64" is invalid or unsupported.\n", s->out_ch_layout);
s->out_ch_layout = 0;
}
switch(s->engine){
#if CONFIG_LIBSOXR
case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
#endif
case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;
default:
av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n");
return AVERROR(EINVAL);
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
s-> in_ch_layout= 0;
}
if(!s-> in_ch_layout)
s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);
if(!s->out_ch_layout)
s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 ||
s->rematrix_custom;
if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){
if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){
s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
}else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P
&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P
&& !s->rematrix
&& s->engine != SWR_ENGINE_SOXR){
s->int_sample_fmt= AV_SAMPLE_FMT_S32P;
}else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){
s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
}else{
av_log(s, AV_LOG_DEBUG, "Using double precision mode\n");
s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;
}
}
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&&s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&&s->int_sample_fmt != AV_SAMPLE_FMT_DBLP){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT/DBL is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
return AVERROR(EINVAL);
}
set_audiodata_fmt(&s-> in, s-> in_sample_fmt);
set_audiodata_fmt(&s->out, s->out_sample_fmt);
if (s->firstpts_in_samples != AV_NOPTS_VALUE) {
if (!s->async && s->min_compensation >= FLT_MAX/2)
s->async = 1;
s->firstpts =
s->outpts = s->firstpts_in_samples * s->out_sample_rate;
} else
s->firstpts = AV_NOPTS_VALUE;
if (s->async) {
if (s->min_compensation >= FLT_MAX/2)
s->min_compensation = 0.001;
if (s->async > 1.0001) {
s->max_soft_compensation = s->async / (double) s->in_sample_rate;
}
}
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby);
if (!s->resample) {
av_log(s, AV_LOG_ERROR, "Failed to initilaize resampler\n");
return AVERROR(ENOMEM);
}
}else
s->resampler->free(&s->resample);
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&& s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&& s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&& s->int_sample_fmt != AV_SAMPLE_FMT_DBLP
&& s->resample){
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16/s32/flt/dbl\n");
return -1;
}
#define RSC 1
if(!s-> in.ch_count)
s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(!s->out.ch_count)
s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
if(!s-> in.ch_count){
av_assert0(!s->in_ch_layout);
av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
return -1;
}
av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
return AVERROR(EINVAL);
}
if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
return AVERROR(EINVAL);
}
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
"but there is not enough information to do it\n", l1, l2);
return -1;
}
av_assert0(s->used_ch_count);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->in_buffer= s->in;
s->silence = s->in;
s->drop_temp= s->out;
if(!s->resample && !s->rematrix && !s->channel_map && !s->dither.method){
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
return 0;
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
if (!s->in_convert || !s->out_convert)
return AVERROR(ENOMEM);
s->postin= s->in;
s->preout= s->out;
s->midbuf= s->in;
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count= s->used_ch_count;
if(s->resample)
s->in_buffer.ch_count= s->used_ch_count;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
if(s->resample)
s->in_buffer.ch_count = s->out.ch_count;
}
set_audiodata_fmt(&s->postin, s->int_sample_fmt);
set_audiodata_fmt(&s->midbuf, s->int_sample_fmt);
set_audiodata_fmt(&s->preout, s->int_sample_fmt);
if(s->resample){
set_audiodata_fmt(&s->in_buffer, s->int_sample_fmt);
}
if ((ret = swri_dither_init(s, s->out_sample_fmt, s->int_sample_fmt)) < 0)
return ret;
if(s->rematrix || s->dither.method)
return swri_rematrix_init(s);
return 0;
}
| {
"code": [
" return -1;",
" return -1;",
" return AVERROR(EINVAL);",
" return AVERROR(EINVAL);",
" return -1;",
" if (!s->in_convert || !s->out_convert)",
" return AVERROR(ENOMEM);",
" return ret;",
" if(s->rematrix || s->dither.method)",
" return swri_rematrix_init(s);"
],
"line_no": [
231,
231,
17,
17,
231,
337,
339,
393,
397,
399
]
} | av_cold int FUNC_0(struct SwrContext *s){
int VAR_0;
char VAR_1[1024], VAR_2[1024];
clear_context(s);
if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
return AVERROR(EINVAL);
}
if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
return AVERROR(EINVAL);
}
s->out.ch_count = s-> user_out_ch_count;
s-> in.ch_count = s-> user_in_ch_count;
s->used_ch_count = s->user_used_ch_count;
s-> in_ch_layout = s-> user_in_ch_layout;
s->out_ch_layout = s->user_out_ch_layout;
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
s->in_ch_layout = 0;
}
if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Output channel layout 0x%"PRIx64" is invalid or unsupported.\n", s->out_ch_layout);
s->out_ch_layout = 0;
}
switch(s->engine){
#if CONFIG_LIBSOXR
case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
#endif
case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;
default:
av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n");
return AVERROR(EINVAL);
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
s-> in_ch_layout= 0;
}
if(!s-> in_ch_layout)
s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);
if(!s->out_ch_layout)
s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 ||
s->rematrix_custom;
if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){
if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){
s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
}else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P
&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P
&& !s->rematrix
&& s->engine != SWR_ENGINE_SOXR){
s->int_sample_fmt= AV_SAMPLE_FMT_S32P;
}else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){
s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
}else{
av_log(s, AV_LOG_DEBUG, "Using double precision mode\n");
s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;
}
}
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&&s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&&s->int_sample_fmt != AV_SAMPLE_FMT_DBLP){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT/DBL is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
return AVERROR(EINVAL);
}
set_audiodata_fmt(&s-> in, s-> in_sample_fmt);
set_audiodata_fmt(&s->out, s->out_sample_fmt);
if (s->firstpts_in_samples != AV_NOPTS_VALUE) {
if (!s->async && s->min_compensation >= FLT_MAX/2)
s->async = 1;
s->firstpts =
s->outpts = s->firstpts_in_samples * s->out_sample_rate;
} else
s->firstpts = AV_NOPTS_VALUE;
if (s->async) {
if (s->min_compensation >= FLT_MAX/2)
s->min_compensation = 0.001;
if (s->async > 1.0001) {
s->max_soft_compensation = s->async / (double) s->in_sample_rate;
}
}
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby);
if (!s->resample) {
av_log(s, AV_LOG_ERROR, "Failed to initilaize resampler\n");
return AVERROR(ENOMEM);
}
}else
s->resampler->free(&s->resample);
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&& s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&& s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&& s->int_sample_fmt != AV_SAMPLE_FMT_DBLP
&& s->resample){
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16/s32/flt/dbl\n");
return -1;
}
#define RSC 1
if(!s-> in.ch_count)
s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(!s->out.ch_count)
s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
if(!s-> in.ch_count){
av_assert0(!s->in_ch_layout);
av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
return -1;
}
av_get_channel_layout_string(VAR_1, sizeof(VAR_1), s-> in.ch_count, s-> in_ch_layout);
av_get_channel_layout_string(VAR_2, sizeof(VAR_2), s->out.ch_count, s->out_ch_layout);
if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", VAR_2, s->out.ch_count);
return AVERROR(EINVAL);
}
if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", VAR_1, s->used_ch_count);
return AVERROR(EINVAL);
}
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
"but there is not enough information to do it\n", VAR_1, VAR_2);
return -1;
}
av_assert0(s->used_ch_count);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->in_buffer= s->in;
s->silence = s->in;
s->drop_temp= s->out;
if(!s->resample && !s->rematrix && !s->channel_map && !s->dither.method){
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
return 0;
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
if (!s->in_convert || !s->out_convert)
return AVERROR(ENOMEM);
s->postin= s->in;
s->preout= s->out;
s->midbuf= s->in;
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count= s->used_ch_count;
if(s->resample)
s->in_buffer.ch_count= s->used_ch_count;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
if(s->resample)
s->in_buffer.ch_count = s->out.ch_count;
}
set_audiodata_fmt(&s->postin, s->int_sample_fmt);
set_audiodata_fmt(&s->midbuf, s->int_sample_fmt);
set_audiodata_fmt(&s->preout, s->int_sample_fmt);
if(s->resample){
set_audiodata_fmt(&s->in_buffer, s->int_sample_fmt);
}
if ((VAR_0 = swri_dither_init(s, s->out_sample_fmt, s->int_sample_fmt)) < 0)
return VAR_0;
if(s->rematrix || s->dither.method)
return swri_rematrix_init(s);
return 0;
}
| [
"av_cold int FUNC_0(struct SwrContext *s){",
"int VAR_0;",
"char VAR_1[1024], VAR_2[1024];",
"clear_context(s);",
"if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){",
"av_log(s, AV_LOG_ERROR, \"Requested input sample format %d is invalid\\n\", s->in_sample_fmt);",
"return AVERROR(EINVAL);",
"}",
"if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){",
"av_log(s, AV_LOG_ERROR, \"Requested output sample format %d is invalid\\n\", s->out_sample_fmt);",
"return AVERROR(EINVAL);",
"}",
"s->out.ch_count = s-> user_out_ch_count;",
"s-> in.ch_count = s-> user_in_ch_count;",
"s->used_ch_count = s->user_used_ch_count;",
"s-> in_ch_layout = s-> user_in_ch_layout;",
"s->out_ch_layout = s->user_out_ch_layout;",
"if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {",
"av_log(s, AV_LOG_WARNING, \"Input channel layout 0x%\"PRIx64\" is invalid or unsupported.\\n\", s-> in_ch_layout);",
"s->in_ch_layout = 0;",
"}",
"if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) {",
"av_log(s, AV_LOG_WARNING, \"Output channel layout 0x%\"PRIx64\" is invalid or unsupported.\\n\", s->out_ch_layout);",
"s->out_ch_layout = 0;",
"}",
"switch(s->engine){",
"#if CONFIG_LIBSOXR\ncase SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;",
"#endif\ncase SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;",
"default:\nav_log(s, AV_LOG_ERROR, \"Requested resampling engine is unavailable\\n\");",
"return AVERROR(EINVAL);",
"}",
"if(!s->used_ch_count)\ns->used_ch_count= s->in.ch_count;",
"if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){",
"av_log(s, AV_LOG_WARNING, \"Input channel layout has a different number of channels than the number of used channels, ignoring layout\\n\");",
"s-> in_ch_layout= 0;",
"}",
"if(!s-> in_ch_layout)\ns-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);",
"if(!s->out_ch_layout)\ns->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);",
"s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 ||\ns->rematrix_custom;",
"if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){",
"if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){",
"s->int_sample_fmt= AV_SAMPLE_FMT_S16P;",
"}else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P",
"&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P\n&& !s->rematrix\n&& s->engine != SWR_ENGINE_SOXR){",
"s->int_sample_fmt= AV_SAMPLE_FMT_S32P;",
"}else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){",
"s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;",
"}else{",
"av_log(s, AV_LOG_DEBUG, \"Using double precision mode\\n\");",
"s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;",
"}",
"}",
"if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P\n&&s->int_sample_fmt != AV_SAMPLE_FMT_S32P\n&&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP\n&&s->int_sample_fmt != AV_SAMPLE_FMT_DBLP){",
"av_log(s, AV_LOG_ERROR, \"Requested sample format %s is not supported internally, S16/S32/FLT/DBL is supported\\n\", av_get_sample_fmt_name(s->int_sample_fmt));",
"return AVERROR(EINVAL);",
"}",
"set_audiodata_fmt(&s-> in, s-> in_sample_fmt);",
"set_audiodata_fmt(&s->out, s->out_sample_fmt);",
"if (s->firstpts_in_samples != AV_NOPTS_VALUE) {",
"if (!s->async && s->min_compensation >= FLT_MAX/2)\ns->async = 1;",
"s->firstpts =\ns->outpts = s->firstpts_in_samples * s->out_sample_rate;",
"} else",
"s->firstpts = AV_NOPTS_VALUE;",
"if (s->async) {",
"if (s->min_compensation >= FLT_MAX/2)\ns->min_compensation = 0.001;",
"if (s->async > 1.0001) {",
"s->max_soft_compensation = s->async / (double) s->in_sample_rate;",
"}",
"}",
"if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){",
"s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby);",
"if (!s->resample) {",
"av_log(s, AV_LOG_ERROR, \"Failed to initilaize resampler\\n\");",
"return AVERROR(ENOMEM);",
"}",
"}else",
"s->resampler->free(&s->resample);",
"if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P\n&& s->int_sample_fmt != AV_SAMPLE_FMT_S32P\n&& s->int_sample_fmt != AV_SAMPLE_FMT_FLTP\n&& s->int_sample_fmt != AV_SAMPLE_FMT_DBLP\n&& s->resample){",
"av_log(s, AV_LOG_ERROR, \"Resampling only supported with internal s16/s32/flt/dbl\\n\");",
"return -1;",
"}",
"#define RSC 1\nif(!s-> in.ch_count)\ns-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);",
"if(!s->used_ch_count)\ns->used_ch_count= s->in.ch_count;",
"if(!s->out.ch_count)\ns->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);",
"if(!s-> in.ch_count){",
"av_assert0(!s->in_ch_layout);",
"av_log(s, AV_LOG_ERROR, \"Input channel count and layout are unset\\n\");",
"return -1;",
"}",
"av_get_channel_layout_string(VAR_1, sizeof(VAR_1), s-> in.ch_count, s-> in_ch_layout);",
"av_get_channel_layout_string(VAR_2, sizeof(VAR_2), s->out.ch_count, s->out_ch_layout);",
"if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {",
"av_log(s, AV_LOG_ERROR, \"Output channel layout %s mismatches specified channel count %d\\n\", VAR_2, s->out.ch_count);",
"return AVERROR(EINVAL);",
"}",
"if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {",
"av_log(s, AV_LOG_ERROR, \"Input channel layout %s mismatches specified channel count %d\\n\", VAR_1, s->used_ch_count);",
"return AVERROR(EINVAL);",
"}",
"if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {",
"av_log(s, AV_LOG_ERROR, \"Rematrix is needed between %s and %s \"\n\"but there is not enough information to do it\\n\", VAR_1, VAR_2);",
"return -1;",
"}",
"av_assert0(s->used_ch_count);",
"av_assert0(s->out.ch_count);",
"s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;",
"s->in_buffer= s->in;",
"s->silence = s->in;",
"s->drop_temp= s->out;",
"if(!s->resample && !s->rematrix && !s->channel_map && !s->dither.method){",
"s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,\ns-> in_sample_fmt, s-> in.ch_count, NULL, 0);",
"return 0;",
"}",
"s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,\ns-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);",
"s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,\ns->int_sample_fmt, s->out.ch_count, NULL, 0);",
"if (!s->in_convert || !s->out_convert)\nreturn AVERROR(ENOMEM);",
"s->postin= s->in;",
"s->preout= s->out;",
"s->midbuf= s->in;",
"if(s->channel_map){",
"s->postin.ch_count=\ns->midbuf.ch_count= s->used_ch_count;",
"if(s->resample)\ns->in_buffer.ch_count= s->used_ch_count;",
"}",
"if(!s->resample_first){",
"s->midbuf.ch_count= s->out.ch_count;",
"if(s->resample)\ns->in_buffer.ch_count = s->out.ch_count;",
"}",
"set_audiodata_fmt(&s->postin, s->int_sample_fmt);",
"set_audiodata_fmt(&s->midbuf, s->int_sample_fmt);",
"set_audiodata_fmt(&s->preout, s->int_sample_fmt);",
"if(s->resample){",
"set_audiodata_fmt(&s->in_buffer, s->int_sample_fmt);",
"}",
"if ((VAR_0 = swri_dither_init(s, s->out_sample_fmt, s->int_sample_fmt)) < 0)\nreturn VAR_0;",
"if(s->rematrix || s->dither.method)\nreturn swri_rematrix_init(s);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
85,
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
105,
107
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219,
221,
223,
225,
227
],
[
229
],
[
231
],
[
233
],
[
237,
239,
241
],
[
243,
245
],
[
247,
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317,
319
],
[
321
],
[
323
],
[
327,
329
],
[
331,
333
],
[
337,
339
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353,
355
],
[
357,
359
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
375
],
[
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
391,
393
],
[
397,
399
],
[
403
],
[
405
]
]
|
15,306 | static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num)
{
MpegEncContext *s = &v->s;
int mb_cbp = v->cbp[s->mb_x - s->mb_stride],
block_cbp = mb_cbp >> (block_num * 4), bottom_cbp,
mb_is_intra = v->is_intra[s->mb_x - s->mb_stride],
block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
uint8_t *dst;
if (block_num > 3) {
dst = s->dest[block_num - 3];
} else {
dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
}
if (s->mb_y != s->end_mb_y || block_num < 2) {
int16_t (*mv)[2];
int mv_stride;
if (block_num > 3) {
bottom_cbp = v->cbp[s->mb_x] >> (block_num * 4);
bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4);
mv = &v->luma_mv[s->mb_x - s->mb_stride];
mv_stride = s->mb_stride;
} else {
bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4))
: (v->cbp[s->mb_x] >> ((block_num - 2) * 4));
bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))
: (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
mv_stride = s->b8_stride;
mv = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
}
if (bottom_is_intra & 1 || block_is_intra & 1 ||
mv[0][0] != mv[mv_stride][0] || mv[0][1] != mv[mv_stride][1]) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else {
idx = ((bottom_cbp >> 2) | block_cbp) & 3;
if (idx == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
}
}
}
dst -= 4 * linesize;
ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF;
if (ttblk == TT_4X4 || ttblk == TT_8X4) {
idx = (block_cbp | (block_cbp >> 2)) & 3;
if (idx == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
}
}
}
| true | FFmpeg | a52f443714b5c2a40ed272d8445f4c39220a4b69 | static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num)
{
MpegEncContext *s = &v->s;
int mb_cbp = v->cbp[s->mb_x - s->mb_stride],
block_cbp = mb_cbp >> (block_num * 4), bottom_cbp,
mb_is_intra = v->is_intra[s->mb_x - s->mb_stride],
block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
uint8_t *dst;
if (block_num > 3) {
dst = s->dest[block_num - 3];
} else {
dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
}
if (s->mb_y != s->end_mb_y || block_num < 2) {
int16_t (*mv)[2];
int mv_stride;
if (block_num > 3) {
bottom_cbp = v->cbp[s->mb_x] >> (block_num * 4);
bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4);
mv = &v->luma_mv[s->mb_x - s->mb_stride];
mv_stride = s->mb_stride;
} else {
bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4))
: (v->cbp[s->mb_x] >> ((block_num - 2) * 4));
bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))
: (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
mv_stride = s->b8_stride;
mv = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
}
if (bottom_is_intra & 1 || block_is_intra & 1 ||
mv[0][0] != mv[mv_stride][0] || mv[0][1] != mv[mv_stride][1]) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else {
idx = ((bottom_cbp >> 2) | block_cbp) & 3;
if (idx == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
}
}
}
dst -= 4 * linesize;
ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF;
if (ttblk == TT_4X4 || ttblk == TT_8X4) {
idx = (block_cbp | (block_cbp >> 2)) & 3;
if (idx == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
}
}
}
| {
"code": [
" block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;",
" bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4);",
" bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))",
" : (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));",
" if (bottom_is_intra & 1 || block_is_intra & 1 ||"
],
"line_no": [
13,
43,
55,
57,
67
]
} | static av_always_inline void FUNC_0(VC1Context *v, int block_num)
{
MpegEncContext *s = &v->s;
int VAR_0 = v->cbp[s->mb_x - s->mb_stride],
VAR_1 = VAR_0 >> (block_num * 4), VAR_2,
VAR_3 = v->is_intra[s->mb_x - s->mb_stride],
VAR_4 = VAR_3 >> (block_num * 4), VAR_5;
int VAR_6, VAR_7 = block_num > 3 ? s->uvlinesize : s->VAR_7, VAR_8;
uint8_t *dst;
if (block_num > 3) {
dst = s->dest[block_num - 3];
} else {
dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * VAR_7;
}
if (s->mb_y != s->end_mb_y || block_num < 2) {
int16_t (*mv)[2];
int VAR_9;
if (block_num > 3) {
VAR_2 = v->cbp[s->mb_x] >> (block_num * 4);
VAR_5 = v->is_intra[s->mb_x] >> (block_num * 4);
mv = &v->luma_mv[s->mb_x - s->mb_stride];
VAR_9 = s->mb_stride;
} else {
VAR_2 = (block_num < 2) ? (VAR_0 >> ((block_num + 2) * 4))
: (v->cbp[s->mb_x] >> ((block_num - 2) * 4));
VAR_5 = (block_num < 2) ? (VAR_3 >> ((block_num + 2) * 4))
: (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
VAR_9 = s->b8_stride;
mv = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * VAR_9];
}
if (VAR_5 & 1 || VAR_4 & 1 ||
mv[0][0] != mv[VAR_9][0] || mv[0][1] != mv[VAR_9][1]) {
v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);
} else {
VAR_6 = ((VAR_2 >> 2) | VAR_1) & 3;
if (VAR_6 == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);
} else if (VAR_6) {
if (VAR_6 == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, VAR_7, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, VAR_7, v->pq);
}
}
}
dst -= 4 * VAR_7;
VAR_8 = (v->VAR_8[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF;
if (VAR_8 == TT_4X4 || VAR_8 == TT_8X4) {
VAR_6 = (VAR_1 | (VAR_1 >> 2)) & 3;
if (VAR_6 == 3) {
v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);
} else if (VAR_6) {
if (VAR_6 == 1)
v->vc1dsp.vc1_v_loop_filter4(dst + 4, VAR_7, v->pq);
else
v->vc1dsp.vc1_v_loop_filter4(dst, VAR_7, v->pq);
}
}
}
| [
"static av_always_inline void FUNC_0(VC1Context *v, int block_num)\n{",
"MpegEncContext *s = &v->s;",
"int VAR_0 = v->cbp[s->mb_x - s->mb_stride],\nVAR_1 = VAR_0 >> (block_num * 4), VAR_2,\nVAR_3 = v->is_intra[s->mb_x - s->mb_stride],\nVAR_4 = VAR_3 >> (block_num * 4), VAR_5;",
"int VAR_6, VAR_7 = block_num > 3 ? s->uvlinesize : s->VAR_7, VAR_8;",
"uint8_t *dst;",
"if (block_num > 3) {",
"dst = s->dest[block_num - 3];",
"} else {",
"dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * VAR_7;",
"}",
"if (s->mb_y != s->end_mb_y || block_num < 2) {",
"int16_t (*mv)[2];",
"int VAR_9;",
"if (block_num > 3) {",
"VAR_2 = v->cbp[s->mb_x] >> (block_num * 4);",
"VAR_5 = v->is_intra[s->mb_x] >> (block_num * 4);",
"mv = &v->luma_mv[s->mb_x - s->mb_stride];",
"VAR_9 = s->mb_stride;",
"} else {",
"VAR_2 = (block_num < 2) ? (VAR_0 >> ((block_num + 2) * 4))\n: (v->cbp[s->mb_x] >> ((block_num - 2) * 4));",
"VAR_5 = (block_num < 2) ? (VAR_3 >> ((block_num + 2) * 4))\n: (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));",
"VAR_9 = s->b8_stride;",
"mv = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * VAR_9];",
"}",
"if (VAR_5 & 1 || VAR_4 & 1 ||\nmv[0][0] != mv[VAR_9][0] || mv[0][1] != mv[VAR_9][1]) {",
"v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);",
"} else {",
"VAR_6 = ((VAR_2 >> 2) | VAR_1) & 3;",
"if (VAR_6 == 3) {",
"v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);",
"} else if (VAR_6) {",
"if (VAR_6 == 1)\nv->vc1dsp.vc1_v_loop_filter4(dst + 4, VAR_7, v->pq);",
"else\nv->vc1dsp.vc1_v_loop_filter4(dst, VAR_7, v->pq);",
"}",
"}",
"}",
"dst -= 4 * VAR_7;",
"VAR_8 = (v->VAR_8[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF;",
"if (VAR_8 == TT_4X4 || VAR_8 == TT_8X4) {",
"VAR_6 = (VAR_1 | (VAR_1 >> 2)) & 3;",
"if (VAR_6 == 3) {",
"v->vc1dsp.vc1_v_loop_filter8(dst, VAR_7, v->pq);",
"} else if (VAR_6) {",
"if (VAR_6 == 1)\nv->vc1dsp.vc1_v_loop_filter4(dst + 4, VAR_7, v->pq);",
"else\nv->vc1dsp.vc1_v_loop_filter4(dst, VAR_7, v->pq);",
"}",
"}",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
]
]
|
15,307 | int main(void)
{
int x = 0;
int i, j;
AVLFG state;
av_lfg_init(&state, 0xdeadbeef);
for (j = 0; j < 10000; j++) {
START_TIMER
for (i = 0; i < 624; i++) {
//av_log(NULL, AV_LOG_ERROR, "%X\n", av_lfg_get(&state));
x += av_lfg_get(&state);
}
STOP_TIMER("624 calls of av_lfg_get");
}
av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
/* BMG usage example */
{
double mean = 1000;
double stddev = 53;
av_lfg_init(&state, 42);
for (i = 0; i < 1000; i += 2) {
double bmg_out[2];
av_bmg_get(&state, bmg_out);
av_log(NULL, AV_LOG_INFO,
"%f\n%f\n",
bmg_out[0] * stddev + mean,
bmg_out[1] * stddev + mean);
}
}
return 0;
}
| false | FFmpeg | 0c33ceda91dd646414a2e0ec832bada5acb6b762 | int main(void)
{
int x = 0;
int i, j;
AVLFG state;
av_lfg_init(&state, 0xdeadbeef);
for (j = 0; j < 10000; j++) {
START_TIMER
for (i = 0; i < 624; i++) {
x += av_lfg_get(&state);
}
STOP_TIMER("624 calls of av_lfg_get");
}
av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
{
double mean = 1000;
double stddev = 53;
av_lfg_init(&state, 42);
for (i = 0; i < 1000; i += 2) {
double bmg_out[2];
av_bmg_get(&state, bmg_out);
av_log(NULL, AV_LOG_INFO,
"%f\n%f\n",
bmg_out[0] * stddev + mean,
bmg_out[1] * stddev + mean);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
int VAR_0 = 0;
int VAR_1, VAR_2;
AVLFG state;
av_lfg_init(&state, 0xdeadbeef);
for (VAR_2 = 0; VAR_2 < 10000; VAR_2++) {
START_TIMER
for (VAR_1 = 0; VAR_1 < 624; VAR_1++) {
VAR_0 += av_lfg_get(&state);
}
STOP_TIMER("624 calls of av_lfg_get");
}
av_log(NULL, AV_LOG_ERROR, "final value:%X\n", VAR_0);
{
double VAR_3 = 1000;
double VAR_4 = 53;
av_lfg_init(&state, 42);
for (VAR_1 = 0; VAR_1 < 1000; VAR_1 += 2) {
double VAR_5[2];
av_bmg_get(&state, VAR_5);
av_log(NULL, AV_LOG_INFO,
"%f\n%f\n",
VAR_5[0] * VAR_4 + VAR_3,
VAR_5[1] * VAR_4 + VAR_3);
}
}
return 0;
}
| [
"int FUNC_0(void)\n{",
"int VAR_0 = 0;",
"int VAR_1, VAR_2;",
"AVLFG state;",
"av_lfg_init(&state, 0xdeadbeef);",
"for (VAR_2 = 0; VAR_2 < 10000; VAR_2++) {",
"START_TIMER\nfor (VAR_1 = 0; VAR_1 < 624; VAR_1++) {",
"VAR_0 += av_lfg_get(&state);",
"}",
"STOP_TIMER(\"624 calls of av_lfg_get\");",
"}",
"av_log(NULL, AV_LOG_ERROR, \"final value:%X\\n\", VAR_0);",
"{",
"double VAR_3 = 1000;",
"double VAR_4 = 53;",
"av_lfg_init(&state, 42);",
"for (VAR_1 = 0; VAR_1 < 1000; VAR_1 += 2) {",
"double VAR_5[2];",
"av_bmg_get(&state, VAR_5);",
"av_log(NULL, AV_LOG_INFO,\n\"%f\\n%f\\n\",\nVAR_5[0] * VAR_4 + VAR_3,\nVAR_5[1] * VAR_4 + VAR_3);",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55,
57,
59,
61
],
[
63
],
[
65
],
[
69
],
[
71
]
]
|
15,308 | enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
{
while (tags->id != 0) {
if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
&& toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
&& toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
&& toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
return tags->id;
tags++;
}
return CODEC_ID_NONE;
}
| false | FFmpeg | fb7a2bf6956173eda6f9caceef8599fa4f83500d | enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
{
while (tags->id != 0) {
if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
&& toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
&& toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
&& toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
return tags->id;
tags++;
}
return CODEC_ID_NONE;
}
| {
"code": [],
"line_no": []
} | enum CodecID FUNC_0(const CodecTag *VAR_0, unsigned int VAR_1)
{
while (VAR_0->id != 0) {
if( toupper((VAR_1 >> 0)&0xFF) == toupper((VAR_0->VAR_1 >> 0)&0xFF)
&& toupper((VAR_1 >> 8)&0xFF) == toupper((VAR_0->VAR_1 >> 8)&0xFF)
&& toupper((VAR_1 >>16)&0xFF) == toupper((VAR_0->VAR_1 >>16)&0xFF)
&& toupper((VAR_1 >>24)&0xFF) == toupper((VAR_0->VAR_1 >>24)&0xFF))
return VAR_0->id;
VAR_0++;
}
return CODEC_ID_NONE;
}
| [
"enum CodecID FUNC_0(const CodecTag *VAR_0, unsigned int VAR_1)\n{",
"while (VAR_0->id != 0) {",
"if( toupper((VAR_1 >> 0)&0xFF) == toupper((VAR_0->VAR_1 >> 0)&0xFF)\n&& toupper((VAR_1 >> 8)&0xFF) == toupper((VAR_0->VAR_1 >> 8)&0xFF)\n&& toupper((VAR_1 >>16)&0xFF) == toupper((VAR_0->VAR_1 >>16)&0xFF)\n&& toupper((VAR_1 >>24)&0xFF) == toupper((VAR_0->VAR_1 >>24)&0xFF))\nreturn VAR_0->id;",
"VAR_0++;",
"}",
"return CODEC_ID_NONE;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
15,309 | static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int i;
pixel *pix = (pixel*)_pix;
const dctcoef *block = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
pix -= stride;
for(i=0; i<4; i++){
pixel v = pix[0];
pix[1*stride]= v += block[0];
pix[2*stride]= v += block[4];
pix[3*stride]= v += block[8];
pix[4*stride]= v + block[12];
pix++;
block++;
}
}
| false | FFmpeg | 1acd7d594c15aa491729c837ad3519d3469e620a | static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int i;
pixel *pix = (pixel*)_pix;
const dctcoef *block = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
pix -= stride;
for(i=0; i<4; i++){
pixel v = pix[0];
pix[1*stride]= v += block[0];
pix[2*stride]= v += block[4];
pix[3*stride]= v += block[8];
pix[4*stride]= v + block[12];
pix++;
block++;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int VAR_0;
pixel *pix = (pixel*)_pix;
const dctcoef *VAR_1 = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
pix -= stride;
for(VAR_0=0; VAR_0<4; VAR_0++){
pixel v = pix[0];
pix[1*stride]= v += VAR_1[0];
pix[2*stride]= v += VAR_1[4];
pix[3*stride]= v += VAR_1[8];
pix[4*stride]= v + VAR_1[12];
pix++;
VAR_1++;
}
}
| [
"static void FUNC_0(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,\nptrdiff_t stride)\n{",
"int VAR_0;",
"pixel *pix = (pixel*)_pix;",
"const dctcoef *VAR_1 = (const dctcoef*)_block;",
"stride >>= sizeof(pixel)-1;",
"pix -= stride;",
"for(VAR_0=0; VAR_0<4; VAR_0++){",
"pixel v = pix[0];",
"pix[1*stride]= v += VAR_1[0];",
"pix[2*stride]= v += VAR_1[4];",
"pix[3*stride]= v += VAR_1[8];",
"pix[4*stride]= v + VAR_1[12];",
"pix++;",
"VAR_1++;",
"}",
"}"
]
| [
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
]
]
|
15,310 | static void pci_bridge_cleanup_alias(MemoryRegion *alias,
MemoryRegion *parent_space)
{
memory_region_del_subregion(parent_space, alias);
memory_region_destroy(alias);
}
| true | qemu | 523a59f596a3e62f5a28eb171adba35e71310040 | static void pci_bridge_cleanup_alias(MemoryRegion *alias,
MemoryRegion *parent_space)
{
memory_region_del_subregion(parent_space, alias);
memory_region_destroy(alias);
}
| {
"code": [
"static void pci_bridge_cleanup_alias(MemoryRegion *alias,",
" MemoryRegion *parent_space)",
" memory_region_del_subregion(parent_space, alias);",
" memory_region_destroy(alias);"
],
"line_no": [
1,
3,
7,
9
]
} | static void FUNC_0(MemoryRegion *VAR_0,
MemoryRegion *VAR_1)
{
memory_region_del_subregion(VAR_1, VAR_0);
memory_region_destroy(VAR_0);
}
| [
"static void FUNC_0(MemoryRegion *VAR_0,\nMemoryRegion *VAR_1)\n{",
"memory_region_del_subregion(VAR_1, VAR_0);",
"memory_region_destroy(VAR_0);",
"}"
]
| [
1,
1,
1,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
]
|
15,313 | static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
const AVHWAccel *hwaccel = avctx->hwaccel;
int override_dimensions = 1;
int ret;
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
return AVERROR(EINVAL);
}
if (frame->width <= 0 || frame->height <= 0) {
frame->width = FFMAX(avctx->width, AV_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
override_dimensions = 0;
}
if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) {
av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
return AVERROR(EINVAL);
}
}
ret = ff_decode_frame_props(avctx, frame);
return ret;
if (hwaccel) {
if (hwaccel->alloc_frame) {
ret = hwaccel->alloc_frame(avctx, frame);
goto end;
}
} else
avctx->sw_pix_fmt = avctx->pix_fmt;
ret = avctx->get_buffer2(avctx, frame, flags);
if (ret >= 0)
validate_avframe_allocation(avctx, frame);
end:
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
!(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
frame->width = avctx->width;
frame->height = avctx->height;
}
return ret;
} | true | FFmpeg | 4776c61424fa32394e251e9769e1ad2c2fa55598 | static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
const AVHWAccel *hwaccel = avctx->hwaccel;
int override_dimensions = 1;
int ret;
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
return AVERROR(EINVAL);
}
if (frame->width <= 0 || frame->height <= 0) {
frame->width = FFMAX(avctx->width, AV_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
override_dimensions = 0;
}
if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) {
av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
return AVERROR(EINVAL);
}
}
ret = ff_decode_frame_props(avctx, frame);
return ret;
if (hwaccel) {
if (hwaccel->alloc_frame) {
ret = hwaccel->alloc_frame(avctx, frame);
goto end;
}
} else
avctx->sw_pix_fmt = avctx->pix_fmt;
ret = avctx->get_buffer2(avctx, frame, flags);
if (ret >= 0)
validate_avframe_allocation(avctx, frame);
end:
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
!(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
frame->width = avctx->width;
frame->height = avctx->height;
}
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)
{
const AVHWAccel *VAR_3 = VAR_0->VAR_3;
int VAR_4 = 1;
int VAR_5;
if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {
if ((VAR_5 = av_image_check_size2(VAR_0->width, VAR_0->height, VAR_0->max_pixels, AV_PIX_FMT_NONE, 0, VAR_0)) < 0 || VAR_0->pix_fmt<0) {
av_log(VAR_0, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
return AVERROR(EINVAL);
}
if (VAR_1->width <= 0 || VAR_1->height <= 0) {
VAR_1->width = FFMAX(VAR_0->width, AV_CEIL_RSHIFT(VAR_0->coded_width, VAR_0->lowres));
VAR_1->height = FFMAX(VAR_0->height, AV_CEIL_RSHIFT(VAR_0->coded_height, VAR_0->lowres));
VAR_4 = 0;
}
if (VAR_1->data[0] || VAR_1->data[1] || VAR_1->data[2] || VAR_1->data[3]) {
av_log(VAR_0, AV_LOG_ERROR, "pic->data[*]!=NULL in FUNC_0\n");
return AVERROR(EINVAL);
}
}
VAR_5 = ff_decode_frame_props(VAR_0, VAR_1);
return VAR_5;
if (VAR_3) {
if (VAR_3->alloc_frame) {
VAR_5 = VAR_3->alloc_frame(VAR_0, VAR_1);
goto end;
}
} else
VAR_0->sw_pix_fmt = VAR_0->pix_fmt;
VAR_5 = VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2);
if (VAR_5 >= 0)
validate_avframe_allocation(VAR_0, VAR_1);
end:
if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO && !VAR_4 &&
!(VAR_0->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
VAR_1->width = VAR_0->width;
VAR_1->height = VAR_0->height;
}
return VAR_5;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)\n{",
"const AVHWAccel *VAR_3 = VAR_0->VAR_3;",
"int VAR_4 = 1;",
"int VAR_5;",
"if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if ((VAR_5 = av_image_check_size2(VAR_0->width, VAR_0->height, VAR_0->max_pixels, AV_PIX_FMT_NONE, 0, VAR_0)) < 0 || VAR_0->pix_fmt<0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"video_get_buffer: image parameters invalid\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (VAR_1->width <= 0 || VAR_1->height <= 0) {",
"VAR_1->width = FFMAX(VAR_0->width, AV_CEIL_RSHIFT(VAR_0->coded_width, VAR_0->lowres));",
"VAR_1->height = FFMAX(VAR_0->height, AV_CEIL_RSHIFT(VAR_0->coded_height, VAR_0->lowres));",
"VAR_4 = 0;",
"}",
"if (VAR_1->data[0] || VAR_1->data[1] || VAR_1->data[2] || VAR_1->data[3]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pic->data[*]!=NULL in FUNC_0\\n\");",
"return AVERROR(EINVAL);",
"}",
"}",
"VAR_5 = ff_decode_frame_props(VAR_0, VAR_1);",
"return VAR_5;",
"if (VAR_3) {",
"if (VAR_3->alloc_frame) {",
"VAR_5 = VAR_3->alloc_frame(VAR_0, VAR_1);",
"goto end;",
"}",
"} else",
"VAR_0->sw_pix_fmt = VAR_0->pix_fmt;",
"VAR_5 = VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2);",
"if (VAR_5 >= 0)\nvalidate_avframe_allocation(VAR_0, VAR_1);",
"end:\nif (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO && !VAR_4 &&\n!(VAR_0->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {",
"VAR_1->width = VAR_0->width;",
"VAR_1->height = VAR_0->height;",
"}",
"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
]
| [
[
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
]
]
|
15,314 | void pcie_host_mmcfg_init(PCIExpressHost *e, uint32_t size)
{
assert(!(size & (size - 1))); /* power of 2 */
assert(size >= PCIE_MMCFG_SIZE_MIN);
assert(size <= PCIE_MMCFG_SIZE_MAX);
e->size = size;
memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,
"pcie-mmcfg", e->size);
}
| true | qemu | 3a8f2a9ce51036ab2d25bcc31114b5cbb72ab44b | void pcie_host_mmcfg_init(PCIExpressHost *e, uint32_t size)
{
assert(!(size & (size - 1)));
assert(size >= PCIE_MMCFG_SIZE_MIN);
assert(size <= PCIE_MMCFG_SIZE_MAX);
e->size = size;
memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,
"pcie-mmcfg", e->size);
}
| {
"code": [
" memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,",
" \"pcie-mmcfg\", e->size);"
],
"line_no": [
13,
15
]
} | void FUNC_0(PCIExpressHost *VAR_0, uint32_t VAR_1)
{
assert(!(VAR_1 & (VAR_1 - 1)));
assert(VAR_1 >= PCIE_MMCFG_SIZE_MIN);
assert(VAR_1 <= PCIE_MMCFG_SIZE_MAX);
VAR_0->VAR_1 = VAR_1;
memory_region_init_io(&VAR_0->mmio, OBJECT(VAR_0), &pcie_mmcfg_ops, VAR_0,
"pcie-mmcfg", VAR_0->VAR_1);
}
| [
"void FUNC_0(PCIExpressHost *VAR_0, uint32_t VAR_1)\n{",
"assert(!(VAR_1 & (VAR_1 - 1)));",
"assert(VAR_1 >= PCIE_MMCFG_SIZE_MIN);",
"assert(VAR_1 <= PCIE_MMCFG_SIZE_MAX);",
"VAR_0->VAR_1 = VAR_1;",
"memory_region_init_io(&VAR_0->mmio, OBJECT(VAR_0), &pcie_mmcfg_ops, VAR_0,\n\"pcie-mmcfg\", VAR_0->VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
]
]
|
15,315 | static void update_sse_status(CPUX86State *env)
{
int rnd_type;
/* set rounding mode */
switch (env->mxcsr & SSE_RC_MASK) {
default:
case SSE_RC_NEAR:
rnd_type = float_round_nearest_even;
break;
case SSE_RC_DOWN:
rnd_type = float_round_down;
break;
case SSE_RC_UP:
rnd_type = float_round_up;
break;
case SSE_RC_CHOP:
rnd_type = float_round_to_zero;
break;
}
set_float_rounding_mode(rnd_type, &env->sse_status);
/* set denormals are zero */
set_flush_inputs_to_zero((env->mxcsr & SSE_DAZ) ? 1 : 0, &env->sse_status);
/* set flush to zero */
set_flush_to_zero((env->mxcsr & SSE_FZ) ? 1 : 0, &env->fp_status);
}
| true | qemu | 4e47e39ab0ded72c0af174131ecf49d588d66c12 | static void update_sse_status(CPUX86State *env)
{
int rnd_type;
switch (env->mxcsr & SSE_RC_MASK) {
default:
case SSE_RC_NEAR:
rnd_type = float_round_nearest_even;
break;
case SSE_RC_DOWN:
rnd_type = float_round_down;
break;
case SSE_RC_UP:
rnd_type = float_round_up;
break;
case SSE_RC_CHOP:
rnd_type = float_round_to_zero;
break;
}
set_float_rounding_mode(rnd_type, &env->sse_status);
set_flush_inputs_to_zero((env->mxcsr & SSE_DAZ) ? 1 : 0, &env->sse_status);
set_flush_to_zero((env->mxcsr & SSE_FZ) ? 1 : 0, &env->fp_status);
}
| {
"code": [
"static void update_sse_status(CPUX86State *env)",
" switch (env->mxcsr & SSE_RC_MASK) {",
" set_flush_inputs_to_zero((env->mxcsr & SSE_DAZ) ? 1 : 0, &env->sse_status);",
" set_flush_to_zero((env->mxcsr & SSE_FZ) ? 1 : 0, &env->fp_status);"
],
"line_no": [
1,
11,
47,
53
]
} | static void FUNC_0(CPUX86State *VAR_0)
{
int VAR_1;
switch (VAR_0->mxcsr & SSE_RC_MASK) {
default:
case SSE_RC_NEAR:
VAR_1 = float_round_nearest_even;
break;
case SSE_RC_DOWN:
VAR_1 = float_round_down;
break;
case SSE_RC_UP:
VAR_1 = float_round_up;
break;
case SSE_RC_CHOP:
VAR_1 = float_round_to_zero;
break;
}
set_float_rounding_mode(VAR_1, &VAR_0->sse_status);
set_flush_inputs_to_zero((VAR_0->mxcsr & SSE_DAZ) ? 1 : 0, &VAR_0->sse_status);
set_flush_to_zero((VAR_0->mxcsr & SSE_FZ) ? 1 : 0, &VAR_0->fp_status);
}
| [
"static void FUNC_0(CPUX86State *VAR_0)\n{",
"int VAR_1;",
"switch (VAR_0->mxcsr & SSE_RC_MASK) {",
"default:\ncase SSE_RC_NEAR:\nVAR_1 = float_round_nearest_even;",
"break;",
"case SSE_RC_DOWN:\nVAR_1 = float_round_down;",
"break;",
"case SSE_RC_UP:\nVAR_1 = float_round_up;",
"break;",
"case SSE_RC_CHOP:\nVAR_1 = float_round_to_zero;",
"break;",
"}",
"set_float_rounding_mode(VAR_1, &VAR_0->sse_status);",
"set_flush_inputs_to_zero((VAR_0->mxcsr & SSE_DAZ) ? 1 : 0, &VAR_0->sse_status);",
"set_flush_to_zero((VAR_0->mxcsr & SSE_FZ) ? 1 : 0, &VAR_0->fp_status);",
"}"
]
| [
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
13,
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
53
],
[
55
]
]
|
15,316 | static int adts_aac_probe(AVProbeData *p)
{
int max_frames = 0, first_frames = 0;
int fsize, frames;
uint8_t *buf0 = p->buf;
uint8_t *buf2;
uint8_t *buf;
uint8_t *end = buf0 + p->buf_size - 7;
buf = buf0;
for(; buf < end; buf= buf2+1) {
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
uint32_t header = AV_RB16(buf2);
if((header&0xFFF6) != 0xFFF0)
break;
fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
if(fsize < 7)
break;
buf2 += fsize;
}
max_frames = FFMAX(max_frames, frames);
if(buf == buf0)
first_frames= frames;
}
if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
else if(max_frames>=1) return 1;
else return 0;
} | true | FFmpeg | b39f872a41b92a31589052c8f914c5b52f206fd0 | static int adts_aac_probe(AVProbeData *p)
{
int max_frames = 0, first_frames = 0;
int fsize, frames;
uint8_t *buf0 = p->buf;
uint8_t *buf2;
uint8_t *buf;
uint8_t *end = buf0 + p->buf_size - 7;
buf = buf0;
for(; buf < end; buf= buf2+1) {
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
uint32_t header = AV_RB16(buf2);
if((header&0xFFF6) != 0xFFF0)
break;
fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
if(fsize < 7)
break;
buf2 += fsize;
}
max_frames = FFMAX(max_frames, frames);
if(buf == buf0)
first_frames= frames;
}
if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
else if(max_frames>=1) return 1;
else return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
int VAR_1 = 0, VAR_2 = 0;
int VAR_3, VAR_4;
uint8_t *buf0 = VAR_0->buf;
uint8_t *buf2;
uint8_t *buf;
uint8_t *end = buf0 + VAR_0->buf_size - 7;
buf = buf0;
for(; buf < end; buf= buf2+1) {
buf2 = buf;
for(VAR_4 = 0; buf2 < end; VAR_4++) {
uint32_t header = AV_RB16(buf2);
if((header&0xFFF6) != 0xFFF0)
break;
VAR_3 = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
if(VAR_3 < 7)
break;
buf2 += VAR_3;
}
VAR_1 = FFMAX(VAR_1, VAR_4);
if(buf == buf0)
VAR_2= VAR_4;
}
if (VAR_2>=3) return AVPROBE_SCORE_MAX/2+1;
else if(VAR_1>500)return AVPROBE_SCORE_MAX/2;
else if(VAR_1>=3) return AVPROBE_SCORE_MAX/4;
else if(VAR_1>=1) return 1;
else return 0;
} | [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"int VAR_1 = 0, VAR_2 = 0;",
"int VAR_3, VAR_4;",
"uint8_t *buf0 = VAR_0->buf;",
"uint8_t *buf2;",
"uint8_t *buf;",
"uint8_t *end = buf0 + VAR_0->buf_size - 7;",
"buf = buf0;",
"for(; buf < end; buf= buf2+1) {",
"buf2 = buf;",
"for(VAR_4 = 0; buf2 < end; VAR_4++) {",
"uint32_t header = AV_RB16(buf2);",
"if((header&0xFFF6) != 0xFFF0)\nbreak;",
"VAR_3 = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;",
"if(VAR_3 < 7)\nbreak;",
"buf2 += VAR_3;",
"}",
"VAR_1 = FFMAX(VAR_1, VAR_4);",
"if(buf == buf0)\nVAR_2= VAR_4;",
"}",
"if (VAR_2>=3) return AVPROBE_SCORE_MAX/2+1;",
"else if(VAR_1>500)return AVPROBE_SCORE_MAX/2;",
"else if(VAR_1>=3) return AVPROBE_SCORE_MAX/4;",
"else if(VAR_1>=1) return 1;",
"else return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
44
],
[
46
],
[
48
],
[
50,
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
]
]
|
15,317 | static int qio_channel_websock_handshake_read(QIOChannelWebsock *ioc,
Error **errp)
{
char *handshake_end;
ssize_t ret;
/* Typical HTTP headers from novnc are 512 bytes, so limiting
* total header size to 4096 is easily enough. */
size_t want = 4096 - ioc->encinput.offset;
buffer_reserve(&ioc->encinput, want);
ret = qio_channel_read(ioc->master,
(char *)buffer_end(&ioc->encinput), want, errp);
if (ret < 0) {
return -1;
}
ioc->encinput.offset += ret;
handshake_end = g_strstr_len((char *)ioc->encinput.buffer,
ioc->encinput.offset,
QIO_CHANNEL_WEBSOCK_HANDSHAKE_END);
if (!handshake_end) {
if (ioc->encinput.offset >= 4096) {
error_setg(errp,
"End of headers not found in first 4096 bytes");
return -1;
} else {
return 0;
}
}
*handshake_end = '\0';
if (qio_channel_websock_handshake_process(ioc,
(char *)ioc->encinput.buffer,
errp) < 0) {
return -1;
}
buffer_advance(&ioc->encinput,
handshake_end - (char *)ioc->encinput.buffer +
strlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_END));
return 1;
}
| true | qemu | f69a8bde29354493ff8aea64cc9cb3b531d16337 | static int qio_channel_websock_handshake_read(QIOChannelWebsock *ioc,
Error **errp)
{
char *handshake_end;
ssize_t ret;
size_t want = 4096 - ioc->encinput.offset;
buffer_reserve(&ioc->encinput, want);
ret = qio_channel_read(ioc->master,
(char *)buffer_end(&ioc->encinput), want, errp);
if (ret < 0) {
return -1;
}
ioc->encinput.offset += ret;
handshake_end = g_strstr_len((char *)ioc->encinput.buffer,
ioc->encinput.offset,
QIO_CHANNEL_WEBSOCK_HANDSHAKE_END);
if (!handshake_end) {
if (ioc->encinput.offset >= 4096) {
error_setg(errp,
"End of headers not found in first 4096 bytes");
return -1;
} else {
return 0;
}
}
*handshake_end = '\0';
if (qio_channel_websock_handshake_process(ioc,
(char *)ioc->encinput.buffer,
errp) < 0) {
return -1;
}
buffer_advance(&ioc->encinput,
handshake_end - (char *)ioc->encinput.buffer +
strlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_END));
return 1;
}
| {
"code": [
" return 0;",
" return 0;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" if (qio_channel_websock_handshake_process(ioc,",
" (char *)ioc->encinput.buffer,",
" errp) < 0) {",
" return -1;"
],
"line_no": [
51,
51,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
47,
61,
63,
65,
25
]
} | static int FUNC_0(QIOChannelWebsock *VAR_0,
Error **VAR_1)
{
char *VAR_2;
ssize_t ret;
size_t want = 4096 - VAR_0->encinput.offset;
buffer_reserve(&VAR_0->encinput, want);
ret = qio_channel_read(VAR_0->master,
(char *)buffer_end(&VAR_0->encinput), want, VAR_1);
if (ret < 0) {
return -1;
}
VAR_0->encinput.offset += ret;
VAR_2 = g_strstr_len((char *)VAR_0->encinput.buffer,
VAR_0->encinput.offset,
QIO_CHANNEL_WEBSOCK_HANDSHAKE_END);
if (!VAR_2) {
if (VAR_0->encinput.offset >= 4096) {
error_setg(VAR_1,
"End of headers not found in first 4096 bytes");
return -1;
} else {
return 0;
}
}
*VAR_2 = '\0';
if (qio_channel_websock_handshake_process(VAR_0,
(char *)VAR_0->encinput.buffer,
VAR_1) < 0) {
return -1;
}
buffer_advance(&VAR_0->encinput,
VAR_2 - (char *)VAR_0->encinput.buffer +
strlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_END));
return 1;
}
| [
"static int FUNC_0(QIOChannelWebsock *VAR_0,\nError **VAR_1)\n{",
"char *VAR_2;",
"ssize_t ret;",
"size_t want = 4096 - VAR_0->encinput.offset;",
"buffer_reserve(&VAR_0->encinput, want);",
"ret = qio_channel_read(VAR_0->master,\n(char *)buffer_end(&VAR_0->encinput), want, VAR_1);",
"if (ret < 0) {",
"return -1;",
"}",
"VAR_0->encinput.offset += ret;",
"VAR_2 = g_strstr_len((char *)VAR_0->encinput.buffer,\nVAR_0->encinput.offset,\nQIO_CHANNEL_WEBSOCK_HANDSHAKE_END);",
"if (!VAR_2) {",
"if (VAR_0->encinput.offset >= 4096) {",
"error_setg(VAR_1,\n\"End of headers not found in first 4096 bytes\");",
"return -1;",
"} else {",
"return 0;",
"}",
"}",
"*VAR_2 = '\\0';",
"if (qio_channel_websock_handshake_process(VAR_0,\n(char *)VAR_0->encinput.buffer,\nVAR_1) < 0) {",
"return -1;",
"}",
"buffer_advance(&VAR_0->encinput,\nVAR_2 - (char *)VAR_0->encinput.buffer +\nstrlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_END));",
"return 1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63,
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
79
],
[
81
]
]
|
15,318 | static int decode_init_mp3on4(AVCodecContext * avctx)
{
MP3On4DecodeContext *s = avctx->priv_data;
MPEG4AudioConfig cfg;
int i;
if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
return -1;
}
avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size);
if (!cfg.chan_config || cfg.chan_config > 7) {
av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
return -1;
}
s->frames = mp3Frames[cfg.chan_config];
s->coff = chan_offset[cfg.chan_config];
avctx->channels = ff_mpeg4audio_channels[cfg.chan_config];
avctx->channel_layout = chan_layout[cfg.chan_config];
if (cfg.sample_rate < 16000)
s->syncword = 0xffe00000;
else
s->syncword = 0xfff00000;
/* Init the first mp3 decoder in standard way, so that all tables get builded
* We replace avctx->priv_data with the context of the first decoder so that
* decode_init() does not have to be changed.
* Other decoders will be initialized here copying data from the first context
*/
// Allocate zeroed memory for the first decoder context
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
// Put decoder context in place to make init_decode() happy
avctx->priv_data = s->mp3decctx[0];
decode_init(avctx);
// Restore mp3on4 context pointer
avctx->priv_data = s;
s->mp3decctx[0]->adu_mode = 1; // Set adu mode
/* Create a separate codec/context for each frame (first is already ok).
* Each frame is 1 or 2 channels - up to 5 frames allowed
*/
for (i = 1; i < s->frames; i++) {
s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[i])
s->mp3decctx[i]->adu_mode = 1;
s->mp3decctx[i]->avctx = avctx;
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
}
/* Allocate buffer for multi-channel output if needed */
if (s->frames > 1) {
s->decoded_buf = av_malloc(MPA_FRAME_SIZE * MPA_MAX_CHANNELS *
sizeof(*s->decoded_buf));
if (!s->decoded_buf)
}
return 0;
alloc_fail:
decode_close_mp3on4(avctx);
return AVERROR(ENOMEM);
} | true | FFmpeg | 95891804bf300b266aa5328f1c338c046720e658 | static int decode_init_mp3on4(AVCodecContext * avctx)
{
MP3On4DecodeContext *s = avctx->priv_data;
MPEG4AudioConfig cfg;
int i;
if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
return -1;
}
avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size);
if (!cfg.chan_config || cfg.chan_config > 7) {
av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
return -1;
}
s->frames = mp3Frames[cfg.chan_config];
s->coff = chan_offset[cfg.chan_config];
avctx->channels = ff_mpeg4audio_channels[cfg.chan_config];
avctx->channel_layout = chan_layout[cfg.chan_config];
if (cfg.sample_rate < 16000)
s->syncword = 0xffe00000;
else
s->syncword = 0xfff00000;
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
avctx->priv_data = s->mp3decctx[0];
decode_init(avctx);
avctx->priv_data = s;
s->mp3decctx[0]->adu_mode = 1;
for (i = 1; i < s->frames; i++) {
s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[i])
s->mp3decctx[i]->adu_mode = 1;
s->mp3decctx[i]->avctx = avctx;
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
}
if (s->frames > 1) {
s->decoded_buf = av_malloc(MPA_FRAME_SIZE * MPA_MAX_CHANNELS *
sizeof(*s->decoded_buf));
if (!s->decoded_buf)
}
return 0;
alloc_fail:
decode_close_mp3on4(avctx);
return AVERROR(ENOMEM);
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0)
{
MP3On4DecodeContext *s = VAR_0->priv_data;
MPEG4AudioConfig cfg;
int VAR_1;
if ((VAR_0->extradata_size < 2) || (VAR_0->extradata == NULL)) {
av_log(VAR_0, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
return -1;
}
avpriv_mpeg4audio_get_config(&cfg, VAR_0->extradata, VAR_0->extradata_size);
if (!cfg.chan_config || cfg.chan_config > 7) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid channel config number.\n");
return -1;
}
s->frames = mp3Frames[cfg.chan_config];
s->coff = chan_offset[cfg.chan_config];
VAR_0->channels = ff_mpeg4audio_channels[cfg.chan_config];
VAR_0->channel_layout = chan_layout[cfg.chan_config];
if (cfg.sample_rate < 16000)
s->syncword = 0xffe00000;
else
s->syncword = 0xfff00000;
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
VAR_0->priv_data = s->mp3decctx[0];
decode_init(VAR_0);
VAR_0->priv_data = s;
s->mp3decctx[0]->adu_mode = 1;
for (VAR_1 = 1; VAR_1 < s->frames; VAR_1++) {
s->mp3decctx[VAR_1] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[VAR_1])
s->mp3decctx[VAR_1]->adu_mode = 1;
s->mp3decctx[VAR_1]->VAR_0 = VAR_0;
s->mp3decctx[VAR_1]->mpadsp = s->mp3decctx[0]->mpadsp;
}
if (s->frames > 1) {
s->decoded_buf = av_malloc(MPA_FRAME_SIZE * MPA_MAX_CHANNELS *
sizeof(*s->decoded_buf));
if (!s->decoded_buf)
}
return 0;
alloc_fail:
decode_close_mp3on4(VAR_0);
return AVERROR(ENOMEM);
} | [
"static int FUNC_0(AVCodecContext * VAR_0)\n{",
"MP3On4DecodeContext *s = VAR_0->priv_data;",
"MPEG4AudioConfig cfg;",
"int VAR_1;",
"if ((VAR_0->extradata_size < 2) || (VAR_0->extradata == NULL)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Codec extradata missing or too short.\\n\");",
"return -1;",
"}",
"avpriv_mpeg4audio_get_config(&cfg, VAR_0->extradata, VAR_0->extradata_size);",
"if (!cfg.chan_config || cfg.chan_config > 7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid channel config number.\\n\");",
"return -1;",
"}",
"s->frames = mp3Frames[cfg.chan_config];",
"s->coff = chan_offset[cfg.chan_config];",
"VAR_0->channels = ff_mpeg4audio_channels[cfg.chan_config];",
"VAR_0->channel_layout = chan_layout[cfg.chan_config];",
"if (cfg.sample_rate < 16000)\ns->syncword = 0xffe00000;",
"else\ns->syncword = 0xfff00000;",
"s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));",
"VAR_0->priv_data = s->mp3decctx[0];",
"decode_init(VAR_0);",
"VAR_0->priv_data = s;",
"s->mp3decctx[0]->adu_mode = 1;",
"for (VAR_1 = 1; VAR_1 < s->frames; VAR_1++) {",
"s->mp3decctx[VAR_1] = av_mallocz(sizeof(MPADecodeContext));",
"if (!s->mp3decctx[VAR_1])\ns->mp3decctx[VAR_1]->adu_mode = 1;",
"s->mp3decctx[VAR_1]->VAR_0 = VAR_0;",
"s->mp3decctx[VAR_1]->mpadsp = s->mp3decctx[0]->mpadsp;",
"}",
"if (s->frames > 1) {",
"s->decoded_buf = av_malloc(MPA_FRAME_SIZE * MPA_MAX_CHANNELS *\nsizeof(*s->decoded_buf));",
"if (!s->decoded_buf)\n}",
"return 0;",
"alloc_fail:\ndecode_close_mp3on4(VAR_0);",
"return AVERROR(ENOMEM);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
65
],
[
71
],
[
73
],
[
77
],
[
79
],
[
89
],
[
91
],
[
93,
96
],
[
98
],
[
100
],
[
102
],
[
108
],
[
110,
112
],
[
114,
117
],
[
121
],
[
123,
125
],
[
127
],
[
129
]
]
|
15,320 | void avdevice_register_all(void)
{
static int inited;
if (inited)
return;
inited = 1;
/* devices */
REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);
REGISTER_DEMUXER (BKTR, bktr);
REGISTER_DEMUXER (DV1394, dv1394);
REGISTER_MUXDEMUX (OSS, oss);
REGISTER_DEMUXER (V4L2, v4l2);
REGISTER_DEMUXER (V4L, v4l);
REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);
/* external libraries */
REGISTER_DEMUXER (LIBDC1394, libdc1394);
}
| false | FFmpeg | 5e53486545726987ab4482321d4dcf7e23e7652f | void avdevice_register_all(void)
{
static int inited;
if (inited)
return;
inited = 1;
REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);
REGISTER_DEMUXER (BKTR, bktr);
REGISTER_DEMUXER (DV1394, dv1394);
REGISTER_MUXDEMUX (OSS, oss);
REGISTER_DEMUXER (V4L2, v4l2);
REGISTER_DEMUXER (V4L, v4l);
REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);
REGISTER_DEMUXER (LIBDC1394, libdc1394);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
static int VAR_0;
if (VAR_0)
return;
VAR_0 = 1;
REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);
REGISTER_DEMUXER (BKTR, bktr);
REGISTER_DEMUXER (DV1394, dv1394);
REGISTER_MUXDEMUX (OSS, oss);
REGISTER_DEMUXER (V4L2, v4l2);
REGISTER_DEMUXER (V4L, v4l);
REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);
REGISTER_DEMUXER (LIBDC1394, libdc1394);
}
| [
"void FUNC_0(void)\n{",
"static int VAR_0;",
"if (VAR_0)\nreturn;",
"VAR_0 = 1;",
"REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);",
"REGISTER_DEMUXER (BKTR, bktr);",
"REGISTER_DEMUXER (DV1394, dv1394);",
"REGISTER_MUXDEMUX (OSS, oss);",
"REGISTER_DEMUXER (V4L2, v4l2);",
"REGISTER_DEMUXER (V4L, v4l);",
"REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);",
"REGISTER_DEMUXER (LIBDC1394, libdc1394);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.