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
|
---|---|---|---|---|---|---|---|---|---|---|
12,962 | static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
uint16_t ipbh0)
{
CPUS390XState *env = &cpu->env;
uint64_t sccb;
uint32_t code;
int r = 0;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
enter_pgmcheck(cpu, PGM_PRIVILEGED);
return 0;
}
sccb = env->regs[ipbh0 & 0xf];
code = env->regs[(ipbh0 & 0xf0) >> 4];
r = sclp_service_call(sccb, code);
if (r < 0) {
enter_pgmcheck(cpu, -r);
}
setcc(cpu, r);
return 0;
}
| true | qemu | 6e25280216fc23c8387892f76d961559da124528 | static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
uint16_t ipbh0)
{
CPUS390XState *env = &cpu->env;
uint64_t sccb;
uint32_t code;
int r = 0;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
enter_pgmcheck(cpu, PGM_PRIVILEGED);
return 0;
}
sccb = env->regs[ipbh0 & 0xf];
code = env->regs[(ipbh0 & 0xf0) >> 4];
r = sclp_service_call(sccb, code);
if (r < 0) {
enter_pgmcheck(cpu, -r);
}
setcc(cpu, r);
return 0;
}
| {
"code": [
" if (env->psw.mask & PSW_MASK_PSTATE) {",
" enter_pgmcheck(cpu, PGM_PRIVILEGED);",
" return 0;",
" r = sclp_service_call(sccb, code);"
],
"line_no": [
19,
21,
23,
33
]
} | static int FUNC_0(S390CPU *VAR_0, struct kvm_run *VAR_1,
uint16_t VAR_2)
{
CPUS390XState *env = &VAR_0->env;
uint64_t sccb;
uint32_t code;
int VAR_3 = 0;
cpu_synchronize_state(CPU(VAR_0));
if (env->psw.mask & PSW_MASK_PSTATE) {
enter_pgmcheck(VAR_0, PGM_PRIVILEGED);
return 0;
}
sccb = env->regs[VAR_2 & 0xf];
code = env->regs[(VAR_2 & 0xf0) >> 4];
VAR_3 = sclp_service_call(sccb, code);
if (VAR_3 < 0) {
enter_pgmcheck(VAR_0, -VAR_3);
}
setcc(VAR_0, VAR_3);
return 0;
}
| [
"static int FUNC_0(S390CPU *VAR_0, struct kvm_run *VAR_1,\nuint16_t VAR_2)\n{",
"CPUS390XState *env = &VAR_0->env;",
"uint64_t sccb;",
"uint32_t code;",
"int VAR_3 = 0;",
"cpu_synchronize_state(CPU(VAR_0));",
"if (env->psw.mask & PSW_MASK_PSTATE) {",
"enter_pgmcheck(VAR_0, PGM_PRIVILEGED);",
"return 0;",
"}",
"sccb = env->regs[VAR_2 & 0xf];",
"code = env->regs[(VAR_2 & 0xf0) >> 4];",
"VAR_3 = sclp_service_call(sccb, code);",
"if (VAR_3 < 0) {",
"enter_pgmcheck(VAR_0, -VAR_3);",
"}",
"setcc(VAR_0, VAR_3);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
]
|
12,964 | static void libschroedinger_flush(AVCodecContext *avctx)
{
/* Got a seek request. Free the decoded frames queue and then reset
* the decoder */
SchroDecoderParams *p_schro_params = avctx->priv_data;
/* Free data in the output frame queue. */
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
ff_schro_queue_init(&p_schro_params->dec_frame_queue);
schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 0;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static void libschroedinger_flush(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
ff_schro_queue_init(&p_schro_params->dec_frame_queue);
schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 0;
}
| {
"code": [
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" ff_schro_queue_init(&p_schro_params->dec_frame_queue);",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" ff_schro_queue_free(&p_schro_params->dec_frame_queue,",
" libschroedinger_decode_frame_free);",
"static void libschroedinger_flush(AVCodecContext *avctx)",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" ff_schro_queue_free(&p_schro_params->dec_frame_queue,",
" libschroedinger_decode_frame_free);",
" ff_schro_queue_init(&p_schro_params->dec_frame_queue);",
" schro_decoder_reset(p_schro_params->decoder);",
" p_schro_params->eos_pulled = 0;",
" p_schro_params->eos_signalled = 0;"
],
"line_no": [
9,
21,
9,
9,
9,
15,
17,
1,
9,
15,
17,
21,
23,
25,
27
]
} | static void FUNC_0(AVCodecContext *VAR_0)
{
SchroDecoderParams *p_schro_params = VAR_0->priv_data;
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
ff_schro_queue_init(&p_schro_params->dec_frame_queue);
schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 0;
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"SchroDecoderParams *p_schro_params = VAR_0->priv_data;",
"ff_schro_queue_free(&p_schro_params->dec_frame_queue,\nlibschroedinger_decode_frame_free);",
"ff_schro_queue_init(&p_schro_params->dec_frame_queue);",
"schro_decoder_reset(p_schro_params->decoder);",
"p_schro_params->eos_pulled = 0;",
"p_schro_params->eos_signalled = 0;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
9
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
12,965 | CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
{
HEVCContext *h = avctx->priv_data;
const HEVCVPS *vps = (const HEVCVPS *)h->ps.vps_list[0]->data;
const HEVCSPS *sps = (const HEVCSPS *)h->ps.sps_list[0]->data;
int i, num_pps = 0;
const HEVCPPS *pps = h->ps.pps;
PTLCommon ptlc = vps->ptl.general_ptl;
VUI vui = sps->vui;
uint8_t parallelismType;
CFDataRef data = NULL;
uint8_t *p;
int vt_extradata_size = 23 + 5 + vps->data_size + 5 + sps->data_size + 3;
uint8_t *vt_extradata;
for (i = 0; i < MAX_PPS_COUNT; i++) {
if (h->ps.pps_list[i]) {
const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
vt_extradata_size += 2 + pps->data_size;
num_pps++;
}
}
vt_extradata = av_malloc(vt_extradata_size);
if (!vt_extradata)
return NULL;
p = vt_extradata;
/* unsigned int(8) configurationVersion = 1; */
AV_W8(p + 0, 1);
/*
* unsigned int(2) general_profile_space;
* unsigned int(1) general_tier_flag;
* unsigned int(5) general_profile_idc;
*/
AV_W8(p + 1, ptlc.profile_space << 6 |
ptlc.tier_flag << 5 |
ptlc.profile_idc);
/* unsigned int(32) general_profile_compatibility_flags; */
memcpy(p + 2, ptlc.profile_compatibility_flag, 4);
/* unsigned int(48) general_constraint_indicator_flags; */
AV_W8(p + 6, ptlc.progressive_source_flag << 7 |
ptlc.interlaced_source_flag << 6 |
ptlc.non_packed_constraint_flag << 5 |
ptlc.frame_only_constraint_flag << 4);
AV_W8(p + 7, 0);
AV_WN32(p + 8, 0);
/* unsigned int(8) general_level_idc; */
AV_W8(p + 12, ptlc.level_idc);
/*
* bit(4) reserved = ‘1111’b;
* unsigned int(12) min_spatial_segmentation_idc;
*/
AV_W8(p + 13, 0xf0 | (vui.min_spatial_segmentation_idc >> 4));
AV_W8(p + 14, vui.min_spatial_segmentation_idc & 0xff);
/*
* bit(6) reserved = ‘111111’b;
* unsigned int(2) parallelismType;
*/
if (!vui.min_spatial_segmentation_idc)
parallelismType = 0;
else if (pps->entropy_coding_sync_enabled_flag && pps->tiles_enabled_flag)
parallelismType = 0;
else if (pps->entropy_coding_sync_enabled_flag)
parallelismType = 3;
else if (pps->tiles_enabled_flag)
parallelismType = 2;
else
parallelismType = 1;
AV_W8(p + 15, 0xfc | parallelismType);
/*
* bit(6) reserved = ‘111111’b;
* unsigned int(2) chromaFormat;
*/
AV_W8(p + 16, sps->chroma_format_idc | 0xfc);
/*
* bit(5) reserved = ‘11111’b;
* unsigned int(3) bitDepthLumaMinus8;
*/
AV_W8(p + 17, (sps->bit_depth - 8) | 0xfc);
/*
* bit(5) reserved = ‘11111’b;
* unsigned int(3) bitDepthChromaMinus8;
*/
AV_W8(p + 18, (sps->bit_depth_chroma - 8) | 0xfc);
/* bit(16) avgFrameRate; */
AV_WB16(p + 19, 0);
/*
* bit(2) constantFrameRate;
* bit(3) numTemporalLayers;
* bit(1) temporalIdNested;
* unsigned int(2) lengthSizeMinusOne;
*/
AV_W8(p + 21, 0 << 6 |
sps->max_sub_layers << 3 |
sps->temporal_id_nesting_flag << 2 |
3);
/* unsigned int(8) numOfArrays; */
AV_W8(p + 22, 3);
p += 23;
/* vps */
/*
* bit(1) array_completeness;
* unsigned int(1) reserved = 0;
* unsigned int(6) NAL_unit_type;
*/
AV_W8(p, 1 << 7 |
HEVC_NAL_VPS & 0x3f);
/* unsigned int(16) numNalus; */
AV_WB16(p + 1, 1);
/* unsigned int(16) nalUnitLength; */
AV_WB16(p + 3, vps->data_size);
/* bit(8*nalUnitLength) nalUnit; */
memcpy(p + 5, vps->data, vps->data_size);
p += 5 + vps->data_size;
/* sps */
AV_W8(p, 1 << 7 |
HEVC_NAL_SPS & 0x3f);
AV_WB16(p + 1, 1);
AV_WB16(p + 3, sps->data_size);
memcpy(p + 5, sps->data, sps->data_size);
p += 5 + sps->data_size;
/* pps */
AV_W8(p, 1 << 7 |
HEVC_NAL_PPS & 0x3f);
AV_WB16(p + 1, num_pps);
p += 3;
for (i = 0; i < MAX_PPS_COUNT; i++) {
if (h->ps.pps_list[i]) {
const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
AV_WB16(p, pps->data_size);
memcpy(p + 2, pps->data, pps->data_size);
p += 2 + pps->data_size;
}
}
av_assert0(p - vt_extradata == vt_extradata_size);
data = CFDataCreate(kCFAllocatorDefault, vt_extradata, vt_extradata_size);
av_free(vt_extradata);
return data;
}
| true | FFmpeg | 05d77587cb7d0a4e349c5320eb7c0b48610cf6bf | CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
{
HEVCContext *h = avctx->priv_data;
const HEVCVPS *vps = (const HEVCVPS *)h->ps.vps_list[0]->data;
const HEVCSPS *sps = (const HEVCSPS *)h->ps.sps_list[0]->data;
int i, num_pps = 0;
const HEVCPPS *pps = h->ps.pps;
PTLCommon ptlc = vps->ptl.general_ptl;
VUI vui = sps->vui;
uint8_t parallelismType;
CFDataRef data = NULL;
uint8_t *p;
int vt_extradata_size = 23 + 5 + vps->data_size + 5 + sps->data_size + 3;
uint8_t *vt_extradata;
for (i = 0; i < MAX_PPS_COUNT; i++) {
if (h->ps.pps_list[i]) {
const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
vt_extradata_size += 2 + pps->data_size;
num_pps++;
}
}
vt_extradata = av_malloc(vt_extradata_size);
if (!vt_extradata)
return NULL;
p = vt_extradata;
AV_W8(p + 0, 1);
AV_W8(p + 1, ptlc.profile_space << 6 |
ptlc.tier_flag << 5 |
ptlc.profile_idc);
memcpy(p + 2, ptlc.profile_compatibility_flag, 4);
AV_W8(p + 6, ptlc.progressive_source_flag << 7 |
ptlc.interlaced_source_flag << 6 |
ptlc.non_packed_constraint_flag << 5 |
ptlc.frame_only_constraint_flag << 4);
AV_W8(p + 7, 0);
AV_WN32(p + 8, 0);
AV_W8(p + 12, ptlc.level_idc);
AV_W8(p + 13, 0xf0 | (vui.min_spatial_segmentation_idc >> 4));
AV_W8(p + 14, vui.min_spatial_segmentation_idc & 0xff);
if (!vui.min_spatial_segmentation_idc)
parallelismType = 0;
else if (pps->entropy_coding_sync_enabled_flag && pps->tiles_enabled_flag)
parallelismType = 0;
else if (pps->entropy_coding_sync_enabled_flag)
parallelismType = 3;
else if (pps->tiles_enabled_flag)
parallelismType = 2;
else
parallelismType = 1;
AV_W8(p + 15, 0xfc | parallelismType);
AV_W8(p + 16, sps->chroma_format_idc | 0xfc);
AV_W8(p + 17, (sps->bit_depth - 8) | 0xfc);
AV_W8(p + 18, (sps->bit_depth_chroma - 8) | 0xfc);
AV_WB16(p + 19, 0);
AV_W8(p + 21, 0 << 6 |
sps->max_sub_layers << 3 |
sps->temporal_id_nesting_flag << 2 |
3);
AV_W8(p + 22, 3);
p += 23;
AV_W8(p, 1 << 7 |
HEVC_NAL_VPS & 0x3f);
AV_WB16(p + 1, 1);
AV_WB16(p + 3, vps->data_size);
memcpy(p + 5, vps->data, vps->data_size);
p += 5 + vps->data_size;
AV_W8(p, 1 << 7 |
HEVC_NAL_SPS & 0x3f);
AV_WB16(p + 1, 1);
AV_WB16(p + 3, sps->data_size);
memcpy(p + 5, sps->data, sps->data_size);
p += 5 + sps->data_size;
AV_W8(p, 1 << 7 |
HEVC_NAL_PPS & 0x3f);
AV_WB16(p + 1, num_pps);
p += 3;
for (i = 0; i < MAX_PPS_COUNT; i++) {
if (h->ps.pps_list[i]) {
const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
AV_WB16(p, pps->data_size);
memcpy(p + 2, pps->data, pps->data_size);
p += 2 + pps->data_size;
}
}
av_assert0(p - vt_extradata == vt_extradata_size);
data = CFDataCreate(kCFAllocatorDefault, vt_extradata, vt_extradata_size);
av_free(vt_extradata);
return data;
}
| {
"code": [
" for (i = 0; i < MAX_PPS_COUNT; i++) {",
" for (i = 0; i < MAX_PPS_COUNT; i++) {"
],
"line_no": [
31,
31
]
} | CFDataRef FUNC_0(AVCodecContext *avctx)
{
HEVCContext *h = avctx->priv_data;
const HEVCVPS *VAR_0 = (const HEVCVPS *)h->ps.vps_list[0]->data;
const HEVCSPS *VAR_1 = (const HEVCSPS *)h->ps.sps_list[0]->data;
int VAR_2, VAR_3 = 0;
const HEVCPPS *VAR_4 = h->ps.VAR_4;
PTLCommon ptlc = VAR_0->ptl.general_ptl;
VUI vui = VAR_1->vui;
uint8_t parallelismType;
CFDataRef data = NULL;
uint8_t *p;
int VAR_5 = 23 + 5 + VAR_0->data_size + 5 + VAR_1->data_size + 3;
uint8_t *vt_extradata;
for (VAR_2 = 0; VAR_2 < MAX_PPS_COUNT; VAR_2++) {
if (h->ps.pps_list[VAR_2]) {
const HEVCPPS *VAR_4 = (const HEVCPPS *)h->ps.pps_list[VAR_2]->data;
VAR_5 += 2 + VAR_4->data_size;
VAR_3++;
}
}
vt_extradata = av_malloc(VAR_5);
if (!vt_extradata)
return NULL;
p = vt_extradata;
AV_W8(p + 0, 1);
AV_W8(p + 1, ptlc.profile_space << 6 |
ptlc.tier_flag << 5 |
ptlc.profile_idc);
memcpy(p + 2, ptlc.profile_compatibility_flag, 4);
AV_W8(p + 6, ptlc.progressive_source_flag << 7 |
ptlc.interlaced_source_flag << 6 |
ptlc.non_packed_constraint_flag << 5 |
ptlc.frame_only_constraint_flag << 4);
AV_W8(p + 7, 0);
AV_WN32(p + 8, 0);
AV_W8(p + 12, ptlc.level_idc);
AV_W8(p + 13, 0xf0 | (vui.min_spatial_segmentation_idc >> 4));
AV_W8(p + 14, vui.min_spatial_segmentation_idc & 0xff);
if (!vui.min_spatial_segmentation_idc)
parallelismType = 0;
else if (VAR_4->entropy_coding_sync_enabled_flag && VAR_4->tiles_enabled_flag)
parallelismType = 0;
else if (VAR_4->entropy_coding_sync_enabled_flag)
parallelismType = 3;
else if (VAR_4->tiles_enabled_flag)
parallelismType = 2;
else
parallelismType = 1;
AV_W8(p + 15, 0xfc | parallelismType);
AV_W8(p + 16, VAR_1->chroma_format_idc | 0xfc);
AV_W8(p + 17, (VAR_1->bit_depth - 8) | 0xfc);
AV_W8(p + 18, (VAR_1->bit_depth_chroma - 8) | 0xfc);
AV_WB16(p + 19, 0);
AV_W8(p + 21, 0 << 6 |
VAR_1->max_sub_layers << 3 |
VAR_1->temporal_id_nesting_flag << 2 |
3);
AV_W8(p + 22, 3);
p += 23;
AV_W8(p, 1 << 7 |
HEVC_NAL_VPS & 0x3f);
AV_WB16(p + 1, 1);
AV_WB16(p + 3, VAR_0->data_size);
memcpy(p + 5, VAR_0->data, VAR_0->data_size);
p += 5 + VAR_0->data_size;
AV_W8(p, 1 << 7 |
HEVC_NAL_SPS & 0x3f);
AV_WB16(p + 1, 1);
AV_WB16(p + 3, VAR_1->data_size);
memcpy(p + 5, VAR_1->data, VAR_1->data_size);
p += 5 + VAR_1->data_size;
AV_W8(p, 1 << 7 |
HEVC_NAL_PPS & 0x3f);
AV_WB16(p + 1, VAR_3);
p += 3;
for (VAR_2 = 0; VAR_2 < MAX_PPS_COUNT; VAR_2++) {
if (h->ps.pps_list[VAR_2]) {
const HEVCPPS *VAR_4 = (const HEVCPPS *)h->ps.pps_list[VAR_2]->data;
AV_WB16(p, VAR_4->data_size);
memcpy(p + 2, VAR_4->data, VAR_4->data_size);
p += 2 + VAR_4->data_size;
}
}
av_assert0(p - vt_extradata == VAR_5);
data = CFDataCreate(kCFAllocatorDefault, vt_extradata, VAR_5);
av_free(vt_extradata);
return data;
}
| [
"CFDataRef FUNC_0(AVCodecContext *avctx)\n{",
"HEVCContext *h = avctx->priv_data;",
"const HEVCVPS *VAR_0 = (const HEVCVPS *)h->ps.vps_list[0]->data;",
"const HEVCSPS *VAR_1 = (const HEVCSPS *)h->ps.sps_list[0]->data;",
"int VAR_2, VAR_3 = 0;",
"const HEVCPPS *VAR_4 = h->ps.VAR_4;",
"PTLCommon ptlc = VAR_0->ptl.general_ptl;",
"VUI vui = VAR_1->vui;",
"uint8_t parallelismType;",
"CFDataRef data = NULL;",
"uint8_t *p;",
"int VAR_5 = 23 + 5 + VAR_0->data_size + 5 + VAR_1->data_size + 3;",
"uint8_t *vt_extradata;",
"for (VAR_2 = 0; VAR_2 < MAX_PPS_COUNT; VAR_2++) {",
"if (h->ps.pps_list[VAR_2]) {",
"const HEVCPPS *VAR_4 = (const HEVCPPS *)h->ps.pps_list[VAR_2]->data;",
"VAR_5 += 2 + VAR_4->data_size;",
"VAR_3++;",
"}",
"}",
"vt_extradata = av_malloc(VAR_5);",
"if (!vt_extradata)\nreturn NULL;",
"p = vt_extradata;",
"AV_W8(p + 0, 1);",
"AV_W8(p + 1, ptlc.profile_space << 6 |\nptlc.tier_flag << 5 |\nptlc.profile_idc);",
"memcpy(p + 2, ptlc.profile_compatibility_flag, 4);",
"AV_W8(p + 6, ptlc.progressive_source_flag << 7 |\nptlc.interlaced_source_flag << 6 |\nptlc.non_packed_constraint_flag << 5 |\nptlc.frame_only_constraint_flag << 4);",
"AV_W8(p + 7, 0);",
"AV_WN32(p + 8, 0);",
"AV_W8(p + 12, ptlc.level_idc);",
"AV_W8(p + 13, 0xf0 | (vui.min_spatial_segmentation_idc >> 4));",
"AV_W8(p + 14, vui.min_spatial_segmentation_idc & 0xff);",
"if (!vui.min_spatial_segmentation_idc)\nparallelismType = 0;",
"else if (VAR_4->entropy_coding_sync_enabled_flag && VAR_4->tiles_enabled_flag)\nparallelismType = 0;",
"else if (VAR_4->entropy_coding_sync_enabled_flag)\nparallelismType = 3;",
"else if (VAR_4->tiles_enabled_flag)\nparallelismType = 2;",
"else\nparallelismType = 1;",
"AV_W8(p + 15, 0xfc | parallelismType);",
"AV_W8(p + 16, VAR_1->chroma_format_idc | 0xfc);",
"AV_W8(p + 17, (VAR_1->bit_depth - 8) | 0xfc);",
"AV_W8(p + 18, (VAR_1->bit_depth_chroma - 8) | 0xfc);",
"AV_WB16(p + 19, 0);",
"AV_W8(p + 21, 0 << 6 |\nVAR_1->max_sub_layers << 3 |\nVAR_1->temporal_id_nesting_flag << 2 |\n3);",
"AV_W8(p + 22, 3);",
"p += 23;",
"AV_W8(p, 1 << 7 |\nHEVC_NAL_VPS & 0x3f);",
"AV_WB16(p + 1, 1);",
"AV_WB16(p + 3, VAR_0->data_size);",
"memcpy(p + 5, VAR_0->data, VAR_0->data_size);",
"p += 5 + VAR_0->data_size;",
"AV_W8(p, 1 << 7 |\nHEVC_NAL_SPS & 0x3f);",
"AV_WB16(p + 1, 1);",
"AV_WB16(p + 3, VAR_1->data_size);",
"memcpy(p + 5, VAR_1->data, VAR_1->data_size);",
"p += 5 + VAR_1->data_size;",
"AV_W8(p, 1 << 7 |\nHEVC_NAL_PPS & 0x3f);",
"AV_WB16(p + 1, VAR_3);",
"p += 3;",
"for (VAR_2 = 0; VAR_2 < MAX_PPS_COUNT; VAR_2++) {",
"if (h->ps.pps_list[VAR_2]) {",
"const HEVCPPS *VAR_4 = (const HEVCPPS *)h->ps.pps_list[VAR_2]->data;",
"AV_WB16(p, VAR_4->data_size);",
"memcpy(p + 2, VAR_4->data, VAR_4->data_size);",
"p += 2 + VAR_4->data_size;",
"}",
"}",
"av_assert0(p - vt_extradata == VAR_5);",
"data = CFDataCreate(kCFAllocatorDefault, vt_extradata, VAR_5);",
"av_free(vt_extradata);",
"return data;",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
59
],
[
73,
75,
77
],
[
83
],
[
89,
91,
93,
95
],
[
97
],
[
99
],
[
105
],
[
117
],
[
119
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
163
],
[
175
],
[
187
],
[
193
],
[
209,
211,
213,
215
],
[
221
],
[
225
],
[
239,
241
],
[
245
],
[
249
],
[
253
],
[
255
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
]
]
|
12,967 | static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
{
XHCIState *xhci = epctx->xhci;
XHCIStreamContext *stctx = NULL;
XHCITransfer *xfer;
XHCIRing *ring;
USBEndpoint *ep = NULL;
uint64_t mfindex;
unsigned int count = 0;
int length;
int i;
trace_usb_xhci_ep_kick(epctx->slotid, epctx->epid, streamid);
assert(!epctx->kick_active);
/* If the device has been detached, but the guest has not noticed this
yet the 2 above checks will succeed, but we must NOT continue */
if (!xhci->slots[epctx->slotid - 1].uport ||
!xhci->slots[epctx->slotid - 1].uport->dev ||
!xhci->slots[epctx->slotid - 1].uport->dev->attached) {
return;
}
if (epctx->retry) {
XHCITransfer *xfer = epctx->retry;
trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry);
if (xfer->timed_xfer) {
/* time to kick the transfer? */
mfindex = xhci_mfindex_get(xhci);
xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex);
if (xfer->running_retry) {
return;
}
xfer->timed_xfer = 0;
xfer->running_retry = 1;
}
if (xfer->iso_xfer) {
/* retry iso transfer */
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
assert(xfer->packet.status != USB_RET_NAK);
xhci_try_complete_packet(xfer);
} else {
/* retry nak'ed transfer */
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
return;
}
xhci_try_complete_packet(xfer);
}
assert(!xfer->running_retry);
if (xfer->complete) {
xhci_ep_free_xfer(epctx->retry);
}
epctx->retry = NULL;
}
if (epctx->state == EP_HALTED) {
DPRINTF("xhci: ep halted, not running schedule\n");
return;
}
if (epctx->nr_pstreams) {
uint32_t err;
stctx = xhci_find_stream(epctx, streamid, &err);
if (stctx == NULL) {
return;
}
ring = &stctx->ring;
xhci_set_ep_state(xhci, epctx, stctx, EP_RUNNING);
} else {
ring = &epctx->ring;
streamid = 0;
xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING);
}
assert(ring->dequeue != 0);
epctx->kick_active++;
while (1) {
length = xhci_ring_chain_length(xhci, ring);
if (length <= 0) {
break;
}
xfer = xhci_ep_alloc_xfer(epctx, length);
if (xfer == NULL) {
break;
}
for (i = 0; i < length; i++) {
TRBType type;
type = xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL);
assert(type);
}
xfer->streamid = streamid;
if (epctx->epid == 1) {
xhci_fire_ctl_transfer(xhci, xfer);
} else {
xhci_fire_transfer(xhci, xfer, epctx);
}
if (xfer->complete) {
xhci_ep_free_xfer(xfer);
xfer = NULL;
}
if (epctx->state == EP_HALTED) {
break;
}
if (xfer != NULL && xfer->running_retry) {
DPRINTF("xhci: xfer nacked, stopping schedule\n");
epctx->retry = xfer;
break;
}
if (count++ > TRANSFER_LIMIT) {
trace_usb_xhci_enforced_limit("transfers");
break;
}
}
/* update ring dequeue ptr */
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
epctx->kick_active--;
ep = xhci_epid_to_usbep(epctx);
if (ep) {
usb_device_flush_ep_queue(ep->dev, ep);
}
}
| true | qemu | d54fddea989ba4aa2912d49583d86ce01c0d27ea | static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
{
XHCIState *xhci = epctx->xhci;
XHCIStreamContext *stctx = NULL;
XHCITransfer *xfer;
XHCIRing *ring;
USBEndpoint *ep = NULL;
uint64_t mfindex;
unsigned int count = 0;
int length;
int i;
trace_usb_xhci_ep_kick(epctx->slotid, epctx->epid, streamid);
assert(!epctx->kick_active);
if (!xhci->slots[epctx->slotid - 1].uport ||
!xhci->slots[epctx->slotid - 1].uport->dev ||
!xhci->slots[epctx->slotid - 1].uport->dev->attached) {
return;
}
if (epctx->retry) {
XHCITransfer *xfer = epctx->retry;
trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry);
if (xfer->timed_xfer) {
mfindex = xhci_mfindex_get(xhci);
xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex);
if (xfer->running_retry) {
return;
}
xfer->timed_xfer = 0;
xfer->running_retry = 1;
}
if (xfer->iso_xfer) {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
assert(xfer->packet.status != USB_RET_NAK);
xhci_try_complete_packet(xfer);
} else {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
return;
}
xhci_try_complete_packet(xfer);
}
assert(!xfer->running_retry);
if (xfer->complete) {
xhci_ep_free_xfer(epctx->retry);
}
epctx->retry = NULL;
}
if (epctx->state == EP_HALTED) {
DPRINTF("xhci: ep halted, not running schedule\n");
return;
}
if (epctx->nr_pstreams) {
uint32_t err;
stctx = xhci_find_stream(epctx, streamid, &err);
if (stctx == NULL) {
return;
}
ring = &stctx->ring;
xhci_set_ep_state(xhci, epctx, stctx, EP_RUNNING);
} else {
ring = &epctx->ring;
streamid = 0;
xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING);
}
assert(ring->dequeue != 0);
epctx->kick_active++;
while (1) {
length = xhci_ring_chain_length(xhci, ring);
if (length <= 0) {
break;
}
xfer = xhci_ep_alloc_xfer(epctx, length);
if (xfer == NULL) {
break;
}
for (i = 0; i < length; i++) {
TRBType type;
type = xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL);
assert(type);
}
xfer->streamid = streamid;
if (epctx->epid == 1) {
xhci_fire_ctl_transfer(xhci, xfer);
} else {
xhci_fire_transfer(xhci, xfer, epctx);
}
if (xfer->complete) {
xhci_ep_free_xfer(xfer);
xfer = NULL;
}
if (epctx->state == EP_HALTED) {
break;
}
if (xfer != NULL && xfer->running_retry) {
DPRINTF("xhci: xfer nacked, stopping schedule\n");
epctx->retry = xfer;
break;
}
if (count++ > TRANSFER_LIMIT) {
trace_usb_xhci_enforced_limit("transfers");
break;
}
}
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
epctx->kick_active--;
ep = xhci_epid_to_usbep(epctx);
if (ep) {
usb_device_flush_ep_queue(ep->dev, ep);
}
}
| {
"code": [
" xhci_set_ep_state(xhci, epctx, stctx, epctx->state);"
],
"line_no": [
255
]
} | static void FUNC_0(XHCIEPContext *VAR_0, unsigned int VAR_1)
{
XHCIState *xhci = VAR_0->xhci;
XHCIStreamContext *stctx = NULL;
XHCITransfer *xfer;
XHCIRing *ring;
USBEndpoint *ep = NULL;
uint64_t mfindex;
unsigned int VAR_2 = 0;
int VAR_3;
int VAR_4;
trace_usb_xhci_ep_kick(VAR_0->slotid, VAR_0->epid, VAR_1);
assert(!VAR_0->kick_active);
if (!xhci->slots[VAR_0->slotid - 1].uport ||
!xhci->slots[VAR_0->slotid - 1].uport->dev ||
!xhci->slots[VAR_0->slotid - 1].uport->dev->attached) {
return;
}
if (VAR_0->retry) {
XHCITransfer *xfer = VAR_0->retry;
trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry);
if (xfer->timed_xfer) {
mfindex = xhci_mfindex_get(xhci);
xhci_check_intr_iso_kick(xhci, xfer, VAR_0, mfindex);
if (xfer->running_retry) {
return;
}
xfer->timed_xfer = 0;
xfer->running_retry = 1;
}
if (xfer->iso_xfer) {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
assert(xfer->packet.status != USB_RET_NAK);
xhci_try_complete_packet(xfer);
} else {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
return;
}
xhci_try_complete_packet(xfer);
}
assert(!xfer->running_retry);
if (xfer->complete) {
xhci_ep_free_xfer(VAR_0->retry);
}
VAR_0->retry = NULL;
}
if (VAR_0->state == EP_HALTED) {
DPRINTF("xhci: ep halted, not running schedule\n");
return;
}
if (VAR_0->nr_pstreams) {
uint32_t err;
stctx = xhci_find_stream(VAR_0, VAR_1, &err);
if (stctx == NULL) {
return;
}
ring = &stctx->ring;
xhci_set_ep_state(xhci, VAR_0, stctx, EP_RUNNING);
} else {
ring = &VAR_0->ring;
VAR_1 = 0;
xhci_set_ep_state(xhci, VAR_0, NULL, EP_RUNNING);
}
assert(ring->dequeue != 0);
VAR_0->kick_active++;
while (1) {
VAR_3 = xhci_ring_chain_length(xhci, ring);
if (VAR_3 <= 0) {
break;
}
xfer = xhci_ep_alloc_xfer(VAR_0, VAR_3);
if (xfer == NULL) {
break;
}
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {
TRBType type;
type = xhci_ring_fetch(xhci, ring, &xfer->trbs[VAR_4], NULL);
assert(type);
}
xfer->VAR_1 = VAR_1;
if (VAR_0->epid == 1) {
xhci_fire_ctl_transfer(xhci, xfer);
} else {
xhci_fire_transfer(xhci, xfer, VAR_0);
}
if (xfer->complete) {
xhci_ep_free_xfer(xfer);
xfer = NULL;
}
if (VAR_0->state == EP_HALTED) {
break;
}
if (xfer != NULL && xfer->running_retry) {
DPRINTF("xhci: xfer nacked, stopping schedule\n");
VAR_0->retry = xfer;
break;
}
if (VAR_2++ > TRANSFER_LIMIT) {
trace_usb_xhci_enforced_limit("transfers");
break;
}
}
xhci_set_ep_state(xhci, VAR_0, stctx, VAR_0->state);
VAR_0->kick_active--;
ep = xhci_epid_to_usbep(VAR_0);
if (ep) {
usb_device_flush_ep_queue(ep->dev, ep);
}
}
| [
"static void FUNC_0(XHCIEPContext *VAR_0, unsigned int VAR_1)\n{",
"XHCIState *xhci = VAR_0->xhci;",
"XHCIStreamContext *stctx = NULL;",
"XHCITransfer *xfer;",
"XHCIRing *ring;",
"USBEndpoint *ep = NULL;",
"uint64_t mfindex;",
"unsigned int VAR_2 = 0;",
"int VAR_3;",
"int VAR_4;",
"trace_usb_xhci_ep_kick(VAR_0->slotid, VAR_0->epid, VAR_1);",
"assert(!VAR_0->kick_active);",
"if (!xhci->slots[VAR_0->slotid - 1].uport ||\n!xhci->slots[VAR_0->slotid - 1].uport->dev ||\n!xhci->slots[VAR_0->slotid - 1].uport->dev->attached) {",
"return;",
"}",
"if (VAR_0->retry) {",
"XHCITransfer *xfer = VAR_0->retry;",
"trace_usb_xhci_xfer_retry(xfer);",
"assert(xfer->running_retry);",
"if (xfer->timed_xfer) {",
"mfindex = xhci_mfindex_get(xhci);",
"xhci_check_intr_iso_kick(xhci, xfer, VAR_0, mfindex);",
"if (xfer->running_retry) {",
"return;",
"}",
"xfer->timed_xfer = 0;",
"xfer->running_retry = 1;",
"}",
"if (xfer->iso_xfer) {",
"if (xhci_setup_packet(xfer) < 0) {",
"return;",
"}",
"usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);",
"assert(xfer->packet.status != USB_RET_NAK);",
"xhci_try_complete_packet(xfer);",
"} else {",
"if (xhci_setup_packet(xfer) < 0) {",
"return;",
"}",
"usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);",
"if (xfer->packet.status == USB_RET_NAK) {",
"return;",
"}",
"xhci_try_complete_packet(xfer);",
"}",
"assert(!xfer->running_retry);",
"if (xfer->complete) {",
"xhci_ep_free_xfer(VAR_0->retry);",
"}",
"VAR_0->retry = NULL;",
"}",
"if (VAR_0->state == EP_HALTED) {",
"DPRINTF(\"xhci: ep halted, not running schedule\\n\");",
"return;",
"}",
"if (VAR_0->nr_pstreams) {",
"uint32_t err;",
"stctx = xhci_find_stream(VAR_0, VAR_1, &err);",
"if (stctx == NULL) {",
"return;",
"}",
"ring = &stctx->ring;",
"xhci_set_ep_state(xhci, VAR_0, stctx, EP_RUNNING);",
"} else {",
"ring = &VAR_0->ring;",
"VAR_1 = 0;",
"xhci_set_ep_state(xhci, VAR_0, NULL, EP_RUNNING);",
"}",
"assert(ring->dequeue != 0);",
"VAR_0->kick_active++;",
"while (1) {",
"VAR_3 = xhci_ring_chain_length(xhci, ring);",
"if (VAR_3 <= 0) {",
"break;",
"}",
"xfer = xhci_ep_alloc_xfer(VAR_0, VAR_3);",
"if (xfer == NULL) {",
"break;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {",
"TRBType type;",
"type = xhci_ring_fetch(xhci, ring, &xfer->trbs[VAR_4], NULL);",
"assert(type);",
"}",
"xfer->VAR_1 = VAR_1;",
"if (VAR_0->epid == 1) {",
"xhci_fire_ctl_transfer(xhci, xfer);",
"} else {",
"xhci_fire_transfer(xhci, xfer, VAR_0);",
"}",
"if (xfer->complete) {",
"xhci_ep_free_xfer(xfer);",
"xfer = NULL;",
"}",
"if (VAR_0->state == EP_HALTED) {",
"break;",
"}",
"if (xfer != NULL && xfer->running_retry) {",
"DPRINTF(\"xhci: xfer nacked, stopping schedule\\n\");",
"VAR_0->retry = xfer;",
"break;",
"}",
"if (VAR_2++ > TRANSFER_LIMIT) {",
"trace_usb_xhci_enforced_limit(\"transfers\");",
"break;",
"}",
"}",
"xhci_set_ep_state(xhci, VAR_0, stctx, VAR_0->state);",
"VAR_0->kick_active--;",
"ep = xhci_epid_to_usbep(VAR_0);",
"if (ep) {",
"usb_device_flush_ep_queue(ep->dev, ep);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
35,
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
]
]
|
12,969 | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
V9fsPath *dir_path, const char *name, FsCred *credp)
{
int err = -1;
int serrno = 0;
char *newpath;
V9fsString fullname;
char *buffer;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
newpath = fullname.data;
/* Determine the security model */
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(buffer, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_mapped_file_attr(fs_ctx, newpath, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
buffer = rpath(fs_ctx, newpath);
err = symlink(oldpath, buffer);
if (err) {
g_free(buffer);
goto out;
}
err = lchown(buffer, credp->fc_uid, credp->fc_gid);
if (err == -1) {
/*
* If we fail to change ownership and if we are
* using security model none. Ignore the error
*/
if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
goto out;
err_end:
remove(buffer);
errno = serrno;
g_free(buffer);
out:
v9fs_string_free(&fullname);
return err;
}
| true | qemu | 4ed7b2c3a78f785a1bcbe575e08c379b166723e3 | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
V9fsPath *dir_path, const char *name, FsCred *credp)
{
int err = -1;
int serrno = 0;
char *newpath;
V9fsString fullname;
char *buffer;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
newpath = fullname.data;
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(buffer, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_mapped_file_attr(fs_ctx, newpath, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
buffer = rpath(fs_ctx, newpath);
err = symlink(oldpath, buffer);
if (err) {
g_free(buffer);
goto out;
}
err = lchown(buffer, credp->fc_uid, credp->fc_gid);
if (err == -1) {
if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
goto out;
err_end:
remove(buffer);
errno = serrno;
g_free(buffer);
out:
v9fs_string_free(&fullname);
return err;
}
| {
"code": [
" char *buffer;",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" char *buffer;",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" char *buffer;",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" char *buffer;",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);",
" g_free(buffer);"
],
"line_no": [
15,
41,
41,
41,
201,
15,
41,
41,
41,
201,
15,
41,
41,
41,
201,
15,
41,
41,
41,
201
]
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1,
V9fsPath *VAR_2, const char *VAR_3, FsCred *VAR_4)
{
int VAR_5 = -1;
int VAR_6 = 0;
char *VAR_7;
V9fsString fullname;
char *VAR_8;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", VAR_2->data, VAR_3);
VAR_7 = fullname.data;
if (VAR_0->export_flags & V9FS_SM_MAPPED) {
int VAR_10;
ssize_t oldpath_size, write_size;
VAR_8 = rpath(VAR_0, VAR_7);
VAR_10 = open(VAR_8, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (VAR_10 == -1) {
g_free(VAR_8);
VAR_5 = VAR_10;
goto out;
}
oldpath_size = strlen(VAR_1);
do {
write_size = write(VAR_10, (void *)VAR_1, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
VAR_6 = errno;
close(VAR_10);
VAR_5 = -1;
goto err_end;
}
close(VAR_10);
VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;
VAR_5 = local_set_xattr(VAR_8, VAR_4);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {
int VAR_10;
ssize_t oldpath_size, write_size;
VAR_8 = rpath(VAR_0, VAR_7);
VAR_10 = open(VAR_8, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (VAR_10 == -1) {
g_free(VAR_8);
VAR_5 = VAR_10;
goto out;
}
oldpath_size = strlen(VAR_1);
do {
write_size = write(VAR_10, (void *)VAR_1, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
VAR_6 = errno;
close(VAR_10);
VAR_5 = -1;
goto err_end;
}
close(VAR_10);
VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;
VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_7, VAR_4);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
} else if ((VAR_0->export_flags & V9FS_SM_PASSTHROUGH) ||
(VAR_0->export_flags & V9FS_SM_NONE)) {
VAR_8 = rpath(VAR_0, VAR_7);
VAR_5 = symlink(VAR_1, VAR_8);
if (VAR_5) {
g_free(VAR_8);
goto out;
}
VAR_5 = lchown(VAR_8, VAR_4->fc_uid, VAR_4->fc_gid);
if (VAR_5 == -1) {
if ((VAR_0->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
VAR_6 = errno;
goto err_end;
} else
VAR_5 = 0;
}
}
goto out;
err_end:
remove(VAR_8);
errno = VAR_6;
g_free(VAR_8);
out:
v9fs_string_free(&fullname);
return VAR_5;
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1,\nV9fsPath *VAR_2, const char *VAR_3, FsCred *VAR_4)\n{",
"int VAR_5 = -1;",
"int VAR_6 = 0;",
"char *VAR_7;",
"V9fsString fullname;",
"char *VAR_8;",
"v9fs_string_init(&fullname);",
"v9fs_string_sprintf(&fullname, \"%s/%s\", VAR_2->data, VAR_3);",
"VAR_7 = fullname.data;",
"if (VAR_0->export_flags & V9FS_SM_MAPPED) {",
"int VAR_10;",
"ssize_t oldpath_size, write_size;",
"VAR_8 = rpath(VAR_0, VAR_7);",
"VAR_10 = open(VAR_8, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);",
"if (VAR_10 == -1) {",
"g_free(VAR_8);",
"VAR_5 = VAR_10;",
"goto out;",
"}",
"oldpath_size = strlen(VAR_1);",
"do {",
"write_size = write(VAR_10, (void *)VAR_1, oldpath_size);",
"} while (write_size == -1 && errno == EINTR);",
"if (write_size != oldpath_size) {",
"VAR_6 = errno;",
"close(VAR_10);",
"VAR_5 = -1;",
"goto err_end;",
"}",
"close(VAR_10);",
"VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;",
"VAR_5 = local_set_xattr(VAR_8, VAR_4);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {",
"int VAR_10;",
"ssize_t oldpath_size, write_size;",
"VAR_8 = rpath(VAR_0, VAR_7);",
"VAR_10 = open(VAR_8, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);",
"if (VAR_10 == -1) {",
"g_free(VAR_8);",
"VAR_5 = VAR_10;",
"goto out;",
"}",
"oldpath_size = strlen(VAR_1);",
"do {",
"write_size = write(VAR_10, (void *)VAR_1, oldpath_size);",
"} while (write_size == -1 && errno == EINTR);",
"if (write_size != oldpath_size) {",
"VAR_6 = errno;",
"close(VAR_10);",
"VAR_5 = -1;",
"goto err_end;",
"}",
"close(VAR_10);",
"VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;",
"VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_7, VAR_4);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"} else if ((VAR_0->export_flags & V9FS_SM_PASSTHROUGH) ||",
"(VAR_0->export_flags & V9FS_SM_NONE)) {",
"VAR_8 = rpath(VAR_0, VAR_7);",
"VAR_5 = symlink(VAR_1, VAR_8);",
"if (VAR_5) {",
"g_free(VAR_8);",
"goto out;",
"}",
"VAR_5 = lchown(VAR_8, VAR_4->fc_uid, VAR_4->fc_gid);",
"if (VAR_5 == -1) {",
"if ((VAR_0->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {",
"VAR_6 = errno;",
"goto err_end;",
"} else",
"VAR_5 = 0;",
"}",
"}",
"goto out;",
"err_end:\nremove(VAR_8);",
"errno = VAR_6;",
"g_free(VAR_8);",
"out:\nv9fs_string_free(&fullname);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195,
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
]
]
|
12,970 | void OPPROTO op_405_check_satu (void)
{
if (unlikely(T0 < T2)) {
/* Saturate result */
T0 = -1;
}
RETURN();
}
| true | qemu | 6f2d8978728c48ca46f5c01835438508aace5c64 | void OPPROTO op_405_check_satu (void)
{
if (unlikely(T0 < T2)) {
T0 = -1;
}
RETURN();
}
| {
"code": [
" T0 = -1;"
],
"line_no": [
9
]
} | void VAR_0 op_405_check_satu (void)
{
if (unlikely(T0 < T2)) {
T0 = -1;
}
RETURN();
}
| [
"void VAR_0 op_405_check_satu (void)\n{",
"if (unlikely(T0 < T2)) {",
"T0 = -1;",
"}",
"RETURN();",
"}"
]
| [
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
12,971 | static void qemu_gluster_complete_aio(void *opaque)
{
GlusterAIOCB *acb = (GlusterAIOCB *)opaque;
qemu_bh_delete(acb->bh);
acb->bh = NULL;
qemu_coroutine_enter(acb->coroutine, NULL);
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static void qemu_gluster_complete_aio(void *opaque)
{
GlusterAIOCB *acb = (GlusterAIOCB *)opaque;
qemu_bh_delete(acb->bh);
acb->bh = NULL;
qemu_coroutine_enter(acb->coroutine, NULL);
}
| {
"code": [
" qemu_coroutine_enter(acb->coroutine, NULL);",
" qemu_coroutine_enter(acb->coroutine, NULL);"
],
"line_no": [
13,
13
]
} | static void FUNC_0(void *VAR_0)
{
GlusterAIOCB *acb = (GlusterAIOCB *)VAR_0;
qemu_bh_delete(acb->bh);
acb->bh = NULL;
qemu_coroutine_enter(acb->coroutine, NULL);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"GlusterAIOCB *acb = (GlusterAIOCB *)VAR_0;",
"qemu_bh_delete(acb->bh);",
"acb->bh = NULL;",
"qemu_coroutine_enter(acb->coroutine, NULL);",
"}"
]
| [
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
12,972 | static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
uint16_t vendor, uint16_t device,
uint16_t class_code, uint8_t pif)
{
uint8_t *config;
uint32_t size;
proxy->vdev = vdev;
config = proxy->pci_dev.config;
pci_config_set_vendor_id(config, vendor);
pci_config_set_device_id(config, device);
config[0x08] = VIRTIO_PCI_ABI_VERSION;
config[0x09] = pif;
pci_config_set_class(config, class_code);
config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
config[0x2c] = vendor & 0xFF;
config[0x2d] = (vendor >> 8) & 0xFF;
config[0x2e] = vdev->device_id & 0xFF;
config[0x2f] = (vdev->device_id >> 8) & 0xFF;
config[0x3d] = 1;
if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0,
TARGET_PAGE_SIZE)) {
pci_register_bar(&proxy->pci_dev, 1,
msix_bar_size(&proxy->pci_dev),
PCI_ADDRESS_SPACE_MEM,
msix_mmio_map);
} else
vdev->nvectors = 0;
proxy->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len;
if (size & (size-1))
size = 1 << qemu_fls(size);
pci_register_bar(&proxy->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
virtio_map);
qemu_register_reset(virtio_pci_reset, proxy);
virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
}
| true | qemu | e489030df2448d22b3cb92fd5dcb22c6fa0fc9e1 | static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
uint16_t vendor, uint16_t device,
uint16_t class_code, uint8_t pif)
{
uint8_t *config;
uint32_t size;
proxy->vdev = vdev;
config = proxy->pci_dev.config;
pci_config_set_vendor_id(config, vendor);
pci_config_set_device_id(config, device);
config[0x08] = VIRTIO_PCI_ABI_VERSION;
config[0x09] = pif;
pci_config_set_class(config, class_code);
config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
config[0x2c] = vendor & 0xFF;
config[0x2d] = (vendor >> 8) & 0xFF;
config[0x2e] = vdev->device_id & 0xFF;
config[0x2f] = (vdev->device_id >> 8) & 0xFF;
config[0x3d] = 1;
if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0,
TARGET_PAGE_SIZE)) {
pci_register_bar(&proxy->pci_dev, 1,
msix_bar_size(&proxy->pci_dev),
PCI_ADDRESS_SPACE_MEM,
msix_mmio_map);
} else
vdev->nvectors = 0;
proxy->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len;
if (size & (size-1))
size = 1 << qemu_fls(size);
pci_register_bar(&proxy->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
virtio_map);
qemu_register_reset(virtio_pci_reset, proxy);
virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
}
| {
"code": [
" qemu_register_reset(virtio_pci_reset, proxy);"
],
"line_no": [
89
]
} | static void FUNC_0(VirtIOPCIProxy *VAR_0, VirtIODevice *VAR_1,
uint16_t VAR_2, uint16_t VAR_3,
uint16_t VAR_4, uint8_t VAR_5)
{
uint8_t *config;
uint32_t size;
VAR_0->VAR_1 = VAR_1;
config = VAR_0->pci_dev.config;
pci_config_set_vendor_id(config, VAR_2);
pci_config_set_device_id(config, VAR_3);
config[0x08] = VIRTIO_PCI_ABI_VERSION;
config[0x09] = VAR_5;
pci_config_set_class(config, VAR_4);
config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
config[0x2c] = VAR_2 & 0xFF;
config[0x2d] = (VAR_2 >> 8) & 0xFF;
config[0x2e] = VAR_1->device_id & 0xFF;
config[0x2f] = (VAR_1->device_id >> 8) & 0xFF;
config[0x3d] = 1;
if (VAR_1->nvectors && !msix_init(&VAR_0->pci_dev, VAR_1->nvectors, 1, 0,
TARGET_PAGE_SIZE)) {
pci_register_bar(&VAR_0->pci_dev, 1,
msix_bar_size(&VAR_0->pci_dev),
PCI_ADDRESS_SPACE_MEM,
msix_mmio_map);
} else
VAR_1->nvectors = 0;
VAR_0->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&VAR_0->pci_dev) + VAR_1->config_len;
if (size & (size-1))
size = 1 << qemu_fls(size);
pci_register_bar(&VAR_0->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
virtio_map);
qemu_register_reset(virtio_pci_reset, VAR_0);
virtio_bind_device(VAR_1, &virtio_pci_bindings, VAR_0);
}
| [
"static void FUNC_0(VirtIOPCIProxy *VAR_0, VirtIODevice *VAR_1,\nuint16_t VAR_2, uint16_t VAR_3,\nuint16_t VAR_4, uint8_t VAR_5)\n{",
"uint8_t *config;",
"uint32_t size;",
"VAR_0->VAR_1 = VAR_1;",
"config = VAR_0->pci_dev.config;",
"pci_config_set_vendor_id(config, VAR_2);",
"pci_config_set_device_id(config, VAR_3);",
"config[0x08] = VIRTIO_PCI_ABI_VERSION;",
"config[0x09] = VAR_5;",
"pci_config_set_class(config, VAR_4);",
"config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;",
"config[0x2c] = VAR_2 & 0xFF;",
"config[0x2d] = (VAR_2 >> 8) & 0xFF;",
"config[0x2e] = VAR_1->device_id & 0xFF;",
"config[0x2f] = (VAR_1->device_id >> 8) & 0xFF;",
"config[0x3d] = 1;",
"if (VAR_1->nvectors && !msix_init(&VAR_0->pci_dev, VAR_1->nvectors, 1, 0,\nTARGET_PAGE_SIZE)) {",
"pci_register_bar(&VAR_0->pci_dev, 1,\nmsix_bar_size(&VAR_0->pci_dev),\nPCI_ADDRESS_SPACE_MEM,\nmsix_mmio_map);",
"} else",
"VAR_1->nvectors = 0;",
"VAR_0->pci_dev.config_write = virtio_write_config;",
"size = VIRTIO_PCI_REGION_SIZE(&VAR_0->pci_dev) + VAR_1->config_len;",
"if (size & (size-1))\nsize = 1 << qemu_fls(size);",
"pci_register_bar(&VAR_0->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,\nvirtio_map);",
"qemu_register_reset(virtio_pci_reset, VAR_0);",
"virtio_bind_device(VAR_1, &virtio_pci_bindings, 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,
1,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53,
55
],
[
57,
59,
61,
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77,
79
],
[
83,
85
],
[
89
],
[
93
],
[
95
]
]
|
12,973 | static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)
{
unsigned int page, rd;
uint64_t base;
int64_t offset;
page = extract32(insn, 31, 1);
/* SignExtend(immhi:immlo) -> offset */
offset = ((int64_t)sextract32(insn, 5, 19) << 2) | extract32(insn, 29, 2);
rd = extract32(insn, 0, 5);
base = s->pc - 4;
if (page) {
/* ADRP (page based) */
base &= ~0xfff;
offset <<= 12;
}
tcg_gen_movi_i64(cpu_reg(s, rd), base + offset);
}
| true | qemu | 037e1d009e2fcb80784d37f0e12aa999787d46d4 | static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)
{
unsigned int page, rd;
uint64_t base;
int64_t offset;
page = extract32(insn, 31, 1);
offset = ((int64_t)sextract32(insn, 5, 19) << 2) | extract32(insn, 29, 2);
rd = extract32(insn, 0, 5);
base = s->pc - 4;
if (page) {
base &= ~0xfff;
offset <<= 12;
}
tcg_gen_movi_i64(cpu_reg(s, rd), base + offset);
}
| {
"code": [
" int64_t offset;",
" offset = ((int64_t)sextract32(insn, 5, 19) << 2) | extract32(insn, 29, 2);"
],
"line_no": [
9,
17
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
unsigned int VAR_2, VAR_3;
uint64_t base;
int64_t offset;
VAR_2 = extract32(VAR_1, 31, 1);
offset = ((int64_t)sextract32(VAR_1, 5, 19) << 2) | extract32(VAR_1, 29, 2);
VAR_3 = extract32(VAR_1, 0, 5);
base = VAR_0->pc - 4;
if (VAR_2) {
base &= ~0xfff;
offset <<= 12;
}
tcg_gen_movi_i64(cpu_reg(VAR_0, VAR_3), base + offset);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"unsigned int VAR_2, VAR_3;",
"uint64_t base;",
"int64_t offset;",
"VAR_2 = extract32(VAR_1, 31, 1);",
"offset = ((int64_t)sextract32(VAR_1, 5, 19) << 2) | extract32(VAR_1, 29, 2);",
"VAR_3 = extract32(VAR_1, 0, 5);",
"base = VAR_0->pc - 4;",
"if (VAR_2) {",
"base &= ~0xfff;",
"offset <<= 12;",
"}",
"tcg_gen_movi_i64(cpu_reg(VAR_0, VAR_3), base + offset);",
"}"
]
| [
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
]
|
12,974 | ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
{
VocDecContext *voc = s->priv_data;
AVCodecParameters *par = st->codecpar;
AVIOContext *pb = s->pb;
VocType type;
int size, tmp_codec=-1;
int sample_rate = 0;
int channels = 1;
int64_t duration;
int ret;
av_add_index_entry(st,
avio_tell(pb),
voc->pts,
voc->remaining_size,
0,
AVINDEX_KEYFRAME);
while (!voc->remaining_size) {
type = avio_r8(pb);
if (type == VOC_TYPE_EOF)
return AVERROR_EOF;
voc->remaining_size = avio_rl24(pb);
if (!voc->remaining_size) {
if (!s->pb->seekable)
return AVERROR(EIO);
voc->remaining_size = avio_size(pb) - avio_tell(pb);
}
max_size -= 4;
switch (type) {
case VOC_TYPE_VOICE_DATA:
if (!par->sample_rate) {
par->sample_rate = 1000000 / (256 - avio_r8(pb));
if (sample_rate)
par->sample_rate = sample_rate;
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
par->channels = channels;
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
} else
avio_skip(pb, 1);
tmp_codec = avio_r8(pb);
voc->remaining_size -= 2;
max_size -= 2;
channels = 1;
break;
case VOC_TYPE_VOICE_DATA_CONT:
break;
case VOC_TYPE_EXTENDED:
sample_rate = avio_rl16(pb);
avio_r8(pb);
channels = avio_r8(pb) + 1;
sample_rate = 256000000 / (channels * (65536 - sample_rate));
voc->remaining_size = 0;
max_size -= 4;
break;
case VOC_TYPE_NEW_VOICE_DATA:
if (!par->sample_rate) {
par->sample_rate = avio_rl32(pb);
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
par->bits_per_coded_sample = avio_r8(pb);
par->channels = avio_r8(pb);
} else
avio_skip(pb, 6);
tmp_codec = avio_rl16(pb);
avio_skip(pb, 4);
voc->remaining_size -= 12;
max_size -= 12;
break;
default:
avio_skip(pb, voc->remaining_size);
max_size -= voc->remaining_size;
voc->remaining_size = 0;
break;
}
}
if (par->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", par->sample_rate);
return AVERROR_INVALIDDATA;
}
if (tmp_codec >= 0) {
tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
if (par->codec_id == AV_CODEC_ID_NONE)
par->codec_id = tmp_codec;
else if (par->codec_id != tmp_codec)
av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
if (par->codec_id == AV_CODEC_ID_NONE) {
if (s->audio_codec_id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
return AVERROR(EINVAL);
}
av_log(s, AV_LOG_WARNING, "unknown codec tag\n");
}
}
par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample;
if (max_size <= 0)
max_size = 2048;
size = FFMIN(voc->remaining_size, max_size);
voc->remaining_size -= size;
ret = av_get_packet(pb, pkt, size);
pkt->dts = pkt->pts = voc->pts;
duration = av_get_audio_frame_duration2(st->codecpar, size);
if (duration > 0 && voc->pts != AV_NOPTS_VALUE)
voc->pts += duration;
else
voc->pts = AV_NOPTS_VALUE;
return ret;
}
| true | FFmpeg | ad5807f8aa883bee5431186dc1f24c5435d722d3 | ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
{
VocDecContext *voc = s->priv_data;
AVCodecParameters *par = st->codecpar;
AVIOContext *pb = s->pb;
VocType type;
int size, tmp_codec=-1;
int sample_rate = 0;
int channels = 1;
int64_t duration;
int ret;
av_add_index_entry(st,
avio_tell(pb),
voc->pts,
voc->remaining_size,
0,
AVINDEX_KEYFRAME);
while (!voc->remaining_size) {
type = avio_r8(pb);
if (type == VOC_TYPE_EOF)
return AVERROR_EOF;
voc->remaining_size = avio_rl24(pb);
if (!voc->remaining_size) {
if (!s->pb->seekable)
return AVERROR(EIO);
voc->remaining_size = avio_size(pb) - avio_tell(pb);
}
max_size -= 4;
switch (type) {
case VOC_TYPE_VOICE_DATA:
if (!par->sample_rate) {
par->sample_rate = 1000000 / (256 - avio_r8(pb));
if (sample_rate)
par->sample_rate = sample_rate;
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
par->channels = channels;
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
} else
avio_skip(pb, 1);
tmp_codec = avio_r8(pb);
voc->remaining_size -= 2;
max_size -= 2;
channels = 1;
break;
case VOC_TYPE_VOICE_DATA_CONT:
break;
case VOC_TYPE_EXTENDED:
sample_rate = avio_rl16(pb);
avio_r8(pb);
channels = avio_r8(pb) + 1;
sample_rate = 256000000 / (channels * (65536 - sample_rate));
voc->remaining_size = 0;
max_size -= 4;
break;
case VOC_TYPE_NEW_VOICE_DATA:
if (!par->sample_rate) {
par->sample_rate = avio_rl32(pb);
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
par->bits_per_coded_sample = avio_r8(pb);
par->channels = avio_r8(pb);
} else
avio_skip(pb, 6);
tmp_codec = avio_rl16(pb);
avio_skip(pb, 4);
voc->remaining_size -= 12;
max_size -= 12;
break;
default:
avio_skip(pb, voc->remaining_size);
max_size -= voc->remaining_size;
voc->remaining_size = 0;
break;
}
}
if (par->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", par->sample_rate);
return AVERROR_INVALIDDATA;
}
if (tmp_codec >= 0) {
tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
if (par->codec_id == AV_CODEC_ID_NONE)
par->codec_id = tmp_codec;
else if (par->codec_id != tmp_codec)
av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
if (par->codec_id == AV_CODEC_ID_NONE) {
if (s->audio_codec_id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
return AVERROR(EINVAL);
}
av_log(s, AV_LOG_WARNING, "unknown codec tag\n");
}
}
par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample;
if (max_size <= 0)
max_size = 2048;
size = FFMIN(voc->remaining_size, max_size);
voc->remaining_size -= size;
ret = av_get_packet(pb, pkt, size);
pkt->dts = pkt->pts = voc->pts;
duration = av_get_audio_frame_duration2(st->codecpar, size);
if (duration > 0 && voc->pts != AV_NOPTS_VALUE)
voc->pts += duration;
else
voc->pts = AV_NOPTS_VALUE;
return ret;
}
| {
"code": [
" par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample;"
],
"line_no": [
205
]
} | FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVStream *VAR_2, int VAR_3)
{
VocDecContext *voc = VAR_0->priv_data;
AVCodecParameters *par = VAR_2->codecpar;
AVIOContext *pb = VAR_0->pb;
VocType type;
int VAR_4, VAR_5=-1;
int VAR_6 = 0;
int VAR_7 = 1;
int64_t duration;
int VAR_8;
av_add_index_entry(VAR_2,
avio_tell(pb),
voc->pts,
voc->remaining_size,
0,
AVINDEX_KEYFRAME);
while (!voc->remaining_size) {
type = avio_r8(pb);
if (type == VOC_TYPE_EOF)
return AVERROR_EOF;
voc->remaining_size = avio_rl24(pb);
if (!voc->remaining_size) {
if (!VAR_0->pb->seekable)
return AVERROR(EIO);
voc->remaining_size = avio_size(pb) - avio_tell(pb);
}
VAR_3 -= 4;
switch (type) {
case VOC_TYPE_VOICE_DATA:
if (!par->VAR_6) {
par->VAR_6 = 1000000 / (256 - avio_r8(pb));
if (VAR_6)
par->VAR_6 = VAR_6;
avpriv_set_pts_info(VAR_2, 64, 1, par->VAR_6);
par->VAR_7 = VAR_7;
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
} else
avio_skip(pb, 1);
VAR_5 = avio_r8(pb);
voc->remaining_size -= 2;
VAR_3 -= 2;
VAR_7 = 1;
break;
case VOC_TYPE_VOICE_DATA_CONT:
break;
case VOC_TYPE_EXTENDED:
VAR_6 = avio_rl16(pb);
avio_r8(pb);
VAR_7 = avio_r8(pb) + 1;
VAR_6 = 256000000 / (VAR_7 * (65536 - VAR_6));
voc->remaining_size = 0;
VAR_3 -= 4;
break;
case VOC_TYPE_NEW_VOICE_DATA:
if (!par->VAR_6) {
par->VAR_6 = avio_rl32(pb);
avpriv_set_pts_info(VAR_2, 64, 1, par->VAR_6);
par->bits_per_coded_sample = avio_r8(pb);
par->VAR_7 = avio_r8(pb);
} else
avio_skip(pb, 6);
VAR_5 = avio_rl16(pb);
avio_skip(pb, 4);
voc->remaining_size -= 12;
VAR_3 -= 12;
break;
default:
avio_skip(pb, voc->remaining_size);
VAR_3 -= voc->remaining_size;
voc->remaining_size = 0;
break;
}
}
if (par->VAR_6 <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid sample rate %d\n", par->VAR_6);
return AVERROR_INVALIDDATA;
}
if (VAR_5 >= 0) {
VAR_5 = ff_codec_get_id(ff_voc_codec_tags, VAR_5);
if (par->codec_id == AV_CODEC_ID_NONE)
par->codec_id = VAR_5;
else if (par->codec_id != VAR_5)
av_log(VAR_0, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
if (par->codec_id == AV_CODEC_ID_NONE) {
if (VAR_0->audio_codec_id == AV_CODEC_ID_NONE) {
av_log(VAR_0, AV_LOG_ERROR, "unknown codec tag\n");
return AVERROR(EINVAL);
}
av_log(VAR_0, AV_LOG_WARNING, "unknown codec tag\n");
}
}
par->bit_rate = par->VAR_6 * par->VAR_7 * par->bits_per_coded_sample;
if (VAR_3 <= 0)
VAR_3 = 2048;
VAR_4 = FFMIN(voc->remaining_size, VAR_3);
voc->remaining_size -= VAR_4;
VAR_8 = av_get_packet(pb, VAR_1, VAR_4);
VAR_1->dts = VAR_1->pts = voc->pts;
duration = av_get_audio_frame_duration2(VAR_2->codecpar, VAR_4);
if (duration > 0 && voc->pts != AV_NOPTS_VALUE)
voc->pts += duration;
else
voc->pts = AV_NOPTS_VALUE;
return VAR_8;
}
| [
"FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVStream *VAR_2, int VAR_3)\n{",
"VocDecContext *voc = VAR_0->priv_data;",
"AVCodecParameters *par = VAR_2->codecpar;",
"AVIOContext *pb = VAR_0->pb;",
"VocType type;",
"int VAR_4, VAR_5=-1;",
"int VAR_6 = 0;",
"int VAR_7 = 1;",
"int64_t duration;",
"int VAR_8;",
"av_add_index_entry(VAR_2,\navio_tell(pb),\nvoc->pts,\nvoc->remaining_size,\n0,\nAVINDEX_KEYFRAME);",
"while (!voc->remaining_size) {",
"type = avio_r8(pb);",
"if (type == VOC_TYPE_EOF)\nreturn AVERROR_EOF;",
"voc->remaining_size = avio_rl24(pb);",
"if (!voc->remaining_size) {",
"if (!VAR_0->pb->seekable)\nreturn AVERROR(EIO);",
"voc->remaining_size = avio_size(pb) - avio_tell(pb);",
"}",
"VAR_3 -= 4;",
"switch (type) {",
"case VOC_TYPE_VOICE_DATA:\nif (!par->VAR_6) {",
"par->VAR_6 = 1000000 / (256 - avio_r8(pb));",
"if (VAR_6)\npar->VAR_6 = VAR_6;",
"avpriv_set_pts_info(VAR_2, 64, 1, par->VAR_6);",
"par->VAR_7 = VAR_7;",
"par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);",
"} else",
"avio_skip(pb, 1);",
"VAR_5 = avio_r8(pb);",
"voc->remaining_size -= 2;",
"VAR_3 -= 2;",
"VAR_7 = 1;",
"break;",
"case VOC_TYPE_VOICE_DATA_CONT:\nbreak;",
"case VOC_TYPE_EXTENDED:\nVAR_6 = avio_rl16(pb);",
"avio_r8(pb);",
"VAR_7 = avio_r8(pb) + 1;",
"VAR_6 = 256000000 / (VAR_7 * (65536 - VAR_6));",
"voc->remaining_size = 0;",
"VAR_3 -= 4;",
"break;",
"case VOC_TYPE_NEW_VOICE_DATA:\nif (!par->VAR_6) {",
"par->VAR_6 = avio_rl32(pb);",
"avpriv_set_pts_info(VAR_2, 64, 1, par->VAR_6);",
"par->bits_per_coded_sample = avio_r8(pb);",
"par->VAR_7 = avio_r8(pb);",
"} else",
"avio_skip(pb, 6);",
"VAR_5 = avio_rl16(pb);",
"avio_skip(pb, 4);",
"voc->remaining_size -= 12;",
"VAR_3 -= 12;",
"break;",
"default:\navio_skip(pb, voc->remaining_size);",
"VAR_3 -= voc->remaining_size;",
"voc->remaining_size = 0;",
"break;",
"}",
"}",
"if (par->VAR_6 <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid sample rate %d\\n\", par->VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_5 >= 0) {",
"VAR_5 = ff_codec_get_id(ff_voc_codec_tags, VAR_5);",
"if (par->codec_id == AV_CODEC_ID_NONE)\npar->codec_id = VAR_5;",
"else if (par->codec_id != VAR_5)\nav_log(VAR_0, AV_LOG_WARNING, \"Ignoring mid-stream change in audio codec\\n\");",
"if (par->codec_id == AV_CODEC_ID_NONE) {",
"if (VAR_0->audio_codec_id == AV_CODEC_ID_NONE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unknown codec tag\\n\");",
"return AVERROR(EINVAL);",
"}",
"av_log(VAR_0, AV_LOG_WARNING, \"unknown codec tag\\n\");",
"}",
"}",
"par->bit_rate = par->VAR_6 * par->VAR_7 * par->bits_per_coded_sample;",
"if (VAR_3 <= 0)\nVAR_3 = 2048;",
"VAR_4 = FFMIN(voc->remaining_size, VAR_3);",
"voc->remaining_size -= VAR_4;",
"VAR_8 = av_get_packet(pb, VAR_1, VAR_4);",
"VAR_1->dts = VAR_1->pts = voc->pts;",
"duration = av_get_audio_frame_duration2(VAR_2->codecpar, VAR_4);",
"if (duration > 0 && voc->pts != AV_NOPTS_VALUE)\nvoc->pts += duration;",
"else\nvoc->pts = AV_NOPTS_VALUE;",
"return VAR_8;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27,
29,
31,
33,
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
209,
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
225
],
[
227,
229
],
[
231,
233
],
[
237
],
[
239
]
]
|
12,975 | void AcpiCpuHotplug_add(ACPIGPE *gpe, AcpiCpuHotplug *g, CPUState *cpu)
{
CPUClass *k = CPU_GET_CLASS(cpu);
int64_t cpu_id;
*gpe->sts = *gpe->sts | ACPI_CPU_HOTPLUG_STATUS;
cpu_id = k->get_arch_id(CPU(cpu));
g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
} | true | qemu | 39ee3af3a85fedb55b9eeb1a0bc81a2460eeaa01 | void AcpiCpuHotplug_add(ACPIGPE *gpe, AcpiCpuHotplug *g, CPUState *cpu)
{
CPUClass *k = CPU_GET_CLASS(cpu);
int64_t cpu_id;
*gpe->sts = *gpe->sts | ACPI_CPU_HOTPLUG_STATUS;
cpu_id = k->get_arch_id(CPU(cpu));
g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
} | {
"code": [],
"line_no": []
} | void FUNC_0(ACPIGPE *VAR_0, AcpiCpuHotplug *VAR_1, CPUState *VAR_2)
{
CPUClass *k = CPU_GET_CLASS(VAR_2);
int64_t cpu_id;
*VAR_0->sts = *VAR_0->sts | ACPI_CPU_HOTPLUG_STATUS;
cpu_id = k->get_arch_id(CPU(VAR_2));
VAR_1->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
} | [
"void FUNC_0(ACPIGPE *VAR_0, AcpiCpuHotplug *VAR_1, CPUState *VAR_2)\n{",
"CPUClass *k = CPU_GET_CLASS(VAR_2);",
"int64_t cpu_id;",
"*VAR_0->sts = *VAR_0->sts | ACPI_CPU_HOTPLUG_STATUS;",
"cpu_id = k->get_arch_id(CPU(VAR_2));",
"VAR_1->sts[cpu_id / 8] |= (1 << (cpu_id % 8));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
16
],
[
18
]
]
|
12,976 | static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp,
sb_int8_array coding_method, int nb_channels,
int c, int superblocktype_2_3, int cm_table_select)
{
int ch, sb, j;
int tmp, acc, esp_40, comp;
int add1, add2, add3, add4;
int64_t multres;
// This should never happen
if (nb_channels <= 0)
return;
if (!superblocktype_2_3) {
/* This case is untested, no samples available */
SAMPLES_NEEDED
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) {
for (j = 1; j < 64; j++) {
add1 = tone_level_idx[ch][sb][j] - 10;
if (add1 < 0)
add1 = 0;
add2 = add3 = add4 = 0;
if (sb > 1) {
add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;
if (add2 < 0)
add2 = 0;
}
if (sb > 0) {
add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;
if (add3 < 0)
add3 = 0;
}
if (sb < 29) {
add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;
if (add4 < 0)
add4 = 0;
}
tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
if (tmp < 0)
tmp = 0;
tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
}
tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
}
acc = 0;
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
acc += tone_level_idx_temp[ch][sb][j];
if (acc)
tmp = c * 256 / (acc & 0xffff);
multres = 0x66666667 * (acc * 10);
esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++) {
comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
if (comp < 0)
comp += 0xff;
comp /= 256; // signed shift
switch(sb) {
case 0:
if (comp < 30)
comp = 30;
comp += 15;
break;
case 1:
if (comp < 24)
comp = 24;
comp += 10;
break;
case 2:
case 3:
case 4:
if (comp < 16)
comp = 16;
}
if (comp <= 5)
tmp = 0;
else if (comp <= 10)
tmp = 10;
else if (comp <= 16)
tmp = 16;
else if (comp <= 24)
tmp = -1;
else
tmp = 0;
coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
}
for (sb = 0; sb < 30; sb++)
fix_coding_method_array(sb, nb_channels, coding_method);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
if (sb >= 10) {
if (coding_method[ch][sb][j] < 10)
coding_method[ch][sb][j] = 10;
} else {
if (sb >= 2) {
if (coding_method[ch][sb][j] < 16)
coding_method[ch][sb][j] = 16;
} else {
if (coding_method[ch][sb][j] < 30)
coding_method[ch][sb][j] = 30;
}
}
} else { // superblocktype_2_3 != 0
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];
}
return;
}
| true | FFmpeg | d11f9e1b15e3aac6862bdfe2e5cb212b706e2c2f | static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp,
sb_int8_array coding_method, int nb_channels,
int c, int superblocktype_2_3, int cm_table_select)
{
int ch, sb, j;
int tmp, acc, esp_40, comp;
int add1, add2, add3, add4;
int64_t multres;
if (nb_channels <= 0)
return;
if (!superblocktype_2_3) {
SAMPLES_NEEDED
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) {
for (j = 1; j < 64; j++) {
add1 = tone_level_idx[ch][sb][j] - 10;
if (add1 < 0)
add1 = 0;
add2 = add3 = add4 = 0;
if (sb > 1) {
add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;
if (add2 < 0)
add2 = 0;
}
if (sb > 0) {
add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;
if (add3 < 0)
add3 = 0;
}
if (sb < 29) {
add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;
if (add4 < 0)
add4 = 0;
}
tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
if (tmp < 0)
tmp = 0;
tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
}
tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
}
acc = 0;
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
acc += tone_level_idx_temp[ch][sb][j];
if (acc)
tmp = c * 256 / (acc & 0xffff);
multres = 0x66666667 * (acc * 10);
esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++) {
comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
if (comp < 0)
comp += 0xff;
comp /= 256;
switch(sb) {
case 0:
if (comp < 30)
comp = 30;
comp += 15;
break;
case 1:
if (comp < 24)
comp = 24;
comp += 10;
break;
case 2:
case 3:
case 4:
if (comp < 16)
comp = 16;
}
if (comp <= 5)
tmp = 0;
else if (comp <= 10)
tmp = 10;
else if (comp <= 16)
tmp = 16;
else if (comp <= 24)
tmp = -1;
else
tmp = 0;
coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
}
for (sb = 0; sb < 30; sb++)
fix_coding_method_array(sb, nb_channels, coding_method);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
if (sb >= 10) {
if (coding_method[ch][sb][j] < 10)
coding_method[ch][sb][j] = 10;
} else {
if (sb >= 2) {
if (coding_method[ch][sb][j] < 16)
coding_method[ch][sb][j] = 16;
} else {
if (coding_method[ch][sb][j] < 30)
coding_method[ch][sb][j] = 30;
}
}
} else {
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];
}
return;
}
| {
"code": [
" for (j = 1; j < 64; j++) {"
],
"line_no": [
37
]
} | static void FUNC_0 (sb_int8_array VAR_0, sb_int8_array VAR_1,
sb_int8_array VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
int VAR_7, VAR_8, VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14, VAR_15, VAR_16, VAR_17;
int64_t multres;
if (VAR_3 <= 0)
return;
if (!VAR_5) {
SAMPLES_NEEDED
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
for (VAR_8 = 0; VAR_8 < 30; VAR_8++) {
for (VAR_9 = 1; VAR_9 < 64; VAR_9++) {
VAR_14 = VAR_0[VAR_7][VAR_8][VAR_9] - 10;
if (VAR_14 < 0)
VAR_14 = 0;
VAR_15 = VAR_16 = VAR_17 = 0;
if (VAR_8 > 1) {
VAR_15 = VAR_0[VAR_7][VAR_8 - 2][VAR_9] + tone_level_idx_offset_table[VAR_8][0] - 6;
if (VAR_15 < 0)
VAR_15 = 0;
}
if (VAR_8 > 0) {
VAR_16 = VAR_0[VAR_7][VAR_8 - 1][VAR_9] + tone_level_idx_offset_table[VAR_8][1] - 6;
if (VAR_16 < 0)
VAR_16 = 0;
}
if (VAR_8 < 29) {
VAR_17 = VAR_0[VAR_7][VAR_8 + 1][VAR_9] + tone_level_idx_offset_table[VAR_8][3] - 6;
if (VAR_17 < 0)
VAR_17 = 0;
}
VAR_10 = VAR_0[VAR_7][VAR_8][VAR_9 + 1] * 2 - VAR_17 - VAR_16 - VAR_15 - VAR_14;
if (VAR_10 < 0)
VAR_10 = 0;
VAR_1[VAR_7][VAR_8][VAR_9 + 1] = VAR_10 & 0xff;
}
VAR_1[VAR_7][VAR_8][0] = VAR_1[VAR_7][VAR_8][1];
}
VAR_11 = 0;
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
for (VAR_8 = 0; VAR_8 < 30; VAR_8++)
for (VAR_9 = 0; VAR_9 < 64; VAR_9++)
VAR_11 += VAR_1[VAR_7][VAR_8][VAR_9];
if (VAR_11)
VAR_10 = VAR_4 * 256 / (VAR_11 & 0xffff);
multres = 0x66666667 * (VAR_11 * 10);
VAR_12 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
for (VAR_8 = 0; VAR_8 < 30; VAR_8++)
for (VAR_9 = 0; VAR_9 < 64; VAR_9++) {
VAR_13 = VAR_1[VAR_7][VAR_8][VAR_9]* VAR_12 * 10;
if (VAR_13 < 0)
VAR_13 += 0xff;
VAR_13 /= 256;
switch(VAR_8) {
case 0:
if (VAR_13 < 30)
VAR_13 = 30;
VAR_13 += 15;
break;
case 1:
if (VAR_13 < 24)
VAR_13 = 24;
VAR_13 += 10;
break;
case 2:
case 3:
case 4:
if (VAR_13 < 16)
VAR_13 = 16;
}
if (VAR_13 <= 5)
VAR_10 = 0;
else if (VAR_13 <= 10)
VAR_10 = 10;
else if (VAR_13 <= 16)
VAR_10 = 16;
else if (VAR_13 <= 24)
VAR_10 = -1;
else
VAR_10 = 0;
VAR_2[VAR_7][VAR_8][VAR_9] = ((VAR_10 & 0xfffa) + 30 )& 0xff;
}
for (VAR_8 = 0; VAR_8 < 30; VAR_8++)
fix_coding_method_array(VAR_8, VAR_3, VAR_2);
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
for (VAR_8 = 0; VAR_8 < 30; VAR_8++)
for (VAR_9 = 0; VAR_9 < 64; VAR_9++)
if (VAR_8 >= 10) {
if (VAR_2[VAR_7][VAR_8][VAR_9] < 10)
VAR_2[VAR_7][VAR_8][VAR_9] = 10;
} else {
if (VAR_8 >= 2) {
if (VAR_2[VAR_7][VAR_8][VAR_9] < 16)
VAR_2[VAR_7][VAR_8][VAR_9] = 16;
} else {
if (VAR_2[VAR_7][VAR_8][VAR_9] < 30)
VAR_2[VAR_7][VAR_8][VAR_9] = 30;
}
}
} else {
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
for (VAR_8 = 0; VAR_8 < 30; VAR_8++)
for (VAR_9 = 0; VAR_9 < 64; VAR_9++)
VAR_2[VAR_7][VAR_8][VAR_9] = coding_method_table[VAR_6][VAR_8];
}
return;
}
| [
"static void FUNC_0 (sb_int8_array VAR_0, sb_int8_array VAR_1,\nsb_int8_array VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13;",
"int VAR_14, VAR_15, VAR_16, VAR_17;",
"int64_t multres;",
"if (VAR_3 <= 0)\nreturn;",
"if (!VAR_5) {",
"SAMPLES_NEEDED\nfor (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++) {",
"for (VAR_9 = 1; VAR_9 < 64; VAR_9++) {",
"VAR_14 = VAR_0[VAR_7][VAR_8][VAR_9] - 10;",
"if (VAR_14 < 0)\nVAR_14 = 0;",
"VAR_15 = VAR_16 = VAR_17 = 0;",
"if (VAR_8 > 1) {",
"VAR_15 = VAR_0[VAR_7][VAR_8 - 2][VAR_9] + tone_level_idx_offset_table[VAR_8][0] - 6;",
"if (VAR_15 < 0)\nVAR_15 = 0;",
"}",
"if (VAR_8 > 0) {",
"VAR_16 = VAR_0[VAR_7][VAR_8 - 1][VAR_9] + tone_level_idx_offset_table[VAR_8][1] - 6;",
"if (VAR_16 < 0)\nVAR_16 = 0;",
"}",
"if (VAR_8 < 29) {",
"VAR_17 = VAR_0[VAR_7][VAR_8 + 1][VAR_9] + tone_level_idx_offset_table[VAR_8][3] - 6;",
"if (VAR_17 < 0)\nVAR_17 = 0;",
"}",
"VAR_10 = VAR_0[VAR_7][VAR_8][VAR_9 + 1] * 2 - VAR_17 - VAR_16 - VAR_15 - VAR_14;",
"if (VAR_10 < 0)\nVAR_10 = 0;",
"VAR_1[VAR_7][VAR_8][VAR_9 + 1] = VAR_10 & 0xff;",
"}",
"VAR_1[VAR_7][VAR_8][0] = VAR_1[VAR_7][VAR_8][1];",
"}",
"VAR_11 = 0;",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++)",
"for (VAR_9 = 0; VAR_9 < 64; VAR_9++)",
"VAR_11 += VAR_1[VAR_7][VAR_8][VAR_9];",
"if (VAR_11)\nVAR_10 = VAR_4 * 256 / (VAR_11 & 0xffff);",
"multres = 0x66666667 * (VAR_11 * 10);",
"VAR_12 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++)",
"for (VAR_9 = 0; VAR_9 < 64; VAR_9++) {",
"VAR_13 = VAR_1[VAR_7][VAR_8][VAR_9]* VAR_12 * 10;",
"if (VAR_13 < 0)\nVAR_13 += 0xff;",
"VAR_13 /= 256;",
"switch(VAR_8) {",
"case 0:\nif (VAR_13 < 30)\nVAR_13 = 30;",
"VAR_13 += 15;",
"break;",
"case 1:\nif (VAR_13 < 24)\nVAR_13 = 24;",
"VAR_13 += 10;",
"break;",
"case 2:\ncase 3:\ncase 4:\nif (VAR_13 < 16)\nVAR_13 = 16;",
"}",
"if (VAR_13 <= 5)\nVAR_10 = 0;",
"else if (VAR_13 <= 10)\nVAR_10 = 10;",
"else if (VAR_13 <= 16)\nVAR_10 = 16;",
"else if (VAR_13 <= 24)\nVAR_10 = -1;",
"else\nVAR_10 = 0;",
"VAR_2[VAR_7][VAR_8][VAR_9] = ((VAR_10 & 0xfffa) + 30 )& 0xff;",
"}",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++)",
"fix_coding_method_array(VAR_8, VAR_3, VAR_2);",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++)",
"for (VAR_9 = 0; VAR_9 < 64; VAR_9++)",
"if (VAR_8 >= 10) {",
"if (VAR_2[VAR_7][VAR_8][VAR_9] < 10)\nVAR_2[VAR_7][VAR_8][VAR_9] = 10;",
"} else {",
"if (VAR_8 >= 2) {",
"if (VAR_2[VAR_7][VAR_8][VAR_9] < 16)\nVAR_2[VAR_7][VAR_8][VAR_9] = 16;",
"} else {",
"if (VAR_2[VAR_7][VAR_8][VAR_9] < 30)\nVAR_2[VAR_7][VAR_8][VAR_9] = 30;",
"}",
"}",
"} else {",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < 30; VAR_8++)",
"for (VAR_9 = 0; VAR_9 < 64; VAR_9++)",
"VAR_2[VAR_7][VAR_8][VAR_9] = coding_method_table[VAR_6][VAR_8];",
"}",
"return;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21,
23
],
[
27
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135,
137,
139
],
[
141
],
[
143
],
[
145,
147,
149,
151,
153
],
[
155
],
[
157,
159
],
[
161,
163
],
[
165,
167
],
[
169,
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
]
]
|
12,977 | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS])
{
int i;
int w_align= 1;
int h_align= 1;
switch(s->pix_fmt){
case PIX_FMT_YUV420P:
case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV440P:
case PIX_FMT_YUV444P:
case PIX_FMT_GBRP:
case PIX_FMT_GRAY8:
case PIX_FMT_GRAY16BE:
case PIX_FMT_GRAY16LE:
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ440P:
case PIX_FMT_YUVJ444P:
case PIX_FMT_YUVA420P:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP10BE:
w_align = 16; //FIXME assume 16 pixel per macroblock
h_align = 16 * 2; // interlaced needs 2 macroblocks height
break;
case PIX_FMT_YUV411P:
case PIX_FMT_UYYVYY411:
w_align=32;
h_align=8;
break;
case PIX_FMT_YUV410P:
if(s->codec_id == CODEC_ID_SVQ1){
w_align=64;
h_align=64;
}
case PIX_FMT_RGB555:
if(s->codec_id == CODEC_ID_RPZA){
w_align=4;
h_align=4;
}
case PIX_FMT_PAL8:
case PIX_FMT_BGR8:
case PIX_FMT_RGB8:
if(s->codec_id == CODEC_ID_SMC){
w_align=4;
h_align=4;
}
break;
case PIX_FMT_BGR24:
if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
w_align=4;
h_align=4;
}
break;
default:
w_align= 1;
h_align= 1;
break;
}
*width = FFALIGN(*width , w_align);
*height= FFALIGN(*height, h_align);
if(s->codec_id == CODEC_ID_H264 || s->lowres)
*height+=2; // some of the optimized chroma MC reads one line too much
// which is also done in mpeg decoders with lowres > 0
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = STRIDE_ALIGN;
//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
//picture size unneccessarily in some cases. The solution here is not
//pretty and better ideas are welcome!
#if HAVE_MMX
if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
s->codec_id == CODEC_ID_VP6A) {
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = 16;
}
#endif
}
| true | FFmpeg | 2d9535ad317733c977a89194975f14e0cc04fb7f | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS])
{
int i;
int w_align= 1;
int h_align= 1;
switch(s->pix_fmt){
case PIX_FMT_YUV420P:
case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV440P:
case PIX_FMT_YUV444P:
case PIX_FMT_GBRP:
case PIX_FMT_GRAY8:
case PIX_FMT_GRAY16BE:
case PIX_FMT_GRAY16LE:
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ440P:
case PIX_FMT_YUVJ444P:
case PIX_FMT_YUVA420P:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP10BE:
w_align = 16;
h_align = 16 * 2;
break;
case PIX_FMT_YUV411P:
case PIX_FMT_UYYVYY411:
w_align=32;
h_align=8;
break;
case PIX_FMT_YUV410P:
if(s->codec_id == CODEC_ID_SVQ1){
w_align=64;
h_align=64;
}
case PIX_FMT_RGB555:
if(s->codec_id == CODEC_ID_RPZA){
w_align=4;
h_align=4;
}
case PIX_FMT_PAL8:
case PIX_FMT_BGR8:
case PIX_FMT_RGB8:
if(s->codec_id == CODEC_ID_SMC){
w_align=4;
h_align=4;
}
break;
case PIX_FMT_BGR24:
if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
w_align=4;
h_align=4;
}
break;
default:
w_align= 1;
h_align= 1;
break;
}
*width = FFALIGN(*width , w_align);
*height= FFALIGN(*height, h_align);
if(s->codec_id == CODEC_ID_H264 || s->lowres)
*height+=2;
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = STRIDE_ALIGN;
#if HAVE_MMX
if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
s->codec_id == CODEC_ID_VP6A) {
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = 16;
}
#endif
}
| {
"code": [
" for (i = 0; i < AV_NUM_DATA_POINTERS; i++)",
" for (i = 0; i < AV_NUM_DATA_POINTERS; i++)"
],
"line_no": [
167,
187
]
} | void FUNC_0(AVCodecContext *VAR_0, int *VAR_1, int *VAR_2,
int VAR_3[AV_NUM_DATA_POINTERS])
{
int VAR_4;
int VAR_5= 1;
int VAR_6= 1;
switch(VAR_0->pix_fmt){
case PIX_FMT_YUV420P:
case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV440P:
case PIX_FMT_YUV444P:
case PIX_FMT_GBRP:
case PIX_FMT_GRAY8:
case PIX_FMT_GRAY16BE:
case PIX_FMT_GRAY16LE:
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ440P:
case PIX_FMT_YUVJ444P:
case PIX_FMT_YUVA420P:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP10BE:
VAR_5 = 16;
VAR_6 = 16 * 2;
break;
case PIX_FMT_YUV411P:
case PIX_FMT_UYYVYY411:
VAR_5=32;
VAR_6=8;
break;
case PIX_FMT_YUV410P:
if(VAR_0->codec_id == CODEC_ID_SVQ1){
VAR_5=64;
VAR_6=64;
}
case PIX_FMT_RGB555:
if(VAR_0->codec_id == CODEC_ID_RPZA){
VAR_5=4;
VAR_6=4;
}
case PIX_FMT_PAL8:
case PIX_FMT_BGR8:
case PIX_FMT_RGB8:
if(VAR_0->codec_id == CODEC_ID_SMC){
VAR_5=4;
VAR_6=4;
}
break;
case PIX_FMT_BGR24:
if((VAR_0->codec_id == CODEC_ID_MSZH) || (VAR_0->codec_id == CODEC_ID_ZLIB)){
VAR_5=4;
VAR_6=4;
}
break;
default:
VAR_5= 1;
VAR_6= 1;
break;
}
*VAR_1 = FFALIGN(*VAR_1 , VAR_5);
*VAR_2= FFALIGN(*VAR_2, VAR_6);
if(VAR_0->codec_id == CODEC_ID_H264 || VAR_0->lowres)
*VAR_2+=2;
for (VAR_4 = 0; VAR_4 < AV_NUM_DATA_POINTERS; VAR_4++)
VAR_3[VAR_4] = STRIDE_ALIGN;
#if HAVE_MMX
if(VAR_0->codec_id == CODEC_ID_SVQ1 || VAR_0->codec_id == CODEC_ID_VP5 ||
VAR_0->codec_id == CODEC_ID_VP6 || VAR_0->codec_id == CODEC_ID_VP6F ||
VAR_0->codec_id == CODEC_ID_VP6A) {
for (VAR_4 = 0; VAR_4 < AV_NUM_DATA_POINTERS; VAR_4++)
VAR_3[VAR_4] = 16;
}
#endif
}
| [
"void FUNC_0(AVCodecContext *VAR_0, int *VAR_1, int *VAR_2,\nint VAR_3[AV_NUM_DATA_POINTERS])\n{",
"int VAR_4;",
"int VAR_5= 1;",
"int VAR_6= 1;",
"switch(VAR_0->pix_fmt){",
"case PIX_FMT_YUV420P:\ncase PIX_FMT_YUYV422:\ncase PIX_FMT_UYVY422:\ncase PIX_FMT_YUV422P:\ncase PIX_FMT_YUV440P:\ncase PIX_FMT_YUV444P:\ncase PIX_FMT_GBRP:\ncase PIX_FMT_GRAY8:\ncase PIX_FMT_GRAY16BE:\ncase PIX_FMT_GRAY16LE:\ncase PIX_FMT_YUVJ420P:\ncase PIX_FMT_YUVJ422P:\ncase PIX_FMT_YUVJ440P:\ncase PIX_FMT_YUVJ444P:\ncase PIX_FMT_YUVA420P:\ncase PIX_FMT_YUV420P9LE:\ncase PIX_FMT_YUV420P9BE:\ncase PIX_FMT_YUV420P10LE:\ncase PIX_FMT_YUV420P10BE:\ncase PIX_FMT_YUV422P9LE:\ncase PIX_FMT_YUV422P9BE:\ncase PIX_FMT_YUV422P10LE:\ncase PIX_FMT_YUV422P10BE:\ncase PIX_FMT_YUV444P9LE:\ncase PIX_FMT_YUV444P9BE:\ncase PIX_FMT_YUV444P10LE:\ncase PIX_FMT_YUV444P10BE:\ncase PIX_FMT_GBRP9LE:\ncase PIX_FMT_GBRP9BE:\ncase PIX_FMT_GBRP10LE:\ncase PIX_FMT_GBRP10BE:\nVAR_5 = 16;",
"VAR_6 = 16 * 2;",
"break;",
"case PIX_FMT_YUV411P:\ncase PIX_FMT_UYYVYY411:\nVAR_5=32;",
"VAR_6=8;",
"break;",
"case PIX_FMT_YUV410P:\nif(VAR_0->codec_id == CODEC_ID_SVQ1){",
"VAR_5=64;",
"VAR_6=64;",
"}",
"case PIX_FMT_RGB555:\nif(VAR_0->codec_id == CODEC_ID_RPZA){",
"VAR_5=4;",
"VAR_6=4;",
"}",
"case PIX_FMT_PAL8:\ncase PIX_FMT_BGR8:\ncase PIX_FMT_RGB8:\nif(VAR_0->codec_id == CODEC_ID_SMC){",
"VAR_5=4;",
"VAR_6=4;",
"}",
"break;",
"case PIX_FMT_BGR24:\nif((VAR_0->codec_id == CODEC_ID_MSZH) || (VAR_0->codec_id == CODEC_ID_ZLIB)){",
"VAR_5=4;",
"VAR_6=4;",
"}",
"break;",
"default:\nVAR_5= 1;",
"VAR_6= 1;",
"break;",
"}",
"*VAR_1 = FFALIGN(*VAR_1 , VAR_5);",
"*VAR_2= FFALIGN(*VAR_2, VAR_6);",
"if(VAR_0->codec_id == CODEC_ID_H264 || VAR_0->lowres)\n*VAR_2+=2;",
"for (VAR_4 = 0; VAR_4 < AV_NUM_DATA_POINTERS; VAR_4++)",
"VAR_3[VAR_4] = STRIDE_ALIGN;",
"#if HAVE_MMX\nif(VAR_0->codec_id == CODEC_ID_SVQ1 || VAR_0->codec_id == CODEC_ID_VP5 ||\nVAR_0->codec_id == CODEC_ID_VP6 || VAR_0->codec_id == CODEC_ID_VP6F ||\nVAR_0->codec_id == CODEC_ID_VP6A) {",
"for (VAR_4 = 0; VAR_4 < AV_NUM_DATA_POINTERS; VAR_4++)",
"VAR_3[VAR_4] = 16;",
"}",
"#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,
1,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
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
],
[
155
],
[
157
],
[
159,
161
],
[
167
],
[
169
],
[
179,
181,
183,
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
]
]
|
12,978 | PPC_OP(addze)
{
T1 = T0;
T0 += xer_ca;
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(addze)
{
T1 = T0;
T0 += xer_ca;
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| {
"code": [
" RETURN();",
" xer_ca = 1;",
" T1 = T0;",
" if (T0 < T1) {",
" } else {",
" xer_ca = 0;",
" T1 = T0;",
"PPC_OP(addze)",
" T1 = T0;",
" if (T0 < T1) {",
" xer_ca = 1;",
" } else {",
" xer_ca = 0;",
" xer_ca = 1;",
" } else {",
" if (T0 < T1) {",
" if (T0 < T1) {",
" T1 = T0;",
" } else {",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" } else {",
" } else {",
" T0 += xer_ca;",
" xer_ca = 0;",
" } else {",
" RETURN();",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" xer_ca = 0;",
" } else {"
],
"line_no": [
19,
11,
5,
9,
13,
15,
5,
1,
5,
9,
11,
13,
15,
11,
13,
9,
9,
5,
13,
15,
13,
11,
13,
13,
7,
15,
13,
19,
15,
13,
11,
15,
13
]
} | FUNC_0(VAR_0)
{
T1 = T0;
T0 += xer_ca;
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"T1 = T0;",
"T0 += xer_ca;",
"if (T0 < T1) {",
"xer_ca = 1;",
"} else {",
"xer_ca = 0;",
"}",
"RETURN();",
"}"
]
| [
1,
1,
1,
1,
1,
0,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
12,979 | static int get_unused_buffer(QEMUFile *f, void *pv, size_t size)
{
qemu_fseek(f, size, SEEK_CUR);
return 0;
}
| true | qemu | 21174c34b6b9ace9ad82e0deb13be752d28a5907 | static int get_unused_buffer(QEMUFile *f, void *pv, size_t size)
{
qemu_fseek(f, size, SEEK_CUR);
return 0;
}
| {
"code": [
" qemu_fseek(f, size, SEEK_CUR);",
" return 0;",
" qemu_fseek(f, size, SEEK_CUR);"
],
"line_no": [
5,
7,
5
]
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
qemu_fseek(VAR_0, VAR_2, SEEK_CUR);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"qemu_fseek(VAR_0, VAR_2, SEEK_CUR);",
"return 0;",
"}"
]
| [
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
12,980 | void hmp_savevm(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int ret;
QEMUFile *f;
int saved_vm_running;
uint64_t vm_state_size;
qemu_timeval tv;
struct tm tm;
const char *name = qdict_get_try_str(qdict, "name");
Error *local_err = NULL;
/* Verify if there is a device that doesn't support snapshots and is writable */
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
if (!bdrv_can_snapshot(bs)) {
monitor_printf(mon, "Device '%s' is writable but does not support snapshots.\n",
bdrv_get_device_name(bs));
bs = find_vmstate_bs();
if (!bs) {
monitor_printf(mon, "No block device can accept snapshots\n");
saved_vm_running = runstate_is_running();
vm_stop(RUN_STATE_SAVE_VM);
memset(sn, 0, sizeof(*sn));
/* fill auxiliary fields */
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (name) {
ret = bdrv_snapshot_find(bs, old_sn, name);
if (ret >= 0) {
pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
} else {
pstrcpy(sn->name, sizeof(sn->name), name);
} else {
/* cast below needed for OpenBSD where tv_sec is still 'long' */
localtime_r((const time_t *)&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
/* Delete old snapshots of the same name */
if (name && del_existing_snapshots(mon, name) < 0) {
goto the_end;
/* save the VM state */
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
goto the_end;
ret = qemu_savevm_state(f, &local_err);
vm_state_size = qemu_ftell(f);
qemu_fclose(f);
if (ret < 0) {
monitor_printf(mon, "%s\n", error_get_pretty(local_err));
error_free(local_err);
goto the_end;
/* create the snapshots */
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
/* Write VM state size only to the image that contains the state */
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
ret = bdrv_snapshot_create(bs1, sn);
if (ret < 0) {
monitor_printf(mon, "Error while creating snapshot on '%s'\n",
bdrv_get_device_name(bs1));
the_end:
if (saved_vm_running) {
vm_start(); | true | qemu | 560d027b54067ffa4e79c6f7c0a499abb0d749a3 | void hmp_savevm(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int ret;
QEMUFile *f;
int saved_vm_running;
uint64_t vm_state_size;
qemu_timeval tv;
struct tm tm;
const char *name = qdict_get_try_str(qdict, "name");
Error *local_err = NULL;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
if (!bdrv_can_snapshot(bs)) {
monitor_printf(mon, "Device '%s' is writable but does not support snapshots.\n",
bdrv_get_device_name(bs));
bs = find_vmstate_bs();
if (!bs) {
monitor_printf(mon, "No block device can accept snapshots\n");
saved_vm_running = runstate_is_running();
vm_stop(RUN_STATE_SAVE_VM);
memset(sn, 0, sizeof(*sn));
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (name) {
ret = bdrv_snapshot_find(bs, old_sn, name);
if (ret >= 0) {
pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
} else {
pstrcpy(sn->name, sizeof(sn->name), name);
} else {
localtime_r((const time_t *)&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
if (name && del_existing_snapshots(mon, name) < 0) {
goto the_end;
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
goto the_end;
ret = qemu_savevm_state(f, &local_err);
vm_state_size = qemu_ftell(f);
qemu_fclose(f);
if (ret < 0) {
monitor_printf(mon, "%s\n", error_get_pretty(local_err));
error_free(local_err);
goto the_end;
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
ret = bdrv_snapshot_create(bs1, sn);
if (ret < 0) {
monitor_printf(mon, "Error while creating snapshot on '%s'\n",
bdrv_get_device_name(bs1));
the_end:
if (saved_vm_running) {
vm_start(); | {
"code": [],
"line_no": []
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int VAR_2;
QEMUFile *f;
int VAR_3;
uint64_t vm_state_size;
qemu_timeval tv;
struct VAR_4 VAR_4;
const char *VAR_5 = qdict_get_try_str(VAR_1, "VAR_5");
Error *local_err = NULL;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
if (!bdrv_can_snapshot(bs)) {
monitor_printf(VAR_0, "Device '%s' is writable but does not support snapshots.\n",
bdrv_get_device_name(bs));
bs = find_vmstate_bs();
if (!bs) {
monitor_printf(VAR_0, "No block device can accept snapshots\n");
VAR_3 = runstate_is_running();
vm_stop(RUN_STATE_SAVE_VM);
memset(sn, 0, sizeof(*sn));
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (VAR_5) {
VAR_2 = bdrv_snapshot_find(bs, old_sn, VAR_5);
if (VAR_2 >= 0) {
pstrcpy(sn->VAR_5, sizeof(sn->VAR_5), old_sn->VAR_5);
pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
} else {
pstrcpy(sn->VAR_5, sizeof(sn->VAR_5), VAR_5);
} else {
localtime_r((const time_t *)&tv.tv_sec, &VAR_4);
strftime(sn->VAR_5, sizeof(sn->VAR_5), "vm-%Y%m%d%H%M%S", &VAR_4);
if (VAR_5 && del_existing_snapshots(VAR_0, VAR_5) < 0) {
goto the_end;
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
monitor_printf(VAR_0, "Could not open VM state file\n");
goto the_end;
VAR_2 = qemu_savevm_state(f, &local_err);
vm_state_size = qemu_ftell(f);
qemu_fclose(f);
if (VAR_2 < 0) {
monitor_printf(VAR_0, "%s\n", error_get_pretty(local_err));
error_free(local_err);
goto the_end;
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
VAR_2 = bdrv_snapshot_create(bs1, sn);
if (VAR_2 < 0) {
monitor_printf(VAR_0, "Error while creating snapshot on '%s'\n",
bdrv_get_device_name(bs1));
the_end:
if (VAR_3) {
vm_start(); | [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"BlockDriverState *bs, *bs1;",
"QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;",
"int VAR_2;",
"QEMUFile *f;",
"int VAR_3;",
"uint64_t vm_state_size;",
"qemu_timeval tv;",
"struct VAR_4 VAR_4;",
"const char *VAR_5 = qdict_get_try_str(VAR_1, \"VAR_5\");",
"Error *local_err = NULL;",
"bs = NULL;",
"while ((bs = bdrv_next(bs))) {",
"if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {",
"continue;",
"if (!bdrv_can_snapshot(bs)) {",
"monitor_printf(VAR_0, \"Device '%s' is writable but does not support snapshots.\\n\",\nbdrv_get_device_name(bs));",
"bs = find_vmstate_bs();",
"if (!bs) {",
"monitor_printf(VAR_0, \"No block device can accept snapshots\\n\");",
"VAR_3 = runstate_is_running();",
"vm_stop(RUN_STATE_SAVE_VM);",
"memset(sn, 0, sizeof(*sn));",
"qemu_gettimeofday(&tv);",
"sn->date_sec = tv.tv_sec;",
"sn->date_nsec = tv.tv_usec * 1000;",
"sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);",
"if (VAR_5) {",
"VAR_2 = bdrv_snapshot_find(bs, old_sn, VAR_5);",
"if (VAR_2 >= 0) {",
"pstrcpy(sn->VAR_5, sizeof(sn->VAR_5), old_sn->VAR_5);",
"pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);",
"} else {",
"pstrcpy(sn->VAR_5, sizeof(sn->VAR_5), VAR_5);",
"} else {",
"localtime_r((const time_t *)&tv.tv_sec, &VAR_4);",
"strftime(sn->VAR_5, sizeof(sn->VAR_5), \"vm-%Y%m%d%H%M%S\", &VAR_4);",
"if (VAR_5 && del_existing_snapshots(VAR_0, VAR_5) < 0) {",
"goto the_end;",
"f = qemu_fopen_bdrv(bs, 1);",
"if (!f) {",
"monitor_printf(VAR_0, \"Could not open VM state file\\n\");",
"goto the_end;",
"VAR_2 = qemu_savevm_state(f, &local_err);",
"vm_state_size = qemu_ftell(f);",
"qemu_fclose(f);",
"if (VAR_2 < 0) {",
"monitor_printf(VAR_0, \"%s\\n\", error_get_pretty(local_err));",
"error_free(local_err);",
"goto the_end;",
"bs1 = NULL;",
"while ((bs1 = bdrv_next(bs1))) {",
"if (bdrv_can_snapshot(bs1)) {",
"sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);",
"VAR_2 = bdrv_snapshot_create(bs1, sn);",
"if (VAR_2 < 0) {",
"monitor_printf(VAR_0, \"Error while creating snapshot on '%s'\\n\",\nbdrv_get_device_name(bs1));",
"the_end:\nif (VAR_3) {",
"vm_start();"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19,
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
41
],
[
42
],
[
44
],
[
45
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
59
],
[
60
],
[
61
],
[
63
],
[
64
],
[
65
],
[
66,
67
],
[
68,
69
],
[
70
]
]
|
12,981 | static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
SWFContext *swf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vst = NULL, *ast = NULL, *st = 0;
int tag, len, i, frame, v, res;
#if CONFIG_ZLIB
if (swf->zpb)
pb = swf->zpb;
#endif
for(;;) {
uint64_t pos = avio_tell(pb);
tag = get_swf_tag(pb, &len);
if (tag < 0)
return tag;
if (len < 0) {
av_log(s, AV_LOG_ERROR, "invalid tag length: %d\n", len);
return AVERROR_INVALIDDATA;
}
if (tag == TAG_VIDEOSTREAM) {
int ch_id = avio_rl16(pb);
len -= 2;
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id)
goto skip;
}
avio_rl16(pb);
avio_rl16(pb);
avio_rl16(pb);
avio_r8(pb);
/* Check for FLV1 */
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = ch_id;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));
avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);
len -= 8;
} else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
/* streaming found */
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)
goto skip;
}
avio_r8(pb);
v = avio_r8(pb);
swf->samples_per_frame = avio_rl16(pb);
ast = create_new_audio_stream(s, -1, v); /* -1 to avoid clash with video stream ch_id */
if (!ast)
return AVERROR(ENOMEM);
len -= 4;
} else if (tag == TAG_DEFINESOUND) {
/* audio stream */
int ch_id = avio_rl16(pb);
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == ch_id)
goto skip;
}
// FIXME: The entire audio stream is stored in a single chunk/tag. Normally,
// these are smaller audio streams in DEFINESOUND tags, but it's technically
// possible they could be huge. Break it up into multiple packets if it's big.
v = avio_r8(pb);
ast = create_new_audio_stream(s, ch_id, v);
if (!ast)
return AVERROR(ENOMEM);
ast->duration = avio_rl32(pb); // number of samples
if (((v>>4) & 15) == 2) { // MP3 sound data record
ast->skip_samples = avio_rl16(pb);
len -= 2;
}
len -= 7;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
pkt->pos = pos;
pkt->stream_index = ast->index;
return pkt->size;
} else if (tag == TAG_VIDEOFRAME) {
int ch_id = avio_rl16(pb);
len -= 2;
for(i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
frame = avio_rl16(pb);
len -= 2;
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
pkt->pos = pos;
pkt->pts = frame;
pkt->stream_index = st->index;
return pkt->size;
}
}
} else if (tag == TAG_DEFINEBITSLOSSLESS || tag == TAG_DEFINEBITSLOSSLESS2) {
#if CONFIG_ZLIB
long out_len;
uint8_t *buf = NULL, *zbuf = NULL, *pal;
uint32_t colormap[AVPALETTE_COUNT] = {0};
const int alpha_bmp = tag == TAG_DEFINEBITSLOSSLESS2;
const int colormapbpp = 3 + alpha_bmp;
int linesize, colormapsize = 0;
const int ch_id = avio_rl16(pb);
const int bmp_fmt = avio_r8(pb);
const int width = avio_rl16(pb);
const int height = avio_rl16(pb);
len -= 2+1+2+2;
switch (bmp_fmt) {
case 3: // PAL-8
linesize = width;
colormapsize = avio_r8(pb) + 1;
len--;
break;
case 4: // RGB15
linesize = width * 2;
break;
case 5: // RGB24 (0RGB)
linesize = width * 4;
break;
default:
av_log(s, AV_LOG_ERROR, "invalid bitmap format %d, skipped\n", bmp_fmt);
goto bitmap_end_skip;
}
linesize = FFALIGN(linesize, 4);
if (av_image_check_size(width, height, 0, s) < 0 ||
linesize >= INT_MAX / height ||
linesize * height >= INT_MAX - colormapsize * colormapbpp) {
av_log(s, AV_LOG_ERROR, "invalid frame size %dx%d\n", width, height);
goto bitmap_end_skip;
}
out_len = colormapsize * colormapbpp + linesize * height;
av_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
zbuf = av_malloc(len);
buf = av_malloc(out_len);
if (!zbuf || !buf) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
len = avio_read(pb, zbuf, len);
if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
av_log(s, AV_LOG_WARNING, "Failed to uncompress one bitmap\n");
goto bitmap_end_skip;
}
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)
break;
}
if (i == s->nb_streams) {
vst = avformat_new_stream(s, NULL);
if (!vst) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
vst->id = -3; /* -3 to avoid clash with video stream and audio stream */
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
st->codec->width = width;
st->codec->height = height;
if ((res = av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
goto bitmap_end;
pkt->pos = pos;
pkt->stream_index = st->index;
switch (bmp_fmt) {
case 3:
st->codec->pix_fmt = AV_PIX_FMT_PAL8;
for (i = 0; i < colormapsize; i++)
if (alpha_bmp) colormap[i] = buf[3]<<24 | AV_RB24(buf + 4*i);
else colormap[i] = 0xffU <<24 | AV_RB24(buf + 3*i);
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
memcpy(pal, colormap, AVPALETTE_SIZE);
break;
case 4:
st->codec->pix_fmt = AV_PIX_FMT_RGB555;
break;
case 5:
st->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;
break;
default:
av_assert0(0);
}
if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA;
goto bitmap_end;
}
memcpy(pkt->data, buf + colormapsize*colormapbpp, linesize * height);
res = pkt->size;
bitmap_end:
av_freep(&zbuf);
av_freep(&buf);
return res;
bitmap_end_skip:
av_freep(&zbuf);
av_freep(&buf);
#else
av_log(s, AV_LOG_ERROR, "this file requires zlib support compiled in\n");
#endif
} else if (tag == TAG_STREAMBLOCK) {
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
if (st->codec->codec_id == AV_CODEC_ID_MP3) {
avio_skip(pb, 4);
len -= 4;
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
} else { // ADPCM, PCM
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
}
pkt->pos = pos;
pkt->stream_index = st->index;
return pkt->size;
}
}
} else if (tag == TAG_JPEG2) {
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)
break;
}
if (i == s->nb_streams) {
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = -2; /* -2 to avoid clash with video stream and audio stream */
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_MJPEG;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
avio_rl16(pb); /* BITMAP_ID */
len -= 2;
if (len < 4)
goto skip;
if ((res = av_new_packet(pkt, len)) < 0)
return res;
if (avio_read(pb, pkt->data, 4) != 4) {
av_free_packet(pkt);
return AVERROR_INVALIDDATA;
}
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
AV_RB32(pkt->data) == 0xffd9ffd8) {
/* old SWF files containing SOI/EOI as data start */
/* files created by swink have reversed tag */
pkt->size -= 4;
res = avio_read(pb, pkt->data, pkt->size);
} else {
res = avio_read(pb, pkt->data + 4, pkt->size - 4);
if (res >= 0)
res += 4;
}
if (res != pkt->size) {
if (res < 0) {
av_free_packet(pkt);
return res;
}
av_shrink_packet(pkt, res);
}
pkt->pos = pos;
pkt->stream_index = st->index;
return pkt->size;
} else {
av_log(s, AV_LOG_DEBUG, "Unknown tag: %d\n", tag);
}
skip:
if(len<0)
av_log(s, AV_LOG_WARNING, "Cliping len %d\n", len);
len = FFMAX(0, len);
avio_skip(pb, len);
}
} | true | FFmpeg | f5d039840aca64d0ce79cd08e64423833becf570 | static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
SWFContext *swf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vst = NULL, *ast = NULL, *st = 0;
int tag, len, i, frame, v, res;
#if CONFIG_ZLIB
if (swf->zpb)
pb = swf->zpb;
#endif
for(;;) {
uint64_t pos = avio_tell(pb);
tag = get_swf_tag(pb, &len);
if (tag < 0)
return tag;
if (len < 0) {
av_log(s, AV_LOG_ERROR, "invalid tag length: %d\n", len);
return AVERROR_INVALIDDATA;
}
if (tag == TAG_VIDEOSTREAM) {
int ch_id = avio_rl16(pb);
len -= 2;
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id)
goto skip;
}
avio_rl16(pb);
avio_rl16(pb);
avio_rl16(pb);
avio_r8(pb);
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = ch_id;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));
avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);
len -= 8;
} else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)
goto skip;
}
avio_r8(pb);
v = avio_r8(pb);
swf->samples_per_frame = avio_rl16(pb);
ast = create_new_audio_stream(s, -1, v);
if (!ast)
return AVERROR(ENOMEM);
len -= 4;
} else if (tag == TAG_DEFINESOUND) {
int ch_id = avio_rl16(pb);
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == ch_id)
goto skip;
}
v = avio_r8(pb);
ast = create_new_audio_stream(s, ch_id, v);
if (!ast)
return AVERROR(ENOMEM);
ast->duration = avio_rl32(pb);
if (((v>>4) & 15) == 2) {
ast->skip_samples = avio_rl16(pb);
len -= 2;
}
len -= 7;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
pkt->pos = pos;
pkt->stream_index = ast->index;
return pkt->size;
} else if (tag == TAG_VIDEOFRAME) {
int ch_id = avio_rl16(pb);
len -= 2;
for(i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
frame = avio_rl16(pb);
len -= 2;
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
pkt->pos = pos;
pkt->pts = frame;
pkt->stream_index = st->index;
return pkt->size;
}
}
} else if (tag == TAG_DEFINEBITSLOSSLESS || tag == TAG_DEFINEBITSLOSSLESS2) {
#if CONFIG_ZLIB
long out_len;
uint8_t *buf = NULL, *zbuf = NULL, *pal;
uint32_t colormap[AVPALETTE_COUNT] = {0};
const int alpha_bmp = tag == TAG_DEFINEBITSLOSSLESS2;
const int colormapbpp = 3 + alpha_bmp;
int linesize, colormapsize = 0;
const int ch_id = avio_rl16(pb);
const int bmp_fmt = avio_r8(pb);
const int width = avio_rl16(pb);
const int height = avio_rl16(pb);
len -= 2+1+2+2;
switch (bmp_fmt) {
case 3:
linesize = width;
colormapsize = avio_r8(pb) + 1;
len--;
break;
case 4:
linesize = width * 2;
break;
case 5:
linesize = width * 4;
break;
default:
av_log(s, AV_LOG_ERROR, "invalid bitmap format %d, skipped\n", bmp_fmt);
goto bitmap_end_skip;
}
linesize = FFALIGN(linesize, 4);
if (av_image_check_size(width, height, 0, s) < 0 ||
linesize >= INT_MAX / height ||
linesize * height >= INT_MAX - colormapsize * colormapbpp) {
av_log(s, AV_LOG_ERROR, "invalid frame size %dx%d\n", width, height);
goto bitmap_end_skip;
}
out_len = colormapsize * colormapbpp + linesize * height;
av_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
zbuf = av_malloc(len);
buf = av_malloc(out_len);
if (!zbuf || !buf) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
len = avio_read(pb, zbuf, len);
if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
av_log(s, AV_LOG_WARNING, "Failed to uncompress one bitmap\n");
goto bitmap_end_skip;
}
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)
break;
}
if (i == s->nb_streams) {
vst = avformat_new_stream(s, NULL);
if (!vst) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
vst->id = -3;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
st->codec->width = width;
st->codec->height = height;
if ((res = av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
goto bitmap_end;
pkt->pos = pos;
pkt->stream_index = st->index;
switch (bmp_fmt) {
case 3:
st->codec->pix_fmt = AV_PIX_FMT_PAL8;
for (i = 0; i < colormapsize; i++)
if (alpha_bmp) colormap[i] = buf[3]<<24 | AV_RB24(buf + 4*i);
else colormap[i] = 0xffU <<24 | AV_RB24(buf + 3*i);
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
res = AVERROR(ENOMEM);
goto bitmap_end;
}
memcpy(pal, colormap, AVPALETTE_SIZE);
break;
case 4:
st->codec->pix_fmt = AV_PIX_FMT_RGB555;
break;
case 5:
st->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;
break;
default:
av_assert0(0);
}
if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA;
goto bitmap_end;
}
memcpy(pkt->data, buf + colormapsize*colormapbpp, linesize * height);
res = pkt->size;
bitmap_end:
av_freep(&zbuf);
av_freep(&buf);
return res;
bitmap_end_skip:
av_freep(&zbuf);
av_freep(&buf);
#else
av_log(s, AV_LOG_ERROR, "this file requires zlib support compiled in\n");
#endif
} else if (tag == TAG_STREAMBLOCK) {
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
if (st->codec->codec_id == AV_CODEC_ID_MP3) {
avio_skip(pb, 4);
len -= 4;
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
} else {
if (len <= 0)
goto skip;
if ((res = av_get_packet(pb, pkt, len)) < 0)
return res;
}
pkt->pos = pos;
pkt->stream_index = st->index;
return pkt->size;
}
}
} else if (tag == TAG_JPEG2) {
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)
break;
}
if (i == s->nb_streams) {
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = -2;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_MJPEG;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
avio_rl16(pb);
len -= 2;
if (len < 4)
goto skip;
if ((res = av_new_packet(pkt, len)) < 0)
return res;
if (avio_read(pb, pkt->data, 4) != 4) {
av_free_packet(pkt);
return AVERROR_INVALIDDATA;
}
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
AV_RB32(pkt->data) == 0xffd9ffd8) {
pkt->size -= 4;
res = avio_read(pb, pkt->data, pkt->size);
} else {
res = avio_read(pb, pkt->data + 4, pkt->size - 4);
if (res >= 0)
res += 4;
}
if (res != pkt->size) {
if (res < 0) {
av_free_packet(pkt);
return res;
}
av_shrink_packet(pkt, res);
}
pkt->pos = pos;
pkt->stream_index = st->index;
return pkt->size;
} else {
av_log(s, AV_LOG_DEBUG, "Unknown tag: %d\n", tag);
}
skip:
if(len<0)
av_log(s, AV_LOG_WARNING, "Cliping len %d\n", len);
len = FFMAX(0, len);
avio_skip(pb, len);
}
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
SWFContext *swf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVStream *vst = NULL, *ast = NULL, *st = 0;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
#if CONFIG_ZLIB
if (swf->zpb)
pb = swf->zpb;
#endif
for(;;) {
uint64_t pos = avio_tell(pb);
VAR_2 = get_swf_tag(pb, &VAR_3);
if (VAR_2 < 0)
return VAR_2;
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_2 length: %d\n", VAR_3);
return AVERROR_INVALIDDATA;
}
if (VAR_2 == TAG_VIDEOSTREAM) {
int VAR_9 = avio_rl16(pb);
VAR_3 -= 2;
for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == VAR_9)
goto skip;
}
avio_rl16(pb);
avio_rl16(pb);
avio_rl16(pb);
avio_r8(pb);
vst = avformat_new_stream(VAR_0, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = VAR_9;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));
avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);
VAR_3 -= 8;
} else if (VAR_2 == TAG_STREAMHEAD || VAR_2 == TAG_STREAMHEAD2) {
for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)
goto skip;
}
avio_r8(pb);
VAR_6 = avio_r8(pb);
swf->samples_per_frame = avio_rl16(pb);
ast = create_new_audio_stream(VAR_0, -1, VAR_6);
if (!ast)
return AVERROR(ENOMEM);
VAR_3 -= 4;
} else if (VAR_2 == TAG_DEFINESOUND) {
int VAR_9 = avio_rl16(pb);
for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == VAR_9)
goto skip;
}
VAR_6 = avio_r8(pb);
ast = create_new_audio_stream(VAR_0, VAR_9, VAR_6);
if (!ast)
return AVERROR(ENOMEM);
ast->duration = avio_rl32(pb);
if (((VAR_6>>4) & 15) == 2) {
ast->skip_samples = avio_rl16(pb);
VAR_3 -= 2;
}
VAR_3 -= 7;
if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)
return VAR_7;
VAR_1->pos = pos;
VAR_1->stream_index = ast->index;
return VAR_1->size;
} else if (VAR_2 == TAG_VIDEOFRAME) {
int VAR_9 = avio_rl16(pb);
VAR_3 -= 2;
for(VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == VAR_9) {
VAR_5 = avio_rl16(pb);
VAR_3 -= 2;
if (VAR_3 <= 0)
goto skip;
if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)
return VAR_7;
VAR_1->pos = pos;
VAR_1->pts = VAR_5;
VAR_1->stream_index = st->index;
return VAR_1->size;
}
}
} else if (VAR_2 == TAG_DEFINEBITSLOSSLESS || VAR_2 == TAG_DEFINEBITSLOSSLESS2) {
#if CONFIG_ZLIB
long out_len;
uint8_t *buf = NULL, *zbuf = NULL, *pal;
uint32_t colormap[AVPALETTE_COUNT] = {0};
const int alpha_bmp = VAR_2 == TAG_DEFINEBITSLOSSLESS2;
const int colormapbpp = 3 + alpha_bmp;
int linesize, colormapsize = 0;
const int VAR_9 = avio_rl16(pb);
const int bmp_fmt = avio_r8(pb);
const int width = avio_rl16(pb);
const int height = avio_rl16(pb);
VAR_3 -= 2+1+2+2;
switch (bmp_fmt) {
case 3:
linesize = width;
colormapsize = avio_r8(pb) + 1;
VAR_3--;
break;
case 4:
linesize = width * 2;
break;
case 5:
linesize = width * 4;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "invalid bitmap format %d, skipped\n", bmp_fmt);
goto bitmap_end_skip;
}
linesize = FFALIGN(linesize, 4);
if (av_image_check_size(width, height, 0, VAR_0) < 0 ||
linesize >= INT_MAX / height ||
linesize * height >= INT_MAX - colormapsize * colormapbpp) {
av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_5 size %dx%d\n", width, height);
goto bitmap_end_skip;
}
out_len = colormapsize * colormapbpp + linesize * height;
av_dlog(VAR_0, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) VAR_3=%d->%ld pal=%d\n",
VAR_9, bmp_fmt, width, height, linesize, VAR_3, out_len, colormapsize);
zbuf = av_malloc(VAR_3);
buf = av_malloc(out_len);
if (!zbuf || !buf) {
VAR_7 = AVERROR(ENOMEM);
goto bitmap_end;
}
VAR_3 = avio_read(pb, zbuf, VAR_3);
if (VAR_3 < 0 || (VAR_7 = uncompress(buf, &out_len, zbuf, VAR_3)) != Z_OK) {
av_log(VAR_0, AV_LOG_WARNING, "Failed to uncompress one bitmap\n");
goto bitmap_end_skip;
}
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)
break;
}
if (VAR_4 == VAR_0->nb_streams) {
vst = avformat_new_stream(VAR_0, NULL);
if (!vst) {
VAR_7 = AVERROR(ENOMEM);
goto bitmap_end;
}
vst->id = -3;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
st->codec->width = width;
st->codec->height = height;
if ((VAR_7 = av_new_packet(VAR_1, out_len - colormapsize * colormapbpp)) < 0)
goto bitmap_end;
VAR_1->pos = pos;
VAR_1->stream_index = st->index;
switch (bmp_fmt) {
case 3:
st->codec->pix_fmt = AV_PIX_FMT_PAL8;
for (VAR_4 = 0; VAR_4 < colormapsize; VAR_4++)
if (alpha_bmp) colormap[VAR_4] = buf[3]<<24 | AV_RB24(buf + 4*VAR_4);
else colormap[VAR_4] = 0xffU <<24 | AV_RB24(buf + 3*VAR_4);
pal = av_packet_new_side_data(VAR_1, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
VAR_7 = AVERROR(ENOMEM);
goto bitmap_end;
}
memcpy(pal, colormap, AVPALETTE_SIZE);
break;
case 4:
st->codec->pix_fmt = AV_PIX_FMT_RGB555;
break;
case 5:
st->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;
break;
default:
av_assert0(0);
}
if (linesize * height > VAR_1->size) {
VAR_7 = AVERROR_INVALIDDATA;
goto bitmap_end;
}
memcpy(VAR_1->data, buf + colormapsize*colormapbpp, linesize * height);
VAR_7 = VAR_1->size;
bitmap_end:
av_freep(&zbuf);
av_freep(&buf);
return VAR_7;
bitmap_end_skip:
av_freep(&zbuf);
av_freep(&buf);
#else
av_log(VAR_0, AV_LOG_ERROR, "this file requires zlib support compiled in\n");
#endif
} else if (VAR_2 == TAG_STREAMBLOCK) {
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
if (st->codec->codec_id == AV_CODEC_ID_MP3) {
avio_skip(pb, 4);
VAR_3 -= 4;
if (VAR_3 <= 0)
goto skip;
if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)
return VAR_7;
} else {
if (VAR_3 <= 0)
goto skip;
if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)
return VAR_7;
}
VAR_1->pos = pos;
VAR_1->stream_index = st->index;
return VAR_1->size;
}
}
} else if (VAR_2 == TAG_JPEG2) {
for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)
break;
}
if (VAR_4 == VAR_0->nb_streams) {
vst = avformat_new_stream(VAR_0, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->id = -2;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_MJPEG;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
avio_rl16(pb);
VAR_3 -= 2;
if (VAR_3 < 4)
goto skip;
if ((VAR_7 = av_new_packet(VAR_1, VAR_3)) < 0)
return VAR_7;
if (avio_read(pb, VAR_1->data, 4) != 4) {
av_free_packet(VAR_1);
return AVERROR_INVALIDDATA;
}
if (AV_RB32(VAR_1->data) == 0xffd8ffd9 ||
AV_RB32(VAR_1->data) == 0xffd9ffd8) {
VAR_1->size -= 4;
VAR_7 = avio_read(pb, VAR_1->data, VAR_1->size);
} else {
VAR_7 = avio_read(pb, VAR_1->data + 4, VAR_1->size - 4);
if (VAR_7 >= 0)
VAR_7 += 4;
}
if (VAR_7 != VAR_1->size) {
if (VAR_7 < 0) {
av_free_packet(VAR_1);
return VAR_7;
}
av_shrink_packet(VAR_1, VAR_7);
}
VAR_1->pos = pos;
VAR_1->stream_index = st->index;
return VAR_1->size;
} else {
av_log(VAR_0, AV_LOG_DEBUG, "Unknown VAR_2: %d\n", VAR_2);
}
skip:
if(VAR_3<0)
av_log(VAR_0, AV_LOG_WARNING, "Cliping VAR_3 %d\n", VAR_3);
VAR_3 = FFMAX(0, VAR_3);
avio_skip(pb, VAR_3);
}
} | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"SWFContext *swf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *vst = NULL, *ast = NULL, *st = 0;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"#if CONFIG_ZLIB\nif (swf->zpb)\npb = swf->zpb;",
"#endif\nfor(;;) {",
"uint64_t pos = avio_tell(pb);",
"VAR_2 = get_swf_tag(pb, &VAR_3);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid VAR_2 length: %d\\n\", VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_2 == TAG_VIDEOSTREAM) {",
"int VAR_9 = avio_rl16(pb);",
"VAR_3 -= 2;",
"for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == VAR_9)\ngoto skip;",
"}",
"avio_rl16(pb);",
"avio_rl16(pb);",
"avio_rl16(pb);",
"avio_r8(pb);",
"vst = avformat_new_stream(VAR_0, NULL);",
"if (!vst)\nreturn AVERROR(ENOMEM);",
"vst->id = VAR_9;",
"vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));",
"avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);",
"VAR_3 -= 8;",
"} else if (VAR_2 == TAG_STREAMHEAD || VAR_2 == TAG_STREAMHEAD2) {",
"for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)\ngoto skip;",
"}",
"avio_r8(pb);",
"VAR_6 = avio_r8(pb);",
"swf->samples_per_frame = avio_rl16(pb);",
"ast = create_new_audio_stream(VAR_0, -1, VAR_6);",
"if (!ast)\nreturn AVERROR(ENOMEM);",
"VAR_3 -= 4;",
"} else if (VAR_2 == TAG_DEFINESOUND) {",
"int VAR_9 = avio_rl16(pb);",
"for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == VAR_9)\ngoto skip;",
"}",
"VAR_6 = avio_r8(pb);",
"ast = create_new_audio_stream(VAR_0, VAR_9, VAR_6);",
"if (!ast)\nreturn AVERROR(ENOMEM);",
"ast->duration = avio_rl32(pb);",
"if (((VAR_6>>4) & 15) == 2) {",
"ast->skip_samples = avio_rl16(pb);",
"VAR_3 -= 2;",
"}",
"VAR_3 -= 7;",
"if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)\nreturn VAR_7;",
"VAR_1->pos = pos;",
"VAR_1->stream_index = ast->index;",
"return VAR_1->size;",
"} else if (VAR_2 == TAG_VIDEOFRAME) {",
"int VAR_9 = avio_rl16(pb);",
"VAR_3 -= 2;",
"for(VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == VAR_9) {",
"VAR_5 = avio_rl16(pb);",
"VAR_3 -= 2;",
"if (VAR_3 <= 0)\ngoto skip;",
"if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)\nreturn VAR_7;",
"VAR_1->pos = pos;",
"VAR_1->pts = VAR_5;",
"VAR_1->stream_index = st->index;",
"return VAR_1->size;",
"}",
"}",
"} else if (VAR_2 == TAG_DEFINEBITSLOSSLESS || VAR_2 == TAG_DEFINEBITSLOSSLESS2) {",
"#if CONFIG_ZLIB\nlong out_len;",
"uint8_t *buf = NULL, *zbuf = NULL, *pal;",
"uint32_t colormap[AVPALETTE_COUNT] = {0};",
"const int alpha_bmp = VAR_2 == TAG_DEFINEBITSLOSSLESS2;",
"const int colormapbpp = 3 + alpha_bmp;",
"int linesize, colormapsize = 0;",
"const int VAR_9 = avio_rl16(pb);",
"const int bmp_fmt = avio_r8(pb);",
"const int width = avio_rl16(pb);",
"const int height = avio_rl16(pb);",
"VAR_3 -= 2+1+2+2;",
"switch (bmp_fmt) {",
"case 3:\nlinesize = width;",
"colormapsize = avio_r8(pb) + 1;",
"VAR_3--;",
"break;",
"case 4:\nlinesize = width * 2;",
"break;",
"case 5:\nlinesize = width * 4;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid bitmap format %d, skipped\\n\", bmp_fmt);",
"goto bitmap_end_skip;",
"}",
"linesize = FFALIGN(linesize, 4);",
"if (av_image_check_size(width, height, 0, VAR_0) < 0 ||\nlinesize >= INT_MAX / height ||\nlinesize * height >= INT_MAX - colormapsize * colormapbpp) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid VAR_5 size %dx%d\\n\", width, height);",
"goto bitmap_end_skip;",
"}",
"out_len = colormapsize * colormapbpp + linesize * height;",
"av_dlog(VAR_0, \"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) VAR_3=%d->%ld pal=%d\\n\",\nVAR_9, bmp_fmt, width, height, linesize, VAR_3, out_len, colormapsize);",
"zbuf = av_malloc(VAR_3);",
"buf = av_malloc(out_len);",
"if (!zbuf || !buf) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto bitmap_end;",
"}",
"VAR_3 = avio_read(pb, zbuf, VAR_3);",
"if (VAR_3 < 0 || (VAR_7 = uncompress(buf, &out_len, zbuf, VAR_3)) != Z_OK) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Failed to uncompress one bitmap\\n\");",
"goto bitmap_end_skip;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)\nbreak;",
"}",
"if (VAR_4 == VAR_0->nb_streams) {",
"vst = avformat_new_stream(VAR_0, NULL);",
"if (!vst) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto bitmap_end;",
"}",
"vst->id = -3;",
"vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;",
"avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);",
"st = vst;",
"}",
"st->codec->width = width;",
"st->codec->height = height;",
"if ((VAR_7 = av_new_packet(VAR_1, out_len - colormapsize * colormapbpp)) < 0)\ngoto bitmap_end;",
"VAR_1->pos = pos;",
"VAR_1->stream_index = st->index;",
"switch (bmp_fmt) {",
"case 3:\nst->codec->pix_fmt = AV_PIX_FMT_PAL8;",
"for (VAR_4 = 0; VAR_4 < colormapsize; VAR_4++)",
"if (alpha_bmp) colormap[VAR_4] = buf[3]<<24 | AV_RB24(buf + 4*VAR_4);",
"else colormap[VAR_4] = 0xffU <<24 | AV_RB24(buf + 3*VAR_4);",
"pal = av_packet_new_side_data(VAR_1, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);",
"if (!pal) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto bitmap_end;",
"}",
"memcpy(pal, colormap, AVPALETTE_SIZE);",
"break;",
"case 4:\nst->codec->pix_fmt = AV_PIX_FMT_RGB555;",
"break;",
"case 5:\nst->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;",
"break;",
"default:\nav_assert0(0);",
"}",
"if (linesize * height > VAR_1->size) {",
"VAR_7 = AVERROR_INVALIDDATA;",
"goto bitmap_end;",
"}",
"memcpy(VAR_1->data, buf + colormapsize*colormapbpp, linesize * height);",
"VAR_7 = VAR_1->size;",
"bitmap_end:\nav_freep(&zbuf);",
"av_freep(&buf);",
"return VAR_7;",
"bitmap_end_skip:\nav_freep(&zbuf);",
"av_freep(&buf);",
"#else\nav_log(VAR_0, AV_LOG_ERROR, \"this file requires zlib support compiled in\\n\");",
"#endif\n} else if (VAR_2 == TAG_STREAMBLOCK) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {",
"if (st->codec->codec_id == AV_CODEC_ID_MP3) {",
"avio_skip(pb, 4);",
"VAR_3 -= 4;",
"if (VAR_3 <= 0)\ngoto skip;",
"if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)\nreturn VAR_7;",
"} else {",
"if (VAR_3 <= 0)\ngoto skip;",
"if ((VAR_7 = av_get_packet(pb, VAR_1, VAR_3)) < 0)\nreturn VAR_7;",
"}",
"VAR_1->pos = pos;",
"VAR_1->stream_index = st->index;",
"return VAR_1->size;",
"}",
"}",
"} else if (VAR_2 == TAG_JPEG2) {",
"for (VAR_4=0; VAR_4<VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)\nbreak;",
"}",
"if (VAR_4 == VAR_0->nb_streams) {",
"vst = avformat_new_stream(VAR_0, NULL);",
"if (!vst)\nreturn AVERROR(ENOMEM);",
"vst->id = -2;",
"vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"vst->codec->codec_id = AV_CODEC_ID_MJPEG;",
"avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);",
"st = vst;",
"}",
"avio_rl16(pb);",
"VAR_3 -= 2;",
"if (VAR_3 < 4)\ngoto skip;",
"if ((VAR_7 = av_new_packet(VAR_1, VAR_3)) < 0)\nreturn VAR_7;",
"if (avio_read(pb, VAR_1->data, 4) != 4) {",
"av_free_packet(VAR_1);",
"return AVERROR_INVALIDDATA;",
"}",
"if (AV_RB32(VAR_1->data) == 0xffd8ffd9 ||\nAV_RB32(VAR_1->data) == 0xffd9ffd8) {",
"VAR_1->size -= 4;",
"VAR_7 = avio_read(pb, VAR_1->data, VAR_1->size);",
"} else {",
"VAR_7 = avio_read(pb, VAR_1->data + 4, VAR_1->size - 4);",
"if (VAR_7 >= 0)\nVAR_7 += 4;",
"}",
"if (VAR_7 != VAR_1->size) {",
"if (VAR_7 < 0) {",
"av_free_packet(VAR_1);",
"return VAR_7;",
"}",
"av_shrink_packet(VAR_1, VAR_7);",
"}",
"VAR_1->pos = pos;",
"VAR_1->stream_index = st->index;",
"return VAR_1->size;",
"} else {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Unknown VAR_2: %d\\n\", VAR_2);",
"}",
"skip:\nif(VAR_3<0)\nav_log(VAR_0, AV_LOG_WARNING, \"Cliping VAR_3 %d\\n\", VAR_3);",
"VAR_3 = FFMAX(0, VAR_3);",
"avio_skip(pb, VAR_3);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
21,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
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
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
245
],
[
247,
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
279
],
[
283,
285,
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
301,
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
383
],
[
385,
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415,
417
],
[
419
],
[
421,
423
],
[
425
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
441
],
[
445,
447
],
[
449
],
[
451
],
[
453,
455
],
[
457
],
[
459,
461
],
[
463,
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479,
481
],
[
483,
485
],
[
487
],
[
489,
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515,
517
],
[
519
],
[
521
],
[
523
],
[
525,
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545,
547
],
[
549,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561,
563
],
[
569
],
[
572
],
[
574
],
[
576
],
[
578,
580
],
[
582
],
[
584
],
[
586
],
[
588
],
[
590
],
[
592
],
[
594
],
[
596
],
[
600
],
[
602
],
[
604
],
[
606
],
[
608
],
[
610
],
[
612,
614,
616
],
[
618
],
[
620
],
[
622
],
[
624
]
]
|
12,982 | static int dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
int av_unused version;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
int ret;
if (buf_size < 10)
return AVERROR_INVALIDDATA;
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
if (!region)
return AVERROR(ENOMEM);
region->id = region_id;
region->version = -1;
region->next = ctx->region_list;
ctx->region_list = region;
version = ((*buf)>>4) & 15;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
ret = av_image_check_size2(region->width, region->height, avctx->max_pixels, AV_PIX_FMT_PAL8, 0, avctx);
if (ret < 0) {
region->width= region->height= 0;
return ret;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
if (!region->pbuf) {
region->buf_size =
region->width =
region->height = 0;
return AVERROR(ENOMEM);
fill = 1;
region->dirty = 0;
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
region->clut = *buf++;
if (region->depth == 8) {
region->bgcolor = *buf++;
buf += 1;
} else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
ff_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
ff_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
if (!object)
return AVERROR(ENOMEM);
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
if (!display)
return AVERROR(ENOMEM);
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
return 0;
| true | FFmpeg | e1b0044c234775bf99ab1a5c794240a9a692ad8d | static int dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
int av_unused version;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
int ret;
if (buf_size < 10)
return AVERROR_INVALIDDATA;
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
if (!region)
return AVERROR(ENOMEM);
region->id = region_id;
region->version = -1;
region->next = ctx->region_list;
ctx->region_list = region;
version = ((*buf)>>4) & 15;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
ret = av_image_check_size2(region->width, region->height, avctx->max_pixels, AV_PIX_FMT_PAL8, 0, avctx);
if (ret < 0) {
region->width= region->height= 0;
return ret;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
if (!region->pbuf) {
region->buf_size =
region->width =
region->height = 0;
return AVERROR(ENOMEM);
fill = 1;
region->dirty = 0;
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
region->clut = *buf++;
if (region->depth == 8) {
region->bgcolor = *buf++;
buf += 1;
} else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
ff_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
ff_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
if (!object)
return AVERROR(ENOMEM);
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
if (!display)
return AVERROR(ENOMEM);
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
DVBSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_3 = VAR_1 + VAR_2;
int VAR_4, VAR_5;
int VAR_6 version;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int VAR_7;
int VAR_8;
if (VAR_2 < 10)
return AVERROR_INVALIDDATA;
VAR_4 = *VAR_1++;
region = get_region(ctx, VAR_4);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
if (!region)
return AVERROR(ENOMEM);
region->id = VAR_4;
region->version = -1;
region->next = ctx->region_list;
ctx->region_list = region;
version = ((*VAR_1)>>4) & 15;
VAR_7 = ((*VAR_1++) >> 3) & 1;
region->width = AV_RB16(VAR_1);
VAR_1 += 2;
region->height = AV_RB16(VAR_1);
VAR_1 += 2;
VAR_8 = av_image_check_size2(region->width, region->height, VAR_0->max_pixels, AV_PIX_FMT_PAL8, 0, VAR_0);
if (VAR_8 < 0) {
region->width= region->height= 0;
return VAR_8;
if (region->width * region->height != region->VAR_2) {
av_free(region->pbuf);
region->VAR_2 = region->width * region->height;
region->pbuf = av_malloc(region->VAR_2);
if (!region->pbuf) {
region->VAR_2 =
region->width =
region->height = 0;
return AVERROR(ENOMEM);
VAR_7 = 1;
region->dirty = 0;
region->depth = 1 << (((*VAR_1++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(VAR_0, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
region->clut = *VAR_1++;
if (region->depth == 8) {
region->bgcolor = *VAR_1++;
VAR_1 += 1;
} else {
VAR_1 += 1;
if (region->depth == 4)
region->bgcolor = (((*VAR_1++) >> 4) & 15);
else
region->bgcolor = (((*VAR_1++) >> 2) & 3);
ff_dlog(VAR_0, "Region %d, (%dx%d)\n", VAR_4, region->width, region->height);
if (VAR_7) {
memset(region->pbuf, region->bgcolor, region->VAR_2);
ff_dlog(VAR_0, "Fill region (%d)\n", region->bgcolor);
delete_region_display_list(ctx, region);
while (VAR_1 + 5 < VAR_3) {
VAR_5 = AV_RB16(VAR_1);
VAR_1 += 2;
object = get_object(ctx, VAR_5);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
if (!object)
return AVERROR(ENOMEM);
object->id = VAR_5;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*VAR_1) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
if (!display)
return AVERROR(ENOMEM);
display->VAR_5 = VAR_5;
display->VAR_4 = VAR_4;
display->x_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
display->y_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
if ((object->type == 1 || object->type == 2) && VAR_1+1 < VAR_3) {
display->fgcolor = *VAR_1++;
display->bgcolor = *VAR_1++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
return 0;
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_3 = VAR_1 + VAR_2;",
"int VAR_4, VAR_5;",
"int VAR_6 version;",
"DVBSubRegion *region;",
"DVBSubObject *object;",
"DVBSubObjectDisplay *display;",
"int VAR_7;",
"int VAR_8;",
"if (VAR_2 < 10)\nreturn AVERROR_INVALIDDATA;",
"VAR_4 = *VAR_1++;",
"region = get_region(ctx, VAR_4);",
"if (!region) {",
"region = av_mallocz(sizeof(DVBSubRegion));",
"if (!region)\nreturn AVERROR(ENOMEM);",
"region->id = VAR_4;",
"region->version = -1;",
"region->next = ctx->region_list;",
"ctx->region_list = region;",
"version = ((*VAR_1)>>4) & 15;",
"VAR_7 = ((*VAR_1++) >> 3) & 1;",
"region->width = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"region->height = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"VAR_8 = av_image_check_size2(region->width, region->height, VAR_0->max_pixels, AV_PIX_FMT_PAL8, 0, VAR_0);",
"if (VAR_8 < 0) {",
"region->width= region->height= 0;",
"return VAR_8;",
"if (region->width * region->height != region->VAR_2) {",
"av_free(region->pbuf);",
"region->VAR_2 = region->width * region->height;",
"region->pbuf = av_malloc(region->VAR_2);",
"if (!region->pbuf) {",
"region->VAR_2 =\nregion->width =\nregion->height = 0;",
"return AVERROR(ENOMEM);",
"VAR_7 = 1;",
"region->dirty = 0;",
"region->depth = 1 << (((*VAR_1++) >> 2) & 7);",
"if(region->depth<2 || region->depth>8){",
"av_log(VAR_0, AV_LOG_ERROR, \"region depth %d is invalid\\n\", region->depth);",
"region->depth= 4;",
"region->clut = *VAR_1++;",
"if (region->depth == 8) {",
"region->bgcolor = *VAR_1++;",
"VAR_1 += 1;",
"} else {",
"VAR_1 += 1;",
"if (region->depth == 4)\nregion->bgcolor = (((*VAR_1++) >> 4) & 15);",
"else\nregion->bgcolor = (((*VAR_1++) >> 2) & 3);",
"ff_dlog(VAR_0, \"Region %d, (%dx%d)\\n\", VAR_4, region->width, region->height);",
"if (VAR_7) {",
"memset(region->pbuf, region->bgcolor, region->VAR_2);",
"ff_dlog(VAR_0, \"Fill region (%d)\\n\", region->bgcolor);",
"delete_region_display_list(ctx, region);",
"while (VAR_1 + 5 < VAR_3) {",
"VAR_5 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"object = get_object(ctx, VAR_5);",
"if (!object) {",
"object = av_mallocz(sizeof(DVBSubObject));",
"if (!object)\nreturn AVERROR(ENOMEM);",
"object->id = VAR_5;",
"object->next = ctx->object_list;",
"ctx->object_list = object;",
"object->type = (*VAR_1) >> 6;",
"display = av_mallocz(sizeof(DVBSubObjectDisplay));",
"if (!display)\nreturn AVERROR(ENOMEM);",
"display->VAR_5 = VAR_5;",
"display->VAR_4 = VAR_4;",
"display->x_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"display->y_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"if ((object->type == 1 || object->type == 2) && VAR_1+1 < VAR_3) {",
"display->fgcolor = *VAR_1++;",
"display->bgcolor = *VAR_1++;",
"display->region_list_next = region->display_list;",
"region->display_list = display;",
"display->object_list_next = object->display_list;",
"object->display_list = display;",
"return 0;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
66
],
[
68
],
[
72
],
[
74
],
[
76
],
[
78
],
[
82
],
[
88
],
[
90
],
[
92
],
[
97
],
[
99
],
[
103
],
[
107
],
[
109
],
[
111,
113,
115
],
[
117
],
[
122
],
[
124
],
[
129
],
[
131
],
[
133
],
[
135
],
[
138
],
[
142
],
[
144
],
[
146
],
[
148
],
[
150
],
[
154,
156
],
[
158,
160
],
[
165
],
[
169
],
[
171
],
[
173
],
[
178
],
[
182
],
[
184
],
[
186
],
[
190
],
[
194
],
[
196
],
[
198,
200
],
[
204
],
[
206
],
[
208
],
[
213
],
[
217
],
[
219,
221
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
250
],
[
252
],
[
256
],
[
258
],
[
263
]
]
|
12,983 | int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
AVFrame *cur_frame;
/* no picref available, fetch it from the filterchain */
if (!av_fifo_size(buf->fifo)) {
if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
return AVERROR(EAGAIN);
if ((ret = ff_request_frame(inlink)) < 0)
return ret;
}
if (!av_fifo_size(buf->fifo))
return AVERROR(EINVAL);
if (flags & AV_BUFFERSINK_FLAG_PEEK) {
cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
av_frame_ref(frame, cur_frame); /* TODO check failure */
} else {
av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
av_frame_move_ref(frame, cur_frame);
av_frame_free(&cur_frame);
}
return 0;
}
| true | FFmpeg | 5eb273b2e767c86f78cc0e7e1a31bda4fedd2f56 | int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
AVFrame *cur_frame;
if (!av_fifo_size(buf->fifo)) {
if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
return AVERROR(EAGAIN);
if ((ret = ff_request_frame(inlink)) < 0)
return ret;
}
if (!av_fifo_size(buf->fifo))
return AVERROR(EINVAL);
if (flags & AV_BUFFERSINK_FLAG_PEEK) {
cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
av_frame_ref(frame, cur_frame);
} else {
av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
av_frame_move_ref(frame, cur_frame);
av_frame_free(&cur_frame);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int VAR_0 av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
AVFrame *cur_frame;
if (!av_fifo_size(buf->fifo)) {
if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
return AVERROR(EAGAIN);
if ((ret = ff_request_frame(inlink)) < 0)
return ret;
}
if (!av_fifo_size(buf->fifo))
return AVERROR(EINVAL);
if (flags & AV_BUFFERSINK_FLAG_PEEK) {
cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
av_frame_ref(frame, cur_frame);
} else {
av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
av_frame_move_ref(frame, cur_frame);
av_frame_free(&cur_frame);
}
return 0;
}
| [
"int VAR_0 av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)\n{",
"BufferSinkContext *buf = ctx->priv;",
"AVFilterLink *inlink = ctx->inputs[0];",
"int ret;",
"AVFrame *cur_frame;",
"if (!av_fifo_size(buf->fifo)) {",
"if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)\nreturn AVERROR(EAGAIN);",
"if ((ret = ff_request_frame(inlink)) < 0)\nreturn ret;",
"}",
"if (!av_fifo_size(buf->fifo))\nreturn AVERROR(EINVAL);",
"if (flags & AV_BUFFERSINK_FLAG_PEEK) {",
"cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));",
"av_frame_ref(frame, cur_frame);",
"} else {",
"av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);",
"av_frame_move_ref(frame, cur_frame);",
"av_frame_free(&cur_frame);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
]
|
12,985 | void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict)
{
QObject *data;
int devfn;
if (do_pcie_aer_inject_error(mon, qdict, &data) < 0) {
return;
}
qdict = qobject_to_qdict(data);
assert(qdict);
devfn = (int)qdict_get_int(qdict, "devfn");
monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
qdict_get_str(qdict, "id"),
qdict_get_str(qdict, "root_bus"),
(int) qdict_get_int(qdict, "bus"),
PCI_SLOT(devfn), PCI_FUNC(devfn));
}
| true | qemu | 9edd5338a2404909ac8d373964021e6dbb8f5815 | void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict)
{
QObject *data;
int devfn;
if (do_pcie_aer_inject_error(mon, qdict, &data) < 0) {
return;
}
qdict = qobject_to_qdict(data);
assert(qdict);
devfn = (int)qdict_get_int(qdict, "devfn");
monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
qdict_get_str(qdict, "id"),
qdict_get_str(qdict, "root_bus"),
(int) qdict_get_int(qdict, "bus"),
PCI_SLOT(devfn), PCI_FUNC(devfn));
}
| {
"code": [
" QObject *data;",
" int devfn;",
" qdict = qobject_to_qdict(data);",
" assert(qdict);",
" devfn = (int)qdict_get_int(qdict, \"devfn\");",
" qdict_get_str(qdict, \"id\"),",
" qdict_get_str(qdict, \"root_bus\"),",
" (int) qdict_get_int(qdict, \"bus\"),",
" PCI_SLOT(devfn), PCI_FUNC(devfn));"
],
"line_no": [
5,
7,
19,
21,
25,
29,
31,
33,
35
]
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
QObject *data;
int VAR_2;
if (do_pcie_aer_inject_error(VAR_0, VAR_1, &data) < 0) {
return;
}
VAR_1 = qobject_to_qdict(data);
assert(VAR_1);
VAR_2 = (int)qdict_get_int(VAR_1, "VAR_2");
monitor_printf(VAR_0, "OK id: %s root bus: %s, bus: %x VAR_2: %x.%x\n",
qdict_get_str(VAR_1, "id"),
qdict_get_str(VAR_1, "root_bus"),
(int) qdict_get_int(VAR_1, "bus"),
PCI_SLOT(VAR_2), PCI_FUNC(VAR_2));
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"QObject *data;",
"int VAR_2;",
"if (do_pcie_aer_inject_error(VAR_0, VAR_1, &data) < 0) {",
"return;",
"}",
"VAR_1 = qobject_to_qdict(data);",
"assert(VAR_1);",
"VAR_2 = (int)qdict_get_int(VAR_1, \"VAR_2\");",
"monitor_printf(VAR_0, \"OK id: %s root bus: %s, bus: %x VAR_2: %x.%x\\n\",\nqdict_get_str(VAR_1, \"id\"),\nqdict_get_str(VAR_1, \"root_bus\"),\n(int) qdict_get_int(VAR_1, \"bus\"),\nPCI_SLOT(VAR_2), PCI_FUNC(VAR_2));",
"}"
]
| [
0,
1,
1,
0,
0,
0,
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27,
29,
31,
33,
35
],
[
37
]
]
|
12,986 | static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
{
int max_frames, first_frames = 0, frames;
uint8_t *buf, *buf2, *end;
AC3HeaderInfo hdr;
GetBitContext gbc;
enum CodecID codec_id = CODEC_ID_AC3;
max_frames = 0;
buf = p->buf;
end = buf + p->buf_size;
for(; buf < end; buf++) {
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
init_get_bits(&gbc, buf2, 54);
if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)
break;
if(buf2 + hdr.frame_size > end ||
av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
break;
if (hdr.bitstream_id > 10)
codec_id = CODEC_ID_EAC3;
buf2 += hdr.frame_size;
}
max_frames = FFMAX(max_frames, frames);
if(buf == p->buf)
first_frames = frames;
}
if(codec_id != expected_codec_id) return 0;
// keep this in sync with mp3 probe, both need to avoid
// issues with MPEG-files!
if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
else if(max_frames>=1) return 1;
else return 0;
}
| false | FFmpeg | 64bde8056337bb656a11f3c9e2857c10b94e2871 | static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
{
int max_frames, first_frames = 0, frames;
uint8_t *buf, *buf2, *end;
AC3HeaderInfo hdr;
GetBitContext gbc;
enum CodecID codec_id = CODEC_ID_AC3;
max_frames = 0;
buf = p->buf;
end = buf + p->buf_size;
for(; buf < end; buf++) {
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
init_get_bits(&gbc, buf2, 54);
if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)
break;
if(buf2 + hdr.frame_size > end ||
av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
break;
if (hdr.bitstream_id > 10)
codec_id = CODEC_ID_EAC3;
buf2 += hdr.frame_size;
}
max_frames = FFMAX(max_frames, frames);
if(buf == p->buf)
first_frames = frames;
}
if(codec_id != expected_codec_id) return 0;
if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=4) 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, enum CodecID VAR_1)
{
int VAR_2, VAR_3 = 0, VAR_4;
uint8_t *buf, *buf2, *end;
AC3HeaderInfo hdr;
GetBitContext gbc;
enum CodecID VAR_5 = CODEC_ID_AC3;
VAR_2 = 0;
buf = VAR_0->buf;
end = buf + VAR_0->buf_size;
for(; buf < end; buf++) {
buf2 = buf;
for(VAR_4 = 0; buf2 < end; VAR_4++) {
init_get_bits(&gbc, buf2, 54);
if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)
break;
if(buf2 + hdr.frame_size > end ||
av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
break;
if (hdr.bitstream_id > 10)
VAR_5 = CODEC_ID_EAC3;
buf2 += hdr.frame_size;
}
VAR_2 = FFMAX(VAR_2, VAR_4);
if(buf == VAR_0->buf)
VAR_3 = VAR_4;
}
if(VAR_5 != VAR_1) return 0;
if (VAR_3>=4) return AVPROBE_SCORE_MAX/2+1;
else if(VAR_2>500)return AVPROBE_SCORE_MAX/2;
else if(VAR_2>=4) return AVPROBE_SCORE_MAX/4;
else if(VAR_2>=1) return 1;
else return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0, enum CodecID VAR_1)\n{",
"int VAR_2, VAR_3 = 0, VAR_4;",
"uint8_t *buf, *buf2, *end;",
"AC3HeaderInfo hdr;",
"GetBitContext gbc;",
"enum CodecID VAR_5 = CODEC_ID_AC3;",
"VAR_2 = 0;",
"buf = VAR_0->buf;",
"end = buf + VAR_0->buf_size;",
"for(; buf < end; buf++) {",
"buf2 = buf;",
"for(VAR_4 = 0; buf2 < end; VAR_4++) {",
"init_get_bits(&gbc, buf2, 54);",
"if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)\nbreak;",
"if(buf2 + hdr.frame_size > end ||\nav_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))\nbreak;",
"if (hdr.bitstream_id > 10)\nVAR_5 = CODEC_ID_EAC3;",
"buf2 += hdr.frame_size;",
"}",
"VAR_2 = FFMAX(VAR_2, VAR_4);",
"if(buf == VAR_0->buf)\nVAR_3 = VAR_4;",
"}",
"if(VAR_5 != VAR_1) return 0;",
"if (VAR_3>=4) return AVPROBE_SCORE_MAX/2+1;",
"else if(VAR_2>500)return AVPROBE_SCORE_MAX/2;",
"else if(VAR_2>=4) return AVPROBE_SCORE_MAX/4;",
"else if(VAR_2>=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,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
12,987 | static int h263_probe(AVProbeData *p)
{
int code;
const uint8_t *d;
if (p->buf_size < 6)
return 0;
d = p->buf;
code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
if (code == 0x20) {
return 50;
}
return 0;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int h263_probe(AVProbeData *p)
{
int code;
const uint8_t *d;
if (p->buf_size < 6)
return 0;
d = p->buf;
code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
if (code == 0x20) {
return 50;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
int VAR_1;
const uint8_t *VAR_2;
if (VAR_0->buf_size < 6)
return 0;
VAR_2 = VAR_0->buf;
VAR_1 = (VAR_2[0] << 14) | (VAR_2[1] << 6) | (VAR_2[2] >> 2);
if (VAR_1 == 0x20) {
return 50;
}
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"int VAR_1;",
"const uint8_t *VAR_2;",
"if (VAR_0->buf_size < 6)\nreturn 0;",
"VAR_2 = VAR_0->buf;",
"VAR_1 = (VAR_2[0] << 14) | (VAR_2[1] << 6) | (VAR_2[2] >> 2);",
"if (VAR_1 == 0x20) {",
"return 50;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
12,989 | static int cinepak_decode_init(AVCodecContext *avctx)
{
CinepakContext *s = avctx->priv_data;
s->avctx = avctx;
s->width = (avctx->width + 3) & ~3;
s->height = (avctx->height + 3) & ~3;
s->sega_film_skip_bytes = -1; /* uninitialized state */
// check for paletted data
if ((avctx->palctrl == NULL) || (avctx->bits_per_sample == 40)) {
s->palette_video = 0;
avctx->pix_fmt = PIX_FMT_YUV420P;
} else {
s->palette_video = 1;
avctx->pix_fmt = PIX_FMT_PAL8;
}
dsputil_init(&s->dsp, avctx);
s->frame.data[0] = NULL;
return 0;
}
| false | FFmpeg | 32c3047cac9294bb56d23c89a40a22409db5cc70 | static int cinepak_decode_init(AVCodecContext *avctx)
{
CinepakContext *s = avctx->priv_data;
s->avctx = avctx;
s->width = (avctx->width + 3) & ~3;
s->height = (avctx->height + 3) & ~3;
s->sega_film_skip_bytes = -1;
if ((avctx->palctrl == NULL) || (avctx->bits_per_sample == 40)) {
s->palette_video = 0;
avctx->pix_fmt = PIX_FMT_YUV420P;
} else {
s->palette_video = 1;
avctx->pix_fmt = PIX_FMT_PAL8;
}
dsputil_init(&s->dsp, avctx);
s->frame.data[0] = NULL;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
CinepakContext *s = VAR_0->priv_data;
s->VAR_0 = VAR_0;
s->width = (VAR_0->width + 3) & ~3;
s->height = (VAR_0->height + 3) & ~3;
s->sega_film_skip_bytes = -1;
if ((VAR_0->palctrl == NULL) || (VAR_0->bits_per_sample == 40)) {
s->palette_video = 0;
VAR_0->pix_fmt = PIX_FMT_YUV420P;
} else {
s->palette_video = 1;
VAR_0->pix_fmt = PIX_FMT_PAL8;
}
dsputil_init(&s->dsp, VAR_0);
s->frame.data[0] = NULL;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"CinepakContext *s = VAR_0->priv_data;",
"s->VAR_0 = VAR_0;",
"s->width = (VAR_0->width + 3) & ~3;",
"s->height = (VAR_0->height + 3) & ~3;",
"s->sega_film_skip_bytes = -1;",
"if ((VAR_0->palctrl == NULL) || (VAR_0->bits_per_sample == 40)) {",
"s->palette_video = 0;",
"VAR_0->pix_fmt = PIX_FMT_YUV420P;",
"} else {",
"s->palette_video = 1;",
"VAR_0->pix_fmt = PIX_FMT_PAL8;",
"}",
"dsputil_init(&s->dsp, VAR_0);",
"s->frame.data[0] = NULL;",
"return 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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45
],
[
47
]
]
|
12,990 | static int mpegts_init(AVFormatContext *s)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
int i, j;
const char *service_name;
const char *provider_name;
int *pids;
int ret;
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = 0;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
if (!s->nb_programs) {
/* allocate a single DVB service */
title = av_dict_get(s->metadata, "service_name", NULL, 0);
if (!title)
title = av_dict_get(s->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, ts->service_id,
provider_name, service_name);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
} else {
for (i = 0; i < s->nb_programs; i++) {
AVProgram *program = s->programs[i];
title = av_dict_get(program->metadata, "service_name", NULL, 0);
if (!title)
title = av_dict_get(program->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(program->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, program->id,
provider_name, service_name);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
service->program = program;
}
}
ts->pat.pid = PAT_PID;
/* Initialize at 15 so that it wraps and is equal to 0 for the
* first packet we write. */
ts->pat.cc = 15;
ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->pat.write_packet = section_write_packet;
ts->pat.opaque = s;
ts->sdt.pid = SDT_PID;
ts->sdt.cc = 15;
ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->sdt.write_packet = section_write_packet;
ts->sdt.opaque = s;
pids = av_malloc_array(s->nb_streams, sizeof(*pids));
if (!pids) {
ret = AVERROR(ENOMEM);
goto fail;
}
/* assign pids to each stream */
for (i = 0; i < s->nb_streams; i++) {
AVProgram *program;
st = s->streams[i];
ts_st = av_mallocz(sizeof(MpegTSWriteStream));
if (!ts_st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->priv_data = ts_st;
ts_st->user_tb = st->time_base;
avpriv_set_pts_info(st, 33, 1, 90000);
ts_st->payload = av_mallocz(ts->pes_payload_size);
if (!ts_st->payload) {
ret = AVERROR(ENOMEM);
goto fail;
}
program = av_find_program_from_stream(s, NULL, i);
if (program) {
for (j = 0; j < ts->nb_services; j++) {
if (ts->services[j]->program == program) {
service = ts->services[j];
break;
}
}
}
ts_st->service = service;
/* MPEG pid values < 16 are reserved. Applications which set st->id in
* this range are assigned a calculated pid. */
if (st->id < 16) {
ts_st->pid = ts->start_pid + i;
} else if (st->id < 0x1FFF) {
ts_st->pid = st->id;
} else {
av_log(s, AV_LOG_ERROR,
"Invalid stream id %d, must be less than 8191\n", st->id);
ret = AVERROR(EINVAL);
goto fail;
}
if (ts_st->pid == service->pmt.pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
for (j = 0; j < i; j++) {
if (pids[j] == ts_st->pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
}
pids[i] = ts_st->pid;
ts_st->payload_pts = AV_NOPTS_VALUE;
ts_st->payload_dts = AV_NOPTS_VALUE;
ts_st->first_pts_check = 1;
ts_st->cc = 15;
/* update PCR pid by using the first video stream */
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) {
service->pcr_pid = ts_st->pid;
pcr_st = st;
}
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size > 0) {
AVStream *ast;
ts_st->amux = avformat_alloc_context();
if (!ts_st->amux) {
ret = AVERROR(ENOMEM);
goto fail;
}
ts_st->amux->oformat =
av_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? "latm" : "adts",
NULL, NULL);
if (!ts_st->amux->oformat) {
ret = AVERROR(EINVAL);
goto fail;
}
if (!(ast = avformat_new_stream(ts_st->amux, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = avcodec_parameters_copy(ast->codecpar, st->codecpar);
if (ret != 0)
goto fail;
ast->time_base = st->time_base;
ret = avformat_write_header(ts_st->amux, NULL);
if (ret < 0)
goto fail;
}
if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / st->codecpar->sample_rate;
}
}
av_freep(&pids);
/* if no video stream, use the first stream as PCR */
if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
pcr_st = s->streams[0];
ts_st = pcr_st->priv_data;
service->pcr_pid = ts_st->pid;
} else
ts_st = pcr_st->priv_data;
if (ts->mux_rate > 1) {
service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
(TS_PACKET_SIZE * 8 * 1000);
ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
if (ts->copyts < 1)
ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
/* Arbitrary values, PAT/PMT will also be written on video key frames */
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
if (!frame_size) {
av_log(s, AV_LOG_WARNING, "frame size not set\n");
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * 512);
} else {
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * frame_size);
}
} else {
// max delta PCR 0.1s
// TODO: should be avg_frame_rate
service->pcr_packet_period =
ts_st->user_tb.den / (10 * ts_st->user_tb.num);
}
if (!service->pcr_packet_period)
service->pcr_packet_period = 1;
}
ts->last_pat_ts = AV_NOPTS_VALUE;
ts->last_sdt_ts = AV_NOPTS_VALUE;
// The user specified a period, use only it
if (ts->pat_period < INT_MAX/2) {
ts->pat_packet_period = INT_MAX;
}
if (ts->sdt_period < INT_MAX/2) {
ts->sdt_packet_period = INT_MAX;
}
// output a PCR as soon as possible
service->pcr_packet_count = service->pcr_packet_period;
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
if (ts->mux_rate == 1)
av_log(s, AV_LOG_VERBOSE, "muxrate VBR, ");
else
av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
av_log(s, AV_LOG_VERBOSE,
"pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
service->pcr_packet_period,
ts->sdt_packet_period, ts->pat_packet_period);
if (ts->m2ts_mode == -1) {
if (av_match_ext(s->filename, "m2ts")) {
ts->m2ts_mode = 1;
} else {
ts->m2ts_mode = 0;
}
}
return 0;
fail:
av_freep(&pids);
return ret;
} | true | FFmpeg | a566c952f905639456966413fee0b5701867ddcd | static int mpegts_init(AVFormatContext *s)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
int i, j;
const char *service_name;
const char *provider_name;
int *pids;
int ret;
if (s->max_delay < 0)
s->max_delay = 0;
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
if (!s->nb_programs) {
title = av_dict_get(s->metadata, "service_name", NULL, 0);
if (!title)
title = av_dict_get(s->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, ts->service_id,
provider_name, service_name);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
} else {
for (i = 0; i < s->nb_programs; i++) {
AVProgram *program = s->programs[i];
title = av_dict_get(program->metadata, "service_name", NULL, 0);
if (!title)
title = av_dict_get(program->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(program->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, program->id,
provider_name, service_name);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
service->program = program;
}
}
ts->pat.pid = PAT_PID;
ts->pat.cc = 15;
ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->pat.write_packet = section_write_packet;
ts->pat.opaque = s;
ts->sdt.pid = SDT_PID;
ts->sdt.cc = 15;
ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->sdt.write_packet = section_write_packet;
ts->sdt.opaque = s;
pids = av_malloc_array(s->nb_streams, sizeof(*pids));
if (!pids) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < s->nb_streams; i++) {
AVProgram *program;
st = s->streams[i];
ts_st = av_mallocz(sizeof(MpegTSWriteStream));
if (!ts_st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->priv_data = ts_st;
ts_st->user_tb = st->time_base;
avpriv_set_pts_info(st, 33, 1, 90000);
ts_st->payload = av_mallocz(ts->pes_payload_size);
if (!ts_st->payload) {
ret = AVERROR(ENOMEM);
goto fail;
}
program = av_find_program_from_stream(s, NULL, i);
if (program) {
for (j = 0; j < ts->nb_services; j++) {
if (ts->services[j]->program == program) {
service = ts->services[j];
break;
}
}
}
ts_st->service = service;
if (st->id < 16) {
ts_st->pid = ts->start_pid + i;
} else if (st->id < 0x1FFF) {
ts_st->pid = st->id;
} else {
av_log(s, AV_LOG_ERROR,
"Invalid stream id %d, must be less than 8191\n", st->id);
ret = AVERROR(EINVAL);
goto fail;
}
if (ts_st->pid == service->pmt.pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
for (j = 0; j < i; j++) {
if (pids[j] == ts_st->pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
}
pids[i] = ts_st->pid;
ts_st->payload_pts = AV_NOPTS_VALUE;
ts_st->payload_dts = AV_NOPTS_VALUE;
ts_st->first_pts_check = 1;
ts_st->cc = 15;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) {
service->pcr_pid = ts_st->pid;
pcr_st = st;
}
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size > 0) {
AVStream *ast;
ts_st->amux = avformat_alloc_context();
if (!ts_st->amux) {
ret = AVERROR(ENOMEM);
goto fail;
}
ts_st->amux->oformat =
av_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? "latm" : "adts",
NULL, NULL);
if (!ts_st->amux->oformat) {
ret = AVERROR(EINVAL);
goto fail;
}
if (!(ast = avformat_new_stream(ts_st->amux, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = avcodec_parameters_copy(ast->codecpar, st->codecpar);
if (ret != 0)
goto fail;
ast->time_base = st->time_base;
ret = avformat_write_header(ts_st->amux, NULL);
if (ret < 0)
goto fail;
}
if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / st->codecpar->sample_rate;
}
}
av_freep(&pids);
if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
pcr_st = s->streams[0];
ts_st = pcr_st->priv_data;
service->pcr_pid = ts_st->pid;
} else
ts_st = pcr_st->priv_data;
if (ts->mux_rate > 1) {
service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
(TS_PACKET_SIZE * 8 * 1000);
ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
if (ts->copyts < 1)
ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
if (!frame_size) {
av_log(s, AV_LOG_WARNING, "frame size not set\n");
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * 512);
} else {
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * frame_size);
}
} else {
service->pcr_packet_period =
ts_st->user_tb.den / (10 * ts_st->user_tb.num);
}
if (!service->pcr_packet_period)
service->pcr_packet_period = 1;
}
ts->last_pat_ts = AV_NOPTS_VALUE;
ts->last_sdt_ts = AV_NOPTS_VALUE;
if (ts->pat_period < INT_MAX/2) {
ts->pat_packet_period = INT_MAX;
}
if (ts->sdt_period < INT_MAX/2) {
ts->sdt_packet_period = INT_MAX;
}
service->pcr_packet_count = service->pcr_packet_period;
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
if (ts->mux_rate == 1)
av_log(s, AV_LOG_VERBOSE, "muxrate VBR, ");
else
av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
av_log(s, AV_LOG_VERBOSE,
"pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
service->pcr_packet_period,
ts->sdt_packet_period, ts->pat_packet_period);
if (ts->m2ts_mode == -1) {
if (av_match_ext(s->filename, "m2ts")) {
ts->m2ts_mode = 1;
} else {
ts->m2ts_mode = 0;
}
}
return 0;
fail:
av_freep(&pids);
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MpegTSWrite *ts = VAR_0->priv_data;
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
int VAR_1, VAR_2;
const char *VAR_3;
const char *VAR_4;
int *VAR_5;
int VAR_6;
if (VAR_0->max_delay < 0)
VAR_0->max_delay = 0;
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
if (!VAR_0->nb_programs) {
title = av_dict_get(VAR_0->metadata, "VAR_3", NULL, 0);
if (!title)
title = av_dict_get(VAR_0->metadata, "title", NULL, 0);
VAR_3 = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(VAR_0->metadata, "service_provider", NULL, 0);
VAR_4 = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, ts->service_id,
VAR_4, VAR_3);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = VAR_0;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
} else {
for (VAR_1 = 0; VAR_1 < VAR_0->nb_programs; VAR_1++) {
AVProgram *program = VAR_0->programs[VAR_1];
title = av_dict_get(program->metadata, "VAR_3", NULL, 0);
if (!title)
title = av_dict_get(program->metadata, "title", NULL, 0);
VAR_3 = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(program->metadata, "service_provider", NULL, 0);
VAR_4 = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, program->id,
VAR_4, VAR_3);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = VAR_0;
service->pmt.cc = 15;
service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
service->program = program;
}
}
ts->pat.pid = PAT_PID;
ts->pat.cc = 15;
ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->pat.write_packet = section_write_packet;
ts->pat.opaque = VAR_0;
ts->sdt.pid = SDT_PID;
ts->sdt.cc = 15;
ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
ts->sdt.write_packet = section_write_packet;
ts->sdt.opaque = VAR_0;
VAR_5 = av_malloc_array(VAR_0->nb_streams, sizeof(*VAR_5));
if (!VAR_5) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVProgram *program;
st = VAR_0->streams[VAR_1];
ts_st = av_mallocz(sizeof(MpegTSWriteStream));
if (!ts_st) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
st->priv_data = ts_st;
ts_st->user_tb = st->time_base;
avpriv_set_pts_info(st, 33, 1, 90000);
ts_st->payload = av_mallocz(ts->pes_payload_size);
if (!ts_st->payload) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
program = av_find_program_from_stream(VAR_0, NULL, VAR_1);
if (program) {
for (VAR_2 = 0; VAR_2 < ts->nb_services; VAR_2++) {
if (ts->services[VAR_2]->program == program) {
service = ts->services[VAR_2];
break;
}
}
}
ts_st->service = service;
if (st->id < 16) {
ts_st->pid = ts->start_pid + VAR_1;
} else if (st->id < 0x1FFF) {
ts_st->pid = st->id;
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid stream id %d, must be less than 8191\n", st->id);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
if (ts_st->pid == service->pmt.pid) {
av_log(VAR_0, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
if (VAR_5[VAR_2] == ts_st->pid) {
av_log(VAR_0, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
}
VAR_5[VAR_1] = ts_st->pid;
ts_st->payload_pts = AV_NOPTS_VALUE;
ts_st->payload_dts = AV_NOPTS_VALUE;
ts_st->first_pts_check = 1;
ts_st->cc = 15;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) {
service->pcr_pid = ts_st->pid;
pcr_st = st;
}
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size > 0) {
AVStream *ast;
ts_st->amux = avformat_alloc_context();
if (!ts_st->amux) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
ts_st->amux->oformat =
av_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? "latm" : "adts",
NULL, NULL);
if (!ts_st->amux->oformat) {
VAR_6 = AVERROR(EINVAL);
goto fail;
}
if (!(ast = avformat_new_stream(ts_st->amux, NULL))) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
VAR_6 = avcodec_parameters_copy(ast->codecpar, st->codecpar);
if (VAR_6 != 0)
goto fail;
ast->time_base = st->time_base;
VAR_6 = avformat_write_header(ts_st->amux, NULL);
if (VAR_6 < 0)
goto fail;
}
if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / st->codecpar->sample_rate;
}
}
av_freep(&VAR_5);
if (service->pcr_pid == 0x1fff && VAR_0->nb_streams > 0) {
pcr_st = VAR_0->streams[0];
ts_st = pcr_st->priv_data;
service->pcr_pid = ts_st->pid;
} else
ts_st = pcr_st->priv_data;
if (ts->mux_rate > 1) {
service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
(TS_PACKET_SIZE * 8 * 1000);
ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000);
if (ts->copyts < 1)
ts->first_pcr = av_rescale(VAR_0->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
int VAR_7 = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
if (!VAR_7) {
av_log(VAR_0, AV_LOG_WARNING, "frame size not set\n");
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * 512);
} else {
service->pcr_packet_period =
pcr_st->codecpar->sample_rate / (10 * VAR_7);
}
} else {
service->pcr_packet_period =
ts_st->user_tb.den / (10 * ts_st->user_tb.num);
}
if (!service->pcr_packet_period)
service->pcr_packet_period = 1;
}
ts->last_pat_ts = AV_NOPTS_VALUE;
ts->last_sdt_ts = AV_NOPTS_VALUE;
if (ts->pat_period < INT_MAX/2) {
ts->pat_packet_period = INT_MAX;
}
if (ts->sdt_period < INT_MAX/2) {
ts->sdt_packet_period = INT_MAX;
}
service->pcr_packet_count = service->pcr_packet_period;
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
if (ts->mux_rate == 1)
av_log(VAR_0, AV_LOG_VERBOSE, "muxrate VBR, ");
else
av_log(VAR_0, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
av_log(VAR_0, AV_LOG_VERBOSE,
"pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
service->pcr_packet_period,
ts->sdt_packet_period, ts->pat_packet_period);
if (ts->m2ts_mode == -1) {
if (av_match_ext(VAR_0->filename, "m2ts")) {
ts->m2ts_mode = 1;
} else {
ts->m2ts_mode = 0;
}
}
return 0;
fail:
av_freep(&VAR_5);
return VAR_6;
} | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MpegTSWrite *ts = VAR_0->priv_data;",
"MpegTSWriteStream *ts_st;",
"MpegTSService *service;",
"AVStream *st, *pcr_st = NULL;",
"AVDictionaryEntry *title, *provider;",
"int VAR_1, VAR_2;",
"const char *VAR_3;",
"const char *VAR_4;",
"int *VAR_5;",
"int VAR_6;",
"if (VAR_0->max_delay < 0)\nVAR_0->max_delay = 0;",
"ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;",
"ts->tsid = ts->transport_stream_id;",
"ts->onid = ts->original_network_id;",
"if (!VAR_0->nb_programs) {",
"title = av_dict_get(VAR_0->metadata, \"VAR_3\", NULL, 0);",
"if (!title)\ntitle = av_dict_get(VAR_0->metadata, \"title\", NULL, 0);",
"VAR_3 = title ? title->value : DEFAULT_SERVICE_NAME;",
"provider = av_dict_get(VAR_0->metadata, \"service_provider\", NULL, 0);",
"VAR_4 = provider ? provider->value : DEFAULT_PROVIDER_NAME;",
"service = mpegts_add_service(ts, ts->service_id,\nVAR_4, VAR_3);",
"if (!service)\nreturn AVERROR(ENOMEM);",
"service->pmt.write_packet = section_write_packet;",
"service->pmt.opaque = VAR_0;",
"service->pmt.cc = 15;",
"service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;",
"} else {",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_programs; VAR_1++) {",
"AVProgram *program = VAR_0->programs[VAR_1];",
"title = av_dict_get(program->metadata, \"VAR_3\", NULL, 0);",
"if (!title)\ntitle = av_dict_get(program->metadata, \"title\", NULL, 0);",
"VAR_3 = title ? title->value : DEFAULT_SERVICE_NAME;",
"provider = av_dict_get(program->metadata, \"service_provider\", NULL, 0);",
"VAR_4 = provider ? provider->value : DEFAULT_PROVIDER_NAME;",
"service = mpegts_add_service(ts, program->id,\nVAR_4, VAR_3);",
"if (!service)\nreturn AVERROR(ENOMEM);",
"service->pmt.write_packet = section_write_packet;",
"service->pmt.opaque = VAR_0;",
"service->pmt.cc = 15;",
"service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;",
"service->program = program;",
"}",
"}",
"ts->pat.pid = PAT_PID;",
"ts->pat.cc = 15;",
"ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;",
"ts->pat.write_packet = section_write_packet;",
"ts->pat.opaque = VAR_0;",
"ts->sdt.pid = SDT_PID;",
"ts->sdt.cc = 15;",
"ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;",
"ts->sdt.write_packet = section_write_packet;",
"ts->sdt.opaque = VAR_0;",
"VAR_5 = av_malloc_array(VAR_0->nb_streams, sizeof(*VAR_5));",
"if (!VAR_5) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVProgram *program;",
"st = VAR_0->streams[VAR_1];",
"ts_st = av_mallocz(sizeof(MpegTSWriteStream));",
"if (!ts_st) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"st->priv_data = ts_st;",
"ts_st->user_tb = st->time_base;",
"avpriv_set_pts_info(st, 33, 1, 90000);",
"ts_st->payload = av_mallocz(ts->pes_payload_size);",
"if (!ts_st->payload) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"program = av_find_program_from_stream(VAR_0, NULL, VAR_1);",
"if (program) {",
"for (VAR_2 = 0; VAR_2 < ts->nb_services; VAR_2++) {",
"if (ts->services[VAR_2]->program == program) {",
"service = ts->services[VAR_2];",
"break;",
"}",
"}",
"}",
"ts_st->service = service;",
"if (st->id < 16) {",
"ts_st->pid = ts->start_pid + VAR_1;",
"} else if (st->id < 0x1FFF) {",
"ts_st->pid = st->id;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid stream id %d, must be less than 8191\\n\", st->id);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if (ts_st->pid == service->pmt.pid) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Duplicate stream id %d\\n\", ts_st->pid);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"if (VAR_5[VAR_2] == ts_st->pid) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Duplicate stream id %d\\n\", ts_st->pid);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"}",
"VAR_5[VAR_1] = ts_st->pid;",
"ts_st->payload_pts = AV_NOPTS_VALUE;",
"ts_st->payload_dts = AV_NOPTS_VALUE;",
"ts_st->first_pts_check = 1;",
"ts_st->cc = 15;",
"if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&\nservice->pcr_pid == 0x1fff) {",
"service->pcr_pid = ts_st->pid;",
"pcr_st = st;",
"}",
"if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&\nst->codecpar->extradata_size > 0) {",
"AVStream *ast;",
"ts_st->amux = avformat_alloc_context();",
"if (!ts_st->amux) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ts_st->amux->oformat =\nav_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? \"latm\" : \"adts\",\nNULL, NULL);",
"if (!ts_st->amux->oformat) {",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if (!(ast = avformat_new_stream(ts_st->amux, NULL))) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_6 = avcodec_parameters_copy(ast->codecpar, st->codecpar);",
"if (VAR_6 != 0)\ngoto fail;",
"ast->time_base = st->time_base;",
"VAR_6 = avformat_write_header(ts_st->amux, NULL);",
"if (VAR_6 < 0)\ngoto fail;",
"}",
"if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {",
"ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / st->codecpar->sample_rate;",
"}",
"}",
"av_freep(&VAR_5);",
"if (service->pcr_pid == 0x1fff && VAR_0->nb_streams > 0) {",
"pcr_st = VAR_0->streams[0];",
"ts_st = pcr_st->priv_data;",
"service->pcr_pid = ts_st->pid;",
"} else",
"ts_st = pcr_st->priv_data;",
"if (ts->mux_rate > 1) {",
"service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /\n(TS_PACKET_SIZE * 8 * 1000);",
"ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /\n(TS_PACKET_SIZE * 8 * 1000);",
"ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /\n(TS_PACKET_SIZE * 8 * 1000);",
"if (ts->copyts < 1)\nts->first_pcr = av_rescale(VAR_0->max_delay, PCR_TIME_BASE, AV_TIME_BASE);",
"} else {",
"ts->sdt_packet_period = 200;",
"ts->pat_packet_period = 40;",
"if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {",
"int VAR_7 = av_get_audio_frame_duration2(pcr_st->codecpar, 0);",
"if (!VAR_7) {",
"av_log(VAR_0, AV_LOG_WARNING, \"frame size not set\\n\");",
"service->pcr_packet_period =\npcr_st->codecpar->sample_rate / (10 * 512);",
"} else {",
"service->pcr_packet_period =\npcr_st->codecpar->sample_rate / (10 * VAR_7);",
"}",
"} else {",
"service->pcr_packet_period =\nts_st->user_tb.den / (10 * ts_st->user_tb.num);",
"}",
"if (!service->pcr_packet_period)\nservice->pcr_packet_period = 1;",
"}",
"ts->last_pat_ts = AV_NOPTS_VALUE;",
"ts->last_sdt_ts = AV_NOPTS_VALUE;",
"if (ts->pat_period < INT_MAX/2) {",
"ts->pat_packet_period = INT_MAX;",
"}",
"if (ts->sdt_period < INT_MAX/2) {",
"ts->sdt_packet_period = INT_MAX;",
"}",
"service->pcr_packet_count = service->pcr_packet_period;",
"ts->pat_packet_count = ts->pat_packet_period - 1;",
"ts->sdt_packet_count = ts->sdt_packet_period - 1;",
"if (ts->mux_rate == 1)\nav_log(VAR_0, AV_LOG_VERBOSE, \"muxrate VBR, \");",
"else\nav_log(VAR_0, AV_LOG_VERBOSE, \"muxrate %d, \", ts->mux_rate);",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\\n\",\nservice->pcr_packet_period,\nts->sdt_packet_period, ts->pat_packet_period);",
"if (ts->m2ts_mode == -1) {",
"if (av_match_ext(VAR_0->filename, \"m2ts\")) {",
"ts->m2ts_mode = 1;",
"} else {",
"ts->m2ts_mode = 0;",
"}",
"}",
"return 0;",
"fail:\nav_freep(&VAR_5);",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
65,
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
103,
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
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
],
[
290,
292
],
[
294
],
[
296
],
[
298
],
[
300,
302
],
[
304
],
[
306
],
[
308
],
[
310
],
[
312
],
[
314
],
[
316,
318,
320
],
[
322
],
[
324
],
[
326
],
[
328
],
[
330
],
[
332
],
[
334
],
[
336
],
[
338
],
[
340,
342
],
[
344
],
[
346
],
[
348,
350
],
[
352
],
[
354
],
[
356
],
[
358
],
[
360
],
[
364
],
[
370
],
[
372
],
[
374
],
[
376
],
[
378
],
[
380
],
[
384
],
[
386,
388
],
[
390,
392
],
[
394,
396
],
[
400,
402
],
[
404
],
[
408
],
[
410
],
[
412
],
[
414
],
[
416
],
[
418
],
[
420,
422
],
[
424
],
[
426,
428
],
[
430
],
[
432
],
[
438,
440
],
[
442
],
[
444,
446
],
[
448
],
[
452
],
[
454
],
[
458
],
[
460
],
[
462
],
[
464
],
[
466
],
[
468
],
[
474
],
[
476
],
[
478
],
[
482,
484
],
[
486,
488
],
[
490,
492,
494,
496
],
[
500
],
[
502
],
[
504
],
[
506
],
[
508
],
[
510
],
[
512
],
[
516
],
[
520,
522
],
[
524
],
[
526
]
]
|
12,991 | static void rtsp_cmd_setup(HTTPContext *c, const char *url,
RTSPHeader *h)
{
FFStream *stream;
int stream_index, port;
char buf[1024];
char path1[1024];
const char *path;
HTTPContext *rtp_c;
RTSPTransportField *th;
struct sockaddr_in dest_addr;
RTSPActionServerSetup setup;
/* find which url is asked */
url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
path = path1;
if (*path == '/')
path++;
/* now check each stream */
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (!stream->is_feed && !strcmp(stream->fmt->name, "rtp")) {
/* accept aggregate filenames only if single stream */
if (!strcmp(path, stream->filename)) {
if (stream->nb_streams != 1) {
rtsp_reply_error(c, RTSP_STATUS_AGGREGATE);
return;
}
stream_index = 0;
goto found;
}
for(stream_index = 0; stream_index < stream->nb_streams;
stream_index++) {
snprintf(buf, sizeof(buf), "%s/streamid=%d",
stream->filename, stream_index);
if (!strcmp(path, buf))
goto found;
}
}
}
/* no stream found */
rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */
return;
found:
/* generate session id if needed */
if (h->session_id[0] == '\0')
snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
av_random(&random_state), av_random(&random_state));
/* find rtp session, and create it if none found */
rtp_c = find_rtp_session(h->session_id);
if (!rtp_c) {
/* always prefer UDP */
th = find_transport(h, RTSP_PROTOCOL_RTP_UDP);
if (!th) {
th = find_transport(h, RTSP_PROTOCOL_RTP_TCP);
if (!th) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
}
rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id,
th->protocol);
if (!rtp_c) {
rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH);
return;
}
/* open input stream */
if (open_input_stream(rtp_c, "") < 0) {
rtsp_reply_error(c, RTSP_STATUS_INTERNAL);
return;
}
}
/* test if stream is OK (test needed because several SETUP needs
to be done for a given file) */
if (rtp_c->stream != stream) {
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
}
/* test if stream is already set up */
if (rtp_c->rtp_ctx[stream_index]) {
rtsp_reply_error(c, RTSP_STATUS_STATE);
return;
}
/* check transport */
th = find_transport(h, rtp_c->rtp_protocol);
if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&
th->client_port_min <= 0)) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
/* setup default options */
setup.transport_option[0] = '\0';
dest_addr = rtp_c->from_addr;
dest_addr.sin_port = htons(th->client_port_min);
/* setup stream */
if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
/* now everything is OK, so we can send the connection parameters */
rtsp_reply_header(c, RTSP_STATUS_OK);
/* session ID */
url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
switch(rtp_c->rtp_protocol) {
case RTSP_PROTOCOL_RTP_UDP:
port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]);
url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
"client_port=%d-%d;server_port=%d-%d",
th->client_port_min, th->client_port_min + 1,
port, port + 1);
break;
case RTSP_PROTOCOL_RTP_TCP:
url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
stream_index * 2, stream_index * 2 + 1);
break;
default:
break;
}
if (setup.transport_option[0] != '\0')
url_fprintf(c->pb, ";%s", setup.transport_option);
url_fprintf(c->pb, "\r\n");
url_fprintf(c->pb, "\r\n");
}
| true | FFmpeg | 25e3e53d4092e7b69a4d681824fa0f7b2731bb1e | static void rtsp_cmd_setup(HTTPContext *c, const char *url,
RTSPHeader *h)
{
FFStream *stream;
int stream_index, port;
char buf[1024];
char path1[1024];
const char *path;
HTTPContext *rtp_c;
RTSPTransportField *th;
struct sockaddr_in dest_addr;
RTSPActionServerSetup setup;
url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
path = path1;
if (*path == '/')
path++;
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (!stream->is_feed && !strcmp(stream->fmt->name, "rtp")) {
if (!strcmp(path, stream->filename)) {
if (stream->nb_streams != 1) {
rtsp_reply_error(c, RTSP_STATUS_AGGREGATE);
return;
}
stream_index = 0;
goto found;
}
for(stream_index = 0; stream_index < stream->nb_streams;
stream_index++) {
snprintf(buf, sizeof(buf), "%s/streamid=%d",
stream->filename, stream_index);
if (!strcmp(path, buf))
goto found;
}
}
}
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
found:
if (h->session_id[0] == '\0')
snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
av_random(&random_state), av_random(&random_state));
rtp_c = find_rtp_session(h->session_id);
if (!rtp_c) {
th = find_transport(h, RTSP_PROTOCOL_RTP_UDP);
if (!th) {
th = find_transport(h, RTSP_PROTOCOL_RTP_TCP);
if (!th) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
}
rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id,
th->protocol);
if (!rtp_c) {
rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH);
return;
}
if (open_input_stream(rtp_c, "") < 0) {
rtsp_reply_error(c, RTSP_STATUS_INTERNAL);
return;
}
}
if (rtp_c->stream != stream) {
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
}
if (rtp_c->rtp_ctx[stream_index]) {
rtsp_reply_error(c, RTSP_STATUS_STATE);
return;
}
th = find_transport(h, rtp_c->rtp_protocol);
if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&
th->client_port_min <= 0)) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
setup.transport_option[0] = '\0';
dest_addr = rtp_c->from_addr;
dest_addr.sin_port = htons(th->client_port_min);
if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
rtsp_reply_header(c, RTSP_STATUS_OK);
url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
switch(rtp_c->rtp_protocol) {
case RTSP_PROTOCOL_RTP_UDP:
port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]);
url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
"client_port=%d-%d;server_port=%d-%d",
th->client_port_min, th->client_port_min + 1,
port, port + 1);
break;
case RTSP_PROTOCOL_RTP_TCP:
url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
stream_index * 2, stream_index * 2 + 1);
break;
default:
break;
}
if (setup.transport_option[0] != '\0')
url_fprintf(c->pb, ";%s", setup.transport_option);
url_fprintf(c->pb, "\r\n");
url_fprintf(c->pb, "\r\n");
}
| {
"code": [
" if (!stream->is_feed && !strcmp(stream->fmt->name, \"rtp\")) {"
],
"line_no": [
43
]
} | static void FUNC_0(HTTPContext *VAR_0, const char *VAR_1,
RTSPHeader *VAR_2)
{
FFStream *stream;
int VAR_3, VAR_4;
char VAR_5[1024];
char VAR_6[1024];
const char *VAR_7;
HTTPContext *rtp_c;
RTSPTransportField *th;
struct sockaddr_in VAR_8;
RTSPActionServerSetup setup;
url_split(NULL, 0, NULL, 0, NULL, 0, NULL, VAR_6, sizeof(VAR_6), VAR_1);
VAR_7 = VAR_6;
if (*VAR_7 == '/')
VAR_7++;
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (!stream->is_feed && !strcmp(stream->fmt->name, "rtp")) {
if (!strcmp(VAR_7, stream->filename)) {
if (stream->nb_streams != 1) {
rtsp_reply_error(VAR_0, RTSP_STATUS_AGGREGATE);
return;
}
VAR_3 = 0;
goto found;
}
for(VAR_3 = 0; VAR_3 < stream->nb_streams;
VAR_3++) {
snprintf(VAR_5, sizeof(VAR_5), "%s/streamid=%d",
stream->filename, VAR_3);
if (!strcmp(VAR_7, VAR_5))
goto found;
}
}
}
rtsp_reply_error(VAR_0, RTSP_STATUS_SERVICE);
return;
found:
if (VAR_2->session_id[0] == '\0')
snprintf(VAR_2->session_id, sizeof(VAR_2->session_id), "%08x%08x",
av_random(&random_state), av_random(&random_state));
rtp_c = find_rtp_session(VAR_2->session_id);
if (!rtp_c) {
th = find_transport(VAR_2, RTSP_PROTOCOL_RTP_UDP);
if (!th) {
th = find_transport(VAR_2, RTSP_PROTOCOL_RTP_TCP);
if (!th) {
rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);
return;
}
}
rtp_c = rtp_new_connection(&VAR_0->from_addr, stream, VAR_2->session_id,
th->protocol);
if (!rtp_c) {
rtsp_reply_error(VAR_0, RTSP_STATUS_BANDWIDTH);
return;
}
if (open_input_stream(rtp_c, "") < 0) {
rtsp_reply_error(VAR_0, RTSP_STATUS_INTERNAL);
return;
}
}
if (rtp_c->stream != stream) {
rtsp_reply_error(VAR_0, RTSP_STATUS_SERVICE);
return;
}
if (rtp_c->rtp_ctx[VAR_3]) {
rtsp_reply_error(VAR_0, RTSP_STATUS_STATE);
return;
}
th = find_transport(VAR_2, rtp_c->rtp_protocol);
if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&
th->client_port_min <= 0)) {
rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);
return;
}
setup.transport_option[0] = '\0';
VAR_8 = rtp_c->from_addr;
VAR_8.sin_port = htons(th->client_port_min);
if (rtp_new_av_stream(rtp_c, VAR_3, &VAR_8, VAR_0) < 0) {
rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);
return;
}
rtsp_reply_header(VAR_0, RTSP_STATUS_OK);
url_fprintf(VAR_0->pb, "Session: %s\r\n", rtp_c->session_id);
switch(rtp_c->rtp_protocol) {
case RTSP_PROTOCOL_RTP_UDP:
VAR_4 = rtp_get_local_port(rtp_c->rtp_handles[VAR_3]);
url_fprintf(VAR_0->pb, "Transport: RTP/AVP/UDP;unicast;"
"client_port=%d-%d;server_port=%d-%d",
th->client_port_min, th->client_port_min + 1,
VAR_4, VAR_4 + 1);
break;
case RTSP_PROTOCOL_RTP_TCP:
url_fprintf(VAR_0->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
VAR_3 * 2, VAR_3 * 2 + 1);
break;
default:
break;
}
if (setup.transport_option[0] != '\0')
url_fprintf(VAR_0->pb, ";%s", setup.transport_option);
url_fprintf(VAR_0->pb, "\r\n");
url_fprintf(VAR_0->pb, "\r\n");
}
| [
"static void FUNC_0(HTTPContext *VAR_0, const char *VAR_1,\nRTSPHeader *VAR_2)\n{",
"FFStream *stream;",
"int VAR_3, VAR_4;",
"char VAR_5[1024];",
"char VAR_6[1024];",
"const char *VAR_7;",
"HTTPContext *rtp_c;",
"RTSPTransportField *th;",
"struct sockaddr_in VAR_8;",
"RTSPActionServerSetup setup;",
"url_split(NULL, 0, NULL, 0, NULL, 0, NULL, VAR_6, sizeof(VAR_6), VAR_1);",
"VAR_7 = VAR_6;",
"if (*VAR_7 == '/')\nVAR_7++;",
"for(stream = first_stream; stream != NULL; stream = stream->next) {",
"if (!stream->is_feed && !strcmp(stream->fmt->name, \"rtp\")) {",
"if (!strcmp(VAR_7, stream->filename)) {",
"if (stream->nb_streams != 1) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_AGGREGATE);",
"return;",
"}",
"VAR_3 = 0;",
"goto found;",
"}",
"for(VAR_3 = 0; VAR_3 < stream->nb_streams;",
"VAR_3++) {",
"snprintf(VAR_5, sizeof(VAR_5), \"%s/streamid=%d\",\nstream->filename, VAR_3);",
"if (!strcmp(VAR_7, VAR_5))\ngoto found;",
"}",
"}",
"}",
"rtsp_reply_error(VAR_0, RTSP_STATUS_SERVICE);",
"return;",
"found:\nif (VAR_2->session_id[0] == '\\0')\nsnprintf(VAR_2->session_id, sizeof(VAR_2->session_id), \"%08x%08x\",\nav_random(&random_state), av_random(&random_state));",
"rtp_c = find_rtp_session(VAR_2->session_id);",
"if (!rtp_c) {",
"th = find_transport(VAR_2, RTSP_PROTOCOL_RTP_UDP);",
"if (!th) {",
"th = find_transport(VAR_2, RTSP_PROTOCOL_RTP_TCP);",
"if (!th) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);",
"return;",
"}",
"}",
"rtp_c = rtp_new_connection(&VAR_0->from_addr, stream, VAR_2->session_id,\nth->protocol);",
"if (!rtp_c) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_BANDWIDTH);",
"return;",
"}",
"if (open_input_stream(rtp_c, \"\") < 0) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_INTERNAL);",
"return;",
"}",
"}",
"if (rtp_c->stream != stream) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_SERVICE);",
"return;",
"}",
"if (rtp_c->rtp_ctx[VAR_3]) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_STATE);",
"return;",
"}",
"th = find_transport(VAR_2, rtp_c->rtp_protocol);",
"if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&\nth->client_port_min <= 0)) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);",
"return;",
"}",
"setup.transport_option[0] = '\\0';",
"VAR_8 = rtp_c->from_addr;",
"VAR_8.sin_port = htons(th->client_port_min);",
"if (rtp_new_av_stream(rtp_c, VAR_3, &VAR_8, VAR_0) < 0) {",
"rtsp_reply_error(VAR_0, RTSP_STATUS_TRANSPORT);",
"return;",
"}",
"rtsp_reply_header(VAR_0, RTSP_STATUS_OK);",
"url_fprintf(VAR_0->pb, \"Session: %s\\r\\n\", rtp_c->session_id);",
"switch(rtp_c->rtp_protocol) {",
"case RTSP_PROTOCOL_RTP_UDP:\nVAR_4 = rtp_get_local_port(rtp_c->rtp_handles[VAR_3]);",
"url_fprintf(VAR_0->pb, \"Transport: RTP/AVP/UDP;unicast;\"",
"\"client_port=%d-%d;server_port=%d-%d\",",
"th->client_port_min, th->client_port_min + 1,\nVAR_4, VAR_4 + 1);",
"break;",
"case RTSP_PROTOCOL_RTP_TCP:\nurl_fprintf(VAR_0->pb, \"Transport: RTP/AVP/TCP;interleaved=%d-%d\",",
"VAR_3 * 2, VAR_3 * 2 + 1);",
"break;",
"default:\nbreak;",
"}",
"if (setup.transport_option[0] != '\\0')\nurl_fprintf(VAR_0->pb, \";%s\", setup.transport_option);",
"url_fprintf(VAR_0->pb, \"\\r\\n\");",
"url_fprintf(VAR_0->pb, \"\\r\\n\");",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33,
35
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
95,
97,
99
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
161
],
[
163
],
[
165
],
[
167
],
[
173
],
[
175
],
[
177
],
[
179
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
201
],
[
203
],
[
205
],
[
211
],
[
213
],
[
215
],
[
217
],
[
223
],
[
227
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247,
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261,
263
],
[
265
],
[
271
],
[
273
]
]
|
12,992 | void aio_set_fd_handler(AioContext *ctx,
int fd,
bool is_external,
IOHandler *io_read,
IOHandler *io_write,
AioPollFn *io_poll,
void *opaque)
{
AioHandler *node;
bool is_new = false;
bool deleted = false;
qemu_lockcnt_lock(&ctx->list_lock);
node = find_aio_handler(ctx, fd);
/* Are we deleting the fd handler? */
if (!io_read && !io_write && !io_poll) {
if (node == NULL) {
qemu_lockcnt_unlock(&ctx->list_lock);
return;
}
g_source_remove_poll(&ctx->source, &node->pfd);
/* If the lock is held, just mark the node as deleted */
if (qemu_lockcnt_count(&ctx->list_lock)) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
/* Otherwise, delete it for real. We can't just mark it as
* deleted because deleted nodes are only cleaned up while
* no one is walking the handlers list.
*/
QLIST_REMOVE(node, node);
deleted = true;
}
if (!node->io_poll) {
ctx->poll_disable_cnt--;
}
} else {
if (node == NULL) {
/* Alloc and insert if it's not already there */
node = g_new0(AioHandler, 1);
node->pfd.fd = fd;
QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
is_new = true;
ctx->poll_disable_cnt += !io_poll;
} else {
ctx->poll_disable_cnt += !io_poll - !node->io_poll;
}
/* Update handler with latest information */
node->io_read = io_read;
node->io_write = io_write;
node->io_poll = io_poll;
node->opaque = opaque;
node->is_external = is_external;
node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);
}
aio_epoll_update(ctx, node, is_new);
qemu_lockcnt_unlock(&ctx->list_lock);
aio_notify(ctx);
if (deleted) {
g_free(node);
}
}
| true | qemu | f708a5e71cba0d784e307334c07ade5f56f827ab | void aio_set_fd_handler(AioContext *ctx,
int fd,
bool is_external,
IOHandler *io_read,
IOHandler *io_write,
AioPollFn *io_poll,
void *opaque)
{
AioHandler *node;
bool is_new = false;
bool deleted = false;
qemu_lockcnt_lock(&ctx->list_lock);
node = find_aio_handler(ctx, fd);
if (!io_read && !io_write && !io_poll) {
if (node == NULL) {
qemu_lockcnt_unlock(&ctx->list_lock);
return;
}
g_source_remove_poll(&ctx->source, &node->pfd);
if (qemu_lockcnt_count(&ctx->list_lock)) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
deleted = true;
}
if (!node->io_poll) {
ctx->poll_disable_cnt--;
}
} else {
if (node == NULL) {
node = g_new0(AioHandler, 1);
node->pfd.fd = fd;
QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
is_new = true;
ctx->poll_disable_cnt += !io_poll;
} else {
ctx->poll_disable_cnt += !io_poll - !node->io_poll;
}
node->io_read = io_read;
node->io_write = io_write;
node->io_poll = io_poll;
node->opaque = opaque;
node->is_external = is_external;
node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);
}
aio_epoll_update(ctx, node, is_new);
qemu_lockcnt_unlock(&ctx->list_lock);
aio_notify(ctx);
if (deleted) {
g_free(node);
}
}
| {
"code": [
" g_source_remove_poll(&ctx->source, &node->pfd);"
],
"line_no": [
47
]
} | void FUNC_0(AioContext *VAR_0,
int VAR_1,
bool VAR_2,
IOHandler *VAR_3,
IOHandler *VAR_4,
AioPollFn *VAR_5,
void *VAR_6)
{
AioHandler *node;
bool is_new = false;
bool deleted = false;
qemu_lockcnt_lock(&VAR_0->list_lock);
node = find_aio_handler(VAR_0, VAR_1);
if (!VAR_3 && !VAR_4 && !VAR_5) {
if (node == NULL) {
qemu_lockcnt_unlock(&VAR_0->list_lock);
return;
}
g_source_remove_poll(&VAR_0->source, &node->pfd);
if (qemu_lockcnt_count(&VAR_0->list_lock)) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
deleted = true;
}
if (!node->VAR_5) {
VAR_0->poll_disable_cnt--;
}
} else {
if (node == NULL) {
node = g_new0(AioHandler, 1);
node->pfd.VAR_1 = VAR_1;
QLIST_INSERT_HEAD_RCU(&VAR_0->aio_handlers, node, node);
g_source_add_poll(&VAR_0->source, &node->pfd);
is_new = true;
VAR_0->poll_disable_cnt += !VAR_5;
} else {
VAR_0->poll_disable_cnt += !VAR_5 - !node->VAR_5;
}
node->VAR_3 = VAR_3;
node->VAR_4 = VAR_4;
node->VAR_5 = VAR_5;
node->VAR_6 = VAR_6;
node->VAR_2 = VAR_2;
node->pfd.events = (VAR_3 ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
node->pfd.events |= (VAR_4 ? G_IO_OUT | G_IO_ERR : 0);
}
aio_epoll_update(VAR_0, node, is_new);
qemu_lockcnt_unlock(&VAR_0->list_lock);
aio_notify(VAR_0);
if (deleted) {
g_free(node);
}
}
| [
"void FUNC_0(AioContext *VAR_0,\nint VAR_1,\nbool VAR_2,\nIOHandler *VAR_3,\nIOHandler *VAR_4,\nAioPollFn *VAR_5,\nvoid *VAR_6)\n{",
"AioHandler *node;",
"bool is_new = false;",
"bool deleted = false;",
"qemu_lockcnt_lock(&VAR_0->list_lock);",
"node = find_aio_handler(VAR_0, VAR_1);",
"if (!VAR_3 && !VAR_4 && !VAR_5) {",
"if (node == NULL) {",
"qemu_lockcnt_unlock(&VAR_0->list_lock);",
"return;",
"}",
"g_source_remove_poll(&VAR_0->source, &node->pfd);",
"if (qemu_lockcnt_count(&VAR_0->list_lock)) {",
"node->deleted = 1;",
"node->pfd.revents = 0;",
"} else {",
"QLIST_REMOVE(node, node);",
"deleted = true;",
"}",
"if (!node->VAR_5) {",
"VAR_0->poll_disable_cnt--;",
"}",
"} else {",
"if (node == NULL) {",
"node = g_new0(AioHandler, 1);",
"node->pfd.VAR_1 = VAR_1;",
"QLIST_INSERT_HEAD_RCU(&VAR_0->aio_handlers, node, node);",
"g_source_add_poll(&VAR_0->source, &node->pfd);",
"is_new = true;",
"VAR_0->poll_disable_cnt += !VAR_5;",
"} else {",
"VAR_0->poll_disable_cnt += !VAR_5 - !node->VAR_5;",
"}",
"node->VAR_3 = VAR_3;",
"node->VAR_4 = VAR_4;",
"node->VAR_5 = VAR_5;",
"node->VAR_6 = VAR_6;",
"node->VAR_2 = VAR_2;",
"node->pfd.events = (VAR_3 ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);",
"node->pfd.events |= (VAR_4 ? G_IO_OUT | G_IO_ERR : 0);",
"}",
"aio_epoll_update(VAR_0, node, is_new);",
"qemu_lockcnt_unlock(&VAR_0->list_lock);",
"aio_notify(VAR_0);",
"if (deleted) {",
"g_free(node);",
"}",
"}"
]
| [
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
]
| [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
]
]
|
12,993 | static int check_bits_for_superframe(GetBitContext *orig_gb,
WMAVoiceContext *s)
{
GetBitContext s_gb, *gb = &s_gb;
int n, need_bits, bd_idx;
const struct frame_type_desc *frame_desc;
/* initialize a copy */
init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits);
skip_bits_long(gb, get_bits_count(orig_gb));
av_assert1(get_bits_left(gb) == get_bits_left(orig_gb));
/* superframe header */
if (get_bits_left(gb) < 14)
return 1;
if (!get_bits1(gb))
return AVERROR(ENOSYS); // WMAPro-in-WMAVoice superframe
if (get_bits1(gb)) skip_bits(gb, 12); // number of samples in superframe
if (s->has_residual_lsps) { // residual LSPs (for all frames)
if (get_bits_left(gb) < s->sframe_lsp_bitsize)
return 1;
skip_bits_long(gb, s->sframe_lsp_bitsize);
}
/* frames */
for (n = 0; n < MAX_FRAMES; n++) {
int aw_idx_is_ext = 0;
if (!s->has_residual_lsps) { // independent LSPs (per-frame)
if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1;
skip_bits_long(gb, s->frame_lsp_bitsize);
}
bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
if (bd_idx < 0)
return AVERROR_INVALIDDATA; // invalid frame type VLC code
frame_desc = &frame_descs[bd_idx];
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
if (get_bits_left(gb) < s->pitch_nbits)
return 1;
skip_bits_long(gb, s->pitch_nbits);
}
if (frame_desc->fcb_type == FCB_TYPE_SILENCE) {
skip_bits(gb, 8);
} else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
int tmp = get_bits(gb, 6);
if (tmp >= 0x36) {
skip_bits(gb, 2);
aw_idx_is_ext = 1;
}
}
/* blocks */
if (frame_desc->acb_type == ACB_TYPE_HAMMING) {
need_bits = s->block_pitch_nbits +
(frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits;
} else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
need_bits = 2 * !aw_idx_is_ext;
} else
need_bits = 0;
need_bits += frame_desc->frame_size;
if (get_bits_left(gb) < need_bits)
return 1;
skip_bits_long(gb, need_bits);
}
return 0;
}
| false | FFmpeg | 3deb4b54a24f8cddce463d9f5751b01efeb976af | static int check_bits_for_superframe(GetBitContext *orig_gb,
WMAVoiceContext *s)
{
GetBitContext s_gb, *gb = &s_gb;
int n, need_bits, bd_idx;
const struct frame_type_desc *frame_desc;
init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits);
skip_bits_long(gb, get_bits_count(orig_gb));
av_assert1(get_bits_left(gb) == get_bits_left(orig_gb));
if (get_bits_left(gb) < 14)
return 1;
if (!get_bits1(gb))
return AVERROR(ENOSYS);
if (get_bits1(gb)) skip_bits(gb, 12);
if (s->has_residual_lsps) {
if (get_bits_left(gb) < s->sframe_lsp_bitsize)
return 1;
skip_bits_long(gb, s->sframe_lsp_bitsize);
}
for (n = 0; n < MAX_FRAMES; n++) {
int aw_idx_is_ext = 0;
if (!s->has_residual_lsps) {
if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1;
skip_bits_long(gb, s->frame_lsp_bitsize);
}
bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
if (bd_idx < 0)
return AVERROR_INVALIDDATA;
frame_desc = &frame_descs[bd_idx];
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
if (get_bits_left(gb) < s->pitch_nbits)
return 1;
skip_bits_long(gb, s->pitch_nbits);
}
if (frame_desc->fcb_type == FCB_TYPE_SILENCE) {
skip_bits(gb, 8);
} else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
int tmp = get_bits(gb, 6);
if (tmp >= 0x36) {
skip_bits(gb, 2);
aw_idx_is_ext = 1;
}
}
if (frame_desc->acb_type == ACB_TYPE_HAMMING) {
need_bits = s->block_pitch_nbits +
(frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits;
} else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
need_bits = 2 * !aw_idx_is_ext;
} else
need_bits = 0;
need_bits += frame_desc->frame_size;
if (get_bits_left(gb) < need_bits)
return 1;
skip_bits_long(gb, need_bits);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetBitContext *VAR_0,
WMAVoiceContext *VAR_1)
{
GetBitContext s_gb, *gb = &s_gb;
int VAR_2, VAR_3, VAR_4;
const struct frame_type_desc *VAR_5;
init_get_bits(gb, VAR_0->buffer, VAR_0->size_in_bits);
skip_bits_long(gb, get_bits_count(VAR_0));
av_assert1(get_bits_left(gb) == get_bits_left(VAR_0));
if (get_bits_left(gb) < 14)
return 1;
if (!get_bits1(gb))
return AVERROR(ENOSYS);
if (get_bits1(gb)) skip_bits(gb, 12);
if (VAR_1->has_residual_lsps) {
if (get_bits_left(gb) < VAR_1->sframe_lsp_bitsize)
return 1;
skip_bits_long(gb, VAR_1->sframe_lsp_bitsize);
}
for (VAR_2 = 0; VAR_2 < MAX_FRAMES; VAR_2++) {
int aw_idx_is_ext = 0;
if (!VAR_1->has_residual_lsps) {
if (get_bits_left(gb) < VAR_1->frame_lsp_bitsize) return 1;
skip_bits_long(gb, VAR_1->frame_lsp_bitsize);
}
VAR_4 = VAR_1->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
if (VAR_4 < 0)
return AVERROR_INVALIDDATA;
VAR_5 = &frame_descs[VAR_4];
if (VAR_5->acb_type == ACB_TYPE_ASYMMETRIC) {
if (get_bits_left(gb) < VAR_1->pitch_nbits)
return 1;
skip_bits_long(gb, VAR_1->pitch_nbits);
}
if (VAR_5->fcb_type == FCB_TYPE_SILENCE) {
skip_bits(gb, 8);
} else if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {
int tmp = get_bits(gb, 6);
if (tmp >= 0x36) {
skip_bits(gb, 2);
aw_idx_is_ext = 1;
}
}
if (VAR_5->acb_type == ACB_TYPE_HAMMING) {
VAR_3 = VAR_1->block_pitch_nbits +
(VAR_5->n_blocks - 1) * VAR_1->block_delta_pitch_nbits;
} else if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {
VAR_3 = 2 * !aw_idx_is_ext;
} else
VAR_3 = 0;
VAR_3 += VAR_5->frame_size;
if (get_bits_left(gb) < VAR_3)
return 1;
skip_bits_long(gb, VAR_3);
}
return 0;
}
| [
"static int FUNC_0(GetBitContext *VAR_0,\nWMAVoiceContext *VAR_1)\n{",
"GetBitContext s_gb, *gb = &s_gb;",
"int VAR_2, VAR_3, VAR_4;",
"const struct frame_type_desc *VAR_5;",
"init_get_bits(gb, VAR_0->buffer, VAR_0->size_in_bits);",
"skip_bits_long(gb, get_bits_count(VAR_0));",
"av_assert1(get_bits_left(gb) == get_bits_left(VAR_0));",
"if (get_bits_left(gb) < 14)\nreturn 1;",
"if (!get_bits1(gb))\nreturn AVERROR(ENOSYS);",
"if (get_bits1(gb)) skip_bits(gb, 12);",
"if (VAR_1->has_residual_lsps) {",
"if (get_bits_left(gb) < VAR_1->sframe_lsp_bitsize)\nreturn 1;",
"skip_bits_long(gb, VAR_1->sframe_lsp_bitsize);",
"}",
"for (VAR_2 = 0; VAR_2 < MAX_FRAMES; VAR_2++) {",
"int aw_idx_is_ext = 0;",
"if (!VAR_1->has_residual_lsps) {",
"if (get_bits_left(gb) < VAR_1->frame_lsp_bitsize) return 1;",
"skip_bits_long(gb, VAR_1->frame_lsp_bitsize);",
"}",
"VAR_4 = VAR_1->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];",
"if (VAR_4 < 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = &frame_descs[VAR_4];",
"if (VAR_5->acb_type == ACB_TYPE_ASYMMETRIC) {",
"if (get_bits_left(gb) < VAR_1->pitch_nbits)\nreturn 1;",
"skip_bits_long(gb, VAR_1->pitch_nbits);",
"}",
"if (VAR_5->fcb_type == FCB_TYPE_SILENCE) {",
"skip_bits(gb, 8);",
"} else if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {",
"int tmp = get_bits(gb, 6);",
"if (tmp >= 0x36) {",
"skip_bits(gb, 2);",
"aw_idx_is_ext = 1;",
"}",
"}",
"if (VAR_5->acb_type == ACB_TYPE_HAMMING) {",
"VAR_3 = VAR_1->block_pitch_nbits +\n(VAR_5->n_blocks - 1) * VAR_1->block_delta_pitch_nbits;",
"} else if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {",
"VAR_3 = 2 * !aw_idx_is_ext;",
"} else",
"VAR_3 = 0;",
"VAR_3 += VAR_5->frame_size;",
"if (get_bits_left(gb) < VAR_3)\nreturn 1;",
"skip_bits_long(gb, 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,
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
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
]
]
|
12,994 | static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale)
{
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
const int strength = ff_h263_loop_filter_strength[qscale];
__asm__ volatile (
H263_LOOP_FILTER
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %0 \n\t"
"movq %%mm6, %3 \n\t"
: "+m"(*(uint64_t*)(src - 2 * stride)),
"+m"(*(uint64_t*)(src - 1 * stride)),
"+m"(*(uint64_t*)(src + 0 * stride)),
"+m"(*(uint64_t*)(src + 1 * stride))
: "g"(2 * strength), "m"(ff_pb_FC)
);
}
}
| false | FFmpeg | 659d4ba5af5d72716ee370bb367c741bd15e75b4 | static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale)
{
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
const int strength = ff_h263_loop_filter_strength[qscale];
__asm__ volatile (
H263_LOOP_FILTER
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %0 \n\t"
"movq %%mm6, %3 \n\t"
: "+m"(*(uint64_t*)(src - 2 * stride)),
"+m"(*(uint64_t*)(src - 1 * stride)),
"+m"(*(uint64_t*)(src + 0 * stride)),
"+m"(*(uint64_t*)(src + 1 * stride))
: "g"(2 * strength), "m"(ff_pb_FC)
);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2)
{
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
const int VAR_3 = ff_h263_loop_filter_strength[VAR_2];
__asm__ volatile (
H263_LOOP_FILTER
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %0 \n\t"
"movq %%mm6, %3 \n\t"
: "+m"(*(uint64_t*)(VAR_0 - 2 * VAR_1)),
"+m"(*(uint64_t*)(VAR_0 - 1 * VAR_1)),
"+m"(*(uint64_t*)(VAR_0 + 0 * VAR_1)),
"+m"(*(uint64_t*)(VAR_0 + 1 * VAR_1))
: "g"(2 * VAR_3), "m"(ff_pb_FC)
);
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2)\n{",
"if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {",
"const int VAR_3 = ff_h263_loop_filter_strength[VAR_2];",
"__asm__ volatile (\nH263_LOOP_FILTER\n\"movq %%mm3, %1 \\n\\t\"\n\"movq %%mm4, %2 \\n\\t\"\n\"movq %%mm5, %0 \\n\\t\"\n\"movq %%mm6, %3 \\n\\t\"\n: \"+m\"(*(uint64_t*)(VAR_0 - 2 * VAR_1)),\n\"+m\"(*(uint64_t*)(VAR_0 - 1 * VAR_1)),\n\"+m\"(*(uint64_t*)(VAR_0 + 0 * VAR_1)),\n\"+m\"(*(uint64_t*)(VAR_0 + 1 * VAR_1))\n: \"g\"(2 * VAR_3), \"m\"(ff_pb_FC)\n);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35
],
[
37
],
[
39
]
]
|
12,995 | static int64_t *concat_channels_lists(const int64_t *layouts, const int *counts)
{
int nb_layouts = 0, nb_counts = 0, i;
int64_t *list;
if (layouts)
for (; layouts[nb_layouts] != -1; nb_layouts++);
if (counts)
for (; counts[nb_counts] != -1; nb_counts++);
if (nb_counts > INT_MAX - 1 - nb_layouts)
return NULL;
if (!(list = av_calloc(nb_layouts + nb_counts + 1, sizeof(*list))))
return NULL;
for (i = 0; i < nb_layouts; i++)
list[i] = layouts[i];
for (i = 0; i < nb_counts; i++)
list[nb_layouts + i] = FF_COUNT2LAYOUT(counts[i]);
list[nb_layouts + nb_counts] = -1;
return list;
}
| false | FFmpeg | e48ded8551172b58a78f30303a81dfce125344e0 | static int64_t *concat_channels_lists(const int64_t *layouts, const int *counts)
{
int nb_layouts = 0, nb_counts = 0, i;
int64_t *list;
if (layouts)
for (; layouts[nb_layouts] != -1; nb_layouts++);
if (counts)
for (; counts[nb_counts] != -1; nb_counts++);
if (nb_counts > INT_MAX - 1 - nb_layouts)
return NULL;
if (!(list = av_calloc(nb_layouts + nb_counts + 1, sizeof(*list))))
return NULL;
for (i = 0; i < nb_layouts; i++)
list[i] = layouts[i];
for (i = 0; i < nb_counts; i++)
list[nb_layouts + i] = FF_COUNT2LAYOUT(counts[i]);
list[nb_layouts + nb_counts] = -1;
return list;
}
| {
"code": [],
"line_no": []
} | static int64_t *FUNC_0(const int64_t *layouts, const int *counts)
{
int VAR_0 = 0, VAR_1 = 0, VAR_2;
int64_t *list;
if (layouts)
for (; layouts[VAR_0] != -1; VAR_0++);
if (counts)
for (; counts[VAR_1] != -1; VAR_1++);
if (VAR_1 > INT_MAX - 1 - VAR_0)
return NULL;
if (!(list = av_calloc(VAR_0 + VAR_1 + 1, sizeof(*list))))
return NULL;
for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++)
list[VAR_2] = layouts[VAR_2];
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)
list[VAR_0 + VAR_2] = FF_COUNT2LAYOUT(counts[VAR_2]);
list[VAR_0 + VAR_1] = -1;
return list;
}
| [
"static int64_t *FUNC_0(const int64_t *layouts, const int *counts)\n{",
"int VAR_0 = 0, VAR_1 = 0, VAR_2;",
"int64_t *list;",
"if (layouts)\nfor (; layouts[VAR_0] != -1; VAR_0++);",
"if (counts)\nfor (; counts[VAR_1] != -1; VAR_1++);",
"if (VAR_1 > INT_MAX - 1 - VAR_0)\nreturn NULL;",
"if (!(list = av_calloc(VAR_0 + VAR_1 + 1, sizeof(*list))))\nreturn NULL;",
"for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++)",
"list[VAR_2] = layouts[VAR_2];",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)",
"list[VAR_0 + VAR_2] = FF_COUNT2LAYOUT(counts[VAR_2]);",
"list[VAR_0 + VAR_1] = -1;",
"return list;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
]
|
12,996 | static void vnc_qmp_event(VncState *vs, QAPIEvent event)
{
VncServerInfo *si;
if (!vs->info) {
return;
}
g_assert(vs->info->base);
si = vnc_server_info_get(vs->vd);
if (!si) {
return;
}
switch (event) {
case QAPI_EVENT_VNC_CONNECTED:
qapi_event_send_vnc_connected(si, vs->info->base, &error_abort);
break;
case QAPI_EVENT_VNC_INITIALIZED:
qapi_event_send_vnc_initialized(si, vs->info, &error_abort);
break;
case QAPI_EVENT_VNC_DISCONNECTED:
qapi_event_send_vnc_disconnected(si, vs->info, &error_abort);
break;
default:
break;
}
qapi_free_VncServerInfo(si);
}
| false | qemu | ddf21908961073199f3d186204da4810f2ea150b | static void vnc_qmp_event(VncState *vs, QAPIEvent event)
{
VncServerInfo *si;
if (!vs->info) {
return;
}
g_assert(vs->info->base);
si = vnc_server_info_get(vs->vd);
if (!si) {
return;
}
switch (event) {
case QAPI_EVENT_VNC_CONNECTED:
qapi_event_send_vnc_connected(si, vs->info->base, &error_abort);
break;
case QAPI_EVENT_VNC_INITIALIZED:
qapi_event_send_vnc_initialized(si, vs->info, &error_abort);
break;
case QAPI_EVENT_VNC_DISCONNECTED:
qapi_event_send_vnc_disconnected(si, vs->info, &error_abort);
break;
default:
break;
}
qapi_free_VncServerInfo(si);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VncState *VAR_0, QAPIEvent VAR_1)
{
VncServerInfo *si;
if (!VAR_0->info) {
return;
}
g_assert(VAR_0->info->base);
si = vnc_server_info_get(VAR_0->vd);
if (!si) {
return;
}
switch (VAR_1) {
case QAPI_EVENT_VNC_CONNECTED:
qapi_event_send_vnc_connected(si, VAR_0->info->base, &error_abort);
break;
case QAPI_EVENT_VNC_INITIALIZED:
qapi_event_send_vnc_initialized(si, VAR_0->info, &error_abort);
break;
case QAPI_EVENT_VNC_DISCONNECTED:
qapi_event_send_vnc_disconnected(si, VAR_0->info, &error_abort);
break;
default:
break;
}
qapi_free_VncServerInfo(si);
}
| [
"static void FUNC_0(VncState *VAR_0, QAPIEvent VAR_1)\n{",
"VncServerInfo *si;",
"if (!VAR_0->info) {",
"return;",
"}",
"g_assert(VAR_0->info->base);",
"si = vnc_server_info_get(VAR_0->vd);",
"if (!si) {",
"return;",
"}",
"switch (VAR_1) {",
"case QAPI_EVENT_VNC_CONNECTED:\nqapi_event_send_vnc_connected(si, VAR_0->info->base, &error_abort);",
"break;",
"case QAPI_EVENT_VNC_INITIALIZED:\nqapi_event_send_vnc_initialized(si, VAR_0->info, &error_abort);",
"break;",
"case QAPI_EVENT_VNC_DISCONNECTED:\nqapi_event_send_vnc_disconnected(si, VAR_0->info, &error_abort);",
"break;",
"default:\nbreak;",
"}",
"qapi_free_VncServerInfo(si);",
"}"
]
| [
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
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
57
],
[
59
]
]
|
12,997 | void dump_exec_info(FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i, target_code_size, max_target_code_size;
int direct_jmp_count, direct_jmp2_count, cross_page;
TranslationBlock *tb;
target_code_size = 0;
max_target_code_size = 0;
cross_page = 0;
direct_jmp_count = 0;
direct_jmp2_count = 0;
for(i = 0; i < nb_tbs; i++) {
tb = &tbs[i];
target_code_size += tb->size;
if (tb->size > max_target_code_size)
max_target_code_size = tb->size;
if (tb->page_addr[1] != -1)
cross_page++;
if (tb->tb_next_offset[0] != 0xffff) {
direct_jmp_count++;
if (tb->tb_next_offset[1] != 0xffff) {
direct_jmp2_count++;
}
}
}
/* XXX: avoid using doubles ? */
cpu_fprintf(f, "Translation buffer state:\n");
cpu_fprintf(f, "gen code size %ld/%ld\n",
code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);
cpu_fprintf(f, "TB count %d/%d\n",
nb_tbs, code_gen_max_blocks);
cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
nb_tbs ? target_code_size / nb_tbs : 0,
max_target_code_size);
cpu_fprintf(f, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
target_code_size ? (double) (code_gen_ptr - code_gen_buffer) / target_code_size : 0);
cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
cross_page,
nb_tbs ? (cross_page * 100) / nb_tbs : 0);
cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
direct_jmp_count,
nb_tbs ? (direct_jmp_count * 100) / nb_tbs : 0,
direct_jmp2_count,
nb_tbs ? (direct_jmp2_count * 100) / nb_tbs : 0);
cpu_fprintf(f, "\nStatistics:\n");
cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);
cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count);
tcg_dump_info(f, cpu_fprintf);
}
| false | qemu | 055403b2a72729497fb58e0c6293547e767679d3 | void dump_exec_info(FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i, target_code_size, max_target_code_size;
int direct_jmp_count, direct_jmp2_count, cross_page;
TranslationBlock *tb;
target_code_size = 0;
max_target_code_size = 0;
cross_page = 0;
direct_jmp_count = 0;
direct_jmp2_count = 0;
for(i = 0; i < nb_tbs; i++) {
tb = &tbs[i];
target_code_size += tb->size;
if (tb->size > max_target_code_size)
max_target_code_size = tb->size;
if (tb->page_addr[1] != -1)
cross_page++;
if (tb->tb_next_offset[0] != 0xffff) {
direct_jmp_count++;
if (tb->tb_next_offset[1] != 0xffff) {
direct_jmp2_count++;
}
}
}
cpu_fprintf(f, "Translation buffer state:\n");
cpu_fprintf(f, "gen code size %ld/%ld\n",
code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);
cpu_fprintf(f, "TB count %d/%d\n",
nb_tbs, code_gen_max_blocks);
cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
nb_tbs ? target_code_size / nb_tbs : 0,
max_target_code_size);
cpu_fprintf(f, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
target_code_size ? (double) (code_gen_ptr - code_gen_buffer) / target_code_size : 0);
cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
cross_page,
nb_tbs ? (cross_page * 100) / nb_tbs : 0);
cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
direct_jmp_count,
nb_tbs ? (direct_jmp_count * 100) / nb_tbs : 0,
direct_jmp2_count,
nb_tbs ? (direct_jmp2_count * 100) / nb_tbs : 0);
cpu_fprintf(f, "\nStatistics:\n");
cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);
cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count);
tcg_dump_info(f, cpu_fprintf);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(FILE *VAR_2,
int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))
{
int VAR_3, VAR_4, VAR_5;
int VAR_6, VAR_7, VAR_8;
TranslationBlock *tb;
VAR_4 = 0;
VAR_5 = 0;
VAR_8 = 0;
VAR_6 = 0;
VAR_7 = 0;
for(VAR_3 = 0; VAR_3 < nb_tbs; VAR_3++) {
tb = &tbs[VAR_3];
VAR_4 += tb->size;
if (tb->size > VAR_5)
VAR_5 = tb->size;
if (tb->page_addr[1] != -1)
VAR_8++;
if (tb->tb_next_offset[0] != 0xffff) {
VAR_6++;
if (tb->tb_next_offset[1] != 0xffff) {
VAR_7++;
}
}
}
VAR_1(VAR_2, "Translation buffer state:\n");
VAR_1(VAR_2, "gen code size %ld/%ld\n",
code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);
VAR_1(VAR_2, "TB count %d/%d\n",
nb_tbs, code_gen_max_blocks);
VAR_1(VAR_2, "TB avg target size %d max=%d bytes\n",
nb_tbs ? VAR_4 / nb_tbs : 0,
VAR_5);
VAR_1(VAR_2, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
VAR_4 ? (double) (code_gen_ptr - code_gen_buffer) / VAR_4 : 0);
VAR_1(VAR_2, "cross page TB count %d (%d%%)\n",
VAR_8,
nb_tbs ? (VAR_8 * 100) / nb_tbs : 0);
VAR_1(VAR_2, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
VAR_6,
nb_tbs ? (VAR_6 * 100) / nb_tbs : 0,
VAR_7,
nb_tbs ? (VAR_7 * 100) / nb_tbs : 0);
VAR_1(VAR_2, "\nStatistics:\n");
VAR_1(VAR_2, "TB flush count %d\n", tb_flush_count);
VAR_1(VAR_2, "TB invalidate count %d\n", tb_phys_invalidate_count);
VAR_1(VAR_2, "TLB flush count %d\n", tlb_flush_count);
tcg_dump_info(VAR_2, VAR_1);
}
| [
"void FUNC_0(FILE *VAR_2,\nint (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{",
"int VAR_3, VAR_4, VAR_5;",
"int VAR_6, VAR_7, VAR_8;",
"TranslationBlock *tb;",
"VAR_4 = 0;",
"VAR_5 = 0;",
"VAR_8 = 0;",
"VAR_6 = 0;",
"VAR_7 = 0;",
"for(VAR_3 = 0; VAR_3 < nb_tbs; VAR_3++) {",
"tb = &tbs[VAR_3];",
"VAR_4 += tb->size;",
"if (tb->size > VAR_5)\nVAR_5 = tb->size;",
"if (tb->page_addr[1] != -1)\nVAR_8++;",
"if (tb->tb_next_offset[0] != 0xffff) {",
"VAR_6++;",
"if (tb->tb_next_offset[1] != 0xffff) {",
"VAR_7++;",
"}",
"}",
"}",
"VAR_1(VAR_2, \"Translation buffer state:\\n\");",
"VAR_1(VAR_2, \"gen code size %ld/%ld\\n\",\ncode_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);",
"VAR_1(VAR_2, \"TB count %d/%d\\n\",\nnb_tbs, code_gen_max_blocks);",
"VAR_1(VAR_2, \"TB avg target size %d max=%d bytes\\n\",\nnb_tbs ? VAR_4 / nb_tbs : 0,\nVAR_5);",
"VAR_1(VAR_2, \"TB avg host size %d bytes (expansion ratio: %0.1f)\\n\",\nnb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,\nVAR_4 ? (double) (code_gen_ptr - code_gen_buffer) / VAR_4 : 0);",
"VAR_1(VAR_2, \"cross page TB count %d (%d%%)\\n\",\nVAR_8,\nnb_tbs ? (VAR_8 * 100) / nb_tbs : 0);",
"VAR_1(VAR_2, \"direct jump count %d (%d%%) (2 jumps=%d %d%%)\\n\",\nVAR_6,\nnb_tbs ? (VAR_6 * 100) / nb_tbs : 0,\nVAR_7,\nnb_tbs ? (VAR_7 * 100) / nb_tbs : 0);",
"VAR_1(VAR_2, \"\\nStatistics:\\n\");",
"VAR_1(VAR_2, \"TB flush count %d\\n\", tb_flush_count);",
"VAR_1(VAR_2, \"TB invalidate count %d\\n\", tb_phys_invalidate_count);",
"VAR_1(VAR_2, \"TLB flush count %d\\n\", tlb_flush_count);",
"tcg_dump_info(VAR_2, VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65,
67,
69
],
[
71,
73,
75
],
[
77,
79,
81
],
[
83,
85,
87,
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
]
]
|
12,998 | static void ac3_downmix(AC3DecodeContext *s)
{
int i, j;
float v0, v1;
for(i=0; i<256; i++) {
v0 = v1 = 0.0f;
for(j=0; j<s->fbw_channels; j++) {
v0 += s->output[j][i] * s->downmix_coeffs[j][0];
v1 += s->output[j][i] * s->downmix_coeffs[j][1];
}
v0 /= s->downmix_coeff_sum[0];
v1 /= s->downmix_coeff_sum[1];
if(s->output_mode == AC3_CHMODE_MONO) {
s->output[0][i] = (v0 + v1) * LEVEL_MINUS_3DB;
} else if(s->output_mode == AC3_CHMODE_STEREO) {
s->output[0][i] = v0;
s->output[1][i] = v1;
}
}
}
| false | FFmpeg | d8870f120ea5f46940bac63a90424ca6a6000ad9 | static void ac3_downmix(AC3DecodeContext *s)
{
int i, j;
float v0, v1;
for(i=0; i<256; i++) {
v0 = v1 = 0.0f;
for(j=0; j<s->fbw_channels; j++) {
v0 += s->output[j][i] * s->downmix_coeffs[j][0];
v1 += s->output[j][i] * s->downmix_coeffs[j][1];
}
v0 /= s->downmix_coeff_sum[0];
v1 /= s->downmix_coeff_sum[1];
if(s->output_mode == AC3_CHMODE_MONO) {
s->output[0][i] = (v0 + v1) * LEVEL_MINUS_3DB;
} else if(s->output_mode == AC3_CHMODE_STEREO) {
s->output[0][i] = v0;
s->output[1][i] = v1;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3DecodeContext *VAR_0)
{
int VAR_1, VAR_2;
float VAR_3, VAR_4;
for(VAR_1=0; VAR_1<256; VAR_1++) {
VAR_3 = VAR_4 = 0.0f;
for(VAR_2=0; VAR_2<VAR_0->fbw_channels; VAR_2++) {
VAR_3 += VAR_0->output[VAR_2][VAR_1] * VAR_0->downmix_coeffs[VAR_2][0];
VAR_4 += VAR_0->output[VAR_2][VAR_1] * VAR_0->downmix_coeffs[VAR_2][1];
}
VAR_3 /= VAR_0->downmix_coeff_sum[0];
VAR_4 /= VAR_0->downmix_coeff_sum[1];
if(VAR_0->output_mode == AC3_CHMODE_MONO) {
VAR_0->output[0][VAR_1] = (VAR_3 + VAR_4) * LEVEL_MINUS_3DB;
} else if(VAR_0->output_mode == AC3_CHMODE_STEREO) {
VAR_0->output[0][VAR_1] = VAR_3;
VAR_0->output[1][VAR_1] = VAR_4;
}
}
}
| [
"static void FUNC_0(AC3DecodeContext *VAR_0)\n{",
"int VAR_1, VAR_2;",
"float VAR_3, VAR_4;",
"for(VAR_1=0; VAR_1<256; VAR_1++) {",
"VAR_3 = VAR_4 = 0.0f;",
"for(VAR_2=0; VAR_2<VAR_0->fbw_channels; VAR_2++) {",
"VAR_3 += VAR_0->output[VAR_2][VAR_1] * VAR_0->downmix_coeffs[VAR_2][0];",
"VAR_4 += VAR_0->output[VAR_2][VAR_1] * VAR_0->downmix_coeffs[VAR_2][1];",
"}",
"VAR_3 /= VAR_0->downmix_coeff_sum[0];",
"VAR_4 /= VAR_0->downmix_coeff_sum[1];",
"if(VAR_0->output_mode == AC3_CHMODE_MONO) {",
"VAR_0->output[0][VAR_1] = (VAR_3 + VAR_4) * LEVEL_MINUS_3DB;",
"} else if(VAR_0->output_mode == AC3_CHMODE_STEREO) {",
"VAR_0->output[0][VAR_1] = VAR_3;",
"VAR_0->output[1][VAR_1] = VAR_4;",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
]
|
13,000 | static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
int i;
virtio_net_set_multiqueue(n,
__virtio_has_feature(features, VIRTIO_NET_F_MQ));
virtio_net_set_mrg_rx_bufs(n,
__virtio_has_feature(features,
VIRTIO_NET_F_MRG_RXBUF),
__virtio_has_feature(features,
VIRTIO_F_VERSION_1));
if (n->has_vnet_hdr) {
n->curr_guest_offloads =
virtio_net_guest_offloads_by_features(features);
virtio_net_apply_guest_offloads(n);
}
for (i = 0; i < n->max_queues; i++) {
NetClientState *nc = qemu_get_subqueue(n->nic, i);
if (!get_vhost_net(nc->peer)) {
continue;
}
vhost_net_ack_features(get_vhost_net(nc->peer), features);
}
if (__virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) {
memset(n->vlans, 0, MAX_VLAN >> 3);
} else {
memset(n->vlans, 0xff, MAX_VLAN >> 3);
}
}
| false | qemu | 95129d6fc9ead97155627a4ca0cfd37282883658 | static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
int i;
virtio_net_set_multiqueue(n,
__virtio_has_feature(features, VIRTIO_NET_F_MQ));
virtio_net_set_mrg_rx_bufs(n,
__virtio_has_feature(features,
VIRTIO_NET_F_MRG_RXBUF),
__virtio_has_feature(features,
VIRTIO_F_VERSION_1));
if (n->has_vnet_hdr) {
n->curr_guest_offloads =
virtio_net_guest_offloads_by_features(features);
virtio_net_apply_guest_offloads(n);
}
for (i = 0; i < n->max_queues; i++) {
NetClientState *nc = qemu_get_subqueue(n->nic, i);
if (!get_vhost_net(nc->peer)) {
continue;
}
vhost_net_ack_features(get_vhost_net(nc->peer), features);
}
if (__virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) {
memset(n->vlans, 0, MAX_VLAN >> 3);
} else {
memset(n->vlans, 0xff, MAX_VLAN >> 3);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIODevice *VAR_0, uint64_t VAR_1)
{
VirtIONet *n = VIRTIO_NET(VAR_0);
int VAR_2;
virtio_net_set_multiqueue(n,
__virtio_has_feature(VAR_1, VIRTIO_NET_F_MQ));
virtio_net_set_mrg_rx_bufs(n,
__virtio_has_feature(VAR_1,
VIRTIO_NET_F_MRG_RXBUF),
__virtio_has_feature(VAR_1,
VIRTIO_F_VERSION_1));
if (n->has_vnet_hdr) {
n->curr_guest_offloads =
virtio_net_guest_offloads_by_features(VAR_1);
virtio_net_apply_guest_offloads(n);
}
for (VAR_2 = 0; VAR_2 < n->max_queues; VAR_2++) {
NetClientState *nc = qemu_get_subqueue(n->nic, VAR_2);
if (!get_vhost_net(nc->peer)) {
continue;
}
vhost_net_ack_features(get_vhost_net(nc->peer), VAR_1);
}
if (__virtio_has_feature(VAR_1, VIRTIO_NET_F_CTRL_VLAN)) {
memset(n->vlans, 0, MAX_VLAN >> 3);
} else {
memset(n->vlans, 0xff, MAX_VLAN >> 3);
}
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, uint64_t VAR_1)\n{",
"VirtIONet *n = VIRTIO_NET(VAR_0);",
"int VAR_2;",
"virtio_net_set_multiqueue(n,\n__virtio_has_feature(VAR_1, VIRTIO_NET_F_MQ));",
"virtio_net_set_mrg_rx_bufs(n,\n__virtio_has_feature(VAR_1,\nVIRTIO_NET_F_MRG_RXBUF),\n__virtio_has_feature(VAR_1,\nVIRTIO_F_VERSION_1));",
"if (n->has_vnet_hdr) {",
"n->curr_guest_offloads =\nvirtio_net_guest_offloads_by_features(VAR_1);",
"virtio_net_apply_guest_offloads(n);",
"}",
"for (VAR_2 = 0; VAR_2 < n->max_queues; VAR_2++) {",
"NetClientState *nc = qemu_get_subqueue(n->nic, VAR_2);",
"if (!get_vhost_net(nc->peer)) {",
"continue;",
"}",
"vhost_net_ack_features(get_vhost_net(nc->peer), VAR_1);",
"}",
"if (__virtio_has_feature(VAR_1, VIRTIO_NET_F_CTRL_VLAN)) {",
"memset(n->vlans, 0, MAX_VLAN >> 3);",
"} else {",
"memset(n->vlans, 0xff, MAX_VLAN >> 3);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17,
19,
21,
23,
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
]
|
13,003 | int postcopy_ram_enable_notify(MigrationIncomingState *mis)
{
/* Open the fd for the kernel to give us userfaults */
mis->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
if (mis->userfault_fd == -1) {
error_report("%s: Failed to open userfault fd: %s", __func__,
strerror(errno));
return -1;
}
/*
* Although the host check already tested the API, we need to
* do the check again as an ABI handshake on the new fd.
*/
if (!ufd_version_check(mis->userfault_fd)) {
return -1;
}
/* Now an eventfd we use to tell the fault-thread to quit */
mis->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);
if (mis->userfault_quit_fd == -1) {
error_report("%s: Opening userfault_quit_fd: %s", __func__,
strerror(errno));
close(mis->userfault_fd);
return -1;
}
qemu_sem_init(&mis->fault_thread_sem, 0);
qemu_thread_create(&mis->fault_thread, "postcopy/fault",
postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABLE);
qemu_sem_wait(&mis->fault_thread_sem);
qemu_sem_destroy(&mis->fault_thread_sem);
mis->have_fault_thread = true;
/* Mark so that we get notified of accesses to unwritten areas */
if (qemu_ram_foreach_block(ram_block_enable_notify, mis)) {
return -1;
}
/*
* Ballooning can mark pages as absent while we're postcopying
* that would cause false userfaults.
*/
qemu_balloon_inhibit(true);
trace_postcopy_ram_enable_notify();
return 0;
}
| false | qemu | d7651f150d61936344c4fab45eaeb0716c606af2 | int postcopy_ram_enable_notify(MigrationIncomingState *mis)
{
mis->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
if (mis->userfault_fd == -1) {
error_report("%s: Failed to open userfault fd: %s", __func__,
strerror(errno));
return -1;
}
if (!ufd_version_check(mis->userfault_fd)) {
return -1;
}
mis->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);
if (mis->userfault_quit_fd == -1) {
error_report("%s: Opening userfault_quit_fd: %s", __func__,
strerror(errno));
close(mis->userfault_fd);
return -1;
}
qemu_sem_init(&mis->fault_thread_sem, 0);
qemu_thread_create(&mis->fault_thread, "postcopy/fault",
postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABLE);
qemu_sem_wait(&mis->fault_thread_sem);
qemu_sem_destroy(&mis->fault_thread_sem);
mis->have_fault_thread = true;
if (qemu_ram_foreach_block(ram_block_enable_notify, mis)) {
return -1;
}
qemu_balloon_inhibit(true);
trace_postcopy_ram_enable_notify();
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MigrationIncomingState *VAR_0)
{
VAR_0->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
if (VAR_0->userfault_fd == -1) {
error_report("%s: Failed to open userfault fd: %s", __func__,
strerror(errno));
return -1;
}
if (!ufd_version_check(VAR_0->userfault_fd)) {
return -1;
}
VAR_0->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);
if (VAR_0->userfault_quit_fd == -1) {
error_report("%s: Opening userfault_quit_fd: %s", __func__,
strerror(errno));
close(VAR_0->userfault_fd);
return -1;
}
qemu_sem_init(&VAR_0->fault_thread_sem, 0);
qemu_thread_create(&VAR_0->fault_thread, "postcopy/fault",
postcopy_ram_fault_thread, VAR_0, QEMU_THREAD_JOINABLE);
qemu_sem_wait(&VAR_0->fault_thread_sem);
qemu_sem_destroy(&VAR_0->fault_thread_sem);
VAR_0->have_fault_thread = true;
if (qemu_ram_foreach_block(ram_block_enable_notify, VAR_0)) {
return -1;
}
qemu_balloon_inhibit(true);
trace_postcopy_ram_enable_notify();
return 0;
}
| [
"int FUNC_0(MigrationIncomingState *VAR_0)\n{",
"VAR_0->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);",
"if (VAR_0->userfault_fd == -1) {",
"error_report(\"%s: Failed to open userfault fd: %s\", __func__,\nstrerror(errno));",
"return -1;",
"}",
"if (!ufd_version_check(VAR_0->userfault_fd)) {",
"return -1;",
"}",
"VAR_0->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);",
"if (VAR_0->userfault_quit_fd == -1) {",
"error_report(\"%s: Opening userfault_quit_fd: %s\", __func__,\nstrerror(errno));",
"close(VAR_0->userfault_fd);",
"return -1;",
"}",
"qemu_sem_init(&VAR_0->fault_thread_sem, 0);",
"qemu_thread_create(&VAR_0->fault_thread, \"postcopy/fault\",\npostcopy_ram_fault_thread, VAR_0, QEMU_THREAD_JOINABLE);",
"qemu_sem_wait(&VAR_0->fault_thread_sem);",
"qemu_sem_destroy(&VAR_0->fault_thread_sem);",
"VAR_0->have_fault_thread = true;",
"if (qemu_ram_foreach_block(ram_block_enable_notify, VAR_0)) {",
"return -1;",
"}",
"qemu_balloon_inhibit(true);",
"trace_postcopy_ram_enable_notify();",
"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,
3
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73
],
[
75
],
[
87
],
[
91
],
[
95
],
[
97
]
]
|
13,004 | void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
SocketAddress *addr,
QIOTaskFunc func,
gpointer opaque,
GDestroyNotify notify)
{
QIOTask *task;
struct QIODNSResolverLookupData *data =
g_new0(struct QIODNSResolverLookupData, 1);
data->addr = QAPI_CLONE(SocketAddress, addr);
task = qio_task_new(OBJECT(resolver), func, opaque, notify);
qio_task_run_in_thread(task,
qio_dns_resolver_lookup_worker,
data,
qio_dns_resolver_lookup_data_free);
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
SocketAddress *addr,
QIOTaskFunc func,
gpointer opaque,
GDestroyNotify notify)
{
QIOTask *task;
struct QIODNSResolverLookupData *data =
g_new0(struct QIODNSResolverLookupData, 1);
data->addr = QAPI_CLONE(SocketAddress, addr);
task = qio_task_new(OBJECT(resolver), func, opaque, notify);
qio_task_run_in_thread(task,
qio_dns_resolver_lookup_worker,
data,
qio_dns_resolver_lookup_data_free);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QIODNSResolver *VAR_0,
SocketAddress *VAR_1,
QIOTaskFunc VAR_2,
gpointer VAR_3,
GDestroyNotify VAR_4)
{
QIOTask *task;
struct QIODNSResolverLookupData *VAR_5 =
g_new0(struct QIODNSResolverLookupData, 1);
VAR_5->VAR_1 = QAPI_CLONE(SocketAddress, VAR_1);
task = qio_task_new(OBJECT(VAR_0), VAR_2, VAR_3, VAR_4);
qio_task_run_in_thread(task,
qio_dns_resolver_lookup_worker,
VAR_5,
qio_dns_resolver_lookup_data_free);
}
| [
"void FUNC_0(QIODNSResolver *VAR_0,\nSocketAddress *VAR_1,\nQIOTaskFunc VAR_2,\ngpointer VAR_3,\nGDestroyNotify VAR_4)\n{",
"QIOTask *task;",
"struct QIODNSResolverLookupData *VAR_5 =\ng_new0(struct QIODNSResolverLookupData, 1);",
"VAR_5->VAR_1 = QAPI_CLONE(SocketAddress, VAR_1);",
"task = qio_task_new(OBJECT(VAR_0), VAR_2, VAR_3, VAR_4);",
"qio_task_run_in_thread(task,\nqio_dns_resolver_lookup_worker,\nVAR_5,\nqio_dns_resolver_lookup_data_free);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15,
17
],
[
21
],
[
25
],
[
29,
31,
33,
35
],
[
37
]
]
|
13,005 | static void vhost_iommu_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
iommu_listener);
struct vhost_iommu *iommu;
if (!memory_region_is_iommu(section->mr)) {
return;
}
iommu = g_malloc0(sizeof(*iommu));
iommu->n.notify = vhost_iommu_unmap_notify;
iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;
iommu->mr = section->mr;
iommu->iommu_offset = section->offset_within_address_space -
section->offset_within_region;
iommu->hdev = dev;
memory_region_register_iommu_notifier(section->mr, &iommu->n);
QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
/* TODO: can replay help performance here? */
}
| false | qemu | 698feb5e13a2d763369909ce33f2bd7a7c1c11c0 | static void vhost_iommu_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
iommu_listener);
struct vhost_iommu *iommu;
if (!memory_region_is_iommu(section->mr)) {
return;
}
iommu = g_malloc0(sizeof(*iommu));
iommu->n.notify = vhost_iommu_unmap_notify;
iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;
iommu->mr = section->mr;
iommu->iommu_offset = section->offset_within_address_space -
section->offset_within_region;
iommu->hdev = dev;
memory_region_register_iommu_notifier(section->mr, &iommu->n);
QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MemoryListener *VAR_0,
MemoryRegionSection *VAR_1)
{
struct vhost_dev *VAR_2 = container_of(VAR_0, struct vhost_dev,
iommu_listener);
struct vhost_iommu *VAR_3;
if (!memory_region_is_iommu(VAR_1->mr)) {
return;
}
VAR_3 = g_malloc0(sizeof(*VAR_3));
VAR_3->n.notify = vhost_iommu_unmap_notify;
VAR_3->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;
VAR_3->mr = VAR_1->mr;
VAR_3->iommu_offset = VAR_1->offset_within_address_space -
VAR_1->offset_within_region;
VAR_3->hdev = VAR_2;
memory_region_register_iommu_notifier(VAR_1->mr, &VAR_3->n);
QLIST_INSERT_HEAD(&VAR_2->iommu_list, VAR_3, iommu_next);
}
| [
"static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1)\n{",
"struct vhost_dev *VAR_2 = container_of(VAR_0, struct vhost_dev,\niommu_listener);",
"struct vhost_iommu *VAR_3;",
"if (!memory_region_is_iommu(VAR_1->mr)) {",
"return;",
"}",
"VAR_3 = g_malloc0(sizeof(*VAR_3));",
"VAR_3->n.notify = vhost_iommu_unmap_notify;",
"VAR_3->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;",
"VAR_3->mr = VAR_1->mr;",
"VAR_3->iommu_offset = VAR_1->offset_within_address_space -\nVAR_1->offset_within_region;",
"VAR_3->hdev = VAR_2;",
"memory_region_register_iommu_notifier(VAR_1->mr, &VAR_3->n);",
"QLIST_INSERT_HEAD(&VAR_2->iommu_list, VAR_3, iommu_next);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
]
]
|
13,006 | static void arm_timer_write(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
arm_timer_state *s = (arm_timer_state *)opaque;
int freq;
switch (offset >> 2) {
case 0: /* TimerLoad */
s->limit = value;
arm_timer_recalibrate(s, 1);
break;
case 1: /* TimerValue */
/* ??? Linux seems to want to write to this readonly register.
Ignore it. */
break;
case 2: /* TimerControl */
if (s->control & TIMER_CTRL_ENABLE) {
/* Pause the timer if it is running. This may cause some
inaccuracy dure to rounding, but avoids a whole lot of other
messyness. */
ptimer_stop(s->timer);
}
s->control = value;
freq = s->freq;
/* ??? Need to recalculate expiry time after changing divisor. */
switch ((value >> 2) & 3) {
case 1: freq >>= 4; break;
case 2: freq >>= 8; break;
}
arm_timer_recalibrate(s, 0);
ptimer_set_freq(s->timer, freq);
if (s->control & TIMER_CTRL_ENABLE) {
/* Restart the timer if still enabled. */
ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0);
}
break;
case 3: /* TimerIntClr */
s->int_level = 0;
break;
case 6: /* TimerBGLoad */
s->limit = value;
arm_timer_recalibrate(s, 0);
break;
default:
hw_error("arm_timer_write: Bad offset %x\n", (int)offset);
}
arm_timer_update(s);
}
| false | qemu | d6759902cb467c002086853d2eb38fb969c29f7f | static void arm_timer_write(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
arm_timer_state *s = (arm_timer_state *)opaque;
int freq;
switch (offset >> 2) {
case 0:
s->limit = value;
arm_timer_recalibrate(s, 1);
break;
case 1:
break;
case 2:
if (s->control & TIMER_CTRL_ENABLE) {
ptimer_stop(s->timer);
}
s->control = value;
freq = s->freq;
switch ((value >> 2) & 3) {
case 1: freq >>= 4; break;
case 2: freq >>= 8; break;
}
arm_timer_recalibrate(s, 0);
ptimer_set_freq(s->timer, freq);
if (s->control & TIMER_CTRL_ENABLE) {
ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0);
}
break;
case 3:
s->int_level = 0;
break;
case 6:
s->limit = value;
arm_timer_recalibrate(s, 0);
break;
default:
hw_error("arm_timer_write: Bad offset %x\n", (int)offset);
}
arm_timer_update(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{
arm_timer_state *s = (arm_timer_state *)VAR_0;
int VAR_3;
switch (VAR_1 >> 2) {
case 0:
s->limit = VAR_2;
arm_timer_recalibrate(s, 1);
break;
case 1:
break;
case 2:
if (s->control & TIMER_CTRL_ENABLE) {
ptimer_stop(s->timer);
}
s->control = VAR_2;
VAR_3 = s->VAR_3;
switch ((VAR_2 >> 2) & 3) {
case 1: VAR_3 >>= 4; break;
case 2: VAR_3 >>= 8; break;
}
arm_timer_recalibrate(s, 0);
ptimer_set_freq(s->timer, VAR_3);
if (s->control & TIMER_CTRL_ENABLE) {
ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0);
}
break;
case 3:
s->int_level = 0;
break;
case 6:
s->limit = VAR_2;
arm_timer_recalibrate(s, 0);
break;
default:
hw_error("FUNC_0: Bad VAR_1 %x\n", (int)VAR_1);
}
arm_timer_update(s);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{",
"arm_timer_state *s = (arm_timer_state *)VAR_0;",
"int VAR_3;",
"switch (VAR_1 >> 2) {",
"case 0:\ns->limit = VAR_2;",
"arm_timer_recalibrate(s, 1);",
"break;",
"case 1:\nbreak;",
"case 2:\nif (s->control & TIMER_CTRL_ENABLE) {",
"ptimer_stop(s->timer);",
"}",
"s->control = VAR_2;",
"VAR_3 = s->VAR_3;",
"switch ((VAR_2 >> 2) & 3) {",
"case 1: VAR_3 >>= 4; break;",
"case 2: VAR_3 >>= 8; break;",
"}",
"arm_timer_recalibrate(s, 0);",
"ptimer_set_freq(s->timer, VAR_3);",
"if (s->control & TIMER_CTRL_ENABLE) {",
"ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0);",
"}",
"break;",
"case 3:\ns->int_level = 0;",
"break;",
"case 6:\ns->limit = VAR_2;",
"arm_timer_recalibrate(s, 0);",
"break;",
"default:\nhw_error(\"FUNC_0: Bad VAR_1 %x\\n\", (int)VAR_1);",
"}",
"arm_timer_update(s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
29
],
[
31,
33
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
]
]
|
13,007 | static void qed_plug_allocating_write_reqs(BDRVQEDState *s)
{
assert(!s->allocating_write_reqs_plugged);
s->allocating_write_reqs_plugged = true;
}
| false | qemu | 1f01e50b8330c24714ddca5841fdbb703076b121 | static void qed_plug_allocating_write_reqs(BDRVQEDState *s)
{
assert(!s->allocating_write_reqs_plugged);
s->allocating_write_reqs_plugged = true;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BDRVQEDState *VAR_0)
{
assert(!VAR_0->allocating_write_reqs_plugged);
VAR_0->allocating_write_reqs_plugged = true;
}
| [
"static void FUNC_0(BDRVQEDState *VAR_0)\n{",
"assert(!VAR_0->allocating_write_reqs_plugged);",
"VAR_0->allocating_write_reqs_plugged = true;",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
]
]
|
13,008 | static inline void t_gen_swapr(TCGv d, TCGv s)
{
struct {
int shift; /* LSL when positive, LSR when negative. */
uint32_t mask;
} bitrev [] = {
{7, 0x80808080},
{5, 0x40404040},
{3, 0x20202020},
{1, 0x10101010},
{-1, 0x08080808},
{-3, 0x04040404},
{-5, 0x02020202},
{-7, 0x01010101}
};
int i;
TCGv t, org_s;
/* d and s refer the same object. */
t = tcg_temp_new(TCG_TYPE_TL);
org_s = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_mov_tl(org_s, s);
tcg_gen_shli_tl(t, org_s, bitrev[0].shift);
tcg_gen_andi_tl(d, t, bitrev[0].mask);
for (i = 1; i < sizeof bitrev / sizeof bitrev[0]; i++) {
if (bitrev[i].shift >= 0) {
tcg_gen_shli_tl(t, org_s, bitrev[i].shift);
} else {
tcg_gen_shri_tl(t, org_s, -bitrev[i].shift);
}
tcg_gen_andi_tl(t, t, bitrev[i].mask);
tcg_gen_or_tl(d, d, t);
}
tcg_temp_free(t);
tcg_temp_free(org_s);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static inline void t_gen_swapr(TCGv d, TCGv s)
{
struct {
int shift;
uint32_t mask;
} bitrev [] = {
{7, 0x80808080},
{5, 0x40404040},
{3, 0x20202020},
{1, 0x10101010},
{-1, 0x08080808},
{-3, 0x04040404},
{-5, 0x02020202},
{-7, 0x01010101}
};
int i;
TCGv t, org_s;
t = tcg_temp_new(TCG_TYPE_TL);
org_s = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_mov_tl(org_s, s);
tcg_gen_shli_tl(t, org_s, bitrev[0].shift);
tcg_gen_andi_tl(d, t, bitrev[0].mask);
for (i = 1; i < sizeof bitrev / sizeof bitrev[0]; i++) {
if (bitrev[i].shift >= 0) {
tcg_gen_shli_tl(t, org_s, bitrev[i].shift);
} else {
tcg_gen_shri_tl(t, org_s, -bitrev[i].shift);
}
tcg_gen_andi_tl(t, t, bitrev[i].mask);
tcg_gen_or_tl(d, d, t);
}
tcg_temp_free(t);
tcg_temp_free(org_s);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1)
{
struct {
int shift;
uint32_t mask;
} VAR_2 [] = {
{7, 0x80808080},
{5, 0x40404040},
{3, 0x20202020},
{1, 0x10101010},
{-1, 0x08080808},
{-3, 0x04040404},
{-5, 0x02020202},
{-7, 0x01010101}
};
int VAR_3;
TCGv t, org_s;
t = tcg_temp_new(TCG_TYPE_TL);
org_s = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_mov_tl(org_s, VAR_1);
tcg_gen_shli_tl(t, org_s, VAR_2[0].shift);
tcg_gen_andi_tl(VAR_0, t, VAR_2[0].mask);
for (VAR_3 = 1; VAR_3 < sizeof VAR_2 / sizeof VAR_2[0]; VAR_3++) {
if (VAR_2[VAR_3].shift >= 0) {
tcg_gen_shli_tl(t, org_s, VAR_2[VAR_3].shift);
} else {
tcg_gen_shri_tl(t, org_s, -VAR_2[VAR_3].shift);
}
tcg_gen_andi_tl(t, t, VAR_2[VAR_3].mask);
tcg_gen_or_tl(VAR_0, VAR_0, t);
}
tcg_temp_free(t);
tcg_temp_free(org_s);
}
| [
"static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1)\n{",
"struct {",
"int shift;",
"uint32_t mask;",
"} VAR_2 [] = {",
"{7, 0x80808080},",
"{5, 0x40404040},",
"{3, 0x20202020},",
"{1, 0x10101010},",
"{-1, 0x08080808},",
"{-3, 0x04040404},",
"{-5, 0x02020202},",
"{-7, 0x01010101}",
"};",
"int VAR_3;",
"TCGv t, org_s;",
"t = tcg_temp_new(TCG_TYPE_TL);",
"org_s = tcg_temp_new(TCG_TYPE_TL);",
"tcg_gen_mov_tl(org_s, VAR_1);",
"tcg_gen_shli_tl(t, org_s, VAR_2[0].shift);",
"tcg_gen_andi_tl(VAR_0, t, VAR_2[0].mask);",
"for (VAR_3 = 1; VAR_3 < sizeof VAR_2 / sizeof VAR_2[0]; VAR_3++) {",
"if (VAR_2[VAR_3].shift >= 0) {",
"tcg_gen_shli_tl(t, org_s, VAR_2[VAR_3].shift);",
"} else {",
"tcg_gen_shri_tl(t, org_s, -VAR_2[VAR_3].shift);",
"}",
"tcg_gen_andi_tl(t, t, VAR_2[VAR_3].mask);",
"tcg_gen_or_tl(VAR_0, VAR_0, t);",
"}",
"tcg_temp_free(t);",
"tcg_temp_free(org_s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
]
]
|
13,009 | int h263_decode_picture_header(MpegEncContext *s)
{
int format, width, height, i;
uint32_t startcode;
align_get_bits(&s->gb);
startcode= get_bits(&s->gb, 22-8);
for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
if(startcode == 0x20)
break;
}
if (startcode != 0x20) {
av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1;
}
/* temporal reference */
s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
/* PTYPE starts here */
if (get_bits1(&s->gb) != 1) {
/* marker */
av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
return -1;
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
return -1; /* h263 id */
}
skip_bits1(&s->gb); /* split screen off */
skip_bits1(&s->gb); /* camera off */
skip_bits1(&s->gb); /* freeze picture release off */
/* Reset GOB number */
s->gob_number = 0;
format = get_bits(&s->gb, 3);
/*
0 forbidden
1 sub-QCIF
10 QCIF
7 extended PTYPE (PLUSPTYPE)
*/
if (format != 7 && format != 6) {
s->h263_plus = 0;
/* H.263v1 */
width = h263_format[format][0];
height = h263_format[format][1];
if (!width)
return -1;
s->pict_type = I_TYPE + get_bits1(&s->gb);
s->h263_long_vectors = get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
return -1; /* SAC: off */
}
s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
s->unrestricted_mv = s->h263_long_vectors || s->obmc;
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
return -1; /* not PB frame */
}
s->qscale = get_bits(&s->gb, 5);
skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
s->width = width;
s->height = height;
} else {
int ufep;
/* H.263v2 */
s->h263_plus = 1;
ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
/* ufep other than 0 and 1 are reserved */
if (ufep == 1) {
/* OPPTYPE */
format = get_bits(&s->gb, 3);
dprintf("ufep=1, format: %d\n", format);
skip_bits(&s->gb,1); /* Custom PCF */
s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */
s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
s->unrestricted_mv = s->umvplus || s->obmc;
s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Deblocking Filter not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Slice Structured not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
}
s->alt_inter_vlc= get_bits1(&s->gb);
s->modified_quant= get_bits1(&s->gb);
skip_bits(&s->gb, 1); /* Prevent start code emulation */
skip_bits(&s->gb, 3); /* Reserved */
} else if (ufep != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
return -1;
}
/* MPPTYPE */
s->pict_type = get_bits(&s->gb, 3) + I_TYPE;
if (s->pict_type == 8 && s->avctx->codec_tag == ff_get_fourcc("ZYGO"))
s->pict_type = I_TYPE;
if (s->pict_type != I_TYPE &&
s->pict_type != P_TYPE)
return -1;
skip_bits(&s->gb, 2);
s->no_rounding = get_bits1(&s->gb);
skip_bits(&s->gb, 4);
/* Get the picture dimensions */
if (ufep) {
if (format == 6) {
/* Custom Picture Format (CPFMT) */
s->aspect_ratio_info = get_bits(&s->gb, 4);
dprintf("aspect: %d\n", s->aspect_ratio_info);
/* aspect ratios:
0 - forbidden
1 - 1:1
2 - 12:11 (CIF 4:3)
3 - 10:11 (525-type 4:3)
4 - 16:11 (CIF 16:9)
5 - 40:33 (525-type 16:9)
6-14 - reserved
*/
width = (get_bits(&s->gb, 9) + 1) * 4;
skip_bits1(&s->gb);
height = get_bits(&s->gb, 9) * 4;
dprintf("\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
/* aspected dimensions */
s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
} else {
width = h263_format[format][0];
height = h263_format[format][1];
}
if ((width == 0) || (height == 0))
return -1;
s->width = width;
s->height = height;
if (s->umvplus) {
if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
skip_bits1(&s->gb);
}
}
s->qscale = get_bits(&s->gb, 5);
}
/* PEI */
while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
}
s->f_code = 1;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s\n",
s->qscale, av_get_pict_type_char(s->pict_type),
s->gb.size_in_bits, 1-s->no_rounding,
s->obmc ? " AP" : "",
s->umvplus ? " UMV" : "",
s->h263_long_vectors ? " LONG" : "",
s->h263_plus ? " +" : "",
s->h263_aic ? " AIC" : "",
s->alt_inter_vlc ? " AIV" : "",
s->modified_quant ? " MQ" : ""
);
}
#if 1
if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){
int i,j;
for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
av_log(s->avctx, AV_LOG_DEBUG, "\n");
for(i=0; i<13; i++){
for(j=0; j<3; j++){
int v= get_bits(&s->gb, 8);
v |= get_sbits(&s->gb, 8)<<8;
av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
}
#endif
return 0;
}
| false | FFmpeg | 332f9ac4e31ce5e6d0c42ac9e0229d7d1b2b4d60 | int h263_decode_picture_header(MpegEncContext *s)
{
int format, width, height, i;
uint32_t startcode;
align_get_bits(&s->gb);
startcode= get_bits(&s->gb, 22-8);
for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
if(startcode == 0x20)
break;
}
if (startcode != 0x20) {
av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1;
}
s->picture_number = get_bits(&s->gb, 8);
if (get_bits1(&s->gb) != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
return -1;
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
return -1;
}
skip_bits1(&s->gb);
skip_bits1(&s->gb);
skip_bits1(&s->gb);
s->gob_number = 0;
format = get_bits(&s->gb, 3);
if (format != 7 && format != 6) {
s->h263_plus = 0;
width = h263_format[format][0];
height = h263_format[format][1];
if (!width)
return -1;
s->pict_type = I_TYPE + get_bits1(&s->gb);
s->h263_long_vectors = get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
return -1;
}
s->obmc= get_bits1(&s->gb);
s->unrestricted_mv = s->h263_long_vectors || s->obmc;
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
return -1;
}
s->qscale = get_bits(&s->gb, 5);
skip_bits1(&s->gb);
s->width = width;
s->height = height;
} else {
int ufep;
s->h263_plus = 1;
ufep = get_bits(&s->gb, 3);
if (ufep == 1) {
format = get_bits(&s->gb, 3);
dprintf("ufep=1, format: %d\n", format);
skip_bits(&s->gb,1);
s->umvplus = get_bits(&s->gb, 1);
skip_bits1(&s->gb);
s->obmc= get_bits1(&s->gb);
s->unrestricted_mv = s->umvplus || s->obmc;
s->h263_aic = get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Deblocking Filter not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Slice Structured not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
}
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
}
s->alt_inter_vlc= get_bits1(&s->gb);
s->modified_quant= get_bits1(&s->gb);
skip_bits(&s->gb, 1);
skip_bits(&s->gb, 3);
} else if (ufep != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
return -1;
}
s->pict_type = get_bits(&s->gb, 3) + I_TYPE;
if (s->pict_type == 8 && s->avctx->codec_tag == ff_get_fourcc("ZYGO"))
s->pict_type = I_TYPE;
if (s->pict_type != I_TYPE &&
s->pict_type != P_TYPE)
return -1;
skip_bits(&s->gb, 2);
s->no_rounding = get_bits1(&s->gb);
skip_bits(&s->gb, 4);
if (ufep) {
if (format == 6) {
s->aspect_ratio_info = get_bits(&s->gb, 4);
dprintf("aspect: %d\n", s->aspect_ratio_info);
width = (get_bits(&s->gb, 9) + 1) * 4;
skip_bits1(&s->gb);
height = get_bits(&s->gb, 9) * 4;
dprintf("\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
} else {
width = h263_format[format][0];
height = h263_format[format][1];
}
if ((width == 0) || (height == 0))
return -1;
s->width = width;
s->height = height;
if (s->umvplus) {
if(get_bits1(&s->gb)==0)
skip_bits1(&s->gb);
}
}
s->qscale = get_bits(&s->gb, 5);
}
while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
}
s->f_code = 1;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s\n",
s->qscale, av_get_pict_type_char(s->pict_type),
s->gb.size_in_bits, 1-s->no_rounding,
s->obmc ? " AP" : "",
s->umvplus ? " UMV" : "",
s->h263_long_vectors ? " LONG" : "",
s->h263_plus ? " +" : "",
s->h263_aic ? " AIC" : "",
s->alt_inter_vlc ? " AIV" : "",
s->modified_quant ? " MQ" : ""
);
}
#if 1
if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){
int i,j;
for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
av_log(s->avctx, AV_LOG_DEBUG, "\n");
for(i=0; i<13; i++){
for(j=0; j<3; j++){
int v= get_bits(&s->gb, 8);
v |= get_sbits(&s->gb, 8)<<8;
av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
}
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MpegEncContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_6;
uint32_t startcode;
align_get_bits(&VAR_0->gb);
startcode= get_bits(&VAR_0->gb, 22-8);
for(VAR_6= VAR_0->gb.size_in_bits - get_bits_count(&VAR_0->gb); VAR_6>24; VAR_6-=8) {
startcode = ((startcode << 8) | get_bits(&VAR_0->gb, 8)) & 0x003FFFFF;
if(startcode == 0x20)
break;
}
if (startcode != 0x20) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1;
}
VAR_0->picture_number = get_bits(&VAR_0->gb, 8);
if (get_bits1(&VAR_0->gb) != 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad marker\n");
return -1;
}
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad H263 id\n");
return -1;
}
skip_bits1(&VAR_0->gb);
skip_bits1(&VAR_0->gb);
skip_bits1(&VAR_0->gb);
VAR_0->gob_number = 0;
VAR_1 = get_bits(&VAR_0->gb, 3);
if (VAR_1 != 7 && VAR_1 != 6) {
VAR_0->h263_plus = 0;
VAR_2 = h263_format[VAR_1][0];
VAR_3 = h263_format[VAR_1][1];
if (!VAR_2)
return -1;
VAR_0->pict_type = I_TYPE + get_bits1(&VAR_0->gb);
VAR_0->h263_long_vectors = get_bits1(&VAR_0->gb);
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
return -1;
}
VAR_0->obmc= get_bits1(&VAR_0->gb);
VAR_0->unrestricted_mv = VAR_0->h263_long_vectors || VAR_0->obmc;
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
return -1;
}
VAR_0->qscale = get_bits(&VAR_0->gb, 5);
skip_bits1(&VAR_0->gb);
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
} else {
int VAR_5;
VAR_0->h263_plus = 1;
VAR_5 = get_bits(&VAR_0->gb, 3);
if (VAR_5 == 1) {
VAR_1 = get_bits(&VAR_0->gb, 3);
dprintf("VAR_5=1, VAR_1: %d\n", VAR_1);
skip_bits(&VAR_0->gb,1);
VAR_0->umvplus = get_bits(&VAR_0->gb, 1);
skip_bits1(&VAR_0->gb);
VAR_0->obmc= get_bits1(&VAR_0->gb);
VAR_0->unrestricted_mv = VAR_0->umvplus || VAR_0->obmc;
VAR_0->h263_aic = get_bits1(&VAR_0->gb);
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Deblocking Filter not supported\n");
}
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Slice Structured not supported\n");
}
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
}
if (get_bits1(&VAR_0->gb) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
}
VAR_0->alt_inter_vlc= get_bits1(&VAR_0->gb);
VAR_0->modified_quant= get_bits1(&VAR_0->gb);
skip_bits(&VAR_0->gb, 1);
skip_bits(&VAR_0->gb, 3);
} else if (VAR_5 != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", VAR_5);
return -1;
}
VAR_0->pict_type = get_bits(&VAR_0->gb, 3) + I_TYPE;
if (VAR_0->pict_type == 8 && VAR_0->avctx->codec_tag == ff_get_fourcc("ZYGO"))
VAR_0->pict_type = I_TYPE;
if (VAR_0->pict_type != I_TYPE &&
VAR_0->pict_type != P_TYPE)
return -1;
skip_bits(&VAR_0->gb, 2);
VAR_0->no_rounding = get_bits1(&VAR_0->gb);
skip_bits(&VAR_0->gb, 4);
if (VAR_5) {
if (VAR_1 == 6) {
VAR_0->aspect_ratio_info = get_bits(&VAR_0->gb, 4);
dprintf("aspect: %d\n", VAR_0->aspect_ratio_info);
VAR_2 = (get_bits(&VAR_0->gb, 9) + 1) * 4;
skip_bits1(&VAR_0->gb);
VAR_3 = get_bits(&VAR_0->gb, 9) * 4;
dprintf("\nH.263+ Custom picture: %dx%d\n",VAR_2,VAR_3);
if (VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED) {
VAR_0->avctx->sample_aspect_ratio.num= get_bits(&VAR_0->gb, 8);
VAR_0->avctx->sample_aspect_ratio.den= get_bits(&VAR_0->gb, 8);
}else{
VAR_0->avctx->sample_aspect_ratio= pixel_aspect[VAR_0->aspect_ratio_info];
}
} else {
VAR_2 = h263_format[VAR_1][0];
VAR_3 = h263_format[VAR_1][1];
}
if ((VAR_2 == 0) || (VAR_3 == 0))
return -1;
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
if (VAR_0->umvplus) {
if(get_bits1(&VAR_0->gb)==0)
skip_bits1(&VAR_0->gb);
}
}
VAR_0->qscale = get_bits(&VAR_0->gb, 5);
}
while (get_bits1(&VAR_0->gb) != 0) {
skip_bits(&VAR_0->gb, 8);
}
VAR_0->f_code = 1;
if(VAR_0->h263_aic){
VAR_0->y_dc_scale_table=
VAR_0->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
VAR_0->y_dc_scale_table=
VAR_0->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(VAR_0->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(VAR_0->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0\n",
VAR_0->qscale, av_get_pict_type_char(VAR_0->pict_type),
VAR_0->gb.size_in_bits, 1-VAR_0->no_rounding,
VAR_0->obmc ? " AP" : "",
VAR_0->umvplus ? " UMV" : "",
VAR_0->h263_long_vectors ? " LONG" : "",
VAR_0->h263_plus ? " +" : "",
VAR_0->h263_aic ? " AIC" : "",
VAR_0->alt_inter_vlc ? " AIV" : "",
VAR_0->modified_quant ? " MQ" : ""
);
}
#if 1
if (VAR_0->pict_type == I_TYPE && VAR_0->avctx->codec_tag == ff_get_fourcc("ZYGO")){
int VAR_6,VAR_6;
for(VAR_6=0; VAR_6<85; VAR_6++) av_log(VAR_0->avctx, AV_LOG_DEBUG, "%d", get_bits1(&VAR_0->gb));
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
for(VAR_6=0; VAR_6<13; VAR_6++){
for(VAR_6=0; VAR_6<3; VAR_6++){
int VAR_7= get_bits(&VAR_0->gb, 8);
VAR_7 |= get_sbits(&VAR_0->gb, 8)<<8;
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %5d", VAR_7);
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for(VAR_6=0; VAR_6<50; VAR_6++) av_log(VAR_0->avctx, AV_LOG_DEBUG, "%d", get_bits1(&VAR_0->gb));
}
#endif
return 0;
}
| [
"int FUNC_0(MpegEncContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_6;",
"uint32_t startcode;",
"align_get_bits(&VAR_0->gb);",
"startcode= get_bits(&VAR_0->gb, 22-8);",
"for(VAR_6= VAR_0->gb.size_in_bits - get_bits_count(&VAR_0->gb); VAR_6>24; VAR_6-=8) {",
"startcode = ((startcode << 8) | get_bits(&VAR_0->gb, 8)) & 0x003FFFFF;",
"if(startcode == 0x20)\nbreak;",
"}",
"if (startcode != 0x20) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad picture start code\\n\");",
"return -1;",
"}",
"VAR_0->picture_number = get_bits(&VAR_0->gb, 8);",
"if (get_bits1(&VAR_0->gb) != 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad marker\\n\");",
"return -1;",
"}",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad H263 id\\n\");",
"return -1;",
"}",
"skip_bits1(&VAR_0->gb);",
"skip_bits1(&VAR_0->gb);",
"skip_bits1(&VAR_0->gb);",
"VAR_0->gob_number = 0;",
"VAR_1 = get_bits(&VAR_0->gb, 3);",
"if (VAR_1 != 7 && VAR_1 != 6) {",
"VAR_0->h263_plus = 0;",
"VAR_2 = h263_format[VAR_1][0];",
"VAR_3 = h263_format[VAR_1][1];",
"if (!VAR_2)\nreturn -1;",
"VAR_0->pict_type = I_TYPE + get_bits1(&VAR_0->gb);",
"VAR_0->h263_long_vectors = get_bits1(&VAR_0->gb);",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"H263 SAC not supported\\n\");",
"return -1;",
"}",
"VAR_0->obmc= get_bits1(&VAR_0->gb);",
"VAR_0->unrestricted_mv = VAR_0->h263_long_vectors || VAR_0->obmc;",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"H263 PB frame not supported\\n\");",
"return -1;",
"}",
"VAR_0->qscale = get_bits(&VAR_0->gb, 5);",
"skip_bits1(&VAR_0->gb);",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"} else {",
"int VAR_5;",
"VAR_0->h263_plus = 1;",
"VAR_5 = get_bits(&VAR_0->gb, 3);",
"if (VAR_5 == 1) {",
"VAR_1 = get_bits(&VAR_0->gb, 3);",
"dprintf(\"VAR_5=1, VAR_1: %d\\n\", VAR_1);",
"skip_bits(&VAR_0->gb,1);",
"VAR_0->umvplus = get_bits(&VAR_0->gb, 1);",
"skip_bits1(&VAR_0->gb);",
"VAR_0->obmc= get_bits1(&VAR_0->gb);",
"VAR_0->unrestricted_mv = VAR_0->umvplus || VAR_0->obmc;",
"VAR_0->h263_aic = get_bits1(&VAR_0->gb);",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Deblocking Filter not supported\\n\");",
"}",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Slice Structured not supported\\n\");",
"}",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Reference Picture Selection not supported\\n\");",
"}",
"if (get_bits1(&VAR_0->gb) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Independent Segment Decoding not supported\\n\");",
"}",
"VAR_0->alt_inter_vlc= get_bits1(&VAR_0->gb);",
"VAR_0->modified_quant= get_bits1(&VAR_0->gb);",
"skip_bits(&VAR_0->gb, 1);",
"skip_bits(&VAR_0->gb, 3);",
"} else if (VAR_5 != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad UFEP type (%d)\\n\", VAR_5);",
"return -1;",
"}",
"VAR_0->pict_type = get_bits(&VAR_0->gb, 3) + I_TYPE;",
"if (VAR_0->pict_type == 8 && VAR_0->avctx->codec_tag == ff_get_fourcc(\"ZYGO\"))\nVAR_0->pict_type = I_TYPE;",
"if (VAR_0->pict_type != I_TYPE &&\nVAR_0->pict_type != P_TYPE)\nreturn -1;",
"skip_bits(&VAR_0->gb, 2);",
"VAR_0->no_rounding = get_bits1(&VAR_0->gb);",
"skip_bits(&VAR_0->gb, 4);",
"if (VAR_5) {",
"if (VAR_1 == 6) {",
"VAR_0->aspect_ratio_info = get_bits(&VAR_0->gb, 4);",
"dprintf(\"aspect: %d\\n\", VAR_0->aspect_ratio_info);",
"VAR_2 = (get_bits(&VAR_0->gb, 9) + 1) * 4;",
"skip_bits1(&VAR_0->gb);",
"VAR_3 = get_bits(&VAR_0->gb, 9) * 4;",
"dprintf(\"\\nH.263+ Custom picture: %dx%d\\n\",VAR_2,VAR_3);",
"if (VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED) {",
"VAR_0->avctx->sample_aspect_ratio.num= get_bits(&VAR_0->gb, 8);",
"VAR_0->avctx->sample_aspect_ratio.den= get_bits(&VAR_0->gb, 8);",
"}else{",
"VAR_0->avctx->sample_aspect_ratio= pixel_aspect[VAR_0->aspect_ratio_info];",
"}",
"} else {",
"VAR_2 = h263_format[VAR_1][0];",
"VAR_3 = h263_format[VAR_1][1];",
"}",
"if ((VAR_2 == 0) || (VAR_3 == 0))\nreturn -1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"if (VAR_0->umvplus) {",
"if(get_bits1(&VAR_0->gb)==0)\nskip_bits1(&VAR_0->gb);",
"}",
"}",
"VAR_0->qscale = get_bits(&VAR_0->gb, 5);",
"}",
"while (get_bits1(&VAR_0->gb) != 0) {",
"skip_bits(&VAR_0->gb, 8);",
"}",
"VAR_0->f_code = 1;",
"if(VAR_0->h263_aic){",
"VAR_0->y_dc_scale_table=\nVAR_0->c_dc_scale_table= ff_aic_dc_scale_table;",
"}else{",
"VAR_0->y_dc_scale_table=\nVAR_0->c_dc_scale_table= ff_mpeg1_dc_scale_table;",
"}",
"if(VAR_0->avctx->debug&FF_DEBUG_PICT_INFO){",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"qp:%d %c size:%d rnd:%d%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0%VAR_0\\n\",\nVAR_0->qscale, av_get_pict_type_char(VAR_0->pict_type),\nVAR_0->gb.size_in_bits, 1-VAR_0->no_rounding,\nVAR_0->obmc ? \" AP\" : \"\",\nVAR_0->umvplus ? \" UMV\" : \"\",\nVAR_0->h263_long_vectors ? \" LONG\" : \"\",\nVAR_0->h263_plus ? \" +\" : \"\",\nVAR_0->h263_aic ? \" AIC\" : \"\",\nVAR_0->alt_inter_vlc ? \" AIV\" : \"\",\nVAR_0->modified_quant ? \" MQ\" : \"\"\n);",
"}",
"#if 1\nif (VAR_0->pict_type == I_TYPE && VAR_0->avctx->codec_tag == ff_get_fourcc(\"ZYGO\")){",
"int VAR_6,VAR_6;",
"for(VAR_6=0; VAR_6<85; VAR_6++) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%d\", get_bits1(&VAR_0->gb));",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"for(VAR_6=0; VAR_6<13; VAR_6++){",
"for(VAR_6=0; VAR_6<3; VAR_6++){",
"int VAR_7= get_bits(&VAR_0->gb, 8);",
"VAR_7 |= get_sbits(&VAR_0->gb, 8)<<8;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %5d\", VAR_7);",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for(VAR_6=0; VAR_6<50; VAR_6++) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%d\", get_bits1(&VAR_0->gb));",
"}",
"#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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
81
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
113
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
161
],
[
163
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
239
],
[
241,
243
],
[
245,
247,
249
],
[
251
],
[
253
],
[
255
],
[
261
],
[
263
],
[
267
],
[
269
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
329,
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357,
359
],
[
361
],
[
363,
365
],
[
367
],
[
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,
431
],
[
433
]
]
|
13,010 | static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
Error **errp)
{
X86CPU *cpu = NULL;
Error *local_err = NULL;
cpu = cpu_x86_create(cpu_model, &local_err);
if (local_err != NULL) {
goto out;
}
object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| false | qemu | 6aff24c6a61c6fec31e555c7748ba6085b7b2c06 | static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
Error **errp)
{
X86CPU *cpu = NULL;
Error *local_err = NULL;
cpu = cpu_x86_create(cpu_model, &local_err);
if (local_err != NULL) {
goto out;
}
object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| {
"code": [],
"line_no": []
} | static X86CPU *FUNC_0(const char *cpu_model, int64_t apic_id,
Error **errp)
{
X86CPU *cpu = NULL;
Error *local_err = NULL;
cpu = cpu_x86_create(cpu_model, &local_err);
if (local_err != NULL) {
goto out;
}
object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| [
"static X86CPU *FUNC_0(const char *cpu_model, int64_t apic_id,\nError **errp)\n{",
"X86CPU *cpu = NULL;",
"Error *local_err = NULL;",
"cpu = cpu_x86_create(cpu_model, &local_err);",
"if (local_err != NULL) {",
"goto out;",
"}",
"object_property_set_int(OBJECT(cpu), apic_id, \"apic-id\", &local_err);",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", &local_err);",
"out:\nif (local_err) {",
"error_propagate(errp, local_err);",
"object_unref(OBJECT(cpu));",
"cpu = NULL;",
"}",
"return cpu;",
"}"
]
| [
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
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
]
|
13,011 | static int find_pte64 (mmu_ctx_t *ctx, int h, int rw)
{
return _find_pte(ctx, 1, h, rw);
}
| false | qemu | b227a8e9aa5f27d29f77ba90d5eb9d0662a1175e | static int find_pte64 (mmu_ctx_t *ctx, int h, int rw)
{
return _find_pte(ctx, 1, h, rw);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (mmu_ctx_t *VAR_0, int VAR_1, int VAR_2)
{
return _find_pte(VAR_0, 1, VAR_1, VAR_2);
}
| [
"static int FUNC_0 (mmu_ctx_t *VAR_0, int VAR_1, int VAR_2)\n{",
"return _find_pte(VAR_0, 1, VAR_1, VAR_2);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,013 | void pc_basic_device_init(qemu_irq *isa_irq,
ISADevice **rtc_state)
{
int i;
DriveInfo *fd[MAX_FD];
PITState *pit;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet) {
DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
if (hpet) {
for (i = 0; i < 24; i++) {
sysbus_connect_irq(sysbus_from_qdev(hpet), i, isa_irq[i]);
}
rtc_irq = qdev_get_gpio_in(hpet, 0);
}
}
*rtc_state = rtc_init(2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple("i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
vmport_init();
vmmouse = isa_try_create("vmmouse");
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
}
port92 = isa_create_simple("port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
}
| false | qemu | 64d7e9a421fea0ac50b44541f5521de455e7cd5d | void pc_basic_device_init(qemu_irq *isa_irq,
ISADevice **rtc_state)
{
int i;
DriveInfo *fd[MAX_FD];
PITState *pit;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet) {
DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
if (hpet) {
for (i = 0; i < 24; i++) {
sysbus_connect_irq(sysbus_from_qdev(hpet), i, isa_irq[i]);
}
rtc_irq = qdev_get_gpio_in(hpet, 0);
}
}
*rtc_state = rtc_init(2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple("i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
vmport_init();
vmmouse = isa_try_create("vmmouse");
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
}
port92 = isa_create_simple("port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(qemu_irq *VAR_0,
ISADevice **VAR_1)
{
int VAR_2;
DriveInfo *fd[MAX_FD];
PITState *pit;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet) {
DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
if (hpet) {
for (VAR_2 = 0; VAR_2 < 24; VAR_2++) {
sysbus_connect_irq(sysbus_from_qdev(hpet), VAR_2, VAR_0[VAR_2]);
}
rtc_irq = qdev_get_gpio_in(hpet, 0);
}
}
*VAR_1 = rtc_init(2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *VAR_1);
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
for(VAR_2 = 0; VAR_2 < MAX_SERIAL_PORTS; VAR_2++) {
if (serial_hds[VAR_2]) {
serial_isa_init(VAR_2, serial_hds[VAR_2]);
}
}
for(VAR_2 = 0; VAR_2 < MAX_PARALLEL_PORTS; VAR_2++) {
if (parallel_hds[VAR_2]) {
parallel_init(VAR_2, parallel_hds[VAR_2]);
}
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple("i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
vmport_init();
vmmouse = isa_try_create("vmmouse");
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
}
port92 = isa_create_simple("port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
for(VAR_2 = 0; VAR_2 < MAX_FD; VAR_2++) {
fd[VAR_2] = drive_get(IF_FLOPPY, 0, VAR_2);
}
fdctrl_init_isa(fd);
}
| [
"void FUNC_0(qemu_irq *VAR_0,\nISADevice **VAR_1)\n{",
"int VAR_2;",
"DriveInfo *fd[MAX_FD];",
"PITState *pit;",
"qemu_irq rtc_irq = NULL;",
"qemu_irq *a20_line;",
"ISADevice *i8042, *port92, *vmmouse;",
"qemu_irq *cpu_exit_irq;",
"register_ioport_write(0x80, 1, 1, ioport80_write, NULL);",
"register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);",
"if (!no_hpet) {",
"DeviceState *hpet = sysbus_try_create_simple(\"hpet\", HPET_BASE, NULL);",
"if (hpet) {",
"for (VAR_2 = 0; VAR_2 < 24; VAR_2++) {",
"sysbus_connect_irq(sysbus_from_qdev(hpet), VAR_2, VAR_0[VAR_2]);",
"}",
"rtc_irq = qdev_get_gpio_in(hpet, 0);",
"}",
"}",
"*VAR_1 = rtc_init(2000, rtc_irq);",
"qemu_register_boot_set(pc_boot_set, *VAR_1);",
"pit = pit_init(0x40, isa_reserve_irq(0));",
"pcspk_init(pit);",
"for(VAR_2 = 0; VAR_2 < MAX_SERIAL_PORTS; VAR_2++) {",
"if (serial_hds[VAR_2]) {",
"serial_isa_init(VAR_2, serial_hds[VAR_2]);",
"}",
"}",
"for(VAR_2 = 0; VAR_2 < MAX_PARALLEL_PORTS; VAR_2++) {",
"if (parallel_hds[VAR_2]) {",
"parallel_init(VAR_2, parallel_hds[VAR_2]);",
"}",
"}",
"a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);",
"i8042 = isa_create_simple(\"i8042\");",
"i8042_setup_a20_line(i8042, &a20_line[0]);",
"vmport_init();",
"vmmouse = isa_try_create(\"vmmouse\");",
"if (vmmouse) {",
"qdev_prop_set_ptr(&vmmouse->qdev, \"ps2_mouse\", i8042);",
"}",
"port92 = isa_create_simple(\"port92\");",
"port92_init(port92, &a20_line[1]);",
"cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);",
"DMA_init(0, cpu_exit_irq);",
"for(VAR_2 = 0; VAR_2 < MAX_FD; VAR_2++) {",
"fd[VAR_2] = drive_get(IF_FLOPPY, 0, VAR_2);",
"}",
"fdctrl_init_isa(fd);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
]
|
13,014 | static JSONTokenType token_get_type(QObject *obj)
{
return qdict_get_int(qobject_to_qdict(obj), "type");
}
| false | qemu | 9bada8971173345ceb37ed1a47b00a01a4dd48cf | static JSONTokenType token_get_type(QObject *obj)
{
return qdict_get_int(qobject_to_qdict(obj), "type");
}
| {
"code": [],
"line_no": []
} | static JSONTokenType FUNC_0(QObject *obj)
{
return qdict_get_int(qobject_to_qdict(obj), "type");
}
| [
"static JSONTokenType FUNC_0(QObject *obj)\n{",
"return qdict_get_int(qobject_to_qdict(obj), \"type\");",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,015 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *idebus0, BusState *idebus1,
ISADevice *s)
{
int val, nb, nb_heads, max_track, last_sect, i;
FDriveType fd_type[2];
DriveInfo *fd[2];
static pc_cmos_init_late_arg arg;
/* various important CMOS locations needed by PC/Bochs bios */
/* memory size */
val = 640; /* base memory in K */
rtc_set_memory(s, 0x15, val);
rtc_set_memory(s, 0x16, val >> 8);
val = (ram_size / 1024) - 1024;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x17, val);
rtc_set_memory(s, 0x18, val >> 8);
rtc_set_memory(s, 0x30, val);
rtc_set_memory(s, 0x31, val >> 8);
if (above_4g_mem_size) {
rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
}
if (ram_size > (16 * 1024 * 1024))
val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
else
val = 0;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x34, val);
rtc_set_memory(s, 0x35, val >> 8);
/* set the number of CPU */
rtc_set_memory(s, 0x5f, smp_cpus - 1);
/* set boot devices, and disable floppy signature check if requested */
if (set_boot_dev(s, boot_device, fd_bootchk)) {
exit(1);
}
/* floppy type */
for (i = 0; i < 2; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
if (fd[i]) {
bdrv_get_floppy_geometry_hint(fd[i]->bdrv, &nb_heads, &max_track,
&last_sect, FDRIVE_DRV_NONE,
&fd_type[i]);
} else {
fd_type[i] = FDRIVE_DRV_NONE;
}
}
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
cmos_get_fd_drive_type(fd_type[1]);
rtc_set_memory(s, 0x10, val);
val = 0;
nb = 0;
if (fd_type[0] < FDRIVE_DRV_NONE) {
nb++;
}
if (fd_type[1] < FDRIVE_DRV_NONE) {
nb++;
}
switch (nb) {
case 0:
break;
case 1:
val |= 0x01; /* 1 drive, ready for boot */
break;
case 2:
val |= 0x41; /* 2 drives, ready for boot */
break;
}
val |= 0x02; /* FPU is there */
val |= 0x04; /* PS/2 mouse installed */
rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
/* hard drives */
arg.rtc_state = s;
arg.idebus0 = idebus0;
arg.idebus1 = idebus1;
qemu_register_reset(pc_cmos_init_late, &arg);
}
| false | qemu | e14c8062f4c4c336c6e5fa5b51472ffff5f3fe38 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *idebus0, BusState *idebus1,
ISADevice *s)
{
int val, nb, nb_heads, max_track, last_sect, i;
FDriveType fd_type[2];
DriveInfo *fd[2];
static pc_cmos_init_late_arg arg;
val = 640;
rtc_set_memory(s, 0x15, val);
rtc_set_memory(s, 0x16, val >> 8);
val = (ram_size / 1024) - 1024;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x17, val);
rtc_set_memory(s, 0x18, val >> 8);
rtc_set_memory(s, 0x30, val);
rtc_set_memory(s, 0x31, val >> 8);
if (above_4g_mem_size) {
rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
}
if (ram_size > (16 * 1024 * 1024))
val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
else
val = 0;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x34, val);
rtc_set_memory(s, 0x35, val >> 8);
rtc_set_memory(s, 0x5f, smp_cpus - 1);
if (set_boot_dev(s, boot_device, fd_bootchk)) {
exit(1);
}
for (i = 0; i < 2; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
if (fd[i]) {
bdrv_get_floppy_geometry_hint(fd[i]->bdrv, &nb_heads, &max_track,
&last_sect, FDRIVE_DRV_NONE,
&fd_type[i]);
} else {
fd_type[i] = FDRIVE_DRV_NONE;
}
}
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
cmos_get_fd_drive_type(fd_type[1]);
rtc_set_memory(s, 0x10, val);
val = 0;
nb = 0;
if (fd_type[0] < FDRIVE_DRV_NONE) {
nb++;
}
if (fd_type[1] < FDRIVE_DRV_NONE) {
nb++;
}
switch (nb) {
case 0:
break;
case 1:
val |= 0x01;
break;
case 2:
val |= 0x41;
break;
}
val |= 0x02;
val |= 0x04;
rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
arg.rtc_state = s;
arg.idebus0 = idebus0;
arg.idebus1 = idebus1;
qemu_register_reset(pc_cmos_init_late, &arg);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1,
const char *VAR_2,
BusState *VAR_3, BusState *VAR_4,
ISADevice *VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
FDriveType fd_type[2];
DriveInfo *fd[2];
static pc_cmos_init_late_arg VAR_12;
VAR_6 = 640;
rtc_set_memory(VAR_5, 0x15, VAR_6);
rtc_set_memory(VAR_5, 0x16, VAR_6 >> 8);
VAR_6 = (VAR_0 / 1024) - 1024;
if (VAR_6 > 65535)
VAR_6 = 65535;
rtc_set_memory(VAR_5, 0x17, VAR_6);
rtc_set_memory(VAR_5, 0x18, VAR_6 >> 8);
rtc_set_memory(VAR_5, 0x30, VAR_6);
rtc_set_memory(VAR_5, 0x31, VAR_6 >> 8);
if (VAR_1) {
rtc_set_memory(VAR_5, 0x5b, (unsigned int)VAR_1 >> 16);
rtc_set_memory(VAR_5, 0x5c, (unsigned int)VAR_1 >> 24);
rtc_set_memory(VAR_5, 0x5d, (uint64_t)VAR_1 >> 32);
}
if (VAR_0 > (16 * 1024 * 1024))
VAR_6 = (VAR_0 / 65536) - ((16 * 1024 * 1024) / 65536);
else
VAR_6 = 0;
if (VAR_6 > 65535)
VAR_6 = 65535;
rtc_set_memory(VAR_5, 0x34, VAR_6);
rtc_set_memory(VAR_5, 0x35, VAR_6 >> 8);
rtc_set_memory(VAR_5, 0x5f, smp_cpus - 1);
if (set_boot_dev(VAR_5, VAR_2, fd_bootchk)) {
exit(1);
}
for (VAR_11 = 0; VAR_11 < 2; VAR_11++) {
fd[VAR_11] = drive_get(IF_FLOPPY, 0, VAR_11);
if (fd[VAR_11]) {
bdrv_get_floppy_geometry_hint(fd[VAR_11]->bdrv, &VAR_8, &VAR_9,
&VAR_10, FDRIVE_DRV_NONE,
&fd_type[VAR_11]);
} else {
fd_type[VAR_11] = FDRIVE_DRV_NONE;
}
}
VAR_6 = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
cmos_get_fd_drive_type(fd_type[1]);
rtc_set_memory(VAR_5, 0x10, VAR_6);
VAR_6 = 0;
VAR_7 = 0;
if (fd_type[0] < FDRIVE_DRV_NONE) {
VAR_7++;
}
if (fd_type[1] < FDRIVE_DRV_NONE) {
VAR_7++;
}
switch (VAR_7) {
case 0:
break;
case 1:
VAR_6 |= 0x01;
break;
case 2:
VAR_6 |= 0x41;
break;
}
VAR_6 |= 0x02;
VAR_6 |= 0x04;
rtc_set_memory(VAR_5, REG_EQUIPMENT_BYTE, VAR_6);
VAR_12.rtc_state = VAR_5;
VAR_12.VAR_3 = VAR_3;
VAR_12.VAR_4 = VAR_4;
qemu_register_reset(pc_cmos_init_late, &VAR_12);
}
| [
"void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1,\nconst char *VAR_2,\nBusState *VAR_3, BusState *VAR_4,\nISADevice *VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"FDriveType fd_type[2];",
"DriveInfo *fd[2];",
"static pc_cmos_init_late_arg VAR_12;",
"VAR_6 = 640;",
"rtc_set_memory(VAR_5, 0x15, VAR_6);",
"rtc_set_memory(VAR_5, 0x16, VAR_6 >> 8);",
"VAR_6 = (VAR_0 / 1024) - 1024;",
"if (VAR_6 > 65535)\nVAR_6 = 65535;",
"rtc_set_memory(VAR_5, 0x17, VAR_6);",
"rtc_set_memory(VAR_5, 0x18, VAR_6 >> 8);",
"rtc_set_memory(VAR_5, 0x30, VAR_6);",
"rtc_set_memory(VAR_5, 0x31, VAR_6 >> 8);",
"if (VAR_1) {",
"rtc_set_memory(VAR_5, 0x5b, (unsigned int)VAR_1 >> 16);",
"rtc_set_memory(VAR_5, 0x5c, (unsigned int)VAR_1 >> 24);",
"rtc_set_memory(VAR_5, 0x5d, (uint64_t)VAR_1 >> 32);",
"}",
"if (VAR_0 > (16 * 1024 * 1024))\nVAR_6 = (VAR_0 / 65536) - ((16 * 1024 * 1024) / 65536);",
"else\nVAR_6 = 0;",
"if (VAR_6 > 65535)\nVAR_6 = 65535;",
"rtc_set_memory(VAR_5, 0x34, VAR_6);",
"rtc_set_memory(VAR_5, 0x35, VAR_6 >> 8);",
"rtc_set_memory(VAR_5, 0x5f, smp_cpus - 1);",
"if (set_boot_dev(VAR_5, VAR_2, fd_bootchk)) {",
"exit(1);",
"}",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++) {",
"fd[VAR_11] = drive_get(IF_FLOPPY, 0, VAR_11);",
"if (fd[VAR_11]) {",
"bdrv_get_floppy_geometry_hint(fd[VAR_11]->bdrv, &VAR_8, &VAR_9,\n&VAR_10, FDRIVE_DRV_NONE,\n&fd_type[VAR_11]);",
"} else {",
"fd_type[VAR_11] = FDRIVE_DRV_NONE;",
"}",
"}",
"VAR_6 = (cmos_get_fd_drive_type(fd_type[0]) << 4) |\ncmos_get_fd_drive_type(fd_type[1]);",
"rtc_set_memory(VAR_5, 0x10, VAR_6);",
"VAR_6 = 0;",
"VAR_7 = 0;",
"if (fd_type[0] < FDRIVE_DRV_NONE) {",
"VAR_7++;",
"}",
"if (fd_type[1] < FDRIVE_DRV_NONE) {",
"VAR_7++;",
"}",
"switch (VAR_7) {",
"case 0:\nbreak;",
"case 1:\nVAR_6 |= 0x01;",
"break;",
"case 2:\nVAR_6 |= 0x41;",
"break;",
"}",
"VAR_6 |= 0x02;",
"VAR_6 |= 0x04;",
"rtc_set_memory(VAR_5, REG_EQUIPMENT_BYTE, VAR_6);",
"VAR_12.rtc_state = VAR_5;",
"VAR_12.VAR_3 = VAR_3;",
"VAR_12.VAR_4 = VAR_4;",
"qemu_register_reset(pc_cmos_init_late, &VAR_12);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
83
],
[
89
],
[
91
],
[
93
],
[
99
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
]
]
|
13,018 | static uint32_t slow_bar_readw(void *opaque, target_phys_addr_t addr)
{
AssignedDevRegion *d = opaque;
uint16_t *in = (uint16_t *)(d->u.r_virtbase + addr);
uint32_t r;
r = *in;
DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
return r;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t slow_bar_readw(void *opaque, target_phys_addr_t addr)
{
AssignedDevRegion *d = opaque;
uint16_t *in = (uint16_t *)(d->u.r_virtbase + addr);
uint32_t r;
r = *in;
DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
return r;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
AssignedDevRegion *d = opaque;
uint16_t *in = (uint16_t *)(d->u.r_virtbase + addr);
uint32_t r;
r = *in;
DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
return r;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"AssignedDevRegion *d = opaque;",
"uint16_t *in = (uint16_t *)(d->u.r_virtbase + addr);",
"uint32_t r;",
"r = *in;",
"DEBUG(\"slow_bar_readl addr=0x\" TARGET_FMT_plx \" val=0x%08x\\n\", addr, r);",
"return r;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
]
]
|
13,019 | static void simple_dict(void)
{
int i;
struct {
const char *encoded;
LiteralQObject decoded;
} test_cases[] = {
{
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(42) },
{ "bar", QLIT_QSTR("hello world") },
{ }
})),
}, {
.encoded = "{}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ }
})),
}, {
.encoded = "{\"foo\": 43}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(43) },
{ }
})),
},
{ }
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded, NULL);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str), NULL);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void simple_dict(void)
{
int i;
struct {
const char *encoded;
LiteralQObject decoded;
} test_cases[] = {
{
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(42) },
{ "bar", QLIT_QSTR("hello world") },
{ }
})),
}, {
.encoded = "{}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ }
})),
}, {
.encoded = "{\"foo\": 43}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(43) },
{ }
})),
},
{ }
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded, NULL);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str), NULL);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| {
"code": [
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(qstring_get_str(str), NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(qstring_get_str(str), NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(qstring_get_str(str), NULL);"
],
"line_no": [
67,
67,
67,
67,
67,
79,
67,
79,
67,
79
]
} | static void FUNC_0(void)
{
int VAR_0;
struct {
const char *encoded;
LiteralQObject decoded;
} VAR_1[] = {
{
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(42) },
{ "bar", QLIT_QSTR("hello world") },
{ }
})),
}, {
.encoded = "{}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ }
})),
}, {
.encoded = "{\"foo\": 43}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
{ "foo", QLIT_QINT(43) },
{ }
})),
},
{ }
};
for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {
QObject *obj;
QString *str;
obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);
g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str), NULL);
g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"struct {",
"const char *encoded;",
"LiteralQObject decoded;",
"} VAR_1[] = {",
"{",
".encoded = \"{\\\"foo\\\": 42, \\\"bar\\\": \\\"hello world\\\"}\",",
".decoded = QLIT_QDICT(((LiteralQDictEntry[]){",
"{ \"foo\", QLIT_QINT(42) },",
"{ \"bar\", QLIT_QSTR(\"hello world\") },",
"{ }",
"})),",
"}, {",
".encoded = \"{}\",",
".decoded = QLIT_QDICT(((LiteralQDictEntry[]){",
"{ }",
"})),",
"}, {",
".encoded = \"{\\\"foo\\\": 43}\",",
".decoded = QLIT_QDICT(((LiteralQDictEntry[]){",
"{ \"foo\", QLIT_QINT(43) },",
"{ }",
"})),",
"},",
"{ }",
"};",
"for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {",
"QObject *obj;",
"QString *str;",
"obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);",
"g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);",
"str = qobject_to_json(obj);",
"qobject_decref(obj);",
"obj = qobject_from_json(qstring_get_str(str), NULL);",
"g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);",
"qobject_decref(obj);",
"QDECREF(str);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
]
]
|
13,020 | static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
{
int16_t *ip = input;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
int Ed, Gd, Add, Bdd, Fd, Hd;
int i;
/* Inverse DCT on the rows now */
for (i = 0; i < 8; i++) {
/* Check for non-zero values */
if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {
A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
Ad = M(xC4S4, (A - C));
Bd = M(xC4S4, (B - D));
Cd = A + C;
Dd = B + D;
E = M(xC4S4, (ip[0] + ip[4]));
F = M(xC4S4, (ip[0] - ip[4]));
G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
Ed = E - G;
Gd = E + G;
Add = F + Ad;
Bdd = Bd - H;
Fd = F - Ad;
Hd = Bd + H;
/* Final sequence of operations over-write original inputs. */
ip[0] = Gd + Cd ;
ip[7] = Gd - Cd ;
ip[1] = Add + Hd;
ip[2] = Add - Hd;
ip[3] = Ed + Dd ;
ip[4] = Ed - Dd ;
ip[5] = Fd + Bdd;
ip[6] = Fd - Bdd;
}
ip += 8; /* next row */
}
ip = input;
for ( i = 0; i < 8; i++) {
/* Check for non-zero values (bitwise or faster than ||) */
if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
A = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]);
B = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]);
C = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]);
D = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]);
Ad = M(xC4S4, (A - C));
Bd = M(xC4S4, (B - D));
Cd = A + C;
Dd = B + D;
E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;
F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;
if(type==1){ //HACK
E += 16*128;
F += 16*128;
}
G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);
H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);
Ed = E - G;
Gd = E + G;
Add = F + Ad;
Bdd = Bd - H;
Fd = F - Ad;
Hd = Bd + H;
/* Final sequence of operations over-write original inputs. */
if(type==0){
ip[0*8] = (Gd + Cd ) >> 4;
ip[7*8] = (Gd - Cd ) >> 4;
ip[1*8] = (Add + Hd ) >> 4;
ip[2*8] = (Add - Hd ) >> 4;
ip[3*8] = (Ed + Dd ) >> 4;
ip[4*8] = (Ed - Dd ) >> 4;
ip[5*8] = (Fd + Bdd ) >> 4;
ip[6*8] = (Fd - Bdd ) >> 4;
}else if(type==1){
dst[0*stride] = cm[(Gd + Cd ) >> 4];
dst[7*stride] = cm[(Gd - Cd ) >> 4];
dst[1*stride] = cm[(Add + Hd ) >> 4];
dst[2*stride] = cm[(Add - Hd ) >> 4];
dst[3*stride] = cm[(Ed + Dd ) >> 4];
dst[4*stride] = cm[(Ed - Dd ) >> 4];
dst[5*stride] = cm[(Fd + Bdd ) >> 4];
dst[6*stride] = cm[(Fd - Bdd ) >> 4];
}else{
dst[0*stride] = cm[dst[0*stride] + ((Gd + Cd ) >> 4)];
dst[7*stride] = cm[dst[7*stride] + ((Gd - Cd ) >> 4)];
dst[1*stride] = cm[dst[1*stride] + ((Add + Hd ) >> 4)];
dst[2*stride] = cm[dst[2*stride] + ((Add - Hd ) >> 4)];
dst[3*stride] = cm[dst[3*stride] + ((Ed + Dd ) >> 4)];
dst[4*stride] = cm[dst[4*stride] + ((Ed - Dd ) >> 4)];
dst[5*stride] = cm[dst[5*stride] + ((Fd + Bdd ) >> 4)];
dst[6*stride] = cm[dst[6*stride] + ((Fd - Bdd ) >> 4)];
}
} else {
if(type==0){
ip[0*8] =
ip[1*8] =
ip[2*8] =
ip[3*8] =
ip[4*8] =
ip[5*8] =
ip[6*8] =
ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
}else if(type==1){
dst[0*stride]=
dst[1*stride]=
dst[2*stride]=
dst[3*stride]=
dst[4*stride]=
dst[5*stride]=
dst[6*stride]=
dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];
}else{
if(ip[0*8]){
int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
dst[0*stride] = cm[dst[0*stride] + v];
dst[1*stride] = cm[dst[1*stride] + v];
dst[2*stride] = cm[dst[2*stride] + v];
dst[3*stride] = cm[dst[3*stride] + v];
dst[4*stride] = cm[dst[4*stride] + v];
dst[5*stride] = cm[dst[5*stride] + v];
dst[6*stride] = cm[dst[6*stride] + v];
dst[7*stride] = cm[dst[7*stride] + v];
}
}
}
ip++; /* next column */
dst++;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
{
int16_t *ip = input;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
int Ed, Gd, Add, Bdd, Fd, Hd;
int i;
for (i = 0; i < 8; i++) {
if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {
A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
Ad = M(xC4S4, (A - C));
Bd = M(xC4S4, (B - D));
Cd = A + C;
Dd = B + D;
E = M(xC4S4, (ip[0] + ip[4]));
F = M(xC4S4, (ip[0] - ip[4]));
G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
Ed = E - G;
Gd = E + G;
Add = F + Ad;
Bdd = Bd - H;
Fd = F - Ad;
Hd = Bd + H;
ip[0] = Gd + Cd ;
ip[7] = Gd - Cd ;
ip[1] = Add + Hd;
ip[2] = Add - Hd;
ip[3] = Ed + Dd ;
ip[4] = Ed - Dd ;
ip[5] = Fd + Bdd;
ip[6] = Fd - Bdd;
}
ip += 8;
}
ip = input;
for ( i = 0; i < 8; i++) {
if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
A = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]);
B = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]);
C = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]);
D = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]);
Ad = M(xC4S4, (A - C));
Bd = M(xC4S4, (B - D));
Cd = A + C;
Dd = B + D;
E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;
F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;
if(type==1){
E += 16*128;
F += 16*128;
}
G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);
H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);
Ed = E - G;
Gd = E + G;
Add = F + Ad;
Bdd = Bd - H;
Fd = F - Ad;
Hd = Bd + H;
if(type==0){
ip[0*8] = (Gd + Cd ) >> 4;
ip[7*8] = (Gd - Cd ) >> 4;
ip[1*8] = (Add + Hd ) >> 4;
ip[2*8] = (Add - Hd ) >> 4;
ip[3*8] = (Ed + Dd ) >> 4;
ip[4*8] = (Ed - Dd ) >> 4;
ip[5*8] = (Fd + Bdd ) >> 4;
ip[6*8] = (Fd - Bdd ) >> 4;
}else if(type==1){
dst[0*stride] = cm[(Gd + Cd ) >> 4];
dst[7*stride] = cm[(Gd - Cd ) >> 4];
dst[1*stride] = cm[(Add + Hd ) >> 4];
dst[2*stride] = cm[(Add - Hd ) >> 4];
dst[3*stride] = cm[(Ed + Dd ) >> 4];
dst[4*stride] = cm[(Ed - Dd ) >> 4];
dst[5*stride] = cm[(Fd + Bdd ) >> 4];
dst[6*stride] = cm[(Fd - Bdd ) >> 4];
}else{
dst[0*stride] = cm[dst[0*stride] + ((Gd + Cd ) >> 4)];
dst[7*stride] = cm[dst[7*stride] + ((Gd - Cd ) >> 4)];
dst[1*stride] = cm[dst[1*stride] + ((Add + Hd ) >> 4)];
dst[2*stride] = cm[dst[2*stride] + ((Add - Hd ) >> 4)];
dst[3*stride] = cm[dst[3*stride] + ((Ed + Dd ) >> 4)];
dst[4*stride] = cm[dst[4*stride] + ((Ed - Dd ) >> 4)];
dst[5*stride] = cm[dst[5*stride] + ((Fd + Bdd ) >> 4)];
dst[6*stride] = cm[dst[6*stride] + ((Fd - Bdd ) >> 4)];
}
} else {
if(type==0){
ip[0*8] =
ip[1*8] =
ip[2*8] =
ip[3*8] =
ip[4*8] =
ip[5*8] =
ip[6*8] =
ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
}else if(type==1){
dst[0*stride]=
dst[1*stride]=
dst[2*stride]=
dst[3*stride]=
dst[4*stride]=
dst[5*stride]=
dst[6*stride]=
dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];
}else{
if(ip[0*8]){
int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
dst[0*stride] = cm[dst[0*stride] + v];
dst[1*stride] = cm[dst[1*stride] + v];
dst[2*stride] = cm[dst[2*stride] + v];
dst[3*stride] = cm[dst[3*stride] + v];
dst[4*stride] = cm[dst[4*stride] + v];
dst[5*stride] = cm[dst[5*stride] + v];
dst[6*stride] = cm[dst[6*stride] + v];
dst[7*stride] = cm[dst[7*stride] + v];
}
}
}
ip++;
dst++;
}
}
| {
"code": [
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" dst[0*stride] = cm[(Gd + Cd ) >> 4];",
" dst[7*stride] = cm[(Gd - Cd ) >> 4];",
" dst[1*stride] = cm[(Add + Hd ) >> 4];",
" dst[2*stride] = cm[(Add - Hd ) >> 4];",
" dst[3*stride] = cm[(Ed + Dd ) >> 4];",
" dst[4*stride] = cm[(Ed - Dd ) >> 4];",
" dst[5*stride] = cm[(Fd + Bdd ) >> 4];",
" dst[6*stride] = cm[(Fd - Bdd ) >> 4];",
" dst[0*stride] = cm[dst[0*stride] + ((Gd + Cd ) >> 4)];",
" dst[7*stride] = cm[dst[7*stride] + ((Gd - Cd ) >> 4)];",
" dst[1*stride] = cm[dst[1*stride] + ((Add + Hd ) >> 4)];",
" dst[2*stride] = cm[dst[2*stride] + ((Add - Hd ) >> 4)];",
" dst[3*stride] = cm[dst[3*stride] + ((Ed + Dd ) >> 4)];",
" dst[4*stride] = cm[dst[4*stride] + ((Ed - Dd ) >> 4)];",
" dst[5*stride] = cm[dst[5*stride] + ((Fd + Bdd ) >> 4)];",
" dst[6*stride] = cm[dst[6*stride] + ((Fd - Bdd ) >> 4)];",
" dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];",
" dst[0*stride] = cm[dst[0*stride] + v];",
" dst[1*stride] = cm[dst[1*stride] + v];",
" dst[2*stride] = cm[dst[2*stride] + v];",
" dst[3*stride] = cm[dst[3*stride] + v];",
" dst[4*stride] = cm[dst[4*stride] + v];",
" dst[5*stride] = cm[dst[5*stride] + v];",
" dst[6*stride] = cm[dst[6*stride] + v];",
" dst[7*stride] = cm[dst[7*stride] + v];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
219,
221,
225,
227,
231,
233,
237,
239,
243,
245,
249,
251,
255,
257,
261,
263,
305,
313,
315,
317,
319,
321,
323,
325,
327,
7
]
} | static av_always_inline void FUNC_0(uint8_t *dst, int stride, int16_t *input, int type)
{
int16_t *ip = input;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;
int VAR_18;
for (VAR_18 = 0; VAR_18 < 8; VAR_18++) {
if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {
VAR_0 = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
VAR_1 = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
VAR_2 = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
VAR_3 = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
VAR_4 = M(xC4S4, (VAR_0 - VAR_2));
VAR_5 = M(xC4S4, (VAR_1 - VAR_3));
VAR_6 = VAR_0 + VAR_2;
VAR_7 = VAR_1 + VAR_3;
VAR_8 = M(xC4S4, (ip[0] + ip[4]));
VAR_9 = M(xC4S4, (ip[0] - ip[4]));
VAR_10 = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
VAR_11 = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
VAR_12 = VAR_8 - VAR_10;
VAR_13 = VAR_8 + VAR_10;
VAR_14 = VAR_9 + VAR_4;
VAR_15 = VAR_5 - VAR_11;
VAR_16 = VAR_9 - VAR_4;
VAR_17 = VAR_5 + VAR_11;
ip[0] = VAR_13 + VAR_6 ;
ip[7] = VAR_13 - VAR_6 ;
ip[1] = VAR_14 + VAR_17;
ip[2] = VAR_14 - VAR_17;
ip[3] = VAR_12 + VAR_7 ;
ip[4] = VAR_12 - VAR_7 ;
ip[5] = VAR_16 + VAR_15;
ip[6] = VAR_16 - VAR_15;
}
ip += 8;
}
ip = input;
for ( VAR_18 = 0; VAR_18 < 8; VAR_18++) {
if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
VAR_0 = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]);
VAR_1 = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]);
VAR_2 = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]);
VAR_3 = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]);
VAR_4 = M(xC4S4, (VAR_0 - VAR_2));
VAR_5 = M(xC4S4, (VAR_1 - VAR_3));
VAR_6 = VAR_0 + VAR_2;
VAR_7 = VAR_1 + VAR_3;
VAR_8 = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;
VAR_9 = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;
if(type==1){
VAR_8 += 16*128;
VAR_9 += 16*128;
}
VAR_10 = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);
VAR_11 = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);
VAR_12 = VAR_8 - VAR_10;
VAR_13 = VAR_8 + VAR_10;
VAR_14 = VAR_9 + VAR_4;
VAR_15 = VAR_5 - VAR_11;
VAR_16 = VAR_9 - VAR_4;
VAR_17 = VAR_5 + VAR_11;
if(type==0){
ip[0*8] = (VAR_13 + VAR_6 ) >> 4;
ip[7*8] = (VAR_13 - VAR_6 ) >> 4;
ip[1*8] = (VAR_14 + VAR_17 ) >> 4;
ip[2*8] = (VAR_14 - VAR_17 ) >> 4;
ip[3*8] = (VAR_12 + VAR_7 ) >> 4;
ip[4*8] = (VAR_12 - VAR_7 ) >> 4;
ip[5*8] = (VAR_16 + VAR_15 ) >> 4;
ip[6*8] = (VAR_16 - VAR_15 ) >> 4;
}else if(type==1){
dst[0*stride] = cm[(VAR_13 + VAR_6 ) >> 4];
dst[7*stride] = cm[(VAR_13 - VAR_6 ) >> 4];
dst[1*stride] = cm[(VAR_14 + VAR_17 ) >> 4];
dst[2*stride] = cm[(VAR_14 - VAR_17 ) >> 4];
dst[3*stride] = cm[(VAR_12 + VAR_7 ) >> 4];
dst[4*stride] = cm[(VAR_12 - VAR_7 ) >> 4];
dst[5*stride] = cm[(VAR_16 + VAR_15 ) >> 4];
dst[6*stride] = cm[(VAR_16 - VAR_15 ) >> 4];
}else{
dst[0*stride] = cm[dst[0*stride] + ((VAR_13 + VAR_6 ) >> 4)];
dst[7*stride] = cm[dst[7*stride] + ((VAR_13 - VAR_6 ) >> 4)];
dst[1*stride] = cm[dst[1*stride] + ((VAR_14 + VAR_17 ) >> 4)];
dst[2*stride] = cm[dst[2*stride] + ((VAR_14 - VAR_17 ) >> 4)];
dst[3*stride] = cm[dst[3*stride] + ((VAR_12 + VAR_7 ) >> 4)];
dst[4*stride] = cm[dst[4*stride] + ((VAR_12 - VAR_7 ) >> 4)];
dst[5*stride] = cm[dst[5*stride] + ((VAR_16 + VAR_15 ) >> 4)];
dst[6*stride] = cm[dst[6*stride] + ((VAR_16 - VAR_15 ) >> 4)];
}
} else {
if(type==0){
ip[0*8] =
ip[1*8] =
ip[2*8] =
ip[3*8] =
ip[4*8] =
ip[5*8] =
ip[6*8] =
ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
}else if(type==1){
dst[0*stride]=
dst[1*stride]=
dst[2*stride]=
dst[3*stride]=
dst[4*stride]=
dst[5*stride]=
dst[6*stride]=
dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];
}else{
if(ip[0*8]){
int VAR_19= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
dst[0*stride] = cm[dst[0*stride] + VAR_19];
dst[1*stride] = cm[dst[1*stride] + VAR_19];
dst[2*stride] = cm[dst[2*stride] + VAR_19];
dst[3*stride] = cm[dst[3*stride] + VAR_19];
dst[4*stride] = cm[dst[4*stride] + VAR_19];
dst[5*stride] = cm[dst[5*stride] + VAR_19];
dst[6*stride] = cm[dst[6*stride] + VAR_19];
dst[7*stride] = cm[dst[7*stride] + VAR_19];
}
}
}
ip++;
dst++;
}
}
| [
"static av_always_inline void FUNC_0(uint8_t *dst, int stride, int16_t *input, int type)\n{",
"int16_t *ip = input;",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;",
"int VAR_18;",
"for (VAR_18 = 0; VAR_18 < 8; VAR_18++) {",
"if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {",
"VAR_0 = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);",
"VAR_1 = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);",
"VAR_2 = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);",
"VAR_3 = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);",
"VAR_4 = M(xC4S4, (VAR_0 - VAR_2));",
"VAR_5 = M(xC4S4, (VAR_1 - VAR_3));",
"VAR_6 = VAR_0 + VAR_2;",
"VAR_7 = VAR_1 + VAR_3;",
"VAR_8 = M(xC4S4, (ip[0] + ip[4]));",
"VAR_9 = M(xC4S4, (ip[0] - ip[4]));",
"VAR_10 = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);",
"VAR_11 = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);",
"VAR_12 = VAR_8 - VAR_10;",
"VAR_13 = VAR_8 + VAR_10;",
"VAR_14 = VAR_9 + VAR_4;",
"VAR_15 = VAR_5 - VAR_11;",
"VAR_16 = VAR_9 - VAR_4;",
"VAR_17 = VAR_5 + VAR_11;",
"ip[0] = VAR_13 + VAR_6 ;",
"ip[7] = VAR_13 - VAR_6 ;",
"ip[1] = VAR_14 + VAR_17;",
"ip[2] = VAR_14 - VAR_17;",
"ip[3] = VAR_12 + VAR_7 ;",
"ip[4] = VAR_12 - VAR_7 ;",
"ip[5] = VAR_16 + VAR_15;",
"ip[6] = VAR_16 - VAR_15;",
"}",
"ip += 8;",
"}",
"ip = input;",
"for ( VAR_18 = 0; VAR_18 < 8; VAR_18++) {",
"if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |\nip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {",
"VAR_0 = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]);",
"VAR_1 = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]);",
"VAR_2 = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]);",
"VAR_3 = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]);",
"VAR_4 = M(xC4S4, (VAR_0 - VAR_2));",
"VAR_5 = M(xC4S4, (VAR_1 - VAR_3));",
"VAR_6 = VAR_0 + VAR_2;",
"VAR_7 = VAR_1 + VAR_3;",
"VAR_8 = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;",
"VAR_9 = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;",
"if(type==1){",
"VAR_8 += 16*128;",
"VAR_9 += 16*128;",
"}",
"VAR_10 = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);",
"VAR_11 = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);",
"VAR_12 = VAR_8 - VAR_10;",
"VAR_13 = VAR_8 + VAR_10;",
"VAR_14 = VAR_9 + VAR_4;",
"VAR_15 = VAR_5 - VAR_11;",
"VAR_16 = VAR_9 - VAR_4;",
"VAR_17 = VAR_5 + VAR_11;",
"if(type==0){",
"ip[0*8] = (VAR_13 + VAR_6 ) >> 4;",
"ip[7*8] = (VAR_13 - VAR_6 ) >> 4;",
"ip[1*8] = (VAR_14 + VAR_17 ) >> 4;",
"ip[2*8] = (VAR_14 - VAR_17 ) >> 4;",
"ip[3*8] = (VAR_12 + VAR_7 ) >> 4;",
"ip[4*8] = (VAR_12 - VAR_7 ) >> 4;",
"ip[5*8] = (VAR_16 + VAR_15 ) >> 4;",
"ip[6*8] = (VAR_16 - VAR_15 ) >> 4;",
"}else if(type==1){",
"dst[0*stride] = cm[(VAR_13 + VAR_6 ) >> 4];",
"dst[7*stride] = cm[(VAR_13 - VAR_6 ) >> 4];",
"dst[1*stride] = cm[(VAR_14 + VAR_17 ) >> 4];",
"dst[2*stride] = cm[(VAR_14 - VAR_17 ) >> 4];",
"dst[3*stride] = cm[(VAR_12 + VAR_7 ) >> 4];",
"dst[4*stride] = cm[(VAR_12 - VAR_7 ) >> 4];",
"dst[5*stride] = cm[(VAR_16 + VAR_15 ) >> 4];",
"dst[6*stride] = cm[(VAR_16 - VAR_15 ) >> 4];",
"}else{",
"dst[0*stride] = cm[dst[0*stride] + ((VAR_13 + VAR_6 ) >> 4)];",
"dst[7*stride] = cm[dst[7*stride] + ((VAR_13 - VAR_6 ) >> 4)];",
"dst[1*stride] = cm[dst[1*stride] + ((VAR_14 + VAR_17 ) >> 4)];",
"dst[2*stride] = cm[dst[2*stride] + ((VAR_14 - VAR_17 ) >> 4)];",
"dst[3*stride] = cm[dst[3*stride] + ((VAR_12 + VAR_7 ) >> 4)];",
"dst[4*stride] = cm[dst[4*stride] + ((VAR_12 - VAR_7 ) >> 4)];",
"dst[5*stride] = cm[dst[5*stride] + ((VAR_16 + VAR_15 ) >> 4)];",
"dst[6*stride] = cm[dst[6*stride] + ((VAR_16 - VAR_15 ) >> 4)];",
"}",
"} else {",
"if(type==0){",
"ip[0*8] =\nip[1*8] =\nip[2*8] =\nip[3*8] =\nip[4*8] =\nip[5*8] =\nip[6*8] =\nip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);",
"}else if(type==1){",
"dst[0*stride]=\ndst[1*stride]=\ndst[2*stride]=\ndst[3*stride]=\ndst[4*stride]=\ndst[5*stride]=\ndst[6*stride]=\ndst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];",
"}else{",
"if(ip[0*8]){",
"int VAR_19= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);",
"dst[0*stride] = cm[dst[0*stride] + VAR_19];",
"dst[1*stride] = cm[dst[1*stride] + VAR_19];",
"dst[2*stride] = cm[dst[2*stride] + VAR_19];",
"dst[3*stride] = cm[dst[3*stride] + VAR_19];",
"dst[4*stride] = cm[dst[4*stride] + VAR_19];",
"dst[5*stride] = cm[dst[5*stride] + VAR_19];",
"dst[6*stride] = cm[dst[6*stride] + VAR_19];",
"dst[7*stride] = cm[dst[7*stride] + VAR_19];",
"}",
"}",
"}",
"ip++;",
"dst++;",
"}",
"}"
]
| [
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,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
115
],
[
119
],
[
123,
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
173
],
[
175
],
[
179
],
[
181
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273,
275,
277,
279,
281,
283,
285,
287
],
[
289
],
[
291,
293,
295,
297,
299,
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
343
]
]
|
13,021 | static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
QdrawContext * const a = avctx->priv_data;
AVFrame * const p= (AVFrame*)&a->pic;
uint8_t* outdata;
int colors;
int i;
uint32_t *pal;
int r, g, b;
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
outdata = a->pic.data[0];
if (buf_end - buf < 0x68 + 4)
buf += 0x68; /* jump to palette */
colors = AV_RB32(buf);
buf += 4;
if(colors < 0 || colors > 256) {
av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors);
return -1;
}
if (buf_end - buf < (colors + 1) * 8)
pal = (uint32_t*)p->data[1];
for (i = 0; i <= colors; i++) {
unsigned int idx;
idx = AV_RB16(buf); /* color index */
buf += 2;
if (idx > 255) {
av_log(avctx, AV_LOG_ERROR, "Palette index out of range: %u\n", idx);
buf += 6;
continue;
}
r = *buf++;
buf++;
g = *buf++;
buf++;
b = *buf++;
buf++;
pal[idx] = (r << 16) | (g << 8) | b;
}
p->palette_has_changed = 1;
if (buf_end - buf < 18)
buf += 18; /* skip unneeded data */
for (i = 0; i < avctx->height; i++) {
int size, left, code, pix;
const uint8_t *next;
uint8_t *out;
int tsize = 0;
/* decode line */
out = outdata;
size = AV_RB16(buf); /* size of packed line */
buf += 2;
left = size;
next = buf + size;
while (left > 0) {
code = *buf++;
if (code & 0x80 ) { /* run */
pix = *buf++;
if ((out + (257 - code)) > (outdata + a->pic.linesize[0]))
break;
memset(out, pix, 257 - code);
out += 257 - code;
tsize += 257 - code;
left -= 2;
} else { /* copy */
if ((out + code) > (outdata + a->pic.linesize[0]))
break;
if (buf_end - buf < code + 1)
memcpy(out, buf, code + 1);
out += code + 1;
buf += code + 1;
left -= 2 + code;
tsize += code + 1;
}
}
buf = next;
outdata += a->pic.linesize[0];
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = a->pic;
return buf_size;
} | true | FFmpeg | 44e2f0c3cd2df68659e07ed3d5eab4974794eb33 | static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
QdrawContext * const a = avctx->priv_data;
AVFrame * const p= (AVFrame*)&a->pic;
uint8_t* outdata;
int colors;
int i;
uint32_t *pal;
int r, g, b;
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
outdata = a->pic.data[0];
if (buf_end - buf < 0x68 + 4)
buf += 0x68;
colors = AV_RB32(buf);
buf += 4;
if(colors < 0 || colors > 256) {
av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors);
return -1;
}
if (buf_end - buf < (colors + 1) * 8)
pal = (uint32_t*)p->data[1];
for (i = 0; i <= colors; i++) {
unsigned int idx;
idx = AV_RB16(buf);
buf += 2;
if (idx > 255) {
av_log(avctx, AV_LOG_ERROR, "Palette index out of range: %u\n", idx);
buf += 6;
continue;
}
r = *buf++;
buf++;
g = *buf++;
buf++;
b = *buf++;
buf++;
pal[idx] = (r << 16) | (g << 8) | b;
}
p->palette_has_changed = 1;
if (buf_end - buf < 18)
buf += 18;
for (i = 0; i < avctx->height; i++) {
int size, left, code, pix;
const uint8_t *next;
uint8_t *out;
int tsize = 0;
out = outdata;
size = AV_RB16(buf);
buf += 2;
left = size;
next = buf + size;
while (left > 0) {
code = *buf++;
if (code & 0x80 ) {
pix = *buf++;
if ((out + (257 - code)) > (outdata + a->pic.linesize[0]))
break;
memset(out, pix, 257 - code);
out += 257 - code;
tsize += 257 - code;
left -= 2;
} else {
if ((out + code) > (outdata + a->pic.linesize[0]))
break;
if (buf_end - buf < code + 1)
memcpy(out, buf, code + 1);
out += code + 1;
buf += code + 1;
left -= 2 + code;
tsize += code + 1;
}
}
buf = next;
outdata += a->pic.linesize[0];
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = a->pic;
return buf_size;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;
int VAR_6 = VAR_3->size;
QdrawContext * const a = VAR_0->priv_data;
AVFrame * const p= (AVFrame*)&a->pic;
uint8_t* outdata;
int VAR_7;
int VAR_8;
uint32_t *pal;
int VAR_9, VAR_10, VAR_11;
if(p->VAR_1[0])
VAR_0->release_buffer(VAR_0, p);
p->reference= 0;
if(VAR_0->get_buffer(VAR_0, p) < 0){
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
outdata = a->pic.VAR_1[0];
if (VAR_5 - VAR_4 < 0x68 + 4)
VAR_4 += 0x68;
VAR_7 = AV_RB32(VAR_4);
VAR_4 += 4;
if(VAR_7 < 0 || VAR_7 > 256) {
av_log(VAR_0, AV_LOG_ERROR, "Error color count - %VAR_8(0x%X)\n", VAR_7, VAR_7);
return -1;
}
if (VAR_5 - VAR_4 < (VAR_7 + 1) * 8)
pal = (uint32_t*)p->VAR_1[1];
for (VAR_8 = 0; VAR_8 <= VAR_7; VAR_8++) {
unsigned int VAR_12;
VAR_12 = AV_RB16(VAR_4);
VAR_4 += 2;
if (VAR_12 > 255) {
av_log(VAR_0, AV_LOG_ERROR, "Palette index out of range: %u\n", VAR_12);
VAR_4 += 6;
continue;
}
VAR_9 = *VAR_4++;
VAR_4++;
VAR_10 = *VAR_4++;
VAR_4++;
VAR_11 = *VAR_4++;
VAR_4++;
pal[VAR_12] = (VAR_9 << 16) | (VAR_10 << 8) | VAR_11;
}
p->palette_has_changed = 1;
if (VAR_5 - VAR_4 < 18)
VAR_4 += 18;
for (VAR_8 = 0; VAR_8 < VAR_0->height; VAR_8++) {
int size, left, code, pix;
const uint8_t *next;
uint8_t *out;
int tsize = 0;
out = outdata;
size = AV_RB16(VAR_4);
VAR_4 += 2;
left = size;
next = VAR_4 + size;
while (left > 0) {
code = *VAR_4++;
if (code & 0x80 ) {
pix = *VAR_4++;
if ((out + (257 - code)) > (outdata + a->pic.linesize[0]))
break;
memset(out, pix, 257 - code);
out += 257 - code;
tsize += 257 - code;
left -= 2;
} else {
if ((out + code) > (outdata + a->pic.linesize[0]))
break;
if (VAR_5 - VAR_4 < code + 1)
memcpy(out, VAR_4, code + 1);
out += code + 1;
VAR_4 += code + 1;
left -= 2 + code;
tsize += code + 1;
}
}
VAR_4 = next;
outdata += a->pic.linesize[0];
}
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1 = a->pic;
return VAR_6;
} | [
"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;",
"const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;",
"int VAR_6 = VAR_3->size;",
"QdrawContext * const a = VAR_0->priv_data;",
"AVFrame * const p= (AVFrame*)&a->pic;",
"uint8_t* outdata;",
"int VAR_7;",
"int VAR_8;",
"uint32_t *pal;",
"int VAR_9, VAR_10, VAR_11;",
"if(p->VAR_1[0])\nVAR_0->release_buffer(VAR_0, p);",
"p->reference= 0;",
"if(VAR_0->get_buffer(VAR_0, p) < 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"p->pict_type= AV_PICTURE_TYPE_I;",
"p->key_frame= 1;",
"outdata = a->pic.VAR_1[0];",
"if (VAR_5 - VAR_4 < 0x68 + 4)\nVAR_4 += 0x68;",
"VAR_7 = AV_RB32(VAR_4);",
"VAR_4 += 4;",
"if(VAR_7 < 0 || VAR_7 > 256) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error color count - %VAR_8(0x%X)\\n\", VAR_7, VAR_7);",
"return -1;",
"}",
"if (VAR_5 - VAR_4 < (VAR_7 + 1) * 8)\npal = (uint32_t*)p->VAR_1[1];",
"for (VAR_8 = 0; VAR_8 <= VAR_7; VAR_8++) {",
"unsigned int VAR_12;",
"VAR_12 = AV_RB16(VAR_4);",
"VAR_4 += 2;",
"if (VAR_12 > 255) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Palette index out of range: %u\\n\", VAR_12);",
"VAR_4 += 6;",
"continue;",
"}",
"VAR_9 = *VAR_4++;",
"VAR_4++;",
"VAR_10 = *VAR_4++;",
"VAR_4++;",
"VAR_11 = *VAR_4++;",
"VAR_4++;",
"pal[VAR_12] = (VAR_9 << 16) | (VAR_10 << 8) | VAR_11;",
"}",
"p->palette_has_changed = 1;",
"if (VAR_5 - VAR_4 < 18)\nVAR_4 += 18;",
"for (VAR_8 = 0; VAR_8 < VAR_0->height; VAR_8++) {",
"int size, left, code, pix;",
"const uint8_t *next;",
"uint8_t *out;",
"int tsize = 0;",
"out = outdata;",
"size = AV_RB16(VAR_4);",
"VAR_4 += 2;",
"left = size;",
"next = VAR_4 + size;",
"while (left > 0) {",
"code = *VAR_4++;",
"if (code & 0x80 ) {",
"pix = *VAR_4++;",
"if ((out + (257 - code)) > (outdata + a->pic.linesize[0]))\nbreak;",
"memset(out, pix, 257 - code);",
"out += 257 - code;",
"tsize += 257 - code;",
"left -= 2;",
"} else {",
"if ((out + code) > (outdata + a->pic.linesize[0]))\nbreak;",
"if (VAR_5 - VAR_4 < code + 1)\nmemcpy(out, VAR_4, code + 1);",
"out += code + 1;",
"VAR_4 += code + 1;",
"left -= 2 + code;",
"tsize += code + 1;",
"}",
"}",
"VAR_4 = next;",
"outdata += a->pic.linesize[0];",
"}",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1 = a->pic;",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15,
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25,
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33,
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53,
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
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
]
]
|
13,022 | static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
const char *name, int restricted,
const char *vnetwork, const char *vhost,
const char *vhostname, const char *tftp_export,
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *smb_export,
const char *vsmbserver)
{
/* default settings according to historic slirp */
struct in_addr net = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
struct in_addr mask = { .s_addr = htonl(0xffffff00) }; /* 255.255.255.0 */
struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
struct in_addr dns = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
#ifndef _WIN32
struct in_addr smbsrv = { .s_addr = 0 };
#endif
SlirpState *s;
char buf[20];
uint32_t addr;
int shift;
char *end;
struct slirp_config_str *config;
if (!tftp_export) {
tftp_export = legacy_tftp_prefix;
}
if (!bootfile) {
bootfile = legacy_bootp_filename;
}
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
return -1;
}
addr = ntohl(net.s_addr);
if (!(addr & 0x80000000)) {
mask.s_addr = htonl(0xff000000); /* class A */
} else if ((addr & 0xfff00000) == 0xac100000) {
mask.s_addr = htonl(0xfff00000); /* priv. 172.16.0.0/12 */
} else if ((addr & 0xc0000000) == 0x80000000) {
mask.s_addr = htonl(0xffff0000); /* class B */
} else if ((addr & 0xffff0000) == 0xc0a80000) {
mask.s_addr = htonl(0xffff0000); /* priv. 192.168.0.0/16 */
} else if ((addr & 0xffff0000) == 0xc6120000) {
mask.s_addr = htonl(0xfffe0000); /* tests 198.18.0.0/15 */
} else if ((addr & 0xe0000000) == 0xe0000000) {
mask.s_addr = htonl(0xffffff00); /* class C */
} else {
mask.s_addr = htonl(0xfffffff0); /* multicast/reserved */
}
} else {
if (!inet_aton(buf, &net)) {
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
return -1;
}
} else if (shift < 4 || shift > 32) {
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
}
}
net.s_addr &= mask.s_addr;
host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);
dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);
dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);
}
if (vhost && !inet_aton(vhost, &host)) {
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
return -1;
}
if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
return -1;
}
if ((dns.s_addr & mask.s_addr) != net.s_addr ||
dns.s_addr == host.s_addr) {
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
return -1;
}
#endif
s = qemu_mallocz(sizeof(SlirpState));
s->slirp = slirp_init(restricted, net, mask, host, vhostname,
tftp_export, bootfile, dhcp, dns, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
slirp_hostfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
} else {
slirp_guestfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
}
}
#ifndef _WIN32
if (!smb_export) {
smb_export = legacy_smb_export;
}
if (smb_export) {
slirp_smb(s, mon, smb_export, smbsrv);
}
#endif
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
net_slirp_cleanup, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
return 0;
}
| true | qemu | 0752706de257b38763006ff5bb6b39a97e669ba2 | static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
const char *name, int restricted,
const char *vnetwork, const char *vhost,
const char *vhostname, const char *tftp_export,
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *smb_export,
const char *vsmbserver)
{
struct in_addr net = { .s_addr = htonl(0x0a000200) };
struct in_addr mask = { .s_addr = htonl(0xffffff00) };
struct in_addr host = { .s_addr = htonl(0x0a000202) };
struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) };
struct in_addr dns = { .s_addr = htonl(0x0a000203) };
#ifndef _WIN32
struct in_addr smbsrv = { .s_addr = 0 };
#endif
SlirpState *s;
char buf[20];
uint32_t addr;
int shift;
char *end;
struct slirp_config_str *config;
if (!tftp_export) {
tftp_export = legacy_tftp_prefix;
}
if (!bootfile) {
bootfile = legacy_bootp_filename;
}
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
return -1;
}
addr = ntohl(net.s_addr);
if (!(addr & 0x80000000)) {
mask.s_addr = htonl(0xff000000);
} else if ((addr & 0xfff00000) == 0xac100000) {
mask.s_addr = htonl(0xfff00000);
} else if ((addr & 0xc0000000) == 0x80000000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc0a80000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc6120000) {
mask.s_addr = htonl(0xfffe0000);
} else if ((addr & 0xe0000000) == 0xe0000000) {
mask.s_addr = htonl(0xffffff00);
} else {
mask.s_addr = htonl(0xfffffff0);
}
} else {
if (!inet_aton(buf, &net)) {
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
return -1;
}
} else if (shift < 4 || shift > 32) {
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
}
}
net.s_addr &= mask.s_addr;
host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);
dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);
dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);
}
if (vhost && !inet_aton(vhost, &host)) {
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
return -1;
}
if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
return -1;
}
if ((dns.s_addr & mask.s_addr) != net.s_addr ||
dns.s_addr == host.s_addr) {
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
return -1;
}
#endif
s = qemu_mallocz(sizeof(SlirpState));
s->slirp = slirp_init(restricted, net, mask, host, vhostname,
tftp_export, bootfile, dhcp, dns, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
slirp_hostfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
} else {
slirp_guestfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
}
}
#ifndef _WIN32
if (!smb_export) {
smb_export = legacy_smb_export;
}
if (smb_export) {
slirp_smb(s, mon, smb_export, smbsrv);
}
#endif
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
net_slirp_cleanup, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
return 0;
}
| {
"code": [
" slirp_hostfwd(s, mon, config->str,",
" config->flags & SLIRP_CFG_LEGACY);",
" slirp_guestfwd(s, mon, config->str,",
" config->flags & SLIRP_CFG_LEGACY);",
" slirp_smb(s, mon, smb_export, smbsrv);"
],
"line_no": [
219,
221,
225,
227,
243
]
} | static int FUNC_0(Monitor *VAR_0, VLANState *VAR_1, const char *VAR_2,
const char *VAR_3, int VAR_4,
const char *VAR_5, const char *VAR_6,
const char *VAR_7, const char *VAR_8,
const char *VAR_9, const char *VAR_10,
const char *VAR_11, const char *VAR_12,
const char *VAR_13)
{
struct in_addr VAR_14 = { .s_addr = htonl(0x0a000200) };
struct in_addr VAR_15 = { .s_addr = htonl(0xffffff00) };
struct in_addr VAR_16 = { .s_addr = htonl(0x0a000202) };
struct in_addr VAR_17 = { .s_addr = htonl(0x0a00020f) };
struct in_addr VAR_18 = { .s_addr = htonl(0x0a000203) };
#ifndef _WIN32
struct in_addr VAR_19 = { .s_addr = 0 };
#endif
SlirpState *s;
char VAR_20[20];
uint32_t addr;
int VAR_21;
char *VAR_22;
struct slirp_config_str *VAR_23;
if (!VAR_8) {
VAR_8 = legacy_tftp_prefix;
}
if (!VAR_9) {
VAR_9 = legacy_bootp_filename;
}
if (VAR_5) {
if (get_str_sep(VAR_20, sizeof(VAR_20), &VAR_5, '/') < 0) {
if (!inet_aton(VAR_5, &VAR_14)) {
return -1;
}
addr = ntohl(VAR_14.s_addr);
if (!(addr & 0x80000000)) {
VAR_15.s_addr = htonl(0xff000000);
} else if ((addr & 0xfff00000) == 0xac100000) {
VAR_15.s_addr = htonl(0xfff00000);
} else if ((addr & 0xc0000000) == 0x80000000) {
VAR_15.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc0a80000) {
VAR_15.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc6120000) {
VAR_15.s_addr = htonl(0xfffe0000);
} else if ((addr & 0xe0000000) == 0xe0000000) {
VAR_15.s_addr = htonl(0xffffff00);
} else {
VAR_15.s_addr = htonl(0xfffffff0);
}
} else {
if (!inet_aton(VAR_20, &VAR_14)) {
return -1;
}
VAR_21 = strtol(VAR_5, &VAR_22, 10);
if (*VAR_22 != '\0') {
if (!inet_aton(VAR_5, &VAR_15)) {
return -1;
}
} else if (VAR_21 < 4 || VAR_21 > 32) {
return -1;
} else {
VAR_15.s_addr = htonl(0xffffffff << (32 - VAR_21));
}
}
VAR_14.s_addr &= VAR_15.s_addr;
VAR_16.s_addr = VAR_14.s_addr | (htonl(0x0202) & ~VAR_15.s_addr);
VAR_17.s_addr = VAR_14.s_addr | (htonl(0x020f) & ~VAR_15.s_addr);
VAR_18.s_addr = VAR_14.s_addr | (htonl(0x0203) & ~VAR_15.s_addr);
}
if (VAR_6 && !inet_aton(VAR_6, &VAR_16)) {
return -1;
}
if ((VAR_16.s_addr & VAR_15.s_addr) != VAR_14.s_addr) {
return -1;
}
if (VAR_10 && !inet_aton(VAR_10, &VAR_17)) {
return -1;
}
if ((VAR_17.s_addr & VAR_15.s_addr) != VAR_14.s_addr ||
VAR_17.s_addr == VAR_16.s_addr || VAR_17.s_addr == VAR_18.s_addr) {
return -1;
}
if (VAR_11 && !inet_aton(VAR_11, &VAR_18)) {
return -1;
}
if ((VAR_18.s_addr & VAR_15.s_addr) != VAR_14.s_addr ||
VAR_18.s_addr == VAR_16.s_addr) {
return -1;
}
#ifndef _WIN32
if (VAR_13 && !inet_aton(VAR_13, &VAR_19)) {
return -1;
}
#endif
s = qemu_mallocz(sizeof(SlirpState));
s->slirp = slirp_init(VAR_4, VAR_14, VAR_15, VAR_16, VAR_7,
VAR_8, VAR_9, VAR_17, VAR_18, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
for (VAR_23 = slirp_configs; VAR_23; VAR_23 = VAR_23->next) {
if (VAR_23->flags & SLIRP_CFG_HOSTFWD) {
slirp_hostfwd(s, VAR_0, VAR_23->str,
VAR_23->flags & SLIRP_CFG_LEGACY);
} else {
slirp_guestfwd(s, VAR_0, VAR_23->str,
VAR_23->flags & SLIRP_CFG_LEGACY);
}
}
#ifndef _WIN32
if (!VAR_12) {
VAR_12 = legacy_smb_export;
}
if (VAR_12) {
slirp_smb(s, VAR_0, VAR_12, VAR_19);
}
#endif
s->vc = qemu_new_vlan_client(VAR_1, VAR_2, VAR_3, NULL, slirp_receive, NULL,
net_slirp_cleanup, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"VAR_14=%s, VAR_4=%c", inet_ntoa(VAR_14), VAR_4 ? 'y' : 'n');
return 0;
}
| [
"static int FUNC_0(Monitor *VAR_0, VLANState *VAR_1, const char *VAR_2,\nconst char *VAR_3, int VAR_4,\nconst char *VAR_5, const char *VAR_6,\nconst char *VAR_7, const char *VAR_8,\nconst char *VAR_9, const char *VAR_10,\nconst char *VAR_11, const char *VAR_12,\nconst char *VAR_13)\n{",
"struct in_addr VAR_14 = { .s_addr = htonl(0x0a000200) };",
"struct in_addr VAR_15 = { .s_addr = htonl(0xffffff00) };",
"struct in_addr VAR_16 = { .s_addr = htonl(0x0a000202) };",
"struct in_addr VAR_17 = { .s_addr = htonl(0x0a00020f) };",
"struct in_addr VAR_18 = { .s_addr = htonl(0x0a000203) };",
"#ifndef _WIN32\nstruct in_addr VAR_19 = { .s_addr = 0 };",
"#endif\nSlirpState *s;",
"char VAR_20[20];",
"uint32_t addr;",
"int VAR_21;",
"char *VAR_22;",
"struct slirp_config_str *VAR_23;",
"if (!VAR_8) {",
"VAR_8 = legacy_tftp_prefix;",
"}",
"if (!VAR_9) {",
"VAR_9 = legacy_bootp_filename;",
"}",
"if (VAR_5) {",
"if (get_str_sep(VAR_20, sizeof(VAR_20), &VAR_5, '/') < 0) {",
"if (!inet_aton(VAR_5, &VAR_14)) {",
"return -1;",
"}",
"addr = ntohl(VAR_14.s_addr);",
"if (!(addr & 0x80000000)) {",
"VAR_15.s_addr = htonl(0xff000000);",
"} else if ((addr & 0xfff00000) == 0xac100000) {",
"VAR_15.s_addr = htonl(0xfff00000);",
"} else if ((addr & 0xc0000000) == 0x80000000) {",
"VAR_15.s_addr = htonl(0xffff0000);",
"} else if ((addr & 0xffff0000) == 0xc0a80000) {",
"VAR_15.s_addr = htonl(0xffff0000);",
"} else if ((addr & 0xffff0000) == 0xc6120000) {",
"VAR_15.s_addr = htonl(0xfffe0000);",
"} else if ((addr & 0xe0000000) == 0xe0000000) {",
"VAR_15.s_addr = htonl(0xffffff00);",
"} else {",
"VAR_15.s_addr = htonl(0xfffffff0);",
"}",
"} else {",
"if (!inet_aton(VAR_20, &VAR_14)) {",
"return -1;",
"}",
"VAR_21 = strtol(VAR_5, &VAR_22, 10);",
"if (*VAR_22 != '\\0') {",
"if (!inet_aton(VAR_5, &VAR_15)) {",
"return -1;",
"}",
"} else if (VAR_21 < 4 || VAR_21 > 32) {",
"return -1;",
"} else {",
"VAR_15.s_addr = htonl(0xffffffff << (32 - VAR_21));",
"}",
"}",
"VAR_14.s_addr &= VAR_15.s_addr;",
"VAR_16.s_addr = VAR_14.s_addr | (htonl(0x0202) & ~VAR_15.s_addr);",
"VAR_17.s_addr = VAR_14.s_addr | (htonl(0x020f) & ~VAR_15.s_addr);",
"VAR_18.s_addr = VAR_14.s_addr | (htonl(0x0203) & ~VAR_15.s_addr);",
"}",
"if (VAR_6 && !inet_aton(VAR_6, &VAR_16)) {",
"return -1;",
"}",
"if ((VAR_16.s_addr & VAR_15.s_addr) != VAR_14.s_addr) {",
"return -1;",
"}",
"if (VAR_10 && !inet_aton(VAR_10, &VAR_17)) {",
"return -1;",
"}",
"if ((VAR_17.s_addr & VAR_15.s_addr) != VAR_14.s_addr ||\nVAR_17.s_addr == VAR_16.s_addr || VAR_17.s_addr == VAR_18.s_addr) {",
"return -1;",
"}",
"if (VAR_11 && !inet_aton(VAR_11, &VAR_18)) {",
"return -1;",
"}",
"if ((VAR_18.s_addr & VAR_15.s_addr) != VAR_14.s_addr ||\nVAR_18.s_addr == VAR_16.s_addr) {",
"return -1;",
"}",
"#ifndef _WIN32\nif (VAR_13 && !inet_aton(VAR_13, &VAR_19)) {",
"return -1;",
"}",
"#endif\ns = qemu_mallocz(sizeof(SlirpState));",
"s->slirp = slirp_init(VAR_4, VAR_14, VAR_15, VAR_16, VAR_7,\nVAR_8, VAR_9, VAR_17, VAR_18, s);",
"QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);",
"for (VAR_23 = slirp_configs; VAR_23; VAR_23 = VAR_23->next) {",
"if (VAR_23->flags & SLIRP_CFG_HOSTFWD) {",
"slirp_hostfwd(s, VAR_0, VAR_23->str,\nVAR_23->flags & SLIRP_CFG_LEGACY);",
"} else {",
"slirp_guestfwd(s, VAR_0, VAR_23->str,\nVAR_23->flags & SLIRP_CFG_LEGACY);",
"}",
"}",
"#ifndef _WIN32\nif (!VAR_12) {",
"VAR_12 = legacy_smb_export;",
"}",
"if (VAR_12) {",
"slirp_smb(s, VAR_0, VAR_12, VAR_19);",
"}",
"#endif\ns->vc = qemu_new_vlan_client(VAR_1, VAR_2, VAR_3, NULL, slirp_receive, NULL,\nnet_slirp_cleanup, s);",
"snprintf(s->vc->info_str, sizeof(s->vc->info_str),\n\"VAR_14=%s, VAR_4=%c\", inet_ntoa(VAR_14), VAR_4 ? 'y' : 'n');",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
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
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
193,
195
],
[
197
],
[
199
],
[
201,
205
],
[
207,
209
],
[
211
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
251,
253
],
[
255,
257
],
[
259
],
[
261
]
]
|
13,023 | void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
{
QIOChannel *ioc;
const char *argv[] = { "/bin/sh", "-c", command, NULL };
trace_migration_exec_outgoing(command);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
O_WRONLY,
errp));
if (!ioc) {
return;
}
migration_set_outgoing_channel(s, ioc);
object_unref(OBJECT(ioc));
}
| true | qemu | e122636562218b3d442cd2cd18fbc188dd9ce709 | void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
{
QIOChannel *ioc;
const char *argv[] = { "/bin/sh", "-c", command, NULL };
trace_migration_exec_outgoing(command);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
O_WRONLY,
errp));
if (!ioc) {
return;
}
migration_set_outgoing_channel(s, ioc);
object_unref(OBJECT(ioc));
}
| {
"code": [
" migration_set_outgoing_channel(s, ioc);",
" migration_set_outgoing_channel(s, ioc);"
],
"line_no": [
27,
27
]
} | void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2)
{
QIOChannel *ioc;
const char *VAR_3[] = { "/bin/sh", "-c", VAR_1, NULL };
trace_migration_exec_outgoing(VAR_1);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(VAR_3,
O_WRONLY,
VAR_2));
if (!ioc) {
return;
}
migration_set_outgoing_channel(VAR_0, ioc);
object_unref(OBJECT(ioc));
}
| [
"void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"QIOChannel *ioc;",
"const char *VAR_3[] = { \"/bin/sh\", \"-c\", VAR_1, NULL };",
"trace_migration_exec_outgoing(VAR_1);",
"ioc = QIO_CHANNEL(qio_channel_command_new_spawn(VAR_3,\nO_WRONLY,\nVAR_2));",
"if (!ioc) {",
"return;",
"}",
"migration_set_outgoing_channel(VAR_0, ioc);",
"object_unref(OBJECT(ioc));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
]
]
|
13,025 | static int nsv_probe(AVProbeData *p)
{
int i;
av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
/* check file header */
/* streamed files might not have any header */
if (p->buf[0] == 'N' && p->buf[1] == 'S' &&
p->buf[2] == 'V' && (p->buf[3] == 'f' || p->buf[3] == 's'))
return AVPROBE_SCORE_MAX;
/* XXX: do streamed files always start at chunk boundary ?? */
/* or do we need to search NSVs in the byte stream ? */
/* seems the servers don't bother starting clean chunks... */
/* sometimes even the first header is at 9KB or something :^) */
for (i = 1; i < p->buf_size - 3; i++) {
if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
p->buf[i+2] == 'V' && p->buf[i+3] == 's')
return AVPROBE_SCORE_MAX-20;
}
/* so we'll have more luck on extension... */
if (av_match_ext(p->filename, "nsv"))
return AVPROBE_SCORE_MAX/2;
/* FIXME: add mime-type check */
return 0;
}
| false | FFmpeg | 45faf7fcd335b91e41b0e3ba4e397a9640d8c694 | static int nsv_probe(AVProbeData *p)
{
int i;
av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
if (p->buf[0] == 'N' && p->buf[1] == 'S' &&
p->buf[2] == 'V' && (p->buf[3] == 'f' || p->buf[3] == 's'))
return AVPROBE_SCORE_MAX;
for (i = 1; i < p->buf_size - 3; i++) {
if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
p->buf[i+2] == 'V' && p->buf[i+3] == 's')
return AVPROBE_SCORE_MAX-20;
}
if (av_match_ext(p->filename, "nsv"))
return AVPROBE_SCORE_MAX/2;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
int VAR_1;
av_dlog(NULL, "FUNC_0(), buf_size %d\n", VAR_0->buf_size);
if (VAR_0->buf[0] == 'N' && VAR_0->buf[1] == 'S' &&
VAR_0->buf[2] == 'V' && (VAR_0->buf[3] == 'f' || VAR_0->buf[3] == 's'))
return AVPROBE_SCORE_MAX;
for (VAR_1 = 1; VAR_1 < VAR_0->buf_size - 3; VAR_1++) {
if (VAR_0->buf[VAR_1+0] == 'N' && VAR_0->buf[VAR_1+1] == 'S' &&
VAR_0->buf[VAR_1+2] == 'V' && VAR_0->buf[VAR_1+3] == 's')
return AVPROBE_SCORE_MAX-20;
}
if (av_match_ext(VAR_0->filename, "nsv"))
return AVPROBE_SCORE_MAX/2;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"int VAR_1;",
"av_dlog(NULL, \"FUNC_0(), buf_size %d\\n\", VAR_0->buf_size);",
"if (VAR_0->buf[0] == 'N' && VAR_0->buf[1] == 'S' &&\nVAR_0->buf[2] == 'V' && (VAR_0->buf[3] == 'f' || VAR_0->buf[3] == 's'))\nreturn AVPROBE_SCORE_MAX;",
"for (VAR_1 = 1; VAR_1 < VAR_0->buf_size - 3; VAR_1++) {",
"if (VAR_0->buf[VAR_1+0] == 'N' && VAR_0->buf[VAR_1+1] == 'S' &&\nVAR_0->buf[VAR_1+2] == 'V' && VAR_0->buf[VAR_1+3] == 's')\nreturn AVPROBE_SCORE_MAX-20;",
"}",
"if (av_match_ext(VAR_0->filename, \"nsv\"))\nreturn AVPROBE_SCORE_MAX/2;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13,
15,
17
],
[
27
],
[
29,
31,
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
]
]
|
13,026 | static int nvdec_hevc_decode_init(AVCodecContext *avctx)
{
const HEVCContext *s = avctx->priv_data;
const HEVCSPS *sps = s->ps.sps;
return ff_nvdec_decode_init(avctx, sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1);
}
| false | FFmpeg | 7546964f96168cd6ac819ef4c3212ee586619f1a | static int nvdec_hevc_decode_init(AVCodecContext *avctx)
{
const HEVCContext *s = avctx->priv_data;
const HEVCSPS *sps = s->ps.sps;
return ff_nvdec_decode_init(avctx, sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
const HEVCContext *VAR_1 = VAR_0->priv_data;
const HEVCSPS *VAR_2 = VAR_1->ps.VAR_2;
return ff_nvdec_decode_init(VAR_0, VAR_2->temporal_layer[VAR_2->max_sub_layers - 1].max_dec_pic_buffering + 1);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"const HEVCContext *VAR_1 = VAR_0->priv_data;",
"const HEVCSPS *VAR_2 = VAR_1->ps.VAR_2;",
"return ff_nvdec_decode_init(VAR_0, VAR_2->temporal_layer[VAR_2->max_sub_layers - 1].max_dec_pic_buffering + 1);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
13,028 | qemu_irq sh7750_irl(SH7750State *s)
{
sh_intc_toggle_source(sh_intc_source(&s->intc, IRL), 1, 0); /* enable */
return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),
1)[0];
}
| true | qemu | f3c7d0389fe8a2792fd4c1cf151b885de03c8f62 | qemu_irq sh7750_irl(SH7750State *s)
{
sh_intc_toggle_source(sh_intc_source(&s->intc, IRL), 1, 0);
return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),
1)[0];
}
| {
"code": [
" return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),",
" 1)[0];"
],
"line_no": [
7,
9
]
} | qemu_irq FUNC_0(SH7750State *s)
{
sh_intc_toggle_source(sh_intc_source(&s->intc, IRL), 1, 0);
return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),
1)[0];
}
| [
"qemu_irq FUNC_0(SH7750State *s)\n{",
"sh_intc_toggle_source(sh_intc_source(&s->intc, IRL), 1, 0);",
"return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),\n1)[0];",
"}"
]
| [
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
]
]
|
13,029 | static uint64_t ivshmem_io_read(void *opaque, hwaddr addr,
unsigned size)
{
IVShmemState *s = opaque;
uint32_t ret;
switch (addr)
{
case INTRMASK:
ret = ivshmem_IntrMask_read(s);
break;
case INTRSTATUS:
ret = ivshmem_IntrStatus_read(s);
break;
case IVPOSITION:
/* return my VM ID if the memory is mapped */
if (s->shm_fd >= 0) {
ret = s->vm_id;
} else {
ret = -1;
}
break;
default:
IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
ret = 0;
}
return ret;
}
| true | qemu | f689d2811a36894618087e1e2cc3ade78e758e94 | static uint64_t ivshmem_io_read(void *opaque, hwaddr addr,
unsigned size)
{
IVShmemState *s = opaque;
uint32_t ret;
switch (addr)
{
case INTRMASK:
ret = ivshmem_IntrMask_read(s);
break;
case INTRSTATUS:
ret = ivshmem_IntrStatus_read(s);
break;
case IVPOSITION:
if (s->shm_fd >= 0) {
ret = s->vm_id;
} else {
ret = -1;
}
break;
default:
IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
ret = 0;
}
return ret;
}
| {
"code": [
" if (s->shm_fd >= 0) {"
],
"line_no": [
39
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
IVShmemState *s = opaque;
uint32_t ret;
switch (addr)
{
case INTRMASK:
ret = ivshmem_IntrMask_read(s);
break;
case INTRSTATUS:
ret = ivshmem_IntrStatus_read(s);
break;
case IVPOSITION:
if (s->shm_fd >= 0) {
ret = s->vm_id;
} else {
ret = -1;
}
break;
default:
IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
ret = 0;
}
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"IVShmemState *s = opaque;",
"uint32_t ret;",
"switch (addr)\n{",
"case INTRMASK:\nret = ivshmem_IntrMask_read(s);",
"break;",
"case INTRSTATUS:\nret = ivshmem_IntrStatus_read(s);",
"break;",
"case IVPOSITION:\nif (s->shm_fd >= 0) {",
"ret = s->vm_id;",
"} else {",
"ret = -1;",
"}",
"break;",
"default:\nIVSHMEM_DPRINTF(\"why are we reading \" TARGET_FMT_plx \"\\n\", addr);",
"ret = 0;",
"}",
"return ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
23
],
[
27,
29
],
[
31
],
[
35,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
]
]
|
13,030 | static void mcf_fec_enable_rx(mcf_fec_state *s)
{
mcf_fec_bd bd;
mcf_fec_read_bd(&bd, s->rx_descriptor);
s->rx_enabled = ((bd.flags & FEC_BD_E) != 0);
if (!s->rx_enabled)
DPRINTF("RX buffer full\n");
}
| true | qemu | ff1d2ac949dc94d8a0e71fd46939fb69c2ef075b | static void mcf_fec_enable_rx(mcf_fec_state *s)
{
mcf_fec_bd bd;
mcf_fec_read_bd(&bd, s->rx_descriptor);
s->rx_enabled = ((bd.flags & FEC_BD_E) != 0);
if (!s->rx_enabled)
DPRINTF("RX buffer full\n");
}
| {
"code": [
" if (!s->rx_enabled)",
" DPRINTF(\"RX buffer full\\n\");"
],
"line_no": [
13,
15
]
} | static void FUNC_0(mcf_fec_state *VAR_0)
{
mcf_fec_bd bd;
mcf_fec_read_bd(&bd, VAR_0->rx_descriptor);
VAR_0->rx_enabled = ((bd.flags & FEC_BD_E) != 0);
if (!VAR_0->rx_enabled)
DPRINTF("RX buffer full\n");
}
| [
"static void FUNC_0(mcf_fec_state *VAR_0)\n{",
"mcf_fec_bd bd;",
"mcf_fec_read_bd(&bd, VAR_0->rx_descriptor);",
"VAR_0->rx_enabled = ((bd.flags & FEC_BD_E) != 0);",
"if (!VAR_0->rx_enabled)\nDPRINTF(\"RX buffer full\\n\");",
"}"
]
| [
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
]
]
|
13,032 | void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep, uint64_t id,
bool short_not_ok, bool int_req)
{
assert(!usb_packet_is_inflight(p));
assert(p->iov.iov != NULL);
p->id = id;
p->pid = pid;
p->ep = ep;
p->result = 0;
p->parameter = 0;
p->short_not_ok = short_not_ok;
p->int_req = int_req;
qemu_iovec_reset(&p->iov);
usb_packet_set_state(p, USB_PACKET_SETUP);
} | true | qemu | a552a966f16b7b39c5df16fc17e12d02c4fa5954 | void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep, uint64_t id,
bool short_not_ok, bool int_req)
{
assert(!usb_packet_is_inflight(p));
assert(p->iov.iov != NULL);
p->id = id;
p->pid = pid;
p->ep = ep;
p->result = 0;
p->parameter = 0;
p->short_not_ok = short_not_ok;
p->int_req = int_req;
qemu_iovec_reset(&p->iov);
usb_packet_set_state(p, USB_PACKET_SETUP);
} | {
"code": [],
"line_no": []
} | void FUNC_0(USBPacket *VAR_0, int VAR_1, USBEndpoint *VAR_2, uint64_t VAR_3,
bool VAR_4, bool VAR_5)
{
assert(!usb_packet_is_inflight(VAR_0));
assert(VAR_0->iov.iov != NULL);
VAR_0->VAR_3 = VAR_3;
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_2 = VAR_2;
VAR_0->result = 0;
VAR_0->parameter = 0;
VAR_0->VAR_4 = VAR_4;
VAR_0->VAR_5 = VAR_5;
qemu_iovec_reset(&VAR_0->iov);
usb_packet_set_state(VAR_0, USB_PACKET_SETUP);
} | [
"void FUNC_0(USBPacket *VAR_0, int VAR_1, USBEndpoint *VAR_2, uint64_t VAR_3,\nbool VAR_4, bool VAR_5)\n{",
"assert(!usb_packet_is_inflight(VAR_0));",
"assert(VAR_0->iov.iov != NULL);",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->result = 0;",
"VAR_0->parameter = 0;",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->VAR_5 = VAR_5;",
"qemu_iovec_reset(&VAR_0->iov);",
"usb_packet_set_state(VAR_0, USB_PACKET_SETUP);",
"}"
]
| [
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
],
[
26
],
[
28
],
[
30
]
]
|
13,033 | static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSI *s = VIRTIO_SCSI(dev);
static int virtio_scsi_id;
Error *err = NULL;
virtio_scsi_common_realize(dev, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
scsi_bus_new(&s->bus, sizeof(s->bus), dev,
&virtio_scsi_scsi_info, vdev->bus_name);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
}
register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
virtio_scsi_save, virtio_scsi_load, s);
}
| true | qemu | 91d670fbf9945ca4ecbd123affb36889e7fe8a5d | static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSI *s = VIRTIO_SCSI(dev);
static int virtio_scsi_id;
Error *err = NULL;
virtio_scsi_common_realize(dev, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
scsi_bus_new(&s->bus, sizeof(s->bus), dev,
&virtio_scsi_scsi_info, vdev->bus_name);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
}
register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
virtio_scsi_save, virtio_scsi_load, s);
}
| {
"code": [
" virtio_scsi_common_realize(dev, &err);",
" virtio_scsi_common_realize(dev, &err);"
],
"line_no": [
15,
15
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VirtIOSCSI *s = VIRTIO_SCSI(VAR_0);
static int VAR_2;
Error *err = NULL;
virtio_scsi_common_realize(VAR_0, &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
scsi_bus_new(&s->bus, sizeof(s->bus), VAR_0,
&virtio_scsi_scsi_info, vdev->bus_name);
if (!VAR_0->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
}
register_savevm(VAR_0, "virtio-scsi", VAR_2++, 1,
virtio_scsi_save, virtio_scsi_load, s);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VirtIOSCSI *s = VIRTIO_SCSI(VAR_0);",
"static int VAR_2;",
"Error *err = NULL;",
"virtio_scsi_common_realize(VAR_0, &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"scsi_bus_new(&s->bus, sizeof(s->bus), VAR_0,\n&virtio_scsi_scsi_info, vdev->bus_name);",
"if (!VAR_0->hotplugged) {",
"scsi_bus_legacy_handle_cmdline(&s->bus, &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"}",
"register_savevm(VAR_0, \"virtio-scsi\", VAR_2++, 1,\nvirtio_scsi_save, virtio_scsi_load, s);",
"}"
]
| [
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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
]
]
|
13,037 | void qemu_mutex_lock(QemuMutex *mutex)
{
EnterCriticalSection(&mutex->lock);
/* Win32 CRITICAL_SECTIONs are recursive. Assert that we're not
* using them as such.
*/
assert(mutex->owner == 0);
mutex->owner = GetCurrentThreadId();
}
| true | qemu | 12f8def0e02232d7c6416ad9b66640f973c531d1 | void qemu_mutex_lock(QemuMutex *mutex)
{
EnterCriticalSection(&mutex->lock);
assert(mutex->owner == 0);
mutex->owner = GetCurrentThreadId();
}
| {
"code": [
" assert(mutex->owner == 0);",
" EnterCriticalSection(&mutex->lock);",
" assert(mutex->owner == 0);",
" mutex->owner = GetCurrentThreadId();"
],
"line_no": [
15,
5,
15,
17
]
} | void FUNC_0(QemuMutex *VAR_0)
{
EnterCriticalSection(&VAR_0->lock);
assert(VAR_0->owner == 0);
VAR_0->owner = GetCurrentThreadId();
}
| [
"void FUNC_0(QemuMutex *VAR_0)\n{",
"EnterCriticalSection(&VAR_0->lock);",
"assert(VAR_0->owner == 0);",
"VAR_0->owner = GetCurrentThreadId();",
"}"
]
| [
0,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
15
],
[
17
],
[
19
]
]
|
13,038 | void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
{
/* We're passed bits [11..0] of the instruction; extract
* SYSm and the mask bits.
* Invalid combinations of SYSm and mask are UNPREDICTABLE;
* we choose to treat them as if the mask bits were valid.
* NB that the pseudocode 'mask' variable is bits [11..10],
* whereas ours is [11..8].
*/
uint32_t mask = extract32(maskreg, 8, 4);
uint32_t reg = extract32(maskreg, 0, 8);
if (arm_current_el(env) == 0 && reg > 7) {
/* only xPSR sub-fields may be written by unprivileged */
return;
}
switch (reg) {
case 0 ... 7: /* xPSR sub-fields */
/* only APSR is actually writable */
if (!(reg & 4)) {
uint32_t apsrmask = 0;
if (mask & 8) {
apsrmask |= 0xf8000000; /* APSR NZCVQ */
}
if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
apsrmask |= 0x000f0000; /* APSR GE[3:0] */
}
xpsr_write(env, val, apsrmask);
}
break;
case 8: /* MSP */
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->v7m.other_sp = val;
} else {
env->regs[13] = val;
}
break;
case 9: /* PSP */
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->regs[13] = val;
} else {
env->v7m.other_sp = val;
}
break;
case 16: /* PRIMASK */
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17: /* BASEPRI */
env->v7m.basepri = val & 0xff;
break;
case 18: /* BASEPRI_MAX */
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19: /* FAULTMASK */
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20: /* CONTROL */
switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
env->v7m.control = val & (R_V7M_CONTROL_SPSEL_MASK |
R_V7M_CONTROL_NPRIV_MASK);
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special"
" register %d\n", reg);
return;
}
}
| true | qemu | 792dac309c8660306557ba058b8b5a6a75ab3c1f | void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
{
uint32_t mask = extract32(maskreg, 8, 4);
uint32_t reg = extract32(maskreg, 0, 8);
if (arm_current_el(env) == 0 && reg > 7) {
return;
}
switch (reg) {
case 0 ... 7:
if (!(reg & 4)) {
uint32_t apsrmask = 0;
if (mask & 8) {
apsrmask |= 0xf8000000;
}
if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
apsrmask |= 0x000f0000;
}
xpsr_write(env, val, apsrmask);
}
break;
case 8:
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->v7m.other_sp = val;
} else {
env->regs[13] = val;
}
break;
case 9:
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->regs[13] = val;
} else {
env->v7m.other_sp = val;
}
break;
case 16:
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17:
env->v7m.basepri = val & 0xff;
break;
case 18:
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19:
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20:
switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
env->v7m.control = val & (R_V7M_CONTROL_SPSEL_MASK |
R_V7M_CONTROL_NPRIV_MASK);
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special"
" register %d\n", reg);
return;
}
}
| {
"code": [
" switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);",
" env->v7m.control = val & (R_V7M_CONTROL_SPSEL_MASK |",
" R_V7M_CONTROL_NPRIV_MASK);"
],
"line_no": [
139,
141,
143
]
} | void FUNC_0(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
{
uint32_t mask = extract32(maskreg, 8, 4);
uint32_t reg = extract32(maskreg, 0, 8);
if (arm_current_el(env) == 0 && reg > 7) {
return;
}
switch (reg) {
case 0 ... 7:
if (!(reg & 4)) {
uint32_t apsrmask = 0;
if (mask & 8) {
apsrmask |= 0xf8000000;
}
if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
apsrmask |= 0x000f0000;
}
xpsr_write(env, val, apsrmask);
}
break;
case 8:
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->v7m.other_sp = val;
} else {
env->regs[13] = val;
}
break;
case 9:
if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {
env->regs[13] = val;
} else {
env->v7m.other_sp = val;
}
break;
case 16:
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17:
env->v7m.basepri = val & 0xff;
break;
case 18:
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19:
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20:
switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
env->v7m.control = val & (R_V7M_CONTROL_SPSEL_MASK |
R_V7M_CONTROL_NPRIV_MASK);
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special"
" register %d\n", reg);
return;
}
}
| [
"void FUNC_0(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)\n{",
"uint32_t mask = extract32(maskreg, 8, 4);",
"uint32_t reg = extract32(maskreg, 0, 8);",
"if (arm_current_el(env) == 0 && reg > 7) {",
"return;",
"}",
"switch (reg) {",
"case 0 ... 7:\nif (!(reg & 4)) {",
"uint32_t apsrmask = 0;",
"if (mask & 8) {",
"apsrmask |= 0xf8000000;",
"}",
"if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) {",
"apsrmask |= 0x000f0000;",
"}",
"xpsr_write(env, val, apsrmask);",
"}",
"break;",
"case 8:\nif (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {",
"env->v7m.other_sp = val;",
"} else {",
"env->regs[13] = val;",
"}",
"break;",
"case 9:\nif (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) {",
"env->regs[13] = val;",
"} else {",
"env->v7m.other_sp = val;",
"}",
"break;",
"case 16:\nif (val & 1) {",
"env->daif |= PSTATE_I;",
"} else {",
"env->daif &= ~PSTATE_I;",
"}",
"break;",
"case 17:\nenv->v7m.basepri = val & 0xff;",
"break;",
"case 18:\nval &= 0xff;",
"if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))\nenv->v7m.basepri = val;",
"break;",
"case 19:\nif (val & 1) {",
"env->daif |= PSTATE_F;",
"} else {",
"env->daif &= ~PSTATE_F;",
"}",
"break;",
"case 20:\nswitch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);",
"env->v7m.control = val & (R_V7M_CONTROL_SPSEL_MASK |\nR_V7M_CONTROL_NPRIV_MASK);",
"break;",
"default:\nqemu_log_mask(LOG_GUEST_ERROR, \"Attempt to write unknown special\"\n\" register %d\\n\", reg);",
"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,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
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
]
]
|
13,041 | static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
PayloadContext *h264_data, const char *line)
{
AVStream *stream;
AVCodecContext *codec;
const char *p = line;
if (st_index < 0)
return 0;
stream = s->streams[st_index];
codec = stream->codec;
assert(h264_data->cookie == MAGIC_COOKIE);
if (av_strstart(p, "framesize:", &p)) {
char buf1[50];
char *dst = buf1;
// remove the protocol identifier..
while (*p && *p == ' ') p++; // strip spaces.
while (*p && *p != ' ') p++; // eat protocol identifier
while (*p && *p == ' ') p++; // strip trailing spaces.
while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1) {
*dst++ = *p++;
}
*dst = '\0';
// a='framesize:96 320-240'
// set our parameters..
codec->width = atoi(buf1);
codec->height = atoi(p + 1); // skip the -
codec->pix_fmt = PIX_FMT_YUV420P;
} else if (av_strstart(p, "fmtp:", &p)) {
return ff_parse_fmtp(stream, h264_data, p, sdp_parse_fmtp_config_h264);
} else if (av_strstart(p, "cliprect:", &p)) {
// could use this if we wanted.
}
return 0; // keep processing it the normal way...
}
| true | FFmpeg | 5a571d324129ce367584ad9d92aae1d286f389a2 | static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
PayloadContext *h264_data, const char *line)
{
AVStream *stream;
AVCodecContext *codec;
const char *p = line;
if (st_index < 0)
return 0;
stream = s->streams[st_index];
codec = stream->codec;
assert(h264_data->cookie == MAGIC_COOKIE);
if (av_strstart(p, "framesize:", &p)) {
char buf1[50];
char *dst = buf1;
while (*p && *p == ' ') p++;
while (*p && *p != ' ') p++;
while (*p && *p == ' ') p++;
while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1) {
*dst++ = *p++;
}
*dst = '\0';
codec->width = atoi(buf1);
codec->height = atoi(p + 1);
codec->pix_fmt = PIX_FMT_YUV420P;
} else if (av_strstart(p, "fmtp:", &p)) {
return ff_parse_fmtp(stream, h264_data, p, sdp_parse_fmtp_config_h264);
} else if (av_strstart(p, "cliprect:", &p)) {
}
return 0;
}
| {
"code": [
" assert(h264_data->cookie == MAGIC_COOKIE);"
],
"line_no": [
25
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
PayloadContext *VAR_2, const char *VAR_3)
{
AVStream *stream;
AVCodecContext *codec;
const char *VAR_4 = VAR_3;
if (VAR_1 < 0)
return 0;
stream = VAR_0->streams[VAR_1];
codec = stream->codec;
assert(VAR_2->cookie == MAGIC_COOKIE);
if (av_strstart(VAR_4, "framesize:", &VAR_4)) {
char VAR_5[50];
char *VAR_6 = VAR_5;
while (*VAR_4 && *VAR_4 == ' ') VAR_4++;
while (*VAR_4 && *VAR_4 != ' ') VAR_4++;
while (*VAR_4 && *VAR_4 == ' ') VAR_4++;
while (*VAR_4 && *VAR_4 != '-' && (VAR_6 - VAR_5) < sizeof(VAR_5) - 1) {
*VAR_6++ = *VAR_4++;
}
*VAR_6 = '\0';
codec->width = atoi(VAR_5);
codec->height = atoi(VAR_4 + 1);
codec->pix_fmt = PIX_FMT_YUV420P;
} else if (av_strstart(VAR_4, "fmtp:", &VAR_4)) {
return ff_parse_fmtp(stream, VAR_2, VAR_4, sdp_parse_fmtp_config_h264);
} else if (av_strstart(VAR_4, "cliprect:", &VAR_4)) {
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nPayloadContext *VAR_2, const char *VAR_3)\n{",
"AVStream *stream;",
"AVCodecContext *codec;",
"const char *VAR_4 = VAR_3;",
"if (VAR_1 < 0)\nreturn 0;",
"stream = VAR_0->streams[VAR_1];",
"codec = stream->codec;",
"assert(VAR_2->cookie == MAGIC_COOKIE);",
"if (av_strstart(VAR_4, \"framesize:\", &VAR_4)) {",
"char VAR_5[50];",
"char *VAR_6 = VAR_5;",
"while (*VAR_4 && *VAR_4 == ' ') VAR_4++;",
"while (*VAR_4 && *VAR_4 != ' ') VAR_4++;",
"while (*VAR_4 && *VAR_4 == ' ') VAR_4++;",
"while (*VAR_4 && *VAR_4 != '-' && (VAR_6 - VAR_5) < sizeof(VAR_5) - 1) {",
"*VAR_6++ = *VAR_4++;",
"}",
"*VAR_6 = '\\0';",
"codec->width = atoi(VAR_5);",
"codec->height = atoi(VAR_4 + 1);",
"codec->pix_fmt = PIX_FMT_YUV420P;",
"} else if (av_strstart(VAR_4, \"fmtp:\", &VAR_4)) {",
"return ff_parse_fmtp(stream, VAR_2, VAR_4, sdp_parse_fmtp_config_h264);",
"} else if (av_strstart(VAR_4, \"cliprect:\", &VAR_4)) {",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
]
]
|
13,042 | PPC_OP(icbi)
{
do_icbi();
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(icbi)
{
do_icbi();
RETURN();
}
| {
"code": [
" RETURN();",
"PPC_OP(icbi)",
" RETURN();"
],
"line_no": [
7,
1,
7
]
} | FUNC_0(VAR_0)
{
do_icbi();
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"do_icbi();",
"RETURN();",
"}"
]
| [
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
13,043 | void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/){
idct(dest, line_size, block, 1);
}
| false | FFmpeg | 28f9ab7029bd1a02f659995919f899f84ee7361b | void ff_vp3_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block){
idct(dest, line_size, block, 1);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2){
idct(VAR_0, VAR_1, VAR_2, 1);
}
| [
"void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2){",
"idct(VAR_0, VAR_1, VAR_2, 1);",
"}"
]
| [
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
]
]
|
13,044 | static bool is_iso_bc_entry_compatible(IsoBcSection *s)
{
return true;
}
| false | qemu | ba21f0cca8165c5b284274edd12dc955cf4fb248 | static bool is_iso_bc_entry_compatible(IsoBcSection *s)
{
return true;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(IsoBcSection *s)
{
return true;
}
| [
"static bool FUNC_0(IsoBcSection *s)\n{",
"return true;",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,045 | int64_t bdrv_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum);
}
| false | qemu | 67a0fd2a9bca204d2b39f910a97c7137636a0715 | int64_t bdrv_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum);
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum);
}
| [
"int64_t FUNC_0(BlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, int *pnum)\n{",
"return bdrv_get_block_status_above(bs, backing_bs(bs),\nsector_num, nb_sectors, pnum);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
]
]
|
13,047 | static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| false | qemu | de9e9d9f17a36ff76c1a02a5348835e5e0a081b0 | static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,
unsigned int VAR_2)
{
gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);
gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);
tcg_gen_or_tl(VAR_0, VAR_0, cpu_tmp0);
tcg_gen_xori_tl(VAR_0, VAR_0, 0x1);
}
| [
"static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,\nunsigned int VAR_2)\n{",
"gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);",
"gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);",
"tcg_gen_or_tl(VAR_0, VAR_0, cpu_tmp0);",
"tcg_gen_xori_tl(VAR_0, VAR_0, 0x1);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
13,048 | static int blk_free(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
struct ioreq *ioreq;
while (!LIST_EMPTY(&blkdev->freelist)) {
ioreq = LIST_FIRST(&blkdev->freelist);
LIST_REMOVE(ioreq, list);
qemu_iovec_destroy(&ioreq->v);
qemu_free(ioreq);
}
qemu_free(blkdev->params);
qemu_free(blkdev->mode);
qemu_free(blkdev->type);
qemu_free(blkdev->dev);
qemu_free(blkdev->devtype);
qemu_bh_delete(blkdev->bh);
return 0;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static int blk_free(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
struct ioreq *ioreq;
while (!LIST_EMPTY(&blkdev->freelist)) {
ioreq = LIST_FIRST(&blkdev->freelist);
LIST_REMOVE(ioreq, list);
qemu_iovec_destroy(&ioreq->v);
qemu_free(ioreq);
}
qemu_free(blkdev->params);
qemu_free(blkdev->mode);
qemu_free(blkdev->type);
qemu_free(blkdev->dev);
qemu_free(blkdev->devtype);
qemu_bh_delete(blkdev->bh);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct XenDevice *VAR_0)
{
struct XenBlkDev *VAR_1 = container_of(VAR_0, struct XenBlkDev, VAR_0);
struct VAR_2 *VAR_2;
while (!LIST_EMPTY(&VAR_1->freelist)) {
VAR_2 = LIST_FIRST(&VAR_1->freelist);
LIST_REMOVE(VAR_2, list);
qemu_iovec_destroy(&VAR_2->v);
qemu_free(VAR_2);
}
qemu_free(VAR_1->params);
qemu_free(VAR_1->mode);
qemu_free(VAR_1->type);
qemu_free(VAR_1->dev);
qemu_free(VAR_1->devtype);
qemu_bh_delete(VAR_1->bh);
return 0;
}
| [
"static int FUNC_0(struct XenDevice *VAR_0)\n{",
"struct XenBlkDev *VAR_1 = container_of(VAR_0, struct XenBlkDev, VAR_0);",
"struct VAR_2 *VAR_2;",
"while (!LIST_EMPTY(&VAR_1->freelist)) {",
"VAR_2 = LIST_FIRST(&VAR_1->freelist);",
"LIST_REMOVE(VAR_2, list);",
"qemu_iovec_destroy(&VAR_2->v);",
"qemu_free(VAR_2);",
"}",
"qemu_free(VAR_1->params);",
"qemu_free(VAR_1->mode);",
"qemu_free(VAR_1->type);",
"qemu_free(VAR_1->dev);",
"qemu_free(VAR_1->devtype);",
"qemu_bh_delete(VAR_1->bh);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
]
|
13,049 | static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
{
IDEState *ide_if = opaque;
IDEState *s = ide_if->cur_drive;
uint32_t addr;
int ret, hob;
addr = addr1 & 7;
/* FIXME: HOB readback uses bit 7, but it's always set right now */
//hob = s->select & (1 << 7);
hob = 0;
switch(addr) {
case 0:
ret = 0xff;
break;
case 1:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->error;
else
ret = s->hob_feature;
break;
case 2:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->nsector & 0xff;
else
ret = s->hob_nsector;
break;
case 3:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->sector;
else
ret = s->hob_sector;
break;
case 4:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->lcyl;
else
ret = s->hob_lcyl;
break;
case 5:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->hcyl;
else
ret = s->hob_hcyl;
break;
case 6:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else
ret = s->select;
break;
default:
case 7:
if ((!ide_if[0].bs && !ide_if[1].bs) ||
(s != ide_if && !s->bs))
ret = 0;
else
ret = s->status;
qemu_irq_lower(s->irq);
break;
}
#ifdef DEBUG_IDE
printf("ide: read addr=0x%x val=%02x\n", addr1, ret);
#endif
return ret;
}
| false | qemu | c45ca54ff98c29551fadf9e8f64eb43d54cdcb0c | static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
{
IDEState *ide_if = opaque;
IDEState *s = ide_if->cur_drive;
uint32_t addr;
int ret, hob;
addr = addr1 & 7;
hob = 0;
switch(addr) {
case 0:
ret = 0xff;
break;
case 1:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->error;
else
ret = s->hob_feature;
break;
case 2:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->nsector & 0xff;
else
ret = s->hob_nsector;
break;
case 3:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->sector;
else
ret = s->hob_sector;
break;
case 4:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->lcyl;
else
ret = s->hob_lcyl;
break;
case 5:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->hcyl;
else
ret = s->hob_hcyl;
break;
case 6:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else
ret = s->select;
break;
default:
case 7:
if ((!ide_if[0].bs && !ide_if[1].bs) ||
(s != ide_if && !s->bs))
ret = 0;
else
ret = s->status;
qemu_irq_lower(s->irq);
break;
}
#ifdef DEBUG_IDE
printf("ide: read addr=0x%x val=%02x\n", addr1, ret);
#endif
return ret;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, uint32_t addr1)
{
IDEState *ide_if = opaque;
IDEState *s = ide_if->cur_drive;
uint32_t addr;
int VAR_0, VAR_1;
addr = addr1 & 7;
VAR_1 = 0;
switch(addr) {
case 0:
VAR_0 = 0xff;
break;
case 1:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else if (!VAR_1)
VAR_0 = s->error;
else
VAR_0 = s->hob_feature;
break;
case 2:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else if (!VAR_1)
VAR_0 = s->nsector & 0xff;
else
VAR_0 = s->hob_nsector;
break;
case 3:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else if (!VAR_1)
VAR_0 = s->sector;
else
VAR_0 = s->hob_sector;
break;
case 4:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else if (!VAR_1)
VAR_0 = s->lcyl;
else
VAR_0 = s->hob_lcyl;
break;
case 5:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else if (!VAR_1)
VAR_0 = s->hcyl;
else
VAR_0 = s->hob_hcyl;
break;
case 6:
if (!ide_if[0].bs && !ide_if[1].bs)
VAR_0 = 0;
else
VAR_0 = s->select;
break;
default:
case 7:
if ((!ide_if[0].bs && !ide_if[1].bs) ||
(s != ide_if && !s->bs))
VAR_0 = 0;
else
VAR_0 = s->status;
qemu_irq_lower(s->irq);
break;
}
#ifdef DEBUG_IDE
printf("ide: read addr=0x%x val=%02x\n", addr1, VAR_0);
#endif
return VAR_0;
}
| [
"static uint32_t FUNC_0(void *opaque, uint32_t addr1)\n{",
"IDEState *ide_if = opaque;",
"IDEState *s = ide_if->cur_drive;",
"uint32_t addr;",
"int VAR_0, VAR_1;",
"addr = addr1 & 7;",
"VAR_1 = 0;",
"switch(addr) {",
"case 0:\nVAR_0 = 0xff;",
"break;",
"case 1:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else if (!VAR_1)\nVAR_0 = s->error;",
"else\nVAR_0 = s->hob_feature;",
"break;",
"case 2:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else if (!VAR_1)\nVAR_0 = s->nsector & 0xff;",
"else\nVAR_0 = s->hob_nsector;",
"break;",
"case 3:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else if (!VAR_1)\nVAR_0 = s->sector;",
"else\nVAR_0 = s->hob_sector;",
"break;",
"case 4:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else if (!VAR_1)\nVAR_0 = s->lcyl;",
"else\nVAR_0 = s->hob_lcyl;",
"break;",
"case 5:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else if (!VAR_1)\nVAR_0 = s->hcyl;",
"else\nVAR_0 = s->hob_hcyl;",
"break;",
"case 6:\nif (!ide_if[0].bs && !ide_if[1].bs)\nVAR_0 = 0;",
"else\nVAR_0 = s->select;",
"break;",
"default:\ncase 7:\nif ((!ide_if[0].bs && !ide_if[1].bs) ||\n(s != ide_if && !s->bs))\nVAR_0 = 0;",
"else\nVAR_0 = s->status;",
"qemu_irq_lower(s->irq);",
"break;",
"}",
"#ifdef DEBUG_IDE\nprintf(\"ide: read addr=0x%x val=%02x\\n\", addr1, VAR_0);",
"#endif\nreturn 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33,
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47,
49,
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63,
65,
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79,
81,
83
],
[
85,
87
],
[
89,
91
],
[
93
],
[
95,
97,
99
],
[
101,
103
],
[
105,
107
],
[
109
],
[
111,
113,
115
],
[
117,
119
],
[
121
],
[
123,
125,
127,
129,
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151
]
]
|
13,052 | void qmp_block_dirty_bitmap_add(const char *node, const char *name,
bool has_granularity, uint32_t granularity,
Error **errp)
{
AioContext *aio_context;
BlockDriverState *bs;
if (!name || name[0] == '\0') {
error_setg(errp, "Bitmap name cannot be empty");
return;
}
bs = bdrv_lookup_bs(node, node, errp);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (has_granularity) {
if (granularity < 512 || !is_power_of_2(granularity)) {
error_setg(errp, "Granularity must be power of 2 "
"and at least 512");
goto out;
}
} else {
/* Default to cluster size, if available: */
granularity = bdrv_get_default_bitmap_granularity(bs);
}
bdrv_create_dirty_bitmap(bs, granularity, name, errp);
out:
aio_context_release(aio_context);
}
| false | qemu | 2119882c7eb7e2c612b24fc0c8d86f5887d6f1c3 | void qmp_block_dirty_bitmap_add(const char *node, const char *name,
bool has_granularity, uint32_t granularity,
Error **errp)
{
AioContext *aio_context;
BlockDriverState *bs;
if (!name || name[0] == '\0') {
error_setg(errp, "Bitmap name cannot be empty");
return;
}
bs = bdrv_lookup_bs(node, node, errp);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (has_granularity) {
if (granularity < 512 || !is_power_of_2(granularity)) {
error_setg(errp, "Granularity must be power of 2 "
"and at least 512");
goto out;
}
} else {
granularity = bdrv_get_default_bitmap_granularity(bs);
}
bdrv_create_dirty_bitmap(bs, granularity, name, errp);
out:
aio_context_release(aio_context);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, uint32_t VAR_3,
Error **VAR_4)
{
AioContext *aio_context;
BlockDriverState *bs;
if (!VAR_1 || VAR_1[0] == '\0') {
error_setg(VAR_4, "Bitmap VAR_1 cannot be empty");
return;
}
bs = bdrv_lookup_bs(VAR_0, VAR_0, VAR_4);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (VAR_2) {
if (VAR_3 < 512 || !is_power_of_2(VAR_3)) {
error_setg(VAR_4, "Granularity must be power of 2 "
"and at least 512");
goto out;
}
} else {
VAR_3 = bdrv_get_default_bitmap_granularity(bs);
}
bdrv_create_dirty_bitmap(bs, VAR_3, VAR_1, VAR_4);
out:
aio_context_release(aio_context);
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, uint32_t VAR_3,\nError **VAR_4)\n{",
"AioContext *aio_context;",
"BlockDriverState *bs;",
"if (!VAR_1 || VAR_1[0] == '\\0') {",
"error_setg(VAR_4, \"Bitmap VAR_1 cannot be empty\");",
"return;",
"}",
"bs = bdrv_lookup_bs(VAR_0, VAR_0, VAR_4);",
"if (!bs) {",
"return;",
"}",
"aio_context = bdrv_get_aio_context(bs);",
"aio_context_acquire(aio_context);",
"if (VAR_2) {",
"if (VAR_3 < 512 || !is_power_of_2(VAR_3)) {",
"error_setg(VAR_4, \"Granularity must be power of 2 \"\n\"and at least 512\");",
"goto out;",
"}",
"} else {",
"VAR_3 = bdrv_get_default_bitmap_granularity(bs);",
"}",
"bdrv_create_dirty_bitmap(bs, VAR_3, VAR_1, VAR_4);",
"out:\naio_context_release(aio_context);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
71
]
]
|
13,053 | static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
{
uint16_t nodenr;
uint16List *cpus = NULL;
if (node->has_nodeid) {
nodenr = node->nodeid;
} else {
nodenr = nb_numa_nodes;
}
if (nodenr >= MAX_NODES) {
error_setg(errp, "Max number of NUMA nodes reached: %"
PRIu16 "", nodenr);
return;
}
if (numa_info[nodenr].present) {
error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr);
return;
}
for (cpus = node->cpus; cpus; cpus = cpus->next) {
if (cpus->value >= MAX_CPUMASK_BITS) {
error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
cpus->value, MAX_CPUMASK_BITS - 1);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
}
if (node->has_mem && node->has_memdev) {
error_setg(errp, "qemu: cannot specify both mem= and memdev=");
return;
}
if (have_memdevs == -1) {
have_memdevs = node->has_memdev;
}
if (node->has_memdev != have_memdevs) {
error_setg(errp, "qemu: memdev option must be specified for either "
"all or no nodes");
return;
}
if (node->has_mem) {
uint64_t mem_size = node->mem;
const char *mem_str = qemu_opt_get(opts, "mem");
/* Fix up legacy suffix-less format */
if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
mem_size <<= 20;
}
numa_info[nodenr].node_mem = mem_size;
}
if (node->has_memdev) {
Object *o;
o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL);
if (!o) {
error_setg(errp, "memdev=%s is ambiguous", node->memdev);
return;
}
object_ref(o);
numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL);
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
numa_info[nodenr].present = true;
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
}
| false | qemu | 8979c945c1a7ffd20edbd5da2513c04baccfd7de | static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
{
uint16_t nodenr;
uint16List *cpus = NULL;
if (node->has_nodeid) {
nodenr = node->nodeid;
} else {
nodenr = nb_numa_nodes;
}
if (nodenr >= MAX_NODES) {
error_setg(errp, "Max number of NUMA nodes reached: %"
PRIu16 "", nodenr);
return;
}
if (numa_info[nodenr].present) {
error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr);
return;
}
for (cpus = node->cpus; cpus; cpus = cpus->next) {
if (cpus->value >= MAX_CPUMASK_BITS) {
error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
cpus->value, MAX_CPUMASK_BITS - 1);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
}
if (node->has_mem && node->has_memdev) {
error_setg(errp, "qemu: cannot specify both mem= and memdev=");
return;
}
if (have_memdevs == -1) {
have_memdevs = node->has_memdev;
}
if (node->has_memdev != have_memdevs) {
error_setg(errp, "qemu: memdev option must be specified for either "
"all or no nodes");
return;
}
if (node->has_mem) {
uint64_t mem_size = node->mem;
const char *mem_str = qemu_opt_get(opts, "mem");
if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
mem_size <<= 20;
}
numa_info[nodenr].node_mem = mem_size;
}
if (node->has_memdev) {
Object *o;
o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL);
if (!o) {
error_setg(errp, "memdev=%s is ambiguous", node->memdev);
return;
}
object_ref(o);
numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL);
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
numa_info[nodenr].present = true;
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NumaNodeOptions *VAR_0, QemuOpts *VAR_1, Error **VAR_2)
{
uint16_t nodenr;
uint16List *cpus = NULL;
if (VAR_0->has_nodeid) {
nodenr = VAR_0->nodeid;
} else {
nodenr = nb_numa_nodes;
}
if (nodenr >= MAX_NODES) {
error_setg(VAR_2, "Max number of NUMA nodes reached: %"
PRIu16 "", nodenr);
return;
}
if (numa_info[nodenr].present) {
error_setg(VAR_2, "Duplicate NUMA nodeid: %" PRIu16, nodenr);
return;
}
for (cpus = VAR_0->cpus; cpus; cpus = cpus->next) {
if (cpus->value >= MAX_CPUMASK_BITS) {
error_setg(VAR_2, "CPU number %" PRIu16 " is bigger than %d",
cpus->value, MAX_CPUMASK_BITS - 1);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
}
if (VAR_0->has_mem && VAR_0->has_memdev) {
error_setg(VAR_2, "qemu: cannot specify both mem= and memdev=");
return;
}
if (have_memdevs == -1) {
have_memdevs = VAR_0->has_memdev;
}
if (VAR_0->has_memdev != have_memdevs) {
error_setg(VAR_2, "qemu: memdev option must be specified for either "
"all or no nodes");
return;
}
if (VAR_0->has_mem) {
uint64_t mem_size = VAR_0->mem;
const char *VAR_3 = qemu_opt_get(VAR_1, "mem");
if (g_ascii_isdigit(VAR_3[strlen(VAR_3) - 1])) {
mem_size <<= 20;
}
numa_info[nodenr].node_mem = mem_size;
}
if (VAR_0->has_memdev) {
Object *o;
o = object_resolve_path_type(VAR_0->memdev, TYPE_MEMORY_BACKEND, NULL);
if (!o) {
error_setg(VAR_2, "memdev=%s is ambiguous", VAR_0->memdev);
return;
}
object_ref(o);
numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL);
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
numa_info[nodenr].present = true;
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
}
| [
"static void FUNC_0(NumaNodeOptions *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{",
"uint16_t nodenr;",
"uint16List *cpus = NULL;",
"if (VAR_0->has_nodeid) {",
"nodenr = VAR_0->nodeid;",
"} else {",
"nodenr = nb_numa_nodes;",
"}",
"if (nodenr >= MAX_NODES) {",
"error_setg(VAR_2, \"Max number of NUMA nodes reached: %\"\nPRIu16 \"\", nodenr);",
"return;",
"}",
"if (numa_info[nodenr].present) {",
"error_setg(VAR_2, \"Duplicate NUMA nodeid: %\" PRIu16, nodenr);",
"return;",
"}",
"for (cpus = VAR_0->cpus; cpus; cpus = cpus->next) {",
"if (cpus->value >= MAX_CPUMASK_BITS) {",
"error_setg(VAR_2, \"CPU number %\" PRIu16 \" is bigger than %d\",\ncpus->value, MAX_CPUMASK_BITS - 1);",
"return;",
"}",
"bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);",
"}",
"if (VAR_0->has_mem && VAR_0->has_memdev) {",
"error_setg(VAR_2, \"qemu: cannot specify both mem= and memdev=\");",
"return;",
"}",
"if (have_memdevs == -1) {",
"have_memdevs = VAR_0->has_memdev;",
"}",
"if (VAR_0->has_memdev != have_memdevs) {",
"error_setg(VAR_2, \"qemu: memdev option must be specified for either \"\n\"all or no nodes\");",
"return;",
"}",
"if (VAR_0->has_mem) {",
"uint64_t mem_size = VAR_0->mem;",
"const char *VAR_3 = qemu_opt_get(VAR_1, \"mem\");",
"if (g_ascii_isdigit(VAR_3[strlen(VAR_3) - 1])) {",
"mem_size <<= 20;",
"}",
"numa_info[nodenr].node_mem = mem_size;",
"}",
"if (VAR_0->has_memdev) {",
"Object *o;",
"o = object_resolve_path_type(VAR_0->memdev, TYPE_MEMORY_BACKEND, NULL);",
"if (!o) {",
"error_setg(VAR_2, \"memdev=%s is ambiguous\", VAR_0->memdev);",
"return;",
"}",
"object_ref(o);",
"numa_info[nodenr].node_mem = object_property_get_int(o, \"size\", NULL);",
"numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);",
"}",
"numa_info[nodenr].present = true;",
"max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
]
]
|
13,054 | static int create_filtergraph(AVFilterContext *ctx,
const AVFrame *in, const AVFrame *out)
{
ColorSpaceContext *s = ctx->priv;
const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in->format);
const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(in_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\n",
in->format, av_get_pix_fmt_name(in->format),
in_desc ? in_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(out_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\n",
out->format, av_get_pix_fmt_name(out->format),
out_desc ? out_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (in->color_primaries != s->in_prm) s->in_primaries = NULL;
if (out->color_primaries != s->out_prm) s->out_primaries = NULL;
if (in->color_trc != s->in_trc) s->in_txchr = NULL;
if (out->color_trc != s->out_trc) s->out_txchr = NULL;
if (in->colorspace != s->in_csp ||
in->color_range != s->in_rng) s->in_lumacoef = NULL;
if (out->colorspace != s->out_csp ||
out->color_range != s->out_rng) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = in->color_primaries;
if (s->user_iall != CS_UNSPECIFIED)
s->in_prm = default_prm[FFMIN(s->user_iall, CS_NB)];
if (s->user_iprm != AVCOL_PRI_UNSPECIFIED)
s->in_prm = s->user_iprm;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\n",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = out->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR, "Please specify output primaries\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\n",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
fill_rgb2xyz_table(s->out_primaries, rgb2xyz);
invert_matrix3x3(rgb2xyz, xyz2rgb);
fill_rgb2xyz_table(s->in_primaries, rgb2xyz);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double wpconv[3][3], tmp[3][3];
fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(tmp, rgb2xyz, wpconv);
mul3x3(rgb2rgb, tmp, xyz2rgb);
} else {
mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
}
for (m = 0; m < 3; m++)
for (n = 0; n < 3; n++) {
s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]);
for (o = 1; o < 8; o++)
s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0];
}
emms = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = in->color_trc;
if (s->user_iall != CS_UNSPECIFIED)
s->in_trc = default_trc[FFMIN(s->user_iall, CS_NB)];
if (s->user_itrc != AVCOL_TRC_UNSPECIFIED)
s->in_trc = s->user_itrc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\n",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = out->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
res = fill_gamma_table(s);
if (res < 0)
return res;
emms = 1;
}
if (!s->in_lumacoef) {
s->in_csp = in->colorspace;
if (s->user_iall != CS_UNSPECIFIED)
s->in_csp = default_csp[FFMIN(s->user_iall, CS_NB)];
if (s->user_icsp != AVCOL_SPC_UNSPECIFIED)
s->in_csp = s->user_icsp;
s->in_rng = in->color_range;
if (s->user_irng != AVCOL_RANGE_UNSPECIFIED)
s->in_rng = s->user_irng;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\n",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
redo_yuv2rgb = 1;
}
if (!s->out_lumacoef) {
s->out_csp = out->colorspace;
s->out_rng = out->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
redo_rgb2yuv = 1;
}
fmt_identical = in_desc->log2_chroma_h == out_desc->log2_chroma_h &&
in_desc->log2_chroma_w == out_desc->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && fmt_identical;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->in_rng == s->out_rng &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef)) &&
in_desc->comp[0].depth == out_desc->comp[0].depth;
if (!s->yuv2yuv_passthrough) {
if (redo_yuv2rgb) {
double rgb2yuv[3][3], (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
int off, bits, in_rng;
res = get_range_off(&off, &s->in_y_rng, &s->in_uv_rng,
s->in_rng, in_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\n",
s->in_rng, av_color_range_name(s->in_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[0][n] = off;
fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv);
invert_matrix3x3(rgb2yuv, yuv2rgb);
bits = 1 << (in_desc->comp[0].depth - 1);
for (n = 0; n < 3; n++) {
for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
s->yuv2rgb_coeffs[n][m][0] = lrint(28672 * bits * yuv2rgb[n][m] / in_rng);
for (o = 1; o < 8; o++)
s->yuv2rgb_coeffs[n][m][o] = s->yuv2rgb_coeffs[n][m][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
emms = 1;
}
if (redo_rgb2yuv) {
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
int off, out_rng, bits;
res = get_range_off(&off, &s->out_y_rng, &s->out_uv_rng,
s->out_rng, out_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\n",
s->out_rng, av_color_range_name(s->out_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[1][n] = off;
fill_rgb2yuv_table(s->out_lumacoef, rgb2yuv);
bits = 1 << (29 - out_desc->comp[0].depth);
for (out_rng = s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
for (m = 0; m < 3; m++) {
s->rgb2yuv_coeffs[n][m][0] = lrint(bits * out_rng * rgb2yuv[n][m] / 28672);
for (o = 1; o < 8; o++)
s->rgb2yuv_coeffs[n][m][o] = s->rgb2yuv_coeffs[n][m][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->rgb2yuv = s->dsp.rgb2yuv[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
emms = 1;
}
if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
int idepth = in_desc->comp[0].depth, odepth = out_desc->comp[0].depth;
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
double (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
double yuv2yuv[3][3];
int in_rng, out_rng;
mul3x3(yuv2yuv, yuv2rgb, rgb2yuv);
for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
s->yuv2yuv_coeffs[m][n][0] =
lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) /
(in_rng * (1 << odepth)));
for (o = 1; o < 8; o++)
s->yuv2yuv_coeffs[m][n][o] = s->yuv2yuv_coeffs[m][n][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->yuv2yuv = s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
}
}
if (emms)
emms_c();
return 0;
}
| false | FFmpeg | cb78d14cf9b5ab59b4a9177f390f5e1abff58644 | static int create_filtergraph(AVFilterContext *ctx,
const AVFrame *in, const AVFrame *out)
{
ColorSpaceContext *s = ctx->priv;
const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in->format);
const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(in_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\n",
in->format, av_get_pix_fmt_name(in->format),
in_desc ? in_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(out_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\n",
out->format, av_get_pix_fmt_name(out->format),
out_desc ? out_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (in->color_primaries != s->in_prm) s->in_primaries = NULL;
if (out->color_primaries != s->out_prm) s->out_primaries = NULL;
if (in->color_trc != s->in_trc) s->in_txchr = NULL;
if (out->color_trc != s->out_trc) s->out_txchr = NULL;
if (in->colorspace != s->in_csp ||
in->color_range != s->in_rng) s->in_lumacoef = NULL;
if (out->colorspace != s->out_csp ||
out->color_range != s->out_rng) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = in->color_primaries;
if (s->user_iall != CS_UNSPECIFIED)
s->in_prm = default_prm[FFMIN(s->user_iall, CS_NB)];
if (s->user_iprm != AVCOL_PRI_UNSPECIFIED)
s->in_prm = s->user_iprm;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\n",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = out->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR, "Please specify output primaries\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\n",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
fill_rgb2xyz_table(s->out_primaries, rgb2xyz);
invert_matrix3x3(rgb2xyz, xyz2rgb);
fill_rgb2xyz_table(s->in_primaries, rgb2xyz);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double wpconv[3][3], tmp[3][3];
fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(tmp, rgb2xyz, wpconv);
mul3x3(rgb2rgb, tmp, xyz2rgb);
} else {
mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
}
for (m = 0; m < 3; m++)
for (n = 0; n < 3; n++) {
s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]);
for (o = 1; o < 8; o++)
s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0];
}
emms = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = in->color_trc;
if (s->user_iall != CS_UNSPECIFIED)
s->in_trc = default_trc[FFMIN(s->user_iall, CS_NB)];
if (s->user_itrc != AVCOL_TRC_UNSPECIFIED)
s->in_trc = s->user_itrc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\n",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = out->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
res = fill_gamma_table(s);
if (res < 0)
return res;
emms = 1;
}
if (!s->in_lumacoef) {
s->in_csp = in->colorspace;
if (s->user_iall != CS_UNSPECIFIED)
s->in_csp = default_csp[FFMIN(s->user_iall, CS_NB)];
if (s->user_icsp != AVCOL_SPC_UNSPECIFIED)
s->in_csp = s->user_icsp;
s->in_rng = in->color_range;
if (s->user_irng != AVCOL_RANGE_UNSPECIFIED)
s->in_rng = s->user_irng;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\n",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
redo_yuv2rgb = 1;
}
if (!s->out_lumacoef) {
s->out_csp = out->colorspace;
s->out_rng = out->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
redo_rgb2yuv = 1;
}
fmt_identical = in_desc->log2_chroma_h == out_desc->log2_chroma_h &&
in_desc->log2_chroma_w == out_desc->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && fmt_identical;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->in_rng == s->out_rng &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef)) &&
in_desc->comp[0].depth == out_desc->comp[0].depth;
if (!s->yuv2yuv_passthrough) {
if (redo_yuv2rgb) {
double rgb2yuv[3][3], (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
int off, bits, in_rng;
res = get_range_off(&off, &s->in_y_rng, &s->in_uv_rng,
s->in_rng, in_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\n",
s->in_rng, av_color_range_name(s->in_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[0][n] = off;
fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv);
invert_matrix3x3(rgb2yuv, yuv2rgb);
bits = 1 << (in_desc->comp[0].depth - 1);
for (n = 0; n < 3; n++) {
for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
s->yuv2rgb_coeffs[n][m][0] = lrint(28672 * bits * yuv2rgb[n][m] / in_rng);
for (o = 1; o < 8; o++)
s->yuv2rgb_coeffs[n][m][o] = s->yuv2rgb_coeffs[n][m][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
emms = 1;
}
if (redo_rgb2yuv) {
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
int off, out_rng, bits;
res = get_range_off(&off, &s->out_y_rng, &s->out_uv_rng,
s->out_rng, out_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\n",
s->out_rng, av_color_range_name(s->out_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[1][n] = off;
fill_rgb2yuv_table(s->out_lumacoef, rgb2yuv);
bits = 1 << (29 - out_desc->comp[0].depth);
for (out_rng = s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
for (m = 0; m < 3; m++) {
s->rgb2yuv_coeffs[n][m][0] = lrint(bits * out_rng * rgb2yuv[n][m] / 28672);
for (o = 1; o < 8; o++)
s->rgb2yuv_coeffs[n][m][o] = s->rgb2yuv_coeffs[n][m][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->rgb2yuv = s->dsp.rgb2yuv[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
emms = 1;
}
if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
int idepth = in_desc->comp[0].depth, odepth = out_desc->comp[0].depth;
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
double (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
double yuv2yuv[3][3];
int in_rng, out_rng;
mul3x3(yuv2yuv, yuv2rgb, rgb2yuv);
for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
s->yuv2yuv_coeffs[m][n][0] =
lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) /
(in_rng * (1 << odepth)));
for (o = 1; o < 8; o++)
s->yuv2yuv_coeffs[m][n][o] = s->yuv2yuv_coeffs[m][n][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->yuv2yuv = s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
}
}
if (emms)
emms_c();
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0,
const AVFrame *VAR_1, const AVFrame *VAR_2)
{
ColorSpaceContext *s = VAR_0->priv;
const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1->format);
const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_2->format);
int VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(VAR_3)) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\VAR_7",
VAR_1->format, av_get_pix_fmt_name(VAR_1->format),
VAR_3 ? VAR_3->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(VAR_4)) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\VAR_7",
VAR_2->format, av_get_pix_fmt_name(VAR_2->format),
VAR_4 ? VAR_4->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (VAR_1->color_primaries != s->in_prm) s->in_primaries = NULL;
if (VAR_2->color_primaries != s->out_prm) s->out_primaries = NULL;
if (VAR_1->color_trc != s->in_trc) s->in_txchr = NULL;
if (VAR_2->color_trc != s->out_trc) s->out_txchr = NULL;
if (VAR_1->colorspace != s->in_csp ||
VAR_1->color_range != s->VAR_27) s->in_lumacoef = NULL;
if (VAR_2->colorspace != s->out_csp ||
VAR_2->color_range != s->VAR_27) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = VAR_1->color_primaries;
if (s->user_iall != CS_UNSPECIFIED)
s->in_prm = default_prm[FFMIN(s->user_iall, CS_NB)];
if (s->user_iprm != AVCOL_PRI_UNSPECIFIED)
s->in_prm = s->user_iprm;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\VAR_7",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = VAR_2->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR, "Please specify output primaries\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\VAR_7",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double VAR_13[3][3], VAR_14[3][3], VAR_15[3][3];
fill_rgb2xyz_table(s->out_primaries, VAR_13);
invert_matrix3x3(VAR_13, VAR_14);
fill_rgb2xyz_table(s->in_primaries, VAR_13);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double VAR_16[3][3], VAR_17[3][3];
fill_whitepoint_conv_table(VAR_16, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(VAR_17, VAR_13, VAR_16);
mul3x3(VAR_15, VAR_17, VAR_14);
} else {
mul3x3(VAR_15, VAR_13, VAR_14);
}
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0] = lrint(16384.0 * VAR_15[VAR_6][VAR_7]);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->lrgb2lrgb_coeffs[VAR_6][VAR_7][VAR_8] = s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0];
}
VAR_5 = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = VAR_1->color_trc;
if (s->user_iall != CS_UNSPECIFIED)
s->in_trc = default_trc[FFMIN(s->user_iall, CS_NB)];
if (s->user_itrc != AVCOL_TRC_UNSPECIFIED)
s->in_trc = s->user_itrc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\VAR_7",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = VAR_2->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR,
"Please specify output transfer characteristics\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\VAR_7",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
VAR_9 = fill_gamma_table(s);
if (VAR_9 < 0)
return VAR_9;
VAR_5 = 1;
}
if (!s->in_lumacoef) {
s->in_csp = VAR_1->colorspace;
if (s->user_iall != CS_UNSPECIFIED)
s->in_csp = default_csp[FFMIN(s->user_iall, CS_NB)];
if (s->user_icsp != AVCOL_SPC_UNSPECIFIED)
s->in_csp = s->user_icsp;
s->VAR_27 = VAR_1->color_range;
if (s->user_irng != AVCOL_RANGE_UNSPECIFIED)
s->VAR_27 = s->user_irng;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\VAR_7",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
VAR_11 = 1;
}
if (!s->out_lumacoef) {
s->out_csp = VAR_2->colorspace;
s->VAR_27 = VAR_2->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR,
"Please specify output transfer characteristics\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\VAR_7",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
VAR_12 = 1;
}
VAR_10 = VAR_3->log2_chroma_h == VAR_4->log2_chroma_h &&
VAR_3->log2_chroma_w == VAR_4->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && VAR_10;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->VAR_27 == s->VAR_27 &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef)) &&
VAR_3->comp[0].depth == VAR_4->comp[0].depth;
if (!s->yuv2yuv_passthrough) {
if (VAR_11) {
double VAR_26[3][3], (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;
int VAR_23, VAR_24, VAR_27;
VAR_9 = get_range_off(&VAR_23, &s->in_y_rng, &s->in_uv_rng,
s->VAR_27, VAR_3->comp[0].depth);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\VAR_7",
s->VAR_27, av_color_range_name(s->VAR_27));
return VAR_9;
}
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
s->yuv_offset[0][VAR_7] = VAR_23;
fill_rgb2yuv_table(s->in_lumacoef, VAR_26);
invert_matrix3x3(VAR_26, VAR_26);
VAR_24 = 1 << (VAR_3->comp[0].depth - 1);
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
for (VAR_27 = s->in_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->in_uv_rng) {
s->yuv2rgb_coeffs[VAR_7][VAR_6][0] = lrint(28672 * VAR_24 * VAR_26[VAR_7][VAR_6] / VAR_27);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->yuv2rgb_coeffs[VAR_7][VAR_6][VAR_8] = s->yuv2rgb_coeffs[VAR_7][VAR_6][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->VAR_26 = s->dsp.VAR_26[(VAR_3->comp[0].depth - 8) >> 1]
[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];
VAR_5 = 1;
}
if (VAR_12) {
double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;
int VAR_23, VAR_27, VAR_24;
VAR_9 = get_range_off(&VAR_23, &s->out_y_rng, &s->out_uv_rng,
s->VAR_27, VAR_4->comp[0].depth);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\VAR_7",
s->VAR_27, av_color_range_name(s->VAR_27));
return VAR_9;
}
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
s->yuv_offset[1][VAR_7] = VAR_23;
fill_rgb2yuv_table(s->out_lumacoef, VAR_26);
VAR_24 = 1 << (29 - VAR_4->comp[0].depth);
for (VAR_27 = s->out_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->out_uv_rng) {
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
s->rgb2yuv_coeffs[VAR_7][VAR_6][0] = lrint(VAR_24 * VAR_27 * VAR_26[VAR_7][VAR_6] / 28672);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->rgb2yuv_coeffs[VAR_7][VAR_6][VAR_8] = s->rgb2yuv_coeffs[VAR_7][VAR_6][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->VAR_26 = s->dsp.VAR_26[(VAR_4->comp[0].depth - 8) >> 1]
[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(VAR_4->comp[0].depth - 8) >> 1]
[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];
VAR_5 = 1;
}
if (s->yuv2yuv_fastmode && (VAR_11 || VAR_12)) {
int VAR_24 = VAR_3->comp[0].depth, VAR_25 = VAR_4->comp[0].depth;
double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;
double (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;
double VAR_26[3][3];
int VAR_27, VAR_27;
mul3x3(VAR_26, VAR_26, VAR_26);
for (VAR_27 = s->out_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->out_uv_rng) {
for (VAR_27 = s->in_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->in_uv_rng) {
s->yuv2yuv_coeffs[VAR_6][VAR_7][0] =
lrint(16384 * VAR_26[VAR_6][VAR_7] * VAR_27 * (1 << VAR_24) /
(VAR_27 * (1 << VAR_25)));
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->yuv2yuv_coeffs[VAR_6][VAR_7][VAR_8] = s->yuv2yuv_coeffs[VAR_6][VAR_7][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->VAR_26 = s->dsp.VAR_26[(VAR_24 - 8) >> 1][(VAR_25 - 8) >> 1]
[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];
}
}
if (VAR_5)
emms_c();
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0,\nconst AVFrame *VAR_1, const AVFrame *VAR_2)\n{",
"ColorSpaceContext *s = VAR_0->priv;",
"const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1->format);",
"const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_2->format);",
"int VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;",
"#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)\n#define supported_subsampling(lcw, lch) \\\n(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))\n#define supported_format(d) \\\n((d) != NULL && (d)->nb_components == 3 && \\\n!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \\\nsupported_depth((d)->comp[0].depth) && \\\nsupported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))\nif (!supported_format(VAR_3)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input format %d (%s) or bitdepth (%d)\\VAR_7\",\nVAR_1->format, av_get_pix_fmt_name(VAR_1->format),\nVAR_3 ? VAR_3->comp[0].depth : -1);",
"return AVERROR(EINVAL);",
"}",
"if (!supported_format(VAR_4)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output format %d (%s) or bitdepth (%d)\\VAR_7\",\nVAR_2->format, av_get_pix_fmt_name(VAR_2->format),\nVAR_4 ? VAR_4->comp[0].depth : -1);",
"return AVERROR(EINVAL);",
"}",
"if (VAR_1->color_primaries != s->in_prm) s->in_primaries = NULL;",
"if (VAR_2->color_primaries != s->out_prm) s->out_primaries = NULL;",
"if (VAR_1->color_trc != s->in_trc) s->in_txchr = NULL;",
"if (VAR_2->color_trc != s->out_trc) s->out_txchr = NULL;",
"if (VAR_1->colorspace != s->in_csp ||\nVAR_1->color_range != s->VAR_27) s->in_lumacoef = NULL;",
"if (VAR_2->colorspace != s->out_csp ||\nVAR_2->color_range != s->VAR_27) s->out_lumacoef = NULL;",
"if (!s->out_primaries || !s->in_primaries) {",
"s->in_prm = VAR_1->color_primaries;",
"if (s->user_iall != CS_UNSPECIFIED)\ns->in_prm = default_prm[FFMIN(s->user_iall, CS_NB)];",
"if (s->user_iprm != AVCOL_PRI_UNSPECIFIED)\ns->in_prm = s->user_iprm;",
"s->in_primaries = get_color_primaries(s->in_prm);",
"if (!s->in_primaries) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input primaries %d (%s)\\VAR_7\",\ns->in_prm, av_color_primaries_name(s->in_prm));",
"return AVERROR(EINVAL);",
"}",
"s->out_prm = VAR_2->color_primaries;",
"s->out_primaries = get_color_primaries(s->out_prm);",
"if (!s->out_primaries) {",
"if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Please specify output primaries\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output primaries %d (%s)\\VAR_7\",\ns->out_prm, av_color_primaries_name(s->out_prm));",
"}",
"return AVERROR(EINVAL);",
"}",
"s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,\nsizeof(*s->in_primaries));",
"if (!s->lrgb2lrgb_passthrough) {",
"double VAR_13[3][3], VAR_14[3][3], VAR_15[3][3];",
"fill_rgb2xyz_table(s->out_primaries, VAR_13);",
"invert_matrix3x3(VAR_13, VAR_14);",
"fill_rgb2xyz_table(s->in_primaries, VAR_13);",
"if (s->out_primaries->wp != s->in_primaries->wp &&\ns->wp_adapt != WP_ADAPT_IDENTITY) {",
"double VAR_16[3][3], VAR_17[3][3];",
"fill_whitepoint_conv_table(VAR_16, s->wp_adapt, s->in_primaries->wp,\ns->out_primaries->wp);",
"mul3x3(VAR_17, VAR_13, VAR_16);",
"mul3x3(VAR_15, VAR_17, VAR_14);",
"} else {",
"mul3x3(VAR_15, VAR_13, VAR_14);",
"}",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0] = lrint(16384.0 * VAR_15[VAR_6][VAR_7]);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->lrgb2lrgb_coeffs[VAR_6][VAR_7][VAR_8] = s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0];",
"}",
"VAR_5 = 1;",
"}",
"}",
"if (!s->in_txchr) {",
"av_freep(&s->lin_lut);",
"s->in_trc = VAR_1->color_trc;",
"if (s->user_iall != CS_UNSPECIFIED)\ns->in_trc = default_trc[FFMIN(s->user_iall, CS_NB)];",
"if (s->user_itrc != AVCOL_TRC_UNSPECIFIED)\ns->in_trc = s->user_itrc;",
"s->in_txchr = get_transfer_characteristics(s->in_trc);",
"if (!s->in_txchr) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input transfer characteristics %d (%s)\\VAR_7\",\ns->in_trc, av_color_transfer_name(s->in_trc));",
"return AVERROR(EINVAL);",
"}",
"}",
"if (!s->out_txchr) {",
"av_freep(&s->lin_lut);",
"s->out_trc = VAR_2->color_trc;",
"s->out_txchr = get_transfer_characteristics(s->out_trc);",
"if (!s->out_txchr) {",
"if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Please specify output transfer characteristics\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output transfer characteristics %d (%s)\\VAR_7\",\ns->out_trc, av_color_transfer_name(s->out_trc));",
"}",
"return AVERROR(EINVAL);",
"}",
"}",
"s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&\n!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));",
"if (!s->rgb2rgb_passthrough && !s->lin_lut) {",
"VAR_9 = fill_gamma_table(s);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"VAR_5 = 1;",
"}",
"if (!s->in_lumacoef) {",
"s->in_csp = VAR_1->colorspace;",
"if (s->user_iall != CS_UNSPECIFIED)\ns->in_csp = default_csp[FFMIN(s->user_iall, CS_NB)];",
"if (s->user_icsp != AVCOL_SPC_UNSPECIFIED)\ns->in_csp = s->user_icsp;",
"s->VAR_27 = VAR_1->color_range;",
"if (s->user_irng != AVCOL_RANGE_UNSPECIFIED)\ns->VAR_27 = s->user_irng;",
"s->in_lumacoef = get_luma_coefficients(s->in_csp);",
"if (!s->in_lumacoef) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input colorspace %d (%s)\\VAR_7\",\ns->in_csp, av_color_space_name(s->in_csp));",
"return AVERROR(EINVAL);",
"}",
"VAR_11 = 1;",
"}",
"if (!s->out_lumacoef) {",
"s->out_csp = VAR_2->colorspace;",
"s->VAR_27 = VAR_2->color_range;",
"s->out_lumacoef = get_luma_coefficients(s->out_csp);",
"if (!s->out_lumacoef) {",
"if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Please specify output transfer characteristics\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output transfer characteristics %d (%s)\\VAR_7\",\ns->out_csp, av_color_space_name(s->out_csp));",
"}",
"return AVERROR(EINVAL);",
"}",
"VAR_12 = 1;",
"}",
"VAR_10 = VAR_3->log2_chroma_h == VAR_4->log2_chroma_h &&\nVAR_3->log2_chroma_w == VAR_4->log2_chroma_w;",
"s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && VAR_10;",
"s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->VAR_27 == s->VAR_27 &&\n!memcmp(s->in_lumacoef, s->out_lumacoef,\nsizeof(*s->in_lumacoef)) &&\nVAR_3->comp[0].depth == VAR_4->comp[0].depth;",
"if (!s->yuv2yuv_passthrough) {",
"if (VAR_11) {",
"double VAR_26[3][3], (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;",
"int VAR_23, VAR_24, VAR_27;",
"VAR_9 = get_range_off(&VAR_23, &s->in_y_rng, &s->in_uv_rng,\ns->VAR_27, VAR_3->comp[0].depth);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input color range %d (%s)\\VAR_7\",\ns->VAR_27, av_color_range_name(s->VAR_27));",
"return VAR_9;",
"}",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"s->yuv_offset[0][VAR_7] = VAR_23;",
"fill_rgb2yuv_table(s->in_lumacoef, VAR_26);",
"invert_matrix3x3(VAR_26, VAR_26);",
"VAR_24 = 1 << (VAR_3->comp[0].depth - 1);",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"for (VAR_27 = s->in_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->in_uv_rng) {",
"s->yuv2rgb_coeffs[VAR_7][VAR_6][0] = lrint(28672 * VAR_24 * VAR_26[VAR_7][VAR_6] / VAR_27);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->yuv2rgb_coeffs[VAR_7][VAR_6][VAR_8] = s->yuv2rgb_coeffs[VAR_7][VAR_6][0];",
"}",
"}",
"av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);",
"av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);",
"av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);",
"av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_3->comp[0].depth - 8) >> 1]\n[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];",
"VAR_5 = 1;",
"}",
"if (VAR_12) {",
"double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;",
"int VAR_23, VAR_27, VAR_24;",
"VAR_9 = get_range_off(&VAR_23, &s->out_y_rng, &s->out_uv_rng,\ns->VAR_27, VAR_4->comp[0].depth);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color range %d (%s)\\VAR_7\",\ns->VAR_27, av_color_range_name(s->VAR_27));",
"return VAR_9;",
"}",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"s->yuv_offset[1][VAR_7] = VAR_23;",
"fill_rgb2yuv_table(s->out_lumacoef, VAR_26);",
"VAR_24 = 1 << (29 - VAR_4->comp[0].depth);",
"for (VAR_27 = s->out_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->out_uv_rng) {",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"s->rgb2yuv_coeffs[VAR_7][VAR_6][0] = lrint(VAR_24 * VAR_27 * VAR_26[VAR_7][VAR_6] / 28672);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->rgb2yuv_coeffs[VAR_7][VAR_6][VAR_8] = s->rgb2yuv_coeffs[VAR_7][VAR_6][0];",
"}",
"}",
"av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_4->comp[0].depth - 8) >> 1]\n[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];",
"s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(VAR_4->comp[0].depth - 8) >> 1]\n[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];",
"VAR_5 = 1;",
"}",
"if (s->yuv2yuv_fastmode && (VAR_11 || VAR_12)) {",
"int VAR_24 = VAR_3->comp[0].depth, VAR_25 = VAR_4->comp[0].depth;",
"double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;",
"double (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;",
"double VAR_26[3][3];",
"int VAR_27, VAR_27;",
"mul3x3(VAR_26, VAR_26, VAR_26);",
"for (VAR_27 = s->out_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->out_uv_rng) {",
"for (VAR_27 = s->in_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->in_uv_rng) {",
"s->yuv2yuv_coeffs[VAR_6][VAR_7][0] =\nlrint(16384 * VAR_26[VAR_6][VAR_7] * VAR_27 * (1 << VAR_24) /\n(VAR_27 * (1 << VAR_25)));",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->yuv2yuv_coeffs[VAR_6][VAR_7][VAR_8] = s->yuv2yuv_coeffs[VAR_6][VAR_7][0];",
"}",
"}",
"av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);",
"av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_24 - 8) >> 1][(VAR_25 - 8) >> 1]\n[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];",
"}",
"}",
"if (VAR_5)\nemms_c();",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21,
23,
25,
27,
29,
31,
35
],
[
37,
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53,
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
231
],
[
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
],
[
293
],
[
297
],
[
299
],
[
301,
303
],
[
305,
307
],
[
309
],
[
311,
313
],
[
315
],
[
317
],
[
319,
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355,
357
],
[
359
],
[
361
],
[
363,
365,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
381,
383
],
[
385
],
[
387,
389,
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
405,
407
],
[
409
],
[
411,
413,
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453,
455
],
[
457
],
[
459
],
[
463
],
[
465
],
[
467
],
[
471,
473
],
[
475
],
[
477,
479,
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511,
513
],
[
515,
517
],
[
519
],
[
521
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
539
],
[
541
],
[
543
],
[
545,
547,
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563,
565
],
[
567
],
[
569
],
[
573,
575
],
[
579
],
[
581
]
]
|
13,055 | static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common);
if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE);
}
| false | qemu | 6ef228fc0de1d5fb43ebfef039563d39a3a37067 | static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common);
if (speed < 0) {
error_set(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockJob *VAR_0, int64_t VAR_1, Error **VAR_2)
{
StreamBlockJob *s = container_of(VAR_0, StreamBlockJob, common);
if (VAR_1 < 0) {
error_set(VAR_2, QERR_INVALID_PARAMETER, "VAR_1");
return;
}
ratelimit_set_speed(&s->limit, VAR_1 / BDRV_SECTOR_SIZE);
}
| [
"static void FUNC_0(BlockJob *VAR_0, int64_t VAR_1, Error **VAR_2)\n{",
"StreamBlockJob *s = container_of(VAR_0, StreamBlockJob, common);",
"if (VAR_1 < 0) {",
"error_set(VAR_2, QERR_INVALID_PARAMETER, \"VAR_1\");",
"return;",
"}",
"ratelimit_set_speed(&s->limit, VAR_1 / BDRV_SECTOR_SIZE);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
13,056 | static Rom *find_rom(target_phys_addr_t addr)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (rom->addr > addr) {
continue;
}
if (rom->addr + rom->romsize < addr) {
continue;
}
return rom;
}
return NULL;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static Rom *find_rom(target_phys_addr_t addr)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (rom->addr > addr) {
continue;
}
if (rom->addr + rom->romsize < addr) {
continue;
}
return rom;
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static Rom *FUNC_0(target_phys_addr_t addr)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (rom->addr > addr) {
continue;
}
if (rom->addr + rom->romsize < addr) {
continue;
}
return rom;
}
return NULL;
}
| [
"static Rom *FUNC_0(target_phys_addr_t addr)\n{",
"Rom *rom;",
"QTAILQ_FOREACH(rom, &roms, next) {",
"if (rom->fw_file) {",
"continue;",
"}",
"if (rom->addr > addr) {",
"continue;",
"}",
"if (rom->addr + rom->romsize < addr) {",
"continue;",
"}",
"return rom;",
"}",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
]
|
13,057 | iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
size_t qemu_read_size;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
int i;
#endif
int ret;
uint64_t lba;
uint32_t num_sectors;
qemu_read_size = BDRV_SECTOR_SIZE * (size_t)nb_sectors;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->read_size = qemu_read_size;
acb->buf = NULL;
/* If LUN blocksize is bigger than BDRV_BLOCK_SIZE a read from QEMU
* may be misaligned to the LUN, so we may need to read some extra
* data.
*/
acb->read_offset = 0;
if (iscsilun->block_size > BDRV_SECTOR_SIZE) {
uint64_t bdrv_offset = BDRV_SECTOR_SIZE * sector_num;
acb->read_offset = bdrv_offset % iscsilun->block_size;
}
num_sectors = (qemu_read_size + iscsilun->block_size
+ acb->read_offset - 1)
/ iscsilun->block_size;
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi READ16 "
"command. %s", iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_READ;
lba = sector_qemu2lun(sector_num, iscsilun);
acb->task->expxferlen = qemu_read_size;
switch (iscsilun->type) {
case TYPE_DISK:
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x88;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
break;
default:
acb->task->cdb_size = 10;
acb->task->cdb[0] = 0x28;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba);
*(uint16_t *)&acb->task->cdb[7] = htons(num_sectors);
break;
}
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_read16_cb,
NULL,
acb);
if (ret != 0) {
scsi_free_scsi_task(acb->task);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov);
#else
for (i = 0; i < acb->qiov->niov; i++) {
scsi_task_add_data_in_buffer(acb->task,
acb->qiov->iov[i].iov_len,
acb->qiov->iov[i].iov_base);
}
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| false | qemu | 1dde716ed6719c341c1bfa427781f0715af90cbc | iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
size_t qemu_read_size;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
int i;
#endif
int ret;
uint64_t lba;
uint32_t num_sectors;
qemu_read_size = BDRV_SECTOR_SIZE * (size_t)nb_sectors;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->read_size = qemu_read_size;
acb->buf = NULL;
acb->read_offset = 0;
if (iscsilun->block_size > BDRV_SECTOR_SIZE) {
uint64_t bdrv_offset = BDRV_SECTOR_SIZE * sector_num;
acb->read_offset = bdrv_offset % iscsilun->block_size;
}
num_sectors = (qemu_read_size + iscsilun->block_size
+ acb->read_offset - 1)
/ iscsilun->block_size;
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi READ16 "
"command. %s", iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_READ;
lba = sector_qemu2lun(sector_num, iscsilun);
acb->task->expxferlen = qemu_read_size;
switch (iscsilun->type) {
case TYPE_DISK:
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x88;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
break;
default:
acb->task->cdb_size = 10;
acb->task->cdb[0] = 0x28;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba);
*(uint16_t *)&acb->task->cdb[7] = htons(num_sectors);
break;
}
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_read16_cb,
NULL,
acb);
if (ret != 0) {
scsi_free_scsi_task(acb->task);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov);
#else
for (i = 0; i < acb->qiov->niov; i++) {
scsi_task_add_data_in_buffer(acb->task,
acb->qiov->iov[i].iov_len,
acb->qiov->iov[i].iov_base);
}
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| {
"code": [],
"line_no": []
} | FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
QEMUIOVector *VAR_2, int VAR_3,
BlockDriverCompletionFunc *VAR_4,
void *VAR_5)
{
IscsiLun *iscsilun = VAR_0->VAR_5;
struct iscsi_context *VAR_6 = iscsilun->VAR_6;
IscsiAIOCB *acb;
size_t qemu_read_size;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
int VAR_7;
#endif
int VAR_8;
uint64_t lba;
uint32_t num_sectors;
qemu_read_size = BDRV_SECTOR_SIZE * (size_t)VAR_3;
acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);
trace_iscsi_aio_readv(VAR_6, VAR_1, VAR_3, VAR_5, acb);
acb->iscsilun = iscsilun;
acb->VAR_2 = VAR_2;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->read_size = qemu_read_size;
acb->buf = NULL;
acb->read_offset = 0;
if (iscsilun->block_size > BDRV_SECTOR_SIZE) {
uint64_t bdrv_offset = BDRV_SECTOR_SIZE * VAR_1;
acb->read_offset = bdrv_offset % iscsilun->block_size;
}
num_sectors = (qemu_read_size + iscsilun->block_size
+ acb->read_offset - 1)
/ iscsilun->block_size;
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi READ16 "
"command. %s", iscsi_get_error(VAR_6));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_READ;
lba = sector_qemu2lun(VAR_1, iscsilun);
acb->task->expxferlen = qemu_read_size;
switch (iscsilun->type) {
case TYPE_DISK:
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x88;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
break;
default:
acb->task->cdb_size = 10;
acb->task->cdb[0] = 0x28;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba);
*(uint16_t *)&acb->task->cdb[7] = htons(num_sectors);
break;
}
VAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,
iscsi_aio_read16_cb,
NULL,
acb);
if (VAR_8 != 0) {
scsi_free_scsi_task(acb->task);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->VAR_2->iov, acb->VAR_2->niov);
#else
for (VAR_7 = 0; VAR_7 < acb->VAR_2->niov; VAR_7++) {
scsi_task_add_data_in_buffer(acb->task,
acb->VAR_2->iov[VAR_7].iov_len,
acb->VAR_2->iov[VAR_7].iov_base);
}
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| [
"FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nQEMUIOVector *VAR_2, int VAR_3,\nBlockDriverCompletionFunc *VAR_4,\nvoid *VAR_5)\n{",
"IscsiLun *iscsilun = VAR_0->VAR_5;",
"struct iscsi_context *VAR_6 = iscsilun->VAR_6;",
"IscsiAIOCB *acb;",
"size_t qemu_read_size;",
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)\nint VAR_7;",
"#endif\nint VAR_8;",
"uint64_t lba;",
"uint32_t num_sectors;",
"qemu_read_size = BDRV_SECTOR_SIZE * (size_t)VAR_3;",
"acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);",
"trace_iscsi_aio_readv(VAR_6, VAR_1, VAR_3, VAR_5, acb);",
"acb->iscsilun = iscsilun;",
"acb->VAR_2 = VAR_2;",
"acb->canceled = 0;",
"acb->bh = NULL;",
"acb->status = -EINPROGRESS;",
"acb->read_size = qemu_read_size;",
"acb->buf = NULL;",
"acb->read_offset = 0;",
"if (iscsilun->block_size > BDRV_SECTOR_SIZE) {",
"uint64_t bdrv_offset = BDRV_SECTOR_SIZE * VAR_1;",
"acb->read_offset = bdrv_offset % iscsilun->block_size;",
"}",
"num_sectors = (qemu_read_size + iscsilun->block_size\n+ acb->read_offset - 1)\n/ iscsilun->block_size;",
"acb->task = malloc(sizeof(struct scsi_task));",
"if (acb->task == NULL) {",
"error_report(\"iSCSI: Failed to allocate task for scsi READ16 \"\n\"command. %s\", iscsi_get_error(VAR_6));",
"qemu_aio_release(acb);",
"return NULL;",
"}",
"memset(acb->task, 0, sizeof(struct scsi_task));",
"acb->task->xfer_dir = SCSI_XFER_READ;",
"lba = sector_qemu2lun(VAR_1, iscsilun);",
"acb->task->expxferlen = qemu_read_size;",
"switch (iscsilun->type) {",
"case TYPE_DISK:\nacb->task->cdb_size = 16;",
"acb->task->cdb[0] = 0x88;",
"*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);",
"*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);",
"*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);",
"break;",
"default:\nacb->task->cdb_size = 10;",
"acb->task->cdb[0] = 0x28;",
"*(uint32_t *)&acb->task->cdb[2] = htonl(lba);",
"*(uint16_t *)&acb->task->cdb[7] = htons(num_sectors);",
"break;",
"}",
"VAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,\niscsi_aio_read16_cb,\nNULL,\nacb);",
"if (VAR_8 != 0) {",
"scsi_free_scsi_task(acb->task);",
"qemu_aio_release(acb);",
"return NULL;",
"}",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)\nscsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->VAR_2->iov, acb->VAR_2->niov);",
"#else\nfor (VAR_7 = 0; VAR_7 < acb->VAR_2->niov; VAR_7++) {",
"scsi_task_add_data_in_buffer(acb->task,\nacb->VAR_2->iov[VAR_7].iov_len,\nacb->VAR_2->iov[VAR_7].iov_base);",
"}",
"#endif\niscsi_set_events(iscsilun);",
"return &acb->common;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83,
85,
87
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173,
175
],
[
177,
179,
181
],
[
183
],
[
185,
189
],
[
193
],
[
195
]
]
|
13,058 | static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr,
int count, int copy)
{
struct target_iovec *target_vec;
abi_ulong base;
int i;
target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
if (!target_vec)
return -TARGET_EFAULT;
for(i = 0;i < count; i++) {
base = tswapal(target_vec[i].iov_base);
vec[i].iov_len = tswapal(target_vec[i].iov_len);
if (vec[i].iov_len != 0) {
vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy);
/* Don't check lock_user return value. We must call writev even
if a element has invalid base address. */
} else {
/* zero length pointer is ignored */
vec[i].iov_base = NULL;
}
}
unlock_user (target_vec, target_addr, 0);
return 0;
}
| false | qemu | f287b2c2d4d20d35880ab6dca44bda0476e67dce | static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr,
int count, int copy)
{
struct target_iovec *target_vec;
abi_ulong base;
int i;
target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
if (!target_vec)
return -TARGET_EFAULT;
for(i = 0;i < count; i++) {
base = tswapal(target_vec[i].iov_base);
vec[i].iov_len = tswapal(target_vec[i].iov_len);
if (vec[i].iov_len != 0) {
vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy);
} else {
vec[i].iov_base = NULL;
}
}
unlock_user (target_vec, target_addr, 0);
return 0;
}
| {
"code": [],
"line_no": []
} | static abi_long FUNC_0(int type, struct iovec *vec, abi_ulong target_addr,
int count, int copy)
{
struct target_iovec *VAR_0;
abi_ulong base;
int VAR_1;
VAR_0 = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
if (!VAR_0)
return -TARGET_EFAULT;
for(VAR_1 = 0;VAR_1 < count; VAR_1++) {
base = tswapal(VAR_0[VAR_1].iov_base);
vec[VAR_1].iov_len = tswapal(VAR_0[VAR_1].iov_len);
if (vec[VAR_1].iov_len != 0) {
vec[VAR_1].iov_base = lock_user(type, base, vec[VAR_1].iov_len, copy);
} else {
vec[VAR_1].iov_base = NULL;
}
}
unlock_user (VAR_0, target_addr, 0);
return 0;
}
| [
"static abi_long FUNC_0(int type, struct iovec *vec, abi_ulong target_addr,\nint count, int copy)\n{",
"struct target_iovec *VAR_0;",
"abi_ulong base;",
"int VAR_1;",
"VAR_0 = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);",
"if (!VAR_0)\nreturn -TARGET_EFAULT;",
"for(VAR_1 = 0;VAR_1 < count; VAR_1++) {",
"base = tswapal(VAR_0[VAR_1].iov_base);",
"vec[VAR_1].iov_len = tswapal(VAR_0[VAR_1].iov_len);",
"if (vec[VAR_1].iov_len != 0) {",
"vec[VAR_1].iov_base = lock_user(type, base, vec[VAR_1].iov_len, copy);",
"} else {",
"vec[VAR_1].iov_base = NULL;",
"}",
"}",
"unlock_user (VAR_0, target_addr, 0);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
]
|
13,059 | S390PCIBusDevice *s390_pci_find_next_avail_dev(S390PCIBusDevice *pbdev)
{
int idx = 0;
S390PCIBusDevice *dev = NULL;
S390pciState *s = s390_get_phb();
if (pbdev) {
idx = (pbdev->fh & FH_MASK_INDEX) + 1;
}
for (; idx < PCI_SLOT_MAX; idx++) {
dev = s->pbdev[idx];
if (dev && dev->state != ZPCI_FS_RESERVED) {
return dev;
}
}
return NULL;
}
| false | qemu | e70377dfa4bbc2e101066ca35675bed4129c5a8c | S390PCIBusDevice *s390_pci_find_next_avail_dev(S390PCIBusDevice *pbdev)
{
int idx = 0;
S390PCIBusDevice *dev = NULL;
S390pciState *s = s390_get_phb();
if (pbdev) {
idx = (pbdev->fh & FH_MASK_INDEX) + 1;
}
for (; idx < PCI_SLOT_MAX; idx++) {
dev = s->pbdev[idx];
if (dev && dev->state != ZPCI_FS_RESERVED) {
return dev;
}
}
return NULL;
}
| {
"code": [],
"line_no": []
} | S390PCIBusDevice *FUNC_0(S390PCIBusDevice *pbdev)
{
int VAR_0 = 0;
S390PCIBusDevice *dev = NULL;
S390pciState *s = s390_get_phb();
if (pbdev) {
VAR_0 = (pbdev->fh & FH_MASK_INDEX) + 1;
}
for (; VAR_0 < PCI_SLOT_MAX; VAR_0++) {
dev = s->pbdev[VAR_0];
if (dev && dev->state != ZPCI_FS_RESERVED) {
return dev;
}
}
return NULL;
}
| [
"S390PCIBusDevice *FUNC_0(S390PCIBusDevice *pbdev)\n{",
"int VAR_0 = 0;",
"S390PCIBusDevice *dev = NULL;",
"S390pciState *s = s390_get_phb();",
"if (pbdev) {",
"VAR_0 = (pbdev->fh & FH_MASK_INDEX) + 1;",
"}",
"for (; VAR_0 < PCI_SLOT_MAX; VAR_0++) {",
"dev = s->pbdev[VAR_0];",
"if (dev && dev->state != ZPCI_FS_RESERVED) {",
"return dev;",
"}",
"}",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
]
|
13,061 | static void fw_cfg_ctl_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
fw_cfg_select(opaque, (uint16_t)value);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void fw_cfg_ctl_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
fw_cfg_select(opaque, (uint16_t)value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
fw_cfg_select(VAR_0, (uint16_t)VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"fw_cfg_select(VAR_0, (uint16_t)VAR_2);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
]
]
|
13,062 | static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
int64_t total_sectors;
int64_t n;
int64_t ret, ret2;
*file = NULL;
total_sectors = bdrv_nb_sectors(bs);
if (total_sectors < 0) {
return total_sectors;
}
if (sector_num >= total_sectors) {
*pnum = 0;
return BDRV_BLOCK_EOF;
}
if (!nb_sectors) {
*pnum = 0;
return 0;
}
n = total_sectors - sector_num;
if (n < nb_sectors) {
nb_sectors = n;
}
if (!bs->drv->bdrv_co_get_block_status) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
if (sector_num + nb_sectors == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
if (bs->drv->protocol_name) {
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
*file = bs;
}
return ret;
}
bdrv_inc_in_flight(bs);
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
file);
if (ret < 0) {
*pnum = 0;
goto out;
}
if (ret & BDRV_BLOCK_RAW) {
assert(ret & BDRV_BLOCK_OFFSET_VALID && *file);
ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, pnum, file);
goto out;
}
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
} else {
if (bdrv_unallocated_blocks_are_zero(bs)) {
ret |= BDRV_BLOCK_ZERO;
} else if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t nb_sectors2 = bdrv_nb_sectors(bs2);
if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
ret |= BDRV_BLOCK_ZERO;
}
}
}
if (*file && *file != bs &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
BlockDriverState *file2;
int file_pnum;
ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, &file_pnum, &file2);
if (ret2 >= 0) {
/* Ignore errors. This is just providing extra information, it
* is useful but not necessary.
*/
if (ret2 & BDRV_BLOCK_EOF &&
(!file_pnum || ret2 & BDRV_BLOCK_ZERO)) {
/*
* It is valid for the format block driver to read
* beyond the end of the underlying file's current
* size; such areas read as zero.
*/
ret |= BDRV_BLOCK_ZERO;
} else {
/* Limit request to the range reported by the protocol driver */
*pnum = file_pnum;
ret |= (ret2 & BDRV_BLOCK_ZERO);
}
}
}
out:
bdrv_dec_in_flight(bs);
if (ret >= 0 && sector_num + *pnum == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
return ret;
}
| false | qemu | 298a1665a2800f7264e483c2dd1f551574243a2f | static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
int64_t total_sectors;
int64_t n;
int64_t ret, ret2;
*file = NULL;
total_sectors = bdrv_nb_sectors(bs);
if (total_sectors < 0) {
return total_sectors;
}
if (sector_num >= total_sectors) {
*pnum = 0;
return BDRV_BLOCK_EOF;
}
if (!nb_sectors) {
*pnum = 0;
return 0;
}
n = total_sectors - sector_num;
if (n < nb_sectors) {
nb_sectors = n;
}
if (!bs->drv->bdrv_co_get_block_status) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
if (sector_num + nb_sectors == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
if (bs->drv->protocol_name) {
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
*file = bs;
}
return ret;
}
bdrv_inc_in_flight(bs);
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
file);
if (ret < 0) {
*pnum = 0;
goto out;
}
if (ret & BDRV_BLOCK_RAW) {
assert(ret & BDRV_BLOCK_OFFSET_VALID && *file);
ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, pnum, file);
goto out;
}
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
} else {
if (bdrv_unallocated_blocks_are_zero(bs)) {
ret |= BDRV_BLOCK_ZERO;
} else if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t nb_sectors2 = bdrv_nb_sectors(bs2);
if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
ret |= BDRV_BLOCK_ZERO;
}
}
}
if (*file && *file != bs &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
BlockDriverState *file2;
int file_pnum;
ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, &file_pnum, &file2);
if (ret2 >= 0) {
if (ret2 & BDRV_BLOCK_EOF &&
(!file_pnum || ret2 & BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ZERO;
} else {
*pnum = file_pnum;
ret |= (ret2 & BDRV_BLOCK_ZERO);
}
}
}
out:
bdrv_dec_in_flight(bs);
if (ret >= 0 && sector_num + *pnum == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int64_t VAR_0 bdrv_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
int64_t total_sectors;
int64_t n;
int64_t ret, ret2;
*file = NULL;
total_sectors = bdrv_nb_sectors(bs);
if (total_sectors < 0) {
return total_sectors;
}
if (sector_num >= total_sectors) {
*pnum = 0;
return BDRV_BLOCK_EOF;
}
if (!nb_sectors) {
*pnum = 0;
return 0;
}
n = total_sectors - sector_num;
if (n < nb_sectors) {
nb_sectors = n;
}
if (!bs->drv->bdrv_co_get_block_status) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
if (sector_num + nb_sectors == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
if (bs->drv->protocol_name) {
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
*file = bs;
}
return ret;
}
bdrv_inc_in_flight(bs);
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
file);
if (ret < 0) {
*pnum = 0;
goto out;
}
if (ret & BDRV_BLOCK_RAW) {
assert(ret & BDRV_BLOCK_OFFSET_VALID && *file);
ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, pnum, file);
goto out;
}
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
} else {
if (bdrv_unallocated_blocks_are_zero(bs)) {
ret |= BDRV_BLOCK_ZERO;
} else if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t nb_sectors2 = bdrv_nb_sectors(bs2);
if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
ret |= BDRV_BLOCK_ZERO;
}
}
}
if (*file && *file != bs &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
BlockDriverState *file2;
int file_pnum;
ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
*pnum, &file_pnum, &file2);
if (ret2 >= 0) {
if (ret2 & BDRV_BLOCK_EOF &&
(!file_pnum || ret2 & BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ZERO;
} else {
*pnum = file_pnum;
ret |= (ret2 & BDRV_BLOCK_ZERO);
}
}
}
out:
bdrv_dec_in_flight(bs);
if (ret >= 0 && sector_num + *pnum == total_sectors) {
ret |= BDRV_BLOCK_EOF;
}
return ret;
}
| [
"static int64_t VAR_0 bdrv_co_get_block_status(BlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, int *pnum,\nBlockDriverState **file)\n{",
"int64_t total_sectors;",
"int64_t n;",
"int64_t ret, ret2;",
"*file = NULL;",
"total_sectors = bdrv_nb_sectors(bs);",
"if (total_sectors < 0) {",
"return total_sectors;",
"}",
"if (sector_num >= total_sectors) {",
"*pnum = 0;",
"return BDRV_BLOCK_EOF;",
"}",
"if (!nb_sectors) {",
"*pnum = 0;",
"return 0;",
"}",
"n = total_sectors - sector_num;",
"if (n < nb_sectors) {",
"nb_sectors = n;",
"}",
"if (!bs->drv->bdrv_co_get_block_status) {",
"*pnum = nb_sectors;",
"ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;",
"if (sector_num + nb_sectors == total_sectors) {",
"ret |= BDRV_BLOCK_EOF;",
"}",
"if (bs->drv->protocol_name) {",
"ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);",
"*file = bs;",
"}",
"return ret;",
"}",
"bdrv_inc_in_flight(bs);",
"ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,\nfile);",
"if (ret < 0) {",
"*pnum = 0;",
"goto out;",
"}",
"if (ret & BDRV_BLOCK_RAW) {",
"assert(ret & BDRV_BLOCK_OFFSET_VALID && *file);",
"ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,\n*pnum, pnum, file);",
"goto out;",
"}",
"if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {",
"ret |= BDRV_BLOCK_ALLOCATED;",
"} else {",
"if (bdrv_unallocated_blocks_are_zero(bs)) {",
"ret |= BDRV_BLOCK_ZERO;",
"} else if (bs->backing) {",
"BlockDriverState *bs2 = bs->backing->bs;",
"int64_t nb_sectors2 = bdrv_nb_sectors(bs2);",
"if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {",
"ret |= BDRV_BLOCK_ZERO;",
"}",
"}",
"}",
"if (*file && *file != bs &&\n(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&\n(ret & BDRV_BLOCK_OFFSET_VALID)) {",
"BlockDriverState *file2;",
"int file_pnum;",
"ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,\n*pnum, &file_pnum, &file2);",
"if (ret2 >= 0) {",
"if (ret2 & BDRV_BLOCK_EOF &&\n(!file_pnum || ret2 & BDRV_BLOCK_ZERO)) {",
"ret |= BDRV_BLOCK_ZERO;",
"} else {",
"*pnum = file_pnum;",
"ret |= (ret2 & BDRV_BLOCK_ZERO);",
"}",
"}",
"}",
"out:\nbdrv_dec_in_flight(bs);",
"if (ret >= 0 && sector_num + *pnum == total_sectors) {",
"ret |= BDRV_BLOCK_EOF;",
"}",
"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
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143,
145,
147
],
[
149
],
[
151
],
[
155,
157
],
[
159
],
[
167,
169
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
]
]
|
13,063 | static int dmg_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVDMGState *s = bs->opaque;
int i;
for(i=0;i<nb_sectors;i++) {
uint32_t sector_offset_in_chunk;
if(dmg_read_chunk(bs, sector_num+i) != 0)
return -1;
sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
}
return 0;
}
| false | qemu | 2c1885adcf0312da80c7317b09f9adad97fa0fc6 | static int dmg_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVDMGState *s = bs->opaque;
int i;
for(i=0;i<nb_sectors;i++) {
uint32_t sector_offset_in_chunk;
if(dmg_read_chunk(bs, sector_num+i) != 0)
return -1;
sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{
BDRVDMGState *s = VAR_0->opaque;
int VAR_4;
for(VAR_4=0;VAR_4<VAR_3;VAR_4++) {
uint32_t sector_offset_in_chunk;
if(dmg_read_chunk(VAR_0, VAR_1+VAR_4) != 0)
return -1;
sector_offset_in_chunk = VAR_1+VAR_4-s->sectors[s->current_chunk];
memcpy(VAR_2+VAR_4*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"BDRVDMGState *s = VAR_0->opaque;",
"int VAR_4;",
"for(VAR_4=0;VAR_4<VAR_3;VAR_4++) {",
"uint32_t sector_offset_in_chunk;",
"if(dmg_read_chunk(VAR_0, VAR_1+VAR_4) != 0)\nreturn -1;",
"sector_offset_in_chunk = VAR_1+VAR_4-s->sectors[s->current_chunk];",
"memcpy(VAR_2+VAR_4*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
13,064 | static int nbd_can_read(void *opaque)
{
NBDClient *client = opaque;
return client->recv_coroutine || client->nb_requests < MAX_NBD_REQUESTS;
}
| false | qemu | 958c717df97ea9ca47a2253b8371130fe5f22980 | static int nbd_can_read(void *opaque)
{
NBDClient *client = opaque;
return client->recv_coroutine || client->nb_requests < MAX_NBD_REQUESTS;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
NBDClient *client = VAR_0;
return client->recv_coroutine || client->nb_requests < MAX_NBD_REQUESTS;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"NBDClient *client = VAR_0;",
"return client->recv_coroutine || client->nb_requests < MAX_NBD_REQUESTS;",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
]
]
|
13,065 | int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size)
{
GetBitContext gb;
if (init_get_bits8(&gb, buf, size) < 0)
return DCA_PARSE_ERROR_INVALIDDATA;
return ff_dca_parse_core_frame_header(h, &gb);
}
| false | FFmpeg | 3df4939988ace682f7ac0366ef8fd700d207e6b6 | int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size)
{
GetBitContext gb;
if (init_get_bits8(&gb, buf, size) < 0)
return DCA_PARSE_ERROR_INVALIDDATA;
return ff_dca_parse_core_frame_header(h, &gb);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(DCACoreFrameHeader *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
GetBitContext gb;
if (init_get_bits8(&gb, VAR_1, VAR_2) < 0)
return DCA_PARSE_ERROR_INVALIDDATA;
return ff_dca_parse_core_frame_header(VAR_0, &gb);
}
| [
"int FUNC_0(DCACoreFrameHeader *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"GetBitContext gb;",
"if (init_get_bits8(&gb, VAR_1, VAR_2) < 0)\nreturn DCA_PARSE_ERROR_INVALIDDATA;",
"return ff_dca_parse_core_frame_header(VAR_0, &gb);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
]
]
|
13,066 | static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
unsigned int i;
void *iommu, *espdma, *ledma, *nvram;
qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],
espdma_irq, ledma_irq;
qemu_irq esp_reset, dma_enable;
qemu_irq fdc_tc;
qemu_irq *cpu_halt;
unsigned long kernel_size;
DriveInfo *fd[MAX_FD];
FWCfgState *fw_cfg;
unsigned int num_vsimms;
/* init CPUs */
if (!cpu_model)
cpu_model = hwdef->default_cpu_model;
for(i = 0; i < smp_cpus; i++) {
cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
}
for (i = smp_cpus; i < MAX_CPUS; i++)
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
/* set up devices */
ram_init(0, machine->ram_size, hwdef->max_mem);
/* models without ECC don't trap when missing ram is accessed */
if (!hwdef->ecc_base) {
empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_size);
}
prom_init(hwdef->slavio_base, bios_name);
slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
hwdef->intctl_base + 0x10000ULL,
cpu_irqs);
for (i = 0; i < 32; i++) {
slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i);
}
for (i = 0; i < MAX_CPUS; i++) {
slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i);
}
if (hwdef->idreg_base) {
idreg_init(hwdef->idreg_base);
}
if (hwdef->afx_base) {
afx_init(hwdef->afx_base);
}
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
slavio_irq[30]);
if (hwdef->iommu_pad_base) {
/* On the real hardware (SS-5, LX) the MMU is not padded, but aliased.
Software shouldn't use aliased addresses, neither should it crash
when does. Using empty_slot instead of aliasing can help with
debugging such accesses */
empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len);
}
espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18],
iommu, &espdma_irq, 0);
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
slavio_irq[16], iommu, &ledma_irq, 1);
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit (1);
}
num_vsimms = 0;
if (num_vsimms == 0) {
if (vga_interface_type == VGA_CG3) {
if (graphic_depth != 8) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768) &&
!(graphic_width == 1152 && graphic_height == 900)) {
error_report("Unsupported resolution: %d x %d", graphic_width,
graphic_height);
exit(1);
}
/* sbus irq 5 */
cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
} else {
/* If no display specified, default to TCX */
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768)) {
error_report("Unsupported resolution: %d x %d",
graphic_width, graphic_height);
exit(1);
}
tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
}
}
for (i = num_vsimms; i < MAX_VSIMMS; i++) {
/* vsimm registers probed by OBP */
if (hwdef->vsimm[i].reg_base) {
empty_slot_init(hwdef->vsimm[i].reg_base, 0x2000);
}
}
if (hwdef->sx_base) {
empty_slot_init(hwdef->sx_base, 0x2000);
}
lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 1968, 8);
slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
/* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
if (hwdef->apc_base) {
apc_init(hwdef->apc_base, cpu_halt[0]);
}
if (hwdef->fd_base) {
/* there is zero or one floppy drive */
memset(fd, 0, sizeof(fd));
fd[0] = drive_get(IF_FLOPPY, 0, 0);
sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
&fdc_tc);
} else {
fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1);
}
slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[30], fdc_tc);
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
esp_init(hwdef->esp_base, 2,
espdma_memory_read, espdma_memory_write,
espdma, espdma_irq, &esp_reset, &dma_enable);
qdev_connect_gpio_out(espdma, 0, esp_reset);
qdev_connect_gpio_out(espdma, 1, dma_enable);
if (hwdef->cs_base) {
sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
slavio_irq[5]);
}
if (hwdef->dbri_base) {
/* ISDN chip with attached CS4215 audio codec */
/* prom space */
empty_slot_init(hwdef->dbri_base+0x1000, 0x30);
/* reg space */
empty_slot_init(hwdef->dbri_base+0x10000, 0x100);
}
if (hwdef->bpp_base) {
/* parallel port */
empty_slot_init(hwdef->bpp_base, 0x20);
}
kernel_size = sun4m_load_kernel(machine->kernel_filename,
machine->initrd_filename,
machine->ram_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, machine->kernel_cmdline,
machine->boot_order, machine->ram_size, kernel_size,
graphic_width, graphic_height, graphic_depth,
hwdef->nvram_machine_id, "Sun4m");
if (hwdef->ecc_base)
ecc_init(hwdef->ecc_base, slavio_irq[28],
hwdef->ecc_version);
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (machine->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(machine->kernel_cmdline) + 1);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| false | qemu | 3a5c76baf312d83cb77c8faa72c5f7a477effed0 | static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
unsigned int i;
void *iommu, *espdma, *ledma, *nvram;
qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],
espdma_irq, ledma_irq;
qemu_irq esp_reset, dma_enable;
qemu_irq fdc_tc;
qemu_irq *cpu_halt;
unsigned long kernel_size;
DriveInfo *fd[MAX_FD];
FWCfgState *fw_cfg;
unsigned int num_vsimms;
if (!cpu_model)
cpu_model = hwdef->default_cpu_model;
for(i = 0; i < smp_cpus; i++) {
cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
}
for (i = smp_cpus; i < MAX_CPUS; i++)
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
ram_init(0, machine->ram_size, hwdef->max_mem);
if (!hwdef->ecc_base) {
empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_size);
}
prom_init(hwdef->slavio_base, bios_name);
slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
hwdef->intctl_base + 0x10000ULL,
cpu_irqs);
for (i = 0; i < 32; i++) {
slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i);
}
for (i = 0; i < MAX_CPUS; i++) {
slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i);
}
if (hwdef->idreg_base) {
idreg_init(hwdef->idreg_base);
}
if (hwdef->afx_base) {
afx_init(hwdef->afx_base);
}
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
slavio_irq[30]);
if (hwdef->iommu_pad_base) {
empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len);
}
espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18],
iommu, &espdma_irq, 0);
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
slavio_irq[16], iommu, &ledma_irq, 1);
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit (1);
}
num_vsimms = 0;
if (num_vsimms == 0) {
if (vga_interface_type == VGA_CG3) {
if (graphic_depth != 8) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768) &&
!(graphic_width == 1152 && graphic_height == 900)) {
error_report("Unsupported resolution: %d x %d", graphic_width,
graphic_height);
exit(1);
}
cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
} else {
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768)) {
error_report("Unsupported resolution: %d x %d",
graphic_width, graphic_height);
exit(1);
}
tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
}
}
for (i = num_vsimms; i < MAX_VSIMMS; i++) {
if (hwdef->vsimm[i].reg_base) {
empty_slot_init(hwdef->vsimm[i].reg_base, 0x2000);
}
}
if (hwdef->sx_base) {
empty_slot_init(hwdef->sx_base, 0x2000);
}
lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 1968, 8);
slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
if (hwdef->apc_base) {
apc_init(hwdef->apc_base, cpu_halt[0]);
}
if (hwdef->fd_base) {
memset(fd, 0, sizeof(fd));
fd[0] = drive_get(IF_FLOPPY, 0, 0);
sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
&fdc_tc);
} else {
fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1);
}
slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[30], fdc_tc);
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
esp_init(hwdef->esp_base, 2,
espdma_memory_read, espdma_memory_write,
espdma, espdma_irq, &esp_reset, &dma_enable);
qdev_connect_gpio_out(espdma, 0, esp_reset);
qdev_connect_gpio_out(espdma, 1, dma_enable);
if (hwdef->cs_base) {
sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
slavio_irq[5]);
}
if (hwdef->dbri_base) {
empty_slot_init(hwdef->dbri_base+0x1000, 0x30);
empty_slot_init(hwdef->dbri_base+0x10000, 0x100);
}
if (hwdef->bpp_base) {
empty_slot_init(hwdef->bpp_base, 0x20);
}
kernel_size = sun4m_load_kernel(machine->kernel_filename,
machine->initrd_filename,
machine->ram_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, machine->kernel_cmdline,
machine->boot_order, machine->ram_size, kernel_size,
graphic_width, graphic_height, graphic_depth,
hwdef->nvram_machine_id, "Sun4m");
if (hwdef->ecc_base)
ecc_init(hwdef->ecc_base, slavio_irq[28],
hwdef->ecc_version);
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (machine->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(machine->kernel_cmdline) + 1);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const struct sun4m_hwdef *VAR_0,
MachineState *VAR_1)
{
const char *VAR_2 = VAR_1->VAR_2;
unsigned int VAR_3;
void *VAR_4, *VAR_5, *VAR_6, *VAR_7;
qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],
espdma_irq, ledma_irq;
qemu_irq esp_reset, dma_enable;
qemu_irq fdc_tc;
qemu_irq *cpu_halt;
unsigned long VAR_8;
DriveInfo *fd[MAX_FD];
FWCfgState *fw_cfg;
unsigned int VAR_9;
if (!VAR_2)
VAR_2 = VAR_0->default_cpu_model;
for(VAR_3 = 0; VAR_3 < smp_cpus; VAR_3++) {
cpu_devinit(VAR_2, VAR_3, VAR_0->slavio_base, &cpu_irqs[VAR_3]);
}
for (VAR_3 = smp_cpus; VAR_3 < MAX_CPUS; VAR_3++)
cpu_irqs[VAR_3] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
ram_init(0, VAR_1->ram_size, VAR_0->max_mem);
if (!VAR_0->ecc_base) {
empty_slot_init(VAR_1->ram_size, VAR_0->max_mem - VAR_1->ram_size);
}
prom_init(VAR_0->slavio_base, bios_name);
slavio_intctl = slavio_intctl_init(VAR_0->intctl_base,
VAR_0->intctl_base + 0x10000ULL,
cpu_irqs);
for (VAR_3 = 0; VAR_3 < 32; VAR_3++) {
slavio_irq[VAR_3] = qdev_get_gpio_in(slavio_intctl, VAR_3);
}
for (VAR_3 = 0; VAR_3 < MAX_CPUS; VAR_3++) {
slavio_cpu_irq[VAR_3] = qdev_get_gpio_in(slavio_intctl, 32 + VAR_3);
}
if (VAR_0->idreg_base) {
idreg_init(VAR_0->idreg_base);
}
if (VAR_0->afx_base) {
afx_init(VAR_0->afx_base);
}
VAR_4 = iommu_init(VAR_0->iommu_base, VAR_0->iommu_version,
slavio_irq[30]);
if (VAR_0->iommu_pad_base) {
empty_slot_init(VAR_0->iommu_pad_base,VAR_0->iommu_pad_len);
}
VAR_5 = sparc32_dma_init(VAR_0->dma_base, slavio_irq[18],
VAR_4, &espdma_irq, 0);
VAR_6 = sparc32_dma_init(VAR_0->dma_base + 16ULL,
slavio_irq[16], VAR_4, &ledma_irq, 1);
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit (1);
}
VAR_9 = 0;
if (VAR_9 == 0) {
if (vga_interface_type == VGA_CG3) {
if (graphic_depth != 8) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768) &&
!(graphic_width == 1152 && graphic_height == 900)) {
error_report("Unsupported resolution: %d x %d", graphic_width,
graphic_height);
exit(1);
}
cg3_init(VAR_0->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
} else {
if (graphic_depth != 8 && graphic_depth != 24) {
error_report("Unsupported depth: %d", graphic_depth);
exit(1);
}
if (!(graphic_width == 1024 && graphic_height == 768)) {
error_report("Unsupported resolution: %d x %d",
graphic_width, graphic_height);
exit(1);
}
tcx_init(VAR_0->tcx_base, slavio_irq[11], 0x00100000,
graphic_width, graphic_height, graphic_depth);
}
}
for (VAR_3 = VAR_9; VAR_3 < MAX_VSIMMS; VAR_3++) {
if (VAR_0->vsimm[VAR_3].reg_base) {
empty_slot_init(VAR_0->vsimm[VAR_3].reg_base, 0x2000);
}
}
if (VAR_0->sx_base) {
empty_slot_init(VAR_0->sx_base, 0x2000);
}
lance_init(&nd_table[0], VAR_0->le_base, VAR_6, ledma_irq);
VAR_7 = m48t59_init(slavio_irq[0], VAR_0->nvram_base, 0, 0x2000, 1968, 8);
slavio_timer_init_all(VAR_0->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(VAR_0->ms_kb_base, slavio_irq[14],
display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
escc_init(VAR_0->serial_base, slavio_irq[15], slavio_irq[15],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
if (VAR_0->apc_base) {
apc_init(VAR_0->apc_base, cpu_halt[0]);
}
if (VAR_0->fd_base) {
memset(fd, 0, sizeof(fd));
fd[0] = drive_get(IF_FLOPPY, 0, 0);
sun4m_fdctrl_init(slavio_irq[22], VAR_0->fd_base, fd,
&fdc_tc);
} else {
fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1);
}
slavio_misc_init(VAR_0->slavio_base, VAR_0->aux1_base, VAR_0->aux2_base,
slavio_irq[30], fdc_tc);
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
esp_init(VAR_0->esp_base, 2,
espdma_memory_read, espdma_memory_write,
VAR_5, espdma_irq, &esp_reset, &dma_enable);
qdev_connect_gpio_out(VAR_5, 0, esp_reset);
qdev_connect_gpio_out(VAR_5, 1, dma_enable);
if (VAR_0->cs_base) {
sysbus_create_simple("SUNW,CS4231", VAR_0->cs_base,
slavio_irq[5]);
}
if (VAR_0->dbri_base) {
empty_slot_init(VAR_0->dbri_base+0x1000, 0x30);
empty_slot_init(VAR_0->dbri_base+0x10000, 0x100);
}
if (VAR_0->bpp_base) {
empty_slot_init(VAR_0->bpp_base, 0x20);
}
VAR_8 = sun4m_load_kernel(VAR_1->kernel_filename,
VAR_1->initrd_filename,
VAR_1->ram_size);
nvram_init(VAR_7, (uint8_t *)&nd_table[0].macaddr, VAR_1->kernel_cmdline,
VAR_1->boot_order, VAR_1->ram_size, VAR_8,
graphic_width, graphic_height, graphic_depth,
VAR_0->nvram_machine_id, "Sun4m");
if (VAR_0->ecc_base)
ecc_init(VAR_0->ecc_base, slavio_irq[28],
VAR_0->ecc_version);
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, VAR_0->machine_id);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, VAR_8);
if (VAR_1->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
VAR_1->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, VAR_1->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(VAR_1->kernel_cmdline) + 1);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, VAR_1->boot_order[0]);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| [
"static void FUNC_0(const struct sun4m_hwdef *VAR_0,\nMachineState *VAR_1)\n{",
"const char *VAR_2 = VAR_1->VAR_2;",
"unsigned int VAR_3;",
"void *VAR_4, *VAR_5, *VAR_6, *VAR_7;",
"qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],\nespdma_irq, ledma_irq;",
"qemu_irq esp_reset, dma_enable;",
"qemu_irq fdc_tc;",
"qemu_irq *cpu_halt;",
"unsigned long VAR_8;",
"DriveInfo *fd[MAX_FD];",
"FWCfgState *fw_cfg;",
"unsigned int VAR_9;",
"if (!VAR_2)\nVAR_2 = VAR_0->default_cpu_model;",
"for(VAR_3 = 0; VAR_3 < smp_cpus; VAR_3++) {",
"cpu_devinit(VAR_2, VAR_3, VAR_0->slavio_base, &cpu_irqs[VAR_3]);",
"}",
"for (VAR_3 = smp_cpus; VAR_3 < MAX_CPUS; VAR_3++)",
"cpu_irqs[VAR_3] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);",
"ram_init(0, VAR_1->ram_size, VAR_0->max_mem);",
"if (!VAR_0->ecc_base) {",
"empty_slot_init(VAR_1->ram_size, VAR_0->max_mem - VAR_1->ram_size);",
"}",
"prom_init(VAR_0->slavio_base, bios_name);",
"slavio_intctl = slavio_intctl_init(VAR_0->intctl_base,\nVAR_0->intctl_base + 0x10000ULL,\ncpu_irqs);",
"for (VAR_3 = 0; VAR_3 < 32; VAR_3++) {",
"slavio_irq[VAR_3] = qdev_get_gpio_in(slavio_intctl, VAR_3);",
"}",
"for (VAR_3 = 0; VAR_3 < MAX_CPUS; VAR_3++) {",
"slavio_cpu_irq[VAR_3] = qdev_get_gpio_in(slavio_intctl, 32 + VAR_3);",
"}",
"if (VAR_0->idreg_base) {",
"idreg_init(VAR_0->idreg_base);",
"}",
"if (VAR_0->afx_base) {",
"afx_init(VAR_0->afx_base);",
"}",
"VAR_4 = iommu_init(VAR_0->iommu_base, VAR_0->iommu_version,\nslavio_irq[30]);",
"if (VAR_0->iommu_pad_base) {",
"empty_slot_init(VAR_0->iommu_pad_base,VAR_0->iommu_pad_len);",
"}",
"VAR_5 = sparc32_dma_init(VAR_0->dma_base, slavio_irq[18],\nVAR_4, &espdma_irq, 0);",
"VAR_6 = sparc32_dma_init(VAR_0->dma_base + 16ULL,\nslavio_irq[16], VAR_4, &ledma_irq, 1);",
"if (graphic_depth != 8 && graphic_depth != 24) {",
"error_report(\"Unsupported depth: %d\", graphic_depth);",
"exit (1);",
"}",
"VAR_9 = 0;",
"if (VAR_9 == 0) {",
"if (vga_interface_type == VGA_CG3) {",
"if (graphic_depth != 8) {",
"error_report(\"Unsupported depth: %d\", graphic_depth);",
"exit(1);",
"}",
"if (!(graphic_width == 1024 && graphic_height == 768) &&\n!(graphic_width == 1152 && graphic_height == 900)) {",
"error_report(\"Unsupported resolution: %d x %d\", graphic_width,\ngraphic_height);",
"exit(1);",
"}",
"cg3_init(VAR_0->tcx_base, slavio_irq[11], 0x00100000,\ngraphic_width, graphic_height, graphic_depth);",
"} else {",
"if (graphic_depth != 8 && graphic_depth != 24) {",
"error_report(\"Unsupported depth: %d\", graphic_depth);",
"exit(1);",
"}",
"if (!(graphic_width == 1024 && graphic_height == 768)) {",
"error_report(\"Unsupported resolution: %d x %d\",\ngraphic_width, graphic_height);",
"exit(1);",
"}",
"tcx_init(VAR_0->tcx_base, slavio_irq[11], 0x00100000,\ngraphic_width, graphic_height, graphic_depth);",
"}",
"}",
"for (VAR_3 = VAR_9; VAR_3 < MAX_VSIMMS; VAR_3++) {",
"if (VAR_0->vsimm[VAR_3].reg_base) {",
"empty_slot_init(VAR_0->vsimm[VAR_3].reg_base, 0x2000);",
"}",
"}",
"if (VAR_0->sx_base) {",
"empty_slot_init(VAR_0->sx_base, 0x2000);",
"}",
"lance_init(&nd_table[0], VAR_0->le_base, VAR_6, ledma_irq);",
"VAR_7 = m48t59_init(slavio_irq[0], VAR_0->nvram_base, 0, 0x2000, 1968, 8);",
"slavio_timer_init_all(VAR_0->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);",
"slavio_serial_ms_kbd_init(VAR_0->ms_kb_base, slavio_irq[14],\ndisplay_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);",
"escc_init(VAR_0->serial_base, slavio_irq[15], slavio_irq[15],\nserial_hds[0], serial_hds[1], ESCC_CLOCK, 1);",
"cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);",
"if (VAR_0->apc_base) {",
"apc_init(VAR_0->apc_base, cpu_halt[0]);",
"}",
"if (VAR_0->fd_base) {",
"memset(fd, 0, sizeof(fd));",
"fd[0] = drive_get(IF_FLOPPY, 0, 0);",
"sun4m_fdctrl_init(slavio_irq[22], VAR_0->fd_base, fd,\n&fdc_tc);",
"} else {",
"fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1);",
"}",
"slavio_misc_init(VAR_0->slavio_base, VAR_0->aux1_base, VAR_0->aux2_base,\nslavio_irq[30], fdc_tc);",
"if (drive_get_max_bus(IF_SCSI) > 0) {",
"fprintf(stderr, \"qemu: too many SCSI bus\\n\");",
"exit(1);",
"}",
"esp_init(VAR_0->esp_base, 2,\nespdma_memory_read, espdma_memory_write,\nVAR_5, espdma_irq, &esp_reset, &dma_enable);",
"qdev_connect_gpio_out(VAR_5, 0, esp_reset);",
"qdev_connect_gpio_out(VAR_5, 1, dma_enable);",
"if (VAR_0->cs_base) {",
"sysbus_create_simple(\"SUNW,CS4231\", VAR_0->cs_base,\nslavio_irq[5]);",
"}",
"if (VAR_0->dbri_base) {",
"empty_slot_init(VAR_0->dbri_base+0x1000, 0x30);",
"empty_slot_init(VAR_0->dbri_base+0x10000, 0x100);",
"}",
"if (VAR_0->bpp_base) {",
"empty_slot_init(VAR_0->bpp_base, 0x20);",
"}",
"VAR_8 = sun4m_load_kernel(VAR_1->kernel_filename,\nVAR_1->initrd_filename,\nVAR_1->ram_size);",
"nvram_init(VAR_7, (uint8_t *)&nd_table[0].macaddr, VAR_1->kernel_cmdline,\nVAR_1->boot_order, VAR_1->ram_size, VAR_8,\ngraphic_width, graphic_height, graphic_depth,\nVAR_0->nvram_machine_id, \"Sun4m\");",
"if (VAR_0->ecc_base)\necc_init(VAR_0->ecc_base, slavio_irq[28],\nVAR_0->ecc_version);",
"fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);",
"fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, VAR_0->machine_id);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, VAR_8);",
"if (VAR_1->kernel_cmdline) {",
"fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);",
"pstrcpy_targphys(\"cmdline\", CMDLINE_ADDR, TARGET_PAGE_SIZE,\nVAR_1->kernel_cmdline);",
"fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, VAR_1->kernel_cmdline);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,\nstrlen(VAR_1->kernel_cmdline) + 1);",
"} else {",
"fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);",
"}",
"fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);",
"fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0);",
"fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, VAR_1->boot_order[0]);",
"qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
119
],
[
129
],
[
131
],
[
135,
137
],
[
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171,
173
],
[
175,
177
],
[
179
],
[
181
],
[
187,
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
217,
219
],
[
221
],
[
223
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
249
],
[
253
],
[
257
],
[
261,
263
],
[
269,
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
305,
307
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321,
323,
325
],
[
329
],
[
331
],
[
335
],
[
337,
339
],
[
341
],
[
345
],
[
351
],
[
355
],
[
357
],
[
361
],
[
365
],
[
367
],
[
371,
373,
375
],
[
379,
381,
383,
385
],
[
389,
391,
393
],
[
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
]
]
|
13,067 | static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
RDMALocalBlock *block =
&(rdma->local_ram_blocks.block[rdma->current_index]);
uint8_t *host_addr = block->local_host_addr + (offset - block->offset);
uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
}
/*
* Only merge into chunk sequentially.
*/
if (offset != (rdma->current_addr + rdma->current_length)) {
return 0;
}
if (rdma->current_index < 0) {
return 0;
}
if (offset < block->offset) {
return 0;
}
if ((offset + len) > (block->offset + block->length)) {
return 0;
}
if (rdma->current_chunk < 0) {
return 0;
}
if ((host_addr + len) > chunk_end) {
return 0;
}
return 1;
}
| false | qemu | 44b5949491a47043c4f7c4ff09f0191f82919a82 | static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
RDMALocalBlock *block =
&(rdma->local_ram_blocks.block[rdma->current_index]);
uint8_t *host_addr = block->local_host_addr + (offset - block->offset);
uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
}
if (offset != (rdma->current_addr + rdma->current_length)) {
return 0;
}
if (rdma->current_index < 0) {
return 0;
}
if (offset < block->offset) {
return 0;
}
if ((offset + len) > (block->offset + block->length)) {
return 0;
}
if (rdma->current_chunk < 0) {
return 0;
}
if ((host_addr + len) > chunk_end) {
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(RDMAContext *VAR_0,
uint64_t VAR_1, uint64_t VAR_2)
{
RDMALocalBlock *block =
&(VAR_0->local_ram_blocks.block[VAR_0->current_index]);
uint8_t *host_addr = block->local_host_addr + (VAR_1 - block->VAR_1);
uint8_t *chunk_end = ram_chunk_end(block, VAR_0->current_chunk);
if (VAR_0->current_length == 0) {
return 0;
}
if (VAR_1 != (VAR_0->current_addr + VAR_0->current_length)) {
return 0;
}
if (VAR_0->current_index < 0) {
return 0;
}
if (VAR_1 < block->VAR_1) {
return 0;
}
if ((VAR_1 + VAR_2) > (block->VAR_1 + block->length)) {
return 0;
}
if (VAR_0->current_chunk < 0) {
return 0;
}
if ((host_addr + VAR_2) > chunk_end) {
return 0;
}
return 1;
}
| [
"static inline int FUNC_0(RDMAContext *VAR_0,\nuint64_t VAR_1, uint64_t VAR_2)\n{",
"RDMALocalBlock *block =\n&(VAR_0->local_ram_blocks.block[VAR_0->current_index]);",
"uint8_t *host_addr = block->local_host_addr + (VAR_1 - block->VAR_1);",
"uint8_t *chunk_end = ram_chunk_end(block, VAR_0->current_chunk);",
"if (VAR_0->current_length == 0) {",
"return 0;",
"}",
"if (VAR_1 != (VAR_0->current_addr + VAR_0->current_length)) {",
"return 0;",
"}",
"if (VAR_0->current_index < 0) {",
"return 0;",
"}",
"if (VAR_1 < block->VAR_1) {",
"return 0;",
"}",
"if ((VAR_1 + VAR_2) > (block->VAR_1 + block->length)) {",
"return 0;",
"}",
"if (VAR_0->current_chunk < 0) {",
"return 0;",
"}",
"if ((host_addr + VAR_2) > chunk_end) {",
"return 0;",
"}",
"return 1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
]
]
|
13,069 | static int ogg_new_buf(struct ogg *ogg, int idx)
{
struct ogg_stream *os = ogg->streams + idx;
uint8_t *nb = av_malloc(os->bufsize);
int size = os->bufpos - os->pstart;
if(os->buf){
memcpy(nb, os->buf + os->pstart, size);
av_free(os->buf);
}
os->buf = nb;
os->bufpos = size;
os->pstart = 0;
return 0;
}
| true | FFmpeg | ef0d779706c77ca9007527bd8d41e9400682f4e4 | static int ogg_new_buf(struct ogg *ogg, int idx)
{
struct ogg_stream *os = ogg->streams + idx;
uint8_t *nb = av_malloc(os->bufsize);
int size = os->bufpos - os->pstart;
if(os->buf){
memcpy(nb, os->buf + os->pstart, size);
av_free(os->buf);
}
os->buf = nb;
os->bufpos = size;
os->pstart = 0;
return 0;
}
| {
"code": [
" uint8_t *nb = av_malloc(os->bufsize);"
],
"line_no": [
7
]
} | static int FUNC_0(struct VAR_0 *VAR_0, int VAR_1)
{
struct ogg_stream *VAR_2 = VAR_0->streams + VAR_1;
uint8_t *nb = av_malloc(VAR_2->bufsize);
int VAR_3 = VAR_2->bufpos - VAR_2->pstart;
if(VAR_2->buf){
memcpy(nb, VAR_2->buf + VAR_2->pstart, VAR_3);
av_free(VAR_2->buf);
}
VAR_2->buf = nb;
VAR_2->bufpos = VAR_3;
VAR_2->pstart = 0;
return 0;
}
| [
"static int FUNC_0(struct VAR_0 *VAR_0, int VAR_1)\n{",
"struct ogg_stream *VAR_2 = VAR_0->streams + VAR_1;",
"uint8_t *nb = av_malloc(VAR_2->bufsize);",
"int VAR_3 = VAR_2->bufpos - VAR_2->pstart;",
"if(VAR_2->buf){",
"memcpy(nb, VAR_2->buf + VAR_2->pstart, VAR_3);",
"av_free(VAR_2->buf);",
"}",
"VAR_2->buf = nb;",
"VAR_2->bufpos = VAR_3;",
"VAR_2->pstart = 0;",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
]
|
13,070 | void s390_memory_init(ram_addr_t mem_size)
{
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
/* allocate RAM for core */
memory_region_init_ram(ram, NULL, "s390.ram", mem_size, &error_abort);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);
/* Initialize storage key device */
s390_skeys_init();
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | void s390_memory_init(ram_addr_t mem_size)
{
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
memory_region_init_ram(ram, NULL, "s390.ram", mem_size, &error_abort);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);
s390_skeys_init();
}
| {
"code": [
" memory_region_init_ram(ram, NULL, \"s390.ram\", mem_size, &error_abort);"
],
"line_no": [
13
]
} | void FUNC_0(ram_addr_t VAR_0)
{
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
memory_region_init_ram(ram, NULL, "s390.ram", VAR_0, &error_abort);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);
s390_skeys_init();
}
| [
"void FUNC_0(ram_addr_t VAR_0)\n{",
"MemoryRegion *sysmem = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"memory_region_init_ram(ram, NULL, \"s390.ram\", VAR_0, &error_abort);",
"vmstate_register_ram_global(ram);",
"memory_region_add_subregion(sysmem, 0, ram);",
"s390_skeys_init();",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
]
]
|
13,071 | static void tracked_request_begin(BdrvTrackedRequest *req,
BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, bool is_write)
*req = (BdrvTrackedRequest){
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
};
QLIST_INSERT_HEAD(&bs->tracked_requests, req, list); | true | qemu | f4658285f99473367dbbc34ce6970ec4637c2388 | static void tracked_request_begin(BdrvTrackedRequest *req,
BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, bool is_write)
*req = (BdrvTrackedRequest){
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
};
QLIST_INSERT_HEAD(&bs->tracked_requests, req, list); | {
"code": [],
"line_no": []
} | static void tracked_request_begin(BdrvTrackedRequest *req,
BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, bool is_write)
*req = (BdrvTrackedRequest){
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
};
FUNC_0(&bs->tracked_requests, req, list); | [
"static void tracked_request_begin(BdrvTrackedRequest *req,\nBlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, bool is_write)\n*req = (BdrvTrackedRequest){",
".bs = bs,\n.sector_num = sector_num,\n.nb_sectors = nb_sectors,\n.is_write = is_write,\n};",
"FUNC_0(&bs->tracked_requests, req, list);"
]
| [
0,
0,
0
]
| [
[
1,
2,
3,
4,
5
],
[
6,
7,
8,
9,
10
],
[
11
]
]
|
13,072 | static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc;
int sps_id, i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
get_bits1(&s->gb); //constraint_set0_flag
get_bits1(&s->gb); //constraint_set1_flag
get_bits1(&s->gb); //constraint_set2_flag
get_bits1(&s->gb); //constraint_set3_flag
get_bits(&s->gb, 4); // reserved
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb(&s->gb);
sps= &h->sps_buffer[ sps_id ];
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
if(sps->profile_idc >= 100){ //high profile
if(get_ue_golomb(&s->gb) == 3) //chroma_format_idc
get_bits1(&s->gb); //residual_color_transform_flag
get_ue_golomb(&s->gb); //bit_depth_luma_minus8
get_ue_golomb(&s->gb); //bit_depth_chroma_minus8
sps->transform_bypass = get_bits1(&s->gb);
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
}else
sps->scaling_matrix_present = 0;
sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
sps->poc_type= get_ue_golomb(&s->gb);
if(sps->poc_type == 0){ //FIXME #define
sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;
} else if(sps->poc_type == 1){//FIXME #define
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
sps->poc_cycle_length= get_ue_golomb(&s->gb);
for(i=0; i<sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
}
if(sps->poc_type > 2){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
sps->ref_frame_count= get_ue_golomb(&s->gb);
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
sps->mb_width= get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))
return -1;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
sps->mb_aff= get_bits1(&s->gb);
else
sps->mb_aff= 0;
sps->direct_8x8_inference_flag= get_bits1(&s->gb);
#ifndef ALLOW_INTERLACE
if(sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n");
#endif
if(!sps->direct_8x8_inference_flag && sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF + !direct_8x8_inference is not implemented\n");
sps->crop= get_bits1(&s->gb);
if(sps->crop){
sps->crop_left = get_ue_golomb(&s->gb);
sps->crop_right = get_ue_golomb(&s->gb);
sps->crop_top = get_ue_golomb(&s->gb);
sps->crop_bottom= get_ue_golomb(&s->gb);
if(sps->crop_left || sps->crop_top){
av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
}
}else{
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom= 0;
}
sps->vui_parameters_present_flag= get_bits1(&s->gb);
if( sps->vui_parameters_present_flag )
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : ""
);
}
return 0;
}
| true | FFmpeg | ac658be5db5baa01546715994fbd193a855cbc73 | static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc;
int sps_id, i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits(&s->gb, 4);
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb(&s->gb);
sps= &h->sps_buffer[ sps_id ];
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
if(sps->profile_idc >= 100){
if(get_ue_golomb(&s->gb) == 3)
get_bits1(&s->gb);
get_ue_golomb(&s->gb);
get_ue_golomb(&s->gb);
sps->transform_bypass = get_bits1(&s->gb);
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
}else
sps->scaling_matrix_present = 0;
sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
sps->poc_type= get_ue_golomb(&s->gb);
if(sps->poc_type == 0){
sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;
} else if(sps->poc_type == 1){
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
sps->poc_cycle_length= get_ue_golomb(&s->gb);
for(i=0; i<sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
}
if(sps->poc_type > 2){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
sps->ref_frame_count= get_ue_golomb(&s->gb);
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
sps->mb_width= get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))
return -1;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
sps->mb_aff= get_bits1(&s->gb);
else
sps->mb_aff= 0;
sps->direct_8x8_inference_flag= get_bits1(&s->gb);
#ifndef ALLOW_INTERLACE
if(sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n");
#endif
if(!sps->direct_8x8_inference_flag && sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF + !direct_8x8_inference is not implemented\n");
sps->crop= get_bits1(&s->gb);
if(sps->crop){
sps->crop_left = get_ue_golomb(&s->gb);
sps->crop_right = get_ue_golomb(&s->gb);
sps->crop_top = get_ue_golomb(&s->gb);
sps->crop_bottom= get_ue_golomb(&s->gb);
if(sps->crop_left || sps->crop_top){
av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
}
}else{
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom= 0;
}
sps->vui_parameters_present_flag= get_bits1(&s->gb);
if( sps->vui_parameters_present_flag )
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : ""
);
}
return 0;
}
| {
"code": [
" int sps_id, i;",
" av_log(h->s.avctx, AV_LOG_DEBUG, \"sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\\n\","
],
"line_no": [
7,
191
]
} | static inline int FUNC_0(H264Context *VAR_0){
MpegEncContext * const s = &VAR_0->s;
int VAR_1, VAR_2;
int VAR_3, VAR_4;
SPS *sps;
VAR_1= get_bits(&s->gb, 8);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits(&s->gb, 4);
VAR_2= get_bits(&s->gb, 8);
VAR_3= get_ue_golomb(&s->gb);
sps= &VAR_0->sps_buffer[ VAR_3 ];
sps->VAR_1= VAR_1;
sps->VAR_2= VAR_2;
if(sps->VAR_1 >= 100){
if(get_ue_golomb(&s->gb) == 3)
get_bits1(&s->gb);
get_ue_golomb(&s->gb);
get_ue_golomb(&s->gb);
sps->transform_bypass = get_bits1(&s->gb);
decode_scaling_matrices(VAR_0, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
}else
sps->scaling_matrix_present = 0;
sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
sps->poc_type= get_ue_golomb(&s->gb);
if(sps->poc_type == 0){
sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;
} else if(sps->poc_type == 1){
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
sps->poc_cycle_length= get_ue_golomb(&s->gb);
for(VAR_4=0; VAR_4<sps->poc_cycle_length; VAR_4++)
sps->offset_for_ref_frame[VAR_4]= get_se_golomb(&s->gb);
}
if(sps->poc_type > 2){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
sps->ref_frame_count= get_ue_golomb(&s->gb);
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
sps->mb_width= get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))
return -1;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
sps->mb_aff= get_bits1(&s->gb);
else
sps->mb_aff= 0;
sps->direct_8x8_inference_flag= get_bits1(&s->gb);
#ifndef ALLOW_INTERLACE
if(sps->mb_aff)
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n");
#endif
if(!sps->direct_8x8_inference_flag && sps->mb_aff)
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "MBAFF + !direct_8x8_inference is not implemented\n");
sps->crop= get_bits1(&s->gb);
if(sps->crop){
sps->crop_left = get_ue_golomb(&s->gb);
sps->crop_right = get_ue_golomb(&s->gb);
sps->crop_top = get_ue_golomb(&s->gb);
sps->crop_bottom= get_ue_golomb(&s->gb);
if(sps->crop_left || sps->crop_top){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
}
}else{
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom= 0;
}
sps->vui_parameters_present_flag= get_bits1(&s->gb);
if( sps->vui_parameters_present_flag )
decode_vui_parameters(VAR_0, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
VAR_3, sps->VAR_1, sps->VAR_2,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : ""
);
}
return 0;
}
| [
"static inline int FUNC_0(H264Context *VAR_0){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_1, VAR_2;",
"int VAR_3, VAR_4;",
"SPS *sps;",
"VAR_1= get_bits(&s->gb, 8);",
"get_bits1(&s->gb);",
"get_bits1(&s->gb);",
"get_bits1(&s->gb);",
"get_bits1(&s->gb);",
"get_bits(&s->gb, 4);",
"VAR_2= get_bits(&s->gb, 8);",
"VAR_3= get_ue_golomb(&s->gb);",
"sps= &VAR_0->sps_buffer[ VAR_3 ];",
"sps->VAR_1= VAR_1;",
"sps->VAR_2= VAR_2;",
"if(sps->VAR_1 >= 100){",
"if(get_ue_golomb(&s->gb) == 3)\nget_bits1(&s->gb);",
"get_ue_golomb(&s->gb);",
"get_ue_golomb(&s->gb);",
"sps->transform_bypass = get_bits1(&s->gb);",
"decode_scaling_matrices(VAR_0, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);",
"}else",
"sps->scaling_matrix_present = 0;",
"sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;",
"sps->poc_type= get_ue_golomb(&s->gb);",
"if(sps->poc_type == 0){",
"sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;",
"} else if(sps->poc_type == 1){",
"sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);",
"sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);",
"sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);",
"sps->poc_cycle_length= get_ue_golomb(&s->gb);",
"for(VAR_4=0; VAR_4<sps->poc_cycle_length; VAR_4++)",
"sps->offset_for_ref_frame[VAR_4]= get_se_golomb(&s->gb);",
"}",
"if(sps->poc_type > 2){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"illegal POC type %d\\n\", sps->poc_type);",
"return -1;",
"}",
"sps->ref_frame_count= get_ue_golomb(&s->gb);",
"if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"too many reference frames\\n\");",
"}",
"sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);",
"sps->mb_width= get_ue_golomb(&s->gb) + 1;",
"sps->mb_height= get_ue_golomb(&s->gb) + 1;",
"if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||\navcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))\nreturn -1;",
"sps->frame_mbs_only_flag= get_bits1(&s->gb);",
"if(!sps->frame_mbs_only_flag)\nsps->mb_aff= get_bits1(&s->gb);",
"else\nsps->mb_aff= 0;",
"sps->direct_8x8_inference_flag= get_bits1(&s->gb);",
"#ifndef ALLOW_INTERLACE\nif(sps->mb_aff)\nav_log(VAR_0->s.avctx, AV_LOG_ERROR, \"MBAFF support not included; enable it at compile-time.\\n\");",
"#endif\nif(!sps->direct_8x8_inference_flag && sps->mb_aff)\nav_log(VAR_0->s.avctx, AV_LOG_ERROR, \"MBAFF + !direct_8x8_inference is not implemented\\n\");",
"sps->crop= get_bits1(&s->gb);",
"if(sps->crop){",
"sps->crop_left = get_ue_golomb(&s->gb);",
"sps->crop_right = get_ue_golomb(&s->gb);",
"sps->crop_top = get_ue_golomb(&s->gb);",
"sps->crop_bottom= get_ue_golomb(&s->gb);",
"if(sps->crop_left || sps->crop_top){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"insane cropping not completely supported, this could look slightly wrong ...\\n\");",
"}",
"}else{",
"sps->crop_left =\nsps->crop_right =\nsps->crop_top =\nsps->crop_bottom= 0;",
"}",
"sps->vui_parameters_present_flag= get_bits1(&s->gb);",
"if( sps->vui_parameters_present_flag )\ndecode_vui_parameters(VAR_0, sps);",
"if(s->avctx->debug&FF_DEBUG_PICT_INFO){",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\\n\",\nVAR_3, sps->VAR_1, sps->VAR_2,\nsps->poc_type,\nsps->ref_frame_count,\nsps->mb_width, sps->mb_height,\nsps->frame_mbs_only_flag ? \"FRM\" : (sps->mb_aff ? \"MB-AFF\" : \"PIC-AFF\"),\nsps->direct_8x8_inference_flag ? \"8B8\" : \"\",\nsps->crop_left, sps->crop_right,\nsps->crop_top, sps->crop_bottom,\nsps->vui_parameters_present_flag ? \"VUI\" : \"\"\n);",
"}",
"return 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,
1,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113,
115
],
[
119
],
[
121,
123
],
[
125,
127
],
[
131
],
[
135,
137,
139
],
[
141,
143,
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171,
173,
175
],
[
177
],
[
181
],
[
183,
185
],
[
189
],
[
191,
193,
195,
197,
199,
201,
203,
205,
207,
209,
211
],
[
213
],
[
215
],
[
217
]
]
|
13,073 | static int usb_ehci_initfn(PCIDevice *dev)
{
EHCIState *s = DO_UPCAST(EHCIState, dev, dev);
uint8_t *pci_conf = s->dev.config;
int i;
pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);
/* capabilities pointer */
pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x00);
//pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x50);
pci_set_byte(&pci_conf[PCI_INTERRUPT_PIN], 4); /* interrupt pin D */
pci_set_byte(&pci_conf[PCI_MIN_GNT], 0);
pci_set_byte(&pci_conf[PCI_MAX_LAT], 0);
// pci_conf[0x50] = 0x01; // power management caps
pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2); // release number (2.1.4)
pci_set_byte(&pci_conf[0x61], 0x20); // frame length adjustment (2.1.5)
pci_set_word(&pci_conf[0x62], 0x00); // port wake up capability (2.1.6)
pci_conf[0x64] = 0x00;
pci_conf[0x65] = 0x00;
pci_conf[0x66] = 0x00;
pci_conf[0x67] = 0x00;
pci_conf[0x68] = 0x01;
pci_conf[0x69] = 0x00;
pci_conf[0x6a] = 0x00;
pci_conf[0x6b] = 0x00; // USBLEGSUP
pci_conf[0x6c] = 0x00;
pci_conf[0x6d] = 0x00;
pci_conf[0x6e] = 0x00;
pci_conf[0x6f] = 0xc0; // USBLEFCTLSTS
// 2.2 host controller interface version
s->mmio[0x00] = (uint8_t) OPREGBASE;
s->mmio[0x01] = 0x00;
s->mmio[0x02] = 0x00;
s->mmio[0x03] = 0x01; // HC version
s->mmio[0x04] = NB_PORTS; // Number of downstream ports
s->mmio[0x05] = 0x00; // No companion ports at present
s->mmio[0x06] = 0x00;
s->mmio[0x07] = 0x00;
s->mmio[0x08] = 0x80; // We can cache whole frame, not 64-bit capable
s->mmio[0x09] = 0x68; // EECP
s->mmio[0x0a] = 0x00;
s->mmio[0x0b] = 0x00;
s->irq = s->dev.irq[3];
usb_bus_new(&s->bus, &ehci_bus_ops, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
s->ports[i].dev = 0;
}
s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
s->async_bh = qemu_bh_new(ehci_async_bh, s);
QTAILQ_INIT(&s->aqueues);
QTAILQ_INIT(&s->pqueues);
usb_packet_init(&s->ipacket);
qemu_register_reset(ehci_reset, s);
memory_region_init_io(&s->mem, &ehci_mem_ops, s, "ehci", MMIO_SIZE);
pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem);
return 0;
}
| true | qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | static int usb_ehci_initfn(PCIDevice *dev)
{
EHCIState *s = DO_UPCAST(EHCIState, dev, dev);
uint8_t *pci_conf = s->dev.config;
int i;
pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);
pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x00);
pci_set_byte(&pci_conf[PCI_INTERRUPT_PIN], 4);
pci_set_byte(&pci_conf[PCI_MIN_GNT], 0);
pci_set_byte(&pci_conf[PCI_MAX_LAT], 0);
pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2);
pci_set_byte(&pci_conf[0x61], 0x20);
pci_set_word(&pci_conf[0x62], 0x00);
pci_conf[0x64] = 0x00;
pci_conf[0x65] = 0x00;
pci_conf[0x66] = 0x00;
pci_conf[0x67] = 0x00;
pci_conf[0x68] = 0x01;
pci_conf[0x69] = 0x00;
pci_conf[0x6a] = 0x00;
pci_conf[0x6b] = 0x00;
pci_conf[0x6c] = 0x00;
pci_conf[0x6d] = 0x00;
pci_conf[0x6e] = 0x00;
pci_conf[0x6f] = 0xc0;
s->mmio[0x00] = (uint8_t) OPREGBASE;
s->mmio[0x01] = 0x00;
s->mmio[0x02] = 0x00;
s->mmio[0x03] = 0x01;
s->mmio[0x04] = NB_PORTS;
s->mmio[0x05] = 0x00;
s->mmio[0x06] = 0x00;
s->mmio[0x07] = 0x00;
s->mmio[0x08] = 0x80;
s->mmio[0x09] = 0x68;
s->mmio[0x0a] = 0x00;
s->mmio[0x0b] = 0x00;
s->irq = s->dev.irq[3];
usb_bus_new(&s->bus, &ehci_bus_ops, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
s->ports[i].dev = 0;
}
s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
s->async_bh = qemu_bh_new(ehci_async_bh, s);
QTAILQ_INIT(&s->aqueues);
QTAILQ_INIT(&s->pqueues);
usb_packet_init(&s->ipacket);
qemu_register_reset(ehci_reset, s);
memory_region_init_io(&s->mem, &ehci_mem_ops, s, "ehci", MMIO_SIZE);
pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem);
return 0;
}
| {
"code": [
" s->mmio[0x00] = (uint8_t) OPREGBASE;",
" s->mmio[0x01] = 0x00;",
" s->mmio[0x02] = 0x00;",
" s->mmio[0x06] = 0x00;",
" s->mmio[0x07] = 0x00;",
" s->mmio[0x0a] = 0x00;",
" s->mmio[0x0b] = 0x00;",
" memory_region_init_io(&s->mem, &ehci_mem_ops, s, \"ehci\", MMIO_SIZE);"
],
"line_no": [
73,
75,
77,
85,
87,
93,
95,
133
]
} | static int FUNC_0(PCIDevice *VAR_0)
{
EHCIState *s = DO_UPCAST(EHCIState, VAR_0, VAR_0);
uint8_t *pci_conf = s->VAR_0.config;
int VAR_1;
pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);
pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x00);
pci_set_byte(&pci_conf[PCI_INTERRUPT_PIN], 4);
pci_set_byte(&pci_conf[PCI_MIN_GNT], 0);
pci_set_byte(&pci_conf[PCI_MAX_LAT], 0);
pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2);
pci_set_byte(&pci_conf[0x61], 0x20);
pci_set_word(&pci_conf[0x62], 0x00);
pci_conf[0x64] = 0x00;
pci_conf[0x65] = 0x00;
pci_conf[0x66] = 0x00;
pci_conf[0x67] = 0x00;
pci_conf[0x68] = 0x01;
pci_conf[0x69] = 0x00;
pci_conf[0x6a] = 0x00;
pci_conf[0x6b] = 0x00;
pci_conf[0x6c] = 0x00;
pci_conf[0x6d] = 0x00;
pci_conf[0x6e] = 0x00;
pci_conf[0x6f] = 0xc0;
s->mmio[0x00] = (uint8_t) OPREGBASE;
s->mmio[0x01] = 0x00;
s->mmio[0x02] = 0x00;
s->mmio[0x03] = 0x01;
s->mmio[0x04] = NB_PORTS;
s->mmio[0x05] = 0x00;
s->mmio[0x06] = 0x00;
s->mmio[0x07] = 0x00;
s->mmio[0x08] = 0x80;
s->mmio[0x09] = 0x68;
s->mmio[0x0a] = 0x00;
s->mmio[0x0b] = 0x00;
s->irq = s->VAR_0.irq[3];
usb_bus_new(&s->bus, &ehci_bus_ops, &s->VAR_0.qdev);
for(VAR_1 = 0; VAR_1 < NB_PORTS; VAR_1++) {
usb_register_port(&s->bus, &s->ports[VAR_1], s, VAR_1, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
s->ports[VAR_1].VAR_0 = 0;
}
s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
s->async_bh = qemu_bh_new(ehci_async_bh, s);
QTAILQ_INIT(&s->aqueues);
QTAILQ_INIT(&s->pqueues);
usb_packet_init(&s->ipacket);
qemu_register_reset(ehci_reset, s);
memory_region_init_io(&s->mem, &ehci_mem_ops, s, "ehci", MMIO_SIZE);
pci_register_bar(&s->VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"EHCIState *s = DO_UPCAST(EHCIState, VAR_0, VAR_0);",
"uint8_t *pci_conf = s->VAR_0.config;",
"int VAR_1;",
"pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);",
"pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x00);",
"pci_set_byte(&pci_conf[PCI_INTERRUPT_PIN], 4);",
"pci_set_byte(&pci_conf[PCI_MIN_GNT], 0);",
"pci_set_byte(&pci_conf[PCI_MAX_LAT], 0);",
"pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2);",
"pci_set_byte(&pci_conf[0x61], 0x20);",
"pci_set_word(&pci_conf[0x62], 0x00);",
"pci_conf[0x64] = 0x00;",
"pci_conf[0x65] = 0x00;",
"pci_conf[0x66] = 0x00;",
"pci_conf[0x67] = 0x00;",
"pci_conf[0x68] = 0x01;",
"pci_conf[0x69] = 0x00;",
"pci_conf[0x6a] = 0x00;",
"pci_conf[0x6b] = 0x00;",
"pci_conf[0x6c] = 0x00;",
"pci_conf[0x6d] = 0x00;",
"pci_conf[0x6e] = 0x00;",
"pci_conf[0x6f] = 0xc0;",
"s->mmio[0x00] = (uint8_t) OPREGBASE;",
"s->mmio[0x01] = 0x00;",
"s->mmio[0x02] = 0x00;",
"s->mmio[0x03] = 0x01;",
"s->mmio[0x04] = NB_PORTS;",
"s->mmio[0x05] = 0x00;",
"s->mmio[0x06] = 0x00;",
"s->mmio[0x07] = 0x00;",
"s->mmio[0x08] = 0x80;",
"s->mmio[0x09] = 0x68;",
"s->mmio[0x0a] = 0x00;",
"s->mmio[0x0b] = 0x00;",
"s->irq = s->VAR_0.irq[3];",
"usb_bus_new(&s->bus, &ehci_bus_ops, &s->VAR_0.qdev);",
"for(VAR_1 = 0; VAR_1 < NB_PORTS; VAR_1++) {",
"usb_register_port(&s->bus, &s->ports[VAR_1], s, VAR_1, &ehci_port_ops,\nUSB_SPEED_MASK_HIGH);",
"s->ports[VAR_1].VAR_0 = 0;",
"}",
"s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);",
"s->async_bh = qemu_bh_new(ehci_async_bh, s);",
"QTAILQ_INIT(&s->aqueues);",
"QTAILQ_INIT(&s->pqueues);",
"usb_packet_init(&s->ipacket);",
"qemu_register_reset(ehci_reset, s);",
"memory_region_init_io(&s->mem, &ehci_mem_ops, s, \"ehci\", MMIO_SIZE);",
"pci_register_bar(&s->VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem);",
"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,
1,
1,
0,
0,
0,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19
],
[
25
],
[
27
],
[
29
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
133
],
[
135
],
[
139
],
[
141
]
]
|
13,074 | static int vnc_refresh_server_surface(VncDisplay *vd)
{
int width = MIN(pixman_image_get_width(vd->guest.fb),
pixman_image_get_width(vd->server));
int height = MIN(pixman_image_get_height(vd->guest.fb),
pixman_image_get_height(vd->server));
int cmp_bytes, server_stride, min_stride, guest_stride, y = 0;
uint8_t *guest_row0 = NULL, *server_row0;
VncState *vs;
int has_dirty = 0;
pixman_image_t *tmpbuf = NULL;
struct timeval tv = { 0, 0 };
if (!vd->non_adaptive) {
gettimeofday(&tv, NULL);
has_dirty = vnc_update_stats(vd, &tv);
}
/*
* Walk through the guest dirty map.
* Check and copy modified bits from guest to server surface.
* Update server dirty map.
*/
server_row0 = (uint8_t *)pixman_image_get_data(vd->server);
server_stride = guest_stride = pixman_image_get_stride(vd->server);
cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
server_stride);
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
int width = pixman_image_get_width(vd->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);
} else {
guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);
guest_stride = pixman_image_get_stride(vd->guest.fb);
}
min_stride = MIN(server_stride, guest_stride);
for (;;) {
int x;
uint8_t *guest_ptr, *server_ptr;
unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest),
y * VNC_DIRTY_BPL(&vd->guest));
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
/* no more dirty bits */
break;
}
y = offset / VNC_DIRTY_BPL(&vd->guest);
x = offset % VNC_DIRTY_BPL(&vd->guest);
server_ptr = server_row0 + y * server_stride + x * cmp_bytes;
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y);
guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);
} else {
guest_ptr = guest_row0 + y * guest_stride;
}
guest_ptr += x * cmp_bytes;
for (; x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT);
x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
int _cmp_bytes = cmp_bytes;
if (!test_and_clear_bit(x, vd->guest.dirty[y])) {
continue;
}
if ((x + 1) * cmp_bytes > min_stride) {
_cmp_bytes = min_stride - x * cmp_bytes;
}
if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {
continue;
}
memcpy(server_ptr, guest_ptr, _cmp_bytes);
if (!vd->non_adaptive) {
vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT,
y, &tv);
}
QTAILQ_FOREACH(vs, &vd->clients, next) {
set_bit(x, vs->dirty[y]);
}
has_dirty++;
}
y++;
}
qemu_pixman_image_unref(tmpbuf);
return has_dirty;
}
| true | qemu | eb8934b0418b3b1d125edddc4fc334a54334a49b | static int vnc_refresh_server_surface(VncDisplay *vd)
{
int width = MIN(pixman_image_get_width(vd->guest.fb),
pixman_image_get_width(vd->server));
int height = MIN(pixman_image_get_height(vd->guest.fb),
pixman_image_get_height(vd->server));
int cmp_bytes, server_stride, min_stride, guest_stride, y = 0;
uint8_t *guest_row0 = NULL, *server_row0;
VncState *vs;
int has_dirty = 0;
pixman_image_t *tmpbuf = NULL;
struct timeval tv = { 0, 0 };
if (!vd->non_adaptive) {
gettimeofday(&tv, NULL);
has_dirty = vnc_update_stats(vd, &tv);
}
server_row0 = (uint8_t *)pixman_image_get_data(vd->server);
server_stride = guest_stride = pixman_image_get_stride(vd->server);
cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
server_stride);
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
int width = pixman_image_get_width(vd->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);
} else {
guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);
guest_stride = pixman_image_get_stride(vd->guest.fb);
}
min_stride = MIN(server_stride, guest_stride);
for (;;) {
int x;
uint8_t *guest_ptr, *server_ptr;
unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest),
y * VNC_DIRTY_BPL(&vd->guest));
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
break;
}
y = offset / VNC_DIRTY_BPL(&vd->guest);
x = offset % VNC_DIRTY_BPL(&vd->guest);
server_ptr = server_row0 + y * server_stride + x * cmp_bytes;
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y);
guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);
} else {
guest_ptr = guest_row0 + y * guest_stride;
}
guest_ptr += x * cmp_bytes;
for (; x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT);
x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
int _cmp_bytes = cmp_bytes;
if (!test_and_clear_bit(x, vd->guest.dirty[y])) {
continue;
}
if ((x + 1) * cmp_bytes > min_stride) {
_cmp_bytes = min_stride - x * cmp_bytes;
}
if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {
continue;
}
memcpy(server_ptr, guest_ptr, _cmp_bytes);
if (!vd->non_adaptive) {
vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT,
y, &tv);
}
QTAILQ_FOREACH(vs, &vd->clients, next) {
set_bit(x, vs->dirty[y]);
}
has_dirty++;
}
y++;
}
qemu_pixman_image_unref(tmpbuf);
return has_dirty;
}
| {
"code": [
" int cmp_bytes, server_stride, min_stride, guest_stride, y = 0;",
" server_stride = guest_stride = pixman_image_get_stride(vd->server);",
" min_stride = MIN(server_stride, guest_stride);",
" if ((x + 1) * cmp_bytes > min_stride) {",
" _cmp_bytes = min_stride - x * cmp_bytes;"
],
"line_no": [
13,
51,
71,
133,
135
]
} | static int FUNC_0(VncDisplay *VAR_0)
{
int VAR_10 = MIN(pixman_image_get_width(VAR_0->guest.fb),
pixman_image_get_width(VAR_0->server));
int VAR_2 = MIN(pixman_image_get_height(VAR_0->guest.fb),
pixman_image_get_height(VAR_0->server));
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0;
uint8_t *guest_row0 = NULL, *server_row0;
VncState *vs;
int VAR_8 = 0;
pixman_image_t *tmpbuf = NULL;
struct timeval VAR_9 = { 0, 0 };
if (!VAR_0->non_adaptive) {
gettimeofday(&VAR_9, NULL);
VAR_8 = vnc_update_stats(VAR_0, &VAR_9);
}
server_row0 = (uint8_t *)pixman_image_get_data(VAR_0->server);
VAR_4 = VAR_6 = pixman_image_get_stride(VAR_0->server);
VAR_3 = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
VAR_4);
if (VAR_0->guest.format != VNC_SERVER_FB_FORMAT) {
int VAR_10 = pixman_image_get_width(VAR_0->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, VAR_10);
} else {
guest_row0 = (uint8_t *)pixman_image_get_data(VAR_0->guest.fb);
VAR_6 = pixman_image_get_stride(VAR_0->guest.fb);
}
VAR_5 = MIN(VAR_4, VAR_6);
for (;;) {
int VAR_10;
uint8_t *guest_ptr, *server_ptr;
unsigned long VAR_11 = find_next_bit((unsigned long *) &VAR_0->guest.dirty,
VAR_2 * VNC_DIRTY_BPL(&VAR_0->guest),
VAR_7 * VNC_DIRTY_BPL(&VAR_0->guest));
if (VAR_11 == VAR_2 * VNC_DIRTY_BPL(&VAR_0->guest)) {
break;
}
VAR_7 = VAR_11 / VNC_DIRTY_BPL(&VAR_0->guest);
VAR_10 = VAR_11 % VNC_DIRTY_BPL(&VAR_0->guest);
server_ptr = server_row0 + VAR_7 * VAR_4 + VAR_10 * VAR_3;
if (VAR_0->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, VAR_0->guest.fb, VAR_10, 0, VAR_7);
guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);
} else {
guest_ptr = guest_row0 + VAR_7 * VAR_6;
}
guest_ptr += VAR_10 * VAR_3;
for (; VAR_10 < DIV_ROUND_UP(VAR_10, VNC_DIRTY_PIXELS_PER_BIT);
VAR_10++, guest_ptr += VAR_3, server_ptr += VAR_3) {
int _cmp_bytes = VAR_3;
if (!test_and_clear_bit(VAR_10, VAR_0->guest.dirty[VAR_7])) {
continue;
}
if ((VAR_10 + 1) * VAR_3 > VAR_5) {
_cmp_bytes = VAR_5 - VAR_10 * VAR_3;
}
if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {
continue;
}
memcpy(server_ptr, guest_ptr, _cmp_bytes);
if (!VAR_0->non_adaptive) {
vnc_rect_updated(VAR_0, VAR_10 * VNC_DIRTY_PIXELS_PER_BIT,
VAR_7, &VAR_9);
}
QTAILQ_FOREACH(vs, &VAR_0->clients, next) {
set_bit(VAR_10, vs->dirty[VAR_7]);
}
VAR_8++;
}
VAR_7++;
}
qemu_pixman_image_unref(tmpbuf);
return VAR_8;
}
| [
"static int FUNC_0(VncDisplay *VAR_0)\n{",
"int VAR_10 = MIN(pixman_image_get_width(VAR_0->guest.fb),\npixman_image_get_width(VAR_0->server));",
"int VAR_2 = MIN(pixman_image_get_height(VAR_0->guest.fb),\npixman_image_get_height(VAR_0->server));",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0;",
"uint8_t *guest_row0 = NULL, *server_row0;",
"VncState *vs;",
"int VAR_8 = 0;",
"pixman_image_t *tmpbuf = NULL;",
"struct timeval VAR_9 = { 0, 0 };",
"if (!VAR_0->non_adaptive) {",
"gettimeofday(&VAR_9, NULL);",
"VAR_8 = vnc_update_stats(VAR_0, &VAR_9);",
"}",
"server_row0 = (uint8_t *)pixman_image_get_data(VAR_0->server);",
"VAR_4 = VAR_6 = pixman_image_get_stride(VAR_0->server);",
"VAR_3 = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,\nVAR_4);",
"if (VAR_0->guest.format != VNC_SERVER_FB_FORMAT) {",
"int VAR_10 = pixman_image_get_width(VAR_0->server);",
"tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, VAR_10);",
"} else {",
"guest_row0 = (uint8_t *)pixman_image_get_data(VAR_0->guest.fb);",
"VAR_6 = pixman_image_get_stride(VAR_0->guest.fb);",
"}",
"VAR_5 = MIN(VAR_4, VAR_6);",
"for (;;) {",
"int VAR_10;",
"uint8_t *guest_ptr, *server_ptr;",
"unsigned long VAR_11 = find_next_bit((unsigned long *) &VAR_0->guest.dirty,\nVAR_2 * VNC_DIRTY_BPL(&VAR_0->guest),\nVAR_7 * VNC_DIRTY_BPL(&VAR_0->guest));",
"if (VAR_11 == VAR_2 * VNC_DIRTY_BPL(&VAR_0->guest)) {",
"break;",
"}",
"VAR_7 = VAR_11 / VNC_DIRTY_BPL(&VAR_0->guest);",
"VAR_10 = VAR_11 % VNC_DIRTY_BPL(&VAR_0->guest);",
"server_ptr = server_row0 + VAR_7 * VAR_4 + VAR_10 * VAR_3;",
"if (VAR_0->guest.format != VNC_SERVER_FB_FORMAT) {",
"qemu_pixman_linebuf_fill(tmpbuf, VAR_0->guest.fb, VAR_10, 0, VAR_7);",
"guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);",
"} else {",
"guest_ptr = guest_row0 + VAR_7 * VAR_6;",
"}",
"guest_ptr += VAR_10 * VAR_3;",
"for (; VAR_10 < DIV_ROUND_UP(VAR_10, VNC_DIRTY_PIXELS_PER_BIT);",
"VAR_10++, guest_ptr += VAR_3, server_ptr += VAR_3) {",
"int _cmp_bytes = VAR_3;",
"if (!test_and_clear_bit(VAR_10, VAR_0->guest.dirty[VAR_7])) {",
"continue;",
"}",
"if ((VAR_10 + 1) * VAR_3 > VAR_5) {",
"_cmp_bytes = VAR_5 - VAR_10 * VAR_3;",
"}",
"if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {",
"continue;",
"}",
"memcpy(server_ptr, guest_ptr, _cmp_bytes);",
"if (!VAR_0->non_adaptive) {",
"vnc_rect_updated(VAR_0, VAR_10 * VNC_DIRTY_PIXELS_PER_BIT,\nVAR_7, &VAR_9);",
"}",
"QTAILQ_FOREACH(vs, &VAR_0->clients, next) {",
"set_bit(VAR_10, vs->dirty[VAR_7]);",
"}",
"VAR_8++;",
"}",
"VAR_7++;",
"}",
"qemu_pixman_image_unref(tmpbuf);",
"return VAR_8;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
]
]
|
13,075 | static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
/* Are we at the start of a block? */
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
av_assert0(desc);
if (mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
/*use the last lot... */
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
/* We shouldn't get here if frames_per_jpeg <= 0 because this was rejected
in init */
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
/* ff_init_buffer_info(avctx, &s->picture[1]); */
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
} | true | FFmpeg | 360bc0d90aa66cf21e9f488e77d21db18e01ec9c | static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
av_assert0(desc);
if (mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const AVPixFmtDescriptor *VAR_4;
SMVJpegDecodeContext *s = VAR_0->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int VAR_5, VAR_6 = 0, VAR_7 = 0;
VAR_6 = VAR_3->pts % s->frames_per_jpeg;
if (!VAR_6) {
av_frame_unref(mjpeg_data);
VAR_7 = avcodec_decode_video2(s->VAR_0, mjpeg_data, &s->mjpeg_data_size, VAR_3);
if (VAR_7 < 0) {
s->mjpeg_data_size = 0;
return VAR_7;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
VAR_4 = av_pix_fmt_desc_get(s->VAR_0->pix_fmt);
av_assert0(VAR_4);
if (mjpeg_data->height % (s->frames_per_jpeg << VAR_4->log2_chroma_h)) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
*VAR_2 = s->mjpeg_data_size;
VAR_0->pix_fmt = s->VAR_0->pix_fmt;
VAR_7 = ff_set_dimensions(VAR_0, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (VAR_7 < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return VAR_7;
}
if (*VAR_2) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = VAR_0->width;
s->picture[1]->height = VAR_0->height;
s->picture[1]->format = VAR_0->pix_fmt;
smv_img_pnt(s->picture[1]->VAR_1, mjpeg_data->VAR_1, mjpeg_data->linesize,
VAR_0->pix_fmt, VAR_0->width, VAR_0->height, VAR_6);
for (VAR_5 = 0; VAR_5 < AV_NUM_DATA_POINTERS; VAR_5++)
s->picture[1]->linesize[VAR_5] = mjpeg_data->linesize[VAR_5];
VAR_7 = av_frame_ref(VAR_1, s->picture[1]);
}
return VAR_7;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const AVPixFmtDescriptor *VAR_4;",
"SMVJpegDecodeContext *s = VAR_0->priv_data;",
"AVFrame* mjpeg_data = s->picture[0];",
"int VAR_5, VAR_6 = 0, VAR_7 = 0;",
"VAR_6 = VAR_3->pts % s->frames_per_jpeg;",
"if (!VAR_6) {",
"av_frame_unref(mjpeg_data);",
"VAR_7 = avcodec_decode_video2(s->VAR_0, mjpeg_data, &s->mjpeg_data_size, VAR_3);",
"if (VAR_7 < 0) {",
"s->mjpeg_data_size = 0;",
"return VAR_7;",
"}",
"} else if (!s->mjpeg_data_size)",
"return AVERROR(EINVAL);",
"VAR_4 = av_pix_fmt_desc_get(s->VAR_0->pix_fmt);",
"av_assert0(VAR_4);",
"if (mjpeg_data->height % (s->frames_per_jpeg << VAR_4->log2_chroma_h)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid height\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"*VAR_2 = s->mjpeg_data_size;",
"VAR_0->pix_fmt = s->VAR_0->pix_fmt;",
"VAR_7 = ff_set_dimensions(VAR_0, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);",
"if (VAR_7 < 0) {",
"av_log(s, AV_LOG_ERROR, \"Failed to set dimensions\\n\");",
"return VAR_7;",
"}",
"if (*VAR_2) {",
"s->picture[1]->extended_data = NULL;",
"s->picture[1]->width = VAR_0->width;",
"s->picture[1]->height = VAR_0->height;",
"s->picture[1]->format = VAR_0->pix_fmt;",
"smv_img_pnt(s->picture[1]->VAR_1, mjpeg_data->VAR_1, mjpeg_data->linesize,\nVAR_0->pix_fmt, VAR_0->width, VAR_0->height, VAR_6);",
"for (VAR_5 = 0; VAR_5 < AV_NUM_DATA_POINTERS; VAR_5++)",
"s->picture[1]->linesize[VAR_5] = mjpeg_data->linesize[VAR_5];",
"VAR_7 = av_frame_ref(VAR_1, s->picture[1]);",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
26
],
[
27
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
41,
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
]
]
|
13,076 | static inline uint16_t vring_avail_ring(VirtQueue *vq, int i)
{
VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
hwaddr pa = offsetof(VRingAvail, ring[i]);
return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);
}
| true | qemu | e0e2d644096c79a71099b176d08f465f6803a8b1 | static inline uint16_t vring_avail_ring(VirtQueue *vq, int i)
{
VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
hwaddr pa = offsetof(VRingAvail, ring[i]);
return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);
}
| {
"code": [
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
" VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5
]
} | static inline uint16_t FUNC_0(VirtQueue *vq, int i)
{
VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
hwaddr pa = offsetof(VRingAvail, ring[i]);
return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);
}
| [
"static inline uint16_t FUNC_0(VirtQueue *vq, int i)\n{",
"VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);",
"hwaddr pa = offsetof(VRingAvail, ring[i]);",
"return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);",
"}"
]
| [
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
13,078 | static int open_f(BlockDriverState *bs, int argc, char **argv)
{
int flags = 0;
int readonly = 0;
int growable = 0;
int c;
QemuOpts *qopts;
QDict *opts;
while ((c = getopt(argc, argv, "snrgo:")) != EOF) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
break;
case 'n':
flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
break;
case 'r':
readonly = 1;
break;
case 'g':
growable = 1;
break;
case 'o':
if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
printf("could not parse option list -- %s\n", optarg);
qemu_opts_reset(&empty_opts);
return 0;
}
break;
default:
qemu_opts_reset(&empty_opts);
return qemuio_command_usage(&open_cmd);
}
}
if (!readonly) {
flags |= BDRV_O_RDWR;
}
qopts = qemu_opts_find(&empty_opts, NULL);
opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL;
qemu_opts_reset(&empty_opts);
if (optind == argc - 1) {
return openfile(argv[optind], flags, growable, opts);
} else if (optind == argc) {
return openfile(NULL, flags, growable, opts);
} else {
return qemuio_command_usage(&open_cmd);
}
} | true | qemu | 29f2601aa605f0af0cba8eedcff7812c6c8532e9 | static int open_f(BlockDriverState *bs, int argc, char **argv)
{
int flags = 0;
int readonly = 0;
int growable = 0;
int c;
QemuOpts *qopts;
QDict *opts;
while ((c = getopt(argc, argv, "snrgo:")) != EOF) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
break;
case 'n':
flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
break;
case 'r':
readonly = 1;
break;
case 'g':
growable = 1;
break;
case 'o':
if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
printf("could not parse option list -- %s\n", optarg);
qemu_opts_reset(&empty_opts);
return 0;
}
break;
default:
qemu_opts_reset(&empty_opts);
return qemuio_command_usage(&open_cmd);
}
}
if (!readonly) {
flags |= BDRV_O_RDWR;
}
qopts = qemu_opts_find(&empty_opts, NULL);
opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL;
qemu_opts_reset(&empty_opts);
if (optind == argc - 1) {
return openfile(argv[optind], flags, growable, opts);
} else if (optind == argc) {
return openfile(NULL, flags, growable, opts);
} else {
return qemuio_command_usage(&open_cmd);
}
} | {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, char **VAR_2)
{
int VAR_3 = 0;
int VAR_4 = 0;
int VAR_5 = 0;
int VAR_6;
QemuOpts *qopts;
QDict *opts;
while ((VAR_6 = getopt(VAR_1, VAR_2, "snrgo:")) != EOF) {
switch (VAR_6) {
case 's':
VAR_3 |= BDRV_O_SNAPSHOT;
break;
case 'n':
VAR_3 |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
break;
case 'r':
VAR_4 = 1;
break;
case 'g':
VAR_5 = 1;
break;
case 'o':
if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
printf("could not parse option list -- %s\n", optarg);
qemu_opts_reset(&empty_opts);
return 0;
}
break;
default:
qemu_opts_reset(&empty_opts);
return qemuio_command_usage(&open_cmd);
}
}
if (!VAR_4) {
VAR_3 |= BDRV_O_RDWR;
}
qopts = qemu_opts_find(&empty_opts, NULL);
opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL;
qemu_opts_reset(&empty_opts);
if (optind == VAR_1 - 1) {
return openfile(VAR_2[optind], VAR_3, VAR_5, opts);
} else if (optind == VAR_1) {
return openfile(NULL, VAR_3, VAR_5, opts);
} else {
return qemuio_command_usage(&open_cmd);
}
} | [
"static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, char **VAR_2)\n{",
"int VAR_3 = 0;",
"int VAR_4 = 0;",
"int VAR_5 = 0;",
"int VAR_6;",
"QemuOpts *qopts;",
"QDict *opts;",
"while ((VAR_6 = getopt(VAR_1, VAR_2, \"snrgo:\")) != EOF) {",
"switch (VAR_6) {",
"case 's':\nVAR_3 |= BDRV_O_SNAPSHOT;",
"break;",
"case 'n':\nVAR_3 |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;",
"break;",
"case 'r':\nVAR_4 = 1;",
"break;",
"case 'g':\nVAR_5 = 1;",
"break;",
"case 'o':\nif (!qemu_opts_parse(&empty_opts, optarg, 0)) {",
"printf(\"could not parse option list -- %s\\n\", optarg);",
"qemu_opts_reset(&empty_opts);",
"return 0;",
"}",
"break;",
"default:\nqemu_opts_reset(&empty_opts);",
"return qemuio_command_usage(&open_cmd);",
"}",
"}",
"if (!VAR_4) {",
"VAR_3 |= BDRV_O_RDWR;",
"}",
"qopts = qemu_opts_find(&empty_opts, NULL);",
"opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL;",
"qemu_opts_reset(&empty_opts);",
"if (optind == VAR_1 - 1) {",
"return openfile(VAR_2[optind], VAR_3, VAR_5, opts);",
"} else if (optind == VAR_1) {",
"return openfile(NULL, VAR_3, VAR_5, opts);",
"} else {",
"return qemuio_command_usage(&open_cmd);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
100
],
[
102
],
[
104
]
]
|
13,079 | av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
{
int n, n4, i;
double alpha, theta;
int tstep;
memset(s, 0, sizeof(*s));
n = 1 << nbits;
s->mdct_bits = nbits;
s->mdct_size = n;
n4 = n >> 2;
s->permutation = FF_MDCT_PERM_NONE;
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
goto fail;
s->tcos = av_malloc(n/2 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
switch (s->permutation) {
case FF_MDCT_PERM_NONE:
s->tsin = s->tcos + n4;
tstep = 1;
break;
case FF_MDCT_PERM_INTERLEAVE:
s->tsin = s->tcos + 1;
tstep = 2;
break;
default:
goto fail;
}
theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
scale = sqrt(fabs(scale));
for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + theta) / n;
s->tcos[i*tstep] = -cos(alpha) * scale;
s->tsin[i*tstep] = -sin(alpha) * scale;
}
return 0;
fail:
ff_mdct_end(s);
return -1;
}
| false | FFmpeg | e6b1ed693ae4098e6b9eabf938fc31ec0b09b120 | av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
{
int n, n4, i;
double alpha, theta;
int tstep;
memset(s, 0, sizeof(*s));
n = 1 << nbits;
s->mdct_bits = nbits;
s->mdct_size = n;
n4 = n >> 2;
s->permutation = FF_MDCT_PERM_NONE;
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
goto fail;
s->tcos = av_malloc(n/2 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
switch (s->permutation) {
case FF_MDCT_PERM_NONE:
s->tsin = s->tcos + n4;
tstep = 1;
break;
case FF_MDCT_PERM_INTERLEAVE:
s->tsin = s->tcos + 1;
tstep = 2;
break;
default:
goto fail;
}
theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
scale = sqrt(fabs(scale));
for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + theta) / n;
s->tcos[i*tstep] = -cos(alpha) * scale;
s->tsin[i*tstep] = -sin(alpha) * scale;
}
return 0;
fail:
ff_mdct_end(s);
return -1;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(FFTContext *s, int nbits, int inverse, double scale)
{
int VAR_0, VAR_1, VAR_2;
double VAR_3, VAR_4;
int VAR_5;
memset(s, 0, sizeof(*s));
VAR_0 = 1 << nbits;
s->mdct_bits = nbits;
s->mdct_size = VAR_0;
VAR_1 = VAR_0 >> 2;
s->permutation = FF_MDCT_PERM_NONE;
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
goto fail;
s->tcos = av_malloc(VAR_0/2 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
switch (s->permutation) {
case FF_MDCT_PERM_NONE:
s->tsin = s->tcos + VAR_1;
VAR_5 = 1;
break;
case FF_MDCT_PERM_INTERLEAVE:
s->tsin = s->tcos + 1;
VAR_5 = 2;
break;
default:
goto fail;
}
VAR_4 = 1.0 / 8.0 + (scale < 0 ? VAR_1 : 0);
scale = sqrt(fabs(scale));
for(VAR_2=0;VAR_2<VAR_1;VAR_2++) {
VAR_3 = 2 * M_PI * (VAR_2 + VAR_4) / VAR_0;
s->tcos[VAR_2*VAR_5] = -cos(VAR_3) * scale;
s->tsin[VAR_2*VAR_5] = -sin(VAR_3) * scale;
}
return 0;
fail:
ff_mdct_end(s);
return -1;
}
| [
"av_cold int FUNC_0(FFTContext *s, int nbits, int inverse, double scale)\n{",
"int VAR_0, VAR_1, VAR_2;",
"double VAR_3, VAR_4;",
"int VAR_5;",
"memset(s, 0, sizeof(*s));",
"VAR_0 = 1 << nbits;",
"s->mdct_bits = nbits;",
"s->mdct_size = VAR_0;",
"VAR_1 = VAR_0 >> 2;",
"s->permutation = FF_MDCT_PERM_NONE;",
"if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)\ngoto fail;",
"s->tcos = av_malloc(VAR_0/2 * sizeof(FFTSample));",
"if (!s->tcos)\ngoto fail;",
"switch (s->permutation) {",
"case FF_MDCT_PERM_NONE:\ns->tsin = s->tcos + VAR_1;",
"VAR_5 = 1;",
"break;",
"case FF_MDCT_PERM_INTERLEAVE:\ns->tsin = s->tcos + 1;",
"VAR_5 = 2;",
"break;",
"default:\ngoto fail;",
"}",
"VAR_4 = 1.0 / 8.0 + (scale < 0 ? VAR_1 : 0);",
"scale = sqrt(fabs(scale));",
"for(VAR_2=0;VAR_2<VAR_1;VAR_2++) {",
"VAR_3 = 2 * M_PI * (VAR_2 + VAR_4) / VAR_0;",
"s->tcos[VAR_2*VAR_5] = -cos(VAR_3) * scale;",
"s->tsin[VAR_2*VAR_5] = -sin(VAR_3) * scale;",
"}",
"return 0;",
"fail:\nff_mdct_end(s);",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33
],
[
35,
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
]
]
|
13,080 | int ff_slice_thread_init(AVCodecContext *avctx)
{
int i;
ThreadContext *c;
int thread_count = avctx->thread_count;
#if HAVE_W32THREADS
w32thread_init();
#endif
if (!thread_count) {
int nb_cpus = av_cpu_count();
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
// use number of cores + 1 as thread count if there is more than one
if (nb_cpus > 1)
thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
else
thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(ThreadContext));
if (!c)
return -1;
c->workers = av_mallocz(sizeof(pthread_t)*thread_count);
if (!c->workers) {
av_free(c);
return -1;
}
avctx->thread_opaque = c;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
c->done = 0;
pthread_cond_init(&c->current_job_cond, NULL);
pthread_cond_init(&c->last_job_cond, NULL);
pthread_mutex_init(&c->current_job_lock, NULL);
pthread_mutex_lock(&c->current_job_lock);
for (i=0; i<thread_count; i++) {
if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
avctx->thread_count = i;
pthread_mutex_unlock(&c->current_job_lock);
ff_thread_free(avctx);
return -1;
}
}
thread_park_workers(c, thread_count);
avctx->execute = thread_execute;
avctx->execute2 = thread_execute2;
return 0;
}
| false | FFmpeg | daa7a1d4431b6acf1f93c4a98b3de123abf4ca18 | int ff_slice_thread_init(AVCodecContext *avctx)
{
int i;
ThreadContext *c;
int thread_count = avctx->thread_count;
#if HAVE_W32THREADS
w32thread_init();
#endif
if (!thread_count) {
int nb_cpus = av_cpu_count();
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
if (nb_cpus > 1)
thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
else
thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(ThreadContext));
if (!c)
return -1;
c->workers = av_mallocz(sizeof(pthread_t)*thread_count);
if (!c->workers) {
av_free(c);
return -1;
}
avctx->thread_opaque = c;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
c->done = 0;
pthread_cond_init(&c->current_job_cond, NULL);
pthread_cond_init(&c->last_job_cond, NULL);
pthread_mutex_init(&c->current_job_lock, NULL);
pthread_mutex_lock(&c->current_job_lock);
for (i=0; i<thread_count; i++) {
if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
avctx->thread_count = i;
pthread_mutex_unlock(&c->current_job_lock);
ff_thread_free(avctx);
return -1;
}
}
thread_park_workers(c, thread_count);
avctx->execute = thread_execute;
avctx->execute2 = thread_execute2;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0)
{
int VAR_1;
ThreadContext *c;
int VAR_2 = VAR_0->VAR_2;
#if HAVE_W32THREADS
w32thread_init();
#endif
if (!VAR_2) {
int VAR_3 = av_cpu_count();
av_log(VAR_0, AV_LOG_DEBUG, "detected %d logical cores\n", VAR_3);
if (VAR_3 > 1)
VAR_2 = VAR_0->VAR_2 = FFMIN(VAR_3 + 1, MAX_AUTO_THREADS);
else
VAR_2 = VAR_0->VAR_2 = 1;
}
if (VAR_2 <= 1) {
VAR_0->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(ThreadContext));
if (!c)
return -1;
c->workers = av_mallocz(sizeof(pthread_t)*VAR_2);
if (!c->workers) {
av_free(c);
return -1;
}
VAR_0->thread_opaque = c;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
c->done = 0;
pthread_cond_init(&c->current_job_cond, NULL);
pthread_cond_init(&c->last_job_cond, NULL);
pthread_mutex_init(&c->current_job_lock, NULL);
pthread_mutex_lock(&c->current_job_lock);
for (VAR_1=0; VAR_1<VAR_2; VAR_1++) {
if(pthread_create(&c->workers[VAR_1], NULL, worker, VAR_0)) {
VAR_0->VAR_2 = VAR_1;
pthread_mutex_unlock(&c->current_job_lock);
ff_thread_free(VAR_0);
return -1;
}
}
thread_park_workers(c, VAR_2);
VAR_0->execute = thread_execute;
VAR_0->execute2 = thread_execute2;
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0)\n{",
"int VAR_1;",
"ThreadContext *c;",
"int VAR_2 = VAR_0->VAR_2;",
"#if HAVE_W32THREADS\nw32thread_init();",
"#endif\nif (!VAR_2) {",
"int VAR_3 = av_cpu_count();",
"av_log(VAR_0, AV_LOG_DEBUG, \"detected %d logical cores\\n\", VAR_3);",
"if (VAR_3 > 1)\nVAR_2 = VAR_0->VAR_2 = FFMIN(VAR_3 + 1, MAX_AUTO_THREADS);",
"else\nVAR_2 = VAR_0->VAR_2 = 1;",
"}",
"if (VAR_2 <= 1) {",
"VAR_0->active_thread_type = 0;",
"return 0;",
"}",
"c = av_mallocz(sizeof(ThreadContext));",
"if (!c)\nreturn -1;",
"c->workers = av_mallocz(sizeof(pthread_t)*VAR_2);",
"if (!c->workers) {",
"av_free(c);",
"return -1;",
"}",
"VAR_0->thread_opaque = c;",
"c->current_job = 0;",
"c->job_count = 0;",
"c->job_size = 0;",
"c->done = 0;",
"pthread_cond_init(&c->current_job_cond, NULL);",
"pthread_cond_init(&c->last_job_cond, NULL);",
"pthread_mutex_init(&c->current_job_lock, NULL);",
"pthread_mutex_lock(&c->current_job_lock);",
"for (VAR_1=0; VAR_1<VAR_2; VAR_1++) {",
"if(pthread_create(&c->workers[VAR_1], NULL, worker, VAR_0)) {",
"VAR_0->VAR_2 = VAR_1;",
"pthread_mutex_unlock(&c->current_job_lock);",
"ff_thread_free(VAR_0);",
"return -1;",
"}",
"}",
"thread_park_workers(c, VAR_2);",
"VAR_0->execute = thread_execute;",
"VAR_0->execute2 = thread_execute2;",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
21
],
[
23
],
[
25
],
[
29,
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
]
]
|
13,082 | void ff_avg_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_and_aver_dst_4x4_msa(src - (2 * stride) - 2,
stride, dst, stride);
}
| false | FFmpeg | 1181d93231e9b807965724587d363c1cfd5a1d0d | void ff_avg_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_and_aver_dst_4x4_msa(src - (2 * stride) - 2,
stride, dst, stride);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_mid_and_aver_dst_4x4_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_mid_and_aver_dst_4x4_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
11
]
]
|
13,084 | int qsv_transcode_init(OutputStream *ost)
{
InputStream *ist;
const enum AVPixelFormat *pix_fmt;
AVDictionaryEntry *e;
const AVOption *opt;
int flags = 0;
int err, i;
QSVContext *qsv = NULL;
AVQSVContext *hwctx = NULL;
mfxIMPL impl;
mfxVersion ver = { { 3, 1 } };
/* check if the encoder supports QSV */
if (!ost->enc->pix_fmts)
return 0;
for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_QSV)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
return 0;
if (strcmp(ost->avfilter, "null") || ost->source_index < 0)
return 0;
/* check if the decoder supports QSV and the output only goes to this stream */
ist = input_streams[ost->source_index];
if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts)
return 0;
for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_QSV)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
return 0;
for (i = 0; i < nb_output_streams; i++)
if (output_streams[i] != ost &&
output_streams[i]->source_index == ost->source_index)
return 0;
av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n");
qsv = av_mallocz(sizeof(*qsv));
hwctx = av_qsv_alloc_context();
if (!qsv || !hwctx)
goto fail;
impl = choose_implementation(ist);
err = MFXInit(impl, &ver, &qsv->session);
if (err != MFX_ERR_NONE) {
av_log(NULL, AV_LOG_ERROR, "Error initializing an MFX session: %d\n", err);
goto fail;
}
e = av_dict_get(ost->encoder_opts, "flags", NULL, 0);
opt = av_opt_find(ost->enc_ctx, "flags", NULL, 0, 0);
if (e && opt)
av_opt_eval_flags(ost->enc_ctx, opt, e->value, &flags);
qsv->ost = ost;
hwctx->session = qsv->session;
hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
hwctx->opaque_alloc = 1;
hwctx->nb_opaque_surfaces = 16;
ost->hwaccel_ctx = qsv;
ost->enc_ctx->hwaccel_context = hwctx;
ost->enc_ctx->pix_fmt = AV_PIX_FMT_QSV;
ist->hwaccel_ctx = qsv;
ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV;
ist->resample_pix_fmt = AV_PIX_FMT_QSV;
return 0;
fail:
av_freep(&hwctx);
av_freep(&qsv);
return AVERROR_UNKNOWN;
}
| false | FFmpeg | 03cef34aa66662e2ab3681d290e7c5a6634f4058 | int qsv_transcode_init(OutputStream *ost)
{
InputStream *ist;
const enum AVPixelFormat *pix_fmt;
AVDictionaryEntry *e;
const AVOption *opt;
int flags = 0;
int err, i;
QSVContext *qsv = NULL;
AVQSVContext *hwctx = NULL;
mfxIMPL impl;
mfxVersion ver = { { 3, 1 } };
if (!ost->enc->pix_fmts)
return 0;
for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_QSV)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
return 0;
if (strcmp(ost->avfilter, "null") || ost->source_index < 0)
return 0;
ist = input_streams[ost->source_index];
if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts)
return 0;
for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_QSV)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
return 0;
for (i = 0; i < nb_output_streams; i++)
if (output_streams[i] != ost &&
output_streams[i]->source_index == ost->source_index)
return 0;
av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n");
qsv = av_mallocz(sizeof(*qsv));
hwctx = av_qsv_alloc_context();
if (!qsv || !hwctx)
goto fail;
impl = choose_implementation(ist);
err = MFXInit(impl, &ver, &qsv->session);
if (err != MFX_ERR_NONE) {
av_log(NULL, AV_LOG_ERROR, "Error initializing an MFX session: %d\n", err);
goto fail;
}
e = av_dict_get(ost->encoder_opts, "flags", NULL, 0);
opt = av_opt_find(ost->enc_ctx, "flags", NULL, 0, 0);
if (e && opt)
av_opt_eval_flags(ost->enc_ctx, opt, e->value, &flags);
qsv->ost = ost;
hwctx->session = qsv->session;
hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
hwctx->opaque_alloc = 1;
hwctx->nb_opaque_surfaces = 16;
ost->hwaccel_ctx = qsv;
ost->enc_ctx->hwaccel_context = hwctx;
ost->enc_ctx->pix_fmt = AV_PIX_FMT_QSV;
ist->hwaccel_ctx = qsv;
ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV;
ist->resample_pix_fmt = AV_PIX_FMT_QSV;
return 0;
fail:
av_freep(&hwctx);
av_freep(&qsv);
return AVERROR_UNKNOWN;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(OutputStream *VAR_0)
{
InputStream *ist;
const enum AVPixelFormat *VAR_1;
AVDictionaryEntry *e;
const AVOption *VAR_2;
int VAR_3 = 0;
int VAR_4, VAR_5;
QSVContext *qsv = NULL;
AVQSVContext *hwctx = NULL;
mfxIMPL impl;
mfxVersion ver = { { 3, 1 } };
if (!VAR_0->enc->pix_fmts)
return 0;
for (VAR_1 = VAR_0->enc->pix_fmts; *VAR_1 != AV_PIX_FMT_NONE; VAR_1++)
if (*VAR_1 == AV_PIX_FMT_QSV)
break;
if (*VAR_1 == AV_PIX_FMT_NONE)
return 0;
if (strcmp(VAR_0->avfilter, "null") || VAR_0->source_index < 0)
return 0;
ist = input_streams[VAR_0->source_index];
if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts)
return 0;
for (VAR_1 = ist->dec->pix_fmts; *VAR_1 != AV_PIX_FMT_NONE; VAR_1++)
if (*VAR_1 == AV_PIX_FMT_QSV)
break;
if (*VAR_1 == AV_PIX_FMT_NONE)
return 0;
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++)
if (output_streams[VAR_5] != VAR_0 &&
output_streams[VAR_5]->source_index == VAR_0->source_index)
return 0;
av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n");
qsv = av_mallocz(sizeof(*qsv));
hwctx = av_qsv_alloc_context();
if (!qsv || !hwctx)
goto fail;
impl = choose_implementation(ist);
VAR_4 = MFXInit(impl, &ver, &qsv->session);
if (VAR_4 != MFX_ERR_NONE) {
av_log(NULL, AV_LOG_ERROR, "Error initializing an MFX session: %d\n", VAR_4);
goto fail;
}
e = av_dict_get(VAR_0->encoder_opts, "VAR_3", NULL, 0);
VAR_2 = av_opt_find(VAR_0->enc_ctx, "VAR_3", NULL, 0, 0);
if (e && VAR_2)
av_opt_eval_flags(VAR_0->enc_ctx, VAR_2, e->value, &VAR_3);
qsv->VAR_0 = VAR_0;
hwctx->session = qsv->session;
hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
hwctx->opaque_alloc = 1;
hwctx->nb_opaque_surfaces = 16;
VAR_0->hwaccel_ctx = qsv;
VAR_0->enc_ctx->hwaccel_context = hwctx;
VAR_0->enc_ctx->VAR_1 = AV_PIX_FMT_QSV;
ist->hwaccel_ctx = qsv;
ist->dec_ctx->VAR_1 = AV_PIX_FMT_QSV;
ist->resample_pix_fmt = AV_PIX_FMT_QSV;
return 0;
fail:
av_freep(&hwctx);
av_freep(&qsv);
return AVERROR_UNKNOWN;
}
| [
"int FUNC_0(OutputStream *VAR_0)\n{",
"InputStream *ist;",
"const enum AVPixelFormat *VAR_1;",
"AVDictionaryEntry *e;",
"const AVOption *VAR_2;",
"int VAR_3 = 0;",
"int VAR_4, VAR_5;",
"QSVContext *qsv = NULL;",
"AVQSVContext *hwctx = NULL;",
"mfxIMPL impl;",
"mfxVersion ver = { { 3, 1 } };",
"if (!VAR_0->enc->pix_fmts)\nreturn 0;",
"for (VAR_1 = VAR_0->enc->pix_fmts; *VAR_1 != AV_PIX_FMT_NONE; VAR_1++)",
"if (*VAR_1 == AV_PIX_FMT_QSV)\nbreak;",
"if (*VAR_1 == AV_PIX_FMT_NONE)\nreturn 0;",
"if (strcmp(VAR_0->avfilter, \"null\") || VAR_0->source_index < 0)\nreturn 0;",
"ist = input_streams[VAR_0->source_index];",
"if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts)\nreturn 0;",
"for (VAR_1 = ist->dec->pix_fmts; *VAR_1 != AV_PIX_FMT_NONE; VAR_1++)",
"if (*VAR_1 == AV_PIX_FMT_QSV)\nbreak;",
"if (*VAR_1 == AV_PIX_FMT_NONE)\nreturn 0;",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++)",
"if (output_streams[VAR_5] != VAR_0 &&\noutput_streams[VAR_5]->source_index == VAR_0->source_index)\nreturn 0;",
"av_log(NULL, AV_LOG_VERBOSE, \"Setting up QSV transcoding\\n\");",
"qsv = av_mallocz(sizeof(*qsv));",
"hwctx = av_qsv_alloc_context();",
"if (!qsv || !hwctx)\ngoto fail;",
"impl = choose_implementation(ist);",
"VAR_4 = MFXInit(impl, &ver, &qsv->session);",
"if (VAR_4 != MFX_ERR_NONE) {",
"av_log(NULL, AV_LOG_ERROR, \"Error initializing an MFX session: %d\\n\", VAR_4);",
"goto fail;",
"}",
"e = av_dict_get(VAR_0->encoder_opts, \"VAR_3\", NULL, 0);",
"VAR_2 = av_opt_find(VAR_0->enc_ctx, \"VAR_3\", NULL, 0, 0);",
"if (e && VAR_2)\nav_opt_eval_flags(VAR_0->enc_ctx, VAR_2, e->value, &VAR_3);",
"qsv->VAR_0 = VAR_0;",
"hwctx->session = qsv->session;",
"hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;",
"hwctx->opaque_alloc = 1;",
"hwctx->nb_opaque_surfaces = 16;",
"VAR_0->hwaccel_ctx = qsv;",
"VAR_0->enc_ctx->hwaccel_context = hwctx;",
"VAR_0->enc_ctx->VAR_1 = AV_PIX_FMT_QSV;",
"ist->hwaccel_ctx = qsv;",
"ist->dec_ctx->VAR_1 = AV_PIX_FMT_QSV;",
"ist->resample_pix_fmt = AV_PIX_FMT_QSV;",
"return 0;",
"fail:\nav_freep(&hwctx);",
"av_freep(&qsv);",
"return AVERROR_UNKNOWN;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
51,
53
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71,
73
],
[
77
],
[
79,
81,
83
],
[
87
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121,
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
157
],
[
161,
163
],
[
165
],
[
167
],
[
169
]
]
|
13,085 | static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
int64_t pos = avio_tell(pb);
int has_h264 = 0, has_video = 0;
int minor = 0x200;
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
has_video = 1;
if (st->codec->codec_id == AV_CODEC_ID_H264)
has_h264 = 1;
}
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "ftyp");
if (mov->mode == MODE_3GP) {
ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
minor = has_h264 ? 0x100 : 0x200;
} else if (mov->mode & MODE_3G2) {
ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
minor = has_h264 ? 0x20000 : 0x10000;
} else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "isom");
else if (mov->mode == MODE_IPOD)
ffio_wfourcc(pb, has_video ? "M4V ":"M4A ");
else if (mov->mode == MODE_ISM)
ffio_wfourcc(pb, "isml");
else if (mov->mode == MODE_F4V)
ffio_wfourcc(pb, "f4v ");
else
ffio_wfourcc(pb, "qt ");
avio_wb32(pb, minor);
if (mov->mode == MODE_MOV)
ffio_wfourcc(pb, "qt ");
else if (mov->mode == MODE_ISM) {
ffio_wfourcc(pb, "piff");
ffio_wfourcc(pb, "iso2");
} else {
ffio_wfourcc(pb, "isom");
ffio_wfourcc(pb, "iso2");
if (has_h264)
ffio_wfourcc(pb, "avc1");
}
if (mov->mode == MODE_3GP)
ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
else if (mov->mode & MODE_3G2)
ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "mp41");
return update_size(pb, pos);
}
| false | FFmpeg | 1e9db41e2a2166be5671b088ef4ad06a40af459f | static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
int64_t pos = avio_tell(pb);
int has_h264 = 0, has_video = 0;
int minor = 0x200;
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
has_video = 1;
if (st->codec->codec_id == AV_CODEC_ID_H264)
has_h264 = 1;
}
avio_wb32(pb, 0);
ffio_wfourcc(pb, "ftyp");
if (mov->mode == MODE_3GP) {
ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
minor = has_h264 ? 0x100 : 0x200;
} else if (mov->mode & MODE_3G2) {
ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
minor = has_h264 ? 0x20000 : 0x10000;
} else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "isom");
else if (mov->mode == MODE_IPOD)
ffio_wfourcc(pb, has_video ? "M4V ":"M4A ");
else if (mov->mode == MODE_ISM)
ffio_wfourcc(pb, "isml");
else if (mov->mode == MODE_F4V)
ffio_wfourcc(pb, "f4v ");
else
ffio_wfourcc(pb, "qt ");
avio_wb32(pb, minor);
if (mov->mode == MODE_MOV)
ffio_wfourcc(pb, "qt ");
else if (mov->mode == MODE_ISM) {
ffio_wfourcc(pb, "piff");
ffio_wfourcc(pb, "iso2");
} else {
ffio_wfourcc(pb, "isom");
ffio_wfourcc(pb, "iso2");
if (has_h264)
ffio_wfourcc(pb, "avc1");
}
if (mov->mode == MODE_3GP)
ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
else if (mov->mode & MODE_3G2)
ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "mp41");
return update_size(pb, pos);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVIOContext *VAR_0, AVFormatContext *VAR_1)
{
MOVMuxContext *mov = VAR_1->priv_data;
int64_t pos = avio_tell(VAR_0);
int VAR_2 = 0, VAR_3 = 0;
int VAR_4 = 0x200;
int VAR_5;
for (VAR_5 = 0; VAR_5 < VAR_1->nb_streams; VAR_5++) {
AVStream *st = VAR_1->streams[VAR_5];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
VAR_3 = 1;
if (st->codec->codec_id == AV_CODEC_ID_H264)
VAR_2 = 1;
}
avio_wb32(VAR_0, 0);
ffio_wfourcc(VAR_0, "ftyp");
if (mov->mode == MODE_3GP) {
ffio_wfourcc(VAR_0, VAR_2 ? "3gp6" : "3gp4");
VAR_4 = VAR_2 ? 0x100 : 0x200;
} else if (mov->mode & MODE_3G2) {
ffio_wfourcc(VAR_0, VAR_2 ? "3g2b" : "3g2a");
VAR_4 = VAR_2 ? 0x20000 : 0x10000;
} else if (mov->mode == MODE_PSP)
ffio_wfourcc(VAR_0, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(VAR_0, "isom");
else if (mov->mode == MODE_IPOD)
ffio_wfourcc(VAR_0, VAR_3 ? "M4V ":"M4A ");
else if (mov->mode == MODE_ISM)
ffio_wfourcc(VAR_0, "isml");
else if (mov->mode == MODE_F4V)
ffio_wfourcc(VAR_0, "f4v ");
else
ffio_wfourcc(VAR_0, "qt ");
avio_wb32(VAR_0, VAR_4);
if (mov->mode == MODE_MOV)
ffio_wfourcc(VAR_0, "qt ");
else if (mov->mode == MODE_ISM) {
ffio_wfourcc(VAR_0, "piff");
ffio_wfourcc(VAR_0, "iso2");
} else {
ffio_wfourcc(VAR_0, "isom");
ffio_wfourcc(VAR_0, "iso2");
if (VAR_2)
ffio_wfourcc(VAR_0, "avc1");
}
if (mov->mode == MODE_3GP)
ffio_wfourcc(VAR_0, VAR_2 ? "3gp6":"3gp4");
else if (mov->mode & MODE_3G2)
ffio_wfourcc(VAR_0, VAR_2 ? "3g2b":"3g2a");
else if (mov->mode == MODE_PSP)
ffio_wfourcc(VAR_0, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(VAR_0, "mp41");
return update_size(VAR_0, pos);
}
| [
"static int FUNC_0(AVIOContext *VAR_0, AVFormatContext *VAR_1)\n{",
"MOVMuxContext *mov = VAR_1->priv_data;",
"int64_t pos = avio_tell(VAR_0);",
"int VAR_2 = 0, VAR_3 = 0;",
"int VAR_4 = 0x200;",
"int VAR_5;",
"for (VAR_5 = 0; VAR_5 < VAR_1->nb_streams; VAR_5++) {",
"AVStream *st = VAR_1->streams[VAR_5];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)\nVAR_3 = 1;",
"if (st->codec->codec_id == AV_CODEC_ID_H264)\nVAR_2 = 1;",
"}",
"avio_wb32(VAR_0, 0);",
"ffio_wfourcc(VAR_0, \"ftyp\");",
"if (mov->mode == MODE_3GP) {",
"ffio_wfourcc(VAR_0, VAR_2 ? \"3gp6\" : \"3gp4\");",
"VAR_4 = VAR_2 ? 0x100 : 0x200;",
"} else if (mov->mode & MODE_3G2) {",
"ffio_wfourcc(VAR_0, VAR_2 ? \"3g2b\" : \"3g2a\");",
"VAR_4 = VAR_2 ? 0x20000 : 0x10000;",
"} else if (mov->mode == MODE_PSP)",
"ffio_wfourcc(VAR_0, \"MSNV\");",
"else if (mov->mode == MODE_MP4)\nffio_wfourcc(VAR_0, \"isom\");",
"else if (mov->mode == MODE_IPOD)\nffio_wfourcc(VAR_0, VAR_3 ? \"M4V \":\"M4A \");",
"else if (mov->mode == MODE_ISM)\nffio_wfourcc(VAR_0, \"isml\");",
"else if (mov->mode == MODE_F4V)\nffio_wfourcc(VAR_0, \"f4v \");",
"else\nffio_wfourcc(VAR_0, \"qt \");",
"avio_wb32(VAR_0, VAR_4);",
"if (mov->mode == MODE_MOV)\nffio_wfourcc(VAR_0, \"qt \");",
"else if (mov->mode == MODE_ISM) {",
"ffio_wfourcc(VAR_0, \"piff\");",
"ffio_wfourcc(VAR_0, \"iso2\");",
"} else {",
"ffio_wfourcc(VAR_0, \"isom\");",
"ffio_wfourcc(VAR_0, \"iso2\");",
"if (VAR_2)\nffio_wfourcc(VAR_0, \"avc1\");",
"}",
"if (mov->mode == MODE_3GP)\nffio_wfourcc(VAR_0, VAR_2 ? \"3gp6\":\"3gp4\");",
"else if (mov->mode & MODE_3G2)\nffio_wfourcc(VAR_0, VAR_2 ? \"3g2b\":\"3g2a\");",
"else if (mov->mode == MODE_PSP)\nffio_wfourcc(VAR_0, \"MSNV\");",
"else if (mov->mode == MODE_MP4)\nffio_wfourcc(VAR_0, \"mp41\");",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
]
]
|
13,086 | static av_cold int bktr_init(const char *video_device, int width, int height,
int format, int *video_fd, int *tuner_fd, int idev, double frequency)
{
struct meteor_geomet geo;
int h_max;
long ioctl_frequency;
char *arg;
int c;
struct sigaction act = { 0 }, old;
if (idev < 0 || idev > 4)
{
arg = getenv ("BKTR_DEV");
if (arg)
idev = atoi (arg);
if (idev < 0 || idev > 4)
idev = 1;
}
if (format < 1 || format > 6)
{
arg = getenv ("BKTR_FORMAT");
if (arg)
format = atoi (arg);
if (format < 1 || format > 6)
format = VIDEO_FORMAT;
}
if (frequency <= 0)
{
arg = getenv ("BKTR_FREQUENCY");
if (arg)
frequency = atof (arg);
if (frequency <= 0)
frequency = 0.0;
}
sigemptyset(&act.sa_mask);
act.sa_handler = catchsignal;
sigaction(SIGUSR1, &act, &old);
*tuner_fd = open("/dev/tuner0", O_RDONLY);
if (*tuner_fd < 0)
av_log(NULL, AV_LOG_ERROR, "Warning. Tuner not opened, continuing: %s\n", strerror(errno));
*video_fd = open(video_device, O_RDONLY);
if (*video_fd < 0) {
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", video_device, strerror(errno));
return -1;
}
geo.rows = height;
geo.columns = width;
geo.frames = 1;
geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
switch (format) {
case PAL: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
case PALN: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALN; break;
case PALM: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALM; break;
case SECAM: h_max = SECAM_HEIGHT; c = BT848_IFORM_F_SECAM; break;
case NTSC: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCM; break;
case NTSCJ: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCJ; break;
default: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
}
if (height <= h_max / 2)
geo.oformat |= METEOR_GEO_EVEN_ONLY;
if (ioctl(*video_fd, METEORSETGEO, &geo) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSETGEO: %s\n", strerror(errno));
return -1;
}
if (ioctl(*video_fd, BT848SFMT, &c) < 0) {
av_log(NULL, AV_LOG_ERROR, "BT848SFMT: %s\n", strerror(errno));
return -1;
}
c = bktr_dev[idev];
if (ioctl(*video_fd, METEORSINPUT, &c) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSINPUT: %s\n", strerror(errno));
return -1;
}
video_buf_size = width * height * 12 / 8;
video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size,
PROT_READ, MAP_SHARED, *video_fd, (off_t)0);
if (video_buf == MAP_FAILED) {
av_log(NULL, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return -1;
}
if (frequency != 0.0) {
ioctl_frequency = (unsigned long)(frequency*16);
if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SETFREQ: %s\n", strerror(errno));
}
c = AUDIO_UNMUTE;
if (ioctl(*tuner_fd, BT848_SAUDIO, &c) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SAUDIO: %s\n", strerror(errno));
c = METEOR_CAP_CONTINOUS;
ioctl(*video_fd, METEORCAPTUR, &c);
c = SIGUSR1;
ioctl(*video_fd, METEORSSIGNAL, &c);
return 0;
}
| true | FFmpeg | 4f1d7cc0ed66f4ab390631722a7daa660e55a0f3 | static av_cold int bktr_init(const char *video_device, int width, int height,
int format, int *video_fd, int *tuner_fd, int idev, double frequency)
{
struct meteor_geomet geo;
int h_max;
long ioctl_frequency;
char *arg;
int c;
struct sigaction act = { 0 }, old;
if (idev < 0 || idev > 4)
{
arg = getenv ("BKTR_DEV");
if (arg)
idev = atoi (arg);
if (idev < 0 || idev > 4)
idev = 1;
}
if (format < 1 || format > 6)
{
arg = getenv ("BKTR_FORMAT");
if (arg)
format = atoi (arg);
if (format < 1 || format > 6)
format = VIDEO_FORMAT;
}
if (frequency <= 0)
{
arg = getenv ("BKTR_FREQUENCY");
if (arg)
frequency = atof (arg);
if (frequency <= 0)
frequency = 0.0;
}
sigemptyset(&act.sa_mask);
act.sa_handler = catchsignal;
sigaction(SIGUSR1, &act, &old);
*tuner_fd = open("/dev/tuner0", O_RDONLY);
if (*tuner_fd < 0)
av_log(NULL, AV_LOG_ERROR, "Warning. Tuner not opened, continuing: %s\n", strerror(errno));
*video_fd = open(video_device, O_RDONLY);
if (*video_fd < 0) {
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", video_device, strerror(errno));
return -1;
}
geo.rows = height;
geo.columns = width;
geo.frames = 1;
geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
switch (format) {
case PAL: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
case PALN: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALN; break;
case PALM: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALM; break;
case SECAM: h_max = SECAM_HEIGHT; c = BT848_IFORM_F_SECAM; break;
case NTSC: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCM; break;
case NTSCJ: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCJ; break;
default: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
}
if (height <= h_max / 2)
geo.oformat |= METEOR_GEO_EVEN_ONLY;
if (ioctl(*video_fd, METEORSETGEO, &geo) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSETGEO: %s\n", strerror(errno));
return -1;
}
if (ioctl(*video_fd, BT848SFMT, &c) < 0) {
av_log(NULL, AV_LOG_ERROR, "BT848SFMT: %s\n", strerror(errno));
return -1;
}
c = bktr_dev[idev];
if (ioctl(*video_fd, METEORSINPUT, &c) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSINPUT: %s\n", strerror(errno));
return -1;
}
video_buf_size = width * height * 12 / 8;
video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size,
PROT_READ, MAP_SHARED, *video_fd, (off_t)0);
if (video_buf == MAP_FAILED) {
av_log(NULL, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return -1;
}
if (frequency != 0.0) {
ioctl_frequency = (unsigned long)(frequency*16);
if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SETFREQ: %s\n", strerror(errno));
}
c = AUDIO_UNMUTE;
if (ioctl(*tuner_fd, BT848_SAUDIO, &c) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SAUDIO: %s\n", strerror(errno));
c = METEOR_CAP_CONTINOUS;
ioctl(*video_fd, METEORCAPTUR, &c);
c = SIGUSR1;
ioctl(*video_fd, METEORSSIGNAL, &c);
return 0;
}
| {
"code": [
" struct sigaction act = { 0 }, old;"
],
"line_no": [
17
]
} | static av_cold int FUNC_0(const char *video_device, int width, int height,
int format, int *video_fd, int *tuner_fd, int idev, double frequency)
{
struct meteor_geomet VAR_0;
int VAR_1;
long VAR_2;
char *VAR_3;
int VAR_4;
struct sigaction VAR_5 = { 0 }, VAR_6;
if (idev < 0 || idev > 4)
{
VAR_3 = getenv ("BKTR_DEV");
if (VAR_3)
idev = atoi (VAR_3);
if (idev < 0 || idev > 4)
idev = 1;
}
if (format < 1 || format > 6)
{
VAR_3 = getenv ("BKTR_FORMAT");
if (VAR_3)
format = atoi (VAR_3);
if (format < 1 || format > 6)
format = VIDEO_FORMAT;
}
if (frequency <= 0)
{
VAR_3 = getenv ("BKTR_FREQUENCY");
if (VAR_3)
frequency = atof (VAR_3);
if (frequency <= 0)
frequency = 0.0;
}
sigemptyset(&VAR_5.sa_mask);
VAR_5.sa_handler = catchsignal;
sigaction(SIGUSR1, &VAR_5, &VAR_6);
*tuner_fd = open("/dev/tuner0", O_RDONLY);
if (*tuner_fd < 0)
av_log(NULL, AV_LOG_ERROR, "Warning. Tuner not opened, continuing: %s\n", strerror(errno));
*video_fd = open(video_device, O_RDONLY);
if (*video_fd < 0) {
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", video_device, strerror(errno));
return -1;
}
VAR_0.rows = height;
VAR_0.columns = width;
VAR_0.frames = 1;
VAR_0.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
switch (format) {
case PAL: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALBDGHI; break;
case PALN: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALN; break;
case PALM: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALM; break;
case SECAM: VAR_1 = SECAM_HEIGHT; VAR_4 = BT848_IFORM_F_SECAM; break;
case NTSC: VAR_1 = NTSC_HEIGHT; VAR_4 = BT848_IFORM_F_NTSCM; break;
case NTSCJ: VAR_1 = NTSC_HEIGHT; VAR_4 = BT848_IFORM_F_NTSCJ; break;
default: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALBDGHI; break;
}
if (height <= VAR_1 / 2)
VAR_0.oformat |= METEOR_GEO_EVEN_ONLY;
if (ioctl(*video_fd, METEORSETGEO, &VAR_0) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSETGEO: %s\n", strerror(errno));
return -1;
}
if (ioctl(*video_fd, BT848SFMT, &VAR_4) < 0) {
av_log(NULL, AV_LOG_ERROR, "BT848SFMT: %s\n", strerror(errno));
return -1;
}
VAR_4 = bktr_dev[idev];
if (ioctl(*video_fd, METEORSINPUT, &VAR_4) < 0) {
av_log(NULL, AV_LOG_ERROR, "METEORSINPUT: %s\n", strerror(errno));
return -1;
}
video_buf_size = width * height * 12 / 8;
video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size,
PROT_READ, MAP_SHARED, *video_fd, (off_t)0);
if (video_buf == MAP_FAILED) {
av_log(NULL, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return -1;
}
if (frequency != 0.0) {
VAR_2 = (unsigned long)(frequency*16);
if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &VAR_2) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SETFREQ: %s\n", strerror(errno));
}
VAR_4 = AUDIO_UNMUTE;
if (ioctl(*tuner_fd, BT848_SAUDIO, &VAR_4) < 0)
av_log(NULL, AV_LOG_ERROR, "TVTUNER_SAUDIO: %s\n", strerror(errno));
VAR_4 = METEOR_CAP_CONTINOUS;
ioctl(*video_fd, METEORCAPTUR, &VAR_4);
VAR_4 = SIGUSR1;
ioctl(*video_fd, METEORSSIGNAL, &VAR_4);
return 0;
}
| [
"static av_cold int FUNC_0(const char *video_device, int width, int height,\nint format, int *video_fd, int *tuner_fd, int idev, double frequency)\n{",
"struct meteor_geomet VAR_0;",
"int VAR_1;",
"long VAR_2;",
"char *VAR_3;",
"int VAR_4;",
"struct sigaction VAR_5 = { 0 }, VAR_6;",
"if (idev < 0 || idev > 4)\n{",
"VAR_3 = getenv (\"BKTR_DEV\");",
"if (VAR_3)\nidev = atoi (VAR_3);",
"if (idev < 0 || idev > 4)\nidev = 1;",
"}",
"if (format < 1 || format > 6)\n{",
"VAR_3 = getenv (\"BKTR_FORMAT\");",
"if (VAR_3)\nformat = atoi (VAR_3);",
"if (format < 1 || format > 6)\nformat = VIDEO_FORMAT;",
"}",
"if (frequency <= 0)\n{",
"VAR_3 = getenv (\"BKTR_FREQUENCY\");",
"if (VAR_3)\nfrequency = atof (VAR_3);",
"if (frequency <= 0)\nfrequency = 0.0;",
"}",
"sigemptyset(&VAR_5.sa_mask);",
"VAR_5.sa_handler = catchsignal;",
"sigaction(SIGUSR1, &VAR_5, &VAR_6);",
"*tuner_fd = open(\"/dev/tuner0\", O_RDONLY);",
"if (*tuner_fd < 0)\nav_log(NULL, AV_LOG_ERROR, \"Warning. Tuner not opened, continuing: %s\\n\", strerror(errno));",
"*video_fd = open(video_device, O_RDONLY);",
"if (*video_fd < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"%s: %s\\n\", video_device, strerror(errno));",
"return -1;",
"}",
"VAR_0.rows = height;",
"VAR_0.columns = width;",
"VAR_0.frames = 1;",
"VAR_0.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;",
"switch (format) {",
"case PAL: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALBDGHI; break;",
"case PALN: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALN; break;",
"case PALM: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALM; break;",
"case SECAM: VAR_1 = SECAM_HEIGHT; VAR_4 = BT848_IFORM_F_SECAM; break;",
"case NTSC: VAR_1 = NTSC_HEIGHT; VAR_4 = BT848_IFORM_F_NTSCM; break;",
"case NTSCJ: VAR_1 = NTSC_HEIGHT; VAR_4 = BT848_IFORM_F_NTSCJ; break;",
"default: VAR_1 = PAL_HEIGHT; VAR_4 = BT848_IFORM_F_PALBDGHI; break;",
"}",
"if (height <= VAR_1 / 2)\nVAR_0.oformat |= METEOR_GEO_EVEN_ONLY;",
"if (ioctl(*video_fd, METEORSETGEO, &VAR_0) < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"METEORSETGEO: %s\\n\", strerror(errno));",
"return -1;",
"}",
"if (ioctl(*video_fd, BT848SFMT, &VAR_4) < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"BT848SFMT: %s\\n\", strerror(errno));",
"return -1;",
"}",
"VAR_4 = bktr_dev[idev];",
"if (ioctl(*video_fd, METEORSINPUT, &VAR_4) < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"METEORSINPUT: %s\\n\", strerror(errno));",
"return -1;",
"}",
"video_buf_size = width * height * 12 / 8;",
"video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size,\nPROT_READ, MAP_SHARED, *video_fd, (off_t)0);",
"if (video_buf == MAP_FAILED) {",
"av_log(NULL, AV_LOG_ERROR, \"mmap: %s\\n\", strerror(errno));",
"return -1;",
"}",
"if (frequency != 0.0) {",
"VAR_2 = (unsigned long)(frequency*16);",
"if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &VAR_2) < 0)\nav_log(NULL, AV_LOG_ERROR, \"TVTUNER_SETFREQ: %s\\n\", strerror(errno));",
"}",
"VAR_4 = AUDIO_UNMUTE;",
"if (ioctl(*tuner_fd, BT848_SAUDIO, &VAR_4) < 0)\nav_log(NULL, AV_LOG_ERROR, \"TVTUNER_SAUDIO: %s\\n\", strerror(errno));",
"VAR_4 = METEOR_CAP_CONTINOUS;",
"ioctl(*video_fd, METEORCAPTUR, &VAR_4);",
"VAR_4 = SIGUSR1;",
"ioctl(*video_fd, METEORSSIGNAL, &VAR_4);",
"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
]
| [
[
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
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
201
],
[
203,
205
],
[
209
],
[
211
],
[
215
],
[
217
],
[
221
],
[
223
]
]
|
13,087 | static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
void *dst_l, void *dst_r, const int type)
{
int i, j, count = 0;
int last, t;
int A, B, L, L2, R, R2;
int pos = s->pos;
uint32_t crc = s->sc.crc;
uint32_t crc_extra_bits = s->extra_sc.crc;
int16_t *dst16_l = dst_l;
int16_t *dst16_r = dst_r;
int32_t *dst32_l = dst_l;
int32_t *dst32_r = dst_r;
float *dstfl_l = dst_l;
float *dstfl_r = dst_r;
s->one = s->zero = s->zeroes = 0;
do {
L = wv_get_value(s, gb, 0, &last);
if (last)
break;
R = wv_get_value(s, gb, 1, &last);
if (last)
break;
for (i = 0; i < s->terms; i++) {
t = s->decorr[i].value;
if (t > 0) {
if (t > 8) {
if (t & 1) {
A = 2 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
B = 2 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1];
} else {
A = (3 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
B = (3 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1;
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
s->decorr[i].samplesB[1] = s->decorr[i].samplesB[0];
j = 0;
} else {
A = s->decorr[i].samplesA[pos];
B = s->decorr[i].samplesB[pos];
j = (pos + t) & 7;
if (type != AV_SAMPLE_FMT_S16P) {
L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10);
} else {
L2 = L + ((s->decorr[i].weightA * A + 512) >> 10);
R2 = R + ((s->decorr[i].weightB * B + 512) >> 10);
if (A && L)
s->decorr[i].weightA -= ((((L ^ A) >> 30) & 2) - 1) * s->decorr[i].delta;
if (B && R)
s->decorr[i].weightB -= ((((R ^ B) >> 30) & 2) - 1) * s->decorr[i].delta;
s->decorr[i].samplesA[j] = L = L2;
s->decorr[i].samplesB[j] = R = R2;
} else if (t == -1) {
if (type != AV_SAMPLE_FMT_S16P)
L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L);
L = L2;
if (type != AV_SAMPLE_FMT_S16P)
R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, L2, R);
R = R2;
s->decorr[i].samplesA[0] = R;
} else {
if (type != AV_SAMPLE_FMT_S16P)
R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, s->decorr[i].samplesB[0], R);
R = R2;
if (t == -3) {
R2 = s->decorr[i].samplesA[0];
s->decorr[i].samplesA[0] = R;
if (type != AV_SAMPLE_FMT_S16P)
L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, R2, L);
L = L2;
s->decorr[i].samplesB[0] = L;
pos = (pos + 1) & 7;
if (s->joint)
L += (R -= (L >> 1));
crc = (crc * 3 + L) * 3 + R;
if (type == AV_SAMPLE_FMT_FLTP) {
*dstfl_l++ = wv_get_value_float(s, &crc_extra_bits, L);
*dstfl_r++ = wv_get_value_float(s, &crc_extra_bits, R);
} else if (type == AV_SAMPLE_FMT_S32P) {
*dst32_l++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst32_r++ = wv_get_value_integer(s, &crc_extra_bits, R);
} else {
*dst16_l++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst16_r++ = wv_get_value_integer(s, &crc_extra_bits, R);
count++;
} while (!last && count < s->samples);
wv_reset_saved_context(s);
if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
wv_check_crc(s, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
return 0; | true | FFmpeg | 866c44d4b0f90d448cffbe9d4422a2dec7df698b | static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
void *dst_l, void *dst_r, const int type)
{
int i, j, count = 0;
int last, t;
int A, B, L, L2, R, R2;
int pos = s->pos;
uint32_t crc = s->sc.crc;
uint32_t crc_extra_bits = s->extra_sc.crc;
int16_t *dst16_l = dst_l;
int16_t *dst16_r = dst_r;
int32_t *dst32_l = dst_l;
int32_t *dst32_r = dst_r;
float *dstfl_l = dst_l;
float *dstfl_r = dst_r;
s->one = s->zero = s->zeroes = 0;
do {
L = wv_get_value(s, gb, 0, &last);
if (last)
break;
R = wv_get_value(s, gb, 1, &last);
if (last)
break;
for (i = 0; i < s->terms; i++) {
t = s->decorr[i].value;
if (t > 0) {
if (t > 8) {
if (t & 1) {
A = 2 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
B = 2 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1];
} else {
A = (3 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
B = (3 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1;
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
s->decorr[i].samplesB[1] = s->decorr[i].samplesB[0];
j = 0;
} else {
A = s->decorr[i].samplesA[pos];
B = s->decorr[i].samplesB[pos];
j = (pos + t) & 7;
if (type != AV_SAMPLE_FMT_S16P) {
L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10);
} else {
L2 = L + ((s->decorr[i].weightA * A + 512) >> 10);
R2 = R + ((s->decorr[i].weightB * B + 512) >> 10);
if (A && L)
s->decorr[i].weightA -= ((((L ^ A) >> 30) & 2) - 1) * s->decorr[i].delta;
if (B && R)
s->decorr[i].weightB -= ((((R ^ B) >> 30) & 2) - 1) * s->decorr[i].delta;
s->decorr[i].samplesA[j] = L = L2;
s->decorr[i].samplesB[j] = R = R2;
} else if (t == -1) {
if (type != AV_SAMPLE_FMT_S16P)
L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L);
L = L2;
if (type != AV_SAMPLE_FMT_S16P)
R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, L2, R);
R = R2;
s->decorr[i].samplesA[0] = R;
} else {
if (type != AV_SAMPLE_FMT_S16P)
R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, s->decorr[i].samplesB[0], R);
R = R2;
if (t == -3) {
R2 = s->decorr[i].samplesA[0];
s->decorr[i].samplesA[0] = R;
if (type != AV_SAMPLE_FMT_S16P)
L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, R2, L);
L = L2;
s->decorr[i].samplesB[0] = L;
pos = (pos + 1) & 7;
if (s->joint)
L += (R -= (L >> 1));
crc = (crc * 3 + L) * 3 + R;
if (type == AV_SAMPLE_FMT_FLTP) {
*dstfl_l++ = wv_get_value_float(s, &crc_extra_bits, L);
*dstfl_r++ = wv_get_value_float(s, &crc_extra_bits, R);
} else if (type == AV_SAMPLE_FMT_S32P) {
*dst32_l++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst32_r++ = wv_get_value_integer(s, &crc_extra_bits, R);
} else {
*dst16_l++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst16_r++ = wv_get_value_integer(s, &crc_extra_bits, R);
count++;
} while (!last && count < s->samples);
wv_reset_saved_context(s);
if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
wv_check_crc(s, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
return 0; | {
"code": [],
"line_no": []
} | static inline int FUNC_0(WavpackFrameContext *VAR_0, GetBitContext *VAR_1,
void *VAR_2, void *VAR_3, const int VAR_4)
{
int VAR_5, VAR_6, VAR_7 = 0;
int VAR_8, VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
int VAR_16 = VAR_0->VAR_16;
uint32_t crc = VAR_0->sc.crc;
uint32_t crc_extra_bits = VAR_0->extra_sc.crc;
int16_t *dst16_l = VAR_2;
int16_t *dst16_r = VAR_3;
int32_t *dst32_l = VAR_2;
int32_t *dst32_r = VAR_3;
float *VAR_17 = VAR_2;
float *VAR_18 = VAR_3;
VAR_0->one = VAR_0->zero = VAR_0->zeroes = 0;
do {
VAR_12 = wv_get_value(VAR_0, VAR_1, 0, &VAR_8);
if (VAR_8)
break;
VAR_14 = wv_get_value(VAR_0, VAR_1, 1, &VAR_8);
if (VAR_8)
break;
for (VAR_5 = 0; VAR_5 < VAR_0->terms; VAR_5++) {
VAR_9 = VAR_0->decorr[VAR_5].value;
if (VAR_9 > 0) {
if (VAR_9 > 8) {
if (VAR_9 & 1) {
VAR_10 = 2 * VAR_0->decorr[VAR_5].samplesA[0] - VAR_0->decorr[VAR_5].samplesA[1];
VAR_11 = 2 * VAR_0->decorr[VAR_5].samplesB[0] - VAR_0->decorr[VAR_5].samplesB[1];
} else {
VAR_10 = (3 * VAR_0->decorr[VAR_5].samplesA[0] - VAR_0->decorr[VAR_5].samplesA[1]) >> 1;
VAR_11 = (3 * VAR_0->decorr[VAR_5].samplesB[0] - VAR_0->decorr[VAR_5].samplesB[1]) >> 1;
VAR_0->decorr[VAR_5].samplesA[1] = VAR_0->decorr[VAR_5].samplesA[0];
VAR_0->decorr[VAR_5].samplesB[1] = VAR_0->decorr[VAR_5].samplesB[0];
VAR_6 = 0;
} else {
VAR_10 = VAR_0->decorr[VAR_5].samplesA[VAR_16];
VAR_11 = VAR_0->decorr[VAR_5].samplesB[VAR_16];
VAR_6 = (VAR_16 + VAR_9) & 7;
if (VAR_4 != AV_SAMPLE_FMT_S16P) {
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_10 + 512) >> 10);
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_11 + 512) >> 10);
} else {
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_10 + 512) >> 10);
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_11 + 512) >> 10);
if (VAR_10 && VAR_12)
VAR_0->decorr[VAR_5].weightA -= ((((VAR_12 ^ VAR_10) >> 30) & 2) - 1) * VAR_0->decorr[VAR_5].delta;
if (VAR_11 && VAR_14)
VAR_0->decorr[VAR_5].weightB -= ((((VAR_14 ^ VAR_11) >> 30) & 2) - 1) * VAR_0->decorr[VAR_5].delta;
VAR_0->decorr[VAR_5].samplesA[VAR_6] = VAR_12 = VAR_13;
VAR_0->decorr[VAR_5].samplesB[VAR_6] = VAR_14 = VAR_15;
} else if (VAR_9 == -1) {
if (VAR_4 != AV_SAMPLE_FMT_S16P)
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_0->decorr[VAR_5].samplesA[0] + 512) >> 10);
else
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_0->decorr[VAR_5].samplesA[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightA, VAR_0->decorr[VAR_5].delta, VAR_0->decorr[VAR_5].samplesA[0], VAR_12);
VAR_12 = VAR_13;
if (VAR_4 != AV_SAMPLE_FMT_S16P)
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_13 + 512) >> 10);
else
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_13 + 512) >> 10);
UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightB, VAR_0->decorr[VAR_5].delta, VAR_13, VAR_14);
VAR_14 = VAR_15;
VAR_0->decorr[VAR_5].samplesA[0] = VAR_14;
} else {
if (VAR_4 != AV_SAMPLE_FMT_S16P)
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_0->decorr[VAR_5].samplesB[0] + 512) >> 10);
else
VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_0->decorr[VAR_5].samplesB[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightB, VAR_0->decorr[VAR_5].delta, VAR_0->decorr[VAR_5].samplesB[0], VAR_14);
VAR_14 = VAR_15;
if (VAR_9 == -3) {
VAR_15 = VAR_0->decorr[VAR_5].samplesA[0];
VAR_0->decorr[VAR_5].samplesA[0] = VAR_14;
if (VAR_4 != AV_SAMPLE_FMT_S16P)
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_15 + 512) >> 10);
else
VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_15 + 512) >> 10);
UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightA, VAR_0->decorr[VAR_5].delta, VAR_15, VAR_12);
VAR_12 = VAR_13;
VAR_0->decorr[VAR_5].samplesB[0] = VAR_12;
VAR_16 = (VAR_16 + 1) & 7;
if (VAR_0->joint)
VAR_12 += (VAR_14 -= (VAR_12 >> 1));
crc = (crc * 3 + VAR_12) * 3 + VAR_14;
if (VAR_4 == AV_SAMPLE_FMT_FLTP) {
*VAR_17++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_12);
*VAR_18++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_14);
} else if (VAR_4 == AV_SAMPLE_FMT_S32P) {
*dst32_l++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_12);
*dst32_r++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_14);
} else {
*dst16_l++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_12);
*dst16_r++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_14);
VAR_7++;
} while (!VAR_8 && VAR_7 < VAR_0->samples);
wv_reset_saved_context(VAR_0);
if ((VAR_0->avctx->err_recognition & AV_EF_CRCCHECK) &&
wv_check_crc(VAR_0, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
return 0; | [
"static inline int FUNC_0(WavpackFrameContext *VAR_0, GetBitContext *VAR_1,\nvoid *VAR_2, void *VAR_3, const int VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7 = 0;",
"int VAR_8, VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"int VAR_16 = VAR_0->VAR_16;",
"uint32_t crc = VAR_0->sc.crc;",
"uint32_t crc_extra_bits = VAR_0->extra_sc.crc;",
"int16_t *dst16_l = VAR_2;",
"int16_t *dst16_r = VAR_3;",
"int32_t *dst32_l = VAR_2;",
"int32_t *dst32_r = VAR_3;",
"float *VAR_17 = VAR_2;",
"float *VAR_18 = VAR_3;",
"VAR_0->one = VAR_0->zero = VAR_0->zeroes = 0;",
"do {",
"VAR_12 = wv_get_value(VAR_0, VAR_1, 0, &VAR_8);",
"if (VAR_8)\nbreak;",
"VAR_14 = wv_get_value(VAR_0, VAR_1, 1, &VAR_8);",
"if (VAR_8)\nbreak;",
"for (VAR_5 = 0; VAR_5 < VAR_0->terms; VAR_5++) {",
"VAR_9 = VAR_0->decorr[VAR_5].value;",
"if (VAR_9 > 0) {",
"if (VAR_9 > 8) {",
"if (VAR_9 & 1) {",
"VAR_10 = 2 * VAR_0->decorr[VAR_5].samplesA[0] - VAR_0->decorr[VAR_5].samplesA[1];",
"VAR_11 = 2 * VAR_0->decorr[VAR_5].samplesB[0] - VAR_0->decorr[VAR_5].samplesB[1];",
"} else {",
"VAR_10 = (3 * VAR_0->decorr[VAR_5].samplesA[0] - VAR_0->decorr[VAR_5].samplesA[1]) >> 1;",
"VAR_11 = (3 * VAR_0->decorr[VAR_5].samplesB[0] - VAR_0->decorr[VAR_5].samplesB[1]) >> 1;",
"VAR_0->decorr[VAR_5].samplesA[1] = VAR_0->decorr[VAR_5].samplesA[0];",
"VAR_0->decorr[VAR_5].samplesB[1] = VAR_0->decorr[VAR_5].samplesB[0];",
"VAR_6 = 0;",
"} else {",
"VAR_10 = VAR_0->decorr[VAR_5].samplesA[VAR_16];",
"VAR_11 = VAR_0->decorr[VAR_5].samplesB[VAR_16];",
"VAR_6 = (VAR_16 + VAR_9) & 7;",
"if (VAR_4 != AV_SAMPLE_FMT_S16P) {",
"VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_10 + 512) >> 10);",
"VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_11 + 512) >> 10);",
"} else {",
"VAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_10 + 512) >> 10);",
"VAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_11 + 512) >> 10);",
"if (VAR_10 && VAR_12)\nVAR_0->decorr[VAR_5].weightA -= ((((VAR_12 ^ VAR_10) >> 30) & 2) - 1) * VAR_0->decorr[VAR_5].delta;",
"if (VAR_11 && VAR_14)\nVAR_0->decorr[VAR_5].weightB -= ((((VAR_14 ^ VAR_11) >> 30) & 2) - 1) * VAR_0->decorr[VAR_5].delta;",
"VAR_0->decorr[VAR_5].samplesA[VAR_6] = VAR_12 = VAR_13;",
"VAR_0->decorr[VAR_5].samplesB[VAR_6] = VAR_14 = VAR_15;",
"} else if (VAR_9 == -1) {",
"if (VAR_4 != AV_SAMPLE_FMT_S16P)\nVAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_0->decorr[VAR_5].samplesA[0] + 512) >> 10);",
"else\nVAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_0->decorr[VAR_5].samplesA[0] + 512) >> 10);",
"UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightA, VAR_0->decorr[VAR_5].delta, VAR_0->decorr[VAR_5].samplesA[0], VAR_12);",
"VAR_12 = VAR_13;",
"if (VAR_4 != AV_SAMPLE_FMT_S16P)\nVAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_13 + 512) >> 10);",
"else\nVAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_13 + 512) >> 10);",
"UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightB, VAR_0->decorr[VAR_5].delta, VAR_13, VAR_14);",
"VAR_14 = VAR_15;",
"VAR_0->decorr[VAR_5].samplesA[0] = VAR_14;",
"} else {",
"if (VAR_4 != AV_SAMPLE_FMT_S16P)\nVAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * (int64_t)VAR_0->decorr[VAR_5].samplesB[0] + 512) >> 10);",
"else\nVAR_15 = VAR_14 + ((VAR_0->decorr[VAR_5].weightB * VAR_0->decorr[VAR_5].samplesB[0] + 512) >> 10);",
"UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightB, VAR_0->decorr[VAR_5].delta, VAR_0->decorr[VAR_5].samplesB[0], VAR_14);",
"VAR_14 = VAR_15;",
"if (VAR_9 == -3) {",
"VAR_15 = VAR_0->decorr[VAR_5].samplesA[0];",
"VAR_0->decorr[VAR_5].samplesA[0] = VAR_14;",
"if (VAR_4 != AV_SAMPLE_FMT_S16P)\nVAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * (int64_t)VAR_15 + 512) >> 10);",
"else\nVAR_13 = VAR_12 + ((VAR_0->decorr[VAR_5].weightA * VAR_15 + 512) >> 10);",
"UPDATE_WEIGHT_CLIP(VAR_0->decorr[VAR_5].weightA, VAR_0->decorr[VAR_5].delta, VAR_15, VAR_12);",
"VAR_12 = VAR_13;",
"VAR_0->decorr[VAR_5].samplesB[0] = VAR_12;",
"VAR_16 = (VAR_16 + 1) & 7;",
"if (VAR_0->joint)\nVAR_12 += (VAR_14 -= (VAR_12 >> 1));",
"crc = (crc * 3 + VAR_12) * 3 + VAR_14;",
"if (VAR_4 == AV_SAMPLE_FMT_FLTP) {",
"*VAR_17++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_12);",
"*VAR_18++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_14);",
"} else if (VAR_4 == AV_SAMPLE_FMT_S32P) {",
"*dst32_l++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_12);",
"*dst32_r++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_14);",
"} else {",
"*dst16_l++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_12);",
"*dst16_r++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_14);",
"VAR_7++;",
"} while (!VAR_8 && VAR_7 < VAR_0->samples);",
"wv_reset_saved_context(VAR_0);",
"if ((VAR_0->avctx->err_recognition & AV_EF_CRCCHECK) &&\nwv_check_crc(VAR_0, crc, crc_extra_bits))\nreturn AVERROR_INVALIDDATA;",
"return 0;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19,
20
],
[
21
],
[
22,
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47,
48
],
[
49,
50
],
[
51
],
[
52
],
[
53
],
[
54,
55
],
[
56,
57
],
[
58
],
[
59
],
[
60,
61
],
[
62,
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68,
69
],
[
70,
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77,
78
],
[
79,
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85,
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
],
[
99
],
[
100,
101,
102
],
[
103
]
]
|
13,088 | static ExitStatus trans_fop_wed_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_wed(ctx, rt, ra, di->f_wed);
}
| true | qemu | eff235eb2bcd7092901f4698a7907e742f3b7f2f | static ExitStatus trans_fop_wed_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_wed(ctx, rt, ra, di->f_wed);
}
| {
"code": [
" return do_fop_wed(ctx, rt, ra, di->f_wed);",
" return do_fop_wed(ctx, rt, ra, di->f_wed);"
],
"line_no": [
11,
11
]
} | static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned VAR_0 = extract32(insn, 0, 5);
unsigned VAR_1 = extract32(insn, 21, 5);
return do_fop_wed(ctx, VAR_0, VAR_1, di->f_wed);
}
| [
"static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn,\nconst DisasInsn *di)\n{",
"unsigned VAR_0 = extract32(insn, 0, 5);",
"unsigned VAR_1 = extract32(insn, 21, 5);",
"return do_fop_wed(ctx, VAR_0, VAR_1, di->f_wed);",
"}"
]
| [
0,
0,
0,
1,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.