id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
24,369 | void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
int numCB, int max_steps, int *closest_cb,
AVLFG *rand_state)
{
int i, k;
if (numpoints > 24*numCB) {
/* ELBG is very costly for a big number of points. So if we have a lot
of them, get a good initial codebook to save on iterations */
int *temp_points = av_malloc(dim*(numpoints/8)*sizeof(int));
for (i=0; i<numpoints/8; i++) {
k = (i*BIG_PRIME) % numpoints;
memcpy(temp_points + i*dim, points + k*dim, dim*sizeof(int));
}
ff_init_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state);
ff_do_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state);
av_free(temp_points);
} else // If not, initialize the codebook with random positions
for (i=0; i < numCB; i++)
memcpy(codebook + i*dim, points + ((i*BIG_PRIME)%numpoints)*dim,
dim*sizeof(int));
}
| false | FFmpeg | ae2d41ec875965ce4ab9fdd88a5e8ba57cada67a | void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
int numCB, int max_steps, int *closest_cb,
AVLFG *rand_state)
{
int i, k;
if (numpoints > 24*numCB) {
int *temp_points = av_malloc(dim*(numpoints/8)*sizeof(int));
for (i=0; i<numpoints/8; i++) {
k = (i*BIG_PRIME) % numpoints;
memcpy(temp_points + i*dim, points + k*dim, dim*sizeof(int));
}
ff_init_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state);
ff_do_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state);
av_free(temp_points);
} else
for (i=0; i < numCB; i++)
memcpy(codebook + i*dim, points + ((i*BIG_PRIME)%numpoints)*dim,
dim*sizeof(int));
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int *VAR_0, int VAR_1, int VAR_2, int *VAR_3,
int VAR_4, int VAR_5, int *VAR_6,
AVLFG *VAR_7)
{
int VAR_8, VAR_9;
if (VAR_2 > 24*VAR_4) {
int *VAR_10 = av_malloc(VAR_1*(VAR_2/8)*sizeof(int));
for (VAR_8=0; VAR_8<VAR_2/8; VAR_8++) {
VAR_9 = (VAR_8*BIG_PRIME) % VAR_2;
memcpy(VAR_10 + VAR_8*VAR_1, VAR_0 + VAR_9*VAR_1, VAR_1*sizeof(int));
}
FUNC_0(VAR_10, VAR_1, VAR_2/8, VAR_3, VAR_4, 2*VAR_5, VAR_6, VAR_7);
ff_do_elbg(VAR_10, VAR_1, VAR_2/8, VAR_3, VAR_4, 2*VAR_5, VAR_6, VAR_7);
av_free(VAR_10);
} else
for (VAR_8=0; VAR_8 < VAR_4; VAR_8++)
memcpy(VAR_3 + VAR_8*VAR_1, VAR_0 + ((VAR_8*BIG_PRIME)%VAR_2)*VAR_1,
VAR_1*sizeof(int));
}
| [
"void FUNC_0(int *VAR_0, int VAR_1, int VAR_2, int *VAR_3,\nint VAR_4, int VAR_5, int *VAR_6,\nAVLFG *VAR_7)\n{",
"int VAR_8, VAR_9;",
"if (VAR_2 > 24*VAR_4) {",
"int *VAR_10 = av_malloc(VAR_1*(VAR_2/8)*sizeof(int));",
"for (VAR_8=0; VAR_8<VAR_2/8; VAR_8++) {",
"VAR_9 = (VAR_8*BIG_PRIME) % VAR_2;",
"memcpy(VAR_10 + VAR_8*VAR_1, VAR_0 + VAR_9*VAR_1, VAR_1*sizeof(int));",
"}",
"FUNC_0(VAR_10, VAR_1, VAR_2/8, VAR_3, VAR_4, 2*VAR_5, VAR_6, VAR_7);",
"ff_do_elbg(VAR_10, VAR_1, VAR_2/8, VAR_3, VAR_4, 2*VAR_5, VAR_6, VAR_7);",
"av_free(VAR_10);",
"} else",
"for (VAR_8=0; VAR_8 < VAR_4; VAR_8++)",
"memcpy(VAR_3 + VAR_8*VAR_1, VAR_0 + ((VAR_8*BIG_PRIME)%VAR_2)*VAR_1,\nVAR_1*sizeof(int));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
51
]
] |
24,370 | av_cold void ff_lpc_init_x86(LPCContext *c)
{
#if HAVE_SSE2_INLINE
int cpu_flags = av_get_cpu_flags();
if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
}
#endif /* HAVE_SSE2_INLINE */
}
| false | FFmpeg | 7fb758cd8ed08e4a37f10e25003953d13c68b8cd | av_cold void ff_lpc_init_x86(LPCContext *c)
{
#if HAVE_SSE2_INLINE
int cpu_flags = av_get_cpu_flags();
if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
}
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(LPCContext *c)
{
#if HAVE_SSE2_INLINE
int cpu_flags = av_get_cpu_flags();
if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
}
#endif
}
| [
"av_cold void FUNC_0(LPCContext *c)\n{",
"#if HAVE_SSE2_INLINE\nint cpu_flags = av_get_cpu_flags();",
"if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {",
"c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;",
"c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
]
] |
24,372 | int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
size= RAW_SAMPLES*s->streams[0]->codec->block_align;
if (size <= 0)
return AVERROR(EINVAL);
ret= av_get_packet(s->pb, pkt, size);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret < 0)
return ret;
return ret;
}
| false | FFmpeg | 4d09bc98974d4602d71e71520535457a53d44222 | int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
size= RAW_SAMPLES*s->streams[0]->codec->block_align;
if (size <= 0)
return AVERROR(EINVAL);
ret= av_get_packet(s->pb, pkt, size);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret < 0)
return ret;
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2, VAR_3;
VAR_3= RAW_SAMPLES*VAR_0->streams[0]->codec->block_align;
if (VAR_3 <= 0)
return AVERROR(EINVAL);
VAR_2= av_get_packet(VAR_0->pb, VAR_1, VAR_3);
VAR_1->flags &= ~AV_PKT_FLAG_CORRUPT;
VAR_1->stream_index = 0;
if (VAR_2 < 0)
return VAR_2;
return VAR_2;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2, VAR_3;",
"VAR_3= RAW_SAMPLES*VAR_0->streams[0]->codec->block_align;",
"if (VAR_3 <= 0)\nreturn AVERROR(EINVAL);",
"VAR_2= av_get_packet(VAR_0->pb, VAR_1, VAR_3);",
"VAR_1->flags &= ~AV_PKT_FLAG_CORRUPT;",
"VAR_1->stream_index = 0;",
"if (VAR_2 < 0)\nreturn VAR_2;",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33
]
] |
24,373 | static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
int mba_xy, mbb_xy;
int ctx = 0;
if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches?
int mb_xy = mb_x + (mb_y&~1)*s->mb_stride;
mba_xy = mb_xy - 1;
if( (mb_y&1)
&& h->slice_table[mba_xy] == h->slice_num
&& MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) )
mba_xy += s->mb_stride;
if( MB_FIELD ){
mbb_xy = mb_xy - s->mb_stride;
if( !(mb_y&1)
&& h->slice_table[mbb_xy] == h->slice_num
&& IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) )
mbb_xy -= s->mb_stride;
}else
mbb_xy = mb_x + (mb_y-1)*s->mb_stride;
}else{
int mb_xy = mb_x + mb_y*s->mb_stride;
mba_xy = mb_xy - 1;
mbb_xy = mb_xy - s->mb_stride;
}
if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ))
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
ctx++;
if( h->slice_type == B_TYPE )
ctx += 13;
return get_cabac( &h->cabac, &h->cabac_state[11+ctx] );
}
| false | FFmpeg | 851ded8918c977d8160c6617b69604f758cabf50 | static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
int mba_xy, mbb_xy;
int ctx = 0;
if(FRAME_MBAFF){
int mb_xy = mb_x + (mb_y&~1)*s->mb_stride;
mba_xy = mb_xy - 1;
if( (mb_y&1)
&& h->slice_table[mba_xy] == h->slice_num
&& MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) )
mba_xy += s->mb_stride;
if( MB_FIELD ){
mbb_xy = mb_xy - s->mb_stride;
if( !(mb_y&1)
&& h->slice_table[mbb_xy] == h->slice_num
&& IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) )
mbb_xy -= s->mb_stride;
}else
mbb_xy = mb_x + (mb_y-1)*s->mb_stride;
}else{
int mb_xy = mb_x + mb_y*s->mb_stride;
mba_xy = mb_xy - 1;
mbb_xy = mb_xy - s->mb_stride;
}
if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ))
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
ctx++;
if( h->slice_type == B_TYPE )
ctx += 13;
return get_cabac( &h->cabac, &h->cabac_state[11+ctx] );
}
| {
"code": [],
"line_no": []
} | static int FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2 ) {
MpegEncContext * const s = &VAR_0->s;
int VAR_3, VAR_4;
int VAR_5 = 0;
if(FRAME_MBAFF){
int VAR_7 = VAR_1 + (VAR_2&~1)*s->mb_stride;
VAR_3 = VAR_7 - 1;
if( (VAR_2&1)
&& VAR_0->slice_table[VAR_3] == VAR_0->slice_num
&& MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[VAR_3] ) )
VAR_3 += s->mb_stride;
if( MB_FIELD ){
VAR_4 = VAR_7 - s->mb_stride;
if( !(VAR_2&1)
&& VAR_0->slice_table[VAR_4] == VAR_0->slice_num
&& IS_INTERLACED( s->current_picture.mb_type[VAR_4] ) )
VAR_4 -= s->mb_stride;
}else
VAR_4 = VAR_1 + (VAR_2-1)*s->mb_stride;
}else{
int VAR_7 = VAR_1 + VAR_2*s->mb_stride;
VAR_3 = VAR_7 - 1;
VAR_4 = VAR_7 - s->mb_stride;
}
if( VAR_0->slice_table[VAR_3] == VAR_0->slice_num && !IS_SKIP( s->current_picture.mb_type[VAR_3] ))
VAR_5++;
if( VAR_0->slice_table[VAR_4] == VAR_0->slice_num && !IS_SKIP( s->current_picture.mb_type[VAR_4] ))
VAR_5++;
if( VAR_0->slice_type == B_TYPE )
VAR_5 += 13;
return get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[11+VAR_5] );
}
| [
"static int FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2 ) {",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_3, VAR_4;",
"int VAR_5 = 0;",
"if(FRAME_MBAFF){",
"int VAR_7 = VAR_1 + (VAR_2&~1)*s->mb_stride;",
"VAR_3 = VAR_7 - 1;",
"if( (VAR_2&1)\n&& VAR_0->slice_table[VAR_3] == VAR_0->slice_num\n&& MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[VAR_3] ) )\nVAR_3 += s->mb_stride;",
"if( MB_FIELD ){",
"VAR_4 = VAR_7 - s->mb_stride;",
"if( !(VAR_2&1)\n&& VAR_0->slice_table[VAR_4] == VAR_0->slice_num\n&& IS_INTERLACED( s->current_picture.mb_type[VAR_4] ) )\nVAR_4 -= s->mb_stride;",
"}else",
"VAR_4 = VAR_1 + (VAR_2-1)*s->mb_stride;",
"}else{",
"int VAR_7 = VAR_1 + VAR_2*s->mb_stride;",
"VAR_3 = VAR_7 - 1;",
"VAR_4 = VAR_7 - s->mb_stride;",
"}",
"if( VAR_0->slice_table[VAR_3] == VAR_0->slice_num && !IS_SKIP( s->current_picture.mb_type[VAR_3] ))\nVAR_5++;",
"if( VAR_0->slice_table[VAR_4] == VAR_0->slice_num && !IS_SKIP( s->current_picture.mb_type[VAR_4] ))\nVAR_5++;",
"if( VAR_0->slice_type == B_TYPE )\nVAR_5 += 13;",
"return get_cabac( &VAR_0->cabac, &VAR_0->cabac_state[11+VAR_5] );",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23
],
[
25
],
[
27
],
[
29,
31,
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57,
59
],
[
63,
65
],
[
67
],
[
69
]
] |
24,374 | static int handle_packets(AVFormatContext *s, int nb_packets)
{
MpegTSContext *ts = s->priv_data;
ByteIOContext *pb = &s->pb;
uint8_t packet[TS_FEC_PACKET_SIZE];
int packet_num, len;
ts->stop_parse = 0;
packet_num = 0;
for(;;) {
if (ts->stop_parse)
break;
packet_num++;
if (nb_packets != 0 && packet_num >= nb_packets)
break;
len = get_buffer(pb, packet, ts->raw_packet_size);
if (len != ts->raw_packet_size)
return AVERROR_IO;
/* check paquet sync byte */
/* XXX: accept to resync ? */
if (packet[0] != 0x47)
return AVERROR_INVALIDDATA;
handle_packet(s, packet);
}
return 0;
}
| false | FFmpeg | ec23a47286a9be0ca67b78f4d8b9d87220c18286 | static int handle_packets(AVFormatContext *s, int nb_packets)
{
MpegTSContext *ts = s->priv_data;
ByteIOContext *pb = &s->pb;
uint8_t packet[TS_FEC_PACKET_SIZE];
int packet_num, len;
ts->stop_parse = 0;
packet_num = 0;
for(;;) {
if (ts->stop_parse)
break;
packet_num++;
if (nb_packets != 0 && packet_num >= nb_packets)
break;
len = get_buffer(pb, packet, ts->raw_packet_size);
if (len != ts->raw_packet_size)
return AVERROR_IO;
if (packet[0] != 0x47)
return AVERROR_INVALIDDATA;
handle_packet(s, packet);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
MpegTSContext *ts = VAR_0->priv_data;
ByteIOContext *pb = &VAR_0->pb;
uint8_t packet[TS_FEC_PACKET_SIZE];
int VAR_2, VAR_3;
ts->stop_parse = 0;
VAR_2 = 0;
for(;;) {
if (ts->stop_parse)
break;
VAR_2++;
if (VAR_1 != 0 && VAR_2 >= VAR_1)
break;
VAR_3 = get_buffer(pb, packet, ts->raw_packet_size);
if (VAR_3 != ts->raw_packet_size)
return AVERROR_IO;
if (packet[0] != 0x47)
return AVERROR_INVALIDDATA;
handle_packet(VAR_0, packet);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"MpegTSContext *ts = VAR_0->priv_data;",
"ByteIOContext *pb = &VAR_0->pb;",
"uint8_t packet[TS_FEC_PACKET_SIZE];",
"int VAR_2, VAR_3;",
"ts->stop_parse = 0;",
"VAR_2 = 0;",
"for(;;) {",
"if (ts->stop_parse)\nbreak;",
"VAR_2++;",
"if (VAR_1 != 0 && VAR_2 >= VAR_1)\nbreak;",
"VAR_3 = get_buffer(pb, packet, ts->raw_packet_size);",
"if (VAR_3 != ts->raw_packet_size)\nreturn AVERROR_IO;",
"if (packet[0] != 0x47)\nreturn AVERROR_INVALIDDATA;",
"handle_packet(VAR_0, packet);",
"}",
"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
],
[
31
],
[
33,
35
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
24,376 | QTestState *qtest_init(const char *extra_args)
{
QTestState *s;
int sock, qmpsock, i;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *qemu_binary;
struct sigaction sigact;
qemu_binary = getenv("QTEST_QEMU_BINARY");
g_assert(qemu_binary != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
sock = init_socket(socket_path);
qmpsock = init_socket(qmp_socket_path);
/* Catch SIGABRT to clean up on g_assert() failure */
sigact = (struct sigaction){
.sa_handler = sigabrt_handler,
.sa_flags = SA_RESETHAND,
};
sigemptyset(&sigact.sa_mask);
sigaction(SIGABRT, &sigact, &s->sigact_old);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log /dev/null "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", qemu_binary, socket_path,
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(sock);
s->qmp_fd = socket_accept(qmpsock);
unlink(socket_path);
unlink(qmp_socket_path);
g_free(socket_path);
g_free(qmp_socket_path);
s->rx = g_string_new("");
for (i = 0; i < MAX_IRQ; i++) {
s->irq_level[i] = false;
}
/* Read the QMP greeting and then do the handshake */
qtest_qmp_discard_response(s, "");
qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
return s;
}
| true | qemu | f8762027a33e2f5d0915c56a904962b1481f75c1 | QTestState *qtest_init(const char *extra_args)
{
QTestState *s;
int sock, qmpsock, i;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *qemu_binary;
struct sigaction sigact;
qemu_binary = getenv("QTEST_QEMU_BINARY");
g_assert(qemu_binary != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
sock = init_socket(socket_path);
qmpsock = init_socket(qmp_socket_path);
sigact = (struct sigaction){
.sa_handler = sigabrt_handler,
.sa_flags = SA_RESETHAND,
};
sigemptyset(&sigact.sa_mask);
sigaction(SIGABRT, &sigact, &s->sigact_old);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log /dev/null "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", qemu_binary, socket_path,
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(sock);
s->qmp_fd = socket_accept(qmpsock);
unlink(socket_path);
unlink(qmp_socket_path);
g_free(socket_path);
g_free(qmp_socket_path);
s->rx = g_string_new("");
for (i = 0; i < MAX_IRQ; i++) {
s->irq_level[i] = false;
}
qtest_qmp_discard_response(s, "");
qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
return s;
}
| {
"code": [
" s->qmp_fd = socket_accept(qmpsock);"
],
"line_no": [
91
]
} | QTestState *FUNC_0(const char *extra_args)
{
QTestState *s;
int VAR_0, VAR_1, VAR_2;
gchar *socket_path;
gchar *qmp_socket_path;
gchar *command;
const char *VAR_3;
struct sigaction VAR_4;
VAR_3 = getenv("QTEST_QEMU_BINARY");
g_assert(VAR_3 != NULL);
s = g_malloc(sizeof(*s));
socket_path = g_strdup_printf("/tmp/qtest-%d.VAR_0", getpid());
qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
VAR_0 = init_socket(socket_path);
VAR_1 = init_socket(qmp_socket_path);
VAR_4 = (struct sigaction){
.sa_handler = sigabrt_handler,
.sa_flags = SA_RESETHAND,
};
sigemptyset(&VAR_4.sa_mask);
sigaction(SIGABRT, &VAR_4, &s->sigact_old);
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
command = g_strdup_printf("exec %s "
"-qtest unix:%s,nowait "
"-qtest-log /dev/null "
"-qmp unix:%s,nowait "
"-machine accel=qtest "
"-display none "
"%s", VAR_3, socket_path,
qmp_socket_path,
extra_args ?: "");
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
s->fd = socket_accept(VAR_0);
s->qmp_fd = socket_accept(VAR_1);
unlink(socket_path);
unlink(qmp_socket_path);
g_free(socket_path);
g_free(qmp_socket_path);
s->rx = g_string_new("");
for (VAR_2 = 0; VAR_2 < MAX_IRQ; VAR_2++) {
s->irq_level[VAR_2] = false;
}
qtest_qmp_discard_response(s, "");
qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
}
return s;
}
| [
"QTestState *FUNC_0(const char *extra_args)\n{",
"QTestState *s;",
"int VAR_0, VAR_1, VAR_2;",
"gchar *socket_path;",
"gchar *qmp_socket_path;",
"gchar *command;",
"const char *VAR_3;",
"struct sigaction VAR_4;",
"VAR_3 = getenv(\"QTEST_QEMU_BINARY\");",
"g_assert(VAR_3 != NULL);",
"s = g_malloc(sizeof(*s));",
"socket_path = g_strdup_printf(\"/tmp/qtest-%d.VAR_0\", getpid());",
"qmp_socket_path = g_strdup_printf(\"/tmp/qtest-%d.qmp\", getpid());",
"VAR_0 = init_socket(socket_path);",
"VAR_1 = init_socket(qmp_socket_path);",
"VAR_4 = (struct sigaction){",
".sa_handler = sigabrt_handler,\n.sa_flags = SA_RESETHAND,\n};",
"sigemptyset(&VAR_4.sa_mask);",
"sigaction(SIGABRT, &VAR_4, &s->sigact_old);",
"s->qemu_pid = fork();",
"if (s->qemu_pid == 0) {",
"command = g_strdup_printf(\"exec %s \"\n\"-qtest unix:%s,nowait \"\n\"-qtest-log /dev/null \"\n\"-qmp unix:%s,nowait \"\n\"-machine accel=qtest \"\n\"-display none \"\n\"%s\", VAR_3, socket_path,\nqmp_socket_path,\nextra_args ?: \"\");",
"execlp(\"/bin/sh\", \"sh\", \"-c\", command, NULL);",
"exit(1);",
"}",
"s->fd = socket_accept(VAR_0);",
"s->qmp_fd = socket_accept(VAR_1);",
"unlink(socket_path);",
"unlink(qmp_socket_path);",
"g_free(socket_path);",
"g_free(qmp_socket_path);",
"s->rx = g_string_new(\"\");",
"for (VAR_2 = 0; VAR_2 < MAX_IRQ; VAR_2++) {",
"s->irq_level[VAR_2] = false;",
"}",
"qtest_qmp_discard_response(s, \"\");",
"qtest_qmp_discard_response(s, \"{ 'execute': 'qmp_capabilities' }\");",
"if (getenv(\"QTEST_STOP\")) {",
"kill(s->qemu_pid, SIGSTOP);",
"}",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
45
],
[
47,
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65,
67,
69,
71,
73,
75,
77,
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
]
] |
24,377 | static void qxl_init_ramsize(PCIQXLDevice *qxl)
{
/* vga mode framebuffer / primary surface (bar 0, first part) */
if (qxl->vgamem_size_mb < 8) {
qxl->vgamem_size_mb = 8;
qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024;
/* vga ram (bar 0, total) */
if (qxl->ram_size_mb != -1) {
qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;
if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
qxl->vga.vram_size = qxl->vgamem_size * 2;
/* vram32 (surfaces, 32bit, bar 1) */
if (qxl->vram32_size_mb != -1) {
qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
if (qxl->vram32_size < 4096) {
qxl->vram32_size = 4096;
/* vram (surfaces, 64bit, bar 4+5) */
if (qxl->vram_size_mb != -1) {
qxl->vram_size = qxl->vram_size_mb * 1024 * 1024;
if (qxl->vram_size < qxl->vram32_size) {
qxl->vram_size = qxl->vram32_size;
if (qxl->revision == 1) {
qxl->vram32_size = 4096;
qxl->vram_size = 4096;
qxl->vgamem_size = msb_mask(qxl->vgamem_size * 2 - 1);
qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1);
qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);
| true | qemu | 876d516311c1538a7d29f2abec48b7cda0645eea | static void qxl_init_ramsize(PCIQXLDevice *qxl)
{
if (qxl->vgamem_size_mb < 8) {
qxl->vgamem_size_mb = 8;
qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024;
if (qxl->ram_size_mb != -1) {
qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;
if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
qxl->vga.vram_size = qxl->vgamem_size * 2;
if (qxl->vram32_size_mb != -1) {
qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
if (qxl->vram32_size < 4096) {
qxl->vram32_size = 4096;
if (qxl->vram_size_mb != -1) {
qxl->vram_size = qxl->vram_size_mb * 1024 * 1024;
if (qxl->vram_size < qxl->vram32_size) {
qxl->vram_size = qxl->vram32_size;
if (qxl->revision == 1) {
qxl->vram32_size = 4096;
qxl->vram_size = 4096;
qxl->vgamem_size = msb_mask(qxl->vgamem_size * 2 - 1);
qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1);
qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIQXLDevice *VAR_0)
{
if (VAR_0->vgamem_size_mb < 8) {
VAR_0->vgamem_size_mb = 8;
VAR_0->vgamem_size = VAR_0->vgamem_size_mb * 1024 * 1024;
if (VAR_0->ram_size_mb != -1) {
VAR_0->vga.vram_size = VAR_0->ram_size_mb * 1024 * 1024;
if (VAR_0->vga.vram_size < VAR_0->vgamem_size * 2) {
VAR_0->vga.vram_size = VAR_0->vgamem_size * 2;
if (VAR_0->vram32_size_mb != -1) {
VAR_0->vram32_size = VAR_0->vram32_size_mb * 1024 * 1024;
if (VAR_0->vram32_size < 4096) {
VAR_0->vram32_size = 4096;
if (VAR_0->vram_size_mb != -1) {
VAR_0->vram_size = VAR_0->vram_size_mb * 1024 * 1024;
if (VAR_0->vram_size < VAR_0->vram32_size) {
VAR_0->vram_size = VAR_0->vram32_size;
if (VAR_0->revision == 1) {
VAR_0->vram32_size = 4096;
VAR_0->vram_size = 4096;
VAR_0->vgamem_size = msb_mask(VAR_0->vgamem_size * 2 - 1);
VAR_0->vga.vram_size = msb_mask(VAR_0->vga.vram_size * 2 - 1);
VAR_0->vram32_size = msb_mask(VAR_0->vram32_size * 2 - 1);
VAR_0->vram_size = msb_mask(VAR_0->vram_size * 2 - 1);
| [
"static void FUNC_0(PCIQXLDevice *VAR_0)\n{",
"if (VAR_0->vgamem_size_mb < 8) {",
"VAR_0->vgamem_size_mb = 8;",
"VAR_0->vgamem_size = VAR_0->vgamem_size_mb * 1024 * 1024;",
"if (VAR_0->ram_size_mb != -1) {",
"VAR_0->vga.vram_size = VAR_0->ram_size_mb * 1024 * 1024;",
"if (VAR_0->vga.vram_size < VAR_0->vgamem_size * 2) {",
"VAR_0->vga.vram_size = VAR_0->vgamem_size * 2;",
"if (VAR_0->vram32_size_mb != -1) {",
"VAR_0->vram32_size = VAR_0->vram32_size_mb * 1024 * 1024;",
"if (VAR_0->vram32_size < 4096) {",
"VAR_0->vram32_size = 4096;",
"if (VAR_0->vram_size_mb != -1) {",
"VAR_0->vram_size = VAR_0->vram_size_mb * 1024 * 1024;",
"if (VAR_0->vram_size < VAR_0->vram32_size) {",
"VAR_0->vram_size = VAR_0->vram32_size;",
"if (VAR_0->revision == 1) {",
"VAR_0->vram32_size = 4096;",
"VAR_0->vram_size = 4096;",
"VAR_0->vgamem_size = msb_mask(VAR_0->vgamem_size * 2 - 1);",
"VAR_0->vga.vram_size = msb_mask(VAR_0->vga.vram_size * 2 - 1);",
"VAR_0->vram32_size = msb_mask(VAR_0->vram32_size * 2 - 1);",
"VAR_0->vram_size = msb_mask(VAR_0->vram_size * 2 - 1);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
18
],
[
24
],
[
26
],
[
29
],
[
31
],
[
38
],
[
40
],
[
43
],
[
45
],
[
52
],
[
54
],
[
57
],
[
59
],
[
64
],
[
66
],
[
68
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
24,378 | static int decode_packet(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kResLevel *rlevel, int precno,
int layno, uint8_t *expn, int numgbits)
{
int bandno, cblkny, cblknx, cblkno, ret;
if (!(ret = get_bits(s, 1))){
j2k_flush(s);
return 0;
} else if (ret < 0)
return ret;
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
J2kPrec *prec = band->prec + precno;
int pos = 0;
if (band->coord[0][0] == band->coord[0][1]
|| band->coord[1][0] == band->coord[1][1])
continue;
for (cblkny = prec->yi0; cblkny < prec->yi1; cblkny++)
for(cblknx = prec->xi0, cblkno = cblkny * band->cblknx + cblknx; cblknx < prec->xi1; cblknx++, cblkno++, pos++){
J2kCblk *cblk = band->cblk + cblkno;
int incl, newpasses, llen;
if (cblk->npasses)
incl = get_bits(s, 1);
else
incl = tag_tree_decode(s, prec->cblkincl + pos, layno+1) == layno;
if (!incl)
continue;
else if (incl < 0)
return incl;
if (!cblk->npasses)
cblk->nonzerobits = expn[bandno] + numgbits - 1 - tag_tree_decode(s, prec->zerobits + pos, 100);
if ((newpasses = getnpasses(s)) < 0)
return newpasses;
if ((llen = getlblockinc(s)) < 0)
return llen;
cblk->lblock += llen;
if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0)
return ret;
cblk->lengthinc = ret;
cblk->npasses += newpasses;
}
}
j2k_flush(s);
if (codsty->csty & J2K_CSTY_EPH) {
if (AV_RB16(s->buf) == J2K_EPH) {
s->buf += 2;
} else {
av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found.\n");
}
}
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
int yi, cblknw = band->prec[precno].xi1 - band->prec[precno].xi0;
for (yi = band->prec[precno].yi0; yi < band->prec[precno].yi1; yi++){
int xi;
for (xi = band->prec[precno].xi0; xi < band->prec[precno].xi1; xi++){
J2kCblk *cblk = band->cblk + yi * cblknw + xi;
if (s->buf_end - s->buf < cblk->lengthinc)
return AVERROR(EINVAL);
bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);
cblk->length += cblk->lengthinc;
cblk->lengthinc = 0;
}
}
}
return 0;
}
| true | FFmpeg | ddfa3751c092feaf1e080f66587024689dfe603c | static int decode_packet(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kResLevel *rlevel, int precno,
int layno, uint8_t *expn, int numgbits)
{
int bandno, cblkny, cblknx, cblkno, ret;
if (!(ret = get_bits(s, 1))){
j2k_flush(s);
return 0;
} else if (ret < 0)
return ret;
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
J2kPrec *prec = band->prec + precno;
int pos = 0;
if (band->coord[0][0] == band->coord[0][1]
|| band->coord[1][0] == band->coord[1][1])
continue;
for (cblkny = prec->yi0; cblkny < prec->yi1; cblkny++)
for(cblknx = prec->xi0, cblkno = cblkny * band->cblknx + cblknx; cblknx < prec->xi1; cblknx++, cblkno++, pos++){
J2kCblk *cblk = band->cblk + cblkno;
int incl, newpasses, llen;
if (cblk->npasses)
incl = get_bits(s, 1);
else
incl = tag_tree_decode(s, prec->cblkincl + pos, layno+1) == layno;
if (!incl)
continue;
else if (incl < 0)
return incl;
if (!cblk->npasses)
cblk->nonzerobits = expn[bandno] + numgbits - 1 - tag_tree_decode(s, prec->zerobits + pos, 100);
if ((newpasses = getnpasses(s)) < 0)
return newpasses;
if ((llen = getlblockinc(s)) < 0)
return llen;
cblk->lblock += llen;
if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0)
return ret;
cblk->lengthinc = ret;
cblk->npasses += newpasses;
}
}
j2k_flush(s);
if (codsty->csty & J2K_CSTY_EPH) {
if (AV_RB16(s->buf) == J2K_EPH) {
s->buf += 2;
} else {
av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found.\n");
}
}
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
int yi, cblknw = band->prec[precno].xi1 - band->prec[precno].xi0;
for (yi = band->prec[precno].yi0; yi < band->prec[precno].yi1; yi++){
int xi;
for (xi = band->prec[precno].xi0; xi < band->prec[precno].xi1; xi++){
J2kCblk *cblk = band->cblk + yi * cblknw + xi;
if (s->buf_end - s->buf < cblk->lengthinc)
return AVERROR(EINVAL);
bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);
cblk->length += cblk->lengthinc;
cblk->lengthinc = 0;
}
}
}
return 0;
}
| {
"code": [
" if (AV_RB16(s->buf) == J2K_EPH) {",
" s->buf += 2;",
" if (s->buf_end - s->buf < cblk->lengthinc)",
" bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);"
],
"line_no": [
101,
103,
129,
133
]
} | static int FUNC_0(J2kDecoderContext *VAR_0, J2kCodingStyle *VAR_1, J2kResLevel *VAR_2, int VAR_3,
int VAR_4, uint8_t *VAR_5, int VAR_6)
{
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
if (!(VAR_11 = get_bits(VAR_0, 1))){
j2k_flush(VAR_0);
return 0;
} else if (VAR_11 < 0)
return VAR_11;
for (VAR_7 = 0; VAR_7 < VAR_2->nbands; VAR_7++){
J2kBand *band = VAR_2->band + VAR_7;
J2kPrec *prec = band->prec + VAR_3;
int pos = 0;
if (band->coord[0][0] == band->coord[0][1]
|| band->coord[1][0] == band->coord[1][1])
continue;
for (VAR_8 = prec->yi0; VAR_8 < prec->yi1; VAR_8++)
for(VAR_9 = prec->xi0, VAR_10 = VAR_8 * band->VAR_9 + VAR_9; VAR_9 < prec->xi1; VAR_9++, VAR_10++, pos++){
J2kCblk *cblk = band->cblk + VAR_10;
int incl, newpasses, llen;
if (cblk->npasses)
incl = get_bits(VAR_0, 1);
else
incl = tag_tree_decode(VAR_0, prec->cblkincl + pos, VAR_4+1) == VAR_4;
if (!incl)
continue;
else if (incl < 0)
return incl;
if (!cblk->npasses)
cblk->nonzerobits = VAR_5[VAR_7] + VAR_6 - 1 - tag_tree_decode(VAR_0, prec->zerobits + pos, 100);
if ((newpasses = getnpasses(VAR_0)) < 0)
return newpasses;
if ((llen = getlblockinc(VAR_0)) < 0)
return llen;
cblk->lblock += llen;
if ((VAR_11 = get_bits(VAR_0, av_log2(newpasses) + cblk->lblock)) < 0)
return VAR_11;
cblk->lengthinc = VAR_11;
cblk->npasses += newpasses;
}
}
j2k_flush(VAR_0);
if (VAR_1->csty & J2K_CSTY_EPH) {
if (AV_RB16(VAR_0->buf) == J2K_EPH) {
VAR_0->buf += 2;
} else {
av_log(VAR_0->avctx, AV_LOG_ERROR, "EPH marker not found.\n");
}
}
for (VAR_7 = 0; VAR_7 < VAR_2->nbands; VAR_7++){
J2kBand *band = VAR_2->band + VAR_7;
int yi, cblknw = band->prec[VAR_3].xi1 - band->prec[VAR_3].xi0;
for (yi = band->prec[VAR_3].yi0; yi < band->prec[VAR_3].yi1; yi++){
int xi;
for (xi = band->prec[VAR_3].xi0; xi < band->prec[VAR_3].xi1; xi++){
J2kCblk *cblk = band->cblk + yi * cblknw + xi;
if (VAR_0->buf_end - VAR_0->buf < cblk->lengthinc)
return AVERROR(EINVAL);
bytestream_get_buffer(&VAR_0->buf, cblk->data, cblk->lengthinc);
cblk->length += cblk->lengthinc;
cblk->lengthinc = 0;
}
}
}
return 0;
}
| [
"static int FUNC_0(J2kDecoderContext *VAR_0, J2kCodingStyle *VAR_1, J2kResLevel *VAR_2, int VAR_3,\nint VAR_4, uint8_t *VAR_5, int VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"if (!(VAR_11 = get_bits(VAR_0, 1))){",
"j2k_flush(VAR_0);",
"return 0;",
"} else if (VAR_11 < 0)",
"return VAR_11;",
"for (VAR_7 = 0; VAR_7 < VAR_2->nbands; VAR_7++){",
"J2kBand *band = VAR_2->band + VAR_7;",
"J2kPrec *prec = band->prec + VAR_3;",
"int pos = 0;",
"if (band->coord[0][0] == band->coord[0][1]\n|| band->coord[1][0] == band->coord[1][1])\ncontinue;",
"for (VAR_8 = prec->yi0; VAR_8 < prec->yi1; VAR_8++)",
"for(VAR_9 = prec->xi0, VAR_10 = VAR_8 * band->VAR_9 + VAR_9; VAR_9 < prec->xi1; VAR_9++, VAR_10++, pos++){",
"J2kCblk *cblk = band->cblk + VAR_10;",
"int incl, newpasses, llen;",
"if (cblk->npasses)\nincl = get_bits(VAR_0, 1);",
"else\nincl = tag_tree_decode(VAR_0, prec->cblkincl + pos, VAR_4+1) == VAR_4;",
"if (!incl)\ncontinue;",
"else if (incl < 0)\nreturn incl;",
"if (!cblk->npasses)\ncblk->nonzerobits = VAR_5[VAR_7] + VAR_6 - 1 - tag_tree_decode(VAR_0, prec->zerobits + pos, 100);",
"if ((newpasses = getnpasses(VAR_0)) < 0)\nreturn newpasses;",
"if ((llen = getlblockinc(VAR_0)) < 0)\nreturn llen;",
"cblk->lblock += llen;",
"if ((VAR_11 = get_bits(VAR_0, av_log2(newpasses) + cblk->lblock)) < 0)\nreturn VAR_11;",
"cblk->lengthinc = VAR_11;",
"cblk->npasses += newpasses;",
"}",
"}",
"j2k_flush(VAR_0);",
"if (VAR_1->csty & J2K_CSTY_EPH) {",
"if (AV_RB16(VAR_0->buf) == J2K_EPH) {",
"VAR_0->buf += 2;",
"} else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"EPH marker not found.\\n\");",
"}",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_2->nbands; VAR_7++){",
"J2kBand *band = VAR_2->band + VAR_7;",
"int yi, cblknw = band->prec[VAR_3].xi1 - band->prec[VAR_3].xi0;",
"for (yi = band->prec[VAR_3].yi0; yi < band->prec[VAR_3].yi1; yi++){",
"int xi;",
"for (xi = band->prec[VAR_3].xi0; xi < band->prec[VAR_3].xi1; xi++){",
"J2kCblk *cblk = band->cblk + yi * cblknw + xi;",
"if (VAR_0->buf_end - VAR_0->buf < cblk->lengthinc)\nreturn AVERROR(EINVAL);",
"bytestream_get_buffer(&VAR_0->buf, cblk->data, cblk->lengthinc);",
"cblk->length += cblk->lengthinc;",
"cblk->lengthinc = 0;",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
]
] |
24,380 | static SoftFloat sbr_sum_square_c(int (*x)[2], int n)
{
SoftFloat ret;
uint64_t accu = 0, round;
int i, nz;
unsigned u;
for (i = 0; i < n; i += 2) {
// Larger values are inavlid and could cause overflows of accu.
av_assert2(FFABS(x[i + 0][0]) >> 29 == 0);
accu += (int64_t)x[i + 0][0] * x[i + 0][0];
av_assert2(FFABS(x[i + 0][1]) >> 29 == 0);
accu += (int64_t)x[i + 0][1] * x[i + 0][1];
av_assert2(FFABS(x[i + 1][0]) >> 29 == 0);
accu += (int64_t)x[i + 1][0] * x[i + 1][0];
av_assert2(FFABS(x[i + 1][1]) >> 29 == 0);
accu += (int64_t)x[i + 1][1] * x[i + 1][1];
}
u = accu >> 32;
if (u == 0) {
nz = 1;
} else {
nz = -1;
while (u < 0x80000000U) {
u <<= 1;
nz++;
}
nz = 32 - nz;
}
round = 1ULL << (nz-1);
u = ((accu + round) >> nz);
u >>= 1;
ret = av_int2sf(u, 15 - nz);
return ret;
}
| true | FFmpeg | b315a3cf42a15358ab38279723f3c93406a66f6a | static SoftFloat sbr_sum_square_c(int (*x)[2], int n)
{
SoftFloat ret;
uint64_t accu = 0, round;
int i, nz;
unsigned u;
for (i = 0; i < n; i += 2) {
av_assert2(FFABS(x[i + 0][0]) >> 29 == 0);
accu += (int64_t)x[i + 0][0] * x[i + 0][0];
av_assert2(FFABS(x[i + 0][1]) >> 29 == 0);
accu += (int64_t)x[i + 0][1] * x[i + 0][1];
av_assert2(FFABS(x[i + 1][0]) >> 29 == 0);
accu += (int64_t)x[i + 1][0] * x[i + 1][0];
av_assert2(FFABS(x[i + 1][1]) >> 29 == 0);
accu += (int64_t)x[i + 1][1] * x[i + 1][1];
}
u = accu >> 32;
if (u == 0) {
nz = 1;
} else {
nz = -1;
while (u < 0x80000000U) {
u <<= 1;
nz++;
}
nz = 32 - nz;
}
round = 1ULL << (nz-1);
u = ((accu + round) >> nz);
u >>= 1;
ret = av_int2sf(u, 15 - nz);
return ret;
}
| {
"code": [
" uint64_t accu = 0, round;",
" int i, nz;",
" av_assert2(FFABS(x[i + 0][0]) >> 29 == 0);",
" accu += (int64_t)x[i + 0][0] * x[i + 0][0];",
" av_assert2(FFABS(x[i + 0][1]) >> 29 == 0);",
" accu += (int64_t)x[i + 0][1] * x[i + 0][1];",
" av_assert2(FFABS(x[i + 1][0]) >> 29 == 0);",
" accu += (int64_t)x[i + 1][0] * x[i + 1][0];",
" av_assert2(FFABS(x[i + 1][1]) >> 29 == 0);",
" accu += (int64_t)x[i + 1][1] * x[i + 1][1];",
" if (u == 0) {",
" nz = 1;",
" } else {",
" nz = -1;",
" nz++;",
" nz = 32 - nz;",
" ret = av_int2sf(u, 15 - nz);"
],
"line_no": [
7,
9,
19,
21,
23,
25,
27,
29,
31,
33,
41,
43,
45,
47,
53,
57,
69
]
} | static SoftFloat FUNC_0(int (*x)[2], int n)
{
SoftFloat ret;
uint64_t accu = 0, round;
int VAR_0, VAR_1;
unsigned VAR_2;
for (VAR_0 = 0; VAR_0 < n; VAR_0 += 2) {
av_assert2(FFABS(x[VAR_0 + 0][0]) >> 29 == 0);
accu += (int64_t)x[VAR_0 + 0][0] * x[VAR_0 + 0][0];
av_assert2(FFABS(x[VAR_0 + 0][1]) >> 29 == 0);
accu += (int64_t)x[VAR_0 + 0][1] * x[VAR_0 + 0][1];
av_assert2(FFABS(x[VAR_0 + 1][0]) >> 29 == 0);
accu += (int64_t)x[VAR_0 + 1][0] * x[VAR_0 + 1][0];
av_assert2(FFABS(x[VAR_0 + 1][1]) >> 29 == 0);
accu += (int64_t)x[VAR_0 + 1][1] * x[VAR_0 + 1][1];
}
VAR_2 = accu >> 32;
if (VAR_2 == 0) {
VAR_1 = 1;
} else {
VAR_1 = -1;
while (VAR_2 < 0x80000000U) {
VAR_2 <<= 1;
VAR_1++;
}
VAR_1 = 32 - VAR_1;
}
round = 1ULL << (VAR_1-1);
VAR_2 = ((accu + round) >> VAR_1);
VAR_2 >>= 1;
ret = av_int2sf(VAR_2, 15 - VAR_1);
return ret;
}
| [
"static SoftFloat FUNC_0(int (*x)[2], int n)\n{",
"SoftFloat ret;",
"uint64_t accu = 0, round;",
"int VAR_0, VAR_1;",
"unsigned VAR_2;",
"for (VAR_0 = 0; VAR_0 < n; VAR_0 += 2) {",
"av_assert2(FFABS(x[VAR_0 + 0][0]) >> 29 == 0);",
"accu += (int64_t)x[VAR_0 + 0][0] * x[VAR_0 + 0][0];",
"av_assert2(FFABS(x[VAR_0 + 0][1]) >> 29 == 0);",
"accu += (int64_t)x[VAR_0 + 0][1] * x[VAR_0 + 0][1];",
"av_assert2(FFABS(x[VAR_0 + 1][0]) >> 29 == 0);",
"accu += (int64_t)x[VAR_0 + 1][0] * x[VAR_0 + 1][0];",
"av_assert2(FFABS(x[VAR_0 + 1][1]) >> 29 == 0);",
"accu += (int64_t)x[VAR_0 + 1][1] * x[VAR_0 + 1][1];",
"}",
"VAR_2 = accu >> 32;",
"if (VAR_2 == 0) {",
"VAR_1 = 1;",
"} else {",
"VAR_1 = -1;",
"while (VAR_2 < 0x80000000U) {",
"VAR_2 <<= 1;",
"VAR_1++;",
"}",
"VAR_1 = 32 - VAR_1;",
"}",
"round = 1ULL << (VAR_1-1);",
"VAR_2 = ((accu + round) >> VAR_1);",
"VAR_2 >>= 1;",
"ret = av_int2sf(VAR_2, 15 - VAR_1);",
"return ret;",
"}"
] | [
0,
0,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
24,381 | int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)
{
return kvm_dirty_pages_log_change(phys_addr, end_addr,
0,
KVM_MEM_LOG_DIRTY_PAGES);
}
| true | qemu | d3f8d37fe2d0c24ec8bac9c94d5b0e2dc09c0d2a | int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)
{
return kvm_dirty_pages_log_change(phys_addr, end_addr,
0,
KVM_MEM_LOG_DIRTY_PAGES);
}
| {
"code": [
" return kvm_dirty_pages_log_change(phys_addr, end_addr,",
"int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)",
" return kvm_dirty_pages_log_change(phys_addr, end_addr,"
],
"line_no": [
5,
1,
5
]
} | int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1)
{
return kvm_dirty_pages_log_change(VAR_0, VAR_1,
0,
KVM_MEM_LOG_DIRTY_PAGES);
}
| [
"int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1)\n{",
"return kvm_dirty_pages_log_change(VAR_0, VAR_1,\n0,\nKVM_MEM_LOG_DIRTY_PAGES);",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
24,382 | int qemu_strtoll(const char *nptr, const char **endptr, int base,
int64_t *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoll(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| true | qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | int qemu_strtoll(const char *nptr, const char **endptr, int base,
int64_t *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoll(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| {
"code": [
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);"
],
"line_no": [
27,
27,
27,
27
]
} | int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,
int64_t *VAR_3)
{
char *VAR_4;
int VAR_5 = 0;
if (!VAR_0) {
if (VAR_1) {
*VAR_1 = VAR_0;
}
VAR_5 = -EINVAL;
} else {
errno = 0;
*VAR_3 = strtoll(VAR_0, &VAR_4, VAR_2);
VAR_5 = check_strtox_error(VAR_1, VAR_4, errno);
}
return VAR_5;
}
| [
"int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,\nint64_t *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5 = 0;",
"if (!VAR_0) {",
"if (VAR_1) {",
"*VAR_1 = VAR_0;",
"}",
"VAR_5 = -EINVAL;",
"} else {",
"errno = 0;",
"*VAR_3 = strtoll(VAR_0, &VAR_4, VAR_2);",
"VAR_5 = check_strtox_error(VAR_1, VAR_4, errno);",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
24,383 | static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
SOFAlizerContext *s = ctx->priv;
ThreadData *td = arg;
AVFrame *in = td->in, *out = td->out;
int offset = jobnr;
int *write = &td->write[jobnr];
const int *const delay = td->delay[jobnr];
const float *const ir = td->ir[jobnr];
int *n_clippings = &td->n_clippings[jobnr];
float *ringbuffer = td->ringbuffer[jobnr];
float *temp_src = td->temp_src[jobnr];
const int n_samples = s->sofa.n_samples; /* length of one IR */
const float *src = (const float *)in->data[0]; /* get pointer to audio input buffer */
float *dst = (float *)out->data[0]; /* get pointer to audio output buffer */
const int in_channels = s->n_conv; /* number of input channels */
/* ring buffer length is: longest IR plus max. delay -> next power of 2 */
const int buffer_length = s->buffer_length;
/* -1 for AND instead of MODULO (applied to powers of 2): */
const uint32_t modulo = (uint32_t)buffer_length - 1;
float *buffer[16]; /* holds ringbuffer for each input channel */
int wr = *write;
int read;
int i, l;
dst += offset;
for (l = 0; l < in_channels; l++) {
/* get starting address of ringbuffer for each input channel */
buffer[l] = ringbuffer + l * buffer_length;
}
for (i = 0; i < in->nb_samples; i++) {
const float *temp_ir = ir; /* using same set of IRs for each sample */
*dst = 0;
for (l = 0; l < in_channels; l++) {
/* write current input sample to ringbuffer (for each channel) */
*(buffer[l] + wr) = src[l];
}
/* loop goes through all channels to be convolved */
for (l = 0; l < in_channels; l++) {
const float *const bptr = buffer[l];
if (l == s->lfe_channel) {
/* LFE is an input channel but requires no convolution */
/* apply gain to LFE signal and add to output buffer */
*dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe;
temp_ir += n_samples;
continue;
}
/* current read position in ringbuffer: input sample write position
* - delay for l-th ch. + diff. betw. IR length and buffer length
* (mod buffer length) */
read = (wr - *(delay + l) - (n_samples - 1) + buffer_length) & modulo;
if (read + n_samples < buffer_length) {
memcpy(temp_src, bptr + read, n_samples * sizeof(*temp_src));
} else {
int len = FFMIN(n_samples - (read % n_samples), buffer_length - read);
memcpy(temp_src, bptr + read, len * sizeof(*temp_src));
memcpy(temp_src + len, bptr, (n_samples - len) * sizeof(*temp_src));
}
/* multiply signal and IR, and add up the results */
dst[0] += s->fdsp->scalarproduct_float(temp_ir, temp_src, n_samples);
temp_ir += n_samples;
}
/* clippings counter */
if (fabs(*dst) > 1)
*n_clippings += 1;
/* move output buffer pointer by +2 to get to next sample of processed channel: */
dst += 2;
src += in_channels;
wr = (wr + 1) & modulo; /* update ringbuffer write position */
}
*write = wr; /* remember write position in ringbuffer for next call */
return 0;
}
| true | FFmpeg | 21234c835d2d003d390d462b6e1b2622e7b02c39 | static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
SOFAlizerContext *s = ctx->priv;
ThreadData *td = arg;
AVFrame *in = td->in, *out = td->out;
int offset = jobnr;
int *write = &td->write[jobnr];
const int *const delay = td->delay[jobnr];
const float *const ir = td->ir[jobnr];
int *n_clippings = &td->n_clippings[jobnr];
float *ringbuffer = td->ringbuffer[jobnr];
float *temp_src = td->temp_src[jobnr];
const int n_samples = s->sofa.n_samples;
const float *src = (const float *)in->data[0];
float *dst = (float *)out->data[0];
const int in_channels = s->n_conv;
const int buffer_length = s->buffer_length;
const uint32_t modulo = (uint32_t)buffer_length - 1;
float *buffer[16];
int wr = *write;
int read;
int i, l;
dst += offset;
for (l = 0; l < in_channels; l++) {
buffer[l] = ringbuffer + l * buffer_length;
}
for (i = 0; i < in->nb_samples; i++) {
const float *temp_ir = ir;
*dst = 0;
for (l = 0; l < in_channels; l++) {
*(buffer[l] + wr) = src[l];
}
for (l = 0; l < in_channels; l++) {
const float *const bptr = buffer[l];
if (l == s->lfe_channel) {
*dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe;
temp_ir += n_samples;
continue;
}
read = (wr - *(delay + l) - (n_samples - 1) + buffer_length) & modulo;
if (read + n_samples < buffer_length) {
memcpy(temp_src, bptr + read, n_samples * sizeof(*temp_src));
} else {
int len = FFMIN(n_samples - (read % n_samples), buffer_length - read);
memcpy(temp_src, bptr + read, len * sizeof(*temp_src));
memcpy(temp_src + len, bptr, (n_samples - len) * sizeof(*temp_src));
}
dst[0] += s->fdsp->scalarproduct_float(temp_ir, temp_src, n_samples);
temp_ir += n_samples;
}
if (fabs(*dst) > 1)
*n_clippings += 1;
dst += 2;
src += in_channels;
wr = (wr + 1) & modulo;
}
*write = wr;
return 0;
}
| {
"code": [
" temp_ir += n_samples;",
" temp_ir += n_samples;"
],
"line_no": [
97,
137
]
} | static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)
{
SOFAlizerContext *s = VAR_0->priv;
ThreadData *td = VAR_1;
AVFrame *in = td->in, *out = td->out;
int VAR_4 = VAR_2;
int *VAR_5 = &td->VAR_5[VAR_2];
const int *const VAR_6 = td->VAR_6[VAR_2];
const float *const VAR_7 = td->VAR_7[VAR_2];
int *VAR_8 = &td->VAR_8[VAR_2];
float *VAR_9 = td->VAR_9[VAR_2];
float *VAR_10 = td->VAR_10[VAR_2];
const int VAR_11 = s->sofa.VAR_11;
const float *VAR_12 = (const float *)in->data[0];
float *VAR_13 = (float *)out->data[0];
const int VAR_14 = s->n_conv;
const int VAR_15 = s->VAR_15;
const uint32_t VAR_16 = (uint32_t)VAR_15 - 1;
float *VAR_17[16];
int VAR_18 = *VAR_5;
int VAR_19;
int VAR_20, VAR_21;
VAR_13 += VAR_4;
for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {
VAR_17[VAR_21] = VAR_9 + VAR_21 * VAR_15;
}
for (VAR_20 = 0; VAR_20 < in->nb_samples; VAR_20++) {
const float *temp_ir = VAR_7;
*VAR_13 = 0;
for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {
*(VAR_17[VAR_21] + VAR_18) = VAR_12[VAR_21];
}
for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {
const float *const bptr = VAR_17[VAR_21];
if (VAR_21 == s->lfe_channel) {
*VAR_13 += *(VAR_17[s->lfe_channel] + VAR_18) * s->gain_lfe;
temp_ir += VAR_11;
continue;
}
VAR_19 = (VAR_18 - *(VAR_6 + VAR_21) - (VAR_11 - 1) + VAR_15) & VAR_16;
if (VAR_19 + VAR_11 < VAR_15) {
memcpy(VAR_10, bptr + VAR_19, VAR_11 * sizeof(*VAR_10));
} else {
int len = FFMIN(VAR_11 - (VAR_19 % VAR_11), VAR_15 - VAR_19);
memcpy(VAR_10, bptr + VAR_19, len * sizeof(*VAR_10));
memcpy(VAR_10 + len, bptr, (VAR_11 - len) * sizeof(*VAR_10));
}
VAR_13[0] += s->fdsp->scalarproduct_float(temp_ir, VAR_10, VAR_11);
temp_ir += VAR_11;
}
if (fabs(*VAR_13) > 1)
*VAR_8 += 1;
VAR_13 += 2;
VAR_12 += VAR_14;
VAR_18 = (VAR_18 + 1) & VAR_16;
}
*VAR_5 = VAR_18;
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)\n{",
"SOFAlizerContext *s = VAR_0->priv;",
"ThreadData *td = VAR_1;",
"AVFrame *in = td->in, *out = td->out;",
"int VAR_4 = VAR_2;",
"int *VAR_5 = &td->VAR_5[VAR_2];",
"const int *const VAR_6 = td->VAR_6[VAR_2];",
"const float *const VAR_7 = td->VAR_7[VAR_2];",
"int *VAR_8 = &td->VAR_8[VAR_2];",
"float *VAR_9 = td->VAR_9[VAR_2];",
"float *VAR_10 = td->VAR_10[VAR_2];",
"const int VAR_11 = s->sofa.VAR_11;",
"const float *VAR_12 = (const float *)in->data[0];",
"float *VAR_13 = (float *)out->data[0];",
"const int VAR_14 = s->n_conv;",
"const int VAR_15 = s->VAR_15;",
"const uint32_t VAR_16 = (uint32_t)VAR_15 - 1;",
"float *VAR_17[16];",
"int VAR_18 = *VAR_5;",
"int VAR_19;",
"int VAR_20, VAR_21;",
"VAR_13 += VAR_4;",
"for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {",
"VAR_17[VAR_21] = VAR_9 + VAR_21 * VAR_15;",
"}",
"for (VAR_20 = 0; VAR_20 < in->nb_samples; VAR_20++) {",
"const float *temp_ir = VAR_7;",
"*VAR_13 = 0;",
"for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {",
"*(VAR_17[VAR_21] + VAR_18) = VAR_12[VAR_21];",
"}",
"for (VAR_21 = 0; VAR_21 < VAR_14; VAR_21++) {",
"const float *const bptr = VAR_17[VAR_21];",
"if (VAR_21 == s->lfe_channel) {",
"*VAR_13 += *(VAR_17[s->lfe_channel] + VAR_18) * s->gain_lfe;",
"temp_ir += VAR_11;",
"continue;",
"}",
"VAR_19 = (VAR_18 - *(VAR_6 + VAR_21) - (VAR_11 - 1) + VAR_15) & VAR_16;",
"if (VAR_19 + VAR_11 < VAR_15) {",
"memcpy(VAR_10, bptr + VAR_19, VAR_11 * sizeof(*VAR_10));",
"} else {",
"int len = FFMIN(VAR_11 - (VAR_19 % VAR_11), VAR_15 - VAR_19);",
"memcpy(VAR_10, bptr + VAR_19, len * sizeof(*VAR_10));",
"memcpy(VAR_10 + len, bptr, (VAR_11 - len) * sizeof(*VAR_10));",
"}",
"VAR_13[0] += s->fdsp->scalarproduct_float(temp_ir, VAR_10, VAR_11);",
"temp_ir += VAR_11;",
"}",
"if (fabs(*VAR_13) > 1)\n*VAR_8 += 1;",
"VAR_13 += 2;",
"VAR_12 += VAR_14;",
"VAR_18 = (VAR_18 + 1) & VAR_16;",
"}",
"*VAR_5 = VAR_18;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
83
],
[
85
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
145,
147
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
167
],
[
169
]
] |
24,385 | int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
{
char *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
int closing_brace_missing = 0;
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
for (; !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
rstrip_spaces_buf(dst);
av_bprintf(dst, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
av_bprint_chars(dst, *in, 1);
break;
case '{':
handle_open_brace(dst, &in, &an, &closing_brace_missing);
break;
case '<':
tag_close = in[1] == '/';
len = 0;
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!av_strcasecmp(tagname, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
av_bprintf(dst, "%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!av_strncasecmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!av_strncasecmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(log_ctx, param));
} else if (!av_strncasecmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
av_bprintf(dst, "%s", stack[sptr].param[i]);
}
} else if (tagname[0] && !tagname[1] && av_stristr("bisu", tagname)) {
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
} else if (!av_strcasecmp(tagname, "br")) {
av_bprintf(dst, "\\N");
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", tagname);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
av_bprint_chars(dst, *in, 1);
} else
av_strlcpy(stack[sptr++].tag, tagname,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(dst, *in, 1);
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
if (!av_bprint_is_complete(dst))
return AVERROR(ENOMEM);
while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
dst->len -= 2;
dst->str[dst->len] = 0;
rstrip_spaces_buf(dst);
return 0;
}
| true | FFmpeg | c61715e2c505c15a5cfc9eab18b4311a6504055a | int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
{
char *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
int closing_brace_missing = 0;
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
for (; !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
rstrip_spaces_buf(dst);
av_bprintf(dst, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
av_bprint_chars(dst, *in, 1);
break;
case '{':
handle_open_brace(dst, &in, &an, &closing_brace_missing);
break;
case '<':
tag_close = in[1] == '/';
len = 0;
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!av_strcasecmp(tagname, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
av_bprintf(dst, "%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!av_strncasecmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!av_strncasecmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(log_ctx, param));
} else if (!av_strncasecmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
av_bprintf(dst, "%s", stack[sptr].param[i]);
}
} else if (tagname[0] && !tagname[1] && av_stristr("bisu", tagname)) {
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
} else if (!av_strcasecmp(tagname, "br")) {
av_bprintf(dst, "\\N");
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", tagname);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
av_bprint_chars(dst, *in, 1);
} else
av_strlcpy(stack[sptr++].tag, tagname,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(dst, *in, 1);
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
if (!av_bprint_is_complete(dst))
return AVERROR(ENOMEM);
while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
dst->len -= 2;
dst->str[dst->len] = 0;
rstrip_spaces_buf(dst);
return 0;
}
| {
"code": [
" if (sscanf(in+tag_close+1, \"%127[^>]>%n\", buffer, &len) >= 1 && len > 0) {",
" if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||"
],
"line_no": [
71,
83
]
} | int FUNC_0(void *VAR_0, AVBPrint *VAR_1, const char *VAR_2)
{
char *VAR_3, VAR_4[128], VAR_5[128];
int VAR_6, VAR_7, VAR_8 = 1, VAR_9 = 1, VAR_10 = 0, VAR_11 = 0;
SrtStack stack[16];
int VAR_12 = 0;
stack[0].tag[0] = 0;
strcpy(stack[0].VAR_3[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].VAR_3[PARAM_COLOR], "{\\c}");
strcpy(stack[0].VAR_3[PARAM_FACE], "{\\fn}");
for (; !VAR_11 && *VAR_2; VAR_2++) {
switch (*VAR_2) {
case '\r':
break;
case '\n':
if (VAR_9) {
VAR_11 = 1;
break;
}
rstrip_spaces_buf(VAR_1);
av_bprintf(VAR_1, "\\N");
VAR_9 = 1;
break;
case ' ':
if (!VAR_9)
av_bprint_chars(VAR_1, *VAR_2, 1);
break;
case '{':
handle_open_brace(VAR_1, &VAR_2, &VAR_10, &VAR_12);
break;
case '<':
VAR_7 = VAR_2[1] == '/';
VAR_6 = 0;
if (sscanf(VAR_2+VAR_7+1, "%127[^>]>%n", VAR_4, &VAR_6) >= 1 && VAR_6 > 0) {
const char *VAR_13 = VAR_4;
while (*VAR_13 == ' ')
VAR_13++;
if ((VAR_3 = strchr(VAR_13, ' ')))
*VAR_3++ = 0;
if ((!VAR_7 && VAR_8 < FF_ARRAY_ELEMS(stack)) ||
( VAR_7 && VAR_8 > 0 && !av_strcasecmp(stack[VAR_8-1].tag, VAR_13))) {
int VAR_14, VAR_15, VAR_16 = 0;
VAR_2 += VAR_6 + VAR_7;
if (!VAR_7)
memset(stack+VAR_8, 0, sizeof(*stack));
if (!av_strcasecmp(VAR_13, "font")) {
if (VAR_7) {
for (VAR_14=PARAM_NUMBER-1; VAR_14>=0; VAR_14--)
if (stack[VAR_8-1].VAR_3[VAR_14][0])
for (VAR_15=VAR_8-2; VAR_15>=0; VAR_15--)
if (stack[VAR_15].VAR_3[VAR_14][0]) {
av_bprintf(VAR_1, "%s", stack[VAR_15].VAR_3[VAR_14]);
break;
}
} else {
while (VAR_3) {
if (!av_strncasecmp(VAR_3, "size=", 5)) {
unsigned VAR_17;
VAR_3 += 5 + (VAR_3[5] == '"');
if (sscanf(VAR_3, "%u", &VAR_17) == 1) {
snprintf(stack[VAR_8].VAR_3[PARAM_SIZE],
sizeof(stack[0].VAR_3[PARAM_SIZE]),
"{\\fs%u}", VAR_17);
}
} else if (!av_strncasecmp(VAR_3, "color=", 6)) {
VAR_3 += 6 + (VAR_3[6] == '"');
snprintf(stack[VAR_8].VAR_3[PARAM_COLOR],
sizeof(stack[0].VAR_3[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(VAR_0, VAR_3));
} else if (!av_strncasecmp(VAR_3, "face=", 5)) {
VAR_3 += 5 + (VAR_3[5] == '"');
VAR_6 = strcspn(VAR_3,
VAR_3[-1] == '"' ? "\"" :" ");
av_strlcpy(VAR_5, VAR_3,
FFMIN(sizeof(VAR_5), VAR_6+1));
VAR_3 += VAR_6;
snprintf(stack[VAR_8].VAR_3[PARAM_FACE],
sizeof(stack[0].VAR_3[PARAM_FACE]),
"{\\fn%s}", VAR_5);
}
if ((VAR_3 = strchr(VAR_3, ' ')))
VAR_3++;
}
for (VAR_14=0; VAR_14<PARAM_NUMBER; VAR_14++)
if (stack[VAR_8].VAR_3[VAR_14][0])
av_bprintf(VAR_1, "%s", stack[VAR_8].VAR_3[VAR_14]);
}
} else if (VAR_13[0] && !VAR_13[1] && av_stristr("bisu", VAR_13)) {
av_bprintf(VAR_1, "{\\%c%d}", (char)av_tolower(VAR_13[0]), !VAR_7);
} else if (!av_strcasecmp(VAR_13, "br")) {
av_bprintf(VAR_1, "\\N");
} else {
VAR_16 = 1;
snprintf(VAR_5, sizeof(VAR_5), "</%s>", VAR_13);
}
if (VAR_7) {
VAR_8--;
} else if (VAR_16 && !strstr(VAR_2, VAR_5)) {
VAR_2 -= VAR_6 + VAR_7;
av_bprint_chars(VAR_1, *VAR_2, 1);
} else
av_strlcpy(stack[VAR_8++].tag, VAR_13,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(VAR_1, *VAR_2, 1);
break;
}
if (*VAR_2 != ' ' && *VAR_2 != '\r' && *VAR_2 != '\n')
VAR_9 = 0;
}
if (!av_bprint_is_complete(VAR_1))
return AVERROR(ENOMEM);
while (VAR_1->VAR_6 >= 2 && !strncmp(&VAR_1->str[VAR_1->VAR_6 - 2], "\\N", 2))
VAR_1->VAR_6 -= 2;
VAR_1->str[VAR_1->VAR_6] = 0;
rstrip_spaces_buf(VAR_1);
return 0;
}
| [
"int FUNC_0(void *VAR_0, AVBPrint *VAR_1, const char *VAR_2)\n{",
"char *VAR_3, VAR_4[128], VAR_5[128];",
"int VAR_6, VAR_7, VAR_8 = 1, VAR_9 = 1, VAR_10 = 0, VAR_11 = 0;",
"SrtStack stack[16];",
"int VAR_12 = 0;",
"stack[0].tag[0] = 0;",
"strcpy(stack[0].VAR_3[PARAM_SIZE], \"{\\\\fs}\");",
"strcpy(stack[0].VAR_3[PARAM_COLOR], \"{\\\\c}\");",
"strcpy(stack[0].VAR_3[PARAM_FACE], \"{\\\\fn}\");",
"for (; !VAR_11 && *VAR_2; VAR_2++) {",
"switch (*VAR_2) {",
"case '\\r':\nbreak;",
"case '\\n':\nif (VAR_9) {",
"VAR_11 = 1;",
"break;",
"}",
"rstrip_spaces_buf(VAR_1);",
"av_bprintf(VAR_1, \"\\\\N\");",
"VAR_9 = 1;",
"break;",
"case ' ':\nif (!VAR_9)\nav_bprint_chars(VAR_1, *VAR_2, 1);",
"break;",
"case '{':",
"handle_open_brace(VAR_1, &VAR_2, &VAR_10, &VAR_12);",
"break;",
"case '<':\nVAR_7 = VAR_2[1] == '/';",
"VAR_6 = 0;",
"if (sscanf(VAR_2+VAR_7+1, \"%127[^>]>%n\", VAR_4, &VAR_6) >= 1 && VAR_6 > 0) {",
"const char *VAR_13 = VAR_4;",
"while (*VAR_13 == ' ')\nVAR_13++;",
"if ((VAR_3 = strchr(VAR_13, ' ')))\n*VAR_3++ = 0;",
"if ((!VAR_7 && VAR_8 < FF_ARRAY_ELEMS(stack)) ||\n( VAR_7 && VAR_8 > 0 && !av_strcasecmp(stack[VAR_8-1].tag, VAR_13))) {",
"int VAR_14, VAR_15, VAR_16 = 0;",
"VAR_2 += VAR_6 + VAR_7;",
"if (!VAR_7)\nmemset(stack+VAR_8, 0, sizeof(*stack));",
"if (!av_strcasecmp(VAR_13, \"font\")) {",
"if (VAR_7) {",
"for (VAR_14=PARAM_NUMBER-1; VAR_14>=0; VAR_14--)",
"if (stack[VAR_8-1].VAR_3[VAR_14][0])\nfor (VAR_15=VAR_8-2; VAR_15>=0; VAR_15--)",
"if (stack[VAR_15].VAR_3[VAR_14][0]) {",
"av_bprintf(VAR_1, \"%s\", stack[VAR_15].VAR_3[VAR_14]);",
"break;",
"}",
"} else {",
"while (VAR_3) {",
"if (!av_strncasecmp(VAR_3, \"size=\", 5)) {",
"unsigned VAR_17;",
"VAR_3 += 5 + (VAR_3[5] == '\"');",
"if (sscanf(VAR_3, \"%u\", &VAR_17) == 1) {",
"snprintf(stack[VAR_8].VAR_3[PARAM_SIZE],\nsizeof(stack[0].VAR_3[PARAM_SIZE]),\n\"{\\\\fs%u}\", VAR_17);",
"}",
"} else if (!av_strncasecmp(VAR_3, \"color=\", 6)) {",
"VAR_3 += 6 + (VAR_3[6] == '\"');",
"snprintf(stack[VAR_8].VAR_3[PARAM_COLOR],\nsizeof(stack[0].VAR_3[PARAM_COLOR]),\n\"{\\\\c&H%X&}\",",
"html_color_parse(VAR_0, VAR_3));",
"} else if (!av_strncasecmp(VAR_3, \"face=\", 5)) {",
"VAR_3 += 5 + (VAR_3[5] == '\"');",
"VAR_6 = strcspn(VAR_3,\nVAR_3[-1] == '\"' ? \"\\\"\" :\" \");",
"av_strlcpy(VAR_5, VAR_3,\nFFMIN(sizeof(VAR_5), VAR_6+1));",
"VAR_3 += VAR_6;",
"snprintf(stack[VAR_8].VAR_3[PARAM_FACE],\nsizeof(stack[0].VAR_3[PARAM_FACE]),\n\"{\\\\fn%s}\", VAR_5);",
"}",
"if ((VAR_3 = strchr(VAR_3, ' ')))\nVAR_3++;",
"}",
"for (VAR_14=0; VAR_14<PARAM_NUMBER; VAR_14++)",
"if (stack[VAR_8].VAR_3[VAR_14][0])\nav_bprintf(VAR_1, \"%s\", stack[VAR_8].VAR_3[VAR_14]);",
"}",
"} else if (VAR_13[0] && !VAR_13[1] && av_stristr(\"bisu\", VAR_13)) {",
"av_bprintf(VAR_1, \"{\\\\%c%d}\", (char)av_tolower(VAR_13[0]), !VAR_7);",
"} else if (!av_strcasecmp(VAR_13, \"br\")) {",
"av_bprintf(VAR_1, \"\\\\N\");",
"} else {",
"VAR_16 = 1;",
"snprintf(VAR_5, sizeof(VAR_5), \"</%s>\", VAR_13);",
"}",
"if (VAR_7) {",
"VAR_8--;",
"} else if (VAR_16 && !strstr(VAR_2, VAR_5)) {",
"VAR_2 -= VAR_6 + VAR_7;",
"av_bprint_chars(VAR_1, *VAR_2, 1);",
"} else",
"av_strlcpy(stack[VAR_8++].tag, VAR_13,\nsizeof(stack[0].tag));",
"break;",
"}",
"}",
"default:\nav_bprint_chars(VAR_1, *VAR_2, 1);",
"break;",
"}",
"if (*VAR_2 != ' ' && *VAR_2 != '\\r' && *VAR_2 != '\\n')\nVAR_9 = 0;",
"}",
"if (!av_bprint_is_complete(VAR_1))\nreturn AVERROR(ENOMEM);",
"while (VAR_1->VAR_6 >= 2 && !strncmp(&VAR_1->str[VAR_1->VAR_6 - 2], \"\\\\N\", 2))\nVAR_1->VAR_6 -= 2;",
"VAR_1->str[VAR_1->VAR_6] = 0;",
"rstrip_spaces_buf(VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
159,
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227,
229
],
[
231
],
[
235,
237
],
[
241,
243
],
[
245
],
[
247
],
[
251
],
[
253
]
] |
24,386 | void qemu_mutex_destroy(QemuMutex *mutex)
{
assert(mutex->owner == 0);
DeleteCriticalSection(&mutex->lock);
}
| true | qemu | 12f8def0e02232d7c6416ad9b66640f973c531d1 | void qemu_mutex_destroy(QemuMutex *mutex)
{
assert(mutex->owner == 0);
DeleteCriticalSection(&mutex->lock);
}
| {
"code": [
" assert(mutex->owner == 0);",
" DeleteCriticalSection(&mutex->lock);",
" assert(mutex->owner == 0);"
],
"line_no": [
5,
7,
5
]
} | void FUNC_0(QemuMutex *VAR_0)
{
assert(VAR_0->owner == 0);
DeleteCriticalSection(&VAR_0->lock);
}
| [
"void FUNC_0(QemuMutex *VAR_0)\n{",
"assert(VAR_0->owner == 0);",
"DeleteCriticalSection(&VAR_0->lock);",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,387 | static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in)
{
AsyncURB *aurb;
int i, j, ret, max_packet_size, offset, len = 0;
max_packet_size = get_max_packet_size(s, p->devep);
if (max_packet_size == 0)
return USB_RET_NAK;
aurb = get_iso_urb(s, p->devep);
if (!aurb) {
aurb = usb_host_alloc_iso(s, p->devep, in);
}
i = get_iso_urb_idx(s, p->devep);
j = aurb[i].iso_frame_idx;
if (j >= 0 && j < ISO_FRAME_DESC_PER_URB) {
if (in) {
/* Check urb status */
if (aurb[i].urb.status) {
len = urb_status_to_usb_ret(aurb[i].urb.status);
/* Move to the next urb */
aurb[i].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1;
/* Check frame status */
} else if (aurb[i].urb.iso_frame_desc[j].status) {
len = urb_status_to_usb_ret(
aurb[i].urb.iso_frame_desc[j].status);
/* Check the frame fits */
} else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->len) {
printf("husb: received iso data is larger then packet\n");
len = USB_RET_NAK;
/* All good copy data over */
} else {
len = aurb[i].urb.iso_frame_desc[j].actual_length;
memcpy(p->data,
aurb[i].urb.buffer +
j * aurb[i].urb.iso_frame_desc[0].length,
len);
}
} else {
len = p->len;
offset = (j == 0) ? 0 : get_iso_buffer_used(s, p->devep);
/* Check the frame fits */
if (len > max_packet_size) {
printf("husb: send iso data is larger then max packet size\n");
return USB_RET_NAK;
}
/* All good copy data over */
memcpy(aurb[i].urb.buffer + offset, p->data, len);
aurb[i].urb.iso_frame_desc[j].length = len;
offset += len;
set_iso_buffer_used(s, p->devep, offset);
/* Start the stream once we have buffered enough data */
if (!is_iso_started(s, p->devep) && i == 1 && j == 8) {
set_iso_started(s, p->devep);
}
}
aurb[i].iso_frame_idx++;
if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
i = (i + 1) % s->iso_urb_count;
set_iso_urb_idx(s, p->devep, i);
}
} else {
if (in) {
set_iso_started(s, p->devep);
} else {
DPRINTF("hubs: iso out error no free buffer, dropping packet\n");
}
}
if (is_iso_started(s, p->devep)) {
/* (Re)-submit all fully consumed / filled urbs */
for (i = 0; i < s->iso_urb_count; i++) {
if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]);
if (ret < 0) {
printf("husb error submitting iso urb %d: %d\n", i, errno);
if (!in || len == 0) {
switch(errno) {
case ETIMEDOUT:
len = USB_RET_NAK;
break;
case EPIPE:
default:
len = USB_RET_STALL;
}
}
break;
}
aurb[i].iso_frame_idx = -1;
change_iso_inflight(s, p->devep, +1);
}
}
}
return len;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in)
{
AsyncURB *aurb;
int i, j, ret, max_packet_size, offset, len = 0;
max_packet_size = get_max_packet_size(s, p->devep);
if (max_packet_size == 0)
return USB_RET_NAK;
aurb = get_iso_urb(s, p->devep);
if (!aurb) {
aurb = usb_host_alloc_iso(s, p->devep, in);
}
i = get_iso_urb_idx(s, p->devep);
j = aurb[i].iso_frame_idx;
if (j >= 0 && j < ISO_FRAME_DESC_PER_URB) {
if (in) {
if (aurb[i].urb.status) {
len = urb_status_to_usb_ret(aurb[i].urb.status);
aurb[i].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1;
} else if (aurb[i].urb.iso_frame_desc[j].status) {
len = urb_status_to_usb_ret(
aurb[i].urb.iso_frame_desc[j].status);
} else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->len) {
printf("husb: received iso data is larger then packet\n");
len = USB_RET_NAK;
} else {
len = aurb[i].urb.iso_frame_desc[j].actual_length;
memcpy(p->data,
aurb[i].urb.buffer +
j * aurb[i].urb.iso_frame_desc[0].length,
len);
}
} else {
len = p->len;
offset = (j == 0) ? 0 : get_iso_buffer_used(s, p->devep);
if (len > max_packet_size) {
printf("husb: send iso data is larger then max packet size\n");
return USB_RET_NAK;
}
memcpy(aurb[i].urb.buffer + offset, p->data, len);
aurb[i].urb.iso_frame_desc[j].length = len;
offset += len;
set_iso_buffer_used(s, p->devep, offset);
if (!is_iso_started(s, p->devep) && i == 1 && j == 8) {
set_iso_started(s, p->devep);
}
}
aurb[i].iso_frame_idx++;
if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
i = (i + 1) % s->iso_urb_count;
set_iso_urb_idx(s, p->devep, i);
}
} else {
if (in) {
set_iso_started(s, p->devep);
} else {
DPRINTF("hubs: iso out error no free buffer, dropping packet\n");
}
}
if (is_iso_started(s, p->devep)) {
for (i = 0; i < s->iso_urb_count; i++) {
if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]);
if (ret < 0) {
printf("husb error submitting iso urb %d: %d\n", i, errno);
if (!in || len == 0) {
switch(errno) {
case ETIMEDOUT:
len = USB_RET_NAK;
break;
case EPIPE:
default:
len = USB_RET_STALL;
}
}
break;
}
aurb[i].iso_frame_idx = -1;
change_iso_inflight(s, p->devep, +1);
}
}
}
return len;
}
| {
"code": [
" } else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->len) {",
" memcpy(p->data,",
" aurb[i].urb.buffer +",
" j * aurb[i].urb.iso_frame_desc[0].length,",
" len);",
" len = p->len;",
" memcpy(aurb[i].urb.buffer + offset, p->data, len);"
],
"line_no": [
57,
69,
71,
73,
75,
81,
101
]
} | static int FUNC_0(USBHostDevice *VAR_0, USBPacket *VAR_1, int VAR_2)
{
AsyncURB *aurb;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;
VAR_6 = get_max_packet_size(VAR_0, VAR_1->devep);
if (VAR_6 == 0)
return USB_RET_NAK;
aurb = get_iso_urb(VAR_0, VAR_1->devep);
if (!aurb) {
aurb = usb_host_alloc_iso(VAR_0, VAR_1->devep, VAR_2);
}
VAR_3 = get_iso_urb_idx(VAR_0, VAR_1->devep);
VAR_4 = aurb[VAR_3].iso_frame_idx;
if (VAR_4 >= 0 && VAR_4 < ISO_FRAME_DESC_PER_URB) {
if (VAR_2) {
if (aurb[VAR_3].urb.status) {
VAR_8 = urb_status_to_usb_ret(aurb[VAR_3].urb.status);
aurb[VAR_3].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1;
} else if (aurb[VAR_3].urb.iso_frame_desc[VAR_4].status) {
VAR_8 = urb_status_to_usb_ret(
aurb[VAR_3].urb.iso_frame_desc[VAR_4].status);
} else if (aurb[VAR_3].urb.iso_frame_desc[VAR_4].actual_length > VAR_1->VAR_8) {
printf("husb: received iso data is larger then packet\n");
VAR_8 = USB_RET_NAK;
} else {
VAR_8 = aurb[VAR_3].urb.iso_frame_desc[VAR_4].actual_length;
memcpy(VAR_1->data,
aurb[VAR_3].urb.buffer +
VAR_4 * aurb[VAR_3].urb.iso_frame_desc[0].length,
VAR_8);
}
} else {
VAR_8 = VAR_1->VAR_8;
VAR_7 = (VAR_4 == 0) ? 0 : get_iso_buffer_used(VAR_0, VAR_1->devep);
if (VAR_8 > VAR_6) {
printf("husb: send iso data is larger then max packet size\n");
return USB_RET_NAK;
}
memcpy(aurb[VAR_3].urb.buffer + VAR_7, VAR_1->data, VAR_8);
aurb[VAR_3].urb.iso_frame_desc[VAR_4].length = VAR_8;
VAR_7 += VAR_8;
set_iso_buffer_used(VAR_0, VAR_1->devep, VAR_7);
if (!is_iso_started(VAR_0, VAR_1->devep) && VAR_3 == 1 && VAR_4 == 8) {
set_iso_started(VAR_0, VAR_1->devep);
}
}
aurb[VAR_3].iso_frame_idx++;
if (aurb[VAR_3].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
VAR_3 = (VAR_3 + 1) % VAR_0->iso_urb_count;
set_iso_urb_idx(VAR_0, VAR_1->devep, VAR_3);
}
} else {
if (VAR_2) {
set_iso_started(VAR_0, VAR_1->devep);
} else {
DPRINTF("hubs: iso out error no free buffer, dropping packet\n");
}
}
if (is_iso_started(VAR_0, VAR_1->devep)) {
for (VAR_3 = 0; VAR_3 < VAR_0->iso_urb_count; VAR_3++) {
if (aurb[VAR_3].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {
VAR_5 = ioctl(VAR_0->fd, USBDEVFS_SUBMITURB, &aurb[VAR_3]);
if (VAR_5 < 0) {
printf("husb error submitting iso urb %d: %d\n", VAR_3, errno);
if (!VAR_2 || VAR_8 == 0) {
switch(errno) {
case ETIMEDOUT:
VAR_8 = USB_RET_NAK;
break;
case EPIPE:
default:
VAR_8 = USB_RET_STALL;
}
}
break;
}
aurb[VAR_3].iso_frame_idx = -1;
change_iso_inflight(VAR_0, VAR_1->devep, +1);
}
}
}
return VAR_8;
}
| [
"static int FUNC_0(USBHostDevice *VAR_0, USBPacket *VAR_1, int VAR_2)\n{",
"AsyncURB *aurb;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;",
"VAR_6 = get_max_packet_size(VAR_0, VAR_1->devep);",
"if (VAR_6 == 0)\nreturn USB_RET_NAK;",
"aurb = get_iso_urb(VAR_0, VAR_1->devep);",
"if (!aurb) {",
"aurb = usb_host_alloc_iso(VAR_0, VAR_1->devep, VAR_2);",
"}",
"VAR_3 = get_iso_urb_idx(VAR_0, VAR_1->devep);",
"VAR_4 = aurb[VAR_3].iso_frame_idx;",
"if (VAR_4 >= 0 && VAR_4 < ISO_FRAME_DESC_PER_URB) {",
"if (VAR_2) {",
"if (aurb[VAR_3].urb.status) {",
"VAR_8 = urb_status_to_usb_ret(aurb[VAR_3].urb.status);",
"aurb[VAR_3].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1;",
"} else if (aurb[VAR_3].urb.iso_frame_desc[VAR_4].status) {",
"VAR_8 = urb_status_to_usb_ret(\naurb[VAR_3].urb.iso_frame_desc[VAR_4].status);",
"} else if (aurb[VAR_3].urb.iso_frame_desc[VAR_4].actual_length > VAR_1->VAR_8) {",
"printf(\"husb: received iso data is larger then packet\\n\");",
"VAR_8 = USB_RET_NAK;",
"} else {",
"VAR_8 = aurb[VAR_3].urb.iso_frame_desc[VAR_4].actual_length;",
"memcpy(VAR_1->data,\naurb[VAR_3].urb.buffer +\nVAR_4 * aurb[VAR_3].urb.iso_frame_desc[0].length,\nVAR_8);",
"}",
"} else {",
"VAR_8 = VAR_1->VAR_8;",
"VAR_7 = (VAR_4 == 0) ? 0 : get_iso_buffer_used(VAR_0, VAR_1->devep);",
"if (VAR_8 > VAR_6) {",
"printf(\"husb: send iso data is larger then max packet size\\n\");",
"return USB_RET_NAK;",
"}",
"memcpy(aurb[VAR_3].urb.buffer + VAR_7, VAR_1->data, VAR_8);",
"aurb[VAR_3].urb.iso_frame_desc[VAR_4].length = VAR_8;",
"VAR_7 += VAR_8;",
"set_iso_buffer_used(VAR_0, VAR_1->devep, VAR_7);",
"if (!is_iso_started(VAR_0, VAR_1->devep) && VAR_3 == 1 && VAR_4 == 8) {",
"set_iso_started(VAR_0, VAR_1->devep);",
"}",
"}",
"aurb[VAR_3].iso_frame_idx++;",
"if (aurb[VAR_3].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {",
"VAR_3 = (VAR_3 + 1) % VAR_0->iso_urb_count;",
"set_iso_urb_idx(VAR_0, VAR_1->devep, VAR_3);",
"}",
"} else {",
"if (VAR_2) {",
"set_iso_started(VAR_0, VAR_1->devep);",
"} else {",
"DPRINTF(\"hubs: iso out error no free buffer, dropping packet\\n\");",
"}",
"}",
"if (is_iso_started(VAR_0, VAR_1->devep)) {",
"for (VAR_3 = 0; VAR_3 < VAR_0->iso_urb_count; VAR_3++) {",
"if (aurb[VAR_3].iso_frame_idx == ISO_FRAME_DESC_PER_URB) {",
"VAR_5 = ioctl(VAR_0->fd, USBDEVFS_SUBMITURB, &aurb[VAR_3]);",
"if (VAR_5 < 0) {",
"printf(\"husb error submitting iso urb %d: %d\\n\", VAR_3, errno);",
"if (!VAR_2 || VAR_8 == 0) {",
"switch(errno) {",
"case ETIMEDOUT:\nVAR_8 = USB_RET_NAK;",
"break;",
"case EPIPE:\ndefault:\nVAR_8 = USB_RET_STALL;",
"}",
"}",
"break;",
"}",
"aurb[VAR_3].iso_frame_idx = -1;",
"change_iso_inflight(VAR_0, VAR_1->devep, +1);",
"}",
"}",
"}",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51,
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69,
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171,
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
]
] |
24,388 | static void pcie_pci_bridge_realize(PCIDevice *d, Error **errp)
{
PCIBridge *br = PCI_BRIDGE(d);
PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(d);
int rc, pos;
pci_bridge_initfn(d, TYPE_PCI_BUS);
d->config[PCI_INTERRUPT_PIN] = 0x1;
memory_region_init(&pcie_br->shpc_bar, OBJECT(d), "shpc-bar",
shpc_bar_size(d));
rc = shpc_init(d, &br->sec_bus, &pcie_br->shpc_bar, 0, errp);
if (rc) {
goto error;
}
rc = pcie_cap_init(d, 0, PCI_EXP_TYPE_PCI_BRIDGE, 0, errp);
if (rc < 0) {
goto cap_error;
}
pos = pci_add_capability(d, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, errp);
if (pos < 0) {
goto pm_error;
}
d->exp.pm_cap = pos;
pci_set_word(d->config + pos + PCI_PM_PMC, 0x3);
pcie_cap_arifwd_init(d);
pcie_cap_deverr_init(d);
rc = pcie_aer_init(d, PCI_ERR_VER, 0x100, PCI_ERR_SIZEOF, errp);
if (rc < 0) {
goto aer_error;
}
if (pcie_br->msi != ON_OFF_AUTO_OFF) {
rc = msi_init(d, 0, 1, true, true, errp);
if (rc < 0) {
goto msi_error;
}
}
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64, &pcie_br->shpc_bar);
return;
msi_error:
pcie_aer_exit(d);
aer_error:
pm_error:
pcie_cap_exit(d);
cap_error:
shpc_free(d);
error:
pci_bridge_exitfn(d);
}
| true | qemu | d659d94013390238961fac741572306c95496bf5 | static void pcie_pci_bridge_realize(PCIDevice *d, Error **errp)
{
PCIBridge *br = PCI_BRIDGE(d);
PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(d);
int rc, pos;
pci_bridge_initfn(d, TYPE_PCI_BUS);
d->config[PCI_INTERRUPT_PIN] = 0x1;
memory_region_init(&pcie_br->shpc_bar, OBJECT(d), "shpc-bar",
shpc_bar_size(d));
rc = shpc_init(d, &br->sec_bus, &pcie_br->shpc_bar, 0, errp);
if (rc) {
goto error;
}
rc = pcie_cap_init(d, 0, PCI_EXP_TYPE_PCI_BRIDGE, 0, errp);
if (rc < 0) {
goto cap_error;
}
pos = pci_add_capability(d, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, errp);
if (pos < 0) {
goto pm_error;
}
d->exp.pm_cap = pos;
pci_set_word(d->config + pos + PCI_PM_PMC, 0x3);
pcie_cap_arifwd_init(d);
pcie_cap_deverr_init(d);
rc = pcie_aer_init(d, PCI_ERR_VER, 0x100, PCI_ERR_SIZEOF, errp);
if (rc < 0) {
goto aer_error;
}
if (pcie_br->msi != ON_OFF_AUTO_OFF) {
rc = msi_init(d, 0, 1, true, true, errp);
if (rc < 0) {
goto msi_error;
}
}
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64, &pcie_br->shpc_bar);
return;
msi_error:
pcie_aer_exit(d);
aer_error:
pm_error:
pcie_cap_exit(d);
cap_error:
shpc_free(d);
error:
pci_bridge_exitfn(d);
}
| {
"code": [
" rc = msi_init(d, 0, 1, true, true, errp);",
" goto msi_error;",
" shpc_free(d);"
],
"line_no": [
75,
79,
105
]
} | static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)
{
PCIBridge *br = PCI_BRIDGE(VAR_0);
PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(VAR_0);
int VAR_2, VAR_3;
pci_bridge_initfn(VAR_0, TYPE_PCI_BUS);
VAR_0->config[PCI_INTERRUPT_PIN] = 0x1;
memory_region_init(&pcie_br->shpc_bar, OBJECT(VAR_0), "shpc-bar",
shpc_bar_size(VAR_0));
VAR_2 = shpc_init(VAR_0, &br->sec_bus, &pcie_br->shpc_bar, 0, VAR_1);
if (VAR_2) {
goto error;
}
VAR_2 = pcie_cap_init(VAR_0, 0, PCI_EXP_TYPE_PCI_BRIDGE, 0, VAR_1);
if (VAR_2 < 0) {
goto cap_error;
}
VAR_3 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, VAR_1);
if (VAR_3 < 0) {
goto pm_error;
}
VAR_0->exp.pm_cap = VAR_3;
pci_set_word(VAR_0->config + VAR_3 + PCI_PM_PMC, 0x3);
pcie_cap_arifwd_init(VAR_0);
pcie_cap_deverr_init(VAR_0);
VAR_2 = pcie_aer_init(VAR_0, PCI_ERR_VER, 0x100, PCI_ERR_SIZEOF, VAR_1);
if (VAR_2 < 0) {
goto aer_error;
}
if (pcie_br->msi != ON_OFF_AUTO_OFF) {
VAR_2 = msi_init(VAR_0, 0, 1, true, true, VAR_1);
if (VAR_2 < 0) {
goto msi_error;
}
}
pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64, &pcie_br->shpc_bar);
return;
msi_error:
pcie_aer_exit(VAR_0);
aer_error:
pm_error:
pcie_cap_exit(VAR_0);
cap_error:
shpc_free(VAR_0);
error:
pci_bridge_exitfn(VAR_0);
}
| [
"static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{",
"PCIBridge *br = PCI_BRIDGE(VAR_0);",
"PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(VAR_0);",
"int VAR_2, VAR_3;",
"pci_bridge_initfn(VAR_0, TYPE_PCI_BUS);",
"VAR_0->config[PCI_INTERRUPT_PIN] = 0x1;",
"memory_region_init(&pcie_br->shpc_bar, OBJECT(VAR_0), \"shpc-bar\",\nshpc_bar_size(VAR_0));",
"VAR_2 = shpc_init(VAR_0, &br->sec_bus, &pcie_br->shpc_bar, 0, VAR_1);",
"if (VAR_2) {",
"goto error;",
"}",
"VAR_2 = pcie_cap_init(VAR_0, 0, PCI_EXP_TYPE_PCI_BRIDGE, 0, VAR_1);",
"if (VAR_2 < 0) {",
"goto cap_error;",
"}",
"VAR_3 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, VAR_1);",
"if (VAR_3 < 0) {",
"goto pm_error;",
"}",
"VAR_0->exp.pm_cap = VAR_3;",
"pci_set_word(VAR_0->config + VAR_3 + PCI_PM_PMC, 0x3);",
"pcie_cap_arifwd_init(VAR_0);",
"pcie_cap_deverr_init(VAR_0);",
"VAR_2 = pcie_aer_init(VAR_0, PCI_ERR_VER, 0x100, PCI_ERR_SIZEOF, VAR_1);",
"if (VAR_2 < 0) {",
"goto aer_error;",
"}",
"if (pcie_br->msi != ON_OFF_AUTO_OFF) {",
"VAR_2 = msi_init(VAR_0, 0, 1, true, true, VAR_1);",
"if (VAR_2 < 0) {",
"goto msi_error;",
"}",
"}",
"pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_TYPE_64, &pcie_br->shpc_bar);",
"return;",
"msi_error:\npcie_aer_exit(VAR_0);",
"aer_error:\npm_error:\npcie_cap_exit(VAR_0);",
"cap_error:\nshpc_free(VAR_0);",
"error:\npci_bridge_exitfn(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,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
93,
95
],
[
97,
99,
101
],
[
103,
105
],
[
107,
109
],
[
111
]
] |
24,389 | static int qcrypto_cipher_init_aes(QCryptoCipher *cipher,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipherBuiltin *ctxt;
if (cipher->mode != QCRYPTO_CIPHER_MODE_CBC &&
cipher->mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %d", cipher->mode);
return -1;
}
ctxt = g_new0(QCryptoCipherBuiltin, 1);
if (AES_set_encrypt_key(key, nkey * 8, &ctxt->state.aes.encrypt_key) != 0) {
error_setg(errp, "Failed to set encryption key");
goto error;
}
if (AES_set_decrypt_key(key, nkey * 8, &ctxt->state.aes.decrypt_key) != 0) {
error_setg(errp, "Failed to set decryption key");
goto error;
}
ctxt->free = qcrypto_cipher_free_aes;
ctxt->setiv = qcrypto_cipher_setiv_aes;
ctxt->encrypt = qcrypto_cipher_encrypt_aes;
ctxt->decrypt = qcrypto_cipher_decrypt_aes;
cipher->opaque = ctxt;
return 0;
error:
g_free(ctxt);
return -1;
} | true | qemu | 3a661f1eabf7e8db66e28489884d9b54aacb94ea | static int qcrypto_cipher_init_aes(QCryptoCipher *cipher,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipherBuiltin *ctxt;
if (cipher->mode != QCRYPTO_CIPHER_MODE_CBC &&
cipher->mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %d", cipher->mode);
return -1;
}
ctxt = g_new0(QCryptoCipherBuiltin, 1);
if (AES_set_encrypt_key(key, nkey * 8, &ctxt->state.aes.encrypt_key) != 0) {
error_setg(errp, "Failed to set encryption key");
goto error;
}
if (AES_set_decrypt_key(key, nkey * 8, &ctxt->state.aes.decrypt_key) != 0) {
error_setg(errp, "Failed to set decryption key");
goto error;
}
ctxt->free = qcrypto_cipher_free_aes;
ctxt->setiv = qcrypto_cipher_setiv_aes;
ctxt->encrypt = qcrypto_cipher_encrypt_aes;
ctxt->decrypt = qcrypto_cipher_decrypt_aes;
cipher->opaque = ctxt;
return 0;
error:
g_free(ctxt);
return -1;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(QCryptoCipher *VAR_0,
const uint8_t *VAR_1, size_t VAR_2,
Error **VAR_3)
{
QCryptoCipherBuiltin *ctxt;
if (VAR_0->mode != QCRYPTO_CIPHER_MODE_CBC &&
VAR_0->mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(VAR_3, "Unsupported VAR_0 mode %d", VAR_0->mode);
return -1;
}
ctxt = g_new0(QCryptoCipherBuiltin, 1);
if (AES_set_encrypt_key(VAR_1, VAR_2 * 8, &ctxt->state.aes.encrypt_key) != 0) {
error_setg(VAR_3, "Failed to set encryption VAR_1");
goto error;
}
if (AES_set_decrypt_key(VAR_1, VAR_2 * 8, &ctxt->state.aes.decrypt_key) != 0) {
error_setg(VAR_3, "Failed to set decryption VAR_1");
goto error;
}
ctxt->free = qcrypto_cipher_free_aes;
ctxt->setiv = qcrypto_cipher_setiv_aes;
ctxt->encrypt = qcrypto_cipher_encrypt_aes;
ctxt->decrypt = qcrypto_cipher_decrypt_aes;
VAR_0->opaque = ctxt;
return 0;
error:
g_free(ctxt);
return -1;
} | [
"static int FUNC_0(QCryptoCipher *VAR_0,\nconst uint8_t *VAR_1, size_t VAR_2,\nError **VAR_3)\n{",
"QCryptoCipherBuiltin *ctxt;",
"if (VAR_0->mode != QCRYPTO_CIPHER_MODE_CBC &&\nVAR_0->mode != QCRYPTO_CIPHER_MODE_ECB) {",
"error_setg(VAR_3, \"Unsupported VAR_0 mode %d\", VAR_0->mode);",
"return -1;",
"}",
"ctxt = g_new0(QCryptoCipherBuiltin, 1);",
"if (AES_set_encrypt_key(VAR_1, VAR_2 * 8, &ctxt->state.aes.encrypt_key) != 0) {",
"error_setg(VAR_3, \"Failed to set encryption VAR_1\");",
"goto error;",
"}",
"if (AES_set_decrypt_key(VAR_1, VAR_2 * 8, &ctxt->state.aes.decrypt_key) != 0) {",
"error_setg(VAR_3, \"Failed to set decryption VAR_1\");",
"goto error;",
"}",
"ctxt->free = qcrypto_cipher_free_aes;",
"ctxt->setiv = qcrypto_cipher_setiv_aes;",
"ctxt->encrypt = qcrypto_cipher_encrypt_aes;",
"ctxt->decrypt = qcrypto_cipher_decrypt_aes;",
"VAR_0->opaque = ctxt;",
"return 0;",
"error:\ng_free(ctxt);",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60
],
[
64
],
[
68,
70
],
[
72
],
[
74
]
] |
24,390 | static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
MXFPartition *partition;
UID op;
uint64_t footer_partition;
if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
return AVERROR(ENOMEM);
mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
if (!mxf->partitions)
return AVERROR(ENOMEM);
if (mxf->parsing_backward) {
/* insert the new partition pack in the middle
* this makes the entries in mxf->partitions sorted by offset */
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
/* consider both footers to be closed (there is only Footer and CompleteFooter) */
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 8);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
avio_skip(pb, 16);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
/* some files don'thave FooterPartition set in every partition */
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc, "PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, "
"FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 0x10) mxf->op = OPAtom;
else
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh\n", op[12], op[13]);
return 0;
}
| true | FFmpeg | fd34dbea58e097609ff09cf7dcc59f74930195d3 | static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
MXFPartition *partition;
UID op;
uint64_t footer_partition;
if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
return AVERROR(ENOMEM);
mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
if (!mxf->partitions)
return AVERROR(ENOMEM);
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 8);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
avio_skip(pb, 16);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc, "PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, "
"FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 0x10) mxf->op = OPAtom;
else
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh\n", op[12], op[13]);
return 0;
}
| {
"code": [
"static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)",
" avio_skip(pb, 8);",
" avio_skip(pb, 16);",
" av_log(mxf->fc, AV_LOG_ERROR, \"unknown operational pattern: %02xh %02xh\\n\", op[12], op[13]);"
],
"line_no": [
1,
95,
103,
169
]
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)
{
MXFContext *mxf = VAR_0;
MXFPartition *partition;
UID op;
uint64_t footer_partition;
if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
return AVERROR(ENOMEM);
mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
if (!mxf->partitions)
return AVERROR(ENOMEM);
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
switch(VAR_4[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", VAR_4[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(VAR_4[14] & 1);
partition->complete = VAR_4[14] > 2;
avio_skip(VAR_1, 8);
partition->this_partition = avio_rb64(VAR_1);
partition->previous_partition = avio_rb64(VAR_1);
footer_partition = avio_rb64(VAR_1);
avio_skip(VAR_1, 16);
partition->index_sid = avio_rb32(VAR_1);
avio_skip(VAR_1, 8);
partition->body_sid = avio_rb32(VAR_1);
avio_read(VAR_1, op, sizeof(UID));
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc, "PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, "
"FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 0x10) mxf->op = OPAtom;
else
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh\n", op[12], op[13]);
return 0;
}
| [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)\n{",
"MXFContext *mxf = VAR_0;",
"MXFPartition *partition;",
"UID op;",
"uint64_t footer_partition;",
"if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))\nreturn AVERROR(ENOMEM);",
"mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));",
"if (!mxf->partitions)\nreturn AVERROR(ENOMEM);",
"if (mxf->parsing_backward) {",
"memmove(&mxf->partitions[mxf->last_forward_partition+1],\n&mxf->partitions[mxf->last_forward_partition],\n(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));",
"partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];",
"} else {",
"mxf->last_forward_partition++;",
"partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];",
"}",
"memset(partition, 0, sizeof(*partition));",
"mxf->partitions_count++;",
"switch(VAR_4[13]) {",
"case 2:\npartition->type = Header;",
"break;",
"case 3:\npartition->type = BodyPartition;",
"break;",
"case 4:\npartition->type = Footer;",
"break;",
"default:\nav_log(mxf->fc, AV_LOG_ERROR, \"unknown partition type %i\\n\", VAR_4[13]);",
"return AVERROR_INVALIDDATA;",
"}",
"partition->closed = partition->type == Footer || !(VAR_4[14] & 1);",
"partition->complete = VAR_4[14] > 2;",
"avio_skip(VAR_1, 8);",
"partition->this_partition = avio_rb64(VAR_1);",
"partition->previous_partition = avio_rb64(VAR_1);",
"footer_partition = avio_rb64(VAR_1);",
"avio_skip(VAR_1, 16);",
"partition->index_sid = avio_rb32(VAR_1);",
"avio_skip(VAR_1, 8);",
"partition->body_sid = avio_rb32(VAR_1);",
"avio_read(VAR_1, op, sizeof(UID));",
"if (footer_partition) {",
"if (mxf->footer_partition && mxf->footer_partition != footer_partition) {",
"av_log(mxf->fc, AV_LOG_ERROR, \"inconsistent FooterPartition value: %li != %li\\n\",\nmxf->footer_partition, footer_partition);",
"} else {",
"mxf->footer_partition = footer_partition;",
"}",
"}",
"av_dlog(mxf->fc, \"PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, \"\n\"FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\\n\",\npartition->this_partition,\npartition->previous_partition, footer_partition,\npartition->index_sid, partition->body_sid);",
"if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;",
"else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;",
"else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;",
"else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;",
"else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;",
"else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;",
"else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;",
"else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;",
"else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;",
"else if (op[12] == 0x10) mxf->op = OPAtom;",
"else\nav_log(mxf->fc, AV_LOG_ERROR, \"unknown operational pattern: %02xh %02xh\\n\", op[12], op[13]);",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23,
25
],
[
29
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135,
137,
139,
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
173
],
[
175
]
] |
24,391 | static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
int x,y;
uint64_t ssd=0;
//printf("%d %d\n", w, h);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int d= src1[x + y*stride1] - src2[x + y*stride2];
ssd+= d*d;
//printf("%d", abs(src1[x + y*stride1] - src2[x + y*stride2])/26 );
}
//printf("\n");
}
return ssd;
}
| true | FFmpeg | 221b804f3491638ecf2eec1302c669ad2d9ec799 | static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
int x,y;
uint64_t ssd=0;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int d= src1[x + y*stride1] - src2[x + y*stride2];
ssd+= d*d;
}
}
return ssd;
}
| {
"code": [
"\tint x,y;",
"\tuint64_t ssd=0;",
"\tfor(y=0; y<h; y++){",
"\t\tfor(x=0; x<w; x++){",
"\t\t\tint d= src1[x + y*stride1] - src2[x + y*stride2];",
"\t\t\tssd+= d*d;",
"\treturn ssd;"
],
"line_no": [
3,
5,
13,
15,
17,
19,
29
]
} | static uint64_t FUNC_0(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
int VAR_0,VAR_1;
uint64_t ssd=0;
for(VAR_1=0; VAR_1<h; VAR_1++){
for(VAR_0=0; VAR_0<w; VAR_0++){
int VAR_2= src1[VAR_0 + VAR_1*stride1] - src2[VAR_0 + VAR_1*stride2];
ssd+= VAR_2*VAR_2;
}
}
return ssd;
}
| [
"static uint64_t FUNC_0(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){",
"int VAR_0,VAR_1;",
"uint64_t ssd=0;",
"for(VAR_1=0; VAR_1<h; VAR_1++){",
"for(VAR_0=0; VAR_0<w; VAR_0++){",
"int VAR_2= src1[VAR_0 + VAR_1*stride1] - src2[VAR_0 + VAR_1*stride2];",
"ssd+= VAR_2*VAR_2;",
"}",
"}",
"return ssd;",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1
],
[
3
],
[
5
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
24,393 | static inline void test_server_connect(TestServer *server)
{
test_server_create_chr(server, ",reconnect=1");
}
| true | qemu | 20784087eb875e22cf0021989e61716304b63c84 | static inline void test_server_connect(TestServer *server)
{
test_server_create_chr(server, ",reconnect=1");
}
| {
"code": [
"static inline void test_server_connect(TestServer *server)",
" test_server_create_chr(server, \",reconnect=1\");"
],
"line_no": [
1,
5
]
} | static inline void FUNC_0(TestServer *VAR_0)
{
test_server_create_chr(VAR_0, ",reconnect=1");
}
| [
"static inline void FUNC_0(TestServer *VAR_0)\n{",
"test_server_create_chr(VAR_0, \",reconnect=1\");",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,394 | static int put_system_header(AVFormatContext *ctx, uint8_t *buf,int only_for_stream_id)
{
MpegMuxContext *s = ctx->priv_data;
int size, i, private_stream_coded, id;
PutBitContext pb;
init_put_bits(&pb, buf, 128);
put_bits(&pb, 32, SYSTEM_HEADER_START_CODE);
put_bits(&pb, 16, 0);
put_bits(&pb, 1, 1);
put_bits(&pb, 22, s->mux_rate); /* maximum bit rate of the multiplexed stream */
put_bits(&pb, 1, 1); /* marker */
if (s->is_vcd && only_for_stream_id==VIDEO_ID) {
/* This header applies only to the video stream (see VCD standard p. IV-7)*/
put_bits(&pb, 6, 0);
} else
put_bits(&pb, 6, s->audio_bound);
if (s->is_vcd) {
/* see VCD standard, p. IV-7*/
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 1);
} else {
put_bits(&pb, 1, 0); /* variable bitrate*/
put_bits(&pb, 1, 0); /* non constrainted bit stream */
}
if (s->is_vcd || s->is_dvd) {
/* see VCD standard p IV-7 */
put_bits(&pb, 1, 1); /* audio locked */
put_bits(&pb, 1, 1); /* video locked */
} else {
put_bits(&pb, 1, 0); /* audio locked */
put_bits(&pb, 1, 0); /* video locked */
}
put_bits(&pb, 1, 1); /* marker */
if (s->is_vcd && only_for_stream_id==AUDIO_ID) {
/* This header applies only to the audio stream (see VCD standard p. IV-7)*/
put_bits(&pb, 5, 0);
} else
put_bits(&pb, 5, s->video_bound);
if (s->is_dvd) {
put_bits(&pb, 1, 0); /* packet_rate_restriction_flag */
put_bits(&pb, 7, 0x7f); /* reserved byte */
} else
put_bits(&pb, 8, 0xff); /* reserved byte */
/* DVD-Video Stream_bound entries
id (0xB9) video, maximum P-STD for stream 0xE0. (P-STD_buffer_bound_scale = 1)
id (0xB8) audio, maximum P-STD for any MPEG audio (0xC0 to 0xC7) streams. If there are none set to 4096 (32x128). (P-STD_buffer_bound_scale = 0)
id (0xBD) private stream 1 (audio other than MPEG and subpictures). (P-STD_buffer_bound_scale = 1)
id (0xBF) private stream 2, NAV packs, set to 2x1024. */
if (s->is_dvd) {
int P_STD_max_video = 0;
int P_STD_max_mpeg_audio = 0;
int P_STD_max_mpeg_PS1 = 0;
for(i=0;i<ctx->nb_streams;i++) {
StreamInfo *stream = ctx->streams[i]->priv_data;
id = stream->id;
if (id == 0xbd && stream->max_buffer_size > P_STD_max_mpeg_PS1) {
P_STD_max_mpeg_PS1 = stream->max_buffer_size;
} else if (id >= 0xc0 && id <= 0xc7 && stream->max_buffer_size > P_STD_max_mpeg_audio) {
P_STD_max_mpeg_audio = stream->max_buffer_size;
} else if (id == 0xe0 && stream->max_buffer_size > P_STD_max_video) {
P_STD_max_video = stream->max_buffer_size;
}
}
/* video */
put_bits(&pb, 8, 0xb9); /* stream ID */
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, P_STD_max_video / 1024);
/* audio */
if (P_STD_max_mpeg_audio == 0)
P_STD_max_mpeg_audio = 4096;
put_bits(&pb, 8, 0xb8); /* stream ID */
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, P_STD_max_mpeg_audio / 128);
/* private stream 1 */
put_bits(&pb, 8, 0xbd); /* stream ID */
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, P_STD_max_mpeg_PS1 / 128);
/* private stream 2 */
put_bits(&pb, 8, 0xbf); /* stream ID */
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, 2);
}
else {
/* audio stream info */
private_stream_coded = 0;
for(i=0;i<ctx->nb_streams;i++) {
StreamInfo *stream = ctx->streams[i]->priv_data;
/* For VCDs, only include the stream info for the stream
that the pack which contains this system belongs to.
(see VCD standard p. IV-7) */
if ( !s->is_vcd || stream->id==only_for_stream_id
|| only_for_stream_id==0) {
id = stream->id;
if (id < 0xc0) {
/* special case for private streams (AC-3 uses that) */
if (private_stream_coded)
continue;
private_stream_coded = 1;
id = 0xbd;
}
put_bits(&pb, 8, id); /* stream ID */
put_bits(&pb, 2, 3);
if (id < 0xe0) {
/* audio */
put_bits(&pb, 1, 0);
put_bits(&pb, 13, stream->max_buffer_size / 128);
} else {
/* video */
put_bits(&pb, 1, 1);
put_bits(&pb, 13, stream->max_buffer_size / 1024);
}
}
}
}
flush_put_bits(&pb);
size = put_bits_ptr(&pb) - pb.buf;
/* patch packet size */
buf[4] = (size - 6) >> 8;
buf[5] = (size - 6) & 0xff;
return size;
}
| false | FFmpeg | 24dc7776ff4452764d0365b12d0728153f879cf8 | static int put_system_header(AVFormatContext *ctx, uint8_t *buf,int only_for_stream_id)
{
MpegMuxContext *s = ctx->priv_data;
int size, i, private_stream_coded, id;
PutBitContext pb;
init_put_bits(&pb, buf, 128);
put_bits(&pb, 32, SYSTEM_HEADER_START_CODE);
put_bits(&pb, 16, 0);
put_bits(&pb, 1, 1);
put_bits(&pb, 22, s->mux_rate);
put_bits(&pb, 1, 1);
if (s->is_vcd && only_for_stream_id==VIDEO_ID) {
put_bits(&pb, 6, 0);
} else
put_bits(&pb, 6, s->audio_bound);
if (s->is_vcd) {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 1);
} else {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
}
if (s->is_vcd || s->is_dvd) {
put_bits(&pb, 1, 1);
put_bits(&pb, 1, 1);
} else {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
}
put_bits(&pb, 1, 1);
if (s->is_vcd && only_for_stream_id==AUDIO_ID) {
put_bits(&pb, 5, 0);
} else
put_bits(&pb, 5, s->video_bound);
if (s->is_dvd) {
put_bits(&pb, 1, 0);
put_bits(&pb, 7, 0x7f);
} else
put_bits(&pb, 8, 0xff);
if (s->is_dvd) {
int P_STD_max_video = 0;
int P_STD_max_mpeg_audio = 0;
int P_STD_max_mpeg_PS1 = 0;
for(i=0;i<ctx->nb_streams;i++) {
StreamInfo *stream = ctx->streams[i]->priv_data;
id = stream->id;
if (id == 0xbd && stream->max_buffer_size > P_STD_max_mpeg_PS1) {
P_STD_max_mpeg_PS1 = stream->max_buffer_size;
} else if (id >= 0xc0 && id <= 0xc7 && stream->max_buffer_size > P_STD_max_mpeg_audio) {
P_STD_max_mpeg_audio = stream->max_buffer_size;
} else if (id == 0xe0 && stream->max_buffer_size > P_STD_max_video) {
P_STD_max_video = stream->max_buffer_size;
}
}
put_bits(&pb, 8, 0xb9);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, P_STD_max_video / 1024);
if (P_STD_max_mpeg_audio == 0)
P_STD_max_mpeg_audio = 4096;
put_bits(&pb, 8, 0xb8);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, P_STD_max_mpeg_audio / 128);
put_bits(&pb, 8, 0xbd);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, P_STD_max_mpeg_PS1 / 128);
put_bits(&pb, 8, 0xbf);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, 2);
}
else {
private_stream_coded = 0;
for(i=0;i<ctx->nb_streams;i++) {
StreamInfo *stream = ctx->streams[i]->priv_data;
if ( !s->is_vcd || stream->id==only_for_stream_id
|| only_for_stream_id==0) {
id = stream->id;
if (id < 0xc0) {
if (private_stream_coded)
continue;
private_stream_coded = 1;
id = 0xbd;
}
put_bits(&pb, 8, id);
put_bits(&pb, 2, 3);
if (id < 0xe0) {
put_bits(&pb, 1, 0);
put_bits(&pb, 13, stream->max_buffer_size / 128);
} else {
put_bits(&pb, 1, 1);
put_bits(&pb, 13, stream->max_buffer_size / 1024);
}
}
}
}
flush_put_bits(&pb);
size = put_bits_ptr(&pb) - pb.buf;
buf[4] = (size - 6) >> 8;
buf[5] = (size - 6) & 0xff;
return size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1,int VAR_2)
{
MpegMuxContext *s = VAR_0->priv_data;
int VAR_3, VAR_4, VAR_5, VAR_6;
PutBitContext pb;
init_put_bits(&pb, VAR_1, 128);
put_bits(&pb, 32, SYSTEM_HEADER_START_CODE);
put_bits(&pb, 16, 0);
put_bits(&pb, 1, 1);
put_bits(&pb, 22, s->mux_rate);
put_bits(&pb, 1, 1);
if (s->is_vcd && VAR_2==VIDEO_ID) {
put_bits(&pb, 6, 0);
} else
put_bits(&pb, 6, s->audio_bound);
if (s->is_vcd) {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 1);
} else {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
}
if (s->is_vcd || s->is_dvd) {
put_bits(&pb, 1, 1);
put_bits(&pb, 1, 1);
} else {
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
}
put_bits(&pb, 1, 1);
if (s->is_vcd && VAR_2==AUDIO_ID) {
put_bits(&pb, 5, 0);
} else
put_bits(&pb, 5, s->video_bound);
if (s->is_dvd) {
put_bits(&pb, 1, 0);
put_bits(&pb, 7, 0x7f);
} else
put_bits(&pb, 8, 0xff);
if (s->is_dvd) {
int VAR_7 = 0;
int VAR_8 = 0;
int VAR_9 = 0;
for(VAR_4=0;VAR_4<VAR_0->nb_streams;VAR_4++) {
StreamInfo *stream = VAR_0->streams[VAR_4]->priv_data;
VAR_6 = stream->VAR_6;
if (VAR_6 == 0xbd && stream->max_buffer_size > VAR_9) {
VAR_9 = stream->max_buffer_size;
} else if (VAR_6 >= 0xc0 && VAR_6 <= 0xc7 && stream->max_buffer_size > VAR_8) {
VAR_8 = stream->max_buffer_size;
} else if (VAR_6 == 0xe0 && stream->max_buffer_size > VAR_7) {
VAR_7 = stream->max_buffer_size;
}
}
put_bits(&pb, 8, 0xb9);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, VAR_7 / 1024);
if (VAR_8 == 0)
VAR_8 = 4096;
put_bits(&pb, 8, 0xb8);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, VAR_8 / 128);
put_bits(&pb, 8, 0xbd);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, VAR_9 / 128);
put_bits(&pb, 8, 0xbf);
put_bits(&pb, 2, 3);
put_bits(&pb, 1, 1);
put_bits(&pb, 13, 2);
}
else {
VAR_5 = 0;
for(VAR_4=0;VAR_4<VAR_0->nb_streams;VAR_4++) {
StreamInfo *stream = VAR_0->streams[VAR_4]->priv_data;
if ( !s->is_vcd || stream->VAR_6==VAR_2
|| VAR_2==0) {
VAR_6 = stream->VAR_6;
if (VAR_6 < 0xc0) {
if (VAR_5)
continue;
VAR_5 = 1;
VAR_6 = 0xbd;
}
put_bits(&pb, 8, VAR_6);
put_bits(&pb, 2, 3);
if (VAR_6 < 0xe0) {
put_bits(&pb, 1, 0);
put_bits(&pb, 13, stream->max_buffer_size / 128);
} else {
put_bits(&pb, 1, 1);
put_bits(&pb, 13, stream->max_buffer_size / 1024);
}
}
}
}
flush_put_bits(&pb);
VAR_3 = put_bits_ptr(&pb) - pb.VAR_1;
VAR_1[4] = (VAR_3 - 6) >> 8;
VAR_1[5] = (VAR_3 - 6) & 0xff;
return VAR_3;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1,int VAR_2)\n{",
"MpegMuxContext *s = VAR_0->priv_data;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"PutBitContext pb;",
"init_put_bits(&pb, VAR_1, 128);",
"put_bits(&pb, 32, SYSTEM_HEADER_START_CODE);",
"put_bits(&pb, 16, 0);",
"put_bits(&pb, 1, 1);",
"put_bits(&pb, 22, s->mux_rate);",
"put_bits(&pb, 1, 1);",
"if (s->is_vcd && VAR_2==VIDEO_ID) {",
"put_bits(&pb, 6, 0);",
"} else",
"put_bits(&pb, 6, s->audio_bound);",
"if (s->is_vcd) {",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 1, 1);",
"} else {",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 1, 0);",
"}",
"if (s->is_vcd || s->is_dvd) {",
"put_bits(&pb, 1, 1);",
"put_bits(&pb, 1, 1);",
"} else {",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 1, 0);",
"}",
"put_bits(&pb, 1, 1);",
"if (s->is_vcd && VAR_2==AUDIO_ID) {",
"put_bits(&pb, 5, 0);",
"} else",
"put_bits(&pb, 5, s->video_bound);",
"if (s->is_dvd) {",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 7, 0x7f);",
"} else",
"put_bits(&pb, 8, 0xff);",
"if (s->is_dvd) {",
"int VAR_7 = 0;",
"int VAR_8 = 0;",
"int VAR_9 = 0;",
"for(VAR_4=0;VAR_4<VAR_0->nb_streams;VAR_4++) {",
"StreamInfo *stream = VAR_0->streams[VAR_4]->priv_data;",
"VAR_6 = stream->VAR_6;",
"if (VAR_6 == 0xbd && stream->max_buffer_size > VAR_9) {",
"VAR_9 = stream->max_buffer_size;",
"} else if (VAR_6 >= 0xc0 && VAR_6 <= 0xc7 && stream->max_buffer_size > VAR_8) {",
"VAR_8 = stream->max_buffer_size;",
"} else if (VAR_6 == 0xe0 && stream->max_buffer_size > VAR_7) {",
"VAR_7 = stream->max_buffer_size;",
"}",
"}",
"put_bits(&pb, 8, 0xb9);",
"put_bits(&pb, 2, 3);",
"put_bits(&pb, 1, 1);",
"put_bits(&pb, 13, VAR_7 / 1024);",
"if (VAR_8 == 0)\nVAR_8 = 4096;",
"put_bits(&pb, 8, 0xb8);",
"put_bits(&pb, 2, 3);",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 13, VAR_8 / 128);",
"put_bits(&pb, 8, 0xbd);",
"put_bits(&pb, 2, 3);",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 13, VAR_9 / 128);",
"put_bits(&pb, 8, 0xbf);",
"put_bits(&pb, 2, 3);",
"put_bits(&pb, 1, 1);",
"put_bits(&pb, 13, 2);",
"}",
"else {",
"VAR_5 = 0;",
"for(VAR_4=0;VAR_4<VAR_0->nb_streams;VAR_4++) {",
"StreamInfo *stream = VAR_0->streams[VAR_4]->priv_data;",
"if ( !s->is_vcd || stream->VAR_6==VAR_2\n|| VAR_2==0) {",
"VAR_6 = stream->VAR_6;",
"if (VAR_6 < 0xc0) {",
"if (VAR_5)\ncontinue;",
"VAR_5 = 1;",
"VAR_6 = 0xbd;",
"}",
"put_bits(&pb, 8, VAR_6);",
"put_bits(&pb, 2, 3);",
"if (VAR_6 < 0xe0) {",
"put_bits(&pb, 1, 0);",
"put_bits(&pb, 13, stream->max_buffer_size / 128);",
"} else {",
"put_bits(&pb, 1, 1);",
"put_bits(&pb, 13, stream->max_buffer_size / 1024);",
"}",
"}",
"}",
"}",
"flush_put_bits(&pb);",
"VAR_3 = put_bits_ptr(&pb) - pb.VAR_1;",
"VAR_1[4] = (VAR_3 - 6) >> 8;",
"VAR_1[5] = (VAR_3 - 6) & 0xff;",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
161
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
225,
227
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
283
],
[
285
],
[
289
],
[
291
]
] |
24,395 | static int standard_decode_i_mbs(VC9Context *v)
{
int x, y, ac_pred, cbpcy;
/* Select ttmb table depending on pq */
if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];
else v->ttmb_vlc = &vc9_ttmb_vlc[2];
for (y=0; y<v->height_mb; y++)
{
for (x=0; x<v->width_mb; x++)
{
cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table,
VC9_CBPCY_I_VLC_BITS, 2);
ac_pred = get_bits(&v->gb, 1);
//Decode blocks from that mb wrt cbpcy
}
}
return 0;
}
| false | FFmpeg | e5540b3fd30367ce3cc33b2f34a04b660dbc4b38 | static int standard_decode_i_mbs(VC9Context *v)
{
int x, y, ac_pred, cbpcy;
if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];
else v->ttmb_vlc = &vc9_ttmb_vlc[2];
for (y=0; y<v->height_mb; y++)
{
for (x=0; x<v->width_mb; x++)
{
cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table,
VC9_CBPCY_I_VLC_BITS, 2);
ac_pred = get_bits(&v->gb, 1);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VC9Context *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_4;
if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1];
else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2];
for (VAR_2=0; VAR_2<VAR_0->height_mb; VAR_2++)
{
for (VAR_1=0; VAR_1<VAR_0->width_mb; VAR_1++)
{
VAR_4 = get_vlc2(&VAR_0->gb, vc9_cbpcy_i_vlc.table,
VC9_CBPCY_I_VLC_BITS, 2);
VAR_3 = get_bits(&VAR_0->gb, 1);
}
}
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0];",
"else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1];",
"else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2];",
"for (VAR_2=0; VAR_2<VAR_0->height_mb; VAR_2++)",
"{",
"for (VAR_1=0; VAR_1<VAR_0->width_mb; VAR_1++)",
"{",
"VAR_4 = get_vlc2(&VAR_0->gb, vc9_cbpcy_i_vlc.table,\nVC9_CBPCY_I_VLC_BITS, 2);",
"VAR_3 = get_bits(&VAR_0->gb, 1);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
24,396 | static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
{
int dc = (block[0] + 32) >> 6;
int y;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(dc)
);
for(y=2; y--; dst += 4*stride){
__asm__ volatile(
"movq %0, %%mm2 \n\t"
"movq %1, %%mm3 \n\t"
"movq %2, %%mm4 \n\t"
"movq %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movq %%mm2, %0 \n\t"
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %3 \n\t"
:"+m"(*(uint64_t*)(dst+0*stride)),
"+m"(*(uint64_t*)(dst+1*stride)),
"+m"(*(uint64_t*)(dst+2*stride)),
"+m"(*(uint64_t*)(dst+3*stride))
);
}
}
| false | FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
{
int dc = (block[0] + 32) >> 6;
int y;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(dc)
);
for(y=2; y--; dst += 4*stride){
__asm__ volatile(
"movq %0, %%mm2 \n\t"
"movq %1, %%mm3 \n\t"
"movq %2, %%mm4 \n\t"
"movq %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movq %%mm2, %0 \n\t"
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %3 \n\t"
:"+m"(*(uint64_t*)(dst+0*stride)),
"+m"(*(uint64_t*)(dst+1*stride)),
"+m"(*(uint64_t*)(dst+2*stride)),
"+m"(*(uint64_t*)(dst+3*stride))
);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int16_t *VAR_1, int VAR_2)
{
int VAR_3 = (VAR_1[0] + 32) >> 6;
int VAR_4;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(VAR_3)
);
for(VAR_4=2; VAR_4--; VAR_0 += 4*VAR_2){
__asm__ volatile(
"movq %0, %%mm2 \n\t"
"movq %1, %%mm3 \n\t"
"movq %2, %%mm4 \n\t"
"movq %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movq %%mm2, %0 \n\t"
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %3 \n\t"
:"+m"(*(uint64_t*)(VAR_0+0*VAR_2)),
"+m"(*(uint64_t*)(VAR_0+1*VAR_2)),
"+m"(*(uint64_t*)(VAR_0+2*VAR_2)),
"+m"(*(uint64_t*)(VAR_0+3*VAR_2))
);
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"int VAR_3 = (VAR_1[0] + 32) >> 6;",
"int VAR_4;",
"__asm__ volatile(\n\"movd %0, %%mm0 \\n\\t\"\n\"pshufw $0, %%mm0, %%mm0 \\n\\t\"\n\"pxor %%mm1, %%mm1 \\n\\t\"\n\"psubw %%mm0, %%mm1 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"packuswb %%mm1, %%mm1 \\n\\t\"\n::\"r\"(VAR_3)\n);",
"for(VAR_4=2; VAR_4--; VAR_0 += 4*VAR_2){",
"__asm__ volatile(\n\"movq %0, %%mm2 \\n\\t\"\n\"movq %1, %%mm3 \\n\\t\"\n\"movq %2, %%mm4 \\n\\t\"\n\"movq %3, %%mm5 \\n\\t\"\n\"paddusb %%mm0, %%mm2 \\n\\t\"\n\"paddusb %%mm0, %%mm3 \\n\\t\"\n\"paddusb %%mm0, %%mm4 \\n\\t\"\n\"paddusb %%mm0, %%mm5 \\n\\t\"\n\"psubusb %%mm1, %%mm2 \\n\\t\"\n\"psubusb %%mm1, %%mm3 \\n\\t\"\n\"psubusb %%mm1, %%mm4 \\n\\t\"\n\"psubusb %%mm1, %%mm5 \\n\\t\"\n\"movq %%mm2, %0 \\n\\t\"\n\"movq %%mm3, %1 \\n\\t\"\n\"movq %%mm4, %2 \\n\\t\"\n\"movq %%mm5, %3 \\n\\t\"\n:\"+m\"(*(uint64_t*)(VAR_0+0*VAR_2)),\n\"+m\"(*(uint64_t*)(VAR_0+1*VAR_2)),\n\"+m\"(*(uint64_t*)(VAR_0+2*VAR_2)),\n\"+m\"(*(uint64_t*)(VAR_0+3*VAR_2))\n);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13,
15,
17,
19,
21,
23,
25
],
[
27
],
[
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71
],
[
73
],
[
75
]
] |
24,397 | static int movie_get_frame(AVFilterLink *outlink)
{
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, frame_decoded;
AVStream *st = movie->format_ctx->streams[movie->stream_index];
if (movie->is_done == 1)
return 0;
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
// Is this a packet from the video stream?
if (pkt.stream_index == movie->stream_index) {
avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
if (frame_decoded) {
/* FIXME: avoid the memcpy */
movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE2, outlink->w, outlink->h);
av_image_copy(movie->picref->data, movie->picref->linesize,
(void*)movie->frame->data, movie->frame->linesize,
movie->picref->format, outlink->w, outlink->h);
avfilter_copy_frame_props(movie->picref, movie->frame);
/* FIXME: use a PTS correction mechanism as that in
* ffplay.c when some API will be available for that */
/* use pkt_dts if pkt_pts is not available */
movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
movie->frame->pkt_dts : movie->frame->pkt_pts;
if (!movie->frame->sample_aspect_ratio.num)
movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
av_dlog(outlink->src,
"movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
movie->file_name, movie->picref->pts,
(double)movie->picref->pts * av_q2d(st->time_base),
movie->picref->pos,
movie->picref->video->sample_aspect_ratio.num,
movie->picref->video->sample_aspect_ratio.den);
// We got it. Free the packet since we are returning
av_free_packet(&pkt);
return 0;
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&pkt);
}
// On multi-frame source we should stop the mixing process when
// the movie source does not have more frames
if (ret == AVERROR_EOF)
movie->is_done = 1;
return ret;
}
| false | FFmpeg | d19d52d4a11547cc70bcbc3a2f8b83ccd24bb951 | static int movie_get_frame(AVFilterLink *outlink)
{
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, frame_decoded;
AVStream *st = movie->format_ctx->streams[movie->stream_index];
if (movie->is_done == 1)
return 0;
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
if (pkt.stream_index == movie->stream_index) {
avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
if (frame_decoded) {
movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE2, outlink->w, outlink->h);
av_image_copy(movie->picref->data, movie->picref->linesize,
(void*)movie->frame->data, movie->frame->linesize,
movie->picref->format, outlink->w, outlink->h);
avfilter_copy_frame_props(movie->picref, movie->frame);
movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
movie->frame->pkt_dts : movie->frame->pkt_pts;
if (!movie->frame->sample_aspect_ratio.num)
movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
av_dlog(outlink->src,
"movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
movie->file_name, movie->picref->pts,
(double)movie->picref->pts * av_q2d(st->time_base),
movie->picref->pos,
movie->picref->video->sample_aspect_ratio.num,
movie->picref->video->sample_aspect_ratio.den);
av_free_packet(&pkt);
return 0;
}
}
av_free_packet(&pkt);
}
if (ret == AVERROR_EOF)
movie->is_done = 1;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0)
{
MovieContext *movie = VAR_0->src->priv;
AVPacket pkt;
int VAR_1, VAR_2;
AVStream *st = movie->format_ctx->streams[movie->stream_index];
if (movie->is_done == 1)
return 0;
while ((VAR_1 = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
if (pkt.stream_index == movie->stream_index) {
avcodec_decode_video2(movie->codec_ctx, movie->frame, &VAR_2, &pkt);
if (VAR_2) {
movie->picref = avfilter_get_video_buffer(VAR_0, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE2, VAR_0->w, VAR_0->h);
av_image_copy(movie->picref->data, movie->picref->linesize,
(void*)movie->frame->data, movie->frame->linesize,
movie->picref->format, VAR_0->w, VAR_0->h);
avfilter_copy_frame_props(movie->picref, movie->frame);
movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
movie->frame->pkt_dts : movie->frame->pkt_pts;
if (!movie->frame->sample_aspect_ratio.num)
movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
av_dlog(VAR_0->src,
"FUNC_0(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
movie->file_name, movie->picref->pts,
(double)movie->picref->pts * av_q2d(st->time_base),
movie->picref->pos,
movie->picref->video->sample_aspect_ratio.num,
movie->picref->video->sample_aspect_ratio.den);
av_free_packet(&pkt);
return 0;
}
}
av_free_packet(&pkt);
}
if (VAR_1 == AVERROR_EOF)
movie->is_done = 1;
return VAR_1;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"MovieContext *movie = VAR_0->src->priv;",
"AVPacket pkt;",
"int VAR_1, VAR_2;",
"AVStream *st = movie->format_ctx->streams[movie->stream_index];",
"if (movie->is_done == 1)\nreturn 0;",
"while ((VAR_1 = av_read_frame(movie->format_ctx, &pkt)) >= 0) {",
"if (pkt.stream_index == movie->stream_index) {",
"avcodec_decode_video2(movie->codec_ctx, movie->frame, &VAR_2, &pkt);",
"if (VAR_2) {",
"movie->picref = avfilter_get_video_buffer(VAR_0, AV_PERM_WRITE | AV_PERM_PRESERVE |\nAV_PERM_REUSE2, VAR_0->w, VAR_0->h);",
"av_image_copy(movie->picref->data, movie->picref->linesize,\n(void*)movie->frame->data, movie->frame->linesize,\nmovie->picref->format, VAR_0->w, VAR_0->h);",
"avfilter_copy_frame_props(movie->picref, movie->frame);",
"movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?\nmovie->frame->pkt_dts : movie->frame->pkt_pts;",
"if (!movie->frame->sample_aspect_ratio.num)\nmovie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;",
"av_dlog(VAR_0->src,\n\"FUNC_0(): file:'%s' pts:%\"PRId64\" time:%lf pos:%\"PRId64\" aspect:%d/%d\\n\",\nmovie->file_name, movie->picref->pts,\n(double)movie->picref->pts * av_q2d(st->time_base),\nmovie->picref->pos,\nmovie->picref->video->sample_aspect_ratio.num,\nmovie->picref->video->sample_aspect_ratio.den);",
"av_free_packet(&pkt);",
"return 0;",
"}",
"}",
"av_free_packet(&pkt);",
"}",
"if (VAR_1 == AVERROR_EOF)\nmovie->is_done = 1;",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
35,
37
],
[
39,
41,
43
],
[
45
],
[
55,
57
],
[
61,
63
],
[
65,
67,
69,
71,
73,
75,
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
103,
105
],
[
107
],
[
109
]
] |
24,399 | static void do_io_interrupt(CPUS390XState *env)
{
S390CPU *cpu = s390_env_get_cpu(env);
LowCore *lowcore;
IOIntQueue *q;
uint8_t isc;
int disable = 1;
int found = 0;
if (!(env->psw.mask & PSW_MASK_IO)) {
cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n");
}
for (isc = 0; isc < ARRAY_SIZE(env->io_index); isc++) {
uint64_t isc_bits;
if (env->io_index[isc] < 0) {
continue;
}
if (env->io_index[isc] > MAX_IO_QUEUE) {
cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n",
isc, env->io_index[isc]);
}
q = &env->io_queue[env->io_index[isc]][isc];
isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word));
if (!(env->cregs[6] & isc_bits)) {
disable = 0;
continue;
}
if (!found) {
uint64_t mask, addr;
found = 1;
lowcore = cpu_map_lowcore(env);
lowcore->subchannel_id = cpu_to_be16(q->id);
lowcore->subchannel_nr = cpu_to_be16(q->nr);
lowcore->io_int_parm = cpu_to_be32(q->parm);
lowcore->io_int_word = cpu_to_be32(q->word);
lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(env));
lowcore->io_old_psw.addr = cpu_to_be64(env->psw.addr);
mask = be64_to_cpu(lowcore->io_new_psw.mask);
addr = be64_to_cpu(lowcore->io_new_psw.addr);
cpu_unmap_lowcore(lowcore);
env->io_index[isc]--;
DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
env->psw.mask, env->psw.addr);
load_psw(env, mask, addr);
}
if (env->io_index[isc] >= 0) {
disable = 0;
}
continue;
}
if (disable) {
env->pending_int &= ~INTERRUPT_IO;
}
}
| true | qemu | 1a71992376792a0d11ea27688bd1a21cdffd1826 | static void do_io_interrupt(CPUS390XState *env)
{
S390CPU *cpu = s390_env_get_cpu(env);
LowCore *lowcore;
IOIntQueue *q;
uint8_t isc;
int disable = 1;
int found = 0;
if (!(env->psw.mask & PSW_MASK_IO)) {
cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n");
}
for (isc = 0; isc < ARRAY_SIZE(env->io_index); isc++) {
uint64_t isc_bits;
if (env->io_index[isc] < 0) {
continue;
}
if (env->io_index[isc] > MAX_IO_QUEUE) {
cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n",
isc, env->io_index[isc]);
}
q = &env->io_queue[env->io_index[isc]][isc];
isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word));
if (!(env->cregs[6] & isc_bits)) {
disable = 0;
continue;
}
if (!found) {
uint64_t mask, addr;
found = 1;
lowcore = cpu_map_lowcore(env);
lowcore->subchannel_id = cpu_to_be16(q->id);
lowcore->subchannel_nr = cpu_to_be16(q->nr);
lowcore->io_int_parm = cpu_to_be32(q->parm);
lowcore->io_int_word = cpu_to_be32(q->word);
lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(env));
lowcore->io_old_psw.addr = cpu_to_be64(env->psw.addr);
mask = be64_to_cpu(lowcore->io_new_psw.mask);
addr = be64_to_cpu(lowcore->io_new_psw.addr);
cpu_unmap_lowcore(lowcore);
env->io_index[isc]--;
DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
env->psw.mask, env->psw.addr);
load_psw(env, mask, addr);
}
if (env->io_index[isc] >= 0) {
disable = 0;
}
continue;
}
if (disable) {
env->pending_int &= ~INTERRUPT_IO;
}
}
| {
"code": [
" if (env->io_index[isc] > MAX_IO_QUEUE) {"
],
"line_no": [
39
]
} | static void FUNC_0(CPUS390XState *VAR_0)
{
S390CPU *cpu = s390_env_get_cpu(VAR_0);
LowCore *lowcore;
IOIntQueue *q;
uint8_t isc;
int VAR_1 = 1;
int VAR_2 = 0;
if (!(VAR_0->psw.mask & PSW_MASK_IO)) {
cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n");
}
for (isc = 0; isc < ARRAY_SIZE(VAR_0->io_index); isc++) {
uint64_t isc_bits;
if (VAR_0->io_index[isc] < 0) {
continue;
}
if (VAR_0->io_index[isc] > MAX_IO_QUEUE) {
cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n",
isc, VAR_0->io_index[isc]);
}
q = &VAR_0->io_queue[VAR_0->io_index[isc]][isc];
isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word));
if (!(VAR_0->cregs[6] & isc_bits)) {
VAR_1 = 0;
continue;
}
if (!VAR_2) {
uint64_t mask, addr;
VAR_2 = 1;
lowcore = cpu_map_lowcore(VAR_0);
lowcore->subchannel_id = cpu_to_be16(q->id);
lowcore->subchannel_nr = cpu_to_be16(q->nr);
lowcore->io_int_parm = cpu_to_be32(q->parm);
lowcore->io_int_word = cpu_to_be32(q->word);
lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(VAR_0));
lowcore->io_old_psw.addr = cpu_to_be64(VAR_0->psw.addr);
mask = be64_to_cpu(lowcore->io_new_psw.mask);
addr = be64_to_cpu(lowcore->io_new_psw.addr);
cpu_unmap_lowcore(lowcore);
VAR_0->io_index[isc]--;
DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
VAR_0->psw.mask, VAR_0->psw.addr);
load_psw(VAR_0, mask, addr);
}
if (VAR_0->io_index[isc] >= 0) {
VAR_1 = 0;
}
continue;
}
if (VAR_1) {
VAR_0->pending_int &= ~INTERRUPT_IO;
}
}
| [
"static void FUNC_0(CPUS390XState *VAR_0)\n{",
"S390CPU *cpu = s390_env_get_cpu(VAR_0);",
"LowCore *lowcore;",
"IOIntQueue *q;",
"uint8_t isc;",
"int VAR_1 = 1;",
"int VAR_2 = 0;",
"if (!(VAR_0->psw.mask & PSW_MASK_IO)) {",
"cpu_abort(CPU(cpu), \"I/O int w/o I/O mask\\n\");",
"}",
"for (isc = 0; isc < ARRAY_SIZE(VAR_0->io_index); isc++) {",
"uint64_t isc_bits;",
"if (VAR_0->io_index[isc] < 0) {",
"continue;",
"}",
"if (VAR_0->io_index[isc] > MAX_IO_QUEUE) {",
"cpu_abort(CPU(cpu), \"I/O queue overrun for isc %d: %d\\n\",\nisc, VAR_0->io_index[isc]);",
"}",
"q = &VAR_0->io_queue[VAR_0->io_index[isc]][isc];",
"isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word));",
"if (!(VAR_0->cregs[6] & isc_bits)) {",
"VAR_1 = 0;",
"continue;",
"}",
"if (!VAR_2) {",
"uint64_t mask, addr;",
"VAR_2 = 1;",
"lowcore = cpu_map_lowcore(VAR_0);",
"lowcore->subchannel_id = cpu_to_be16(q->id);",
"lowcore->subchannel_nr = cpu_to_be16(q->nr);",
"lowcore->io_int_parm = cpu_to_be32(q->parm);",
"lowcore->io_int_word = cpu_to_be32(q->word);",
"lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(VAR_0));",
"lowcore->io_old_psw.addr = cpu_to_be64(VAR_0->psw.addr);",
"mask = be64_to_cpu(lowcore->io_new_psw.mask);",
"addr = be64_to_cpu(lowcore->io_new_psw.addr);",
"cpu_unmap_lowcore(lowcore);",
"VAR_0->io_index[isc]--;",
"DPRINTF(\"%s: %\" PRIx64 \" %\" PRIx64 \"\\n\", __func__,\nVAR_0->psw.mask, VAR_0->psw.addr);",
"load_psw(VAR_0, mask, addr);",
"}",
"if (VAR_0->io_index[isc] >= 0) {",
"VAR_1 = 0;",
"}",
"continue;",
"}",
"if (VAR_1) {",
"VAR_0->pending_int &= ~INTERRUPT_IO;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
]
] |
24,401 | static int rtp_new_av_stream(HTTPContext *c,
int stream_index, struct sockaddr_in *dest_addr,
HTTPContext *rtsp_c)
{
AVFormatContext *ctx;
AVStream *st;
char *ipaddr;
URLContext *h = NULL;
uint8_t *dummy_buf;
int max_packet_size;
/* now we can open the relevant output stream */
ctx = avformat_alloc_context();
if (!ctx)
return -1;
ctx->oformat = av_guess_format("rtp", NULL, NULL);
st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
st->codec= avcodec_alloc_context();
ctx->nb_streams = 1;
ctx->streams[0] = st;
if (!c->stream->feed ||
c->stream->feed == c->stream)
memcpy(st, c->stream->streams[stream_index], sizeof(AVStream));
else
memcpy(st,
c->stream->feed->streams[c->stream->feed_streams[stream_index]],
sizeof(AVStream));
st->priv_data = NULL;
/* build destination RTP address */
ipaddr = inet_ntoa(dest_addr->sin_addr);
switch(c->rtp_protocol) {
case RTSP_LOWER_TRANSPORT_UDP:
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
/* RTP/UDP case */
/* XXX: also pass as parameter to function ? */
if (c->stream->is_multicast) {
int ttl;
ttl = c->stream->multicast_ttl;
if (!ttl)
ttl = 16;
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp://%s:%d?multicast=1&ttl=%d",
ipaddr, ntohs(dest_addr->sin_port), ttl);
} else {
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port));
}
if (url_open(&h, ctx->filename, URL_WRONLY) < 0)
goto fail;
c->rtp_handles[stream_index] = h;
max_packet_size = url_get_max_packet_size(h);
break;
case RTSP_LOWER_TRANSPORT_TCP:
/* RTP/TCP case */
c->rtsp_c = rtsp_c;
max_packet_size = RTSP_TCP_MAX_PACKET_SIZE;
break;
default:
goto fail;
}
http_log("%s:%d - - \"PLAY %s/streamid=%d %s\"\n",
ipaddr, ntohs(dest_addr->sin_port),
c->stream->filename, stream_index, c->protocol);
/* normally, no packets should be output here, but the packet size may be checked */
if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) {
/* XXX: close stream */
goto fail;
}
av_set_parameters(ctx, NULL);
if (av_write_header(ctx) < 0) {
fail:
if (h)
url_close(h);
av_free(ctx);
return -1;
}
url_close_dyn_buf(ctx->pb, &dummy_buf);
av_free(dummy_buf);
c->rtp_ctx[stream_index] = ctx;
return 0;
}
| true | FFmpeg | 9cc9a155100d4364ad02d50e89b313ec94195102 | static int rtp_new_av_stream(HTTPContext *c,
int stream_index, struct sockaddr_in *dest_addr,
HTTPContext *rtsp_c)
{
AVFormatContext *ctx;
AVStream *st;
char *ipaddr;
URLContext *h = NULL;
uint8_t *dummy_buf;
int max_packet_size;
ctx = avformat_alloc_context();
if (!ctx)
return -1;
ctx->oformat = av_guess_format("rtp", NULL, NULL);
st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
st->codec= avcodec_alloc_context();
ctx->nb_streams = 1;
ctx->streams[0] = st;
if (!c->stream->feed ||
c->stream->feed == c->stream)
memcpy(st, c->stream->streams[stream_index], sizeof(AVStream));
else
memcpy(st,
c->stream->feed->streams[c->stream->feed_streams[stream_index]],
sizeof(AVStream));
st->priv_data = NULL;
ipaddr = inet_ntoa(dest_addr->sin_addr);
switch(c->rtp_protocol) {
case RTSP_LOWER_TRANSPORT_UDP:
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
if (c->stream->is_multicast) {
int ttl;
ttl = c->stream->multicast_ttl;
if (!ttl)
ttl = 16;
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp:
ipaddr, ntohs(dest_addr->sin_port), ttl);
} else {
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp:
}
if (url_open(&h, ctx->filename, URL_WRONLY) < 0)
goto fail;
c->rtp_handles[stream_index] = h;
max_packet_size = url_get_max_packet_size(h);
break;
case RTSP_LOWER_TRANSPORT_TCP:
c->rtsp_c = rtsp_c;
max_packet_size = RTSP_TCP_MAX_PACKET_SIZE;
break;
default:
goto fail;
}
http_log("%s:%d - - \"PLAY %s/streamid=%d %s\"\n",
ipaddr, ntohs(dest_addr->sin_port),
c->stream->filename, stream_index, c->protocol);
if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) {
goto fail;
}
av_set_parameters(ctx, NULL);
if (av_write_header(ctx) < 0) {
fail:
if (h)
url_close(h);
av_free(ctx);
return -1;
}
url_close_dyn_buf(ctx->pb, &dummy_buf);
av_free(dummy_buf);
c->rtp_ctx[stream_index] = ctx;
return 0;
}
| {
"code": [
" st->codec= avcodec_alloc_context();"
],
"line_no": [
41
]
} | static int FUNC_0(HTTPContext *VAR_0,
int VAR_1, struct sockaddr_in *VAR_2,
HTTPContext *VAR_3)
{
AVFormatContext *ctx;
AVStream *st;
char *VAR_4;
URLContext *h = NULL;
uint8_t *dummy_buf;
int VAR_5;
ctx = avformat_alloc_context();
if (!ctx)
return -1;
ctx->oformat = av_guess_format("rtp", NULL, NULL);
st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
st->codec= avcodec_alloc_context();
ctx->nb_streams = 1;
ctx->streams[0] = st;
if (!VAR_0->stream->feed ||
VAR_0->stream->feed == VAR_0->stream)
memcpy(st, VAR_0->stream->streams[VAR_1], sizeof(AVStream));
else
memcpy(st,
VAR_0->stream->feed->streams[VAR_0->stream->feed_streams[VAR_1]],
sizeof(AVStream));
st->priv_data = NULL;
VAR_4 = inet_ntoa(VAR_2->sin_addr);
switch(VAR_0->rtp_protocol) {
case RTSP_LOWER_TRANSPORT_UDP:
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
if (VAR_0->stream->is_multicast) {
int VAR_6;
VAR_6 = VAR_0->stream->multicast_ttl;
if (!VAR_6)
VAR_6 = 16;
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp:
VAR_4, ntohs(VAR_2->sin_port), VAR_6);
} else {
snprintf(ctx->filename, sizeof(ctx->filename),
"rtp:
}
if (url_open(&h, ctx->filename, URL_WRONLY) < 0)
goto fail;
VAR_0->rtp_handles[VAR_1] = h;
VAR_5 = url_get_max_packet_size(h);
break;
case RTSP_LOWER_TRANSPORT_TCP:
VAR_0->VAR_3 = VAR_3;
VAR_5 = RTSP_TCP_MAX_PACKET_SIZE;
break;
default:
goto fail;
}
http_log("%s:%d - - \"PLAY %s/streamid=%d %s\"\n",
VAR_4, ntohs(VAR_2->sin_port),
VAR_0->stream->filename, VAR_1, VAR_0->protocol);
if (url_open_dyn_packet_buf(&ctx->pb, VAR_5) < 0) {
goto fail;
}
av_set_parameters(ctx, NULL);
if (av_write_header(ctx) < 0) {
fail:
if (h)
url_close(h);
av_free(ctx);
return -1;
}
url_close_dyn_buf(ctx->pb, &dummy_buf);
av_free(dummy_buf);
VAR_0->rtp_ctx[VAR_1] = ctx;
return 0;
}
| [
"static int FUNC_0(HTTPContext *VAR_0,\nint VAR_1, struct sockaddr_in *VAR_2,\nHTTPContext *VAR_3)\n{",
"AVFormatContext *ctx;",
"AVStream *st;",
"char *VAR_4;",
"URLContext *h = NULL;",
"uint8_t *dummy_buf;",
"int VAR_5;",
"ctx = avformat_alloc_context();",
"if (!ctx)\nreturn -1;",
"ctx->oformat = av_guess_format(\"rtp\", NULL, NULL);",
"st = av_mallocz(sizeof(AVStream));",
"if (!st)\ngoto fail;",
"st->codec= avcodec_alloc_context();",
"ctx->nb_streams = 1;",
"ctx->streams[0] = st;",
"if (!VAR_0->stream->feed ||\nVAR_0->stream->feed == VAR_0->stream)\nmemcpy(st, VAR_0->stream->streams[VAR_1], sizeof(AVStream));",
"else\nmemcpy(st,\nVAR_0->stream->feed->streams[VAR_0->stream->feed_streams[VAR_1]],\nsizeof(AVStream));",
"st->priv_data = NULL;",
"VAR_4 = inet_ntoa(VAR_2->sin_addr);",
"switch(VAR_0->rtp_protocol) {",
"case RTSP_LOWER_TRANSPORT_UDP:\ncase RTSP_LOWER_TRANSPORT_UDP_MULTICAST:\nif (VAR_0->stream->is_multicast) {",
"int VAR_6;",
"VAR_6 = VAR_0->stream->multicast_ttl;",
"if (!VAR_6)\nVAR_6 = 16;",
"snprintf(ctx->filename, sizeof(ctx->filename),\n\"rtp:\nVAR_4, ntohs(VAR_2->sin_port), VAR_6);",
"} else {",
"snprintf(ctx->filename, sizeof(ctx->filename),\n\"rtp:\n}",
"if (url_open(&h, ctx->filename, URL_WRONLY) < 0)\ngoto fail;",
"VAR_0->rtp_handles[VAR_1] = h;",
"VAR_5 = url_get_max_packet_size(h);",
"break;",
"case RTSP_LOWER_TRANSPORT_TCP:\nVAR_0->VAR_3 = VAR_3;",
"VAR_5 = RTSP_TCP_MAX_PACKET_SIZE;",
"break;",
"default:\ngoto fail;",
"}",
"http_log(\"%s:%d - - \\\"PLAY %s/streamid=%d %s\\\"\\n\",\nVAR_4, ntohs(VAR_2->sin_port),\nVAR_0->stream->filename, VAR_1, VAR_0->protocol);",
"if (url_open_dyn_packet_buf(&ctx->pb, VAR_5) < 0) {",
"goto fail;",
"}",
"av_set_parameters(ctx, NULL);",
"if (av_write_header(ctx) < 0) {",
"fail:\nif (h)\nurl_close(h);",
"av_free(ctx);",
"return -1;",
"}",
"url_close_dyn_buf(ctx->pb, &dummy_buf);",
"av_free(dummy_buf);",
"VAR_0->rtp_ctx[VAR_1] = ctx;",
"return 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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53
],
[
55,
57,
59,
61
],
[
63
],
[
69
],
[
73
],
[
75,
77,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97,
99
],
[
101
],
[
103,
105,
107
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
139,
141,
143
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
]
] |
24,402 | void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp)
{
unix_nonblocking_connect(path, unix_wait_for_connect, s, errp);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp)
{
unix_nonblocking_connect(path, unix_wait_for_connect, s, errp);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2)
{
unix_nonblocking_connect(VAR_1, unix_wait_for_connect, VAR_0, VAR_2);
}
| [
"void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"unix_nonblocking_connect(VAR_1, unix_wait_for_connect, VAR_0, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,403 | static void *mptsas_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
MPTSASState *s = container_of(bus, MPTSASState, bus);
PCIDevice *pci = PCI_DEVICE(s);
MPTSASRequest *req;
int i, n;
req = g_new(MPTSASRequest, 1);
qemu_get_buffer(f, (unsigned char *)&req->scsi_io, sizeof(req->scsi_io));
n = qemu_get_be32(f);
/* TODO: add a way for SCSIBusInfo's load_request to fail,
* and fail migration instead of asserting here.
* When we do, we might be able to re-enable NDEBUG below.
*/
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(n >= 0);
pci_dma_sglist_init(&req->qsg, pci, n);
for (i = 0; i < n; i++) {
uint64_t base = qemu_get_be64(f);
uint64_t len = qemu_get_be64(f);
qemu_sglist_add(&req->qsg, base, len);
}
scsi_req_ref(sreq);
req->sreq = sreq;
req->dev = s;
return req;
}
| true | qemu | 262a69f4282e44426c7a132138581d400053e0a1 | static void *mptsas_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
MPTSASState *s = container_of(bus, MPTSASState, bus);
PCIDevice *pci = PCI_DEVICE(s);
MPTSASRequest *req;
int i, n;
req = g_new(MPTSASRequest, 1);
qemu_get_buffer(f, (unsigned char *)&req->scsi_io, sizeof(req->scsi_io));
n = qemu_get_be32(f);
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(n >= 0);
pci_dma_sglist_init(&req->qsg, pci, n);
for (i = 0; i < n; i++) {
uint64_t base = qemu_get_be64(f);
uint64_t len = qemu_get_be64(f);
qemu_sglist_add(&req->qsg, base, len);
}
scsi_req_ref(sreq);
req->sreq = sreq;
req->dev = s;
return req;
}
| {
"code": [
"#ifdef NDEBUG",
"#error building with NDEBUG is not supported",
"#endif",
"#ifdef NDEBUG",
"#error building with NDEBUG is not supported",
"#endif"
],
"line_no": [
33,
35,
37,
33,
35,
37
]
} | static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)
{
SCSIBus *bus = VAR_1->bus;
MPTSASState *s = container_of(bus, MPTSASState, bus);
PCIDevice *pci = PCI_DEVICE(s);
MPTSASRequest *req;
int VAR_2, VAR_3;
req = g_new(MPTSASRequest, 1);
qemu_get_buffer(VAR_0, (unsigned char *)&req->scsi_io, sizeof(req->scsi_io));
VAR_3 = qemu_get_be32(VAR_0);
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(VAR_3 >= 0);
pci_dma_sglist_init(&req->qsg, pci, VAR_3);
for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {
uint64_t base = qemu_get_be64(VAR_0);
uint64_t len = qemu_get_be64(VAR_0);
qemu_sglist_add(&req->qsg, base, len);
}
scsi_req_ref(VAR_1);
req->VAR_1 = VAR_1;
req->dev = s;
return req;
}
| [
"static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)\n{",
"SCSIBus *bus = VAR_1->bus;",
"MPTSASState *s = container_of(bus, MPTSASState, bus);",
"PCIDevice *pci = PCI_DEVICE(s);",
"MPTSASRequest *req;",
"int VAR_2, VAR_3;",
"req = g_new(MPTSASRequest, 1);",
"qemu_get_buffer(VAR_0, (unsigned char *)&req->scsi_io, sizeof(req->scsi_io));",
"VAR_3 = qemu_get_be32(VAR_0);",
"#ifdef NDEBUG\n#error building with NDEBUG is not supported\n#endif\nassert(VAR_3 >= 0);",
"pci_dma_sglist_init(&req->qsg, pci, VAR_3);",
"for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {",
"uint64_t base = qemu_get_be64(VAR_0);",
"uint64_t len = qemu_get_be64(VAR_0);",
"qemu_sglist_add(&req->qsg, base, len);",
"}",
"scsi_req_ref(VAR_1);",
"req->VAR_1 = VAR_1;",
"req->dev = s;",
"return req;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
33,
35,
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
24,404 | static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
ff_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
ff_dlog(avctx, "\n");
}
if (i % 16)
ff_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
if (!clut)
return AVERROR(ENOMEM);
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
ff_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
}
| true | FFmpeg | 8a69f2602fea04b7ebae2db16f2581e8ff5ee0cd | static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
ff_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
ff_dlog(avctx, "\n");
}
if (i % 16)
ff_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
if (!clut)
return AVERROR(ENOMEM);
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
ff_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
}
| {
"code": [
" if (depth & 0x80)",
" else if (depth & 0x40)"
],
"line_no": [
173,
177
]
} | 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;
DVBSubCLUT *clut;
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, VAR_18, VAR_19;
ff_dlog(VAR_0, "DVB clut packet:\n");
for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) {
ff_dlog(VAR_0, "%02x ", VAR_1[VAR_4]);
if (VAR_4 % 16 == 15)
ff_dlog(VAR_0, "\n");
}
if (VAR_4 % 16)
ff_dlog(VAR_0, "\n");
VAR_5 = *VAR_1++;
VAR_6 = ((*VAR_1)>>4)&15;
VAR_1 += 1;
clut = get_clut(ctx, VAR_5);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
if (!clut)
return AVERROR(ENOMEM);
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = VAR_5;
clut->VAR_6 = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->VAR_6 != VAR_6) {
clut->VAR_6 = VAR_6;
while (VAR_1 + 4 < VAR_3) {
VAR_7 = *VAR_1++;
VAR_8 = (*VAR_1) & 0xe0;
if (VAR_8 == 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid clut VAR_8 0x%x!\n", *VAR_1);
}
VAR_9 = (*VAR_1++) & 1;
if (VAR_9) {
VAR_10 = *VAR_1++;
VAR_11 = *VAR_1++;
VAR_12 = *VAR_1++;
VAR_13 = *VAR_1++;
} else {
VAR_10 = VAR_1[0] & 0xfc;
VAR_11 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4;
VAR_12 = (VAR_1[1] << 2) & 0xf0;
VAR_13 = (VAR_1[1] << 6) & 0xc0;
VAR_1 += 2;
}
if (VAR_10 == 0)
VAR_13 = 0xff;
YUV_TO_RGB1_CCIR(VAR_12, VAR_11);
YUV_TO_RGB2_CCIR(VAR_14, VAR_15, VAR_16, VAR_10);
ff_dlog(VAR_0, "clut %d := (%d,%d,%d,%d)\n", VAR_7, VAR_14, VAR_15, VAR_16, VAR_13);
if (!!(VAR_8 & 0x80) + !!(VAR_8 & 0x40) + !!(VAR_8 & 0x20) > 1) {
ff_dlog(VAR_0, "More than one bit level marked: %x\n", VAR_8);
if (VAR_0->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (VAR_8 & 0x80)
clut->clut4[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
else if (VAR_8 & 0x40)
clut->clut16[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
else if (VAR_8 & 0x20)
clut->clut256[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
}
}
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;",
"DVBSubCLUT *clut;",
"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, VAR_18, VAR_19;",
"ff_dlog(VAR_0, \"DVB clut packet:\\n\");",
"for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) {",
"ff_dlog(VAR_0, \"%02x \", VAR_1[VAR_4]);",
"if (VAR_4 % 16 == 15)\nff_dlog(VAR_0, \"\\n\");",
"}",
"if (VAR_4 % 16)\nff_dlog(VAR_0, \"\\n\");",
"VAR_5 = *VAR_1++;",
"VAR_6 = ((*VAR_1)>>4)&15;",
"VAR_1 += 1;",
"clut = get_clut(ctx, VAR_5);",
"if (!clut) {",
"clut = av_malloc(sizeof(DVBSubCLUT));",
"if (!clut)\nreturn AVERROR(ENOMEM);",
"memcpy(clut, &default_clut, sizeof(DVBSubCLUT));",
"clut->id = VAR_5;",
"clut->VAR_6 = -1;",
"clut->next = ctx->clut_list;",
"ctx->clut_list = clut;",
"}",
"if (clut->VAR_6 != VAR_6) {",
"clut->VAR_6 = VAR_6;",
"while (VAR_1 + 4 < VAR_3) {",
"VAR_7 = *VAR_1++;",
"VAR_8 = (*VAR_1) & 0xe0;",
"if (VAR_8 == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid clut VAR_8 0x%x!\\n\", *VAR_1);",
"}",
"VAR_9 = (*VAR_1++) & 1;",
"if (VAR_9) {",
"VAR_10 = *VAR_1++;",
"VAR_11 = *VAR_1++;",
"VAR_12 = *VAR_1++;",
"VAR_13 = *VAR_1++;",
"} else {",
"VAR_10 = VAR_1[0] & 0xfc;",
"VAR_11 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4;",
"VAR_12 = (VAR_1[1] << 2) & 0xf0;",
"VAR_13 = (VAR_1[1] << 6) & 0xc0;",
"VAR_1 += 2;",
"}",
"if (VAR_10 == 0)\nVAR_13 = 0xff;",
"YUV_TO_RGB1_CCIR(VAR_12, VAR_11);",
"YUV_TO_RGB2_CCIR(VAR_14, VAR_15, VAR_16, VAR_10);",
"ff_dlog(VAR_0, \"clut %d := (%d,%d,%d,%d)\\n\", VAR_7, VAR_14, VAR_15, VAR_16, VAR_13);",
"if (!!(VAR_8 & 0x80) + !!(VAR_8 & 0x40) + !!(VAR_8 & 0x20) > 1) {",
"ff_dlog(VAR_0, \"More than one bit level marked: %x\\n\", VAR_8);",
"if (VAR_0->strict_std_compliance > FF_COMPLIANCE_NORMAL)\nreturn AVERROR_INVALIDDATA;",
"}",
"if (VAR_8 & 0x80)\nclut->clut4[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"else if (VAR_8 & 0x40)\nclut->clut16[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"else if (VAR_8 & 0x20)\nclut->clut256[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"}",
"}",
"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,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65,
67
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
97
],
[
99
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147,
149
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
173,
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
187
],
[
191
],
[
193
]
] |
24,405 | VLANClientState *qemu_new_vlan_client(VLANState *vlan,
IOReadHandler *fd_read, void *opaque)
{
VLANClientState *vc, **pvc;
vc = qemu_mallocz(sizeof(VLANClientState));
if (!vc)
return NULL;
vc->fd_read = fd_read;
vc->opaque = opaque;
vc->vlan = vlan;
vc->next = NULL;
pvc = &vlan->first_client;
while (*pvc != NULL)
pvc = &(*pvc)->next;
*pvc = vc;
return vc;
}
| true | qemu | d861b05ea30e6ac177de9b679da96194ebe21afc | VLANClientState *qemu_new_vlan_client(VLANState *vlan,
IOReadHandler *fd_read, void *opaque)
{
VLANClientState *vc, **pvc;
vc = qemu_mallocz(sizeof(VLANClientState));
if (!vc)
return NULL;
vc->fd_read = fd_read;
vc->opaque = opaque;
vc->vlan = vlan;
vc->next = NULL;
pvc = &vlan->first_client;
while (*pvc != NULL)
pvc = &(*pvc)->next;
*pvc = vc;
return vc;
}
| {
"code": [
" IOReadHandler *fd_read, void *opaque)"
],
"line_no": [
3
]
} | VLANClientState *FUNC_0(VLANState *vlan,
IOReadHandler *fd_read, void *opaque)
{
VLANClientState *vc, **pvc;
vc = qemu_mallocz(sizeof(VLANClientState));
if (!vc)
return NULL;
vc->fd_read = fd_read;
vc->opaque = opaque;
vc->vlan = vlan;
vc->next = NULL;
pvc = &vlan->first_client;
while (*pvc != NULL)
pvc = &(*pvc)->next;
*pvc = vc;
return vc;
}
| [
"VLANClientState *FUNC_0(VLANState *vlan,\nIOReadHandler *fd_read, void *opaque)\n{",
"VLANClientState *vc, **pvc;",
"vc = qemu_mallocz(sizeof(VLANClientState));",
"if (!vc)\nreturn NULL;",
"vc->fd_read = fd_read;",
"vc->opaque = opaque;",
"vc->vlan = vlan;",
"vc->next = NULL;",
"pvc = &vlan->first_client;",
"while (*pvc != NULL)\npvc = &(*pvc)->next;",
"*pvc = vc;",
"return vc;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
]
] |
24,406 | static void unterminated_escape(void)
{
QObject *obj = qobject_from_json("\"abc\\\"", NULL);
g_assert(obj == NULL);
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void unterminated_escape(void)
{
QObject *obj = qobject_from_json("\"abc\\\"", NULL);
g_assert(obj == NULL);
}
| {
"code": [
" QObject *obj = qobject_from_json(\"\\\"abc\\\\\\\"\", NULL);"
],
"line_no": [
5
]
} | static void FUNC_0(void)
{
QObject *obj = qobject_from_json("\"abc\\\"", NULL);
g_assert(obj == NULL);
}
| [
"static void FUNC_0(void)\n{",
"QObject *obj = qobject_from_json(\"\\\"abc\\\\\\\"\", NULL);",
"g_assert(obj == NULL);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,407 | struct omap_gpmc_s *omap_gpmc_init(struct omap_mpu_state_s *mpu,
hwaddr base,
qemu_irq irq, qemu_irq drq)
{
int cs;
struct omap_gpmc_s *s = (struct omap_gpmc_s *)
g_malloc0(sizeof(struct omap_gpmc_s));
memory_region_init_io(&s->iomem, NULL, &omap_gpmc_ops, s, "omap-gpmc", 0x1000);
memory_region_add_subregion(get_system_memory(), base, &s->iomem);
s->irq = irq;
s->drq = drq;
s->accept_256 = cpu_is_omap3630(mpu);
s->revision = cpu_class_omap3(mpu) ? 0x50 : 0x20;
s->lastirq = 0;
omap_gpmc_reset(s);
/* We have to register a different IO memory handler for each
* chip select region in case a NAND device is mapped there. We
* make the region the worst-case size of 256MB and rely on the
* container memory region in cs_map to chop it down to the actual
* guest-requested size.
*/
for (cs = 0; cs < 8; cs++) {
memory_region_init_io(&s->cs_file[cs].nandiomem, NULL,
&omap_nand_ops,
&s->cs_file[cs],
"omap-nand",
256 * 1024 * 1024);
}
memory_region_init_io(&s->prefetch.iomem, NULL, &omap_prefetch_ops, s,
"omap-gpmc-prefetch", 256 * 1024 * 1024);
return s;
}
| true | qemu | b45c03f585ea9bb1af76c73e82195418c294919d | struct omap_gpmc_s *omap_gpmc_init(struct omap_mpu_state_s *mpu,
hwaddr base,
qemu_irq irq, qemu_irq drq)
{
int cs;
struct omap_gpmc_s *s = (struct omap_gpmc_s *)
g_malloc0(sizeof(struct omap_gpmc_s));
memory_region_init_io(&s->iomem, NULL, &omap_gpmc_ops, s, "omap-gpmc", 0x1000);
memory_region_add_subregion(get_system_memory(), base, &s->iomem);
s->irq = irq;
s->drq = drq;
s->accept_256 = cpu_is_omap3630(mpu);
s->revision = cpu_class_omap3(mpu) ? 0x50 : 0x20;
s->lastirq = 0;
omap_gpmc_reset(s);
for (cs = 0; cs < 8; cs++) {
memory_region_init_io(&s->cs_file[cs].nandiomem, NULL,
&omap_nand_ops,
&s->cs_file[cs],
"omap-nand",
256 * 1024 * 1024);
}
memory_region_init_io(&s->prefetch.iomem, NULL, &omap_prefetch_ops, s,
"omap-gpmc-prefetch", 256 * 1024 * 1024);
return s;
}
| {
"code": [
" struct omap_gpmc_s *s = (struct omap_gpmc_s *)",
" g_malloc0(sizeof(struct omap_gpmc_s));"
],
"line_no": [
11,
13
]
} | struct omap_gpmc_s *FUNC_0(struct omap_mpu_state_s *VAR_0,
hwaddr VAR_1,
qemu_irq VAR_2, qemu_irq VAR_3)
{
int VAR_4;
struct omap_gpmc_s *VAR_5 = (struct omap_gpmc_s *)
g_malloc0(sizeof(struct omap_gpmc_s));
memory_region_init_io(&VAR_5->iomem, NULL, &omap_gpmc_ops, VAR_5, "omap-gpmc", 0x1000);
memory_region_add_subregion(get_system_memory(), VAR_1, &VAR_5->iomem);
VAR_5->VAR_2 = VAR_2;
VAR_5->VAR_3 = VAR_3;
VAR_5->accept_256 = cpu_is_omap3630(VAR_0);
VAR_5->revision = cpu_class_omap3(VAR_0) ? 0x50 : 0x20;
VAR_5->lastirq = 0;
omap_gpmc_reset(VAR_5);
for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {
memory_region_init_io(&VAR_5->cs_file[VAR_4].nandiomem, NULL,
&omap_nand_ops,
&VAR_5->cs_file[VAR_4],
"omap-nand",
256 * 1024 * 1024);
}
memory_region_init_io(&VAR_5->prefetch.iomem, NULL, &omap_prefetch_ops, VAR_5,
"omap-gpmc-prefetch", 256 * 1024 * 1024);
return VAR_5;
}
| [
"struct omap_gpmc_s *FUNC_0(struct omap_mpu_state_s *VAR_0,\nhwaddr VAR_1,\nqemu_irq VAR_2, qemu_irq VAR_3)\n{",
"int VAR_4;",
"struct omap_gpmc_s *VAR_5 = (struct omap_gpmc_s *)\ng_malloc0(sizeof(struct omap_gpmc_s));",
"memory_region_init_io(&VAR_5->iomem, NULL, &omap_gpmc_ops, VAR_5, \"omap-gpmc\", 0x1000);",
"memory_region_add_subregion(get_system_memory(), VAR_1, &VAR_5->iomem);",
"VAR_5->VAR_2 = VAR_2;",
"VAR_5->VAR_3 = VAR_3;",
"VAR_5->accept_256 = cpu_is_omap3630(VAR_0);",
"VAR_5->revision = cpu_class_omap3(VAR_0) ? 0x50 : 0x20;",
"VAR_5->lastirq = 0;",
"omap_gpmc_reset(VAR_5);",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {",
"memory_region_init_io(&VAR_5->cs_file[VAR_4].nandiomem, NULL,\n&omap_nand_ops,\n&VAR_5->cs_file[VAR_4],\n\"omap-nand\",\n256 * 1024 * 1024);",
"}",
"memory_region_init_io(&VAR_5->prefetch.iomem, NULL, &omap_prefetch_ops, VAR_5,\n\"omap-gpmc-prefetch\", 256 * 1024 * 1024);",
"return VAR_5;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
49
],
[
51,
53,
55,
57,
59
],
[
61
],
[
65,
67
],
[
69
],
[
71
]
] |
24,408 | bool trace_backend_init(const char *events, const char *file)
{
GThread *thread;
if (!g_thread_supported()) {
g_thread_init(NULL);
}
trace_available_cond = g_cond_new();
trace_empty_cond = g_cond_new();
thread = trace_thread_create(writeout_thread);
if (!thread) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
return false;
}
atexit(st_flush_trace_buffer);
trace_backend_init_events(events);
st_set_trace_file(file);
return true;
} | true | qemu | 42ed3727536ccf80c87942b3f04e7378fe90f107 | bool trace_backend_init(const char *events, const char *file)
{
GThread *thread;
if (!g_thread_supported()) {
g_thread_init(NULL);
}
trace_available_cond = g_cond_new();
trace_empty_cond = g_cond_new();
thread = trace_thread_create(writeout_thread);
if (!thread) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
return false;
}
atexit(st_flush_trace_buffer);
trace_backend_init_events(events);
st_set_trace_file(file);
return true;
} | {
"code": [],
"line_no": []
} | bool FUNC_0(const char *events, const char *file)
{
GThread *thread;
if (!g_thread_supported()) {
g_thread_init(NULL);
}
trace_available_cond = g_cond_new();
trace_empty_cond = g_cond_new();
thread = trace_thread_create(writeout_thread);
if (!thread) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
return false;
}
atexit(st_flush_trace_buffer);
trace_backend_init_events(events);
st_set_trace_file(file);
return true;
} | [
"bool FUNC_0(const char *events, const char *file)\n{",
"GThread *thread;",
"if (!g_thread_supported()) {",
"g_thread_init(NULL);",
"}",
"trace_available_cond = g_cond_new();",
"trace_empty_cond = g_cond_new();",
"thread = trace_thread_create(writeout_thread);",
"if (!thread) {",
"fprintf(stderr, \"warning: unable to initialize simple trace backend\\n\");",
"return false;",
"}",
"atexit(st_flush_trace_buffer);",
"trace_backend_init_events(events);",
"st_set_trace_file(file);",
"return true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
12
],
[
18
],
[
22
],
[
24
],
[
28
],
[
30
],
[
32
],
[
34
],
[
36
],
[
40
],
[
42
],
[
44
],
[
46
],
[
48
]
] |
24,409 | static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,
int mvn, int r_x, int r_y, uint8_t* is_intra)
{
MpegEncContext *s = &v->s;
int xy, wrap, off = 0;
int A[2], B[2], C[2];
int px, py;
int a_valid = 0, b_valid = 0, c_valid = 0;
int field_a, field_b, field_c; // 0: same, 1: opposit
int total_valid, num_samefield, num_oppfield;
int pos_c, pos_b, n_adj;
wrap = s->b8_stride;
xy = s->block_index[n];
if (s->mb_intra) {
s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0;
s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0;
s->current_picture.f.motion_val[1][xy][0] = 0;
s->current_picture.f.motion_val[1][xy][1] = 0;
if (mvn == 1) { /* duplicate motion data for 1-MV block */
s->current_picture.f.motion_val[0][xy + 1][0] = 0;
s->current_picture.f.motion_val[0][xy + 1][1] = 0;
s->current_picture.f.motion_val[0][xy + wrap][0] = 0;
s->current_picture.f.motion_val[0][xy + wrap][1] = 0;
s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0;
s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0;
v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
s->current_picture.f.motion_val[1][xy + 1][0] = 0;
s->current_picture.f.motion_val[1][xy + 1][1] = 0;
s->current_picture.f.motion_val[1][xy + wrap][0] = 0;
s->current_picture.f.motion_val[1][xy + wrap][1] = 0;
s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0;
s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0;
}
return;
}
off = ((n == 0) || (n == 1)) ? 1 : -1;
/* predict A */
if (s->mb_x || (n == 1) || (n == 3)) {
if ((v->blk_mv_type[xy]) // current block (MB) has a field MV
|| (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { // or both have frame MV
A[0] = s->current_picture.f.motion_val[0][xy - 1][0];
A[1] = s->current_picture.f.motion_val[0][xy - 1][1];
a_valid = 1;
} else { // current block has frame mv and cand. has field MV (so average)
A[0] = (s->current_picture.f.motion_val[0][xy - 1][0]
+ s->current_picture.f.motion_val[0][xy - 1 + off * wrap][0] + 1) >> 1;
A[1] = (s->current_picture.f.motion_val[0][xy - 1][1]
+ s->current_picture.f.motion_val[0][xy - 1 + off * wrap][1] + 1) >> 1;
a_valid = 1;
}
if (!(n & 1) && v->is_intra[s->mb_x - 1]) {
a_valid = 0;
A[0] = A[1] = 0;
}
} else
A[0] = A[1] = 0;
/* Predict B and C */
B[0] = B[1] = C[0] = C[1] = 0;
if (n == 0 || n == 1 || v->blk_mv_type[xy]) {
if (!s->first_slice_line) {
if (!v->is_intra[s->mb_x - s->mb_stride]) {
b_valid = 1;
n_adj = n | 2;
pos_b = s->block_index[n_adj] - 2 * wrap;
if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) {
n_adj = (n & 2) | (n & 1);
}
B[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][0];
B[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][1];
if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) {
B[0] = (B[0] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1;
B[1] = (B[1] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1;
}
}
if (s->mb_width > 1) {
if (!v->is_intra[s->mb_x - s->mb_stride + 1]) {
c_valid = 1;
n_adj = 2;
pos_c = s->block_index[2] - 2 * wrap + 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n & 2;
}
C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][0];
C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1;
C[1] = (1 + C[1] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1;
}
if (s->mb_x == s->mb_width - 1) {
if (!v->is_intra[s->mb_x - s->mb_stride - 1]) {
c_valid = 1;
n_adj = 3;
pos_c = s->block_index[3] - 2 * wrap - 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n | 1;
}
C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][0];
C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][0]) >> 1;
C[1] = (1 + C[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][1]) >> 1;
}
} else
c_valid = 0;
}
}
}
}
} else {
pos_b = s->block_index[1];
b_valid = 1;
B[0] = s->current_picture.f.motion_val[0][pos_b][0];
B[1] = s->current_picture.f.motion_val[0][pos_b][1];
pos_c = s->block_index[0];
c_valid = 1;
C[0] = s->current_picture.f.motion_val[0][pos_c][0];
C[1] = s->current_picture.f.motion_val[0][pos_c][1];
}
total_valid = a_valid + b_valid + c_valid;
// check if predictor A is out of bounds
if (!s->mb_x && !(n == 1 || n == 3)) {
A[0] = A[1] = 0;
}
// check if predictor B is out of bounds
if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) {
B[0] = B[1] = C[0] = C[1] = 0;
}
if (!v->blk_mv_type[xy]) {
if (s->mb_width == 1) {
px = B[0];
py = B[1];
} else {
if (total_valid >= 2) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (total_valid) {
if (a_valid) { px = A[0]; py = A[1]; }
if (b_valid) { px = B[0]; py = B[1]; }
if (c_valid) { px = C[0]; py = C[1]; }
} else
px = py = 0;
}
} else {
if (a_valid)
field_a = (A[1] & 4) ? 1 : 0;
else
field_a = 0;
if (b_valid)
field_b = (B[1] & 4) ? 1 : 0;
else
field_b = 0;
if (c_valid)
field_c = (C[1] & 4) ? 1 : 0;
else
field_c = 0;
num_oppfield = field_a + field_b + field_c;
num_samefield = total_valid - num_oppfield;
if (total_valid == 3) {
if ((num_samefield == 3) || (num_oppfield == 3)) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (num_samefield >= num_oppfield) {
/* take one MV from same field set depending on priority
the check for B may not be necessary */
px = !field_a ? A[0] : B[0];
py = !field_a ? A[1] : B[1];
} else {
px = field_a ? A[0] : B[0];
py = field_a ? A[1] : B[1];
}
} else if (total_valid == 2) {
if (num_samefield >= num_oppfield) {
if (!field_a && a_valid) {
px = A[0];
py = A[1];
} else if (!field_b && b_valid) {
px = B[0];
py = B[1];
} else if (c_valid) {
px = C[0];
py = C[1];
} else px = py = 0;
} else {
if (field_a && a_valid) {
px = A[0];
py = A[1];
} else if (field_b && b_valid) {
px = B[0];
py = B[1];
} else if (c_valid) {
px = C[0];
py = C[1];
} else px = py = 0;
}
} else if (total_valid == 1) {
px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
} else
px = py = 0;
}
/* store MV using signed modulus of MV range defined in 4.11 */
s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
if (mvn == 1) { /* duplicate motion data for 1-MV block */
s->current_picture.f.motion_val[0][xy + 1 ][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + 1 ][1] = s->current_picture.f.motion_val[0][xy][1];
s->current_picture.f.motion_val[0][xy + wrap ][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + wrap ][1] = s->current_picture.f.motion_val[0][xy][1];
s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1];
} else if (mvn == 2) { /* duplicate motion data for 2-Field MV block */
s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1];
s->mv[0][n + 1][0] = s->mv[0][n][0];
s->mv[0][n + 1][1] = s->mv[0][n][1];
}
}
| true | FFmpeg | 6136b989f658fff68e2b758db583f04358d3d412 | static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,
int mvn, int r_x, int r_y, uint8_t* is_intra)
{
MpegEncContext *s = &v->s;
int xy, wrap, off = 0;
int A[2], B[2], C[2];
int px, py;
int a_valid = 0, b_valid = 0, c_valid = 0;
int field_a, field_b, field_c;
int total_valid, num_samefield, num_oppfield;
int pos_c, pos_b, n_adj;
wrap = s->b8_stride;
xy = s->block_index[n];
if (s->mb_intra) {
s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0;
s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0;
s->current_picture.f.motion_val[1][xy][0] = 0;
s->current_picture.f.motion_val[1][xy][1] = 0;
if (mvn == 1) {
s->current_picture.f.motion_val[0][xy + 1][0] = 0;
s->current_picture.f.motion_val[0][xy + 1][1] = 0;
s->current_picture.f.motion_val[0][xy + wrap][0] = 0;
s->current_picture.f.motion_val[0][xy + wrap][1] = 0;
s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0;
s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0;
v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
s->current_picture.f.motion_val[1][xy + 1][0] = 0;
s->current_picture.f.motion_val[1][xy + 1][1] = 0;
s->current_picture.f.motion_val[1][xy + wrap][0] = 0;
s->current_picture.f.motion_val[1][xy + wrap][1] = 0;
s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0;
s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0;
}
return;
}
off = ((n == 0) || (n == 1)) ? 1 : -1;
if (s->mb_x || (n == 1) || (n == 3)) {
if ((v->blk_mv_type[xy])
|| (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) {
A[0] = s->current_picture.f.motion_val[0][xy - 1][0];
A[1] = s->current_picture.f.motion_val[0][xy - 1][1];
a_valid = 1;
} else {
A[0] = (s->current_picture.f.motion_val[0][xy - 1][0]
+ s->current_picture.f.motion_val[0][xy - 1 + off * wrap][0] + 1) >> 1;
A[1] = (s->current_picture.f.motion_val[0][xy - 1][1]
+ s->current_picture.f.motion_val[0][xy - 1 + off * wrap][1] + 1) >> 1;
a_valid = 1;
}
if (!(n & 1) && v->is_intra[s->mb_x - 1]) {
a_valid = 0;
A[0] = A[1] = 0;
}
} else
A[0] = A[1] = 0;
B[0] = B[1] = C[0] = C[1] = 0;
if (n == 0 || n == 1 || v->blk_mv_type[xy]) {
if (!s->first_slice_line) {
if (!v->is_intra[s->mb_x - s->mb_stride]) {
b_valid = 1;
n_adj = n | 2;
pos_b = s->block_index[n_adj] - 2 * wrap;
if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) {
n_adj = (n & 2) | (n & 1);
}
B[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][0];
B[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][1];
if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) {
B[0] = (B[0] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1;
B[1] = (B[1] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1;
}
}
if (s->mb_width > 1) {
if (!v->is_intra[s->mb_x - s->mb_stride + 1]) {
c_valid = 1;
n_adj = 2;
pos_c = s->block_index[2] - 2 * wrap + 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n & 2;
}
C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][0];
C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1;
C[1] = (1 + C[1] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1;
}
if (s->mb_x == s->mb_width - 1) {
if (!v->is_intra[s->mb_x - s->mb_stride - 1]) {
c_valid = 1;
n_adj = 3;
pos_c = s->block_index[3] - 2 * wrap - 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n | 1;
}
C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][0];
C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][0]) >> 1;
C[1] = (1 + C[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][1]) >> 1;
}
} else
c_valid = 0;
}
}
}
}
} else {
pos_b = s->block_index[1];
b_valid = 1;
B[0] = s->current_picture.f.motion_val[0][pos_b][0];
B[1] = s->current_picture.f.motion_val[0][pos_b][1];
pos_c = s->block_index[0];
c_valid = 1;
C[0] = s->current_picture.f.motion_val[0][pos_c][0];
C[1] = s->current_picture.f.motion_val[0][pos_c][1];
}
total_valid = a_valid + b_valid + c_valid;
if (!s->mb_x && !(n == 1 || n == 3)) {
A[0] = A[1] = 0;
}
if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) {
B[0] = B[1] = C[0] = C[1] = 0;
}
if (!v->blk_mv_type[xy]) {
if (s->mb_width == 1) {
px = B[0];
py = B[1];
} else {
if (total_valid >= 2) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (total_valid) {
if (a_valid) { px = A[0]; py = A[1]; }
if (b_valid) { px = B[0]; py = B[1]; }
if (c_valid) { px = C[0]; py = C[1]; }
} else
px = py = 0;
}
} else {
if (a_valid)
field_a = (A[1] & 4) ? 1 : 0;
else
field_a = 0;
if (b_valid)
field_b = (B[1] & 4) ? 1 : 0;
else
field_b = 0;
if (c_valid)
field_c = (C[1] & 4) ? 1 : 0;
else
field_c = 0;
num_oppfield = field_a + field_b + field_c;
num_samefield = total_valid - num_oppfield;
if (total_valid == 3) {
if ((num_samefield == 3) || (num_oppfield == 3)) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (num_samefield >= num_oppfield) {
px = !field_a ? A[0] : B[0];
py = !field_a ? A[1] : B[1];
} else {
px = field_a ? A[0] : B[0];
py = field_a ? A[1] : B[1];
}
} else if (total_valid == 2) {
if (num_samefield >= num_oppfield) {
if (!field_a && a_valid) {
px = A[0];
py = A[1];
} else if (!field_b && b_valid) {
px = B[0];
py = B[1];
} else if (c_valid) {
px = C[0];
py = C[1];
} else px = py = 0;
} else {
if (field_a && a_valid) {
px = A[0];
py = A[1];
} else if (field_b && b_valid) {
px = B[0];
py = B[1];
} else if (c_valid) {
px = C[0];
py = C[1];
} else px = py = 0;
}
} else if (total_valid == 1) {
px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
} else
px = py = 0;
}
s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
if (mvn == 1) {
s->current_picture.f.motion_val[0][xy + 1 ][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + 1 ][1] = s->current_picture.f.motion_val[0][xy][1];
s->current_picture.f.motion_val[0][xy + wrap ][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + wrap ][1] = s->current_picture.f.motion_val[0][xy][1];
s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1];
} else if (mvn == 2) {
s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0];
s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1];
s->mv[0][n + 1][0] = s->mv[0][n][0];
s->mv[0][n + 1][1] = s->mv[0][n][1];
}
}
| {
"code": [
" if (a_valid) { px = A[0]; py = A[1]; }",
" if (b_valid) { px = B[0]; py = B[1]; }",
" if (c_valid) { px = C[0]; py = C[1]; }"
],
"line_no": [
281,
283,
285
]
} | static inline void FUNC_0(VC1Context *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, uint8_t* VAR_7)
{
MpegEncContext *s = &VAR_0->s;
int VAR_8, VAR_9, VAR_10 = 0;
int VAR_11[2], VAR_12[2], VAR_13[2];
int VAR_14, VAR_15;
int VAR_16 = 0, VAR_17 = 0, VAR_18 = 0;
int VAR_19, VAR_20, VAR_21;
int VAR_22, VAR_23, VAR_24;
int VAR_25, VAR_26, VAR_27;
VAR_9 = s->b8_stride;
VAR_8 = s->block_index[VAR_1];
if (s->mb_intra) {
s->mv[0][VAR_1][0] = s->current_picture.f.motion_val[0][VAR_8][0] = 0;
s->mv[0][VAR_1][1] = s->current_picture.f.motion_val[0][VAR_8][1] = 0;
s->current_picture.f.motion_val[1][VAR_8][0] = 0;
s->current_picture.f.motion_val[1][VAR_8][1] = 0;
if (VAR_4 == 1) {
s->current_picture.f.motion_val[0][VAR_8 + 1][0] = 0;
s->current_picture.f.motion_val[0][VAR_8 + 1][1] = 0;
s->current_picture.f.motion_val[0][VAR_8 + VAR_9][0] = 0;
s->current_picture.f.motion_val[0][VAR_8 + VAR_9][1] = 0;
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][0] = 0;
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][1] = 0;
VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0;
s->current_picture.f.motion_val[1][VAR_8 + 1][0] = 0;
s->current_picture.f.motion_val[1][VAR_8 + 1][1] = 0;
s->current_picture.f.motion_val[1][VAR_8 + VAR_9][0] = 0;
s->current_picture.f.motion_val[1][VAR_8 + VAR_9][1] = 0;
s->current_picture.f.motion_val[1][VAR_8 + VAR_9 + 1][0] = 0;
s->current_picture.f.motion_val[1][VAR_8 + VAR_9 + 1][1] = 0;
}
return;
}
VAR_10 = ((VAR_1 == 0) || (VAR_1 == 1)) ? 1 : -1;
if (s->mb_x || (VAR_1 == 1) || (VAR_1 == 3)) {
if ((VAR_0->blk_mv_type[VAR_8])
|| (!VAR_0->blk_mv_type[VAR_8] && !VAR_0->blk_mv_type[VAR_8 - 1])) {
VAR_11[0] = s->current_picture.f.motion_val[0][VAR_8 - 1][0];
VAR_11[1] = s->current_picture.f.motion_val[0][VAR_8 - 1][1];
VAR_16 = 1;
} else {
VAR_11[0] = (s->current_picture.f.motion_val[0][VAR_8 - 1][0]
+ s->current_picture.f.motion_val[0][VAR_8 - 1 + VAR_10 * VAR_9][0] + 1) >> 1;
VAR_11[1] = (s->current_picture.f.motion_val[0][VAR_8 - 1][1]
+ s->current_picture.f.motion_val[0][VAR_8 - 1 + VAR_10 * VAR_9][1] + 1) >> 1;
VAR_16 = 1;
}
if (!(VAR_1 & 1) && VAR_0->VAR_7[s->mb_x - 1]) {
VAR_16 = 0;
VAR_11[0] = VAR_11[1] = 0;
}
} else
VAR_11[0] = VAR_11[1] = 0;
VAR_12[0] = VAR_12[1] = VAR_13[0] = VAR_13[1] = 0;
if (VAR_1 == 0 || VAR_1 == 1 || VAR_0->blk_mv_type[VAR_8]) {
if (!s->first_slice_line) {
if (!VAR_0->VAR_7[s->mb_x - s->mb_stride]) {
VAR_17 = 1;
VAR_27 = VAR_1 | 2;
VAR_26 = s->block_index[VAR_27] - 2 * VAR_9;
if (VAR_0->blk_mv_type[VAR_26] && VAR_0->blk_mv_type[VAR_8]) {
VAR_27 = (VAR_1 & 2) | (VAR_1 & 1);
}
VAR_12[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9][0];
VAR_12[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9][1];
if (VAR_0->blk_mv_type[VAR_26] && !VAR_0->blk_mv_type[VAR_8]) {
VAR_12[0] = (VAR_12[0] + s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9][0] + 1) >> 1;
VAR_12[1] = (VAR_12[1] + s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9][1] + 1) >> 1;
}
}
if (s->mb_width > 1) {
if (!VAR_0->VAR_7[s->mb_x - s->mb_stride + 1]) {
VAR_18 = 1;
VAR_27 = 2;
VAR_25 = s->block_index[2] - 2 * VAR_9 + 2;
if (VAR_0->blk_mv_type[VAR_25] && VAR_0->blk_mv_type[VAR_8]) {
VAR_27 = VAR_1 & 2;
}
VAR_13[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 + 2][0];
VAR_13[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 + 2][1];
if (VAR_0->blk_mv_type[VAR_25] && !VAR_0->blk_mv_type[VAR_8]) {
VAR_13[0] = (1 + VAR_13[0] + (s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9 + 2][0])) >> 1;
VAR_13[1] = (1 + VAR_13[1] + (s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9 + 2][1])) >> 1;
}
if (s->mb_x == s->mb_width - 1) {
if (!VAR_0->VAR_7[s->mb_x - s->mb_stride - 1]) {
VAR_18 = 1;
VAR_27 = 3;
VAR_25 = s->block_index[3] - 2 * VAR_9 - 2;
if (VAR_0->blk_mv_type[VAR_25] && VAR_0->blk_mv_type[VAR_8]) {
VAR_27 = VAR_1 | 1;
}
VAR_13[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 - 2][0];
VAR_13[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 - 2][1];
if (VAR_0->blk_mv_type[VAR_25] && !VAR_0->blk_mv_type[VAR_8]) {
VAR_13[0] = (1 + VAR_13[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * VAR_9 - 2][0]) >> 1;
VAR_13[1] = (1 + VAR_13[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * VAR_9 - 2][1]) >> 1;
}
} else
VAR_18 = 0;
}
}
}
}
} else {
VAR_26 = s->block_index[1];
VAR_17 = 1;
VAR_12[0] = s->current_picture.f.motion_val[0][VAR_26][0];
VAR_12[1] = s->current_picture.f.motion_val[0][VAR_26][1];
VAR_25 = s->block_index[0];
VAR_18 = 1;
VAR_13[0] = s->current_picture.f.motion_val[0][VAR_25][0];
VAR_13[1] = s->current_picture.f.motion_val[0][VAR_25][1];
}
VAR_22 = VAR_16 + VAR_17 + VAR_18;
if (!s->mb_x && !(VAR_1 == 1 || VAR_1 == 3)) {
VAR_11[0] = VAR_11[1] = 0;
}
if ((s->first_slice_line && VAR_0->blk_mv_type[VAR_8]) || (s->first_slice_line && !(VAR_1 & 2))) {
VAR_12[0] = VAR_12[1] = VAR_13[0] = VAR_13[1] = 0;
}
if (!VAR_0->blk_mv_type[VAR_8]) {
if (s->mb_width == 1) {
VAR_14 = VAR_12[0];
VAR_15 = VAR_12[1];
} else {
if (VAR_22 >= 2) {
VAR_14 = mid_pred(VAR_11[0], VAR_12[0], VAR_13[0]);
VAR_15 = mid_pred(VAR_11[1], VAR_12[1], VAR_13[1]);
} else if (VAR_22) {
if (VAR_16) { VAR_14 = VAR_11[0]; VAR_15 = VAR_11[1]; }
if (VAR_17) { VAR_14 = VAR_12[0]; VAR_15 = VAR_12[1]; }
if (VAR_18) { VAR_14 = VAR_13[0]; VAR_15 = VAR_13[1]; }
} else
VAR_14 = VAR_15 = 0;
}
} else {
if (VAR_16)
VAR_19 = (VAR_11[1] & 4) ? 1 : 0;
else
VAR_19 = 0;
if (VAR_17)
VAR_20 = (VAR_12[1] & 4) ? 1 : 0;
else
VAR_20 = 0;
if (VAR_18)
VAR_21 = (VAR_13[1] & 4) ? 1 : 0;
else
VAR_21 = 0;
VAR_24 = VAR_19 + VAR_20 + VAR_21;
VAR_23 = VAR_22 - VAR_24;
if (VAR_22 == 3) {
if ((VAR_23 == 3) || (VAR_24 == 3)) {
VAR_14 = mid_pred(VAR_11[0], VAR_12[0], VAR_13[0]);
VAR_15 = mid_pred(VAR_11[1], VAR_12[1], VAR_13[1]);
} else if (VAR_23 >= VAR_24) {
VAR_14 = !VAR_19 ? VAR_11[0] : VAR_12[0];
VAR_15 = !VAR_19 ? VAR_11[1] : VAR_12[1];
} else {
VAR_14 = VAR_19 ? VAR_11[0] : VAR_12[0];
VAR_15 = VAR_19 ? VAR_11[1] : VAR_12[1];
}
} else if (VAR_22 == 2) {
if (VAR_23 >= VAR_24) {
if (!VAR_19 && VAR_16) {
VAR_14 = VAR_11[0];
VAR_15 = VAR_11[1];
} else if (!VAR_20 && VAR_17) {
VAR_14 = VAR_12[0];
VAR_15 = VAR_12[1];
} else if (VAR_18) {
VAR_14 = VAR_13[0];
VAR_15 = VAR_13[1];
} else VAR_14 = VAR_15 = 0;
} else {
if (VAR_19 && VAR_16) {
VAR_14 = VAR_11[0];
VAR_15 = VAR_11[1];
} else if (VAR_20 && VAR_17) {
VAR_14 = VAR_12[0];
VAR_15 = VAR_12[1];
} else if (VAR_18) {
VAR_14 = VAR_13[0];
VAR_15 = VAR_13[1];
} else VAR_14 = VAR_15 = 0;
}
} else if (VAR_22 == 1) {
VAR_14 = (VAR_16) ? VAR_11[0] : ((VAR_17) ? VAR_12[0] : VAR_13[0]);
VAR_15 = (VAR_16) ? VAR_11[1] : ((VAR_17) ? VAR_12[1] : VAR_13[1]);
} else
VAR_14 = VAR_15 = 0;
}
s->mv[0][VAR_1][0] = s->current_picture.f.motion_val[0][VAR_8][0] = ((VAR_14 + VAR_2 + VAR_5) & ((VAR_5 << 1) - 1)) - VAR_5;
s->mv[0][VAR_1][1] = s->current_picture.f.motion_val[0][VAR_8][1] = ((VAR_15 + VAR_3 + VAR_6) & ((VAR_6 << 1) - 1)) - VAR_6;
if (VAR_4 == 1) {
s->current_picture.f.motion_val[0][VAR_8 + 1 ][0] = s->current_picture.f.motion_val[0][VAR_8][0];
s->current_picture.f.motion_val[0][VAR_8 + 1 ][1] = s->current_picture.f.motion_val[0][VAR_8][1];
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 ][0] = s->current_picture.f.motion_val[0][VAR_8][0];
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 ][1] = s->current_picture.f.motion_val[0][VAR_8][1];
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][0] = s->current_picture.f.motion_val[0][VAR_8][0];
s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][1] = s->current_picture.f.motion_val[0][VAR_8][1];
} else if (VAR_4 == 2) {
s->current_picture.f.motion_val[0][VAR_8 + 1][0] = s->current_picture.f.motion_val[0][VAR_8][0];
s->current_picture.f.motion_val[0][VAR_8 + 1][1] = s->current_picture.f.motion_val[0][VAR_8][1];
s->mv[0][VAR_1 + 1][0] = s->mv[0][VAR_1][0];
s->mv[0][VAR_1 + 1][1] = s->mv[0][VAR_1][1];
}
}
| [
"static inline void FUNC_0(VC1Context *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6, uint8_t* VAR_7)\n{",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_8, VAR_9, VAR_10 = 0;",
"int VAR_11[2], VAR_12[2], VAR_13[2];",
"int VAR_14, VAR_15;",
"int VAR_16 = 0, VAR_17 = 0, VAR_18 = 0;",
"int VAR_19, VAR_20, VAR_21;",
"int VAR_22, VAR_23, VAR_24;",
"int VAR_25, VAR_26, VAR_27;",
"VAR_9 = s->b8_stride;",
"VAR_8 = s->block_index[VAR_1];",
"if (s->mb_intra) {",
"s->mv[0][VAR_1][0] = s->current_picture.f.motion_val[0][VAR_8][0] = 0;",
"s->mv[0][VAR_1][1] = s->current_picture.f.motion_val[0][VAR_8][1] = 0;",
"s->current_picture.f.motion_val[1][VAR_8][0] = 0;",
"s->current_picture.f.motion_val[1][VAR_8][1] = 0;",
"if (VAR_4 == 1) {",
"s->current_picture.f.motion_val[0][VAR_8 + 1][0] = 0;",
"s->current_picture.f.motion_val[0][VAR_8 + 1][1] = 0;",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9][0] = 0;",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9][1] = 0;",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][0] = 0;",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][1] = 0;",
"VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + 1][0] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + 1][1] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + VAR_9][0] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + VAR_9][1] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + VAR_9 + 1][0] = 0;",
"s->current_picture.f.motion_val[1][VAR_8 + VAR_9 + 1][1] = 0;",
"}",
"return;",
"}",
"VAR_10 = ((VAR_1 == 0) || (VAR_1 == 1)) ? 1 : -1;",
"if (s->mb_x || (VAR_1 == 1) || (VAR_1 == 3)) {",
"if ((VAR_0->blk_mv_type[VAR_8])\n|| (!VAR_0->blk_mv_type[VAR_8] && !VAR_0->blk_mv_type[VAR_8 - 1])) {",
"VAR_11[0] = s->current_picture.f.motion_val[0][VAR_8 - 1][0];",
"VAR_11[1] = s->current_picture.f.motion_val[0][VAR_8 - 1][1];",
"VAR_16 = 1;",
"} else {",
"VAR_11[0] = (s->current_picture.f.motion_val[0][VAR_8 - 1][0]\n+ s->current_picture.f.motion_val[0][VAR_8 - 1 + VAR_10 * VAR_9][0] + 1) >> 1;",
"VAR_11[1] = (s->current_picture.f.motion_val[0][VAR_8 - 1][1]\n+ s->current_picture.f.motion_val[0][VAR_8 - 1 + VAR_10 * VAR_9][1] + 1) >> 1;",
"VAR_16 = 1;",
"}",
"if (!(VAR_1 & 1) && VAR_0->VAR_7[s->mb_x - 1]) {",
"VAR_16 = 0;",
"VAR_11[0] = VAR_11[1] = 0;",
"}",
"} else",
"VAR_11[0] = VAR_11[1] = 0;",
"VAR_12[0] = VAR_12[1] = VAR_13[0] = VAR_13[1] = 0;",
"if (VAR_1 == 0 || VAR_1 == 1 || VAR_0->blk_mv_type[VAR_8]) {",
"if (!s->first_slice_line) {",
"if (!VAR_0->VAR_7[s->mb_x - s->mb_stride]) {",
"VAR_17 = 1;",
"VAR_27 = VAR_1 | 2;",
"VAR_26 = s->block_index[VAR_27] - 2 * VAR_9;",
"if (VAR_0->blk_mv_type[VAR_26] && VAR_0->blk_mv_type[VAR_8]) {",
"VAR_27 = (VAR_1 & 2) | (VAR_1 & 1);",
"}",
"VAR_12[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9][0];",
"VAR_12[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9][1];",
"if (VAR_0->blk_mv_type[VAR_26] && !VAR_0->blk_mv_type[VAR_8]) {",
"VAR_12[0] = (VAR_12[0] + s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9][0] + 1) >> 1;",
"VAR_12[1] = (VAR_12[1] + s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9][1] + 1) >> 1;",
"}",
"}",
"if (s->mb_width > 1) {",
"if (!VAR_0->VAR_7[s->mb_x - s->mb_stride + 1]) {",
"VAR_18 = 1;",
"VAR_27 = 2;",
"VAR_25 = s->block_index[2] - 2 * VAR_9 + 2;",
"if (VAR_0->blk_mv_type[VAR_25] && VAR_0->blk_mv_type[VAR_8]) {",
"VAR_27 = VAR_1 & 2;",
"}",
"VAR_13[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 + 2][0];",
"VAR_13[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 + 2][1];",
"if (VAR_0->blk_mv_type[VAR_25] && !VAR_0->blk_mv_type[VAR_8]) {",
"VAR_13[0] = (1 + VAR_13[0] + (s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9 + 2][0])) >> 1;",
"VAR_13[1] = (1 + VAR_13[1] + (s->current_picture.f.motion_val[0][s->block_index[VAR_27 ^ 2] - 2 * VAR_9 + 2][1])) >> 1;",
"}",
"if (s->mb_x == s->mb_width - 1) {",
"if (!VAR_0->VAR_7[s->mb_x - s->mb_stride - 1]) {",
"VAR_18 = 1;",
"VAR_27 = 3;",
"VAR_25 = s->block_index[3] - 2 * VAR_9 - 2;",
"if (VAR_0->blk_mv_type[VAR_25] && VAR_0->blk_mv_type[VAR_8]) {",
"VAR_27 = VAR_1 | 1;",
"}",
"VAR_13[0] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 - 2][0];",
"VAR_13[1] = s->current_picture.f.motion_val[0][s->block_index[VAR_27] - 2 * VAR_9 - 2][1];",
"if (VAR_0->blk_mv_type[VAR_25] && !VAR_0->blk_mv_type[VAR_8]) {",
"VAR_13[0] = (1 + VAR_13[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * VAR_9 - 2][0]) >> 1;",
"VAR_13[1] = (1 + VAR_13[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * VAR_9 - 2][1]) >> 1;",
"}",
"} else",
"VAR_18 = 0;",
"}",
"}",
"}",
"}",
"} else {",
"VAR_26 = s->block_index[1];",
"VAR_17 = 1;",
"VAR_12[0] = s->current_picture.f.motion_val[0][VAR_26][0];",
"VAR_12[1] = s->current_picture.f.motion_val[0][VAR_26][1];",
"VAR_25 = s->block_index[0];",
"VAR_18 = 1;",
"VAR_13[0] = s->current_picture.f.motion_val[0][VAR_25][0];",
"VAR_13[1] = s->current_picture.f.motion_val[0][VAR_25][1];",
"}",
"VAR_22 = VAR_16 + VAR_17 + VAR_18;",
"if (!s->mb_x && !(VAR_1 == 1 || VAR_1 == 3)) {",
"VAR_11[0] = VAR_11[1] = 0;",
"}",
"if ((s->first_slice_line && VAR_0->blk_mv_type[VAR_8]) || (s->first_slice_line && !(VAR_1 & 2))) {",
"VAR_12[0] = VAR_12[1] = VAR_13[0] = VAR_13[1] = 0;",
"}",
"if (!VAR_0->blk_mv_type[VAR_8]) {",
"if (s->mb_width == 1) {",
"VAR_14 = VAR_12[0];",
"VAR_15 = VAR_12[1];",
"} else {",
"if (VAR_22 >= 2) {",
"VAR_14 = mid_pred(VAR_11[0], VAR_12[0], VAR_13[0]);",
"VAR_15 = mid_pred(VAR_11[1], VAR_12[1], VAR_13[1]);",
"} else if (VAR_22) {",
"if (VAR_16) { VAR_14 = VAR_11[0]; VAR_15 = VAR_11[1]; }",
"if (VAR_17) { VAR_14 = VAR_12[0]; VAR_15 = VAR_12[1]; }",
"if (VAR_18) { VAR_14 = VAR_13[0]; VAR_15 = VAR_13[1]; }",
"} else",
"VAR_14 = VAR_15 = 0;",
"}",
"} else {",
"if (VAR_16)\nVAR_19 = (VAR_11[1] & 4) ? 1 : 0;",
"else\nVAR_19 = 0;",
"if (VAR_17)\nVAR_20 = (VAR_12[1] & 4) ? 1 : 0;",
"else\nVAR_20 = 0;",
"if (VAR_18)\nVAR_21 = (VAR_13[1] & 4) ? 1 : 0;",
"else\nVAR_21 = 0;",
"VAR_24 = VAR_19 + VAR_20 + VAR_21;",
"VAR_23 = VAR_22 - VAR_24;",
"if (VAR_22 == 3) {",
"if ((VAR_23 == 3) || (VAR_24 == 3)) {",
"VAR_14 = mid_pred(VAR_11[0], VAR_12[0], VAR_13[0]);",
"VAR_15 = mid_pred(VAR_11[1], VAR_12[1], VAR_13[1]);",
"} else if (VAR_23 >= VAR_24) {",
"VAR_14 = !VAR_19 ? VAR_11[0] : VAR_12[0];",
"VAR_15 = !VAR_19 ? VAR_11[1] : VAR_12[1];",
"} else {",
"VAR_14 = VAR_19 ? VAR_11[0] : VAR_12[0];",
"VAR_15 = VAR_19 ? VAR_11[1] : VAR_12[1];",
"}",
"} else if (VAR_22 == 2) {",
"if (VAR_23 >= VAR_24) {",
"if (!VAR_19 && VAR_16) {",
"VAR_14 = VAR_11[0];",
"VAR_15 = VAR_11[1];",
"} else if (!VAR_20 && VAR_17) {",
"VAR_14 = VAR_12[0];",
"VAR_15 = VAR_12[1];",
"} else if (VAR_18) {",
"VAR_14 = VAR_13[0];",
"VAR_15 = VAR_13[1];",
"} else VAR_14 = VAR_15 = 0;",
"} else {",
"if (VAR_19 && VAR_16) {",
"VAR_14 = VAR_11[0];",
"VAR_15 = VAR_11[1];",
"} else if (VAR_20 && VAR_17) {",
"VAR_14 = VAR_12[0];",
"VAR_15 = VAR_12[1];",
"} else if (VAR_18) {",
"VAR_14 = VAR_13[0];",
"VAR_15 = VAR_13[1];",
"} else VAR_14 = VAR_15 = 0;",
"}",
"} else if (VAR_22 == 1) {",
"VAR_14 = (VAR_16) ? VAR_11[0] : ((VAR_17) ? VAR_12[0] : VAR_13[0]);",
"VAR_15 = (VAR_16) ? VAR_11[1] : ((VAR_17) ? VAR_12[1] : VAR_13[1]);",
"} else",
"VAR_14 = VAR_15 = 0;",
"}",
"s->mv[0][VAR_1][0] = s->current_picture.f.motion_val[0][VAR_8][0] = ((VAR_14 + VAR_2 + VAR_5) & ((VAR_5 << 1) - 1)) - VAR_5;",
"s->mv[0][VAR_1][1] = s->current_picture.f.motion_val[0][VAR_8][1] = ((VAR_15 + VAR_3 + VAR_6) & ((VAR_6 << 1) - 1)) - VAR_6;",
"if (VAR_4 == 1) {",
"s->current_picture.f.motion_val[0][VAR_8 + 1 ][0] = s->current_picture.f.motion_val[0][VAR_8][0];",
"s->current_picture.f.motion_val[0][VAR_8 + 1 ][1] = s->current_picture.f.motion_val[0][VAR_8][1];",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 ][0] = s->current_picture.f.motion_val[0][VAR_8][0];",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 ][1] = s->current_picture.f.motion_val[0][VAR_8][1];",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][0] = s->current_picture.f.motion_val[0][VAR_8][0];",
"s->current_picture.f.motion_val[0][VAR_8 + VAR_9 + 1][1] = s->current_picture.f.motion_val[0][VAR_8][1];",
"} else if (VAR_4 == 2) {",
"s->current_picture.f.motion_val[0][VAR_8 + 1][0] = s->current_picture.f.motion_val[0][VAR_8][0];",
"s->current_picture.f.motion_val[0][VAR_8 + 1][1] = s->current_picture.f.motion_val[0][VAR_8][1];",
"s->mv[0][VAR_1 + 1][0] = s->mv[0][VAR_1][0];",
"s->mv[0][VAR_1 + 1][1] = s->mv[0][VAR_1][1];",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
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
],
[
103
],
[
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
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299,
301
],
[
303,
305
],
[
307,
309
],
[
311,
313
],
[
315,
317
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
]
] |
24,411 | ip_reass(register struct ip *ip, register struct ipq *fp)
{
register struct mbuf *m = dtom(ip);
register struct ipasfrag *q;
int hlen = ip->ip_hl << 2;
int i, next;
DEBUG_CALL("ip_reass");
DEBUG_ARG("ip = %lx", (long)ip);
DEBUG_ARG("fp = %lx", (long)fp);
DEBUG_ARG("m = %lx", (long)m);
/*
* Presence of header sizes in mbufs
* would confuse code below.
* Fragment m_data is concatenated.
*/
m->m_data += hlen;
m->m_len -= hlen;
/*
* If first fragment to arrive, create a reassembly queue.
*/
if (fp == 0) {
struct mbuf *t;
if ((t = m_get()) == NULL) goto dropfrag;
fp = mtod(t, struct ipq *);
insque(&fp->ip_link, &ipq.ip_link);
fp->ipq_ttl = IPFRAGTTL;
fp->ipq_p = ip->ip_p;
fp->ipq_id = ip->ip_id;
fp->frag_link.next = fp->frag_link.prev = &fp->frag_link;
fp->ipq_src = ip->ip_src;
fp->ipq_dst = ip->ip_dst;
q = (struct ipasfrag *)fp;
goto insert;
}
/*
* Find a segment which begins after this one does.
*/
for (q = fp->frag_link.next; q != (struct ipasfrag *)&fp->frag_link;
q = q->ipf_next)
if (q->ipf_off > ip->ip_off)
break;
/*
* If there is a preceding segment, it may provide some of
* our data already. If so, drop the data from the incoming
* segment. If it provides all of our data, drop us.
*/
if (q->ipf_prev != &fp->frag_link) {
struct ipasfrag *pq = q->ipf_prev;
i = pq->ipf_off + pq->ipf_len - ip->ip_off;
if (i > 0) {
if (i >= ip->ip_len)
goto dropfrag;
m_adj(dtom(ip), i);
ip->ip_off += i;
ip->ip_len -= i;
}
}
/*
* While we overlap succeeding segments trim them or,
* if they are completely covered, dequeue them.
*/
while (q != (struct ipasfrag*)&fp->frag_link &&
ip->ip_off + ip->ip_len > q->ipf_off) {
i = (ip->ip_off + ip->ip_len) - q->ipf_off;
if (i < q->ipf_len) {
q->ipf_len -= i;
q->ipf_off += i;
m_adj(dtom(q), i);
break;
}
q = q->ipf_next;
m_freem(dtom(q->ipf_prev));
ip_deq(q->ipf_prev);
}
insert:
/*
* Stick new segment in its place;
* check for complete reassembly.
*/
ip_enq(iptofrag(ip), q->ipf_prev);
next = 0;
for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link;
q = q->ipf_next) {
if (q->ipf_off != next)
return (0);
next += q->ipf_len;
}
if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos & 1)
return (0);
/*
* Reassembly is complete; concatenate fragments.
*/
q = fp->frag_link.next;
m = dtom(q);
q = (struct ipasfrag *) q->ipf_next;
while (q != (struct ipasfrag*)&fp->frag_link) {
struct mbuf *t = dtom(q);
q = (struct ipasfrag *) q->ipf_next;
m_cat(m, t);
}
/*
* Create header for new ip packet by
* modifying header of first packet;
* dequeue and discard fragment reassembly header.
* Make header visible.
*/
q = fp->frag_link.next;
/*
* If the fragments concatenated to an mbuf that's
* bigger than the total size of the fragment, then and
* m_ext buffer was alloced. But fp->ipq_next points to
* the old buffer (in the mbuf), so we must point ip
* into the new buffer.
*/
if (m->m_flags & M_EXT) {
int delta;
delta = (char *)ip - m->m_dat;
q = (struct ipasfrag *)(m->m_ext + delta);
}
/* DEBUG_ARG("ip = %lx", (long)ip);
* ip=(struct ipasfrag *)m->m_data; */
ip = fragtoip(q);
ip->ip_len = next;
ip->ip_tos &= ~1;
ip->ip_src = fp->ipq_src;
ip->ip_dst = fp->ipq_dst;
remque(&fp->ip_link);
(void) m_free(dtom(fp));
m->m_len += (ip->ip_hl << 2);
m->m_data -= (ip->ip_hl << 2);
return ip;
dropfrag:
STAT(ipstat.ips_fragdropped++);
m_freem(m);
return (0);
}
| true | qemu | f2ba730e89b420903257e543c1bb7f7d945ba36a | ip_reass(register struct ip *ip, register struct ipq *fp)
{
register struct mbuf *m = dtom(ip);
register struct ipasfrag *q;
int hlen = ip->ip_hl << 2;
int i, next;
DEBUG_CALL("ip_reass");
DEBUG_ARG("ip = %lx", (long)ip);
DEBUG_ARG("fp = %lx", (long)fp);
DEBUG_ARG("m = %lx", (long)m);
m->m_data += hlen;
m->m_len -= hlen;
if (fp == 0) {
struct mbuf *t;
if ((t = m_get()) == NULL) goto dropfrag;
fp = mtod(t, struct ipq *);
insque(&fp->ip_link, &ipq.ip_link);
fp->ipq_ttl = IPFRAGTTL;
fp->ipq_p = ip->ip_p;
fp->ipq_id = ip->ip_id;
fp->frag_link.next = fp->frag_link.prev = &fp->frag_link;
fp->ipq_src = ip->ip_src;
fp->ipq_dst = ip->ip_dst;
q = (struct ipasfrag *)fp;
goto insert;
}
for (q = fp->frag_link.next; q != (struct ipasfrag *)&fp->frag_link;
q = q->ipf_next)
if (q->ipf_off > ip->ip_off)
break;
if (q->ipf_prev != &fp->frag_link) {
struct ipasfrag *pq = q->ipf_prev;
i = pq->ipf_off + pq->ipf_len - ip->ip_off;
if (i > 0) {
if (i >= ip->ip_len)
goto dropfrag;
m_adj(dtom(ip), i);
ip->ip_off += i;
ip->ip_len -= i;
}
}
while (q != (struct ipasfrag*)&fp->frag_link &&
ip->ip_off + ip->ip_len > q->ipf_off) {
i = (ip->ip_off + ip->ip_len) - q->ipf_off;
if (i < q->ipf_len) {
q->ipf_len -= i;
q->ipf_off += i;
m_adj(dtom(q), i);
break;
}
q = q->ipf_next;
m_freem(dtom(q->ipf_prev));
ip_deq(q->ipf_prev);
}
insert:
ip_enq(iptofrag(ip), q->ipf_prev);
next = 0;
for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link;
q = q->ipf_next) {
if (q->ipf_off != next)
return (0);
next += q->ipf_len;
}
if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos & 1)
return (0);
q = fp->frag_link.next;
m = dtom(q);
q = (struct ipasfrag *) q->ipf_next;
while (q != (struct ipasfrag*)&fp->frag_link) {
struct mbuf *t = dtom(q);
q = (struct ipasfrag *) q->ipf_next;
m_cat(m, t);
}
q = fp->frag_link.next;
if (m->m_flags & M_EXT) {
int delta;
delta = (char *)ip - m->m_dat;
q = (struct ipasfrag *)(m->m_ext + delta);
}
ip = fragtoip(q);
ip->ip_len = next;
ip->ip_tos &= ~1;
ip->ip_src = fp->ipq_src;
ip->ip_dst = fp->ipq_dst;
remque(&fp->ip_link);
(void) m_free(dtom(fp));
m->m_len += (ip->ip_hl << 2);
m->m_data -= (ip->ip_hl << 2);
return ip;
dropfrag:
STAT(ipstat.ips_fragdropped++);
m_freem(m);
return (0);
}
| {
"code": [
"\t int delta;",
"\t delta = (char *)ip - m->m_dat;"
],
"line_no": [
253,
255
]
} | FUNC_0(register struct VAR_0 *VAR_0, register struct ipq *VAR_1)
{
register struct mbuf *VAR_2 = dtom(VAR_0);
register struct ipasfrag *VAR_3;
int VAR_4 = VAR_0->ip_hl << 2;
int VAR_5, VAR_6;
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_0 = %lx", (long)VAR_0);
DEBUG_ARG("VAR_1 = %lx", (long)VAR_1);
DEBUG_ARG("VAR_2 = %lx", (long)VAR_2);
VAR_2->m_data += VAR_4;
VAR_2->m_len -= VAR_4;
if (VAR_1 == 0) {
struct mbuf *VAR_9;
if ((VAR_9 = m_get()) == NULL) goto dropfrag;
VAR_1 = mtod(VAR_9, struct ipq *);
insque(&VAR_1->ip_link, &ipq.ip_link);
VAR_1->ipq_ttl = IPFRAGTTL;
VAR_1->ipq_p = VAR_0->ip_p;
VAR_1->ipq_id = VAR_0->ip_id;
VAR_1->frag_link.VAR_6 = VAR_1->frag_link.prev = &VAR_1->frag_link;
VAR_1->ipq_src = VAR_0->ip_src;
VAR_1->ipq_dst = VAR_0->ip_dst;
VAR_3 = (struct ipasfrag *)VAR_1;
goto insert;
}
for (VAR_3 = VAR_1->frag_link.VAR_6; VAR_3 != (struct ipasfrag *)&VAR_1->frag_link;
VAR_3 = VAR_3->ipf_next)
if (VAR_3->ipf_off > VAR_0->ip_off)
break;
if (VAR_3->ipf_prev != &VAR_1->frag_link) {
struct ipasfrag *VAR_8 = VAR_3->ipf_prev;
VAR_5 = VAR_8->ipf_off + VAR_8->ipf_len - VAR_0->ip_off;
if (VAR_5 > 0) {
if (VAR_5 >= VAR_0->ip_len)
goto dropfrag;
m_adj(dtom(VAR_0), VAR_5);
VAR_0->ip_off += VAR_5;
VAR_0->ip_len -= VAR_5;
}
}
while (VAR_3 != (struct ipasfrag*)&VAR_1->frag_link &&
VAR_0->ip_off + VAR_0->ip_len > VAR_3->ipf_off) {
VAR_5 = (VAR_0->ip_off + VAR_0->ip_len) - VAR_3->ipf_off;
if (VAR_5 < VAR_3->ipf_len) {
VAR_3->ipf_len -= VAR_5;
VAR_3->ipf_off += VAR_5;
m_adj(dtom(VAR_3), VAR_5);
break;
}
VAR_3 = VAR_3->ipf_next;
m_freem(dtom(VAR_3->ipf_prev));
ip_deq(VAR_3->ipf_prev);
}
insert:
ip_enq(iptofrag(VAR_0), VAR_3->ipf_prev);
VAR_6 = 0;
for (VAR_3 = VAR_1->frag_link.VAR_6; VAR_3 != (struct ipasfrag*)&VAR_1->frag_link;
VAR_3 = VAR_3->ipf_next) {
if (VAR_3->ipf_off != VAR_6)
return (0);
VAR_6 += VAR_3->ipf_len;
}
if (((struct ipasfrag *)(VAR_3->ipf_prev))->ipf_tos & 1)
return (0);
VAR_3 = VAR_1->frag_link.VAR_6;
VAR_2 = dtom(VAR_3);
VAR_3 = (struct ipasfrag *) VAR_3->ipf_next;
while (VAR_3 != (struct ipasfrag*)&VAR_1->frag_link) {
struct mbuf *VAR_9 = dtom(VAR_3);
VAR_3 = (struct ipasfrag *) VAR_3->ipf_next;
m_cat(VAR_2, VAR_9);
}
VAR_3 = VAR_1->frag_link.VAR_6;
if (VAR_2->m_flags & M_EXT) {
int VAR_9;
VAR_9 = (char *)VAR_0 - VAR_2->m_dat;
VAR_3 = (struct ipasfrag *)(VAR_2->m_ext + VAR_9);
}
VAR_0 = fragtoip(VAR_3);
VAR_0->ip_len = VAR_6;
VAR_0->ip_tos &= ~1;
VAR_0->ip_src = VAR_1->ipq_src;
VAR_0->ip_dst = VAR_1->ipq_dst;
remque(&VAR_1->ip_link);
(void) m_free(dtom(VAR_1));
VAR_2->m_len += (VAR_0->ip_hl << 2);
VAR_2->m_data -= (VAR_0->ip_hl << 2);
return VAR_0;
dropfrag:
STAT(ipstat.ips_fragdropped++);
m_freem(VAR_2);
return (0);
}
| [
"FUNC_0(register struct VAR_0 *VAR_0, register struct ipq *VAR_1)\n{",
"register struct mbuf *VAR_2 = dtom(VAR_0);",
"register struct ipasfrag *VAR_3;",
"int VAR_4 = VAR_0->ip_hl << 2;",
"int VAR_5, VAR_6;",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_0 = %lx\", (long)VAR_0);",
"DEBUG_ARG(\"VAR_1 = %lx\", (long)VAR_1);",
"DEBUG_ARG(\"VAR_2 = %lx\", (long)VAR_2);",
"VAR_2->m_data += VAR_4;",
"VAR_2->m_len -= VAR_4;",
"if (VAR_1 == 0) {",
"struct mbuf *VAR_9;",
"if ((VAR_9 = m_get()) == NULL) goto dropfrag;",
"VAR_1 = mtod(VAR_9, struct ipq *);",
"insque(&VAR_1->ip_link, &ipq.ip_link);",
"VAR_1->ipq_ttl = IPFRAGTTL;",
"VAR_1->ipq_p = VAR_0->ip_p;",
"VAR_1->ipq_id = VAR_0->ip_id;",
"VAR_1->frag_link.VAR_6 = VAR_1->frag_link.prev = &VAR_1->frag_link;",
"VAR_1->ipq_src = VAR_0->ip_src;",
"VAR_1->ipq_dst = VAR_0->ip_dst;",
"VAR_3 = (struct ipasfrag *)VAR_1;",
"goto insert;",
"}",
"for (VAR_3 = VAR_1->frag_link.VAR_6; VAR_3 != (struct ipasfrag *)&VAR_1->frag_link;",
"VAR_3 = VAR_3->ipf_next)\nif (VAR_3->ipf_off > VAR_0->ip_off)\nbreak;",
"if (VAR_3->ipf_prev != &VAR_1->frag_link) {",
"struct ipasfrag *VAR_8 = VAR_3->ipf_prev;",
"VAR_5 = VAR_8->ipf_off + VAR_8->ipf_len - VAR_0->ip_off;",
"if (VAR_5 > 0) {",
"if (VAR_5 >= VAR_0->ip_len)\ngoto dropfrag;",
"m_adj(dtom(VAR_0), VAR_5);",
"VAR_0->ip_off += VAR_5;",
"VAR_0->ip_len -= VAR_5;",
"}",
"}",
"while (VAR_3 != (struct ipasfrag*)&VAR_1->frag_link &&\nVAR_0->ip_off + VAR_0->ip_len > VAR_3->ipf_off) {",
"VAR_5 = (VAR_0->ip_off + VAR_0->ip_len) - VAR_3->ipf_off;",
"if (VAR_5 < VAR_3->ipf_len) {",
"VAR_3->ipf_len -= VAR_5;",
"VAR_3->ipf_off += VAR_5;",
"m_adj(dtom(VAR_3), VAR_5);",
"break;",
"}",
"VAR_3 = VAR_3->ipf_next;",
"m_freem(dtom(VAR_3->ipf_prev));",
"ip_deq(VAR_3->ipf_prev);",
"}",
"insert:\nip_enq(iptofrag(VAR_0), VAR_3->ipf_prev);",
"VAR_6 = 0;",
"for (VAR_3 = VAR_1->frag_link.VAR_6; VAR_3 != (struct ipasfrag*)&VAR_1->frag_link;",
"VAR_3 = VAR_3->ipf_next) {",
"if (VAR_3->ipf_off != VAR_6)\nreturn (0);",
"VAR_6 += VAR_3->ipf_len;",
"}",
"if (((struct ipasfrag *)(VAR_3->ipf_prev))->ipf_tos & 1)\nreturn (0);",
"VAR_3 = VAR_1->frag_link.VAR_6;",
"VAR_2 = dtom(VAR_3);",
"VAR_3 = (struct ipasfrag *) VAR_3->ipf_next;",
"while (VAR_3 != (struct ipasfrag*)&VAR_1->frag_link) {",
"struct mbuf *VAR_9 = dtom(VAR_3);",
"VAR_3 = (struct ipasfrag *) VAR_3->ipf_next;",
"m_cat(VAR_2, VAR_9);",
"}",
"VAR_3 = VAR_1->frag_link.VAR_6;",
"if (VAR_2->m_flags & M_EXT) {",
"int VAR_9;",
"VAR_9 = (char *)VAR_0 - VAR_2->m_dat;",
"VAR_3 = (struct ipasfrag *)(VAR_2->m_ext + VAR_9);",
"}",
"VAR_0 = fragtoip(VAR_3);",
"VAR_0->ip_len = VAR_6;",
"VAR_0->ip_tos &= ~1;",
"VAR_0->ip_src = VAR_1->ipq_src;",
"VAR_0->ip_dst = VAR_1->ipq_dst;",
"remque(&VAR_1->ip_link);",
"(void) m_free(dtom(VAR_1));",
"VAR_2->m_len += (VAR_0->ip_hl << 2);",
"VAR_2->m_data -= (VAR_0->ip_hl << 2);",
"return VAR_0;",
"dropfrag:\nSTAT(ipstat.ips_fragdropped++);",
"m_freem(VAR_2);",
"return (0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
35
],
[
37
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
83
],
[
85,
87,
89
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163,
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
189,
191
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
233
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
293,
295
],
[
297
],
[
299
],
[
301
]
] |
24,412 | static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t **buf)
{
int width=s->logical_width;
int i;
signed char rlecode;
/* We will use it to compute the best bulk copy sequence */
unsigned int bulkcount;
/* This will be the number of pixels equal to the preivous frame one's
* starting from the ith pixel */
unsigned int skipcount;
/* This will be the number of consecutive equal pixels in the current
* frame, starting from the ith one also */
unsigned int repeatcount;
/* The cost of the three different possibilities */
int total_bulk_cost;
int total_skip_cost;
int total_repeat_cost;
int temp_cost;
int j;
uint8_t *this_line = p-> data[0] + line*p-> linesize[0] +
(width - 1)*s->pixel_size;
uint8_t *prev_line = s->previous_frame.data[0] + line*s->previous_frame.linesize[0] +
(width - 1)*s->pixel_size;
s->length_table[width] = 0;
skipcount = 0;
for (i = width - 1; i >= 0; i--) {
if (!s->frame.key_frame && !memcmp(this_line, prev_line, s->pixel_size))
skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
else
skipcount = 0;
total_skip_cost = s->length_table[i + skipcount] + 2;
s->skip_table[i] = skipcount;
if (i < width - 1 && !memcmp(this_line, this_line + s->pixel_size, s->pixel_size))
repeatcount = FFMIN(repeatcount + 1, MAX_RLE_REPEAT);
else
repeatcount = 1;
total_repeat_cost = s->length_table[i + repeatcount] + 1 + s->pixel_size;
/* skip code is free for the first pixel, it costs one byte for repeat and bulk copy
* so let's make it aware */
if (i == 0) {
total_skip_cost--;
total_repeat_cost++;
}
if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
/* repeat is the best */
s->length_table[i] = total_repeat_cost;
s->rlecode_table[i] = -repeatcount;
}
else if (skipcount > 0) {
/* skip is the best choice here */
s->length_table[i] = total_skip_cost;
s->rlecode_table[i] = 0;
}
else {
/* We cannot do neither skip nor repeat
* thus we search for the best bulk copy to do */
int limit = FFMIN(width - i, MAX_RLE_BULK);
temp_cost = 1 + s->pixel_size + !i;
total_bulk_cost = INT_MAX;
for (j = 1; j <= limit; j++) {
if (s->length_table[i + j] + temp_cost < total_bulk_cost) {
/* We have found a better bulk copy ... */
total_bulk_cost = s->length_table[i + j] + temp_cost;
bulkcount = j;
}
temp_cost += s->pixel_size;
}
s->length_table[i] = total_bulk_cost;
s->rlecode_table[i] = bulkcount;
}
this_line -= s->pixel_size;
prev_line -= s->pixel_size;
}
/* Good ! Now we have the best sequence for this line, let's output it */
/* We do a special case for the first pixel so that we avoid testing it in
* the whole loop */
i=0;
this_line = p-> data[0] + line*p->linesize[0];
if (s->rlecode_table[0] == 0) {
bytestream_put_byte(buf, s->skip_table[0] + 1);
i += s->skip_table[0];
}
else bytestream_put_byte(buf, 1);
while (i < width) {
rlecode = s->rlecode_table[i];
bytestream_put_byte(buf, rlecode);
if (rlecode == 0) {
/* Write a skip sequence */
bytestream_put_byte(buf, s->skip_table[i] + 1);
i += s->skip_table[i];
}
else if (rlecode > 0) {
/* bulk copy */
if (s->avctx->pix_fmt == PIX_FMT_GRAY8) {
int j;
// QT grayscale colorspace has 0=white and 255=black, we will
// ignore the palette that is included in the AVFrame because
// PIX_FMT_GRAY8 has defined color mapping
for (j = 0; j < rlecode*s->pixel_size; ++j)
bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff);
} else {
bytestream_put_buffer(buf, this_line + i*s->pixel_size, rlecode*s->pixel_size);
}
i += rlecode;
}
else {
/* repeat the bits */
if (s->avctx->pix_fmt == PIX_FMT_GRAY8) {
int j;
// QT grayscale colorspace has 0=white and 255=black, ...
for (j = 0; j < s->pixel_size; ++j)
bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff);
} else {
bytestream_put_buffer(buf, this_line + i*s->pixel_size, s->pixel_size);
}
i -= rlecode;
}
}
bytestream_put_byte(buf, -1); // end RLE line
}
| true | FFmpeg | 8b18288c08fd450601251700eb42d9efbef89803 | static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t **buf)
{
int width=s->logical_width;
int i;
signed char rlecode;
unsigned int bulkcount;
unsigned int skipcount;
unsigned int repeatcount;
int total_bulk_cost;
int total_skip_cost;
int total_repeat_cost;
int temp_cost;
int j;
uint8_t *this_line = p-> data[0] + line*p-> linesize[0] +
(width - 1)*s->pixel_size;
uint8_t *prev_line = s->previous_frame.data[0] + line*s->previous_frame.linesize[0] +
(width - 1)*s->pixel_size;
s->length_table[width] = 0;
skipcount = 0;
for (i = width - 1; i >= 0; i--) {
if (!s->frame.key_frame && !memcmp(this_line, prev_line, s->pixel_size))
skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
else
skipcount = 0;
total_skip_cost = s->length_table[i + skipcount] + 2;
s->skip_table[i] = skipcount;
if (i < width - 1 && !memcmp(this_line, this_line + s->pixel_size, s->pixel_size))
repeatcount = FFMIN(repeatcount + 1, MAX_RLE_REPEAT);
else
repeatcount = 1;
total_repeat_cost = s->length_table[i + repeatcount] + 1 + s->pixel_size;
if (i == 0) {
total_skip_cost--;
total_repeat_cost++;
}
if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
s->length_table[i] = total_repeat_cost;
s->rlecode_table[i] = -repeatcount;
}
else if (skipcount > 0) {
s->length_table[i] = total_skip_cost;
s->rlecode_table[i] = 0;
}
else {
int limit = FFMIN(width - i, MAX_RLE_BULK);
temp_cost = 1 + s->pixel_size + !i;
total_bulk_cost = INT_MAX;
for (j = 1; j <= limit; j++) {
if (s->length_table[i + j] + temp_cost < total_bulk_cost) {
total_bulk_cost = s->length_table[i + j] + temp_cost;
bulkcount = j;
}
temp_cost += s->pixel_size;
}
s->length_table[i] = total_bulk_cost;
s->rlecode_table[i] = bulkcount;
}
this_line -= s->pixel_size;
prev_line -= s->pixel_size;
}
i=0;
this_line = p-> data[0] + line*p->linesize[0];
if (s->rlecode_table[0] == 0) {
bytestream_put_byte(buf, s->skip_table[0] + 1);
i += s->skip_table[0];
}
else bytestream_put_byte(buf, 1);
while (i < width) {
rlecode = s->rlecode_table[i];
bytestream_put_byte(buf, rlecode);
if (rlecode == 0) {
bytestream_put_byte(buf, s->skip_table[i] + 1);
i += s->skip_table[i];
}
else if (rlecode > 0) {
if (s->avctx->pix_fmt == PIX_FMT_GRAY8) {
int j;
for (j = 0; j < rlecode*s->pixel_size; ++j)
bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff);
} else {
bytestream_put_buffer(buf, this_line + i*s->pixel_size, rlecode*s->pixel_size);
}
i += rlecode;
}
else {
if (s->avctx->pix_fmt == PIX_FMT_GRAY8) {
int j;
for (j = 0; j < s->pixel_size; ++j)
bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff);
} else {
bytestream_put_buffer(buf, this_line + i*s->pixel_size, s->pixel_size);
}
i -= rlecode;
}
}
bytestream_put_byte(buf, -1);
}
| {
"code": [
" unsigned int bulkcount;",
" unsigned int repeatcount;"
],
"line_no": [
15,
27
]
} | static void FUNC_0(QtrleEncContext *VAR_0, AVFrame *VAR_1, int VAR_2, uint8_t **VAR_3)
{
int VAR_4=VAR_0->logical_width;
int VAR_5;
signed char VAR_6;
unsigned int VAR_7;
unsigned int VAR_8;
unsigned int VAR_9;
int VAR_10;
int VAR_11;
int VAR_12;
int VAR_13;
int VAR_16;
uint8_t *this_line = VAR_1-> data[0] + VAR_2*VAR_1-> linesize[0] +
(VAR_4 - 1)*VAR_0->pixel_size;
uint8_t *prev_line = VAR_0->previous_frame.data[0] + VAR_2*VAR_0->previous_frame.linesize[0] +
(VAR_4 - 1)*VAR_0->pixel_size;
VAR_0->length_table[VAR_4] = 0;
VAR_8 = 0;
for (VAR_5 = VAR_4 - 1; VAR_5 >= 0; VAR_5--) {
if (!VAR_0->frame.key_frame && !memcmp(this_line, prev_line, VAR_0->pixel_size))
VAR_8 = FFMIN(VAR_8 + 1, MAX_RLE_SKIP);
else
VAR_8 = 0;
VAR_11 = VAR_0->length_table[VAR_5 + VAR_8] + 2;
VAR_0->skip_table[VAR_5] = VAR_8;
if (VAR_5 < VAR_4 - 1 && !memcmp(this_line, this_line + VAR_0->pixel_size, VAR_0->pixel_size))
VAR_9 = FFMIN(VAR_9 + 1, MAX_RLE_REPEAT);
else
VAR_9 = 1;
VAR_12 = VAR_0->length_table[VAR_5 + VAR_9] + 1 + VAR_0->pixel_size;
if (VAR_5 == 0) {
VAR_11--;
VAR_12++;
}
if (VAR_9 > 1 && (VAR_8 == 0 || VAR_12 < VAR_11)) {
VAR_0->length_table[VAR_5] = VAR_12;
VAR_0->rlecode_table[VAR_5] = -VAR_9;
}
else if (VAR_8 > 0) {
VAR_0->length_table[VAR_5] = VAR_11;
VAR_0->rlecode_table[VAR_5] = 0;
}
else {
int VAR_15 = FFMIN(VAR_4 - VAR_5, MAX_RLE_BULK);
VAR_13 = 1 + VAR_0->pixel_size + !VAR_5;
VAR_10 = INT_MAX;
for (VAR_16 = 1; VAR_16 <= VAR_15; VAR_16++) {
if (VAR_0->length_table[VAR_5 + VAR_16] + VAR_13 < VAR_10) {
VAR_10 = VAR_0->length_table[VAR_5 + VAR_16] + VAR_13;
VAR_7 = VAR_16;
}
VAR_13 += VAR_0->pixel_size;
}
VAR_0->length_table[VAR_5] = VAR_10;
VAR_0->rlecode_table[VAR_5] = VAR_7;
}
this_line -= VAR_0->pixel_size;
prev_line -= VAR_0->pixel_size;
}
VAR_5=0;
this_line = VAR_1-> data[0] + VAR_2*VAR_1->linesize[0];
if (VAR_0->rlecode_table[0] == 0) {
bytestream_put_byte(VAR_3, VAR_0->skip_table[0] + 1);
VAR_5 += VAR_0->skip_table[0];
}
else bytestream_put_byte(VAR_3, 1);
while (VAR_5 < VAR_4) {
VAR_6 = VAR_0->rlecode_table[VAR_5];
bytestream_put_byte(VAR_3, VAR_6);
if (VAR_6 == 0) {
bytestream_put_byte(VAR_3, VAR_0->skip_table[VAR_5] + 1);
VAR_5 += VAR_0->skip_table[VAR_5];
}
else if (VAR_6 > 0) {
if (VAR_0->avctx->pix_fmt == PIX_FMT_GRAY8) {
int VAR_16;
for (VAR_16 = 0; VAR_16 < VAR_6*VAR_0->pixel_size; ++VAR_16)
bytestream_put_byte(VAR_3, *(this_line + VAR_5*VAR_0->pixel_size + VAR_16) ^ 0xff);
} else {
bytestream_put_buffer(VAR_3, this_line + VAR_5*VAR_0->pixel_size, VAR_6*VAR_0->pixel_size);
}
VAR_5 += VAR_6;
}
else {
if (VAR_0->avctx->pix_fmt == PIX_FMT_GRAY8) {
int VAR_16;
for (VAR_16 = 0; VAR_16 < VAR_0->pixel_size; ++VAR_16)
bytestream_put_byte(VAR_3, *(this_line + VAR_5*VAR_0->pixel_size + VAR_16) ^ 0xff);
} else {
bytestream_put_buffer(VAR_3, this_line + VAR_5*VAR_0->pixel_size, VAR_0->pixel_size);
}
VAR_5 -= VAR_6;
}
}
bytestream_put_byte(VAR_3, -1);
}
| [
"static void FUNC_0(QtrleEncContext *VAR_0, AVFrame *VAR_1, int VAR_2, uint8_t **VAR_3)\n{",
"int VAR_4=VAR_0->logical_width;",
"int VAR_5;",
"signed char VAR_6;",
"unsigned int VAR_7;",
"unsigned int VAR_8;",
"unsigned int VAR_9;",
"int VAR_10;",
"int VAR_11;",
"int VAR_12;",
"int VAR_13;",
"int VAR_16;",
"uint8_t *this_line = VAR_1-> data[0] + VAR_2*VAR_1-> linesize[0] +\n(VAR_4 - 1)*VAR_0->pixel_size;",
"uint8_t *prev_line = VAR_0->previous_frame.data[0] + VAR_2*VAR_0->previous_frame.linesize[0] +\n(VAR_4 - 1)*VAR_0->pixel_size;",
"VAR_0->length_table[VAR_4] = 0;",
"VAR_8 = 0;",
"for (VAR_5 = VAR_4 - 1; VAR_5 >= 0; VAR_5--) {",
"if (!VAR_0->frame.key_frame && !memcmp(this_line, prev_line, VAR_0->pixel_size))\nVAR_8 = FFMIN(VAR_8 + 1, MAX_RLE_SKIP);",
"else\nVAR_8 = 0;",
"VAR_11 = VAR_0->length_table[VAR_5 + VAR_8] + 2;",
"VAR_0->skip_table[VAR_5] = VAR_8;",
"if (VAR_5 < VAR_4 - 1 && !memcmp(this_line, this_line + VAR_0->pixel_size, VAR_0->pixel_size))\nVAR_9 = FFMIN(VAR_9 + 1, MAX_RLE_REPEAT);",
"else\nVAR_9 = 1;",
"VAR_12 = VAR_0->length_table[VAR_5 + VAR_9] + 1 + VAR_0->pixel_size;",
"if (VAR_5 == 0) {",
"VAR_11--;",
"VAR_12++;",
"}",
"if (VAR_9 > 1 && (VAR_8 == 0 || VAR_12 < VAR_11)) {",
"VAR_0->length_table[VAR_5] = VAR_12;",
"VAR_0->rlecode_table[VAR_5] = -VAR_9;",
"}",
"else if (VAR_8 > 0) {",
"VAR_0->length_table[VAR_5] = VAR_11;",
"VAR_0->rlecode_table[VAR_5] = 0;",
"}",
"else {",
"int VAR_15 = FFMIN(VAR_4 - VAR_5, MAX_RLE_BULK);",
"VAR_13 = 1 + VAR_0->pixel_size + !VAR_5;",
"VAR_10 = INT_MAX;",
"for (VAR_16 = 1; VAR_16 <= VAR_15; VAR_16++) {",
"if (VAR_0->length_table[VAR_5 + VAR_16] + VAR_13 < VAR_10) {",
"VAR_10 = VAR_0->length_table[VAR_5 + VAR_16] + VAR_13;",
"VAR_7 = VAR_16;",
"}",
"VAR_13 += VAR_0->pixel_size;",
"}",
"VAR_0->length_table[VAR_5] = VAR_10;",
"VAR_0->rlecode_table[VAR_5] = VAR_7;",
"}",
"this_line -= VAR_0->pixel_size;",
"prev_line -= VAR_0->pixel_size;",
"}",
"VAR_5=0;",
"this_line = VAR_1-> data[0] + VAR_2*VAR_1->linesize[0];",
"if (VAR_0->rlecode_table[0] == 0) {",
"bytestream_put_byte(VAR_3, VAR_0->skip_table[0] + 1);",
"VAR_5 += VAR_0->skip_table[0];",
"}",
"else bytestream_put_byte(VAR_3, 1);",
"while (VAR_5 < VAR_4) {",
"VAR_6 = VAR_0->rlecode_table[VAR_5];",
"bytestream_put_byte(VAR_3, VAR_6);",
"if (VAR_6 == 0) {",
"bytestream_put_byte(VAR_3, VAR_0->skip_table[VAR_5] + 1);",
"VAR_5 += VAR_0->skip_table[VAR_5];",
"}",
"else if (VAR_6 > 0) {",
"if (VAR_0->avctx->pix_fmt == PIX_FMT_GRAY8) {",
"int VAR_16;",
"for (VAR_16 = 0; VAR_16 < VAR_6*VAR_0->pixel_size; ++VAR_16)",
"bytestream_put_byte(VAR_3, *(this_line + VAR_5*VAR_0->pixel_size + VAR_16) ^ 0xff);",
"} else {",
"bytestream_put_buffer(VAR_3, this_line + VAR_5*VAR_0->pixel_size, VAR_6*VAR_0->pixel_size);",
"}",
"VAR_5 += VAR_6;",
"}",
"else {",
"if (VAR_0->avctx->pix_fmt == PIX_FMT_GRAY8) {",
"int VAR_16;",
"for (VAR_16 = 0; VAR_16 < VAR_0->pixel_size; ++VAR_16)",
"bytestream_put_byte(VAR_3, *(this_line + VAR_5*VAR_0->pixel_size + VAR_16) ^ 0xff);",
"} else {",
"bytestream_put_buffer(VAR_3, this_line + VAR_5*VAR_0->pixel_size, VAR_0->pixel_size);",
"}",
"VAR_5 -= VAR_6;",
"}",
"}",
"bytestream_put_byte(VAR_3, -1);",
"}"
] | [
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
21
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47,
49
],
[
51,
53
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
71,
73
],
[
77
],
[
79
],
[
85,
87
],
[
89,
91
],
[
95
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
141
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
]
] |
24,413 | static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| {
"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;",
" dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];",
" dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];",
" dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];",
" dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];",
" 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;"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
29,
31,
33,
35,
5,
5,
5,
5
]
} | static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, DCTELEM *VAR_2){
int VAR_3[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int VAR_4;
rv34_row_transform(VAR_3, VAR_2);
memset(VAR_2, 0, 16*sizeof(DCTELEM));
for(VAR_4 = 0; VAR_4 < 4; VAR_4++){
const int VAR_5 = 13*(VAR_3[4*0+VAR_4] + VAR_3[4*2+VAR_4]) + 0x200;
const int VAR_6 = 13*(VAR_3[4*0+VAR_4] - VAR_3[4*2+VAR_4]) + 0x200;
const int VAR_7 = 7* VAR_3[4*1+VAR_4] - 17*VAR_3[4*3+VAR_4];
const int VAR_8 = 17* VAR_3[4*1+VAR_4] + 7*VAR_3[4*3+VAR_4];
VAR_0[0] = cm[ VAR_0[0] + ( (VAR_5 + VAR_8) >> 10 ) ];
VAR_0[1] = cm[ VAR_0[1] + ( (VAR_6 + VAR_7) >> 10 ) ];
VAR_0[2] = cm[ VAR_0[2] + ( (VAR_6 - VAR_7) >> 10 ) ];
VAR_0[3] = cm[ VAR_0[3] + ( (VAR_5 - VAR_8) >> 10 ) ];
VAR_0 += VAR_1;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, DCTELEM *VAR_2){",
"int VAR_3[16];",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"int VAR_4;",
"rv34_row_transform(VAR_3, VAR_2);",
"memset(VAR_2, 0, 16*sizeof(DCTELEM));",
"for(VAR_4 = 0; VAR_4 < 4; VAR_4++){",
"const int VAR_5 = 13*(VAR_3[4*0+VAR_4] + VAR_3[4*2+VAR_4]) + 0x200;",
"const int VAR_6 = 13*(VAR_3[4*0+VAR_4] - VAR_3[4*2+VAR_4]) + 0x200;",
"const int VAR_7 = 7* VAR_3[4*1+VAR_4] - 17*VAR_3[4*3+VAR_4];",
"const int VAR_8 = 17* VAR_3[4*1+VAR_4] + 7*VAR_3[4*3+VAR_4];",
"VAR_0[0] = cm[ VAR_0[0] + ( (VAR_5 + VAR_8) >> 10 ) ];",
"VAR_0[1] = cm[ VAR_0[1] + ( (VAR_6 + VAR_7) >> 10 ) ];",
"VAR_0[2] = cm[ VAR_0[2] + ( (VAR_6 - VAR_7) >> 10 ) ];",
"VAR_0[3] = cm[ VAR_0[3] + ( (VAR_5 - VAR_8) >> 10 ) ];",
"VAR_0 += VAR_1;",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
]
] |
24,414 | int ff_lpc_calc_coefs(DSPContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
int omethod, int max_shift, int zero_shift)
{
double autoc[MAX_LPC_ORDER+1];
double ref[MAX_LPC_ORDER];
double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
int i, j, pass;
int opt_order;
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);
if(use_lpc == 1){
s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
for(i=0; i<max_order; i++)
ref[i] = fabs(lpc[i][i]);
}else{
LLSModel m[2];
double var[MAX_LPC_ORDER+1], weight;
for(pass=0; pass<use_lpc-1; pass++){
av_init_lls(&m[pass&1], max_order);
weight=0;
for(i=max_order; i<blocksize; i++){
for(j=0; j<=max_order; j++)
var[j]= samples[i-j];
if(pass){
double eval, inv, rinv;
eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
eval= (512>>pass) + fabs(eval - var[0]);
inv = 1/eval;
rinv = sqrt(inv);
for(j=0; j<=max_order; j++)
var[j] *= rinv;
weight += inv;
}else
weight++;
av_update_lls(&m[pass&1], var, 1.0);
}
av_solve_lls(&m[pass&1], 0.001, 0);
}
for(i=0; i<max_order; i++){
for(j=0; j<max_order; j++)
lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
}
for(i=max_order-1; i>0; i--)
ref[i] = ref[i-1] - ref[i];
}
opt_order = max_order;
if(omethod == ORDER_METHOD_EST) {
opt_order = estimate_best_order(ref, min_order, max_order);
i = opt_order-1;
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
} else {
for(i=min_order-1; i<max_order; i++) {
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
}
}
return opt_order;
}
| true | FFmpeg | 3cfe88194a6ea8c720dfc85239d03c659473bcc3 | int ff_lpc_calc_coefs(DSPContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
int omethod, int max_shift, int zero_shift)
{
double autoc[MAX_LPC_ORDER+1];
double ref[MAX_LPC_ORDER];
double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
int i, j, pass;
int opt_order;
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);
if(use_lpc == 1){
s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
for(i=0; i<max_order; i++)
ref[i] = fabs(lpc[i][i]);
}else{
LLSModel m[2];
double var[MAX_LPC_ORDER+1], weight;
for(pass=0; pass<use_lpc-1; pass++){
av_init_lls(&m[pass&1], max_order);
weight=0;
for(i=max_order; i<blocksize; i++){
for(j=0; j<=max_order; j++)
var[j]= samples[i-j];
if(pass){
double eval, inv, rinv;
eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
eval= (512>>pass) + fabs(eval - var[0]);
inv = 1/eval;
rinv = sqrt(inv);
for(j=0; j<=max_order; j++)
var[j] *= rinv;
weight += inv;
}else
weight++;
av_update_lls(&m[pass&1], var, 1.0);
}
av_solve_lls(&m[pass&1], 0.001, 0);
}
for(i=0; i<max_order; i++){
for(j=0; j<max_order; j++)
lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
}
for(i=max_order-1; i>0; i--)
ref[i] = ref[i-1] - ref[i];
}
opt_order = max_order;
if(omethod == ORDER_METHOD_EST) {
opt_order = estimate_best_order(ref, min_order, max_order);
i = opt_order-1;
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
} else {
for(i=min_order-1; i<max_order; i++) {
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
}
}
return opt_order;
}
| {
"code": [
" double var[MAX_LPC_ORDER+1], weight;"
],
"line_no": [
47
]
} | int FUNC_0(DSPContext *VAR_0,
const int32_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5,
int32_t VAR_6[][MAX_LPC_ORDER], int *VAR_7, int VAR_8,
int VAR_9, int VAR_10, int VAR_11)
{
double VAR_12[MAX_LPC_ORDER+1];
double VAR_13[MAX_LPC_ORDER];
double VAR_14[MAX_LPC_ORDER][MAX_LPC_ORDER];
int VAR_15, VAR_16, VAR_17;
int VAR_18;
assert(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER && VAR_8 > 0);
if(VAR_8 == 1){
VAR_0->flac_compute_autocorr(VAR_1, VAR_2, VAR_4, VAR_12);
compute_lpc_coefs(VAR_12, VAR_4, &VAR_14[0][0], MAX_LPC_ORDER, 0, 1);
for(VAR_15=0; VAR_15<VAR_4; VAR_15++)
VAR_13[VAR_15] = fabs(VAR_14[VAR_15][VAR_15]);
}else{
LLSModel m[2];
double VAR_19[MAX_LPC_ORDER+1], weight;
for(VAR_17=0; VAR_17<VAR_8-1; VAR_17++){
av_init_lls(&m[VAR_17&1], VAR_4);
weight=0;
for(VAR_15=VAR_4; VAR_15<VAR_2; VAR_15++){
for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)
VAR_19[VAR_16]= VAR_1[VAR_15-VAR_16];
if(VAR_17){
double VAR_20, VAR_21, VAR_22;
VAR_20= av_evaluate_lls(&m[(VAR_17-1)&1], VAR_19+1, VAR_4-1);
VAR_20= (512>>VAR_17) + fabs(VAR_20 - VAR_19[0]);
VAR_21 = 1/VAR_20;
VAR_22 = sqrt(VAR_21);
for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)
VAR_19[VAR_16] *= VAR_22;
weight += VAR_21;
}else
weight++;
av_update_lls(&m[VAR_17&1], VAR_19, 1.0);
}
av_solve_lls(&m[VAR_17&1], 0.001, 0);
}
for(VAR_15=0; VAR_15<VAR_4; VAR_15++){
for(VAR_16=0; VAR_16<VAR_4; VAR_16++)
VAR_14[VAR_15][VAR_16]=-m[(VAR_17-1)&1].coeff[VAR_15][VAR_16];
VAR_13[VAR_15]= sqrt(m[(VAR_17-1)&1].variance[VAR_15] / weight) * (VAR_2 - VAR_4) / 4000;
}
for(VAR_15=VAR_4-1; VAR_15>0; VAR_15--)
VAR_13[VAR_15] = VAR_13[VAR_15-1] - VAR_13[VAR_15];
}
VAR_18 = VAR_4;
if(VAR_9 == ORDER_METHOD_EST) {
VAR_18 = estimate_best_order(VAR_13, VAR_3, VAR_4);
VAR_15 = VAR_18-1;
quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);
} else {
for(VAR_15=VAR_3-1; VAR_15<VAR_4; VAR_15++) {
quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);
}
}
return VAR_18;
}
| [
"int FUNC_0(DSPContext *VAR_0,\nconst int32_t *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5,\nint32_t VAR_6[][MAX_LPC_ORDER], int *VAR_7, int VAR_8,\nint VAR_9, int VAR_10, int VAR_11)\n{",
"double VAR_12[MAX_LPC_ORDER+1];",
"double VAR_13[MAX_LPC_ORDER];",
"double VAR_14[MAX_LPC_ORDER][MAX_LPC_ORDER];",
"int VAR_15, VAR_16, VAR_17;",
"int VAR_18;",
"assert(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER && VAR_8 > 0);",
"if(VAR_8 == 1){",
"VAR_0->flac_compute_autocorr(VAR_1, VAR_2, VAR_4, VAR_12);",
"compute_lpc_coefs(VAR_12, VAR_4, &VAR_14[0][0], MAX_LPC_ORDER, 0, 1);",
"for(VAR_15=0; VAR_15<VAR_4; VAR_15++)",
"VAR_13[VAR_15] = fabs(VAR_14[VAR_15][VAR_15]);",
"}else{",
"LLSModel m[2];",
"double VAR_19[MAX_LPC_ORDER+1], weight;",
"for(VAR_17=0; VAR_17<VAR_8-1; VAR_17++){",
"av_init_lls(&m[VAR_17&1], VAR_4);",
"weight=0;",
"for(VAR_15=VAR_4; VAR_15<VAR_2; VAR_15++){",
"for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)",
"VAR_19[VAR_16]= VAR_1[VAR_15-VAR_16];",
"if(VAR_17){",
"double VAR_20, VAR_21, VAR_22;",
"VAR_20= av_evaluate_lls(&m[(VAR_17-1)&1], VAR_19+1, VAR_4-1);",
"VAR_20= (512>>VAR_17) + fabs(VAR_20 - VAR_19[0]);",
"VAR_21 = 1/VAR_20;",
"VAR_22 = sqrt(VAR_21);",
"for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)",
"VAR_19[VAR_16] *= VAR_22;",
"weight += VAR_21;",
"}else",
"weight++;",
"av_update_lls(&m[VAR_17&1], VAR_19, 1.0);",
"}",
"av_solve_lls(&m[VAR_17&1], 0.001, 0);",
"}",
"for(VAR_15=0; VAR_15<VAR_4; VAR_15++){",
"for(VAR_16=0; VAR_16<VAR_4; VAR_16++)",
"VAR_14[VAR_15][VAR_16]=-m[(VAR_17-1)&1].coeff[VAR_15][VAR_16];",
"VAR_13[VAR_15]= sqrt(m[(VAR_17-1)&1].variance[VAR_15] / weight) * (VAR_2 - VAR_4) / 4000;",
"}",
"for(VAR_15=VAR_4-1; VAR_15>0; VAR_15--)",
"VAR_13[VAR_15] = VAR_13[VAR_15-1] - VAR_13[VAR_15];",
"}",
"VAR_18 = VAR_4;",
"if(VAR_9 == ORDER_METHOD_EST) {",
"VAR_18 = estimate_best_order(VAR_13, VAR_3, VAR_4);",
"VAR_15 = VAR_18-1;",
"quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);",
"} else {",
"for(VAR_15=VAR_3-1; VAR_15<VAR_4; VAR_15++) {",
"quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);",
"}",
"}",
"return VAR_18;",
"}"
] | [
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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
]
] |
24,416 | av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
{
av_unused int cpu_flags = av_get_cpu_flags();
cavsdsp_init_mmx(c, avctx);
#if HAVE_AMD3DNOW_INLINE
if (INLINE_AMD3DNOW(cpu_flags))
cavsdsp_init_3dnow(c, avctx);
#endif /* HAVE_AMD3DNOW_INLINE */
#if HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags)) {
DSPFUNC(put, 0, 16, mmxext);
DSPFUNC(put, 1, 8, mmxext);
DSPFUNC(avg, 0, 16, mmxext);
DSPFUNC(avg, 1, 8, mmxext);
}
#endif
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;
}
#endif
#if HAVE_SSE2_EXTERNAL
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;
}
#endif
}
| true | FFmpeg | 835d9f299cf6b3704989a7b3eccfa1c2ec6866d9 | av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
{
av_unused int cpu_flags = av_get_cpu_flags();
cavsdsp_init_mmx(c, avctx);
#if HAVE_AMD3DNOW_INLINE
if (INLINE_AMD3DNOW(cpu_flags))
cavsdsp_init_3dnow(c, avctx);
#endif
#if HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags)) {
DSPFUNC(put, 0, 16, mmxext);
DSPFUNC(put, 1, 8, mmxext);
DSPFUNC(avg, 0, 16, mmxext);
DSPFUNC(avg, 1, 8, mmxext);
}
#endif
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;
}
#endif
#if HAVE_SSE2_EXTERNAL
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;
}
#endif
}
| {
"code": [
" cavsdsp_init_mmx(c, avctx);"
],
"line_no": [
9
]
} | av_cold void FUNC_0(CAVSDSPContext *c, AVCodecContext *avctx)
{
av_unused int cpu_flags = av_get_cpu_flags();
cavsdsp_init_mmx(c, avctx);
#if HAVE_AMD3DNOW_INLINE
if (INLINE_AMD3DNOW(cpu_flags))
cavsdsp_init_3dnow(c, avctx);
#endif
#if HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags)) {
DSPFUNC(put, 0, 16, mmxext);
DSPFUNC(put, 1, 8, mmxext);
DSPFUNC(avg, 0, 16, mmxext);
DSPFUNC(avg, 1, 8, mmxext);
}
#endif
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;
}
#endif
#if HAVE_SSE2_EXTERNAL
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;
}
#endif
}
| [
"av_cold void FUNC_0(CAVSDSPContext *c, AVCodecContext *avctx)\n{",
"av_unused int cpu_flags = av_get_cpu_flags();",
"cavsdsp_init_mmx(c, avctx);",
"#if HAVE_AMD3DNOW_INLINE\nif (INLINE_AMD3DNOW(cpu_flags))\ncavsdsp_init_3dnow(c, avctx);",
"#endif\n#if HAVE_MMXEXT_INLINE\nif (INLINE_MMXEXT(cpu_flags)) {",
"DSPFUNC(put, 0, 16, mmxext);",
"DSPFUNC(put, 1, 8, mmxext);",
"DSPFUNC(avg, 0, 16, mmxext);",
"DSPFUNC(avg, 1, 8, mmxext);",
"}",
"#endif\n#if HAVE_MMX_EXTERNAL\nif (EXTERNAL_MMXEXT(cpu_flags)) {",
"c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;",
"c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;",
"}",
"#endif\n#if HAVE_SSE2_EXTERNAL\nif (EXTERNAL_SSE2(cpu_flags)) {",
"c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;",
"c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;",
"}",
"#endif\n}"
] | [
0,
0,
1,
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,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
]
] |
24,417 | static bool object_create_initial(const char *type)
{
if (g_str_equal(type, "rng-egd")) {
/*
* return false for concrete netfilters since
* they depend on netdevs already existing
if (g_str_equal(type, "filter-buffer") ||
g_str_equal(type, "filter-dump") ||
g_str_equal(type, "filter-mirror") ||
g_str_equal(type, "filter-redirector")) {
return true; | true | qemu | 6546d0dba6c211c1a3eac1252a4f50a0c151a08a | static bool object_create_initial(const char *type)
{
if (g_str_equal(type, "rng-egd")) {
/*
* return false for concrete netfilters since
* they depend on netdevs already existing
if (g_str_equal(type, "filter-buffer") ||
g_str_equal(type, "filter-dump") ||
g_str_equal(type, "filter-mirror") ||
g_str_equal(type, "filter-redirector")) {
return true; | {
"code": [],
"line_no": []
} | static bool FUNC_0(const char *type)
{
if (g_str_equal(type, "rng-egd")) {
/*
* return false for concrete netfilters since
* they depend on netdevs already existing
if (g_str_equal(type, "filter-buffer") ||
g_str_equal(type, "filter-dump") ||
g_str_equal(type, "filter-mirror") ||
g_str_equal(type, "filter-redirector")) {
return true; | [
"static bool FUNC_0(const char *type)\n{",
"if (g_str_equal(type, \"rng-egd\")) {",
"/*\n* return false for concrete netfilters since\n* they depend on netdevs already existing\nif (g_str_equal(type, \"filter-buffer\") ||\ng_str_equal(type, \"filter-dump\") ||\ng_str_equal(type, \"filter-mirror\") ||\ng_str_equal(type, \"filter-redirector\")) {",
"return true;"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4,
5,
6,
7,
8,
9,
10
],
[
11
]
] |
24,418 | static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVBochsState *s = bs->opaque;
int i;
struct bochs_header bochs;
struct bochs_header_v1 header_v1;
int ret;
bs->read_only = 1; // no write support yet
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
if (ret < 0) {
return ret;
}
if (strcmp(bochs.magic, HEADER_MAGIC) ||
strcmp(bochs.type, REDOLOG_TYPE) ||
strcmp(bochs.subtype, GROWING_TYPE) ||
((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
(le32_to_cpu(bochs.version) != HEADER_V1))) {
error_setg(errp, "Image not in Bochs format");
return -EINVAL;
}
if (le32_to_cpu(bochs.version) == HEADER_V1) {
memcpy(&header_v1, &bochs, sizeof(bochs));
bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;
} else {
bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
}
s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
ret = bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap,
s->catalog_size * 4);
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->catalog_bitmap);
return ret;
}
| true | qemu | 3dd8a6763bcc50dfc3de8da9279b741c0dea9fb1 | static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVBochsState *s = bs->opaque;
int i;
struct bochs_header bochs;
struct bochs_header_v1 header_v1;
int ret;
bs->read_only = 1;
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
if (ret < 0) {
return ret;
}
if (strcmp(bochs.magic, HEADER_MAGIC) ||
strcmp(bochs.type, REDOLOG_TYPE) ||
strcmp(bochs.subtype, GROWING_TYPE) ||
((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
(le32_to_cpu(bochs.version) != HEADER_V1))) {
error_setg(errp, "Image not in Bochs format");
return -EINVAL;
}
if (le32_to_cpu(bochs.version) == HEADER_V1) {
memcpy(&header_v1, &bochs, sizeof(bochs));
bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;
} else {
bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
}
s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
ret = bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap,
s->catalog_size * 4);
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->catalog_bitmap);
return ret;
}
| {
"code": [
" struct bochs_header_v1 header_v1;",
" memcpy(&header_v1, &bochs, sizeof(bochs));",
" bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;",
" bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;",
" s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);",
" s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;",
" s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;",
" s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);"
],
"line_no": [
13,
53,
55,
59,
65,
93,
95,
99
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVBochsState *s = VAR_0->opaque;
int VAR_4;
struct bochs_header VAR_5;
struct bochs_header_v1 VAR_6;
int VAR_7;
VAR_0->read_only = 1;
VAR_7 = bdrv_pread(VAR_0->file, 0, &VAR_5, sizeof(VAR_5));
if (VAR_7 < 0) {
return VAR_7;
}
if (strcmp(VAR_5.magic, HEADER_MAGIC) ||
strcmp(VAR_5.type, REDOLOG_TYPE) ||
strcmp(VAR_5.subtype, GROWING_TYPE) ||
((le32_to_cpu(VAR_5.version) != HEADER_VERSION) &&
(le32_to_cpu(VAR_5.version) != HEADER_V1))) {
error_setg(VAR_3, "Image not in Bochs format");
return -EINVAL;
}
if (le32_to_cpu(VAR_5.version) == HEADER_V1) {
memcpy(&VAR_6, &VAR_5, sizeof(VAR_5));
VAR_0->total_sectors = le64_to_cpu(VAR_6.extra.redolog.disk) / 512;
} else {
VAR_0->total_sectors = le64_to_cpu(VAR_5.extra.redolog.disk) / 512;
}
s->catalog_size = le32_to_cpu(VAR_5.extra.redolog.catalog);
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
VAR_7 = bdrv_pread(VAR_0->file, le32_to_cpu(VAR_5.header), s->catalog_bitmap,
s->catalog_size * 4);
if (VAR_7 < 0) {
goto fail;
}
for (VAR_4 = 0; VAR_4 < s->catalog_size; VAR_4++)
le32_to_cpus(&s->catalog_bitmap[VAR_4]);
s->data_offset = le32_to_cpu(VAR_5.header) + (s->catalog_size * 4);
s->bitmap_blocks = 1 + (le32_to_cpu(VAR_5.extra.redolog.bitmap) - 1) / 512;
s->extent_blocks = 1 + (le32_to_cpu(VAR_5.extra.redolog.extent) - 1) / 512;
s->extent_size = le32_to_cpu(VAR_5.extra.redolog.extent);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->catalog_bitmap);
return VAR_7;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVBochsState *s = VAR_0->opaque;",
"int VAR_4;",
"struct bochs_header VAR_5;",
"struct bochs_header_v1 VAR_6;",
"int VAR_7;",
"VAR_0->read_only = 1;",
"VAR_7 = bdrv_pread(VAR_0->file, 0, &VAR_5, sizeof(VAR_5));",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"if (strcmp(VAR_5.magic, HEADER_MAGIC) ||\nstrcmp(VAR_5.type, REDOLOG_TYPE) ||\nstrcmp(VAR_5.subtype, GROWING_TYPE) ||\n((le32_to_cpu(VAR_5.version) != HEADER_VERSION) &&\n(le32_to_cpu(VAR_5.version) != HEADER_V1))) {",
"error_setg(VAR_3, \"Image not in Bochs format\");",
"return -EINVAL;",
"}",
"if (le32_to_cpu(VAR_5.version) == HEADER_V1) {",
"memcpy(&VAR_6, &VAR_5, sizeof(VAR_5));",
"VAR_0->total_sectors = le64_to_cpu(VAR_6.extra.redolog.disk) / 512;",
"} else {",
"VAR_0->total_sectors = le64_to_cpu(VAR_5.extra.redolog.disk) / 512;",
"}",
"s->catalog_size = le32_to_cpu(VAR_5.extra.redolog.catalog);",
"s->catalog_bitmap = g_malloc(s->catalog_size * 4);",
"VAR_7 = bdrv_pread(VAR_0->file, le32_to_cpu(VAR_5.header), s->catalog_bitmap,\ns->catalog_size * 4);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"for (VAR_4 = 0; VAR_4 < s->catalog_size; VAR_4++)",
"le32_to_cpus(&s->catalog_bitmap[VAR_4]);",
"s->data_offset = le32_to_cpu(VAR_5.header) + (s->catalog_size * 4);",
"s->bitmap_blocks = 1 + (le32_to_cpu(VAR_5.extra.redolog.bitmap) - 1) / 512;",
"s->extent_blocks = 1 + (le32_to_cpu(VAR_5.extra.redolog.extent) - 1) / 512;",
"s->extent_size = le32_to_cpu(VAR_5.extra.redolog.extent);",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"fail:\ng_free(s->catalog_bitmap);",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
109,
111
],
[
113
],
[
115
]
] |
24,419 | static int svq3_decode_frame (AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size) {
MpegEncContext *const s = avctx->priv_data;
H264Context *const h = avctx->priv_data;
int m, mb_type;
unsigned char *extradata;
unsigned int size;
s->flags = avctx->flags;
s->flags2 = avctx->flags2;
s->unrestricted_mv = 1;
if (!s->context_initialized) {
s->width = avctx->width;
s->height = avctx->height;
h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c;
h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c;
h->halfpel_flag = 1;
h->thirdpel_flag = 1;
h->unknown_svq3_flag = 0;
h->chroma_qp = 4;
if (MPV_common_init (s) < 0)
return -1;
h->b_stride = 4*s->mb_width;
alloc_tables (h);
/* prowl for the "SEQH" marker in the extradata */
extradata = (unsigned char *)avctx->extradata;
for (m = 0; m < avctx->extradata_size; m++) {
if (!memcmp (extradata, "SEQH", 4))
break;
extradata++;
}
/* if a match was found, parse the extra data */
if (extradata && !memcmp (extradata, "SEQH", 4)) {
GetBitContext gb;
size = AV_RB32(&extradata[4]);
init_get_bits (&gb, extradata + 8, size*8);
/* 'frame size code' and optional 'width, height' */
if (get_bits (&gb, 3) == 7) {
get_bits (&gb, 12);
get_bits (&gb, 12);
}
h->halfpel_flag = get_bits1 (&gb);
h->thirdpel_flag = get_bits1 (&gb);
/* unknown fields */
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
s->low_delay = get_bits1 (&gb);
/* unknown field */
get_bits1 (&gb);
while (get_bits1 (&gb)) {
get_bits (&gb, 8);
}
h->unknown_svq3_flag = get_bits1 (&gb);
avctx->has_b_frames = !s->low_delay;
}
}
/* special case for last picture */
if (buf_size == 0) {
if (s->next_picture_ptr && !s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->next_picture;
*data_size = sizeof(AVFrame);
}
return 0;
}
init_get_bits (&s->gb, buf, 8*buf_size);
s->mb_x = s->mb_y = 0;
if (svq3_decode_slice_header (h))
return -1;
s->pict_type = h->slice_type;
s->picture_number = h->slice_num;
if(avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d\n",
av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
s->adaptive_quant, s->qscale
);
}
/* for hurry_up==5 */
s->current_picture.pict_type = s->pict_type;
s->current_picture.key_frame = (s->pict_type == I_TYPE);
/* skip b frames if we dont have reference frames */
if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0;
/* skip b frames if we are in a hurry */
if (avctx->hurry_up && s->pict_type == B_TYPE) return 0;
/* skip everything if we are in a hurry >= 5 */
if (avctx->hurry_up >= 5) return 0;
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE)
||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE)
|| avctx->skip_frame >= AVDISCARD_ALL)
return 0;
if (s->next_p_frame_damaged) {
if (s->pict_type == B_TYPE)
return 0;
else
s->next_p_frame_damaged = 0;
}
frame_start (h);
if (s->pict_type == B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
if (h->frame_num_offset < 0) {
h->frame_num_offset += 256;
}
if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n");
return -1;
}
} else {
h->prev_frame_num = h->frame_num;
h->frame_num = h->slice_num;
h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);
if (h->prev_frame_num_offset < 0) {
h->prev_frame_num_offset += 256;
}
}
for(m=0; m<2; m++){
int i;
for(i=0; i<4; i++){
int j;
for(j=-1; j<4; j++)
h->ref_cache[m][scan8[0] + 8*i + j]= 1;
h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE;
}
}
for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) {
for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {
if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&
((get_bits_count(&s->gb) & 7) == 0 || show_bits (&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {
skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));
s->gb.size_in_bits = 8*buf_size;
if (svq3_decode_slice_header (h))
return -1;
/* TODO: support s->mb_skip_run */
}
mb_type = svq3_get_ue_golomb (&s->gb);
if (s->pict_type == I_TYPE) {
mb_type += 8;
} else if (s->pict_type == B_TYPE && mb_type >= 4) {
mb_type += 4;
}
if (mb_type > 33 || svq3_decode_mb (h, mb_type)) {
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if (mb_type != 0) {
hl_decode_mb (h);
}
if (s->pict_type != B_TYPE && !s->low_delay) {
s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
(s->pict_type == P_TYPE && mb_type < 8) ? (mb_type - 1) : -1;
}
}
ff_draw_horiz_band(s, 16*s->mb_y, 16);
}
MPV_frame_end(s);
if (s->pict_type == B_TYPE || s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->current_picture;
} else {
*(AVFrame *) data = *(AVFrame *) &s->last_picture;
}
avctx->frame_number = s->picture_number - 1;
/* dont output the last pic after seeking */
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
}
return buf_size;
}
| true | FFmpeg | 0c74098b1c4cc566ee0af19374b03d1e425dd1f0 | static int svq3_decode_frame (AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size) {
MpegEncContext *const s = avctx->priv_data;
H264Context *const h = avctx->priv_data;
int m, mb_type;
unsigned char *extradata;
unsigned int size;
s->flags = avctx->flags;
s->flags2 = avctx->flags2;
s->unrestricted_mv = 1;
if (!s->context_initialized) {
s->width = avctx->width;
s->height = avctx->height;
h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c;
h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c;
h->halfpel_flag = 1;
h->thirdpel_flag = 1;
h->unknown_svq3_flag = 0;
h->chroma_qp = 4;
if (MPV_common_init (s) < 0)
return -1;
h->b_stride = 4*s->mb_width;
alloc_tables (h);
extradata = (unsigned char *)avctx->extradata;
for (m = 0; m < avctx->extradata_size; m++) {
if (!memcmp (extradata, "SEQH", 4))
break;
extradata++;
}
if (extradata && !memcmp (extradata, "SEQH", 4)) {
GetBitContext gb;
size = AV_RB32(&extradata[4]);
init_get_bits (&gb, extradata + 8, size*8);
if (get_bits (&gb, 3) == 7) {
get_bits (&gb, 12);
get_bits (&gb, 12);
}
h->halfpel_flag = get_bits1 (&gb);
h->thirdpel_flag = get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
s->low_delay = get_bits1 (&gb);
get_bits1 (&gb);
while (get_bits1 (&gb)) {
get_bits (&gb, 8);
}
h->unknown_svq3_flag = get_bits1 (&gb);
avctx->has_b_frames = !s->low_delay;
}
}
if (buf_size == 0) {
if (s->next_picture_ptr && !s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->next_picture;
*data_size = sizeof(AVFrame);
}
return 0;
}
init_get_bits (&s->gb, buf, 8*buf_size);
s->mb_x = s->mb_y = 0;
if (svq3_decode_slice_header (h))
return -1;
s->pict_type = h->slice_type;
s->picture_number = h->slice_num;
if(avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d\n",
av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
s->adaptive_quant, s->qscale
);
}
s->current_picture.pict_type = s->pict_type;
s->current_picture.key_frame = (s->pict_type == I_TYPE);
if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0;
if (avctx->hurry_up && s->pict_type == B_TYPE) return 0;
if (avctx->hurry_up >= 5) return 0;
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE)
||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE)
|| avctx->skip_frame >= AVDISCARD_ALL)
return 0;
if (s->next_p_frame_damaged) {
if (s->pict_type == B_TYPE)
return 0;
else
s->next_p_frame_damaged = 0;
}
frame_start (h);
if (s->pict_type == B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
if (h->frame_num_offset < 0) {
h->frame_num_offset += 256;
}
if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n");
return -1;
}
} else {
h->prev_frame_num = h->frame_num;
h->frame_num = h->slice_num;
h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);
if (h->prev_frame_num_offset < 0) {
h->prev_frame_num_offset += 256;
}
}
for(m=0; m<2; m++){
int i;
for(i=0; i<4; i++){
int j;
for(j=-1; j<4; j++)
h->ref_cache[m][scan8[0] + 8*i + j]= 1;
h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE;
}
}
for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) {
for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {
if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&
((get_bits_count(&s->gb) & 7) == 0 || show_bits (&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {
skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));
s->gb.size_in_bits = 8*buf_size;
if (svq3_decode_slice_header (h))
return -1;
}
mb_type = svq3_get_ue_golomb (&s->gb);
if (s->pict_type == I_TYPE) {
mb_type += 8;
} else if (s->pict_type == B_TYPE && mb_type >= 4) {
mb_type += 4;
}
if (mb_type > 33 || svq3_decode_mb (h, mb_type)) {
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if (mb_type != 0) {
hl_decode_mb (h);
}
if (s->pict_type != B_TYPE && !s->low_delay) {
s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
(s->pict_type == P_TYPE && mb_type < 8) ? (mb_type - 1) : -1;
}
}
ff_draw_horiz_band(s, 16*s->mb_y, 16);
}
MPV_frame_end(s);
if (s->pict_type == B_TYPE || s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->current_picture;
} else {
*(AVFrame *) data = *(AVFrame *) &s->last_picture;
}
avctx->frame_number = s->picture_number - 1;
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
}
return buf_size;
}
| {
"code": [
" frame_start (h);"
],
"line_no": [
247
]
} | static int FUNC_0 (AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4) {
MpegEncContext *const s = VAR_0->priv_data;
H264Context *const h = VAR_0->priv_data;
int VAR_5, VAR_6;
unsigned char *VAR_7;
unsigned int VAR_8;
s->flags = VAR_0->flags;
s->flags2 = VAR_0->flags2;
s->unrestricted_mv = 1;
if (!s->context_initialized) {
s->width = VAR_0->width;
s->height = VAR_0->height;
h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c;
h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c;
h->halfpel_flag = 1;
h->thirdpel_flag = 1;
h->unknown_svq3_flag = 0;
h->chroma_qp = 4;
if (MPV_common_init (s) < 0)
return -1;
h->b_stride = 4*s->mb_width;
alloc_tables (h);
VAR_7 = (unsigned char *)VAR_0->VAR_7;
for (VAR_5 = 0; VAR_5 < VAR_0->extradata_size; VAR_5++) {
if (!memcmp (VAR_7, "SEQH", 4))
break;
VAR_7++;
}
if (VAR_7 && !memcmp (VAR_7, "SEQH", 4)) {
GetBitContext gb;
VAR_8 = AV_RB32(&VAR_7[4]);
init_get_bits (&gb, VAR_7 + 8, VAR_8*8);
if (get_bits (&gb, 3) == 7) {
get_bits (&gb, 12);
get_bits (&gb, 12);
}
h->halfpel_flag = get_bits1 (&gb);
h->thirdpel_flag = get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
get_bits1 (&gb);
s->low_delay = get_bits1 (&gb);
get_bits1 (&gb);
while (get_bits1 (&gb)) {
get_bits (&gb, 8);
}
h->unknown_svq3_flag = get_bits1 (&gb);
VAR_0->has_b_frames = !s->low_delay;
}
}
if (VAR_4 == 0) {
if (s->next_picture_ptr && !s->low_delay) {
*(AVFrame *) VAR_1 = *(AVFrame *) &s->next_picture;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
init_get_bits (&s->gb, VAR_3, 8*VAR_4);
s->mb_x = s->mb_y = 0;
if (svq3_decode_slice_header (h))
return -1;
s->pict_type = h->slice_type;
s->picture_number = h->slice_num;
if(VAR_0->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.VAR_0, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d\n",
av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
s->adaptive_quant, s->qscale
);
}
s->current_picture.pict_type = s->pict_type;
s->current_picture.key_frame = (s->pict_type == I_TYPE);
if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0;
if (VAR_0->hurry_up && s->pict_type == B_TYPE) return 0;
if (VAR_0->hurry_up >= 5) return 0;
if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE)
||(VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE)
|| VAR_0->skip_frame >= AVDISCARD_ALL)
return 0;
if (s->next_p_frame_damaged) {
if (s->pict_type == B_TYPE)
return 0;
else
s->next_p_frame_damaged = 0;
}
frame_start (h);
if (s->pict_type == B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
if (h->frame_num_offset < 0) {
h->frame_num_offset += 256;
}
if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
av_log(h->s.VAR_0, AV_LOG_ERROR, "error in B-frame picture id\n");
return -1;
}
} else {
h->prev_frame_num = h->frame_num;
h->frame_num = h->slice_num;
h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);
if (h->prev_frame_num_offset < 0) {
h->prev_frame_num_offset += 256;
}
}
for(VAR_5=0; VAR_5<2; VAR_5++){
int VAR_9;
for(VAR_9=0; VAR_9<4; VAR_9++){
int VAR_10;
for(VAR_10=-1; VAR_10<4; VAR_10++)
h->ref_cache[VAR_5][scan8[0] + 8*VAR_9 + VAR_10]= 1;
h->ref_cache[VAR_5][scan8[0] + 8*VAR_9 + VAR_10]= PART_NOT_AVAILABLE;
}
}
for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) {
for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {
if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&
((get_bits_count(&s->gb) & 7) == 0 || show_bits (&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {
skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));
s->gb.size_in_bits = 8*VAR_4;
if (svq3_decode_slice_header (h))
return -1;
}
VAR_6 = svq3_get_ue_golomb (&s->gb);
if (s->pict_type == I_TYPE) {
VAR_6 += 8;
} else if (s->pict_type == B_TYPE && VAR_6 >= 4) {
VAR_6 += 4;
}
if (VAR_6 > 33 || svq3_decode_mb (h, VAR_6)) {
av_log(h->s.VAR_0, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if (VAR_6 != 0) {
hl_decode_mb (h);
}
if (s->pict_type != B_TYPE && !s->low_delay) {
s->current_picture.VAR_6[s->mb_x + s->mb_y*s->mb_stride] =
(s->pict_type == P_TYPE && VAR_6 < 8) ? (VAR_6 - 1) : -1;
}
}
ff_draw_horiz_band(s, 16*s->mb_y, 16);
}
MPV_frame_end(s);
if (s->pict_type == B_TYPE || s->low_delay) {
*(AVFrame *) VAR_1 = *(AVFrame *) &s->current_picture;
} else {
*(AVFrame *) VAR_1 = *(AVFrame *) &s->last_picture;
}
VAR_0->frame_number = s->picture_number - 1;
if (s->last_picture_ptr || s->low_delay) {
*VAR_2 = sizeof(AVFrame);
}
return VAR_4;
}
| [
"static int FUNC_0 (AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4) {",
"MpegEncContext *const s = VAR_0->priv_data;",
"H264Context *const h = VAR_0->priv_data;",
"int VAR_5, VAR_6;",
"unsigned char *VAR_7;",
"unsigned int VAR_8;",
"s->flags = VAR_0->flags;",
"s->flags2 = VAR_0->flags2;",
"s->unrestricted_mv = 1;",
"if (!s->context_initialized) {",
"s->width = VAR_0->width;",
"s->height = VAR_0->height;",
"h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c;",
"h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c;",
"h->halfpel_flag = 1;",
"h->thirdpel_flag = 1;",
"h->unknown_svq3_flag = 0;",
"h->chroma_qp = 4;",
"if (MPV_common_init (s) < 0)\nreturn -1;",
"h->b_stride = 4*s->mb_width;",
"alloc_tables (h);",
"VAR_7 = (unsigned char *)VAR_0->VAR_7;",
"for (VAR_5 = 0; VAR_5 < VAR_0->extradata_size; VAR_5++) {",
"if (!memcmp (VAR_7, \"SEQH\", 4))\nbreak;",
"VAR_7++;",
"}",
"if (VAR_7 && !memcmp (VAR_7, \"SEQH\", 4)) {",
"GetBitContext gb;",
"VAR_8 = AV_RB32(&VAR_7[4]);",
"init_get_bits (&gb, VAR_7 + 8, VAR_8*8);",
"if (get_bits (&gb, 3) == 7) {",
"get_bits (&gb, 12);",
"get_bits (&gb, 12);",
"}",
"h->halfpel_flag = get_bits1 (&gb);",
"h->thirdpel_flag = get_bits1 (&gb);",
"get_bits1 (&gb);",
"get_bits1 (&gb);",
"get_bits1 (&gb);",
"get_bits1 (&gb);",
"s->low_delay = get_bits1 (&gb);",
"get_bits1 (&gb);",
"while (get_bits1 (&gb)) {",
"get_bits (&gb, 8);",
"}",
"h->unknown_svq3_flag = get_bits1 (&gb);",
"VAR_0->has_b_frames = !s->low_delay;",
"}",
"}",
"if (VAR_4 == 0) {",
"if (s->next_picture_ptr && !s->low_delay) {",
"*(AVFrame *) VAR_1 = *(AVFrame *) &s->next_picture;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"init_get_bits (&s->gb, VAR_3, 8*VAR_4);",
"s->mb_x = s->mb_y = 0;",
"if (svq3_decode_slice_header (h))\nreturn -1;",
"s->pict_type = h->slice_type;",
"s->picture_number = h->slice_num;",
"if(VAR_0->debug&FF_DEBUG_PICT_INFO){",
"av_log(h->s.VAR_0, AV_LOG_DEBUG, \"%c hpel:%d, tpel:%d aqp:%d qp:%d\\n\",\nav_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,\ns->adaptive_quant, s->qscale\n);",
"}",
"s->current_picture.pict_type = s->pict_type;",
"s->current_picture.key_frame = (s->pict_type == I_TYPE);",
"if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0;",
"if (VAR_0->hurry_up && s->pict_type == B_TYPE) return 0;",
"if (VAR_0->hurry_up >= 5) return 0;",
"if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE)\n||(VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE)\n|| VAR_0->skip_frame >= AVDISCARD_ALL)\nreturn 0;",
"if (s->next_p_frame_damaged) {",
"if (s->pict_type == B_TYPE)\nreturn 0;",
"else\ns->next_p_frame_damaged = 0;",
"}",
"frame_start (h);",
"if (s->pict_type == B_TYPE) {",
"h->frame_num_offset = (h->slice_num - h->prev_frame_num);",
"if (h->frame_num_offset < 0) {",
"h->frame_num_offset += 256;",
"}",
"if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {",
"av_log(h->s.VAR_0, AV_LOG_ERROR, \"error in B-frame picture id\\n\");",
"return -1;",
"}",
"} else {",
"h->prev_frame_num = h->frame_num;",
"h->frame_num = h->slice_num;",
"h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);",
"if (h->prev_frame_num_offset < 0) {",
"h->prev_frame_num_offset += 256;",
"}",
"}",
"for(VAR_5=0; VAR_5<2; VAR_5++){",
"int VAR_9;",
"for(VAR_9=0; VAR_9<4; VAR_9++){",
"int VAR_10;",
"for(VAR_10=-1; VAR_10<4; VAR_10++)",
"h->ref_cache[VAR_5][scan8[0] + 8*VAR_9 + VAR_10]= 1;",
"h->ref_cache[VAR_5][scan8[0] + 8*VAR_9 + VAR_10]= PART_NOT_AVAILABLE;",
"}",
"}",
"for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) {",
"for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {",
"if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&\n((get_bits_count(&s->gb) & 7) == 0 || show_bits (&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {",
"skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));",
"s->gb.size_in_bits = 8*VAR_4;",
"if (svq3_decode_slice_header (h))\nreturn -1;",
"}",
"VAR_6 = svq3_get_ue_golomb (&s->gb);",
"if (s->pict_type == I_TYPE) {",
"VAR_6 += 8;",
"} else if (s->pict_type == B_TYPE && VAR_6 >= 4) {",
"VAR_6 += 4;",
"}",
"if (VAR_6 > 33 || svq3_decode_mb (h, VAR_6)) {",
"av_log(h->s.VAR_0, AV_LOG_ERROR, \"error while decoding MB %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"if (VAR_6 != 0) {",
"hl_decode_mb (h);",
"}",
"if (s->pict_type != B_TYPE && !s->low_delay) {",
"s->current_picture.VAR_6[s->mb_x + s->mb_y*s->mb_stride] =\n(s->pict_type == P_TYPE && VAR_6 < 8) ? (VAR_6 - 1) : -1;",
"}",
"}",
"ff_draw_horiz_band(s, 16*s->mb_y, 16);",
"}",
"MPV_frame_end(s);",
"if (s->pict_type == B_TYPE || s->low_delay) {",
"*(AVFrame *) VAR_1 = *(AVFrame *) &s->current_picture;",
"} else {",
"*(AVFrame *) VAR_1 = *(AVFrame *) &s->last_picture;",
"}",
"VAR_0->frame_number = s->picture_number - 1;",
"if (s->last_picture_ptr || s->low_delay) {",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
53
],
[
57
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
79
],
[
83
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
129
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
177,
179
],
[
183
],
[
185
],
[
189
],
[
191,
193,
195,
197
],
[
199
],
[
205
],
[
207
],
[
213
],
[
217
],
[
221
],
[
223,
225,
227,
229
],
[
233
],
[
235,
237
],
[
239,
241
],
[
243
],
[
247
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
317,
319
],
[
323
],
[
325
],
[
329,
331
],
[
337
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
391
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
413
],
[
415
],
[
417
],
[
421
],
[
423
]
] |
24,420 | static inline void elf_core_copy_regs(target_elf_gregset_t *regs,
const CPUSH4State *env)
{
int i;
for (i = 0; i < 16; i++) {
(*regs[i]) = tswapreg(env->gregs[i]);
}
(*regs)[TARGET_REG_PC] = tswapreg(env->pc);
(*regs)[TARGET_REG_PR] = tswapreg(env->pr);
(*regs)[TARGET_REG_SR] = tswapreg(env->sr);
(*regs)[TARGET_REG_GBR] = tswapreg(env->gbr);
(*regs)[TARGET_REG_MACH] = tswapreg(env->mach);
(*regs)[TARGET_REG_MACL] = tswapreg(env->macl);
(*regs)[TARGET_REG_SYSCALL] = 0; /* FIXME */
}
| true | qemu | 72cd500b725fd9a3bbefeb468d54c192fdc28318 | static inline void elf_core_copy_regs(target_elf_gregset_t *regs,
const CPUSH4State *env)
{
int i;
for (i = 0; i < 16; i++) {
(*regs[i]) = tswapreg(env->gregs[i]);
}
(*regs)[TARGET_REG_PC] = tswapreg(env->pc);
(*regs)[TARGET_REG_PR] = tswapreg(env->pr);
(*regs)[TARGET_REG_SR] = tswapreg(env->sr);
(*regs)[TARGET_REG_GBR] = tswapreg(env->gbr);
(*regs)[TARGET_REG_MACH] = tswapreg(env->mach);
(*regs)[TARGET_REG_MACL] = tswapreg(env->macl);
(*regs)[TARGET_REG_SYSCALL] = 0;
}
| {
"code": [
" (*regs[i]) = tswapreg(env->gregs[i]);"
],
"line_no": [
13
]
} | static inline void FUNC_0(target_elf_gregset_t *VAR_0,
const CPUSH4State *VAR_1)
{
int VAR_2;
for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {
(*VAR_0[VAR_2]) = tswapreg(VAR_1->gregs[VAR_2]);
}
(*VAR_0)[TARGET_REG_PC] = tswapreg(VAR_1->pc);
(*VAR_0)[TARGET_REG_PR] = tswapreg(VAR_1->pr);
(*VAR_0)[TARGET_REG_SR] = tswapreg(VAR_1->sr);
(*VAR_0)[TARGET_REG_GBR] = tswapreg(VAR_1->gbr);
(*VAR_0)[TARGET_REG_MACH] = tswapreg(VAR_1->mach);
(*VAR_0)[TARGET_REG_MACL] = tswapreg(VAR_1->macl);
(*VAR_0)[TARGET_REG_SYSCALL] = 0;
}
| [
"static inline void FUNC_0(target_elf_gregset_t *VAR_0,\nconst CPUSH4State *VAR_1)\n{",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {",
"(*VAR_0[VAR_2]) = tswapreg(VAR_1->gregs[VAR_2]);",
"}",
"(*VAR_0)[TARGET_REG_PC] = tswapreg(VAR_1->pc);",
"(*VAR_0)[TARGET_REG_PR] = tswapreg(VAR_1->pr);",
"(*VAR_0)[TARGET_REG_SR] = tswapreg(VAR_1->sr);",
"(*VAR_0)[TARGET_REG_GBR] = tswapreg(VAR_1->gbr);",
"(*VAR_0)[TARGET_REG_MACH] = tswapreg(VAR_1->mach);",
"(*VAR_0)[TARGET_REG_MACL] = tswapreg(VAR_1->macl);",
"(*VAR_0)[TARGET_REG_SYSCALL] = 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
24,421 | static int vorbis_parse_id_hdr(vorbis_context *vc){
GetBitContext *gb=&vc->gb;
uint_fast8_t bl0, bl1;
if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||
(get_bits(gb, 8)!='r') || (get_bits(gb, 8)!='b') ||
(get_bits(gb, 8)!='i') || (get_bits(gb, 8)!='s')) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (no vorbis signature). \n");
return 1;
}
vc->version=get_bits_long(gb, 32); //FIXME check 0
vc->audio_channels=get_bits(gb, 8); //FIXME check >0
vc->audio_samplerate=get_bits_long(gb, 32); //FIXME check >0
vc->bitrate_maximum=get_bits_long(gb, 32);
vc->bitrate_nominal=get_bits_long(gb, 32);
vc->bitrate_minimum=get_bits_long(gb, 32);
bl0=get_bits(gb, 4);
bl1=get_bits(gb, 4);
vc->blocksize[0]=(1<<bl0);
vc->blocksize[1]=(1<<bl1);
if (bl0>13 || bl0<6 || bl1>13 || bl1<6 || bl1<bl0) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (illegal blocksize). \n");
return 3;
}
// output format int16
if (vc->blocksize[1]/2 * vc->audio_channels * 2 >
AVCODEC_MAX_AUDIO_FRAME_SIZE) {
av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis channel count makes "
"output packets too large.\n");
return 4;
}
vc->win[0]=ff_vorbis_vwin[bl0-6];
vc->win[1]=ff_vorbis_vwin[bl1-6];
if(vc->exp_bias){
int i, j;
for(j=0; j<2; j++){
float *win = av_malloc(vc->blocksize[j]/2 * sizeof(float));
for(i=0; i<vc->blocksize[j]/2; i++)
win[i] = vc->win[j][i] * (1<<15);
vc->win[j] = win;
}
}
if ((get_bits1(gb)) == 0) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n");
return 2;
}
vc->channel_residues=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->channel_floors=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->saved=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->ret=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->buf=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
vc->buf_tmp=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
vc->saved_start=0;
ff_mdct_init(&vc->mdct[0], bl0, 1);
ff_mdct_init(&vc->mdct[1], bl1, 1);
AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
/*
BLK=vc->blocksize[0];
for(i=0;i<BLK/2;++i) {
vc->win[0][i]=sin(0.5*3.14159265358*(sin(((float)i+0.5)/(float)BLK*3.14159265358))*(sin(((float)i+0.5)/(float)BLK*3.14159265358)));
}
*/
return 0;
}
| false | FFmpeg | 90901860c21468d6e9ae437c2bacb099c7bd3acf | static int vorbis_parse_id_hdr(vorbis_context *vc){
GetBitContext *gb=&vc->gb;
uint_fast8_t bl0, bl1;
if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||
(get_bits(gb, 8)!='r') || (get_bits(gb, 8)!='b') ||
(get_bits(gb, 8)!='i') || (get_bits(gb, 8)!='s')) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (no vorbis signature). \n");
return 1;
}
vc->version=get_bits_long(gb, 32);
vc->audio_channels=get_bits(gb, 8);
vc->audio_samplerate=get_bits_long(gb, 32);
vc->bitrate_maximum=get_bits_long(gb, 32);
vc->bitrate_nominal=get_bits_long(gb, 32);
vc->bitrate_minimum=get_bits_long(gb, 32);
bl0=get_bits(gb, 4);
bl1=get_bits(gb, 4);
vc->blocksize[0]=(1<<bl0);
vc->blocksize[1]=(1<<bl1);
if (bl0>13 || bl0<6 || bl1>13 || bl1<6 || bl1<bl0) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (illegal blocksize). \n");
return 3;
}
if (vc->blocksize[1]/2 * vc->audio_channels * 2 >
AVCODEC_MAX_AUDIO_FRAME_SIZE) {
av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis channel count makes "
"output packets too large.\n");
return 4;
}
vc->win[0]=ff_vorbis_vwin[bl0-6];
vc->win[1]=ff_vorbis_vwin[bl1-6];
if(vc->exp_bias){
int i, j;
for(j=0; j<2; j++){
float *win = av_malloc(vc->blocksize[j]/2 * sizeof(float));
for(i=0; i<vc->blocksize[j]/2; i++)
win[i] = vc->win[j][i] * (1<<15);
vc->win[j] = win;
}
}
if ((get_bits1(gb)) == 0) {
av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n");
return 2;
}
vc->channel_residues=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->channel_floors=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->saved=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->ret=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
vc->buf=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
vc->buf_tmp=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
vc->saved_start=0;
ff_mdct_init(&vc->mdct[0], bl0, 1);
ff_mdct_init(&vc->mdct[1], bl1, 1);
AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(vorbis_context *VAR_0){
GetBitContext *gb=&VAR_0->gb;
uint_fast8_t bl0, bl1;
if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||
(get_bits(gb, 8)!='r') || (get_bits(gb, 8)!='b') ||
(get_bits(gb, 8)!='VAR_1') || (get_bits(gb, 8)!='s')) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (no vorbis signature). \n");
return 1;
}
VAR_0->version=get_bits_long(gb, 32);
VAR_0->audio_channels=get_bits(gb, 8);
VAR_0->audio_samplerate=get_bits_long(gb, 32);
VAR_0->bitrate_maximum=get_bits_long(gb, 32);
VAR_0->bitrate_nominal=get_bits_long(gb, 32);
VAR_0->bitrate_minimum=get_bits_long(gb, 32);
bl0=get_bits(gb, 4);
bl1=get_bits(gb, 4);
VAR_0->blocksize[0]=(1<<bl0);
VAR_0->blocksize[1]=(1<<bl1);
if (bl0>13 || bl0<6 || bl1>13 || bl1<6 || bl1<bl0) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (illegal blocksize). \n");
return 3;
}
if (VAR_0->blocksize[1]/2 * VAR_0->audio_channels * 2 >
AVCODEC_MAX_AUDIO_FRAME_SIZE) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, "Vorbis channel count makes "
"output packets too large.\n");
return 4;
}
VAR_0->VAR_3[0]=ff_vorbis_vwin[bl0-6];
VAR_0->VAR_3[1]=ff_vorbis_vwin[bl1-6];
if(VAR_0->exp_bias){
int VAR_1, VAR_2;
for(VAR_2=0; VAR_2<2; VAR_2++){
float *VAR_3 = av_malloc(VAR_0->blocksize[VAR_2]/2 * sizeof(float));
for(VAR_1=0; VAR_1<VAR_0->blocksize[VAR_2]/2; VAR_1++)
VAR_3[VAR_1] = VAR_0->VAR_3[VAR_2][VAR_1] * (1<<15);
VAR_0->VAR_3[VAR_2] = VAR_3;
}
}
if ((get_bits1(gb)) == 0) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n");
return 2;
}
VAR_0->channel_residues=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));
VAR_0->channel_floors=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));
VAR_0->saved=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));
VAR_0->ret=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));
VAR_0->buf=(float *)av_malloc(VAR_0->blocksize[1] * sizeof(float));
VAR_0->buf_tmp=(float *)av_malloc(VAR_0->blocksize[1] * sizeof(float));
VAR_0->saved_start=0;
ff_mdct_init(&VAR_0->mdct[0], bl0, 1);
ff_mdct_init(&VAR_0->mdct[1], bl1, 1);
AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
VAR_0->version, VAR_0->audio_channels, VAR_0->audio_samplerate, VAR_0->bitrate_maximum, VAR_0->bitrate_nominal, VAR_0->bitrate_minimum, VAR_0->blocksize[0], VAR_0->blocksize[1]);
return 0;
}
| [
"static int FUNC_0(vorbis_context *VAR_0){",
"GetBitContext *gb=&VAR_0->gb;",
"uint_fast8_t bl0, bl1;",
"if ((get_bits(gb, 8)!='v') || (get_bits(gb, 8)!='o') ||\n(get_bits(gb, 8)!='r') || (get_bits(gb, 8)!='b') ||\n(get_bits(gb, 8)!='VAR_1') || (get_bits(gb, 8)!='s')) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \" Vorbis id header packet corrupt (no vorbis signature). \\n\");",
"return 1;",
"}",
"VAR_0->version=get_bits_long(gb, 32);",
"VAR_0->audio_channels=get_bits(gb, 8);",
"VAR_0->audio_samplerate=get_bits_long(gb, 32);",
"VAR_0->bitrate_maximum=get_bits_long(gb, 32);",
"VAR_0->bitrate_nominal=get_bits_long(gb, 32);",
"VAR_0->bitrate_minimum=get_bits_long(gb, 32);",
"bl0=get_bits(gb, 4);",
"bl1=get_bits(gb, 4);",
"VAR_0->blocksize[0]=(1<<bl0);",
"VAR_0->blocksize[1]=(1<<bl1);",
"if (bl0>13 || bl0<6 || bl1>13 || bl1<6 || bl1<bl0) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \" Vorbis id header packet corrupt (illegal blocksize). \\n\");",
"return 3;",
"}",
"if (VAR_0->blocksize[1]/2 * VAR_0->audio_channels * 2 >\nAVCODEC_MAX_AUDIO_FRAME_SIZE) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \"Vorbis channel count makes \"\n\"output packets too large.\\n\");",
"return 4;",
"}",
"VAR_0->VAR_3[0]=ff_vorbis_vwin[bl0-6];",
"VAR_0->VAR_3[1]=ff_vorbis_vwin[bl1-6];",
"if(VAR_0->exp_bias){",
"int VAR_1, VAR_2;",
"for(VAR_2=0; VAR_2<2; VAR_2++){",
"float *VAR_3 = av_malloc(VAR_0->blocksize[VAR_2]/2 * sizeof(float));",
"for(VAR_1=0; VAR_1<VAR_0->blocksize[VAR_2]/2; VAR_1++)",
"VAR_3[VAR_1] = VAR_0->VAR_3[VAR_2][VAR_1] * (1<<15);",
"VAR_0->VAR_3[VAR_2] = VAR_3;",
"}",
"}",
"if ((get_bits1(gb)) == 0) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \" Vorbis id header packet corrupt (framing flag not set). \\n\");",
"return 2;",
"}",
"VAR_0->channel_residues=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));",
"VAR_0->channel_floors=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));",
"VAR_0->saved=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));",
"VAR_0->ret=(float *)av_malloc((VAR_0->blocksize[1]/2)*VAR_0->audio_channels * sizeof(float));",
"VAR_0->buf=(float *)av_malloc(VAR_0->blocksize[1] * sizeof(float));",
"VAR_0->buf_tmp=(float *)av_malloc(VAR_0->blocksize[1] * sizeof(float));",
"VAR_0->saved_start=0;",
"ff_mdct_init(&VAR_0->mdct[0], bl0, 1);",
"ff_mdct_init(&VAR_0->mdct[1], bl1, 1);",
"AV_DEBUG(\" vorbis version %d \\n audio_channels %d \\n audio_samplerate %d \\n bitrate_max %d \\n bitrate_nom %d \\n bitrate_min %d \\n blk_0 %d blk_1 %d \\n \",\nVAR_0->version, VAR_0->audio_channels, VAR_0->audio_samplerate, VAR_0->bitrate_maximum, VAR_0->bitrate_nominal, VAR_0->bitrate_minimum, VAR_0->blocksize[0], VAR_0->blocksize[1]);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123,
125
],
[
143
],
[
145
]
] |
24,422 | static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1,
tcg_target_long arg2)
{
if (type == TCG_TYPE_I32)
tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX);
else
tcg_out_ldst (s, ret, arg1, arg2, LD, LDX);
}
| true | qemu | 828808f5ece20fd606218e000139799921c89d93 | static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1,
tcg_target_long arg2)
{
if (type == TCG_TYPE_I32)
tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX);
else
tcg_out_ldst (s, ret, arg1, arg2, LD, LDX);
}
| {
"code": [
" tcg_out_ldst (s, ret, arg1, arg2, LD, LDX);"
],
"line_no": [
13
]
} | static void FUNC_0 (TCGContext *VAR_0, TCGType VAR_1, int VAR_2, int VAR_3,
tcg_target_long VAR_4)
{
if (VAR_1 == TCG_TYPE_I32)
tcg_out_ldst (VAR_0, VAR_2, VAR_3, VAR_4, LWZ, LWZX);
else
tcg_out_ldst (VAR_0, VAR_2, VAR_3, VAR_4, LD, LDX);
}
| [
"static void FUNC_0 (TCGContext *VAR_0, TCGType VAR_1, int VAR_2, int VAR_3,\ntcg_target_long VAR_4)\n{",
"if (VAR_1 == TCG_TYPE_I32)\ntcg_out_ldst (VAR_0, VAR_2, VAR_3, VAR_4, LWZ, LWZX);",
"else\ntcg_out_ldst (VAR_0, VAR_2, VAR_3, VAR_4, LD, LDX);",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11,
13
],
[
15
]
] |
24,423 | void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
{
uint64_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le64(value);
fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| true | qemu | 089da572b956ef0f8f5b8d5917358e07892a77c2 | void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
{
uint64_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le64(value);
fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| {
"code": [
" fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));",
" fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));",
" fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));"
],
"line_no": [
13,
13,
13
]
} | void FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint64_t VAR_2)
{
uint64_t *copy;
copy = g_malloc(sizeof(VAR_2));
*copy = cpu_to_le64(VAR_2);
fw_cfg_add_bytes(VAR_0, VAR_1, (uint8_t *)copy, sizeof(VAR_2));
}
| [
"void FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint64_t VAR_2)\n{",
"uint64_t *copy;",
"copy = g_malloc(sizeof(VAR_2));",
"*copy = cpu_to_le64(VAR_2);",
"fw_cfg_add_bytes(VAR_0, VAR_1, (uint8_t *)copy, sizeof(VAR_2));",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
24,425 | static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd,
int is_connected)
{
NetSocketState *s;
s = qemu_mallocz(sizeof(NetSocketState));
if (!s)
return NULL;
s->fd = fd;
s->vc = qemu_new_vlan_client(vlan,
net_socket_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"socket: fd=%d", fd);
if (is_connected) {
net_socket_connect(s);
} else {
qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
}
return s;
}
| true | qemu | d861b05ea30e6ac177de9b679da96194ebe21afc | static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd,
int is_connected)
{
NetSocketState *s;
s = qemu_mallocz(sizeof(NetSocketState));
if (!s)
return NULL;
s->fd = fd;
s->vc = qemu_new_vlan_client(vlan,
net_socket_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"socket: fd=%d", fd);
if (is_connected) {
net_socket_connect(s);
} else {
qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
}
return s;
}
| {
"code": [
" net_socket_receive, s);"
],
"line_no": [
19
]
} | static NetSocketState *FUNC_0(VLANState *vlan, int fd,
int is_connected)
{
NetSocketState *s;
s = qemu_mallocz(sizeof(NetSocketState));
if (!s)
return NULL;
s->fd = fd;
s->vc = qemu_new_vlan_client(vlan,
net_socket_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"socket: fd=%d", fd);
if (is_connected) {
net_socket_connect(s);
} else {
qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
}
return s;
}
| [
"static NetSocketState *FUNC_0(VLANState *vlan, int fd,\nint is_connected)\n{",
"NetSocketState *s;",
"s = qemu_mallocz(sizeof(NetSocketState));",
"if (!s)\nreturn NULL;",
"s->fd = fd;",
"s->vc = qemu_new_vlan_client(vlan,\nnet_socket_receive, s);",
"snprintf(s->vc->info_str, sizeof(s->vc->info_str),\n\"socket: fd=%d\", fd);",
"if (is_connected) {",
"net_socket_connect(s);",
"} else {",
"qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);",
"}",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
24,427 | static int add_string_metadata(int count, const char *name,
TiffContext *s)
{
char *value;
if (bytestream2_get_bytes_left(&s->gb) < count)
return AVERROR_INVALIDDATA;
value = av_malloc(count + 1);
if (!value)
return AVERROR(ENOMEM);
bytestream2_get_bufferu(&s->gb, value, count);
value[count] = 0;
av_dict_set(&s->picture.metadata, name, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| false | FFmpeg | b16830840eb9bdec88fce2aebb38a582e093ab6b | static int add_string_metadata(int count, const char *name,
TiffContext *s)
{
char *value;
if (bytestream2_get_bytes_left(&s->gb) < count)
return AVERROR_INVALIDDATA;
value = av_malloc(count + 1);
if (!value)
return AVERROR(ENOMEM);
bytestream2_get_bufferu(&s->gb, value, count);
value[count] = 0;
av_dict_set(&s->picture.metadata, name, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, const char *VAR_1,
TiffContext *VAR_2)
{
char *VAR_3;
if (bytestream2_get_bytes_left(&VAR_2->gb) < VAR_0)
return AVERROR_INVALIDDATA;
VAR_3 = av_malloc(VAR_0 + 1);
if (!VAR_3)
return AVERROR(ENOMEM);
bytestream2_get_bufferu(&VAR_2->gb, VAR_3, VAR_0);
VAR_3[VAR_0] = 0;
av_dict_set(&VAR_2->picture.metadata, VAR_1, VAR_3, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| [
"static int FUNC_0(int VAR_0, const char *VAR_1,\nTiffContext *VAR_2)\n{",
"char *VAR_3;",
"if (bytestream2_get_bytes_left(&VAR_2->gb) < VAR_0)\nreturn AVERROR_INVALIDDATA;",
"VAR_3 = av_malloc(VAR_0 + 1);",
"if (!VAR_3)\nreturn AVERROR(ENOMEM);",
"bytestream2_get_bufferu(&VAR_2->gb, VAR_3, VAR_0);",
"VAR_3[VAR_0] = 0;",
"av_dict_set(&VAR_2->picture.metadata, VAR_1, VAR_3, AV_DICT_DONT_STRDUP_VAL);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
]
] |
24,428 | static int idcin_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
IdcinDemuxContext *idcin = s->priv_data;
AVStream *st;
unsigned int width, height;
unsigned int sample_rate, bytes_per_sample, channels;
int ret;
/* get the 5 header parameters */
width = avio_rl32(pb);
height = avio_rl32(pb);
sample_rate = avio_rl32(pb);
bytes_per_sample = avio_rl32(pb);
channels = avio_rl32(pb);
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "incomplete header\n");
return s->pb->error ? s->pb->error : AVERROR_EOF;
}
if (av_image_check_size(width, height, 0, s) < 0)
return AVERROR_INVALIDDATA;
if (sample_rate > 0) {
if (sample_rate < 14 || sample_rate > INT_MAX) {
av_log(s, AV_LOG_ERROR, "invalid sample rate: %u\n", sample_rate);
return AVERROR_INVALIDDATA;
}
if (bytes_per_sample < 1 || bytes_per_sample > 2) {
av_log(s, AV_LOG_ERROR, "invalid bytes per sample: %u\n",
bytes_per_sample);
return AVERROR_INVALIDDATA;
}
if (channels < 1 || channels > 2) {
av_log(s, AV_LOG_ERROR, "invalid channels: %u\n", channels);
return AVERROR_INVALIDDATA;
}
idcin->audio_present = 1;
} else {
/* if sample rate is 0, assume no audio */
idcin->audio_present = 0;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
st->start_time = 0;
idcin->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_IDCIN;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = width;
st->codec->height = height;
/* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
if (ret < 0) {
return ret;
} else if (ret != HUFFMAN_TABLE_SIZE) {
av_log(s, AV_LOG_ERROR, "incomplete header\n");
return AVERROR(EIO);
}
if (idcin->audio_present) {
idcin->audio_present = 1;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, sample_rate);
st->start_time = 0;
idcin->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 1;
st->codec->channels = channels;
st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
st->codec->sample_rate = sample_rate;
st->codec->bits_per_coded_sample = bytes_per_sample * 8;
st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
st->codec->block_align = idcin->block_align = bytes_per_sample * channels;
if (bytes_per_sample == 1)
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
if (sample_rate % 14 != 0) {
idcin->audio_chunk_size1 = (sample_rate / 14) *
bytes_per_sample * channels;
idcin->audio_chunk_size2 = (sample_rate / 14 + 1) *
bytes_per_sample * channels;
} else {
idcin->audio_chunk_size1 = idcin->audio_chunk_size2 =
(sample_rate / 14) * bytes_per_sample * channels;
}
idcin->current_audio_chunk = 0;
}
idcin->next_chunk_is_video = 1;
idcin->first_pkt_pos = avio_tell(s->pb);
return 0;
}
| false | FFmpeg | 16e0416fa47ca391214ad20d162240e5d492bf0e | static int idcin_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
IdcinDemuxContext *idcin = s->priv_data;
AVStream *st;
unsigned int width, height;
unsigned int sample_rate, bytes_per_sample, channels;
int ret;
width = avio_rl32(pb);
height = avio_rl32(pb);
sample_rate = avio_rl32(pb);
bytes_per_sample = avio_rl32(pb);
channels = avio_rl32(pb);
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "incomplete header\n");
return s->pb->error ? s->pb->error : AVERROR_EOF;
}
if (av_image_check_size(width, height, 0, s) < 0)
return AVERROR_INVALIDDATA;
if (sample_rate > 0) {
if (sample_rate < 14 || sample_rate > INT_MAX) {
av_log(s, AV_LOG_ERROR, "invalid sample rate: %u\n", sample_rate);
return AVERROR_INVALIDDATA;
}
if (bytes_per_sample < 1 || bytes_per_sample > 2) {
av_log(s, AV_LOG_ERROR, "invalid bytes per sample: %u\n",
bytes_per_sample);
return AVERROR_INVALIDDATA;
}
if (channels < 1 || channels > 2) {
av_log(s, AV_LOG_ERROR, "invalid channels: %u\n", channels);
return AVERROR_INVALIDDATA;
}
idcin->audio_present = 1;
} else {
idcin->audio_present = 0;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
st->start_time = 0;
idcin->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_IDCIN;
st->codec->codec_tag = 0;
st->codec->width = width;
st->codec->height = height;
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
if (ret < 0) {
return ret;
} else if (ret != HUFFMAN_TABLE_SIZE) {
av_log(s, AV_LOG_ERROR, "incomplete header\n");
return AVERROR(EIO);
}
if (idcin->audio_present) {
idcin->audio_present = 1;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, sample_rate);
st->start_time = 0;
idcin->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 1;
st->codec->channels = channels;
st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
st->codec->sample_rate = sample_rate;
st->codec->bits_per_coded_sample = bytes_per_sample * 8;
st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
st->codec->block_align = idcin->block_align = bytes_per_sample * channels;
if (bytes_per_sample == 1)
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
if (sample_rate % 14 != 0) {
idcin->audio_chunk_size1 = (sample_rate / 14) *
bytes_per_sample * channels;
idcin->audio_chunk_size2 = (sample_rate / 14 + 1) *
bytes_per_sample * channels;
} else {
idcin->audio_chunk_size1 = idcin->audio_chunk_size2 =
(sample_rate / 14) * bytes_per_sample * channels;
}
idcin->current_audio_chunk = 0;
}
idcin->next_chunk_is_video = 1;
idcin->first_pkt_pos = avio_tell(s->pb);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVIOContext *pb = VAR_0->pb;
IdcinDemuxContext *idcin = VAR_0->priv_data;
AVStream *st;
unsigned int VAR_1, VAR_2;
unsigned int VAR_3, VAR_4, VAR_5;
int VAR_6;
VAR_1 = avio_rl32(pb);
VAR_2 = avio_rl32(pb);
VAR_3 = avio_rl32(pb);
VAR_4 = avio_rl32(pb);
VAR_5 = avio_rl32(pb);
if (VAR_0->pb->eof_reached) {
av_log(VAR_0, AV_LOG_ERROR, "incomplete header\n");
return VAR_0->pb->error ? VAR_0->pb->error : AVERROR_EOF;
}
if (av_image_check_size(VAR_1, VAR_2, 0, VAR_0) < 0)
return AVERROR_INVALIDDATA;
if (VAR_3 > 0) {
if (VAR_3 < 14 || VAR_3 > INT_MAX) {
av_log(VAR_0, AV_LOG_ERROR, "invalid sample rate: %u\n", VAR_3);
return AVERROR_INVALIDDATA;
}
if (VAR_4 < 1 || VAR_4 > 2) {
av_log(VAR_0, AV_LOG_ERROR, "invalid bytes per sample: %u\n",
VAR_4);
return AVERROR_INVALIDDATA;
}
if (VAR_5 < 1 || VAR_5 > 2) {
av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_5: %u\n", VAR_5);
return AVERROR_INVALIDDATA;
}
idcin->audio_present = 1;
} else {
idcin->audio_present = 0;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
st->start_time = 0;
idcin->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_IDCIN;
st->codec->codec_tag = 0;
st->codec->VAR_1 = VAR_1;
st->codec->VAR_2 = VAR_2;
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
VAR_6 = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
if (VAR_6 < 0) {
return VAR_6;
} else if (VAR_6 != HUFFMAN_TABLE_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "incomplete header\n");
return AVERROR(EIO);
}
if (idcin->audio_present) {
idcin->audio_present = 1;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, VAR_3);
st->start_time = 0;
idcin->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 1;
st->codec->VAR_5 = VAR_5;
st->codec->channel_layout = VAR_5 > 1 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
st->codec->VAR_3 = VAR_3;
st->codec->bits_per_coded_sample = VAR_4 * 8;
st->codec->bit_rate = VAR_3 * VAR_4 * 8 * VAR_5;
st->codec->block_align = idcin->block_align = VAR_4 * VAR_5;
if (VAR_4 == 1)
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
if (VAR_3 % 14 != 0) {
idcin->audio_chunk_size1 = (VAR_3 / 14) *
VAR_4 * VAR_5;
idcin->audio_chunk_size2 = (VAR_3 / 14 + 1) *
VAR_4 * VAR_5;
} else {
idcin->audio_chunk_size1 = idcin->audio_chunk_size2 =
(VAR_3 / 14) * VAR_4 * VAR_5;
}
idcin->current_audio_chunk = 0;
}
idcin->next_chunk_is_video = 1;
idcin->first_pkt_pos = avio_tell(VAR_0->pb);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVIOContext *pb = VAR_0->pb;",
"IdcinDemuxContext *idcin = VAR_0->priv_data;",
"AVStream *st;",
"unsigned int VAR_1, VAR_2;",
"unsigned int VAR_3, VAR_4, VAR_5;",
"int VAR_6;",
"VAR_1 = avio_rl32(pb);",
"VAR_2 = avio_rl32(pb);",
"VAR_3 = avio_rl32(pb);",
"VAR_4 = avio_rl32(pb);",
"VAR_5 = avio_rl32(pb);",
"if (VAR_0->pb->eof_reached) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incomplete header\\n\");",
"return VAR_0->pb->error ? VAR_0->pb->error : AVERROR_EOF;",
"}",
"if (av_image_check_size(VAR_1, VAR_2, 0, VAR_0) < 0)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_3 > 0) {",
"if (VAR_3 < 14 || VAR_3 > INT_MAX) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid sample rate: %u\\n\", VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_4 < 1 || VAR_4 > 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid bytes per sample: %u\\n\",\nVAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_5 < 1 || VAR_5 > 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid VAR_5: %u\\n\", VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"idcin->audio_present = 1;",
"} else {",
"idcin->audio_present = 0;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);",
"st->start_time = 0;",
"idcin->video_stream_index = st->index;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = AV_CODEC_ID_IDCIN;",
"st->codec->codec_tag = 0;",
"st->codec->VAR_1 = VAR_1;",
"st->codec->VAR_2 = VAR_2;",
"st->codec->extradata_size = HUFFMAN_TABLE_SIZE;",
"st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);",
"VAR_6 = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);",
"if (VAR_6 < 0) {",
"return VAR_6;",
"} else if (VAR_6 != HUFFMAN_TABLE_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incomplete header\\n\");",
"return AVERROR(EIO);",
"}",
"if (idcin->audio_present) {",
"idcin->audio_present = 1;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 63, 1, VAR_3);",
"st->start_time = 0;",
"idcin->audio_stream_index = st->index;",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codec->codec_tag = 1;",
"st->codec->VAR_5 = VAR_5;",
"st->codec->channel_layout = VAR_5 > 1 ? AV_CH_LAYOUT_STEREO :\nAV_CH_LAYOUT_MONO;",
"st->codec->VAR_3 = VAR_3;",
"st->codec->bits_per_coded_sample = VAR_4 * 8;",
"st->codec->bit_rate = VAR_3 * VAR_4 * 8 * VAR_5;",
"st->codec->block_align = idcin->block_align = VAR_4 * VAR_5;",
"if (VAR_4 == 1)\nst->codec->codec_id = AV_CODEC_ID_PCM_U8;",
"else\nst->codec->codec_id = AV_CODEC_ID_PCM_S16LE;",
"if (VAR_3 % 14 != 0) {",
"idcin->audio_chunk_size1 = (VAR_3 / 14) *\nVAR_4 * VAR_5;",
"idcin->audio_chunk_size2 = (VAR_3 / 14 + 1) *\nVAR_4 * VAR_5;",
"} else {",
"idcin->audio_chunk_size1 = idcin->audio_chunk_size2 =\n(VAR_3 / 14) * VAR_4 * VAR_5;",
"}",
"idcin->current_audio_chunk = 0;",
"}",
"idcin->next_chunk_is_video = 1;",
"idcin->first_pkt_pos = avio_tell(VAR_0->pb);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171,
173
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
207
],
[
209
]
] |
24,429 | static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
PTLCommon *ptl)
{
int i;
if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
return -1;
ptl->profile_space = get_bits(gb, 2);
ptl->tier_flag = get_bits1(gb);
ptl->profile_idc = get_bits(gb, 5);
if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc);
for (i = 0; i < 32; i++)
ptl->profile_compatibility_flag[i] = get_bits1(gb);
ptl->progressive_source_flag = get_bits1(gb);
ptl->interlaced_source_flag = get_bits1(gb);
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
return 0;
}
| false | FFmpeg | f85cc3bf12236e974403667610b39b802b8651d6 | static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
PTLCommon *ptl)
{
int i;
if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
return -1;
ptl->profile_space = get_bits(gb, 2);
ptl->tier_flag = get_bits1(gb);
ptl->profile_idc = get_bits(gb, 5);
if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc);
for (i = 0; i < 32; i++)
ptl->profile_compatibility_flag[i] = get_bits1(gb);
ptl->progressive_source_flag = get_bits1(gb);
ptl->interlaced_source_flag = get_bits1(gb);
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
skip_bits(gb, 16);
skip_bits(gb, 16);
skip_bits(gb, 12);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,
PTLCommon *VAR_2)
{
int VAR_3;
if (get_bits_left(VAR_0) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
return -1;
VAR_2->profile_space = get_bits(VAR_0, 2);
VAR_2->tier_flag = get_bits1(VAR_0);
VAR_2->profile_idc = get_bits(VAR_0, 5);
if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(VAR_1, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(VAR_1, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(VAR_1, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (VAR_2->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(VAR_1, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(VAR_1, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", VAR_2->profile_idc);
for (VAR_3 = 0; VAR_3 < 32; VAR_3++)
VAR_2->profile_compatibility_flag[VAR_3] = get_bits1(VAR_0);
VAR_2->progressive_source_flag = get_bits1(VAR_0);
VAR_2->interlaced_source_flag = get_bits1(VAR_0);
VAR_2->non_packed_constraint_flag = get_bits1(VAR_0);
VAR_2->frame_only_constraint_flag = get_bits1(VAR_0);
skip_bits(VAR_0, 16);
skip_bits(VAR_0, 16);
skip_bits(VAR_0, 12);
return 0;
}
| [
"static int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,\nPTLCommon *VAR_2)\n{",
"int VAR_3;",
"if (get_bits_left(VAR_0) < 2+1+5 + 32 + 4 + 16 + 16 + 12)\nreturn -1;",
"VAR_2->profile_space = get_bits(VAR_0, 2);",
"VAR_2->tier_flag = get_bits1(VAR_0);",
"VAR_2->profile_idc = get_bits(VAR_0, 5);",
"if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN)\nav_log(VAR_1, AV_LOG_DEBUG, \"Main profile bitstream\\n\");",
"else if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN_10)\nav_log(VAR_1, AV_LOG_DEBUG, \"Main 10 profile bitstream\\n\");",
"else if (VAR_2->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)\nav_log(VAR_1, AV_LOG_DEBUG, \"Main Still Picture profile bitstream\\n\");",
"else if (VAR_2->profile_idc == FF_PROFILE_HEVC_REXT)\nav_log(VAR_1, AV_LOG_DEBUG, \"Range Extension profile bitstream\\n\");",
"else\nav_log(VAR_1, AV_LOG_WARNING, \"Unknown HEVC profile: %d\\n\", VAR_2->profile_idc);",
"for (VAR_3 = 0; VAR_3 < 32; VAR_3++)",
"VAR_2->profile_compatibility_flag[VAR_3] = get_bits1(VAR_0);",
"VAR_2->progressive_source_flag = get_bits1(VAR_0);",
"VAR_2->interlaced_source_flag = get_bits1(VAR_0);",
"VAR_2->non_packed_constraint_flag = get_bits1(VAR_0);",
"VAR_2->frame_only_constraint_flag = get_bits1(VAR_0);",
"skip_bits(VAR_0, 16);",
"skip_bits(VAR_0, 16);",
"skip_bits(VAR_0, 12);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
24,431 | int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
{
struct {
LBRChunk lfe;
LBRChunk tonal;
LBRChunk tonal_grp[5];
LBRChunk grid1[DCA_LBR_CHANNELS / 2];
LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];
LBRChunk ts1[DCA_LBR_CHANNELS / 2];
LBRChunk ts2[DCA_LBR_CHANNELS / 2];
} chunk = { };
GetByteContext gb;
int i, ch, sb, sf, ret, group, chunk_id, chunk_len;
bytestream2_init(&gb, data + asset->lbr_offset, asset->lbr_size);
// LBR sync word
if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n");
return AVERROR_INVALIDDATA;
}
// LBR header type
switch (bytestream2_get_byte(&gb)) {
case LBR_HEADER_SYNC_ONLY:
if (!s->sample_rate) {
av_log(s->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n");
return AVERROR_INVALIDDATA;
}
break;
case LBR_HEADER_DECODER_INIT:
if ((ret = parse_decoder_init(s, &gb)) < 0) {
s->sample_rate = 0;
return ret;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR header type\n");
return AVERROR_INVALIDDATA;
}
// LBR frame chunk header
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR frame chunk was truncated\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, gb.buffer, chunk_len);
switch (chunk_id & 0x7f) {
case LBR_CHUNK_FRAME:
if (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {
int checksum = bytestream2_get_be16(&gb);
uint16_t res = chunk_id;
res += (chunk_len >> 8) & 0xff;
res += chunk_len & 0xff;
for (i = 0; i < chunk_len - 2; i++)
res += gb.buffer[i];
if (checksum != res) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid LBR checksum\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
} else {
bytestream2_skip(&gb, 2);
}
break;
case LBR_CHUNK_FRAME_NO_CSUM:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR frame chunk ID\n");
return AVERROR_INVALIDDATA;
}
// Clear current frame
memset(s->quant_levels, 0, sizeof(s->quant_levels));
memset(s->sb_indices, 0xff, sizeof(s->sb_indices));
memset(s->sec_ch_sbms, 0, sizeof(s->sec_ch_sbms));
memset(s->sec_ch_lrms, 0, sizeof(s->sec_ch_lrms));
memset(s->ch_pres, 0, sizeof(s->ch_pres));
memset(s->grid_1_scf, 0, sizeof(s->grid_1_scf));
memset(s->grid_2_scf, 0, sizeof(s->grid_2_scf));
memset(s->grid_3_avg, 0, sizeof(s->grid_3_avg));
memset(s->grid_3_scf, 0, sizeof(s->grid_3_scf));
memset(s->grid_3_pres, 0, sizeof(s->grid_3_pres));
memset(s->tonal_scf, 0, sizeof(s->tonal_scf));
memset(s->lfe_data, 0, sizeof(s->lfe_data));
s->part_stereo_pres = 0;
s->framenum = (s->framenum + 1) & 31;
for (ch = 0; ch < s->nchannels; ch++) {
for (sb = 0; sb < s->nsubbands / 4; sb++) {
s->part_stereo[ch][sb][0] = s->part_stereo[ch][sb][4];
s->part_stereo[ch][sb][4] = 16;
}
}
memset(s->lpc_coeff[s->framenum & 1], 0, sizeof(s->lpc_coeff[0]));
for (group = 0; group < 5; group++) {
for (sf = 0; sf < 1 << group; sf++) {
int sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] =
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
}
// Parse chunk headers
while (bytestream2_get_bytes_left(&gb) > 0) {
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
chunk_id &= 0x7f;
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR chunk %#x was truncated\n", chunk_id);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
switch (chunk_id) {
case LBR_CHUNK_LFE:
chunk.lfe.len = chunk_len;
chunk.lfe.data = gb.buffer;
break;
case LBR_CHUNK_SCF:
case LBR_CHUNK_TONAL:
case LBR_CHUNK_TONAL_SCF:
chunk.tonal.id = chunk_id;
chunk.tonal.len = chunk_len;
chunk.tonal.data = gb.buffer;
break;
case LBR_CHUNK_TONAL_GRP_1:
case LBR_CHUNK_TONAL_GRP_2:
case LBR_CHUNK_TONAL_GRP_3:
case LBR_CHUNK_TONAL_GRP_4:
case LBR_CHUNK_TONAL_GRP_5:
i = LBR_CHUNK_TONAL_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_TONAL_SCF_GRP_1:
case LBR_CHUNK_TONAL_SCF_GRP_2:
case LBR_CHUNK_TONAL_SCF_GRP_3:
case LBR_CHUNK_TONAL_SCF_GRP_4:
case LBR_CHUNK_TONAL_SCF_GRP_5:
i = LBR_CHUNK_TONAL_SCF_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_LR:
case LBR_CHUNK_RES_GRID_LR + 1:
case LBR_CHUNK_RES_GRID_LR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_LR;
chunk.grid1[i].len = chunk_len;
chunk.grid1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_HR:
case LBR_CHUNK_RES_GRID_HR + 1:
case LBR_CHUNK_RES_GRID_HR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_HR;
chunk.hr_grid[i].len = chunk_len;
chunk.hr_grid[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_1:
case LBR_CHUNK_RES_TS_1 + 1:
case LBR_CHUNK_RES_TS_1 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_1;
chunk.ts1[i].len = chunk_len;
chunk.ts1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_2:
case LBR_CHUNK_RES_TS_2 + 1:
case LBR_CHUNK_RES_TS_2 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_2;
chunk.ts2[i].len = chunk_len;
chunk.ts2[i].data = gb.buffer;
break;
}
bytestream2_skip(&gb, chunk_len);
}
// Parse the chunks
ret = parse_lfe_chunk(s, &chunk.lfe);
ret |= parse_tonal_chunk(s, &chunk.tonal);
for (i = 0; i < 5; i++)
ret |= parse_tonal_group(s, &chunk.tonal_grp[i]);
for (i = 0; i < (s->nchannels + 1) / 2; i++) {
int ch1 = i * 2;
int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
if (parse_grid_1_chunk (s, &chunk.grid1 [i], ch1, ch2) < 0 ||
parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
// TS chunks depend on both grids. TS_2 depends on TS_1.
if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len)
continue;
if (parse_ts1_chunk(s, &chunk.ts1[i], ch1, ch2) < 0 ||
parse_ts2_chunk(s, &chunk.ts2[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
}
if (ret < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return 0;
}
| false | FFmpeg | 27506aceda8115f82f89691a4441d62a8cf24a6e | int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
{
struct {
LBRChunk lfe;
LBRChunk tonal;
LBRChunk tonal_grp[5];
LBRChunk grid1[DCA_LBR_CHANNELS / 2];
LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];
LBRChunk ts1[DCA_LBR_CHANNELS / 2];
LBRChunk ts2[DCA_LBR_CHANNELS / 2];
} chunk = { };
GetByteContext gb;
int i, ch, sb, sf, ret, group, chunk_id, chunk_len;
bytestream2_init(&gb, data + asset->lbr_offset, asset->lbr_size);
if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n");
return AVERROR_INVALIDDATA;
}
switch (bytestream2_get_byte(&gb)) {
case LBR_HEADER_SYNC_ONLY:
if (!s->sample_rate) {
av_log(s->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n");
return AVERROR_INVALIDDATA;
}
break;
case LBR_HEADER_DECODER_INIT:
if ((ret = parse_decoder_init(s, &gb)) < 0) {
s->sample_rate = 0;
return ret;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR header type\n");
return AVERROR_INVALIDDATA;
}
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR frame chunk was truncated\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, gb.buffer, chunk_len);
switch (chunk_id & 0x7f) {
case LBR_CHUNK_FRAME:
if (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {
int checksum = bytestream2_get_be16(&gb);
uint16_t res = chunk_id;
res += (chunk_len >> 8) & 0xff;
res += chunk_len & 0xff;
for (i = 0; i < chunk_len - 2; i++)
res += gb.buffer[i];
if (checksum != res) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid LBR checksum\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
} else {
bytestream2_skip(&gb, 2);
}
break;
case LBR_CHUNK_FRAME_NO_CSUM:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR frame chunk ID\n");
return AVERROR_INVALIDDATA;
}
memset(s->quant_levels, 0, sizeof(s->quant_levels));
memset(s->sb_indices, 0xff, sizeof(s->sb_indices));
memset(s->sec_ch_sbms, 0, sizeof(s->sec_ch_sbms));
memset(s->sec_ch_lrms, 0, sizeof(s->sec_ch_lrms));
memset(s->ch_pres, 0, sizeof(s->ch_pres));
memset(s->grid_1_scf, 0, sizeof(s->grid_1_scf));
memset(s->grid_2_scf, 0, sizeof(s->grid_2_scf));
memset(s->grid_3_avg, 0, sizeof(s->grid_3_avg));
memset(s->grid_3_scf, 0, sizeof(s->grid_3_scf));
memset(s->grid_3_pres, 0, sizeof(s->grid_3_pres));
memset(s->tonal_scf, 0, sizeof(s->tonal_scf));
memset(s->lfe_data, 0, sizeof(s->lfe_data));
s->part_stereo_pres = 0;
s->framenum = (s->framenum + 1) & 31;
for (ch = 0; ch < s->nchannels; ch++) {
for (sb = 0; sb < s->nsubbands / 4; sb++) {
s->part_stereo[ch][sb][0] = s->part_stereo[ch][sb][4];
s->part_stereo[ch][sb][4] = 16;
}
}
memset(s->lpc_coeff[s->framenum & 1], 0, sizeof(s->lpc_coeff[0]));
for (group = 0; group < 5; group++) {
for (sf = 0; sf < 1 << group; sf++) {
int sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] =
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
}
while (bytestream2_get_bytes_left(&gb) > 0) {
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
chunk_id &= 0x7f;
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR chunk %#x was truncated\n", chunk_id);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
switch (chunk_id) {
case LBR_CHUNK_LFE:
chunk.lfe.len = chunk_len;
chunk.lfe.data = gb.buffer;
break;
case LBR_CHUNK_SCF:
case LBR_CHUNK_TONAL:
case LBR_CHUNK_TONAL_SCF:
chunk.tonal.id = chunk_id;
chunk.tonal.len = chunk_len;
chunk.tonal.data = gb.buffer;
break;
case LBR_CHUNK_TONAL_GRP_1:
case LBR_CHUNK_TONAL_GRP_2:
case LBR_CHUNK_TONAL_GRP_3:
case LBR_CHUNK_TONAL_GRP_4:
case LBR_CHUNK_TONAL_GRP_5:
i = LBR_CHUNK_TONAL_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_TONAL_SCF_GRP_1:
case LBR_CHUNK_TONAL_SCF_GRP_2:
case LBR_CHUNK_TONAL_SCF_GRP_3:
case LBR_CHUNK_TONAL_SCF_GRP_4:
case LBR_CHUNK_TONAL_SCF_GRP_5:
i = LBR_CHUNK_TONAL_SCF_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_LR:
case LBR_CHUNK_RES_GRID_LR + 1:
case LBR_CHUNK_RES_GRID_LR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_LR;
chunk.grid1[i].len = chunk_len;
chunk.grid1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_HR:
case LBR_CHUNK_RES_GRID_HR + 1:
case LBR_CHUNK_RES_GRID_HR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_HR;
chunk.hr_grid[i].len = chunk_len;
chunk.hr_grid[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_1:
case LBR_CHUNK_RES_TS_1 + 1:
case LBR_CHUNK_RES_TS_1 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_1;
chunk.ts1[i].len = chunk_len;
chunk.ts1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_2:
case LBR_CHUNK_RES_TS_2 + 1:
case LBR_CHUNK_RES_TS_2 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_2;
chunk.ts2[i].len = chunk_len;
chunk.ts2[i].data = gb.buffer;
break;
}
bytestream2_skip(&gb, chunk_len);
}
ret = parse_lfe_chunk(s, &chunk.lfe);
ret |= parse_tonal_chunk(s, &chunk.tonal);
for (i = 0; i < 5; i++)
ret |= parse_tonal_group(s, &chunk.tonal_grp[i]);
for (i = 0; i < (s->nchannels + 1) / 2; i++) {
int ch1 = i * 2;
int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
if (parse_grid_1_chunk (s, &chunk.grid1 [i], ch1, ch2) < 0 ||
parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len)
continue;
if (parse_ts1_chunk(s, &chunk.ts1[i], ch1, ch2) < 0 ||
parse_ts2_chunk(s, &chunk.ts2[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
}
if (ret < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(DCALbrDecoder *VAR_0, uint8_t *VAR_1, DCAExssAsset *VAR_2)
{
struct {
LBRChunk lfe;
LBRChunk tonal;
LBRChunk tonal_grp[5];
LBRChunk grid1[DCA_LBR_CHANNELS / 2];
LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];
LBRChunk ts1[DCA_LBR_CHANNELS / 2];
LBRChunk ts2[DCA_LBR_CHANNELS / 2];
} VAR_3 = { };
GetByteContext gb;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
bytestream2_init(&gb, VAR_1 + VAR_2->lbr_offset, VAR_2->lbr_size);
if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n");
return AVERROR_INVALIDDATA;
}
switch (bytestream2_get_byte(&gb)) {
case LBR_HEADER_SYNC_ONLY:
if (!VAR_0->sample_rate) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n");
return AVERROR_INVALIDDATA;
}
break;
case LBR_HEADER_DECODER_INIT:
if ((VAR_8 = parse_decoder_init(VAR_0, &gb)) < 0) {
VAR_0->sample_rate = 0;
return VAR_8;
}
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid LBR header type\n");
return AVERROR_INVALIDDATA;
}
VAR_10 = bytestream2_get_byte(&gb);
VAR_11 = (VAR_10 & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
if (VAR_11 > bytestream2_get_bytes_left(&gb)) {
VAR_11 = bytestream2_get_bytes_left(&gb);
av_log(VAR_0->avctx, AV_LOG_WARNING, "LBR frame VAR_3 was truncated\n");
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, gb.buffer, VAR_11);
switch (VAR_10 & 0x7f) {
case LBR_CHUNK_FRAME:
if (VAR_0->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {
int VAR_12 = bytestream2_get_be16(&gb);
uint16_t res = VAR_10;
res += (VAR_11 >> 8) & 0xff;
res += VAR_11 & 0xff;
for (VAR_4 = 0; VAR_4 < VAR_11 - 2; VAR_4++)
res += gb.buffer[VAR_4];
if (VAR_12 != res) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid LBR VAR_12\n");
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
} else {
bytestream2_skip(&gb, 2);
}
break;
case LBR_CHUNK_FRAME_NO_CSUM:
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid LBR frame VAR_3 ID\n");
return AVERROR_INVALIDDATA;
}
memset(VAR_0->quant_levels, 0, sizeof(VAR_0->quant_levels));
memset(VAR_0->sb_indices, 0xff, sizeof(VAR_0->sb_indices));
memset(VAR_0->sec_ch_sbms, 0, sizeof(VAR_0->sec_ch_sbms));
memset(VAR_0->sec_ch_lrms, 0, sizeof(VAR_0->sec_ch_lrms));
memset(VAR_0->ch_pres, 0, sizeof(VAR_0->ch_pres));
memset(VAR_0->grid_1_scf, 0, sizeof(VAR_0->grid_1_scf));
memset(VAR_0->grid_2_scf, 0, sizeof(VAR_0->grid_2_scf));
memset(VAR_0->grid_3_avg, 0, sizeof(VAR_0->grid_3_avg));
memset(VAR_0->grid_3_scf, 0, sizeof(VAR_0->grid_3_scf));
memset(VAR_0->grid_3_pres, 0, sizeof(VAR_0->grid_3_pres));
memset(VAR_0->tonal_scf, 0, sizeof(VAR_0->tonal_scf));
memset(VAR_0->lfe_data, 0, sizeof(VAR_0->lfe_data));
VAR_0->part_stereo_pres = 0;
VAR_0->framenum = (VAR_0->framenum + 1) & 31;
for (VAR_5 = 0; VAR_5 < VAR_0->nchannels; VAR_5++) {
for (VAR_6 = 0; VAR_6 < VAR_0->nsubbands / 4; VAR_6++) {
VAR_0->part_stereo[VAR_5][VAR_6][0] = VAR_0->part_stereo[VAR_5][VAR_6][4];
VAR_0->part_stereo[VAR_5][VAR_6][4] = 16;
}
}
memset(VAR_0->lpc_coeff[VAR_0->framenum & 1], 0, sizeof(VAR_0->lpc_coeff[0]));
for (VAR_9 = 0; VAR_9 < 5; VAR_9++) {
for (VAR_7 = 0; VAR_7 < 1 << VAR_9; VAR_7++) {
int VAR_13 = ((VAR_0->framenum << VAR_9) + VAR_7) & 31;
VAR_0->tonal_bounds[VAR_9][VAR_13][0] =
VAR_0->tonal_bounds[VAR_9][VAR_13][1] = VAR_0->ntones;
}
}
while (bytestream2_get_bytes_left(&gb) > 0) {
VAR_10 = bytestream2_get_byte(&gb);
VAR_11 = (VAR_10 & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
VAR_10 &= 0x7f;
if (VAR_11 > bytestream2_get_bytes_left(&gb)) {
VAR_11 = bytestream2_get_bytes_left(&gb);
av_log(VAR_0->avctx, AV_LOG_WARNING, "LBR VAR_3 %#x was truncated\n", VAR_10);
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
switch (VAR_10) {
case LBR_CHUNK_LFE:
VAR_3.lfe.len = VAR_11;
VAR_3.lfe.VAR_1 = gb.buffer;
break;
case LBR_CHUNK_SCF:
case LBR_CHUNK_TONAL:
case LBR_CHUNK_TONAL_SCF:
VAR_3.tonal.id = VAR_10;
VAR_3.tonal.len = VAR_11;
VAR_3.tonal.VAR_1 = gb.buffer;
break;
case LBR_CHUNK_TONAL_GRP_1:
case LBR_CHUNK_TONAL_GRP_2:
case LBR_CHUNK_TONAL_GRP_3:
case LBR_CHUNK_TONAL_GRP_4:
case LBR_CHUNK_TONAL_GRP_5:
VAR_4 = LBR_CHUNK_TONAL_GRP_5 - VAR_10;
VAR_3.tonal_grp[VAR_4].id = VAR_4;
VAR_3.tonal_grp[VAR_4].len = VAR_11;
VAR_3.tonal_grp[VAR_4].VAR_1 = gb.buffer;
break;
case LBR_CHUNK_TONAL_SCF_GRP_1:
case LBR_CHUNK_TONAL_SCF_GRP_2:
case LBR_CHUNK_TONAL_SCF_GRP_3:
case LBR_CHUNK_TONAL_SCF_GRP_4:
case LBR_CHUNK_TONAL_SCF_GRP_5:
VAR_4 = LBR_CHUNK_TONAL_SCF_GRP_5 - VAR_10;
VAR_3.tonal_grp[VAR_4].id = VAR_4;
VAR_3.tonal_grp[VAR_4].len = VAR_11;
VAR_3.tonal_grp[VAR_4].VAR_1 = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_LR:
case LBR_CHUNK_RES_GRID_LR + 1:
case LBR_CHUNK_RES_GRID_LR + 2:
VAR_4 = VAR_10 - LBR_CHUNK_RES_GRID_LR;
VAR_3.grid1[VAR_4].len = VAR_11;
VAR_3.grid1[VAR_4].VAR_1 = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_HR:
case LBR_CHUNK_RES_GRID_HR + 1:
case LBR_CHUNK_RES_GRID_HR + 2:
VAR_4 = VAR_10 - LBR_CHUNK_RES_GRID_HR;
VAR_3.hr_grid[VAR_4].len = VAR_11;
VAR_3.hr_grid[VAR_4].VAR_1 = gb.buffer;
break;
case LBR_CHUNK_RES_TS_1:
case LBR_CHUNK_RES_TS_1 + 1:
case LBR_CHUNK_RES_TS_1 + 2:
VAR_4 = VAR_10 - LBR_CHUNK_RES_TS_1;
VAR_3.ts1[VAR_4].len = VAR_11;
VAR_3.ts1[VAR_4].VAR_1 = gb.buffer;
break;
case LBR_CHUNK_RES_TS_2:
case LBR_CHUNK_RES_TS_2 + 1:
case LBR_CHUNK_RES_TS_2 + 2:
VAR_4 = VAR_10 - LBR_CHUNK_RES_TS_2;
VAR_3.ts2[VAR_4].len = VAR_11;
VAR_3.ts2[VAR_4].VAR_1 = gb.buffer;
break;
}
bytestream2_skip(&gb, VAR_11);
}
VAR_8 = parse_lfe_chunk(VAR_0, &VAR_3.lfe);
VAR_8 |= parse_tonal_chunk(VAR_0, &VAR_3.tonal);
for (VAR_4 = 0; VAR_4 < 5; VAR_4++)
VAR_8 |= parse_tonal_group(VAR_0, &VAR_3.tonal_grp[VAR_4]);
for (VAR_4 = 0; VAR_4 < (VAR_0->nchannels + 1) / 2; VAR_4++) {
int ch1 = VAR_4 * 2;
int ch2 = FFMIN(ch1 + 1, VAR_0->nchannels - 1);
if (parse_grid_1_chunk (VAR_0, &VAR_3.grid1 [VAR_4], ch1, ch2) < 0 ||
parse_high_res_grid(VAR_0, &VAR_3.hr_grid[VAR_4], ch1, ch2) < 0) {
VAR_8 = -1;
continue;
}
if (!VAR_3.grid1[VAR_4].len || !VAR_3.hr_grid[VAR_4].len || !VAR_3.ts1[VAR_4].len)
continue;
if (parse_ts1_chunk(VAR_0, &VAR_3.ts1[VAR_4], ch1, ch2) < 0 ||
parse_ts2_chunk(VAR_0, &VAR_3.ts2[VAR_4], ch1, ch2) < 0) {
VAR_8 = -1;
continue;
}
}
if (VAR_8 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return 0;
}
| [
"int FUNC_0(DCALbrDecoder *VAR_0, uint8_t *VAR_1, DCAExssAsset *VAR_2)\n{",
"struct {",
"LBRChunk lfe;",
"LBRChunk tonal;",
"LBRChunk tonal_grp[5];",
"LBRChunk grid1[DCA_LBR_CHANNELS / 2];",
"LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];",
"LBRChunk ts1[DCA_LBR_CHANNELS / 2];",
"LBRChunk ts2[DCA_LBR_CHANNELS / 2];",
"} VAR_3 = { };",
"GetByteContext gb;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"bytestream2_init(&gb, VAR_1 + VAR_2->lbr_offset, VAR_2->lbr_size);",
"if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid LBR sync word\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"switch (bytestream2_get_byte(&gb)) {",
"case LBR_HEADER_SYNC_ONLY:\nif (!VAR_0->sample_rate) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"LBR decoder not initialized\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"break;",
"case LBR_HEADER_DECODER_INIT:\nif ((VAR_8 = parse_decoder_init(VAR_0, &gb)) < 0) {",
"VAR_0->sample_rate = 0;",
"return VAR_8;",
"}",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid LBR header type\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_10 = bytestream2_get_byte(&gb);",
"VAR_11 = (VAR_10 & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);",
"if (VAR_11 > bytestream2_get_bytes_left(&gb)) {",
"VAR_11 = bytestream2_get_bytes_left(&gb);",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"LBR frame VAR_3 was truncated\\n\");",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"bytestream2_init(&gb, gb.buffer, VAR_11);",
"switch (VAR_10 & 0x7f) {",
"case LBR_CHUNK_FRAME:\nif (VAR_0->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {",
"int VAR_12 = bytestream2_get_be16(&gb);",
"uint16_t res = VAR_10;",
"res += (VAR_11 >> 8) & 0xff;",
"res += VAR_11 & 0xff;",
"for (VAR_4 = 0; VAR_4 < VAR_11 - 2; VAR_4++)",
"res += gb.buffer[VAR_4];",
"if (VAR_12 != res) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid LBR VAR_12\\n\");",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"} else {",
"bytestream2_skip(&gb, 2);",
"}",
"break;",
"case LBR_CHUNK_FRAME_NO_CSUM:\nbreak;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid LBR frame VAR_3 ID\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"memset(VAR_0->quant_levels, 0, sizeof(VAR_0->quant_levels));",
"memset(VAR_0->sb_indices, 0xff, sizeof(VAR_0->sb_indices));",
"memset(VAR_0->sec_ch_sbms, 0, sizeof(VAR_0->sec_ch_sbms));",
"memset(VAR_0->sec_ch_lrms, 0, sizeof(VAR_0->sec_ch_lrms));",
"memset(VAR_0->ch_pres, 0, sizeof(VAR_0->ch_pres));",
"memset(VAR_0->grid_1_scf, 0, sizeof(VAR_0->grid_1_scf));",
"memset(VAR_0->grid_2_scf, 0, sizeof(VAR_0->grid_2_scf));",
"memset(VAR_0->grid_3_avg, 0, sizeof(VAR_0->grid_3_avg));",
"memset(VAR_0->grid_3_scf, 0, sizeof(VAR_0->grid_3_scf));",
"memset(VAR_0->grid_3_pres, 0, sizeof(VAR_0->grid_3_pres));",
"memset(VAR_0->tonal_scf, 0, sizeof(VAR_0->tonal_scf));",
"memset(VAR_0->lfe_data, 0, sizeof(VAR_0->lfe_data));",
"VAR_0->part_stereo_pres = 0;",
"VAR_0->framenum = (VAR_0->framenum + 1) & 31;",
"for (VAR_5 = 0; VAR_5 < VAR_0->nchannels; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < VAR_0->nsubbands / 4; VAR_6++) {",
"VAR_0->part_stereo[VAR_5][VAR_6][0] = VAR_0->part_stereo[VAR_5][VAR_6][4];",
"VAR_0->part_stereo[VAR_5][VAR_6][4] = 16;",
"}",
"}",
"memset(VAR_0->lpc_coeff[VAR_0->framenum & 1], 0, sizeof(VAR_0->lpc_coeff[0]));",
"for (VAR_9 = 0; VAR_9 < 5; VAR_9++) {",
"for (VAR_7 = 0; VAR_7 < 1 << VAR_9; VAR_7++) {",
"int VAR_13 = ((VAR_0->framenum << VAR_9) + VAR_7) & 31;",
"VAR_0->tonal_bounds[VAR_9][VAR_13][0] =\nVAR_0->tonal_bounds[VAR_9][VAR_13][1] = VAR_0->ntones;",
"}",
"}",
"while (bytestream2_get_bytes_left(&gb) > 0) {",
"VAR_10 = bytestream2_get_byte(&gb);",
"VAR_11 = (VAR_10 & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);",
"VAR_10 &= 0x7f;",
"if (VAR_11 > bytestream2_get_bytes_left(&gb)) {",
"VAR_11 = bytestream2_get_bytes_left(&gb);",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"LBR VAR_3 %#x was truncated\\n\", VAR_10);",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"switch (VAR_10) {",
"case LBR_CHUNK_LFE:\nVAR_3.lfe.len = VAR_11;",
"VAR_3.lfe.VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_SCF:\ncase LBR_CHUNK_TONAL:\ncase LBR_CHUNK_TONAL_SCF:\nVAR_3.tonal.id = VAR_10;",
"VAR_3.tonal.len = VAR_11;",
"VAR_3.tonal.VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_TONAL_GRP_1:\ncase LBR_CHUNK_TONAL_GRP_2:\ncase LBR_CHUNK_TONAL_GRP_3:\ncase LBR_CHUNK_TONAL_GRP_4:\ncase LBR_CHUNK_TONAL_GRP_5:\nVAR_4 = LBR_CHUNK_TONAL_GRP_5 - VAR_10;",
"VAR_3.tonal_grp[VAR_4].id = VAR_4;",
"VAR_3.tonal_grp[VAR_4].len = VAR_11;",
"VAR_3.tonal_grp[VAR_4].VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_TONAL_SCF_GRP_1:\ncase LBR_CHUNK_TONAL_SCF_GRP_2:\ncase LBR_CHUNK_TONAL_SCF_GRP_3:\ncase LBR_CHUNK_TONAL_SCF_GRP_4:\ncase LBR_CHUNK_TONAL_SCF_GRP_5:\nVAR_4 = LBR_CHUNK_TONAL_SCF_GRP_5 - VAR_10;",
"VAR_3.tonal_grp[VAR_4].id = VAR_4;",
"VAR_3.tonal_grp[VAR_4].len = VAR_11;",
"VAR_3.tonal_grp[VAR_4].VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_RES_GRID_LR:\ncase LBR_CHUNK_RES_GRID_LR + 1:\ncase LBR_CHUNK_RES_GRID_LR + 2:\nVAR_4 = VAR_10 - LBR_CHUNK_RES_GRID_LR;",
"VAR_3.grid1[VAR_4].len = VAR_11;",
"VAR_3.grid1[VAR_4].VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_RES_GRID_HR:\ncase LBR_CHUNK_RES_GRID_HR + 1:\ncase LBR_CHUNK_RES_GRID_HR + 2:\nVAR_4 = VAR_10 - LBR_CHUNK_RES_GRID_HR;",
"VAR_3.hr_grid[VAR_4].len = VAR_11;",
"VAR_3.hr_grid[VAR_4].VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_RES_TS_1:\ncase LBR_CHUNK_RES_TS_1 + 1:\ncase LBR_CHUNK_RES_TS_1 + 2:\nVAR_4 = VAR_10 - LBR_CHUNK_RES_TS_1;",
"VAR_3.ts1[VAR_4].len = VAR_11;",
"VAR_3.ts1[VAR_4].VAR_1 = gb.buffer;",
"break;",
"case LBR_CHUNK_RES_TS_2:\ncase LBR_CHUNK_RES_TS_2 + 1:\ncase LBR_CHUNK_RES_TS_2 + 2:\nVAR_4 = VAR_10 - LBR_CHUNK_RES_TS_2;",
"VAR_3.ts2[VAR_4].len = VAR_11;",
"VAR_3.ts2[VAR_4].VAR_1 = gb.buffer;",
"break;",
"}",
"bytestream2_skip(&gb, VAR_11);",
"}",
"VAR_8 = parse_lfe_chunk(VAR_0, &VAR_3.lfe);",
"VAR_8 |= parse_tonal_chunk(VAR_0, &VAR_3.tonal);",
"for (VAR_4 = 0; VAR_4 < 5; VAR_4++)",
"VAR_8 |= parse_tonal_group(VAR_0, &VAR_3.tonal_grp[VAR_4]);",
"for (VAR_4 = 0; VAR_4 < (VAR_0->nchannels + 1) / 2; VAR_4++) {",
"int ch1 = VAR_4 * 2;",
"int ch2 = FFMIN(ch1 + 1, VAR_0->nchannels - 1);",
"if (parse_grid_1_chunk (VAR_0, &VAR_3.grid1 [VAR_4], ch1, ch2) < 0 ||\nparse_high_res_grid(VAR_0, &VAR_3.hr_grid[VAR_4], ch1, ch2) < 0) {",
"VAR_8 = -1;",
"continue;",
"}",
"if (!VAR_3.grid1[VAR_4].len || !VAR_3.hr_grid[VAR_4].len || !VAR_3.ts1[VAR_4].len)\ncontinue;",
"if (parse_ts1_chunk(VAR_0, &VAR_3.ts1[VAR_4], ch1, ch2) < 0 ||\nparse_ts2_chunk(VAR_0, &VAR_3.ts2[VAR_4], ch1, ch2) < 0) {",
"VAR_8 = -1;",
"continue;",
"}",
"}",
"if (VAR_8 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
159
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
267,
269,
271,
273
],
[
275
],
[
277
],
[
279
],
[
283,
285,
287,
289,
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305,
307,
309,
311,
313,
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
327,
329,
331,
333
],
[
335
],
[
337
],
[
339
],
[
343,
345,
347,
349
],
[
351
],
[
353
],
[
355
],
[
359,
361,
363,
365
],
[
367
],
[
369
],
[
371
],
[
375,
377,
379,
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
393
],
[
395
],
[
401
],
[
405
],
[
409
],
[
411
],
[
415
],
[
417
],
[
419
],
[
423,
425
],
[
427
],
[
429
],
[
431
],
[
437,
439
],
[
443,
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
457,
459
],
[
463
],
[
465
]
] |
24,432 | static av_cold int wmv2_decode_init(AVCodecContext *avctx)
{
Wmv2Context *const w = avctx->priv_data;
int ret;
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
return ret;
ff_wmv2_common_init(w);
return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);
}
| false | FFmpeg | 1eaae7abb8f208fefb4e8b9e983e61b2499206a3 | static av_cold int wmv2_decode_init(AVCodecContext *avctx)
{
Wmv2Context *const w = avctx->priv_data;
int ret;
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
return ret;
ff_wmv2_common_init(w);
return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
Wmv2Context *const w = avctx->priv_data;
int VAR_0;
if ((VAR_0 = ff_msmpeg4_decode_init(avctx)) < 0)
return VAR_0;
ff_wmv2_common_init(w);
return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"Wmv2Context *const w = avctx->priv_data;",
"int VAR_0;",
"if ((VAR_0 = ff_msmpeg4_decode_init(avctx)) < 0)\nreturn VAR_0;",
"ff_wmv2_common_init(w);",
"return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
21
],
[
23
]
] |
24,434 | static int amovie_get_samples(AVFilterLink *outlink)
{
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, got_frame = 0;
if (!movie->pkt.size && movie->is_done == 1)
return AVERROR_EOF;
/* check for another frame, in case the previous one was completely consumed */
if (!movie->pkt.size) {
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
// Is this a packet from the selected stream?
if (pkt.stream_index != movie->stream_index) {
av_free_packet(&pkt);
continue;
} else {
movie->pkt0 = movie->pkt = pkt;
break;
}
}
if (ret == AVERROR_EOF) {
movie->is_done = 1;
return ret;
}
}
/* decode and update the movie pkt */
avcodec_get_frame_defaults(movie->frame);
ret = avcodec_decode_audio4(movie->codec_ctx, movie->frame, &got_frame, &movie->pkt);
if (ret < 0) {
movie->pkt.size = 0;
return ret;
}
movie->pkt.data += ret;
movie->pkt.size -= ret;
/* wrap the decoded data in a samplesref */
if (got_frame) {
int nb_samples = movie->frame->nb_samples;
int data_size =
av_samples_get_buffer_size(NULL, movie->codec_ctx->channels,
nb_samples, movie->codec_ctx->sample_fmt, 1);
if (data_size < 0)
return data_size;
movie->samplesref =
ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size);
movie->samplesref->pts = movie->pkt.pts;
movie->samplesref->pos = movie->pkt.pos;
movie->samplesref->audio->sample_rate = movie->codec_ctx->sample_rate;
}
// We got it. Free the packet since we are returning
if (movie->pkt.size <= 0)
av_free_packet(&movie->pkt0);
return 0;
}
| false | FFmpeg | ac726a4f0cd2fb8619b478af51312a4282215f0e | static int amovie_get_samples(AVFilterLink *outlink)
{
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, got_frame = 0;
if (!movie->pkt.size && movie->is_done == 1)
return AVERROR_EOF;
if (!movie->pkt.size) {
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
if (pkt.stream_index != movie->stream_index) {
av_free_packet(&pkt);
continue;
} else {
movie->pkt0 = movie->pkt = pkt;
break;
}
}
if (ret == AVERROR_EOF) {
movie->is_done = 1;
return ret;
}
}
avcodec_get_frame_defaults(movie->frame);
ret = avcodec_decode_audio4(movie->codec_ctx, movie->frame, &got_frame, &movie->pkt);
if (ret < 0) {
movie->pkt.size = 0;
return ret;
}
movie->pkt.data += ret;
movie->pkt.size -= ret;
if (got_frame) {
int nb_samples = movie->frame->nb_samples;
int data_size =
av_samples_get_buffer_size(NULL, movie->codec_ctx->channels,
nb_samples, movie->codec_ctx->sample_fmt, 1);
if (data_size < 0)
return data_size;
movie->samplesref =
ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size);
movie->samplesref->pts = movie->pkt.pts;
movie->samplesref->pos = movie->pkt.pos;
movie->samplesref->audio->sample_rate = movie->codec_ctx->sample_rate;
}
if (movie->pkt.size <= 0)
av_free_packet(&movie->pkt0);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0)
{
MovieContext *movie = VAR_0->src->priv;
AVPacket pkt;
int VAR_1, VAR_2 = 0;
if (!movie->pkt.size && movie->is_done == 1)
return AVERROR_EOF;
if (!movie->pkt.size) {
while ((VAR_1 = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
if (pkt.stream_index != movie->stream_index) {
av_free_packet(&pkt);
continue;
} else {
movie->pkt0 = movie->pkt = pkt;
break;
}
}
if (VAR_1 == AVERROR_EOF) {
movie->is_done = 1;
return VAR_1;
}
}
avcodec_get_frame_defaults(movie->frame);
VAR_1 = avcodec_decode_audio4(movie->codec_ctx, movie->frame, &VAR_2, &movie->pkt);
if (VAR_1 < 0) {
movie->pkt.size = 0;
return VAR_1;
}
movie->pkt.data += VAR_1;
movie->pkt.size -= VAR_1;
if (VAR_2) {
int VAR_3 = movie->frame->VAR_3;
int VAR_4 =
av_samples_get_buffer_size(NULL, movie->codec_ctx->channels,
VAR_3, movie->codec_ctx->sample_fmt, 1);
if (VAR_4 < 0)
return VAR_4;
movie->samplesref =
ff_get_audio_buffer(VAR_0, AV_PERM_WRITE, VAR_3);
memcpy(movie->samplesref->data[0], movie->frame->data[0], VAR_4);
movie->samplesref->pts = movie->pkt.pts;
movie->samplesref->pos = movie->pkt.pos;
movie->samplesref->audio->sample_rate = movie->codec_ctx->sample_rate;
}
if (movie->pkt.size <= 0)
av_free_packet(&movie->pkt0);
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"MovieContext *movie = VAR_0->src->priv;",
"AVPacket pkt;",
"int VAR_1, VAR_2 = 0;",
"if (!movie->pkt.size && movie->is_done == 1)\nreturn AVERROR_EOF;",
"if (!movie->pkt.size) {",
"while ((VAR_1 = av_read_frame(movie->format_ctx, &pkt)) >= 0) {",
"if (pkt.stream_index != movie->stream_index) {",
"av_free_packet(&pkt);",
"continue;",
"} else {",
"movie->pkt0 = movie->pkt = pkt;",
"break;",
"}",
"}",
"if (VAR_1 == AVERROR_EOF) {",
"movie->is_done = 1;",
"return VAR_1;",
"}",
"}",
"avcodec_get_frame_defaults(movie->frame);",
"VAR_1 = avcodec_decode_audio4(movie->codec_ctx, movie->frame, &VAR_2, &movie->pkt);",
"if (VAR_1 < 0) {",
"movie->pkt.size = 0;",
"return VAR_1;",
"}",
"movie->pkt.data += VAR_1;",
"movie->pkt.size -= VAR_1;",
"if (VAR_2) {",
"int VAR_3 = movie->frame->VAR_3;",
"int VAR_4 =\nav_samples_get_buffer_size(NULL, movie->codec_ctx->channels,\nVAR_3, movie->codec_ctx->sample_fmt, 1);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"movie->samplesref =\nff_get_audio_buffer(VAR_0, AV_PERM_WRITE, VAR_3);",
"memcpy(movie->samplesref->data[0], movie->frame->data[0], VAR_4);",
"movie->samplesref->pts = movie->pkt.pts;",
"movie->samplesref->pos = movie->pkt.pos;",
"movie->samplesref->audio->sample_rate = movie->codec_ctx->sample_rate;",
"}",
"if (movie->pkt.size <= 0)\nav_free_packet(&movie->pkt0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83,
85,
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111,
113
],
[
117
],
[
119
]
] |
24,435 | static int h264_init_context(AVCodecContext *avctx, H264Context *h)
{
int i;
h->avctx = avctx;
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
h->workaround_bugs = avctx->workaround_bugs;
h->flags = avctx->flags;
h->prev_poc_msb = 1 << 16;
h->x264_build = -1;
h->recovery_frame = -1;
h->frame_recovered = 0;
h->next_outputed_poc = INT_MIN;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
ff_h264_reset_sei(h);
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
h->DPB[i].f = av_frame_alloc();
if (!h->DPB[i].f)
return AVERROR(ENOMEM);
}
h->cur_pic.f = av_frame_alloc();
if (!h->cur_pic.f)
return AVERROR(ENOMEM);
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].h264 = h;
return 0;
}
| false | FFmpeg | c8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8 | static int h264_init_context(AVCodecContext *avctx, H264Context *h)
{
int i;
h->avctx = avctx;
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
h->workaround_bugs = avctx->workaround_bugs;
h->flags = avctx->flags;
h->prev_poc_msb = 1 << 16;
h->x264_build = -1;
h->recovery_frame = -1;
h->frame_recovered = 0;
h->next_outputed_poc = INT_MIN;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
ff_h264_reset_sei(h);
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
h->DPB[i].f = av_frame_alloc();
if (!h->DPB[i].f)
return AVERROR(ENOMEM);
}
h->cur_pic.f = av_frame_alloc();
if (!h->cur_pic.f)
return AVERROR(ENOMEM);
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].h264 = h;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, H264Context *VAR_1)
{
int VAR_2;
VAR_1->VAR_0 = VAR_0;
VAR_1->picture_structure = PICT_FRAME;
VAR_1->slice_context_count = 1;
VAR_1->workaround_bugs = VAR_0->workaround_bugs;
VAR_1->flags = VAR_0->flags;
VAR_1->prev_poc_msb = 1 << 16;
VAR_1->x264_build = -1;
VAR_1->recovery_frame = -1;
VAR_1->frame_recovered = 0;
VAR_1->next_outputed_poc = INT_MIN;
for (VAR_2 = 0; VAR_2 < MAX_DELAYED_PIC_COUNT; VAR_2++)
VAR_1->last_pocs[VAR_2] = INT_MIN;
ff_h264_reset_sei(VAR_1);
VAR_0->chroma_sample_location = AVCHROMA_LOC_LEFT;
VAR_1->nb_slice_ctx = (VAR_0->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
VAR_1->slice_ctx = av_mallocz_array(VAR_1->nb_slice_ctx, sizeof(*VAR_1->slice_ctx));
if (!VAR_1->slice_ctx) {
VAR_1->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (VAR_2 = 0; VAR_2 < H264_MAX_PICTURE_COUNT; VAR_2++) {
VAR_1->DPB[VAR_2].f = av_frame_alloc();
if (!VAR_1->DPB[VAR_2].f)
return AVERROR(ENOMEM);
}
VAR_1->cur_pic.f = av_frame_alloc();
if (!VAR_1->cur_pic.f)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < VAR_1->nb_slice_ctx; VAR_2++)
VAR_1->slice_ctx[VAR_2].h264 = VAR_1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, H264Context *VAR_1)\n{",
"int VAR_2;",
"VAR_1->VAR_0 = VAR_0;",
"VAR_1->picture_structure = PICT_FRAME;",
"VAR_1->slice_context_count = 1;",
"VAR_1->workaround_bugs = VAR_0->workaround_bugs;",
"VAR_1->flags = VAR_0->flags;",
"VAR_1->prev_poc_msb = 1 << 16;",
"VAR_1->x264_build = -1;",
"VAR_1->recovery_frame = -1;",
"VAR_1->frame_recovered = 0;",
"VAR_1->next_outputed_poc = INT_MIN;",
"for (VAR_2 = 0; VAR_2 < MAX_DELAYED_PIC_COUNT; VAR_2++)",
"VAR_1->last_pocs[VAR_2] = INT_MIN;",
"ff_h264_reset_sei(VAR_1);",
"VAR_0->chroma_sample_location = AVCHROMA_LOC_LEFT;",
"VAR_1->nb_slice_ctx = (VAR_0->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;",
"VAR_1->slice_ctx = av_mallocz_array(VAR_1->nb_slice_ctx, sizeof(*VAR_1->slice_ctx));",
"if (!VAR_1->slice_ctx) {",
"VAR_1->nb_slice_ctx = 0;",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_2 = 0; VAR_2 < H264_MAX_PICTURE_COUNT; VAR_2++) {",
"VAR_1->DPB[VAR_2].f = av_frame_alloc();",
"if (!VAR_1->DPB[VAR_2].f)\nreturn AVERROR(ENOMEM);",
"}",
"VAR_1->cur_pic.f = av_frame_alloc();",
"if (!VAR_1->cur_pic.f)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < VAR_1->nb_slice_ctx; VAR_2++)",
"VAR_1->slice_ctx[VAR_2].h264 = VAR_1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
73
],
[
75,
77
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
24,436 | static uint32_t nvic_readl(NVICState *s, uint32_t offset)
{
ARMCPU *cpu = s->cpu;
uint32_t val;
switch (offset) {
case 4: /* Interrupt Control Type. */
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
case 0xd00: /* CPUID Base. */
return cpu->midr;
case 0xd04: /* Interrupt Control State. */
/* VECTACTIVE */
val = cpu->env.v7m.exception;
/* VECTPENDING */
val |= (s->vectpending & 0xff) << 12;
/* ISRPENDING - set if any external IRQ is pending */
if (nvic_isrpending(s)) {
val |= (1 << 22);
}
/* RETTOBASE - set if only one handler is active */
if (nvic_rettobase(s)) {
val |= (1 << 11);
}
/* PENDSTSET */
if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
val |= (1 << 26);
}
/* PENDSVSET */
if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
val |= (1 << 28);
}
/* NMIPENDSET */
if (s->vectors[ARMV7M_EXCP_NMI].pending) {
val |= (1 << 31);
}
/* ISRPREEMPT not implemented */
return val;
case 0xd08: /* Vector Table Offset. */
return cpu->env.v7m.vecbase;
case 0xd0c: /* Application Interrupt/Reset Control. */
return 0xfa050000 | (s->prigroup << 8);
case 0xd10: /* System Control. */
/* TODO: Implement SLEEPONEXIT. */
return 0;
case 0xd14: /* Configuration Control. */
return cpu->env.v7m.ccr;
case 0xd24: /* System Handler Status. */
val = 0;
if (s->vectors[ARMV7M_EXCP_MEM].active) {
val |= (1 << 0);
}
if (s->vectors[ARMV7M_EXCP_BUS].active) {
val |= (1 << 1);
}
if (s->vectors[ARMV7M_EXCP_USAGE].active) {
val |= (1 << 3);
}
if (s->vectors[ARMV7M_EXCP_SVC].active) {
val |= (1 << 7);
}
if (s->vectors[ARMV7M_EXCP_DEBUG].active) {
val |= (1 << 8);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
val |= (1 << 10);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
val |= (1 << 12);
}
if (s->vectors[ARMV7M_EXCP_MEM].pending) {
val |= (1 << 13);
}
if (s->vectors[ARMV7M_EXCP_BUS].pending) {
val |= (1 << 14);
}
if (s->vectors[ARMV7M_EXCP_SVC].pending) {
val |= (1 << 15);
}
if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
val |= (1 << 16);
}
if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
val |= (1 << 17);
}
if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
val |= (1 << 18);
}
return val;
case 0xd28: /* Configurable Fault Status. */
return cpu->env.v7m.cfsr;
case 0xd2c: /* Hard Fault Status. */
return cpu->env.v7m.hfsr;
case 0xd30: /* Debug Fault Status. */
return cpu->env.v7m.dfsr;
case 0xd34: /* MMFAR MemManage Fault Address */
return cpu->env.v7m.mmfar;
case 0xd38: /* Bus Fault Address. */
return cpu->env.v7m.bfar;
case 0xd3c: /* Aux Fault Status. */
/* TODO: Implement fault status registers. */
qemu_log_mask(LOG_UNIMP,
"Aux Fault status registers unimplemented\n");
return 0;
case 0xd40: /* PFR0. */
return 0x00000030;
case 0xd44: /* PRF1. */
return 0x00000200;
case 0xd48: /* DFR0. */
return 0x00100000;
case 0xd4c: /* AFR0. */
return 0x00000000;
case 0xd50: /* MMFR0. */
return 0x00000030;
case 0xd54: /* MMFR1. */
return 0x00000000;
case 0xd58: /* MMFR2. */
return 0x00000000;
case 0xd5c: /* MMFR3. */
return 0x00000000;
case 0xd60: /* ISAR0. */
return 0x01141110;
case 0xd64: /* ISAR1. */
return 0x02111000;
case 0xd68: /* ISAR2. */
return 0x21112231;
case 0xd6c: /* ISAR3. */
return 0x01111110;
case 0xd70: /* ISAR4. */
return 0x01310102;
/* TODO: Implement debug registers. */
case 0xd90: /* MPU_TYPE */
/* Unified MPU; if the MPU is not present this value is zero */
return cpu->pmsav7_dregion << 8;
break;
case 0xd94: /* MPU_CTRL */
return cpu->env.v7m.mpu_ctrl;
case 0xd98: /* MPU_RNR */
return cpu->env.pmsav7.rnr;
case 0xd9c: /* MPU_RBAR */
case 0xda4: /* MPU_RBAR_A1 */
case 0xdac: /* MPU_RBAR_A2 */
case 0xdb4: /* MPU_RBAR_A3 */
{
int region = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
/* PMSAv8M handling of the aliases is different from v7M:
* aliases A1, A2, A3 override the low two bits of the region
* number in MPU_RNR, and there is no 'region' field in the
* RBAR register.
*/
int aliasno = (offset - 0xd9c) / 8; /* 0..3 */
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rbar[region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf);
}
case 0xda0: /* MPU_RASR (v7M), MPU_RLAR (v8M) */
case 0xda8: /* MPU_RASR_A1 (v7M), MPU_RLAR_A1 (v8M) */
case 0xdb0: /* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) */
case 0xdb8: /* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) */
{
int region = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
/* PMSAv8M handling of the aliases is different from v7M:
* aliases A1, A2, A3 override the low two bits of the region
* number in MPU_RNR.
*/
int aliasno = (offset - 0xda0) / 8; /* 0..3 */
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rlar[region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) |
(cpu->env.pmsav7.drsr[region] & 0xffff);
}
case 0xdc0: /* MPU_MAIR0 */
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair0;
case 0xdc4: /* MPU_MAIR1 */
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair1;
default:
bad_offset:
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
return 0;
}
}
| false | qemu | 45db7ba681ede57113a67499840e69ee586bcdf2 | static uint32_t nvic_readl(NVICState *s, uint32_t offset)
{
ARMCPU *cpu = s->cpu;
uint32_t val;
switch (offset) {
case 4:
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
case 0xd00:
return cpu->midr;
case 0xd04:
val = cpu->env.v7m.exception;
val |= (s->vectpending & 0xff) << 12;
if (nvic_isrpending(s)) {
val |= (1 << 22);
}
if (nvic_rettobase(s)) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
val |= (1 << 26);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
val |= (1 << 28);
}
if (s->vectors[ARMV7M_EXCP_NMI].pending) {
val |= (1 << 31);
}
return val;
case 0xd08:
return cpu->env.v7m.vecbase;
case 0xd0c:
return 0xfa050000 | (s->prigroup << 8);
case 0xd10:
return 0;
case 0xd14:
return cpu->env.v7m.ccr;
case 0xd24:
val = 0;
if (s->vectors[ARMV7M_EXCP_MEM].active) {
val |= (1 << 0);
}
if (s->vectors[ARMV7M_EXCP_BUS].active) {
val |= (1 << 1);
}
if (s->vectors[ARMV7M_EXCP_USAGE].active) {
val |= (1 << 3);
}
if (s->vectors[ARMV7M_EXCP_SVC].active) {
val |= (1 << 7);
}
if (s->vectors[ARMV7M_EXCP_DEBUG].active) {
val |= (1 << 8);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
val |= (1 << 10);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
val |= (1 << 12);
}
if (s->vectors[ARMV7M_EXCP_MEM].pending) {
val |= (1 << 13);
}
if (s->vectors[ARMV7M_EXCP_BUS].pending) {
val |= (1 << 14);
}
if (s->vectors[ARMV7M_EXCP_SVC].pending) {
val |= (1 << 15);
}
if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
val |= (1 << 16);
}
if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
val |= (1 << 17);
}
if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
val |= (1 << 18);
}
return val;
case 0xd28:
return cpu->env.v7m.cfsr;
case 0xd2c:
return cpu->env.v7m.hfsr;
case 0xd30:
return cpu->env.v7m.dfsr;
case 0xd34:
return cpu->env.v7m.mmfar;
case 0xd38:
return cpu->env.v7m.bfar;
case 0xd3c:
qemu_log_mask(LOG_UNIMP,
"Aux Fault status registers unimplemented\n");
return 0;
case 0xd40:
return 0x00000030;
case 0xd44:
return 0x00000200;
case 0xd48:
return 0x00100000;
case 0xd4c:
return 0x00000000;
case 0xd50:
return 0x00000030;
case 0xd54:
return 0x00000000;
case 0xd58:
return 0x00000000;
case 0xd5c:
return 0x00000000;
case 0xd60:
return 0x01141110;
case 0xd64:
return 0x02111000;
case 0xd68:
return 0x21112231;
case 0xd6c:
return 0x01111110;
case 0xd70:
return 0x01310102;
case 0xd90:
return cpu->pmsav7_dregion << 8;
break;
case 0xd94:
return cpu->env.v7m.mpu_ctrl;
case 0xd98:
return cpu->env.pmsav7.rnr;
case 0xd9c:
case 0xda4:
case 0xdac:
case 0xdb4:
{
int region = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xd9c) / 8;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rbar[region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf);
}
case 0xda0:
case 0xda8:
case 0xdb0:
case 0xdb8:
{
int region = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xda0) / 8;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rlar[region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) |
(cpu->env.pmsav7.drsr[region] & 0xffff);
}
case 0xdc0:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair0;
case 0xdc4:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair1;
default:
bad_offset:
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
return 0;
}
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(NVICState *s, uint32_t offset)
{
ARMCPU *cpu = s->cpu;
uint32_t val;
switch (offset) {
case 4:
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
case 0xd00:
return cpu->midr;
case 0xd04:
val = cpu->env.v7m.exception;
val |= (s->vectpending & 0xff) << 12;
if (nvic_isrpending(s)) {
val |= (1 << 22);
}
if (nvic_rettobase(s)) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
val |= (1 << 26);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
val |= (1 << 28);
}
if (s->vectors[ARMV7M_EXCP_NMI].pending) {
val |= (1 << 31);
}
return val;
case 0xd08:
return cpu->env.v7m.vecbase;
case 0xd0c:
return 0xfa050000 | (s->prigroup << 8);
case 0xd10:
return 0;
case 0xd14:
return cpu->env.v7m.ccr;
case 0xd24:
val = 0;
if (s->vectors[ARMV7M_EXCP_MEM].active) {
val |= (1 << 0);
}
if (s->vectors[ARMV7M_EXCP_BUS].active) {
val |= (1 << 1);
}
if (s->vectors[ARMV7M_EXCP_USAGE].active) {
val |= (1 << 3);
}
if (s->vectors[ARMV7M_EXCP_SVC].active) {
val |= (1 << 7);
}
if (s->vectors[ARMV7M_EXCP_DEBUG].active) {
val |= (1 << 8);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
val |= (1 << 10);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
val |= (1 << 12);
}
if (s->vectors[ARMV7M_EXCP_MEM].pending) {
val |= (1 << 13);
}
if (s->vectors[ARMV7M_EXCP_BUS].pending) {
val |= (1 << 14);
}
if (s->vectors[ARMV7M_EXCP_SVC].pending) {
val |= (1 << 15);
}
if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
val |= (1 << 16);
}
if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
val |= (1 << 17);
}
if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
val |= (1 << 18);
}
return val;
case 0xd28:
return cpu->env.v7m.cfsr;
case 0xd2c:
return cpu->env.v7m.hfsr;
case 0xd30:
return cpu->env.v7m.dfsr;
case 0xd34:
return cpu->env.v7m.mmfar;
case 0xd38:
return cpu->env.v7m.bfar;
case 0xd3c:
qemu_log_mask(LOG_UNIMP,
"Aux Fault status registers unimplemented\n");
return 0;
case 0xd40:
return 0x00000030;
case 0xd44:
return 0x00000200;
case 0xd48:
return 0x00100000;
case 0xd4c:
return 0x00000000;
case 0xd50:
return 0x00000030;
case 0xd54:
return 0x00000000;
case 0xd58:
return 0x00000000;
case 0xd5c:
return 0x00000000;
case 0xd60:
return 0x01141110;
case 0xd64:
return 0x02111000;
case 0xd68:
return 0x21112231;
case 0xd6c:
return 0x01111110;
case 0xd70:
return 0x01310102;
case 0xd90:
return cpu->pmsav7_dregion << 8;
break;
case 0xd94:
return cpu->env.v7m.mpu_ctrl;
case 0xd98:
return cpu->env.pmsav7.rnr;
case 0xd9c:
case 0xda4:
case 0xdac:
case 0xdb4:
{
int VAR_2 = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int VAR_2 = (offset - 0xd9c) / 8;
if (VAR_2) {
VAR_2 = deposit32(VAR_2, 0, 2, VAR_2);
}
if (VAR_2 >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rbar[VAR_2];
}
if (VAR_2 >= cpu->pmsav7_dregion) {
return 0;
}
return (cpu->env.pmsav7.drbar[VAR_2] & 0x1f) | (VAR_2 & 0xf);
}
case 0xda0:
case 0xda8:
case 0xdb0:
case 0xdb8:
{
int VAR_2 = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int VAR_2 = (offset - 0xda0) / 8;
if (VAR_2) {
VAR_2 = deposit32(VAR_2, 0, 2, VAR_2);
}
if (VAR_2 >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rlar[VAR_2];
}
if (VAR_2 >= cpu->pmsav7_dregion) {
return 0;
}
return ((cpu->env.pmsav7.dracr[VAR_2] & 0xffff) << 16) |
(cpu->env.pmsav7.drsr[VAR_2] & 0xffff);
}
case 0xdc0:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair0;
case 0xdc4:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair1;
default:
bad_offset:
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
return 0;
}
}
| [
"static uint32_t FUNC_0(NVICState *s, uint32_t offset)\n{",
"ARMCPU *cpu = s->cpu;",
"uint32_t val;",
"switch (offset) {",
"case 4:\nreturn ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;",
"case 0xd00:\nreturn cpu->midr;",
"case 0xd04:\nval = cpu->env.v7m.exception;",
"val |= (s->vectpending & 0xff) << 12;",
"if (nvic_isrpending(s)) {",
"val |= (1 << 22);",
"}",
"if (nvic_rettobase(s)) {",
"val |= (1 << 11);",
"}",
"if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {",
"val |= (1 << 26);",
"}",
"if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {",
"val |= (1 << 28);",
"}",
"if (s->vectors[ARMV7M_EXCP_NMI].pending) {",
"val |= (1 << 31);",
"}",
"return val;",
"case 0xd08:\nreturn cpu->env.v7m.vecbase;",
"case 0xd0c:\nreturn 0xfa050000 | (s->prigroup << 8);",
"case 0xd10:\nreturn 0;",
"case 0xd14:\nreturn cpu->env.v7m.ccr;",
"case 0xd24:\nval = 0;",
"if (s->vectors[ARMV7M_EXCP_MEM].active) {",
"val |= (1 << 0);",
"}",
"if (s->vectors[ARMV7M_EXCP_BUS].active) {",
"val |= (1 << 1);",
"}",
"if (s->vectors[ARMV7M_EXCP_USAGE].active) {",
"val |= (1 << 3);",
"}",
"if (s->vectors[ARMV7M_EXCP_SVC].active) {",
"val |= (1 << 7);",
"}",
"if (s->vectors[ARMV7M_EXCP_DEBUG].active) {",
"val |= (1 << 8);",
"}",
"if (s->vectors[ARMV7M_EXCP_PENDSV].active) {",
"val |= (1 << 10);",
"}",
"if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {",
"val |= (1 << 11);",
"}",
"if (s->vectors[ARMV7M_EXCP_USAGE].pending) {",
"val |= (1 << 12);",
"}",
"if (s->vectors[ARMV7M_EXCP_MEM].pending) {",
"val |= (1 << 13);",
"}",
"if (s->vectors[ARMV7M_EXCP_BUS].pending) {",
"val |= (1 << 14);",
"}",
"if (s->vectors[ARMV7M_EXCP_SVC].pending) {",
"val |= (1 << 15);",
"}",
"if (s->vectors[ARMV7M_EXCP_MEM].enabled) {",
"val |= (1 << 16);",
"}",
"if (s->vectors[ARMV7M_EXCP_BUS].enabled) {",
"val |= (1 << 17);",
"}",
"if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {",
"val |= (1 << 18);",
"}",
"return val;",
"case 0xd28:\nreturn cpu->env.v7m.cfsr;",
"case 0xd2c:\nreturn cpu->env.v7m.hfsr;",
"case 0xd30:\nreturn cpu->env.v7m.dfsr;",
"case 0xd34:\nreturn cpu->env.v7m.mmfar;",
"case 0xd38:\nreturn cpu->env.v7m.bfar;",
"case 0xd3c:\nqemu_log_mask(LOG_UNIMP,\n\"Aux Fault status registers unimplemented\\n\");",
"return 0;",
"case 0xd40:\nreturn 0x00000030;",
"case 0xd44:\nreturn 0x00000200;",
"case 0xd48:\nreturn 0x00100000;",
"case 0xd4c:\nreturn 0x00000000;",
"case 0xd50:\nreturn 0x00000030;",
"case 0xd54:\nreturn 0x00000000;",
"case 0xd58:\nreturn 0x00000000;",
"case 0xd5c:\nreturn 0x00000000;",
"case 0xd60:\nreturn 0x01141110;",
"case 0xd64:\nreturn 0x02111000;",
"case 0xd68:\nreturn 0x21112231;",
"case 0xd6c:\nreturn 0x01111110;",
"case 0xd70:\nreturn 0x01310102;",
"case 0xd90:\nreturn cpu->pmsav7_dregion << 8;",
"break;",
"case 0xd94:\nreturn cpu->env.v7m.mpu_ctrl;",
"case 0xd98:\nreturn cpu->env.pmsav7.rnr;",
"case 0xd9c:\ncase 0xda4:\ncase 0xdac:\ncase 0xdb4:\n{",
"int VAR_2 = cpu->env.pmsav7.rnr;",
"if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {",
"int VAR_2 = (offset - 0xd9c) / 8;",
"if (VAR_2) {",
"VAR_2 = deposit32(VAR_2, 0, 2, VAR_2);",
"}",
"if (VAR_2 >= cpu->pmsav7_dregion) {",
"return 0;",
"}",
"return cpu->env.pmsav8.rbar[VAR_2];",
"}",
"if (VAR_2 >= cpu->pmsav7_dregion) {",
"return 0;",
"}",
"return (cpu->env.pmsav7.drbar[VAR_2] & 0x1f) | (VAR_2 & 0xf);",
"}",
"case 0xda0:\ncase 0xda8:\ncase 0xdb0:\ncase 0xdb8:\n{",
"int VAR_2 = cpu->env.pmsav7.rnr;",
"if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {",
"int VAR_2 = (offset - 0xda0) / 8;",
"if (VAR_2) {",
"VAR_2 = deposit32(VAR_2, 0, 2, VAR_2);",
"}",
"if (VAR_2 >= cpu->pmsav7_dregion) {",
"return 0;",
"}",
"return cpu->env.pmsav8.rlar[VAR_2];",
"}",
"if (VAR_2 >= cpu->pmsav7_dregion) {",
"return 0;",
"}",
"return ((cpu->env.pmsav7.dracr[VAR_2] & 0xffff) << 16) |\n(cpu->env.pmsav7.drsr[VAR_2] & 0xffff);",
"}",
"case 0xdc0:\nif (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {",
"goto bad_offset;",
"}",
"return cpu->env.pmsav8.mair0;",
"case 0xdc4:\nif (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {",
"goto bad_offset;",
"}",
"return cpu->env.pmsav8.mair1;",
"default:\nbad_offset:\nqemu_log_mask(LOG_GUEST_ERROR, \"NVIC: Bad read offset 0x%x\\n\", offset);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21,
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83,
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,
207,
209
],
[
211
],
[
213,
215
],
[
217,
219
],
[
221,
223
],
[
225,
227
],
[
229,
231
],
[
233,
235
],
[
237,
239
],
[
241,
243
],
[
245,
247
],
[
249,
251
],
[
253,
255
],
[
257,
259
],
[
261,
263
],
[
267,
271
],
[
273
],
[
275,
277
],
[
279,
281
],
[
283,
285,
287,
289,
291
],
[
293
],
[
297
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341,
343,
345,
347
],
[
349
],
[
353
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
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
]
] |
24,437 | static void parse_cmdline(const char *cmdline,
int *pnb_args, char **args)
{
const char *p;
int nb_args, ret;
char buf[1024];
p = cmdline;
nb_args = 0;
for(;;) {
while (qemu_isspace(*p))
p++;
if (*p == '\0')
break;
if (nb_args >= MAX_ARGS)
break;
ret = get_str(buf, sizeof(buf), &p);
args[nb_args] = g_strdup(buf);
nb_args++;
if (ret < 0)
break;
}
*pnb_args = nb_args;
}
| false | qemu | f5438c0500bb22c97b30987d2e0eab953416c7c5 | static void parse_cmdline(const char *cmdline,
int *pnb_args, char **args)
{
const char *p;
int nb_args, ret;
char buf[1024];
p = cmdline;
nb_args = 0;
for(;;) {
while (qemu_isspace(*p))
p++;
if (*p == '\0')
break;
if (nb_args >= MAX_ARGS)
break;
ret = get_str(buf, sizeof(buf), &p);
args[nb_args] = g_strdup(buf);
nb_args++;
if (ret < 0)
break;
}
*pnb_args = nb_args;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0,
int *VAR_1, char **VAR_2)
{
const char *VAR_3;
int VAR_4, VAR_5;
char VAR_6[1024];
VAR_3 = VAR_0;
VAR_4 = 0;
for(;;) {
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_3 == '\0')
break;
if (VAR_4 >= MAX_ARGS)
break;
VAR_5 = get_str(VAR_6, sizeof(VAR_6), &VAR_3);
VAR_2[VAR_4] = g_strdup(VAR_6);
VAR_4++;
if (VAR_5 < 0)
break;
}
*VAR_1 = VAR_4;
}
| [
"static void FUNC_0(const char *VAR_0,\nint *VAR_1, char **VAR_2)\n{",
"const char *VAR_3;",
"int VAR_4, VAR_5;",
"char VAR_6[1024];",
"VAR_3 = VAR_0;",
"VAR_4 = 0;",
"for(;;) {",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_3 == '\\0')\nbreak;",
"if (VAR_4 >= MAX_ARGS)\nbreak;",
"VAR_5 = get_str(VAR_6, sizeof(VAR_6), &VAR_3);",
"VAR_2[VAR_4] = g_strdup(VAR_6);",
"VAR_4++;",
"if (VAR_5 < 0)\nbreak;",
"}",
"*VAR_1 = VAR_4;",
"}"
] | [
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
]
] |
24,438 | void portio_list_destroy(PortioList *piolist)
{
g_free(piolist->regions);
g_free(piolist->aliases);
}
| false | qemu | b40acf99bef69fa8ab0f9092ff162fde945eec12 | void portio_list_destroy(PortioList *piolist)
{
g_free(piolist->regions);
g_free(piolist->aliases);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PortioList *VAR_0)
{
g_free(VAR_0->regions);
g_free(VAR_0->aliases);
}
| [
"void FUNC_0(PortioList *VAR_0)\n{",
"g_free(VAR_0->regions);",
"g_free(VAR_0->aliases);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,439 | INLINE flag extractFloat32Sign( float32 a )
{
return a>>31;
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | INLINE flag extractFloat32Sign( float32 a )
{
return a>>31;
}
| {
"code": [],
"line_no": []
} | INLINE VAR_0 extractFloat32Sign( float32 a )
{
return a>>31;
}
| [
"INLINE VAR_0 extractFloat32Sign( float32 a )\n{",
"return a>>31;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11
]
] |
24,440 | static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
int retval;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
retval = v9fs_request(fs_ctx->private, T_MKNOD, NULL, "sdqdd",
&fullname, credp->fc_mode, credp->fc_rdev,
credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (retval < 0) {
errno = -retval;
retval = -1;
}
return retval;
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
int retval;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
retval = v9fs_request(fs_ctx->private, T_MKNOD, NULL, "sdqdd",
&fullname, credp->fc_mode, credp->fc_rdev,
credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (retval < 0) {
errno = -retval;
retval = -1;
}
return retval;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{
int VAR_4;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", VAR_1->data, VAR_2);
VAR_4 = v9fs_request(VAR_0->private, T_MKNOD, NULL, "sdqdd",
&fullname, VAR_3->fc_mode, VAR_3->fc_rdev,
VAR_3->fc_uid, VAR_3->fc_gid);
v9fs_string_free(&fullname);
if (VAR_4 < 0) {
errno = -VAR_4;
VAR_4 = -1;
}
return VAR_4;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, FsCred *VAR_3)\n{",
"int VAR_4;",
"V9fsString fullname;",
"v9fs_string_init(&fullname);",
"v9fs_string_sprintf(&fullname, \"%s/%s\", VAR_1->data, VAR_2);",
"VAR_4 = v9fs_request(VAR_0->private, T_MKNOD, NULL, \"sdqdd\",\n&fullname, VAR_3->fc_mode, VAR_3->fc_rdev,\nVAR_3->fc_uid, VAR_3->fc_gid);",
"v9fs_string_free(&fullname);",
"if (VAR_4 < 0) {",
"errno = -VAR_4;",
"VAR_4 = -1;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
24,441 | static bool memory_region_get_may_overlap(Object *obj, Error **errp)
{
MemoryRegion *mr = MEMORY_REGION(obj);
return mr->may_overlap;
}
| false | qemu | b61359781958759317ee6fd1a45b59be0b7dbbe1 | static bool memory_region_get_may_overlap(Object *obj, Error **errp)
{
MemoryRegion *mr = MEMORY_REGION(obj);
return mr->may_overlap;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(Object *obj, Error **errp)
{
MemoryRegion *mr = MEMORY_REGION(obj);
return mr->may_overlap;
}
| [
"static bool FUNC_0(Object *obj, Error **errp)\n{",
"MemoryRegion *mr = MEMORY_REGION(obj);",
"return mr->may_overlap;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
24,443 | static void DBDMA_run (DBDMA_channel *ch)
{
int channel;
for (channel = 0; channel < DBDMA_CHANNELS; channel++, ch++) {
uint32_t status = be32_to_cpu(ch->regs[DBDMA_STATUS]);
if (!ch->processing && (status & RUN) && (status & ACTIVE))
channel_run(ch);
}
}
| false | qemu | ad674e53b5cce265fadafbde2c6a4f190345cd00 | static void DBDMA_run (DBDMA_channel *ch)
{
int channel;
for (channel = 0; channel < DBDMA_CHANNELS; channel++, ch++) {
uint32_t status = be32_to_cpu(ch->regs[DBDMA_STATUS]);
if (!ch->processing && (status & RUN) && (status & ACTIVE))
channel_run(ch);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (DBDMA_channel *VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < DBDMA_CHANNELS; VAR_1++, VAR_0++) {
uint32_t status = be32_to_cpu(VAR_0->regs[DBDMA_STATUS]);
if (!VAR_0->processing && (status & RUN) && (status & ACTIVE))
channel_run(VAR_0);
}
}
| [
"static void FUNC_0 (DBDMA_channel *VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < DBDMA_CHANNELS; VAR_1++, VAR_0++) {",
"uint32_t status = be32_to_cpu(VAR_0->regs[DBDMA_STATUS]);",
"if (!VAR_0->processing && (status & RUN) && (status & ACTIVE))\nchannel_run(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
]
] |
24,444 | void helper_fstoq(CPUSPARCState *env, float32 src)
{
clear_float_exceptions(env);
QT0 = float32_to_float128(src, &env->fp_status);
check_ieee_exceptions(env);
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | void helper_fstoq(CPUSPARCState *env, float32 src)
{
clear_float_exceptions(env);
QT0 = float32_to_float128(src, &env->fp_status);
check_ieee_exceptions(env);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUSPARCState *VAR_0, float32 VAR_1)
{
clear_float_exceptions(VAR_0);
QT0 = float32_to_float128(VAR_1, &VAR_0->fp_status);
check_ieee_exceptions(VAR_0);
}
| [
"void FUNC_0(CPUSPARCState *VAR_0, float32 VAR_1)\n{",
"clear_float_exceptions(VAR_0);",
"QT0 = float32_to_float128(VAR_1, &VAR_0->fp_status);",
"check_ieee_exceptions(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
24,445 | static void process_incoming_migration_bh(void *opaque)
{
Error *local_err = NULL;
MigrationIncomingState *mis = opaque;
/* Make sure all file formats flush their mutable metadata.
* If we get an error here, just don't restart the VM yet. */
bdrv_invalidate_cache_all(&local_err);
if (!local_err) {
blk_resume_after_migration(&local_err);
}
if (local_err) {
error_report_err(local_err);
local_err = NULL;
autostart = false;
}
/*
* This must happen after all error conditions are dealt with and
* we're sure the VM is going to be running on this host.
*/
qemu_announce_self();
/* If global state section was not received or we are in running
state, we need to obey autostart. Any other state is set with
runstate_set. */
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
/*
* This must happen after any state changes since as soon as an external
* observer sees this event they might start to prod at the VM assuming
* it's ready to use.
*/
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COMPLETED);
qemu_bh_delete(mis->bh);
migration_incoming_state_destroy();
}
| false | qemu | 4417ab7adf1613799054be5afedf810fc2524ee8 | static void process_incoming_migration_bh(void *opaque)
{
Error *local_err = NULL;
MigrationIncomingState *mis = opaque;
bdrv_invalidate_cache_all(&local_err);
if (!local_err) {
blk_resume_after_migration(&local_err);
}
if (local_err) {
error_report_err(local_err);
local_err = NULL;
autostart = false;
}
qemu_announce_self();
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COMPLETED);
qemu_bh_delete(mis->bh);
migration_incoming_state_destroy();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
Error *local_err = NULL;
MigrationIncomingState *mis = VAR_0;
bdrv_invalidate_cache_all(&local_err);
if (!local_err) {
blk_resume_after_migration(&local_err);
}
if (local_err) {
error_report_err(local_err);
local_err = NULL;
autostart = false;
}
qemu_announce_self();
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COMPLETED);
qemu_bh_delete(mis->bh);
migration_incoming_state_destroy();
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"Error *local_err = NULL;",
"MigrationIncomingState *mis = VAR_0;",
"bdrv_invalidate_cache_all(&local_err);",
"if (!local_err) {",
"blk_resume_after_migration(&local_err);",
"}",
"if (local_err) {",
"error_report_err(local_err);",
"local_err = NULL;",
"autostart = false;",
"}",
"qemu_announce_self();",
"if (!global_state_received() ||\nglobal_state_get_runstate() == RUN_STATE_RUNNING) {",
"if (autostart) {",
"vm_start();",
"} else {",
"runstate_set(RUN_STATE_PAUSED);",
"}",
"} else {",
"runstate_set(global_state_get_runstate());",
"}",
"migrate_decompress_threads_join();",
"migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,\nMIGRATION_STATUS_COMPLETED);",
"qemu_bh_delete(mis->bh);",
"migration_incoming_state_destroy();",
"}"
] | [
0,
0,
0,
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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
43
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
87,
89
],
[
91
],
[
93
],
[
95
]
] |
24,446 | int float64_lt_quiet( float64 a, float64 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
|| ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
) {
if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
float_raise( float_flag_invalid STATUS_VAR);
}
return 0;
}
aSign = extractFloat64Sign( a );
bSign = extractFloat64Sign( b );
if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
return ( a != b ) && ( aSign ^ ( a < b ) );
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | int float64_lt_quiet( float64 a, float64 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
|| ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
) {
if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
float_raise( float_flag_invalid STATUS_VAR);
}
return 0;
}
aSign = extractFloat64Sign( a );
bSign = extractFloat64Sign( b );
if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
return ( a != b ) && ( aSign ^ ( a < b ) );
}
| {
"code": [],
"line_no": []
} | int FUNC_0( float64 VAR_0, float64 VAR_1 STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat64Exp( VAR_0 ) == 0x7FF ) && extractFloat64Frac( VAR_0 ) )
|| ( ( extractFloat64Exp( VAR_1 ) == 0x7FF ) && extractFloat64Frac( VAR_1 ) )
) {
if ( float64_is_signaling_nan( VAR_0 ) || float64_is_signaling_nan( VAR_1 ) ) {
float_raise( float_flag_invalid STATUS_VAR);
}
return 0;
}
aSign = extractFloat64Sign( VAR_0 );
bSign = extractFloat64Sign( VAR_1 );
if ( aSign != bSign ) return aSign && ( (bits64) ( ( VAR_0 | VAR_1 )<<1 ) != 0 );
return ( VAR_0 != VAR_1 ) && ( aSign ^ ( VAR_0 < VAR_1 ) );
}
| [
"int FUNC_0( float64 VAR_0, float64 VAR_1 STATUS_PARAM )\n{",
"flag aSign, bSign;",
"if ( ( ( extractFloat64Exp( VAR_0 ) == 0x7FF ) && extractFloat64Frac( VAR_0 ) )\n|| ( ( extractFloat64Exp( VAR_1 ) == 0x7FF ) && extractFloat64Frac( VAR_1 ) )\n) {",
"if ( float64_is_signaling_nan( VAR_0 ) || float64_is_signaling_nan( VAR_1 ) ) {",
"float_raise( float_flag_invalid STATUS_VAR);",
"}",
"return 0;",
"}",
"aSign = extractFloat64Sign( VAR_0 );",
"bSign = extractFloat64Sign( VAR_1 );",
"if ( aSign != bSign ) return aSign && ( (bits64) ( ( VAR_0 | VAR_1 )<<1 ) != 0 );",
"return ( VAR_0 != VAR_1 ) && ( aSign ^ ( VAR_0 < VAR_1 ) );",
"}"
] | [
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
],
[
35
]
] |
24,447 | static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
QEMUMachine *qm = data;
mc->name = qm->name;
mc->desc = qm->desc;
mc->init = qm->init;
mc->kvm_type = qm->kvm_type;
mc->block_default_type = qm->block_default_type;
mc->max_cpus = qm->max_cpus;
mc->no_sdcard = qm->no_sdcard;
mc->has_dynamic_sysbus = qm->has_dynamic_sysbus;
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
}
| false | qemu | 076b35b5a56bca57c4aa41044ed304fe9c45d6c5 | static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
QEMUMachine *qm = data;
mc->name = qm->name;
mc->desc = qm->desc;
mc->init = qm->init;
mc->kvm_type = qm->kvm_type;
mc->block_default_type = qm->block_default_type;
mc->max_cpus = qm->max_cpus;
mc->no_sdcard = qm->no_sdcard;
mc->has_dynamic_sysbus = qm->has_dynamic_sysbus;
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
MachineClass *mc = MACHINE_CLASS(VAR_0);
QEMUMachine *qm = VAR_1;
mc->name = qm->name;
mc->desc = qm->desc;
mc->init = qm->init;
mc->kvm_type = qm->kvm_type;
mc->block_default_type = qm->block_default_type;
mc->max_cpus = qm->max_cpus;
mc->no_sdcard = qm->no_sdcard;
mc->has_dynamic_sysbus = qm->has_dynamic_sysbus;
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"MachineClass *mc = MACHINE_CLASS(VAR_0);",
"QEMUMachine *qm = VAR_1;",
"mc->name = qm->name;",
"mc->desc = qm->desc;",
"mc->init = qm->init;",
"mc->kvm_type = qm->kvm_type;",
"mc->block_default_type = qm->block_default_type;",
"mc->max_cpus = qm->max_cpus;",
"mc->no_sdcard = qm->no_sdcard;",
"mc->has_dynamic_sysbus = qm->has_dynamic_sysbus;",
"mc->is_default = qm->is_default;",
"mc->default_machine_opts = qm->default_machine_opts;",
"mc->default_boot_order = qm->default_boot_order;",
"}"
] | [
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
]
] |
24,449 | int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
int virq;
MSIMessage msg = {0, 0};
if (dev) {
msg = pci_get_msi_message(dev, vector);
}
if (kvm_gsi_direct_mapping()) {
return kvm_arch_msi_data_to_gsi(msg.data);
}
if (!kvm_gsi_routing_enabled()) {
return -ENOSYS;
}
virq = kvm_irqchip_get_virq(s);
if (virq < 0) {
return virq;
}
kroute.gsi = virq;
kroute.type = KVM_IRQ_ROUTING_MSI;
kroute.flags = 0;
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
if (kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
kvm_irqchip_release_virq(s, virq);
return -EINVAL;
}
trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A",
vector, virq);
kvm_add_routing_entry(s, &kroute);
kvm_arch_add_msi_route_post(&kroute, vector, dev);
kvm_irqchip_commit_routes(s);
return virq;
}
| false | qemu | 88c725c78e87eecb061f882177c7a6a2ac1059ad | int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
int virq;
MSIMessage msg = {0, 0};
if (dev) {
msg = pci_get_msi_message(dev, vector);
}
if (kvm_gsi_direct_mapping()) {
return kvm_arch_msi_data_to_gsi(msg.data);
}
if (!kvm_gsi_routing_enabled()) {
return -ENOSYS;
}
virq = kvm_irqchip_get_virq(s);
if (virq < 0) {
return virq;
}
kroute.gsi = virq;
kroute.type = KVM_IRQ_ROUTING_MSI;
kroute.flags = 0;
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
if (kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
kvm_irqchip_release_virq(s, virq);
return -EINVAL;
}
trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A",
vector, virq);
kvm_add_routing_entry(s, &kroute);
kvm_arch_add_msi_route_post(&kroute, vector, dev);
kvm_irqchip_commit_routes(s);
return virq;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(KVMState *VAR_0, int VAR_1, PCIDevice *VAR_2)
{
struct kvm_irq_routing_entry VAR_3 = {};
int VAR_4;
MSIMessage msg = {0, 0};
if (VAR_2) {
msg = pci_get_msi_message(VAR_2, VAR_1);
}
if (kvm_gsi_direct_mapping()) {
return kvm_arch_msi_data_to_gsi(msg.data);
}
if (!kvm_gsi_routing_enabled()) {
return -ENOSYS;
}
VAR_4 = kvm_irqchip_get_virq(VAR_0);
if (VAR_4 < 0) {
return VAR_4;
}
VAR_3.gsi = VAR_4;
VAR_3.type = KVM_IRQ_ROUTING_MSI;
VAR_3.flags = 0;
VAR_3.u.msi.address_lo = (uint32_t)msg.address;
VAR_3.u.msi.address_hi = msg.address >> 32;
VAR_3.u.msi.data = le32_to_cpu(msg.data);
if (kvm_msi_devid_required()) {
VAR_3.flags = KVM_MSI_VALID_DEVID;
VAR_3.u.msi.devid = pci_requester_id(VAR_2);
}
if (kvm_arch_fixup_msi_route(&VAR_3, msg.address, msg.data, VAR_2)) {
kvm_irqchip_release_virq(VAR_0, VAR_4);
return -EINVAL;
}
trace_kvm_irqchip_add_msi_route(VAR_2 ? VAR_2->name : (char *)"N/A",
VAR_1, VAR_4);
kvm_add_routing_entry(VAR_0, &VAR_3);
kvm_arch_add_msi_route_post(&VAR_3, VAR_1, VAR_2);
kvm_irqchip_commit_routes(VAR_0);
return VAR_4;
}
| [
"int FUNC_0(KVMState *VAR_0, int VAR_1, PCIDevice *VAR_2)\n{",
"struct kvm_irq_routing_entry VAR_3 = {};",
"int VAR_4;",
"MSIMessage msg = {0, 0};",
"if (VAR_2) {",
"msg = pci_get_msi_message(VAR_2, VAR_1);",
"}",
"if (kvm_gsi_direct_mapping()) {",
"return kvm_arch_msi_data_to_gsi(msg.data);",
"}",
"if (!kvm_gsi_routing_enabled()) {",
"return -ENOSYS;",
"}",
"VAR_4 = kvm_irqchip_get_virq(VAR_0);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"VAR_3.gsi = VAR_4;",
"VAR_3.type = KVM_IRQ_ROUTING_MSI;",
"VAR_3.flags = 0;",
"VAR_3.u.msi.address_lo = (uint32_t)msg.address;",
"VAR_3.u.msi.address_hi = msg.address >> 32;",
"VAR_3.u.msi.data = le32_to_cpu(msg.data);",
"if (kvm_msi_devid_required()) {",
"VAR_3.flags = KVM_MSI_VALID_DEVID;",
"VAR_3.u.msi.devid = pci_requester_id(VAR_2);",
"}",
"if (kvm_arch_fixup_msi_route(&VAR_3, msg.address, msg.data, VAR_2)) {",
"kvm_irqchip_release_virq(VAR_0, VAR_4);",
"return -EINVAL;",
"}",
"trace_kvm_irqchip_add_msi_route(VAR_2 ? VAR_2->name : (char *)\"N/A\",\nVAR_1, VAR_4);",
"kvm_add_routing_entry(VAR_0, &VAR_3);",
"kvm_arch_add_msi_route_post(&VAR_3, VAR_1, VAR_2);",
"kvm_irqchip_commit_routes(VAR_0);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
24,450 | gen_intermediate_code_internal(TriCoreCPU *cpu, struct TranslationBlock *tb,
int search_pc)
{
CPUState *cs = CPU(cpu);
CPUTriCoreState *env = &cpu->env;
DisasContext ctx;
target_ulong pc_start;
int num_insns;
uint16_t *gen_opc_end;
if (search_pc) {
qemu_log("search pc %d\n", search_pc);
}
num_insns = 0;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.bstate = BS_NONE;
ctx.mem_idx = cpu_mmu_index(env);
tcg_clear_temp_count();
gen_tb_start();
while (ctx.bstate == BS_NONE) {
ctx.opcode = cpu_ldl_code(env, ctx.pc);
decode_opc(env, &ctx, 0);
num_insns++;
if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
if (singlestep) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
ctx.pc = ctx.next_pc;
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
printf("done_generating search pc\n");
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
if (tcg_check_temp_count()) {
printf("LEAK at %08x\n", env->PC);
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
}
| false | qemu | cd42d5b23691ad73edfd6dbcfc935a960a9c5a65 | gen_intermediate_code_internal(TriCoreCPU *cpu, struct TranslationBlock *tb,
int search_pc)
{
CPUState *cs = CPU(cpu);
CPUTriCoreState *env = &cpu->env;
DisasContext ctx;
target_ulong pc_start;
int num_insns;
uint16_t *gen_opc_end;
if (search_pc) {
qemu_log("search pc %d\n", search_pc);
}
num_insns = 0;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.bstate = BS_NONE;
ctx.mem_idx = cpu_mmu_index(env);
tcg_clear_temp_count();
gen_tb_start();
while (ctx.bstate == BS_NONE) {
ctx.opcode = cpu_ldl_code(env, ctx.pc);
decode_opc(env, &ctx, 0);
num_insns++;
if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
if (singlestep) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
ctx.pc = ctx.next_pc;
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
printf("done_generating search pc\n");
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
if (tcg_check_temp_count()) {
printf("LEAK at %08x\n", env->PC);
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
}
| {
"code": [],
"line_no": []
} | FUNC_0(TriCoreCPU *VAR_0, struct TranslationBlock *VAR_1,
int VAR_2)
{
CPUState *cs = CPU(VAR_0);
CPUTriCoreState *env = &VAR_0->env;
DisasContext ctx;
target_ulong pc_start;
int VAR_3;
uint16_t *gen_opc_end;
if (VAR_2) {
qemu_log("search pc %d\n", VAR_2);
}
VAR_3 = 0;
pc_start = VAR_1->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.VAR_1 = VAR_1;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.bstate = BS_NONE;
ctx.mem_idx = cpu_mmu_index(env);
tcg_clear_temp_count();
gen_tb_start();
while (ctx.bstate == BS_NONE) {
ctx.opcode = cpu_ldl_code(env, ctx.pc);
decode_opc(env, &ctx, 0);
VAR_3++;
if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
if (singlestep) {
gen_save_pc(ctx.next_pc);
tcg_gen_exit_tb(0);
break;
}
ctx.pc = ctx.next_pc;
}
gen_tb_end(VAR_1, VAR_3);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (VAR_2) {
printf("done_generating search pc\n");
} else {
VAR_1->size = ctx.pc - pc_start;
VAR_1->icount = VAR_3;
}
if (tcg_check_temp_count()) {
printf("LEAK at %08x\n", env->PC);
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
}
| [
"FUNC_0(TriCoreCPU *VAR_0, struct TranslationBlock *VAR_1,\nint VAR_2)\n{",
"CPUState *cs = CPU(VAR_0);",
"CPUTriCoreState *env = &VAR_0->env;",
"DisasContext ctx;",
"target_ulong pc_start;",
"int VAR_3;",
"uint16_t *gen_opc_end;",
"if (VAR_2) {",
"qemu_log(\"search pc %d\\n\", VAR_2);",
"}",
"VAR_3 = 0;",
"pc_start = VAR_1->pc;",
"gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;",
"ctx.pc = pc_start;",
"ctx.saved_pc = -1;",
"ctx.VAR_1 = VAR_1;",
"ctx.singlestep_enabled = cs->singlestep_enabled;",
"ctx.bstate = BS_NONE;",
"ctx.mem_idx = cpu_mmu_index(env);",
"tcg_clear_temp_count();",
"gen_tb_start();",
"while (ctx.bstate == BS_NONE) {",
"ctx.opcode = cpu_ldl_code(env, ctx.pc);",
"decode_opc(env, &ctx, 0);",
"VAR_3++;",
"if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {",
"gen_save_pc(ctx.next_pc);",
"tcg_gen_exit_tb(0);",
"break;",
"}",
"if (singlestep) {",
"gen_save_pc(ctx.next_pc);",
"tcg_gen_exit_tb(0);",
"break;",
"}",
"ctx.pc = ctx.next_pc;",
"}",
"gen_tb_end(VAR_1, VAR_3);",
"*tcg_ctx.gen_opc_ptr = INDEX_op_end;",
"if (VAR_2) {",
"printf(\"done_generating search pc\\n\");",
"} else {",
"VAR_1->size = ctx.pc - pc_start;",
"VAR_1->icount = VAR_3;",
"}",
"if (tcg_check_temp_count()) {",
"printf(\"LEAK at %08x\\n\", env->PC);",
"}",
"#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"log_target_disas(env, pc_start, ctx.pc - pc_start, 0);",
"qemu_log(\"\\n\");",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
]
] |
24,451 | static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
uint8_t *buf, int count)
{
BDRVRawState *s = bs->opaque;
int ret;
ret = fd_open(bs);
if (ret < 0)
return ret;
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
/* Allow reads beyond the end (needed for pwrite) */
if ((ret == 0) && bs->growable) {
int64_t size = raw_getlength(bs);
if (offset >= size) {
memset(buf, 0, count);
ret = count;
goto label__raw_read__success;
}
}
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
/* Try harder for CDrom. */
if (bs->type == BDRV_TYPE_CDROM) {
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] retry read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
}
label__raw_read__success:
return (ret < 0) ? -errno : ret;
}
| false | qemu | 65d21bc73bda6515fd9b4ff5b2e90454f7a0b419 | static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
uint8_t *buf, int count)
{
BDRVRawState *s = bs->opaque;
int ret;
ret = fd_open(bs);
if (ret < 0)
return ret;
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
if ((ret == 0) && bs->growable) {
int64_t size = raw_getlength(bs);
if (offset >= size) {
memset(buf, 0, count);
ret = count;
goto label__raw_read__success;
}
}
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
if (bs->type == BDRV_TYPE_CDROM) {
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
ret = pread(s->fd, buf, count, offset);
if (ret == count)
goto label__raw_read__success;
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] retry read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
}
label__raw_read__success:
return (ret < 0) ? -errno : ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{
BDRVRawState *s = VAR_0->opaque;
int VAR_4;
VAR_4 = fd_open(VAR_0);
if (VAR_4 < 0)
return VAR_4;
VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);
if (VAR_4 == VAR_3)
goto label__raw_read__success;
if ((VAR_4 == 0) && VAR_0->growable) {
int64_t size = raw_getlength(VAR_0);
if (VAR_1 >= size) {
memset(VAR_2, 0, VAR_3);
VAR_4 = VAR_3;
goto label__raw_read__success;
}
}
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] read failed %d : %d = %s\n",
s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,
VAR_0->total_sectors, VAR_4, errno, strerror(errno));
if (VAR_0->type == BDRV_TYPE_CDROM) {
VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);
if (VAR_4 == VAR_3)
goto label__raw_read__success;
VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);
if (VAR_4 == VAR_3)
goto label__raw_read__success;
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] retry read failed %d : %d = %s\n",
s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,
VAR_0->total_sectors, VAR_4, errno, strerror(errno));
}
label__raw_read__success:
return (VAR_4 < 0) ? -errno : VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"BDRVRawState *s = VAR_0->opaque;",
"int VAR_4;",
"VAR_4 = fd_open(VAR_0);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);",
"if (VAR_4 == VAR_3)\ngoto label__raw_read__success;",
"if ((VAR_4 == 0) && VAR_0->growable) {",
"int64_t size = raw_getlength(VAR_0);",
"if (VAR_1 >= size) {",
"memset(VAR_2, 0, VAR_3);",
"VAR_4 = VAR_3;",
"goto label__raw_read__success;",
"}",
"}",
"DEBUG_BLOCK_PRINT(\"raw_pread(%d:%s, %\" PRId64 \", %p, %d) [%\" PRId64\n\"] read failed %d : %d = %s\\n\",\ns->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,\nVAR_0->total_sectors, VAR_4, errno, strerror(errno));",
"if (VAR_0->type == BDRV_TYPE_CDROM) {",
"VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);",
"if (VAR_4 == VAR_3)\ngoto label__raw_read__success;",
"VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);",
"if (VAR_4 == VAR_3)\ngoto label__raw_read__success;",
"DEBUG_BLOCK_PRINT(\"raw_pread(%d:%s, %\" PRId64 \", %p, %d) [%\" PRId64\n\"] retry read failed %d : %d = %s\\n\",\ns->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,\nVAR_0->total_sectors, VAR_4, errno, strerror(errno));",
"}",
"label__raw_read__success:\nreturn (VAR_4 < 0) ? -errno : VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23,
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53,
55
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
77,
79,
81,
83
],
[
85
],
[
89,
93
],
[
95
]
] |
24,452 | static void tcg_out_qemu_st_slow_path (TCGContext *s, TCGLabelQemuLdst *label)
{
int s_bits;
int ir;
int opc = label->opc;
int mem_index = label->mem_index;
int data_reg = label->datalo_reg;
int data_reg2 = label->datahi_reg;
int addr_reg = label->addrlo_reg;
uint8_t *raddr = label->raddr;
uint8_t **label_ptr = &label->label_ptr[0];
s_bits = opc & 3;
/* resolve label address */
reloc_pc14 (label_ptr[0], (tcg_target_long) s->code_ptr);
/* slow path */
ir = 3;
tcg_out_mov (s, TCG_TYPE_I32, ir++, TCG_AREG0);
#if TARGET_LONG_BITS == 32
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
ir |= 1;
#endif
tcg_out_mov (s, TCG_TYPE_I32, ir++, label->addrhi_reg);
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#endif
switch (opc) {
case 0:
tcg_out32 (s, (RLWINM
| RA (ir)
| RS (data_reg)
| SH (0)
| MB (24)
| ME (31)));
break;
case 1:
tcg_out32 (s, (RLWINM
| RA (ir)
| RS (data_reg)
| SH (0)
| MB (16)
| ME (31)));
break;
case 2:
tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg);
break;
case 3:
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
ir |= 1;
#endif
tcg_out_mov (s, TCG_TYPE_I32, ir++, data_reg2);
tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg);
break;
}
ir++;
tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index);
tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1);
tcg_out32 (s, B | 8);
tcg_out32 (s, (tcg_target_long) raddr);
tcg_out_b (s, 0, (tcg_target_long) raddr);
}
| false | qemu | c878da3b27ceeed953c9f9a1eb002d59e9dcb4c6 | static void tcg_out_qemu_st_slow_path (TCGContext *s, TCGLabelQemuLdst *label)
{
int s_bits;
int ir;
int opc = label->opc;
int mem_index = label->mem_index;
int data_reg = label->datalo_reg;
int data_reg2 = label->datahi_reg;
int addr_reg = label->addrlo_reg;
uint8_t *raddr = label->raddr;
uint8_t **label_ptr = &label->label_ptr[0];
s_bits = opc & 3;
reloc_pc14 (label_ptr[0], (tcg_target_long) s->code_ptr);
ir = 3;
tcg_out_mov (s, TCG_TYPE_I32, ir++, TCG_AREG0);
#if TARGET_LONG_BITS == 32
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
ir |= 1;
#endif
tcg_out_mov (s, TCG_TYPE_I32, ir++, label->addrhi_reg);
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#endif
switch (opc) {
case 0:
tcg_out32 (s, (RLWINM
| RA (ir)
| RS (data_reg)
| SH (0)
| MB (24)
| ME (31)));
break;
case 1:
tcg_out32 (s, (RLWINM
| RA (ir)
| RS (data_reg)
| SH (0)
| MB (16)
| ME (31)));
break;
case 2:
tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg);
break;
case 3:
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
ir |= 1;
#endif
tcg_out_mov (s, TCG_TYPE_I32, ir++, data_reg2);
tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg);
break;
}
ir++;
tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index);
tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1);
tcg_out32 (s, B | 8);
tcg_out32 (s, (tcg_target_long) raddr);
tcg_out_b (s, 0, (tcg_target_long) raddr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (TCGContext *VAR_0, TCGLabelQemuLdst *VAR_1)
{
int VAR_2;
int VAR_3;
int VAR_4 = VAR_1->VAR_4;
int VAR_5 = VAR_1->VAR_5;
int VAR_6 = VAR_1->datalo_reg;
int VAR_7 = VAR_1->datahi_reg;
int VAR_8 = VAR_1->addrlo_reg;
uint8_t *raddr = VAR_1->raddr;
uint8_t **label_ptr = &VAR_1->label_ptr[0];
VAR_2 = VAR_4 & 3;
reloc_pc14 (label_ptr[0], (tcg_target_long) VAR_0->code_ptr);
VAR_3 = 3;
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, TCG_AREG0);
#if TARGET_LONG_BITS == 32
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_8);
#else
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
VAR_3 |= 1;
#endif
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_1->addrhi_reg);
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_8);
#endif
switch (VAR_4) {
case 0:
tcg_out32 (VAR_0, (RLWINM
| RA (VAR_3)
| RS (VAR_6)
| SH (0)
| MB (24)
| ME (31)));
break;
case 1:
tcg_out32 (VAR_0, (RLWINM
| RA (VAR_3)
| RS (VAR_6)
| SH (0)
| MB (16)
| ME (31)));
break;
case 2:
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3, VAR_6);
break;
case 3:
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
VAR_3 |= 1;
#endif
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_7);
tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3, VAR_6);
break;
}
VAR_3++;
tcg_out_movi (VAR_0, TCG_TYPE_I32, VAR_3, VAR_5);
tcg_out_call (VAR_0, (tcg_target_long) qemu_st_helpers[VAR_4], 1);
tcg_out32 (VAR_0, B | 8);
tcg_out32 (VAR_0, (tcg_target_long) raddr);
tcg_out_b (VAR_0, 0, (tcg_target_long) raddr);
}
| [
"static void FUNC_0 (TCGContext *VAR_0, TCGLabelQemuLdst *VAR_1)\n{",
"int VAR_2;",
"int VAR_3;",
"int VAR_4 = VAR_1->VAR_4;",
"int VAR_5 = VAR_1->VAR_5;",
"int VAR_6 = VAR_1->datalo_reg;",
"int VAR_7 = VAR_1->datahi_reg;",
"int VAR_8 = VAR_1->addrlo_reg;",
"uint8_t *raddr = VAR_1->raddr;",
"uint8_t **label_ptr = &VAR_1->label_ptr[0];",
"VAR_2 = VAR_4 & 3;",
"reloc_pc14 (label_ptr[0], (tcg_target_long) VAR_0->code_ptr);",
"VAR_3 = 3;",
"tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, TCG_AREG0);",
"#if TARGET_LONG_BITS == 32\ntcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_8);",
"#else\n#ifdef TCG_TARGET_CALL_ALIGN_ARGS\nVAR_3 |= 1;",
"#endif\ntcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_1->addrhi_reg);",
"tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_8);",
"#endif\nswitch (VAR_4) {",
"case 0:\ntcg_out32 (VAR_0, (RLWINM\n| RA (VAR_3)\n| RS (VAR_6)\n| SH (0)\n| MB (24)\n| ME (31)));",
"break;",
"case 1:\ntcg_out32 (VAR_0, (RLWINM\n| RA (VAR_3)\n| RS (VAR_6)\n| SH (0)\n| MB (16)\n| ME (31)));",
"break;",
"case 2:\ntcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3, VAR_6);",
"break;",
"case 3:\n#ifdef TCG_TARGET_CALL_ALIGN_ARGS\nVAR_3 |= 1;",
"#endif\ntcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3++, VAR_7);",
"tcg_out_mov (VAR_0, TCG_TYPE_I32, VAR_3, VAR_6);",
"break;",
"}",
"VAR_3++;",
"tcg_out_movi (VAR_0, TCG_TYPE_I32, VAR_3, VAR_5);",
"tcg_out_call (VAR_0, (tcg_target_long) qemu_st_helpers[VAR_4], 1);",
"tcg_out32 (VAR_0, B | 8);",
"tcg_out32 (VAR_0, (tcg_target_long) raddr);",
"tcg_out_b (VAR_0, 0, (tcg_target_long) raddr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47,
49
],
[
51,
53
],
[
55
],
[
57,
61
],
[
63,
65,
67,
69,
71,
73,
75
],
[
77
],
[
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
]
] |
24,453 | static int mpegaudio_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
MpegAudioParseContext *s = s1->priv_data;
int len, ret, sr;
uint32_t header;
const uint8_t *buf_ptr;
*poutbuf = NULL;
*poutbuf_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
/* special case for next header for first frame in free
format case (XXX: find a simpler method) */
if (s->free_format_next_header != 0) {
AV_WB32(s->inbuf, s->free_format_next_header);
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
/* no header seen : find one. We need at least MPA_HEADER_SIZE
bytes to parse it */
len = FFMIN(MPA_HEADER_SIZE - len, buf_size);
if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
got_header:
header = AV_RB32(s->inbuf);
ret = ff_mpa_decode_header(avctx, header, &sr);
if (ret < 0) {
s->header_count= -2;
/* no sync found : move by one byte (inefficient, but simple!) */
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
dprintf(avctx, "skip %x\n", header);
/* reset free format frame size to give a chance
to get a new bitrate */
s->free_format_frame_size = 0;
} else {
if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
s->header_count= -3;
s->header= header;
s->header_count++;
s->frame_size = ret;
#if 0
/* free format: prepare to compute frame size */
if (ff_mpegaudio_decode_header(s, header) == 1) {
s->frame_size = -1;
}
#endif
if(s->header_count > 1)
avctx->sample_rate= sr;
}
}
} else
#if 0
if (s->frame_size == -1) {
/* free format : find next sync to compute frame size */
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
/* frame too long: resync */
s->frame_size = 0;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
uint8_t *p, *pend;
uint32_t header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
/* check for header */
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = AV_RB32(p);
header1 = AV_RB32(s->inbuf);
/* check with high probability that we have a
valid header */
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
/* header found: update pointers */
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
/* compute frame size */
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf(avctx, "free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
ff_mpegaudio_decode_header(s, header1);
goto next_data;
}
p++;
}
/* not found: simply increase pointers */
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else
#endif
if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = FFMIN(s->frame_size - len, buf_size);
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
if(s->frame_size > 0 && buf_ptr - buf == s->inbuf_ptr - s->inbuf
&& buf_size + buf_ptr - buf >= s->frame_size){
if(s->header_count > 0){
*poutbuf = buf;
*poutbuf_size = s->frame_size;
}
buf_ptr = buf + s->frame_size;
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
// next_data:
if (s->frame_size > 0 &&
(s->inbuf_ptr - s->inbuf) >= s->frame_size) {
if(s->header_count > 0){
*poutbuf = s->inbuf;
*poutbuf_size = s->inbuf_ptr - s->inbuf;
}
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
}
return buf_ptr - buf;
}
| false | FFmpeg | c96bd21227e594856f8fd0610fd213b002056383 | static int mpegaudio_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
MpegAudioParseContext *s = s1->priv_data;
int len, ret, sr;
uint32_t header;
const uint8_t *buf_ptr;
*poutbuf = NULL;
*poutbuf_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
if (s->free_format_next_header != 0) {
AV_WB32(s->inbuf, s->free_format_next_header);
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
len = FFMIN(MPA_HEADER_SIZE - len, buf_size);
if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
got_header:
header = AV_RB32(s->inbuf);
ret = ff_mpa_decode_header(avctx, header, &sr);
if (ret < 0) {
s->header_count= -2;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
dprintf(avctx, "skip %x\n", header);
s->free_format_frame_size = 0;
} else {
if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
s->header_count= -3;
s->header= header;
s->header_count++;
s->frame_size = ret;
#if 0
if (ff_mpegaudio_decode_header(s, header) == 1) {
s->frame_size = -1;
}
#endif
if(s->header_count > 1)
avctx->sample_rate= sr;
}
}
} else
#if 0
if (s->frame_size == -1) {
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
s->frame_size = 0;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
uint8_t *p, *pend;
uint32_t header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = AV_RB32(p);
header1 = AV_RB32(s->inbuf);
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf(avctx, "free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
ff_mpegaudio_decode_header(s, header1);
goto next_data;
}
p++;
}
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else
#endif
if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = FFMIN(s->frame_size - len, buf_size);
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
if(s->frame_size > 0 && buf_ptr - buf == s->inbuf_ptr - s->inbuf
&& buf_size + buf_ptr - buf >= s->frame_size){
if(s->header_count > 0){
*poutbuf = buf;
*poutbuf_size = s->frame_size;
}
buf_ptr = buf + s->frame_size;
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
if (s->frame_size > 0 &&
(s->inbuf_ptr - s->inbuf) >= s->frame_size) {
if(s->header_count > 0){
*poutbuf = s->inbuf;
*poutbuf_size = s->inbuf_ptr - s->inbuf;
}
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
}
return buf_ptr - buf;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecParserContext *VAR_0,
AVCodecContext *VAR_1,
const uint8_t **VAR_2, int *VAR_3,
const uint8_t *VAR_4, int VAR_5)
{
MpegAudioParseContext *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8;
uint32_t header;
const uint8_t *VAR_9;
*VAR_2 = NULL;
*VAR_3 = 0;
VAR_9 = VAR_4;
while (VAR_5 > 0) {
VAR_6 = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
if (s->free_format_next_header != 0) {
AV_WB32(s->inbuf, s->free_format_next_header);
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
VAR_6 = FFMIN(MPA_HEADER_SIZE - VAR_6, VAR_5);
if (VAR_6 > 0) {
memcpy(s->inbuf_ptr, VAR_9, VAR_6);
VAR_9 += VAR_6;
VAR_5 -= VAR_6;
s->inbuf_ptr += VAR_6;
}
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
got_header:
header = AV_RB32(s->inbuf);
VAR_7 = ff_mpa_decode_header(VAR_1, header, &VAR_8);
if (VAR_7 < 0) {
s->header_count= -2;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
dprintf(VAR_1, "skip %x\n", header);
s->free_format_frame_size = 0;
} else {
if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
s->header_count= -3;
s->header= header;
s->header_count++;
s->frame_size = VAR_7;
#if 0
if (ff_mpegaudio_decode_header(s, header) == 1) {
s->frame_size = -1;
}
#endif
if(s->header_count > 1)
VAR_1->sample_rate= VAR_8;
}
}
} else
#if 0
if (s->frame_size == -1) {
VAR_6 = MPA_MAX_CODED_FRAME_SIZE - VAR_6;
if (VAR_6 > VAR_5)
VAR_6 = VAR_5;
if (VAR_6 == 0) {
s->frame_size = 0;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
uint8_t *p, *pend;
uint32_t header1;
int padding;
memcpy(s->inbuf_ptr, VAR_9, VAR_6);
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + VAR_6 - 4;
while (p <= pend) {
header = AV_RB32(p);
header1 = AV_RB32(s->inbuf);
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
VAR_6 = (p + 4) - s->inbuf_ptr;
VAR_9 += VAR_6;
VAR_5 -= VAR_6;
s->inbuf_ptr = p;
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf(VAR_1, "free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
ff_mpegaudio_decode_header(s, header1);
goto next_data;
}
p++;
}
VAR_9 += VAR_6;
s->inbuf_ptr += VAR_6;
VAR_5 -= VAR_6;
}
} else
#endif
if (VAR_6 < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
VAR_6 = FFMIN(s->frame_size - VAR_6, VAR_5);
memcpy(s->inbuf_ptr, VAR_9, VAR_6);
VAR_9 += VAR_6;
s->inbuf_ptr += VAR_6;
VAR_5 -= VAR_6;
}
if(s->frame_size > 0 && VAR_9 - VAR_4 == s->inbuf_ptr - s->inbuf
&& VAR_5 + VAR_9 - VAR_4 >= s->frame_size){
if(s->header_count > 0){
*VAR_2 = VAR_4;
*VAR_3 = s->frame_size;
}
VAR_9 = VAR_4 + s->frame_size;
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
if (s->frame_size > 0 &&
(s->inbuf_ptr - s->inbuf) >= s->frame_size) {
if(s->header_count > 0){
*VAR_2 = s->inbuf;
*VAR_3 = s->inbuf_ptr - s->inbuf;
}
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
}
return VAR_9 - VAR_4;
}
| [
"static int FUNC_0(AVCodecParserContext *VAR_0,\nAVCodecContext *VAR_1,\nconst uint8_t **VAR_2, int *VAR_3,\nconst uint8_t *VAR_4, int VAR_5)\n{",
"MpegAudioParseContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8;",
"uint32_t header;",
"const uint8_t *VAR_9;",
"*VAR_2 = NULL;",
"*VAR_3 = 0;",
"VAR_9 = VAR_4;",
"while (VAR_5 > 0) {",
"VAR_6 = s->inbuf_ptr - s->inbuf;",
"if (s->frame_size == 0) {",
"if (s->free_format_next_header != 0) {",
"AV_WB32(s->inbuf, s->free_format_next_header);",
"s->inbuf_ptr = s->inbuf + 4;",
"s->free_format_next_header = 0;",
"goto got_header;",
"}",
"VAR_6 = FFMIN(MPA_HEADER_SIZE - VAR_6, VAR_5);",
"if (VAR_6 > 0) {",
"memcpy(s->inbuf_ptr, VAR_9, VAR_6);",
"VAR_9 += VAR_6;",
"VAR_5 -= VAR_6;",
"s->inbuf_ptr += VAR_6;",
"}",
"if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {",
"got_header:\nheader = AV_RB32(s->inbuf);",
"VAR_7 = ff_mpa_decode_header(VAR_1, header, &VAR_8);",
"if (VAR_7 < 0) {",
"s->header_count= -2;",
"memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);",
"s->inbuf_ptr--;",
"dprintf(VAR_1, \"skip %x\\n\", header);",
"s->free_format_frame_size = 0;",
"} else {",
"if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)\ns->header_count= -3;",
"s->header= header;",
"s->header_count++;",
"s->frame_size = VAR_7;",
"#if 0\nif (ff_mpegaudio_decode_header(s, header) == 1) {",
"s->frame_size = -1;",
"}",
"#endif\nif(s->header_count > 1)\nVAR_1->sample_rate= VAR_8;",
"}",
"}",
"} else",
"#if 0\nif (s->frame_size == -1) {",
"VAR_6 = MPA_MAX_CODED_FRAME_SIZE - VAR_6;",
"if (VAR_6 > VAR_5)\nVAR_6 = VAR_5;",
"if (VAR_6 == 0) {",
"s->frame_size = 0;",
"memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);",
"s->inbuf_ptr--;",
"} else {",
"uint8_t *p, *pend;",
"uint32_t header1;",
"int padding;",
"memcpy(s->inbuf_ptr, VAR_9, VAR_6);",
"p = s->inbuf_ptr - 3;",
"pend = s->inbuf_ptr + VAR_6 - 4;",
"while (p <= pend) {",
"header = AV_RB32(p);",
"header1 = AV_RB32(s->inbuf);",
"if ((header & SAME_HEADER_MASK) ==\n(header1 & SAME_HEADER_MASK)) {",
"VAR_6 = (p + 4) - s->inbuf_ptr;",
"VAR_9 += VAR_6;",
"VAR_5 -= VAR_6;",
"s->inbuf_ptr = p;",
"s->free_format_next_header = header;",
"s->free_format_frame_size = s->inbuf_ptr - s->inbuf;",
"padding = (header1 >> 9) & 1;",
"if (s->layer == 1)\ns->free_format_frame_size -= padding * 4;",
"else\ns->free_format_frame_size -= padding;",
"dprintf(VAR_1, \"free frame size=%d padding=%d\\n\",\ns->free_format_frame_size, padding);",
"ff_mpegaudio_decode_header(s, header1);",
"goto next_data;",
"}",
"p++;",
"}",
"VAR_9 += VAR_6;",
"s->inbuf_ptr += VAR_6;",
"VAR_5 -= VAR_6;",
"}",
"} else",
"#endif\nif (VAR_6 < s->frame_size) {",
"if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)\ns->frame_size = MPA_MAX_CODED_FRAME_SIZE;",
"VAR_6 = FFMIN(s->frame_size - VAR_6, VAR_5);",
"memcpy(s->inbuf_ptr, VAR_9, VAR_6);",
"VAR_9 += VAR_6;",
"s->inbuf_ptr += VAR_6;",
"VAR_5 -= VAR_6;",
"}",
"if(s->frame_size > 0 && VAR_9 - VAR_4 == s->inbuf_ptr - s->inbuf\n&& VAR_5 + VAR_9 - VAR_4 >= s->frame_size){",
"if(s->header_count > 0){",
"*VAR_2 = VAR_4;",
"*VAR_3 = s->frame_size;",
"}",
"VAR_9 = VAR_4 + s->frame_size;",
"s->inbuf_ptr = s->inbuf;",
"s->frame_size = 0;",
"break;",
"}",
"if (s->frame_size > 0 &&\n(s->inbuf_ptr - s->inbuf) >= s->frame_size) {",
"if(s->header_count > 0){",
"*VAR_2 = s->inbuf;",
"*VAR_3 = s->inbuf_ptr - s->inbuf;",
"}",
"s->inbuf_ptr = s->inbuf;",
"s->frame_size = 0;",
"break;",
"}",
"}",
"return VAR_9 - VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
109,
113
],
[
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
137
],
[
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181,
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207,
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
285,
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
]
] |
24,454 | int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,
int32_t ag, uint32_t ap)
{
AVReplayGain *replaygain;
if (tg == INT32_MIN && ag == INT32_MIN)
return 0;
replaygain = (AVReplayGain*)ff_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN,
sizeof(*replaygain));
if (!replaygain)
return AVERROR(ENOMEM);
replaygain->track_gain = tg;
replaygain->track_peak = tp;
replaygain->album_gain = ag;
replaygain->album_peak = ap;
return 0;
}
| false | FFmpeg | 7f4ec4364bc4a73036660c1c6a3c4801db524e9e | int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,
int32_t ag, uint32_t ap)
{
AVReplayGain *replaygain;
if (tg == INT32_MIN && ag == INT32_MIN)
return 0;
replaygain = (AVReplayGain*)ff_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN,
sizeof(*replaygain));
if (!replaygain)
return AVERROR(ENOMEM);
replaygain->track_gain = tg;
replaygain->track_peak = tp;
replaygain->album_gain = ag;
replaygain->album_peak = ap;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVStream *VAR_0, int32_t VAR_1, uint32_t VAR_2,
int32_t VAR_3, uint32_t VAR_4)
{
AVReplayGain *replaygain;
if (VAR_1 == INT32_MIN && VAR_3 == INT32_MIN)
return 0;
replaygain = (AVReplayGain*)ff_stream_new_side_data(VAR_0, AV_PKT_DATA_REPLAYGAIN,
sizeof(*replaygain));
if (!replaygain)
return AVERROR(ENOMEM);
replaygain->track_gain = VAR_1;
replaygain->track_peak = VAR_2;
replaygain->album_gain = VAR_3;
replaygain->album_peak = VAR_4;
return 0;
}
| [
"int FUNC_0(AVStream *VAR_0, int32_t VAR_1, uint32_t VAR_2,\nint32_t VAR_3, uint32_t VAR_4)\n{",
"AVReplayGain *replaygain;",
"if (VAR_1 == INT32_MIN && VAR_3 == INT32_MIN)\nreturn 0;",
"replaygain = (AVReplayGain*)ff_stream_new_side_data(VAR_0, AV_PKT_DATA_REPLAYGAIN,\nsizeof(*replaygain));",
"if (!replaygain)\nreturn AVERROR(ENOMEM);",
"replaygain->track_gain = VAR_1;",
"replaygain->track_peak = VAR_2;",
"replaygain->album_gain = VAR_3;",
"replaygain->album_peak = VAR_4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17,
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
24,455 | static void dead_tmp(TCGv tmp)
{
int i;
num_temps--;
i = num_temps;
if (GET_TCGV(temps[i]) == GET_TCGV(tmp))
return;
/* Shuffle this temp to the last slot. */
while (GET_TCGV(temps[i]) != GET_TCGV(tmp))
i--;
while (i < num_temps) {
temps[i] = temps[i + 1];
i++;
}
temps[i] = tmp;
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static void dead_tmp(TCGv tmp)
{
int i;
num_temps--;
i = num_temps;
if (GET_TCGV(temps[i]) == GET_TCGV(tmp))
return;
while (GET_TCGV(temps[i]) != GET_TCGV(tmp))
i--;
while (i < num_temps) {
temps[i] = temps[i + 1];
i++;
}
temps[i] = tmp;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGv VAR_0)
{
int VAR_1;
num_temps--;
VAR_1 = num_temps;
if (GET_TCGV(temps[VAR_1]) == GET_TCGV(VAR_0))
return;
while (GET_TCGV(temps[VAR_1]) != GET_TCGV(VAR_0))
VAR_1--;
while (VAR_1 < num_temps) {
temps[VAR_1] = temps[VAR_1 + 1];
VAR_1++;
}
temps[VAR_1] = VAR_0;
}
| [
"static void FUNC_0(TCGv VAR_0)\n{",
"int VAR_1;",
"num_temps--;",
"VAR_1 = num_temps;",
"if (GET_TCGV(temps[VAR_1]) == GET_TCGV(VAR_0))\nreturn;",
"while (GET_TCGV(temps[VAR_1]) != GET_TCGV(VAR_0))\nVAR_1--;",
"while (VAR_1 < num_temps) {",
"temps[VAR_1] = temps[VAR_1 + 1];",
"VAR_1++;",
"}",
"temps[VAR_1] = VAR_0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
24,456 | pvscsi_update_irq_status(PVSCSIState *s)
{
PCIDevice *d = PCI_DEVICE(s);
bool should_raise = s->reg_interrupt_enabled & s->reg_interrupt_status;
trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
s->reg_interrupt_status);
if (s->msi_used && msi_enabled(d)) {
if (should_raise) {
trace_pvscsi_update_irq_msi();
msi_notify(d, PVSCSI_VECTOR_COMPLETION);
}
return;
}
pci_set_irq(d, !!should_raise);
}
| false | qemu | 269fe4c3ab0cf29329317eb868f8ec90ac761b41 | pvscsi_update_irq_status(PVSCSIState *s)
{
PCIDevice *d = PCI_DEVICE(s);
bool should_raise = s->reg_interrupt_enabled & s->reg_interrupt_status;
trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
s->reg_interrupt_status);
if (s->msi_used && msi_enabled(d)) {
if (should_raise) {
trace_pvscsi_update_irq_msi();
msi_notify(d, PVSCSI_VECTOR_COMPLETION);
}
return;
}
pci_set_irq(d, !!should_raise);
}
| {
"code": [],
"line_no": []
} | FUNC_0(PVSCSIState *VAR_0)
{
PCIDevice *d = PCI_DEVICE(VAR_0);
bool should_raise = VAR_0->reg_interrupt_enabled & VAR_0->reg_interrupt_status;
trace_pvscsi_update_irq_level(should_raise, VAR_0->reg_interrupt_enabled,
VAR_0->reg_interrupt_status);
if (VAR_0->msi_used && msi_enabled(d)) {
if (should_raise) {
trace_pvscsi_update_irq_msi();
msi_notify(d, PVSCSI_VECTOR_COMPLETION);
}
return;
}
pci_set_irq(d, !!should_raise);
}
| [
"FUNC_0(PVSCSIState *VAR_0)\n{",
"PCIDevice *d = PCI_DEVICE(VAR_0);",
"bool should_raise = VAR_0->reg_interrupt_enabled & VAR_0->reg_interrupt_status;",
"trace_pvscsi_update_irq_level(should_raise, VAR_0->reg_interrupt_enabled,\nVAR_0->reg_interrupt_status);",
"if (VAR_0->msi_used && msi_enabled(d)) {",
"if (should_raise) {",
"trace_pvscsi_update_irq_msi();",
"msi_notify(d, PVSCSI_VECTOR_COMPLETION);",
"}",
"return;",
"}",
"pci_set_irq(d, !!should_raise);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
24,457 | static inline void check_io(CPUX86State *env, int addr, int size)
{
int io_offset, val, mask;
/* TSS must be a valid 32 bit one */
if (!(env->tr.flags & DESC_P_MASK) ||
((env->tr.flags >> DESC_TYPE_SHIFT) & 0xf) != 9 ||
env->tr.limit < 103) {
goto fail;
}
io_offset = cpu_lduw_kernel(env, env->tr.base + 0x66);
io_offset += (addr >> 3);
/* Note: the check needs two bytes */
if ((io_offset + 1) > env->tr.limit) {
goto fail;
}
val = cpu_lduw_kernel(env, env->tr.base + io_offset);
val >>= (addr & 7);
mask = (1 << size) - 1;
/* all bits must be zero to allow the I/O */
if ((val & mask) != 0) {
fail:
raise_exception_err(env, EXCP0D_GPF, 0);
}
}
| false | qemu | 81cf8d8adc64203567e03326c13ea4abec9fe5df | static inline void check_io(CPUX86State *env, int addr, int size)
{
int io_offset, val, mask;
if (!(env->tr.flags & DESC_P_MASK) ||
((env->tr.flags >> DESC_TYPE_SHIFT) & 0xf) != 9 ||
env->tr.limit < 103) {
goto fail;
}
io_offset = cpu_lduw_kernel(env, env->tr.base + 0x66);
io_offset += (addr >> 3);
if ((io_offset + 1) > env->tr.limit) {
goto fail;
}
val = cpu_lduw_kernel(env, env->tr.base + io_offset);
val >>= (addr & 7);
mask = (1 << size) - 1;
if ((val & mask) != 0) {
fail:
raise_exception_err(env, EXCP0D_GPF, 0);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(CPUX86State *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5;
if (!(VAR_0->tr.flags & DESC_P_MASK) ||
((VAR_0->tr.flags >> DESC_TYPE_SHIFT) & 0xf) != 9 ||
VAR_0->tr.limit < 103) {
goto fail;
}
VAR_3 = cpu_lduw_kernel(VAR_0, VAR_0->tr.base + 0x66);
VAR_3 += (VAR_1 >> 3);
if ((VAR_3 + 1) > VAR_0->tr.limit) {
goto fail;
}
VAR_4 = cpu_lduw_kernel(VAR_0, VAR_0->tr.base + VAR_3);
VAR_4 >>= (VAR_1 & 7);
VAR_5 = (1 << VAR_2) - 1;
if ((VAR_4 & VAR_5) != 0) {
fail:
raise_exception_err(VAR_0, EXCP0D_GPF, 0);
}
}
| [
"static inline void FUNC_0(CPUX86State *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"if (!(VAR_0->tr.flags & DESC_P_MASK) ||\n((VAR_0->tr.flags >> DESC_TYPE_SHIFT) & 0xf) != 9 ||\nVAR_0->tr.limit < 103) {",
"goto fail;",
"}",
"VAR_3 = cpu_lduw_kernel(VAR_0, VAR_0->tr.base + 0x66);",
"VAR_3 += (VAR_1 >> 3);",
"if ((VAR_3 + 1) > VAR_0->tr.limit) {",
"goto fail;",
"}",
"VAR_4 = cpu_lduw_kernel(VAR_0, VAR_0->tr.base + VAR_3);",
"VAR_4 >>= (VAR_1 & 7);",
"VAR_5 = (1 << VAR_2) - 1;",
"if ((VAR_4 & VAR_5) != 0) {",
"fail:\nraise_exception_err(VAR_0, EXCP0D_GPF, 0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
]
] |
24,458 | void page_set_flags(target_ulong start, target_ulong end, int flags)
{
PageDesc *p;
target_ulong addr;
/* mmap_lock should already be held. */
start = start & TARGET_PAGE_MASK;
end = TARGET_PAGE_ALIGN(end);
if (flags & PAGE_WRITE)
flags |= PAGE_WRITE_ORG;
for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
p = page_find_alloc(addr >> TARGET_PAGE_BITS);
/* We may be called for host regions that are outside guest
address space. */
if (!p)
return;
/* if the write protection is set, then we invalidate the code
inside */
if (!(p->flags & PAGE_WRITE) &&
(flags & PAGE_WRITE) &&
p->first_tb) {
tb_invalidate_phys_page(addr, 0, NULL);
}
p->flags = flags;
}
}
| false | qemu | 376a790970de7e84170ee9360b6ff53ecfa4a1be | void page_set_flags(target_ulong start, target_ulong end, int flags)
{
PageDesc *p;
target_ulong addr;
start = start & TARGET_PAGE_MASK;
end = TARGET_PAGE_ALIGN(end);
if (flags & PAGE_WRITE)
flags |= PAGE_WRITE_ORG;
for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
p = page_find_alloc(addr >> TARGET_PAGE_BITS);
if (!p)
return;
if (!(p->flags & PAGE_WRITE) &&
(flags & PAGE_WRITE) &&
p->first_tb) {
tb_invalidate_phys_page(addr, 0, NULL);
}
p->flags = flags;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)
{
PageDesc *p;
target_ulong addr;
VAR_0 = VAR_0 & TARGET_PAGE_MASK;
VAR_1 = TARGET_PAGE_ALIGN(VAR_1);
if (VAR_2 & PAGE_WRITE)
VAR_2 |= PAGE_WRITE_ORG;
for(addr = VAR_0; addr < VAR_1; addr += TARGET_PAGE_SIZE) {
p = page_find_alloc(addr >> TARGET_PAGE_BITS);
if (!p)
return;
if (!(p->VAR_2 & PAGE_WRITE) &&
(VAR_2 & PAGE_WRITE) &&
p->first_tb) {
tb_invalidate_phys_page(addr, 0, NULL);
}
p->VAR_2 = VAR_2;
}
}
| [
"void FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)\n{",
"PageDesc *p;",
"target_ulong addr;",
"VAR_0 = VAR_0 & TARGET_PAGE_MASK;",
"VAR_1 = TARGET_PAGE_ALIGN(VAR_1);",
"if (VAR_2 & PAGE_WRITE)\nVAR_2 |= PAGE_WRITE_ORG;",
"for(addr = VAR_0; addr < VAR_1; addr += TARGET_PAGE_SIZE) {",
"p = page_find_alloc(addr >> TARGET_PAGE_BITS);",
"if (!p)\nreturn;",
"if (!(p->VAR_2 & PAGE_WRITE) &&\n(VAR_2 & PAGE_WRITE) &&\np->first_tb) {",
"tb_invalidate_phys_page(addr, 0, NULL);",
"}",
"p->VAR_2 = VAR_2;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
29,
31
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
24,459 | static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
int parse_extradata)
{
AVCodecContext *const avctx = h->avctx;
H264SliceContext *sl;
int buf_index;
unsigned context_count;
int next_avc;
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
int nal_index;
int idr_cleared=0;
int ret = 0;
h->nal_unit_type= 0;
if(!h->slice_context_count)
h->slice_context_count= 1;
h->max_contexts = h->slice_context_count;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {
h->current_slice = 0;
if (!h->first_field)
h->cur_pic_ptr = NULL;
ff_h264_reset_sei(h);
if (h->nal_length_size == 4) {
if (buf_size > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)buf_size) {
h->is_avc = 0;
}else if(buf_size > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)buf_size)
h->is_avc = 1;
if (avctx->active_thread_type & FF_THREAD_FRAME)
nals_needed = get_last_needed_nal(h, buf, buf_size);
{
buf_index = 0;
next_avc = h->is_avc ? 0 : buf_size;
nal_index = 0;
for (;;) {
int consumed;
int dst_length;
int bit_length;
const uint8_t *ptr;
int nalsize = 0;
int err;
if (buf_index >= next_avc) {
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
if (nalsize < 0)
break;
next_avc = buf_index + nalsize;
} else {
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
if (buf_index >= buf_size)
break;
if (buf_index >= next_avc)
continue;
sl = &h->slice_ctx[context_count];
ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
&consumed, next_avc - buf_index);
if (!ptr || dst_length < 0) {
ret = -1;
bit_length = get_bit_length(h, buf, ptr, dst_length,
buf_index + consumed, next_avc);
if (h->avctx->debug & FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG,
"NAL %d/%d at %d/%d length %d\n",
h->nal_unit_type, h->nal_ref_idc, buf_index, buf_size, dst_length);
if (h->is_avc && (nalsize != consumed) && nalsize)
av_log(h->avctx, AV_LOG_DEBUG,
"AVC: Consumed only %d bytes instead of %d\n",
consumed, nalsize);
buf_index += consumed;
nal_index++;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0 &&
h->nal_unit_type != NAL_SEI)
continue;
again:
if ( (!(avctx->active_thread_type & FF_THREAD_FRAME) || nals_needed >= nal_index)
&& !h->current_slice)
h->au_pps_id = -1;
/* Ignore per frame NAL unit type during extradata
* parsing. Decoding slices is not possible in codec init
* with frame-mt */
if (parse_extradata) {
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
case NAL_SLICE:
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
av_log(h->avctx, AV_LOG_WARNING,
"Ignoring NAL %d in global header/extradata\n",
h->nal_unit_type);
// fall through to next case
case NAL_AUXILIARY_SLICE:
h->nal_unit_type = NAL_FF_IGNORE;
err = 0;
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
if ((ptr[0] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
if (h->nal_unit_type != NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
if(!idr_cleared) {
if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
ret = AVERROR_INVALIDDATA;
idr(h); // FIXME ensure we don't lose some frames if there is reordering
idr_cleared = 1;
h->has_recovery_point = 1;
case NAL_SLICE:
init_get_bits(&sl->gb, ptr, bit_length);
if ((err = ff_h264_decode_slice_header(h, sl)))
break;
if (h->sei_recovery_frame_cnt >= 0) {
if (h->frame_num != h->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1;
if ( h->recovery_frame < 0
|| ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt) {
h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) &
((1 << h->sps.log2_max_frame_num) - 1);
if (!h->valid_recovery_point)
h->recovery_frame = h->frame_num;
h->cur_pic_ptr->f.key_frame |=
(h->nal_unit_type == NAL_IDR_SLICE);
if (h->nal_unit_type == NAL_IDR_SLICE ||
h->recovery_frame == h->frame_num) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
// If we have an IDR, all frames after it in decoded order are
// "recovered".
if (h->nal_unit_type == NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
h->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL);
h->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT);
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (h->current_slice == 1) {
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))
decode_postinit(h, nal_index >= nals_needed);
if (h->avctx->hwaccel &&
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_start(h);
if (sl->redundant_pic_count == 0) {
if (avctx->hwaccel) {
ret = avctx->hwaccel->decode_slice(avctx,
&buf[buf_index - consumed],
consumed);
if (ret < 0)
} else if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
start_code,
sizeof(start_code));
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
&buf[buf_index - consumed],
consumed);
} else
context_count++;
break;
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
ret = AVERROR(ENOSYS);
break;
case NAL_SEI:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&h->gb, ptr, bit_length);
if (ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? nalsize : 1)) {
av_log(h->avctx, AV_LOG_DEBUG,
"SPS decoding failure, trying again with the complete NAL\n");
if (h->is_avc)
av_assert0(next_avc - buf_index + consumed == nalsize);
if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
break;
init_get_bits(&h->gb, &buf[buf_index + 1 - consumed],
8*(next_avc - buf_index + consumed - 1));
ff_h264_decode_seq_parameter_set(h);
break;
case NAL_PPS:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
case NAL_FF_IGNORE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
h->nal_unit_type, bit_length);
if (context_count == h->max_contexts) {
ret = ff_h264_execute_decode_slices(h, context_count);
if (err < 0 || err == SLICE_SKIPED) {
if (err < 0)
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (err == SLICE_SINGLETHREAD) {
/* Slice could not be decoded in parallel mode, restart. Note
* that rbsp_buffer is not transferred, but since we no longer
* run in parallel mode this should not be an issue. */
sl = &h->slice_ctx[0];
goto again;
if (context_count) {
ret = ff_h264_execute_decode_slices(h, context_count);
ret = 0;
end:
/* clean up */
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
return (ret < 0) ? ret : buf_index;
| true | FFmpeg | c4b2017ba66e1623da9f527704c61c86a6e74844 | static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
int parse_extradata)
{
AVCodecContext *const avctx = h->avctx;
H264SliceContext *sl;
int buf_index;
unsigned context_count;
int next_avc;
int nals_needed = 0;
int nal_index;
int idr_cleared=0;
int ret = 0;
h->nal_unit_type= 0;
if(!h->slice_context_count)
h->slice_context_count= 1;
h->max_contexts = h->slice_context_count;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {
h->current_slice = 0;
if (!h->first_field)
h->cur_pic_ptr = NULL;
ff_h264_reset_sei(h);
if (h->nal_length_size == 4) {
if (buf_size > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)buf_size) {
h->is_avc = 0;
}else if(buf_size > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)buf_size)
h->is_avc = 1;
if (avctx->active_thread_type & FF_THREAD_FRAME)
nals_needed = get_last_needed_nal(h, buf, buf_size);
{
buf_index = 0;
next_avc = h->is_avc ? 0 : buf_size;
nal_index = 0;
for (;;) {
int consumed;
int dst_length;
int bit_length;
const uint8_t *ptr;
int nalsize = 0;
int err;
if (buf_index >= next_avc) {
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
if (nalsize < 0)
break;
next_avc = buf_index + nalsize;
} else {
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
if (buf_index >= buf_size)
break;
if (buf_index >= next_avc)
continue;
sl = &h->slice_ctx[context_count];
ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
&consumed, next_avc - buf_index);
if (!ptr || dst_length < 0) {
ret = -1;
bit_length = get_bit_length(h, buf, ptr, dst_length,
buf_index + consumed, next_avc);
if (h->avctx->debug & FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG,
"NAL %d/%d at %d/%d length %d\n",
h->nal_unit_type, h->nal_ref_idc, buf_index, buf_size, dst_length);
if (h->is_avc && (nalsize != consumed) && nalsize)
av_log(h->avctx, AV_LOG_DEBUG,
"AVC: Consumed only %d bytes instead of %d\n",
consumed, nalsize);
buf_index += consumed;
nal_index++;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0 &&
h->nal_unit_type != NAL_SEI)
continue;
again:
if ( (!(avctx->active_thread_type & FF_THREAD_FRAME) || nals_needed >= nal_index)
&& !h->current_slice)
h->au_pps_id = -1;
if (parse_extradata) {
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
case NAL_SLICE:
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
av_log(h->avctx, AV_LOG_WARNING,
"Ignoring NAL %d in global header/extradata\n",
h->nal_unit_type);
case NAL_AUXILIARY_SLICE:
h->nal_unit_type = NAL_FF_IGNORE;
err = 0;
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
if ((ptr[0] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
if (h->nal_unit_type != NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
if(!idr_cleared) {
if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
ret = AVERROR_INVALIDDATA;
idr(h);
idr_cleared = 1;
h->has_recovery_point = 1;
case NAL_SLICE:
init_get_bits(&sl->gb, ptr, bit_length);
if ((err = ff_h264_decode_slice_header(h, sl)))
break;
if (h->sei_recovery_frame_cnt >= 0) {
if (h->frame_num != h->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1;
if ( h->recovery_frame < 0
|| ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt) {
h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) &
((1 << h->sps.log2_max_frame_num) - 1);
if (!h->valid_recovery_point)
h->recovery_frame = h->frame_num;
h->cur_pic_ptr->f.key_frame |=
(h->nal_unit_type == NAL_IDR_SLICE);
if (h->nal_unit_type == NAL_IDR_SLICE ||
h->recovery_frame == h->frame_num) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
if (h->nal_unit_type == NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
h->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL);
h->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT);
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (h->current_slice == 1) {
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))
decode_postinit(h, nal_index >= nals_needed);
if (h->avctx->hwaccel &&
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_start(h);
if (sl->redundant_pic_count == 0) {
if (avctx->hwaccel) {
ret = avctx->hwaccel->decode_slice(avctx,
&buf[buf_index - consumed],
consumed);
if (ret < 0)
} else if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
start_code,
sizeof(start_code));
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
&buf[buf_index - consumed],
consumed);
} else
context_count++;
break;
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
ret = AVERROR(ENOSYS);
break;
case NAL_SEI:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&h->gb, ptr, bit_length);
if (ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? nalsize : 1)) {
av_log(h->avctx, AV_LOG_DEBUG,
"SPS decoding failure, trying again with the complete NAL\n");
if (h->is_avc)
av_assert0(next_avc - buf_index + consumed == nalsize);
if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
break;
init_get_bits(&h->gb, &buf[buf_index + 1 - consumed],
8*(next_avc - buf_index + consumed - 1));
ff_h264_decode_seq_parameter_set(h);
break;
case NAL_PPS:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
case NAL_FF_IGNORE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
h->nal_unit_type, bit_length);
if (context_count == h->max_contexts) {
ret = ff_h264_execute_decode_slices(h, context_count);
if (err < 0 || err == SLICE_SKIPED) {
if (err < 0)
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (err == SLICE_SINGLETHREAD) {
sl = &h->slice_ctx[0];
goto again;
if (context_count) {
ret = ff_h264_execute_decode_slices(h, context_count);
ret = 0;
end:
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
return (ret < 0) ? ret : buf_index;
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0, const uint8_t *VAR_1, int VAR_2,
int VAR_3)
{
AVCodecContext *const avctx = VAR_0->avctx;
H264SliceContext *sl;
int VAR_4;
unsigned VAR_5;
int VAR_6;
int VAR_7 = 0;
int VAR_8;
int VAR_9=0;
int VAR_10 = 0;
VAR_0->nal_unit_type= 0;
if(!VAR_0->slice_context_count)
VAR_0->slice_context_count= 1;
VAR_0->max_contexts = VAR_0->slice_context_count;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {
VAR_0->current_slice = 0;
if (!VAR_0->first_field)
VAR_0->cur_pic_ptr = NULL;
ff_h264_reset_sei(VAR_0);
if (VAR_0->nal_length_size == 4) {
if (VAR_2 > 8 && AV_RB32(VAR_1) == 1 && AV_RB32(VAR_1+5) > (unsigned)VAR_2) {
VAR_0->is_avc = 0;
}else if(VAR_2 > 3 && AV_RB32(VAR_1) > 1 && AV_RB32(VAR_1) <= (unsigned)VAR_2)
VAR_0->is_avc = 1;
if (avctx->active_thread_type & FF_THREAD_FRAME)
VAR_7 = get_last_needed_nal(VAR_0, VAR_1, VAR_2);
{
VAR_4 = 0;
VAR_6 = VAR_0->is_avc ? 0 : VAR_2;
VAR_8 = 0;
for (;;) {
int VAR_11;
int VAR_12;
int VAR_13;
const uint8_t *VAR_14;
int VAR_15 = 0;
int VAR_16;
if (VAR_4 >= VAR_6) {
VAR_15 = get_avc_nalsize(VAR_0, VAR_1, VAR_2, &VAR_4);
if (VAR_15 < 0)
break;
VAR_6 = VAR_4 + VAR_15;
} else {
VAR_4 = find_start_code(VAR_1, VAR_2, VAR_4, VAR_6);
if (VAR_4 >= VAR_2)
break;
if (VAR_4 >= VAR_6)
continue;
sl = &VAR_0->slice_ctx[VAR_5];
VAR_14 = ff_h264_decode_nal(VAR_0, sl, VAR_1 + VAR_4, &VAR_12,
&VAR_11, VAR_6 - VAR_4);
if (!VAR_14 || VAR_12 < 0) {
VAR_10 = -1;
VAR_13 = get_bit_length(VAR_0, VAR_1, VAR_14, VAR_12,
VAR_4 + VAR_11, VAR_6);
if (VAR_0->avctx->debug & FF_DEBUG_STARTCODE)
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"NAL %d/%d at %d/%d length %d\n",
VAR_0->nal_unit_type, VAR_0->nal_ref_idc, VAR_4, VAR_2, VAR_12);
if (VAR_0->is_avc && (VAR_15 != VAR_11) && VAR_15)
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"AVC: Consumed only %d bytes instead of %d\n",
VAR_11, VAR_15);
VAR_4 += VAR_11;
VAR_8++;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
VAR_0->nal_ref_idc == 0 &&
VAR_0->nal_unit_type != NAL_SEI)
continue;
again:
if ( (!(avctx->active_thread_type & FF_THREAD_FRAME) || VAR_7 >= VAR_8)
&& !VAR_0->current_slice)
VAR_0->au_pps_id = -1;
if (VAR_3) {
switch (VAR_0->nal_unit_type) {
case NAL_IDR_SLICE:
case NAL_SLICE:
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Ignoring NAL %d in global header/extradata\n",
VAR_0->nal_unit_type);
case NAL_AUXILIARY_SLICE:
VAR_0->nal_unit_type = NAL_FF_IGNORE;
VAR_16 = 0;
switch (VAR_0->nal_unit_type) {
case NAL_IDR_SLICE:
if ((VAR_14[0] & 0xFC) == 0x98) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
VAR_0->next_outputed_poc = INT_MIN;
VAR_10 = -1;
if (VAR_0->nal_unit_type != NAL_IDR_SLICE) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
VAR_10 = -1;
if(!VAR_9) {
if (VAR_0->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
av_log(VAR_0, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
VAR_10 = AVERROR_INVALIDDATA;
idr(VAR_0);
VAR_9 = 1;
VAR_0->has_recovery_point = 1;
case NAL_SLICE:
init_get_bits(&sl->gb, VAR_14, VAR_13);
if ((VAR_16 = ff_h264_decode_slice_header(VAR_0, sl)))
break;
if (VAR_0->sei_recovery_frame_cnt >= 0) {
if (VAR_0->frame_num != VAR_0->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
VAR_0->valid_recovery_point = 1;
if ( VAR_0->recovery_frame < 0
|| ((VAR_0->recovery_frame - VAR_0->frame_num) & ((1 << VAR_0->sps.log2_max_frame_num)-1)) > VAR_0->sei_recovery_frame_cnt) {
VAR_0->recovery_frame = (VAR_0->frame_num + VAR_0->sei_recovery_frame_cnt) &
((1 << VAR_0->sps.log2_max_frame_num) - 1);
if (!VAR_0->valid_recovery_point)
VAR_0->recovery_frame = VAR_0->frame_num;
VAR_0->cur_pic_ptr->f.key_frame |=
(VAR_0->nal_unit_type == NAL_IDR_SLICE);
if (VAR_0->nal_unit_type == NAL_IDR_SLICE ||
VAR_0->recovery_frame == VAR_0->frame_num) {
VAR_0->recovery_frame = -1;
VAR_0->cur_pic_ptr->recovered = 1;
if (VAR_0->nal_unit_type == NAL_IDR_SLICE)
VAR_0->frame_recovered |= FRAME_RECOVERED_IDR;
VAR_0->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL);
VAR_0->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT);
#if 1
VAR_0->cur_pic_ptr->recovered |= VAR_0->frame_recovered;
#else
VAR_0->cur_pic_ptr->recovered |= !!(VAR_0->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (VAR_0->current_slice == 1) {
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))
decode_postinit(VAR_0, VAR_8 >= VAR_7);
if (VAR_0->avctx->hwaccel &&
(VAR_10 = VAR_0->avctx->hwaccel->start_frame(VAR_0->avctx, VAR_1, VAR_2)) < 0)
if (CONFIG_H264_VDPAU_DECODER &&
VAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_start(VAR_0);
if (sl->redundant_pic_count == 0) {
if (avctx->hwaccel) {
VAR_10 = avctx->hwaccel->decode_slice(avctx,
&VAR_1[VAR_4 - VAR_11],
VAR_11);
if (VAR_10 < 0)
} else if (CONFIG_H264_VDPAU_DECODER &&
VAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
ff_vdpau_add_data_chunk(VAR_0->cur_pic_ptr->f.data[0],
start_code,
sizeof(start_code));
ff_vdpau_add_data_chunk(VAR_0->cur_pic_ptr->f.data[0],
&VAR_1[VAR_4 - VAR_11],
VAR_11);
} else
VAR_5++;
break;
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
VAR_10 = AVERROR(ENOSYS);
break;
case NAL_SEI:
init_get_bits(&VAR_0->gb, VAR_14, VAR_13);
VAR_10 = ff_h264_decode_sei(VAR_0);
break;
case NAL_SPS:
init_get_bits(&VAR_0->gb, VAR_14, VAR_13);
if (ff_h264_decode_seq_parameter_set(VAR_0) < 0 && (VAR_0->is_avc ? VAR_15 : 1)) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"SPS decoding failure, trying again with the complete NAL\n");
if (VAR_0->is_avc)
av_assert0(VAR_6 - VAR_4 + VAR_11 == VAR_15);
if ((VAR_6 - VAR_4 + VAR_11 - 1) >= INT_MAX/8)
break;
init_get_bits(&VAR_0->gb, &VAR_1[VAR_4 + 1 - VAR_11],
8*(VAR_6 - VAR_4 + VAR_11 - 1));
ff_h264_decode_seq_parameter_set(VAR_0);
break;
case NAL_PPS:
init_get_bits(&VAR_0->gb, VAR_14, VAR_13);
VAR_10 = ff_h264_decode_picture_parameter_set(VAR_0, VAR_13);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
case NAL_FF_IGNORE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
VAR_0->nal_unit_type, VAR_13);
if (VAR_5 == VAR_0->max_contexts) {
VAR_10 = ff_h264_execute_decode_slices(VAR_0, VAR_5);
if (VAR_16 < 0 || VAR_16 == SLICE_SKIPED) {
if (VAR_16 < 0)
av_log(VAR_0->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (VAR_16 == SLICE_SINGLETHREAD) {
sl = &VAR_0->slice_ctx[0];
goto again;
if (VAR_5) {
VAR_10 = ff_h264_execute_decode_slices(VAR_0, VAR_5);
VAR_10 = 0;
end:
if (VAR_0->cur_pic_ptr && !VAR_0->droppable) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_0->picture_structure == PICT_BOTTOM_FIELD);
return (VAR_10 < 0) ? VAR_10 : VAR_4;
| [
"static int FUNC_0(H264Context *VAR_0, const uint8_t *VAR_1, int VAR_2,\nint VAR_3)\n{",
"AVCodecContext *const avctx = VAR_0->avctx;",
"H264SliceContext *sl;",
"int VAR_4;",
"unsigned VAR_5;",
"int VAR_6;",
"int VAR_7 = 0;",
"int VAR_8;",
"int VAR_9=0;",
"int VAR_10 = 0;",
"VAR_0->nal_unit_type= 0;",
"if(!VAR_0->slice_context_count)\nVAR_0->slice_context_count= 1;",
"VAR_0->max_contexts = VAR_0->slice_context_count;",
"if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {",
"VAR_0->current_slice = 0;",
"if (!VAR_0->first_field)\nVAR_0->cur_pic_ptr = NULL;",
"ff_h264_reset_sei(VAR_0);",
"if (VAR_0->nal_length_size == 4) {",
"if (VAR_2 > 8 && AV_RB32(VAR_1) == 1 && AV_RB32(VAR_1+5) > (unsigned)VAR_2) {",
"VAR_0->is_avc = 0;",
"}else if(VAR_2 > 3 && AV_RB32(VAR_1) > 1 && AV_RB32(VAR_1) <= (unsigned)VAR_2)",
"VAR_0->is_avc = 1;",
"if (avctx->active_thread_type & FF_THREAD_FRAME)\nVAR_7 = get_last_needed_nal(VAR_0, VAR_1, VAR_2);",
"{",
"VAR_4 = 0;",
"VAR_6 = VAR_0->is_avc ? 0 : VAR_2;",
"VAR_8 = 0;",
"for (;;) {",
"int VAR_11;",
"int VAR_12;",
"int VAR_13;",
"const uint8_t *VAR_14;",
"int VAR_15 = 0;",
"int VAR_16;",
"if (VAR_4 >= VAR_6) {",
"VAR_15 = get_avc_nalsize(VAR_0, VAR_1, VAR_2, &VAR_4);",
"if (VAR_15 < 0)\nbreak;",
"VAR_6 = VAR_4 + VAR_15;",
"} else {",
"VAR_4 = find_start_code(VAR_1, VAR_2, VAR_4, VAR_6);",
"if (VAR_4 >= VAR_2)\nbreak;",
"if (VAR_4 >= VAR_6)\ncontinue;",
"sl = &VAR_0->slice_ctx[VAR_5];",
"VAR_14 = ff_h264_decode_nal(VAR_0, sl, VAR_1 + VAR_4, &VAR_12,\n&VAR_11, VAR_6 - VAR_4);",
"if (!VAR_14 || VAR_12 < 0) {",
"VAR_10 = -1;",
"VAR_13 = get_bit_length(VAR_0, VAR_1, VAR_14, VAR_12,\nVAR_4 + VAR_11, VAR_6);",
"if (VAR_0->avctx->debug & FF_DEBUG_STARTCODE)\nav_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"NAL %d/%d at %d/%d length %d\\n\",\nVAR_0->nal_unit_type, VAR_0->nal_ref_idc, VAR_4, VAR_2, VAR_12);",
"if (VAR_0->is_avc && (VAR_15 != VAR_11) && VAR_15)\nav_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"AVC: Consumed only %d bytes instead of %d\\n\",\nVAR_11, VAR_15);",
"VAR_4 += VAR_11;",
"VAR_8++;",
"if (avctx->skip_frame >= AVDISCARD_NONREF &&\nVAR_0->nal_ref_idc == 0 &&\nVAR_0->nal_unit_type != NAL_SEI)\ncontinue;",
"again:\nif ( (!(avctx->active_thread_type & FF_THREAD_FRAME) || VAR_7 >= VAR_8)\n&& !VAR_0->current_slice)\nVAR_0->au_pps_id = -1;",
"if (VAR_3) {",
"switch (VAR_0->nal_unit_type) {",
"case NAL_IDR_SLICE:\ncase NAL_SLICE:\ncase NAL_DPA:\ncase NAL_DPB:\ncase NAL_DPC:\nav_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Ignoring NAL %d in global header/extradata\\n\",\nVAR_0->nal_unit_type);",
"case NAL_AUXILIARY_SLICE:\nVAR_0->nal_unit_type = NAL_FF_IGNORE;",
"VAR_16 = 0;",
"switch (VAR_0->nal_unit_type) {",
"case NAL_IDR_SLICE:\nif ((VAR_14[0] & 0xFC) == 0x98) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid inter IDR frame\\n\");",
"VAR_0->next_outputed_poc = INT_MIN;",
"VAR_10 = -1;",
"if (VAR_0->nal_unit_type != NAL_IDR_SLICE) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid mix of idr and non-idr slices\\n\");",
"VAR_10 = -1;",
"if(!VAR_9) {",
"if (VAR_0->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\\n\");",
"VAR_10 = AVERROR_INVALIDDATA;",
"idr(VAR_0);",
"VAR_9 = 1;",
"VAR_0->has_recovery_point = 1;",
"case NAL_SLICE:\ninit_get_bits(&sl->gb, VAR_14, VAR_13);",
"if ((VAR_16 = ff_h264_decode_slice_header(VAR_0, sl)))\nbreak;",
"if (VAR_0->sei_recovery_frame_cnt >= 0) {",
"if (VAR_0->frame_num != VAR_0->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)\nVAR_0->valid_recovery_point = 1;",
"if ( VAR_0->recovery_frame < 0\n|| ((VAR_0->recovery_frame - VAR_0->frame_num) & ((1 << VAR_0->sps.log2_max_frame_num)-1)) > VAR_0->sei_recovery_frame_cnt) {",
"VAR_0->recovery_frame = (VAR_0->frame_num + VAR_0->sei_recovery_frame_cnt) &\n((1 << VAR_0->sps.log2_max_frame_num) - 1);",
"if (!VAR_0->valid_recovery_point)\nVAR_0->recovery_frame = VAR_0->frame_num;",
"VAR_0->cur_pic_ptr->f.key_frame |=\n(VAR_0->nal_unit_type == NAL_IDR_SLICE);",
"if (VAR_0->nal_unit_type == NAL_IDR_SLICE ||\nVAR_0->recovery_frame == VAR_0->frame_num) {",
"VAR_0->recovery_frame = -1;",
"VAR_0->cur_pic_ptr->recovered = 1;",
"if (VAR_0->nal_unit_type == NAL_IDR_SLICE)\nVAR_0->frame_recovered |= FRAME_RECOVERED_IDR;",
"VAR_0->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL);",
"VAR_0->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT);",
"#if 1\nVAR_0->cur_pic_ptr->recovered |= VAR_0->frame_recovered;",
"#else\nVAR_0->cur_pic_ptr->recovered |= !!(VAR_0->frame_recovered & FRAME_RECOVERED_IDR);",
"#endif\nif (VAR_0->current_slice == 1) {",
"if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))\ndecode_postinit(VAR_0, VAR_8 >= VAR_7);",
"if (VAR_0->avctx->hwaccel &&\n(VAR_10 = VAR_0->avctx->hwaccel->start_frame(VAR_0->avctx, VAR_1, VAR_2)) < 0)\nif (CONFIG_H264_VDPAU_DECODER &&\nVAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)\nff_vdpau_h264_picture_start(VAR_0);",
"if (sl->redundant_pic_count == 0) {",
"if (avctx->hwaccel) {",
"VAR_10 = avctx->hwaccel->decode_slice(avctx,\n&VAR_1[VAR_4 - VAR_11],\nVAR_11);",
"if (VAR_10 < 0)\n} else if (CONFIG_H264_VDPAU_DECODER &&",
"VAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {",
"ff_vdpau_add_data_chunk(VAR_0->cur_pic_ptr->f.data[0],\nstart_code,\nsizeof(start_code));",
"ff_vdpau_add_data_chunk(VAR_0->cur_pic_ptr->f.data[0],\n&VAR_1[VAR_4 - VAR_11],\nVAR_11);",
"} else",
"VAR_5++;",
"break;",
"case NAL_DPA:\ncase NAL_DPB:\ncase NAL_DPC:\navpriv_request_sample(avctx, \"data partitioning\");",
"VAR_10 = AVERROR(ENOSYS);",
"break;",
"case NAL_SEI:\ninit_get_bits(&VAR_0->gb, VAR_14, VAR_13);",
"VAR_10 = ff_h264_decode_sei(VAR_0);",
"break;",
"case NAL_SPS:\ninit_get_bits(&VAR_0->gb, VAR_14, VAR_13);",
"if (ff_h264_decode_seq_parameter_set(VAR_0) < 0 && (VAR_0->is_avc ? VAR_15 : 1)) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"SPS decoding failure, trying again with the complete NAL\\n\");",
"if (VAR_0->is_avc)\nav_assert0(VAR_6 - VAR_4 + VAR_11 == VAR_15);",
"if ((VAR_6 - VAR_4 + VAR_11 - 1) >= INT_MAX/8)\nbreak;",
"init_get_bits(&VAR_0->gb, &VAR_1[VAR_4 + 1 - VAR_11],\n8*(VAR_6 - VAR_4 + VAR_11 - 1));",
"ff_h264_decode_seq_parameter_set(VAR_0);",
"break;",
"case NAL_PPS:\ninit_get_bits(&VAR_0->gb, VAR_14, VAR_13);",
"VAR_10 = ff_h264_decode_picture_parameter_set(VAR_0, VAR_13);",
"break;",
"case NAL_AUD:\ncase NAL_END_SEQUENCE:\ncase NAL_END_STREAM:\ncase NAL_FILLER_DATA:\ncase NAL_SPS_EXT:\ncase NAL_AUXILIARY_SLICE:\nbreak;",
"case NAL_FF_IGNORE:\nbreak;",
"default:\nav_log(avctx, AV_LOG_DEBUG, \"Unknown NAL code: %d (%d bits)\\n\",\nVAR_0->nal_unit_type, VAR_13);",
"if (VAR_5 == VAR_0->max_contexts) {",
"VAR_10 = ff_h264_execute_decode_slices(VAR_0, VAR_5);",
"if (VAR_16 < 0 || VAR_16 == SLICE_SKIPED) {",
"if (VAR_16 < 0)\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"decode_slice_header error\\n\");",
"sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;",
"} else if (VAR_16 == SLICE_SINGLETHREAD) {",
"sl = &VAR_0->slice_ctx[0];",
"goto again;",
"if (VAR_5) {",
"VAR_10 = ff_h264_execute_decode_slices(VAR_0, VAR_5);",
"VAR_10 = 0;",
"end:\nif (VAR_0->cur_pic_ptr && !VAR_0->droppable) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_0->picture_structure == PICT_BOTTOM_FIELD);",
"return (VAR_10 < 0) ? VAR_10 : VAR_4;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
63,
65
],
[
69
],
[
71
],
[
74
],
[
76
],
[
78
],
[
80
],
[
82
],
[
84
],
[
86
],
[
88
],
[
90
],
[
94
],
[
96
],
[
98,
100
],
[
102
],
[
104
],
[
106
],
[
108,
110
],
[
112,
114
],
[
119
],
[
123,
125
],
[
127
],
[
129
],
[
135,
137
],
[
141,
143,
145,
147
],
[
151,
153,
155,
157
],
[
161
],
[
163
],
[
167,
169,
171,
173
],
[
177,
179,
181,
183
],
[
191
],
[
193
],
[
195,
197,
199,
201,
203,
205,
207,
209
],
[
213,
215
],
[
221
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241,
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259
],
[
262
],
[
264
],
[
266,
268
],
[
272,
274
],
[
278
],
[
280,
282
],
[
286,
288
],
[
290,
292
],
[
296,
298
],
[
304,
306
],
[
310,
312
],
[
314
],
[
316
],
[
323,
325
],
[
327
],
[
329
],
[
331,
333
],
[
335,
337
],
[
339,
343
],
[
345,
347
],
[
351,
353,
356,
358,
360
],
[
365
],
[
367
],
[
369,
371,
373
],
[
375,
378
],
[
380
],
[
382,
384,
386
],
[
388,
390,
392
],
[
394
],
[
396
],
[
399
],
[
401,
403,
405,
407
],
[
409
],
[
412
],
[
414,
416
],
[
418
],
[
422
],
[
424,
426
],
[
428
],
[
430,
432
],
[
434,
436
],
[
438,
440
],
[
442,
444
],
[
446
],
[
451
],
[
453,
455
],
[
457
],
[
461
],
[
463,
465,
467,
469,
471,
473,
475
],
[
477,
479
],
[
481,
483,
485
],
[
490
],
[
492
],
[
500
],
[
502,
504
],
[
506
],
[
508
],
[
522
],
[
524
],
[
529
],
[
531
],
[
538
],
[
540,
544
],
[
546,
548
],
[
553
]
] |
24,460 | static int check_tag(AVIOContext *s, int offset, unsigned int len)
{
char tag[4];
if (len > 4 ||
avio_seek(s, offset, SEEK_SET) < 0 ||
avio_read(s, tag, len) < len)
return -1;
else if (!AV_RB32(tag) || is_tag(tag, len))
return 1;
return 0;
}
| true | FFmpeg | 0382c94f13b4b20456b7259e90b170dc020419b8 | static int check_tag(AVIOContext *s, int offset, unsigned int len)
{
char tag[4];
if (len > 4 ||
avio_seek(s, offset, SEEK_SET) < 0 ||
avio_read(s, tag, len) < len)
return -1;
else if (!AV_RB32(tag) || is_tag(tag, len))
return 1;
return 0;
}
| {
"code": [
" avio_read(s, tag, len) < len)"
],
"line_no": [
13
]
} | static int FUNC_0(AVIOContext *VAR_0, int VAR_1, unsigned int VAR_2)
{
char VAR_3[4];
if (VAR_2 > 4 ||
avio_seek(VAR_0, VAR_1, SEEK_SET) < 0 ||
avio_read(VAR_0, VAR_3, VAR_2) < VAR_2)
return -1;
else if (!AV_RB32(VAR_3) || is_tag(VAR_3, VAR_2))
return 1;
return 0;
}
| [
"static int FUNC_0(AVIOContext *VAR_0, int VAR_1, unsigned int VAR_2)\n{",
"char VAR_3[4];",
"if (VAR_2 > 4 ||\navio_seek(VAR_0, VAR_1, SEEK_SET) < 0 ||\navio_read(VAR_0, VAR_3, VAR_2) < VAR_2)\nreturn -1;",
"else if (!AV_RB32(VAR_3) || is_tag(VAR_3, VAR_2))\nreturn 1;",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13,
15
],
[
17,
19
],
[
23
],
[
25
]
] |
24,461 | static void fw_cfg_bootsplash(FWCfgState *s)
{
int boot_splash_time = -1;
const char *boot_splash_filename = NULL;
char *p;
char *filename, *file_data;
int file_size;
int file_type = -1;
const char *temp;
/* get user configuration */
QemuOptsList *plist = qemu_find_opts("boot-opts");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "splash");
if (temp != NULL) {
boot_splash_filename = temp;
}
temp = qemu_opt_get(opts, "splash-time");
if (temp != NULL) {
p = (char *)temp;
boot_splash_time = strtol(p, (char **)&p, 10);
}
}
/* insert splash time if user configurated */
if (boot_splash_time >= 0) {
/* validate the input */
if (boot_splash_time > 0xffff) {
error_report("splash time is big than 65535, force it to 65535.");
boot_splash_time = 0xffff;
}
/* use little endian format */
qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff);
qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff);
fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
}
/* insert splash file if user configurated */
if (boot_splash_filename != NULL) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename);
if (filename == NULL) {
error_report("failed to find file '%s'.", boot_splash_filename);
return;
}
/* loading file data */
file_data = read_splashfile(filename, &file_size, &file_type);
if (file_data == NULL) {
g_free(filename);
return;
}
if (boot_splash_filedata != NULL) {
g_free(boot_splash_filedata);
}
boot_splash_filedata = (uint8_t *)file_data;
boot_splash_filedata_size = file_size;
/* insert data */
if (file_type == JPG_FILE) {
fw_cfg_add_file(s, "bootsplash.jpg",
boot_splash_filedata, boot_splash_filedata_size);
} else {
fw_cfg_add_file(s, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
g_free(filename);
}
}
| true | qemu | d09acb9b5ef0bb4fa94d3d459919a6ebaf8804bc | static void fw_cfg_bootsplash(FWCfgState *s)
{
int boot_splash_time = -1;
const char *boot_splash_filename = NULL;
char *p;
char *filename, *file_data;
int file_size;
int file_type = -1;
const char *temp;
QemuOptsList *plist = qemu_find_opts("boot-opts");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "splash");
if (temp != NULL) {
boot_splash_filename = temp;
}
temp = qemu_opt_get(opts, "splash-time");
if (temp != NULL) {
p = (char *)temp;
boot_splash_time = strtol(p, (char **)&p, 10);
}
}
if (boot_splash_time >= 0) {
if (boot_splash_time > 0xffff) {
error_report("splash time is big than 65535, force it to 65535.");
boot_splash_time = 0xffff;
}
qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff);
qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff);
fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
}
if (boot_splash_filename != NULL) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename);
if (filename == NULL) {
error_report("failed to find file '%s'.", boot_splash_filename);
return;
}
file_data = read_splashfile(filename, &file_size, &file_type);
if (file_data == NULL) {
g_free(filename);
return;
}
if (boot_splash_filedata != NULL) {
g_free(boot_splash_filedata);
}
boot_splash_filedata = (uint8_t *)file_data;
boot_splash_filedata_size = file_size;
if (file_type == JPG_FILE) {
fw_cfg_add_file(s, "bootsplash.jpg",
boot_splash_filedata, boot_splash_filedata_size);
} else {
fw_cfg_add_file(s, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
g_free(filename);
}
}
| {
"code": [
" int file_size;"
],
"line_no": [
13
]
} | static void FUNC_0(FWCfgState *VAR_0)
{
int VAR_1 = -1;
const char *VAR_2 = NULL;
char *VAR_3;
char *VAR_4, *VAR_5;
int VAR_6;
int VAR_7 = -1;
const char *VAR_8;
QemuOptsList *plist = qemu_find_opts("boot-opts");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
VAR_8 = qemu_opt_get(opts, "splash");
if (VAR_8 != NULL) {
VAR_2 = VAR_8;
}
VAR_8 = qemu_opt_get(opts, "splash-time");
if (VAR_8 != NULL) {
VAR_3 = (char *)VAR_8;
VAR_1 = strtol(VAR_3, (char **)&VAR_3, 10);
}
}
if (VAR_1 >= 0) {
if (VAR_1 > 0xffff) {
error_report("splash time is big than 65535, force it to 65535.");
VAR_1 = 0xffff;
}
qemu_extra_params_fw[0] = (uint8_t)(VAR_1 & 0xff);
qemu_extra_params_fw[1] = (uint8_t)((VAR_1 >> 8) & 0xff);
fw_cfg_add_file(VAR_0, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
}
if (VAR_2 != NULL) {
VAR_4 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_2);
if (VAR_4 == NULL) {
error_report("failed to find file '%VAR_0'.", VAR_2);
return;
}
VAR_5 = read_splashfile(VAR_4, &VAR_6, &VAR_7);
if (VAR_5 == NULL) {
g_free(VAR_4);
return;
}
if (boot_splash_filedata != NULL) {
g_free(boot_splash_filedata);
}
boot_splash_filedata = (uint8_t *)VAR_5;
boot_splash_filedata_size = VAR_6;
if (VAR_7 == JPG_FILE) {
fw_cfg_add_file(VAR_0, "bootsplash.jpg",
boot_splash_filedata, boot_splash_filedata_size);
} else {
fw_cfg_add_file(VAR_0, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
g_free(VAR_4);
}
}
| [
"static void FUNC_0(FWCfgState *VAR_0)\n{",
"int VAR_1 = -1;",
"const char *VAR_2 = NULL;",
"char *VAR_3;",
"char *VAR_4, *VAR_5;",
"int VAR_6;",
"int VAR_7 = -1;",
"const char *VAR_8;",
"QemuOptsList *plist = qemu_find_opts(\"boot-opts\");",
"QemuOpts *opts = QTAILQ_FIRST(&plist->head);",
"if (opts != NULL) {",
"VAR_8 = qemu_opt_get(opts, \"splash\");",
"if (VAR_8 != NULL) {",
"VAR_2 = VAR_8;",
"}",
"VAR_8 = qemu_opt_get(opts, \"splash-time\");",
"if (VAR_8 != NULL) {",
"VAR_3 = (char *)VAR_8;",
"VAR_1 = strtol(VAR_3, (char **)&VAR_3, 10);",
"}",
"}",
"if (VAR_1 >= 0) {",
"if (VAR_1 > 0xffff) {",
"error_report(\"splash time is big than 65535, force it to 65535.\");",
"VAR_1 = 0xffff;",
"}",
"qemu_extra_params_fw[0] = (uint8_t)(VAR_1 & 0xff);",
"qemu_extra_params_fw[1] = (uint8_t)((VAR_1 >> 8) & 0xff);",
"fw_cfg_add_file(VAR_0, \"etc/boot-menu-wait\", qemu_extra_params_fw, 2);",
"}",
"if (VAR_2 != NULL) {",
"VAR_4 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_2);",
"if (VAR_4 == NULL) {",
"error_report(\"failed to find file '%VAR_0'.\", VAR_2);",
"return;",
"}",
"VAR_5 = read_splashfile(VAR_4, &VAR_6, &VAR_7);",
"if (VAR_5 == NULL) {",
"g_free(VAR_4);",
"return;",
"}",
"if (boot_splash_filedata != NULL) {",
"g_free(boot_splash_filedata);",
"}",
"boot_splash_filedata = (uint8_t *)VAR_5;",
"boot_splash_filedata_size = VAR_6;",
"if (VAR_7 == JPG_FILE) {",
"fw_cfg_add_file(VAR_0, \"bootsplash.jpg\",\nboot_splash_filedata, boot_splash_filedata_size);",
"} else {",
"fw_cfg_add_file(VAR_0, \"bootsplash.bmp\",\nboot_splash_filedata, boot_splash_filedata_size);",
"}",
"g_free(VAR_4);",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
24,462 | static ssize_t handle_aiocb_rw(RawPosixAIOData *aiocb)
{
ssize_t nbytes;
char *buf;
if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {
/*
* If there is just a single buffer, and it is properly aligned
* we can just use plain pread/pwrite without any problems.
*/
if (aiocb->aio_niov == 1) {
return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);
}
/*
* We have more than one iovec, and all are properly aligned.
*
* Try preadv/pwritev first and fall back to linearizing the
* buffer if it's not supported.
*/
if (preadv_present) {
nbytes = handle_aiocb_rw_vector(aiocb);
if (nbytes == aiocb->aio_nbytes ||
(nbytes < 0 && nbytes != -ENOSYS)) {
return nbytes;
}
preadv_present = false;
}
/*
* XXX(hch): short read/write. no easy way to handle the reminder
* using these interfaces. For now retry using plain
* pread/pwrite?
*/
}
/*
* Ok, we have to do it the hard way, copy all segments into
* a single aligned buffer.
*/
buf = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);
if (aiocb->aio_type & QEMU_AIO_WRITE) {
char *p = buf;
int i;
for (i = 0; i < aiocb->aio_niov; ++i) {
memcpy(p, aiocb->aio_iov[i].iov_base, aiocb->aio_iov[i].iov_len);
p += aiocb->aio_iov[i].iov_len;
}
assert(p - buf == aiocb->aio_nbytes);
}
nbytes = handle_aiocb_rw_linear(aiocb, buf);
if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {
char *p = buf;
size_t count = aiocb->aio_nbytes, copy;
int i;
for (i = 0; i < aiocb->aio_niov && count; ++i) {
copy = count;
if (copy > aiocb->aio_iov[i].iov_len) {
copy = aiocb->aio_iov[i].iov_len;
}
memcpy(aiocb->aio_iov[i].iov_base, p, copy);
assert(count >= copy);
p += copy;
count -= copy;
}
assert(count == 0);
}
qemu_vfree(buf);
return nbytes;
}
| true | qemu | 50d4a858e62b1d864227d13f07d2c79c118d046a | static ssize_t handle_aiocb_rw(RawPosixAIOData *aiocb)
{
ssize_t nbytes;
char *buf;
if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {
if (aiocb->aio_niov == 1) {
return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);
}
if (preadv_present) {
nbytes = handle_aiocb_rw_vector(aiocb);
if (nbytes == aiocb->aio_nbytes ||
(nbytes < 0 && nbytes != -ENOSYS)) {
return nbytes;
}
preadv_present = false;
}
}
buf = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);
if (aiocb->aio_type & QEMU_AIO_WRITE) {
char *p = buf;
int i;
for (i = 0; i < aiocb->aio_niov; ++i) {
memcpy(p, aiocb->aio_iov[i].iov_base, aiocb->aio_iov[i].iov_len);
p += aiocb->aio_iov[i].iov_len;
}
assert(p - buf == aiocb->aio_nbytes);
}
nbytes = handle_aiocb_rw_linear(aiocb, buf);
if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {
char *p = buf;
size_t count = aiocb->aio_nbytes, copy;
int i;
for (i = 0; i < aiocb->aio_niov && count; ++i) {
copy = count;
if (copy > aiocb->aio_iov[i].iov_len) {
copy = aiocb->aio_iov[i].iov_len;
}
memcpy(aiocb->aio_iov[i].iov_base, p, copy);
assert(count >= copy);
p += copy;
count -= copy;
}
assert(count == 0);
}
qemu_vfree(buf);
return nbytes;
}
| {
"code": [
" buf = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);"
],
"line_no": [
79
]
} | static ssize_t FUNC_0(RawPosixAIOData *aiocb)
{
ssize_t nbytes;
char *VAR_0;
if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {
if (aiocb->aio_niov == 1) {
return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);
}
if (preadv_present) {
nbytes = handle_aiocb_rw_vector(aiocb);
if (nbytes == aiocb->aio_nbytes ||
(nbytes < 0 && nbytes != -ENOSYS)) {
return nbytes;
}
preadv_present = false;
}
}
VAR_0 = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);
if (aiocb->aio_type & QEMU_AIO_WRITE) {
char *VAR_3 = VAR_0;
int VAR_3;
for (VAR_3 = 0; VAR_3 < aiocb->aio_niov; ++VAR_3) {
memcpy(VAR_3, aiocb->aio_iov[VAR_3].iov_base, aiocb->aio_iov[VAR_3].iov_len);
VAR_3 += aiocb->aio_iov[VAR_3].iov_len;
}
assert(VAR_3 - VAR_0 == aiocb->aio_nbytes);
}
nbytes = handle_aiocb_rw_linear(aiocb, VAR_0);
if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {
char *VAR_3 = VAR_0;
size_t count = aiocb->aio_nbytes, copy;
int VAR_3;
for (VAR_3 = 0; VAR_3 < aiocb->aio_niov && count; ++VAR_3) {
copy = count;
if (copy > aiocb->aio_iov[VAR_3].iov_len) {
copy = aiocb->aio_iov[VAR_3].iov_len;
}
memcpy(aiocb->aio_iov[VAR_3].iov_base, VAR_3, copy);
assert(count >= copy);
VAR_3 += copy;
count -= copy;
}
assert(count == 0);
}
qemu_vfree(VAR_0);
return nbytes;
}
| [
"static ssize_t FUNC_0(RawPosixAIOData *aiocb)\n{",
"ssize_t nbytes;",
"char *VAR_0;",
"if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {",
"if (aiocb->aio_niov == 1) {",
"return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);",
"}",
"if (preadv_present) {",
"nbytes = handle_aiocb_rw_vector(aiocb);",
"if (nbytes == aiocb->aio_nbytes ||\n(nbytes < 0 && nbytes != -ENOSYS)) {",
"return nbytes;",
"}",
"preadv_present = false;",
"}",
"}",
"VAR_0 = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);",
"if (aiocb->aio_type & QEMU_AIO_WRITE) {",
"char *VAR_3 = VAR_0;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < aiocb->aio_niov; ++VAR_3) {",
"memcpy(VAR_3, aiocb->aio_iov[VAR_3].iov_base, aiocb->aio_iov[VAR_3].iov_len);",
"VAR_3 += aiocb->aio_iov[VAR_3].iov_len;",
"}",
"assert(VAR_3 - VAR_0 == aiocb->aio_nbytes);",
"}",
"nbytes = handle_aiocb_rw_linear(aiocb, VAR_0);",
"if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {",
"char *VAR_3 = VAR_0;",
"size_t count = aiocb->aio_nbytes, copy;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < aiocb->aio_niov && count; ++VAR_3) {",
"copy = count;",
"if (copy > aiocb->aio_iov[VAR_3].iov_len) {",
"copy = aiocb->aio_iov[VAR_3].iov_len;",
"}",
"memcpy(aiocb->aio_iov[VAR_3].iov_base, VAR_3, copy);",
"assert(count >= copy);",
"VAR_3 += copy;",
"count -= copy;",
"}",
"assert(count == 0);",
"}",
"qemu_vfree(VAR_0);",
"return nbytes;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
21
],
[
23
],
[
25
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
67
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
]
] |
24,463 | static inline void set_txint(ChannelState *s)
{
s->txint = 1;
if (!s->rxint_under_svc) {
s->txint_under_svc = 1;
if (s->chn == chn_a) {
s->rregs[R_INTR] |= INTR_TXINTA;
if (s->wregs[W_MINTR] & MINTR_STATUSHI)
s->otherchn->rregs[R_IVEC] = IVEC_HITXINTA;
else
s->otherchn->rregs[R_IVEC] = IVEC_LOTXINTA;
} else {
s->rregs[R_IVEC] = IVEC_TXINTB;
s->otherchn->rregs[R_INTR] |= INTR_TXINTB;
}
escc_update_irq(s);
}
}
| true | qemu | f53671c054ba0b5d5b10e2a7294786fa2f73479e | static inline void set_txint(ChannelState *s)
{
s->txint = 1;
if (!s->rxint_under_svc) {
s->txint_under_svc = 1;
if (s->chn == chn_a) {
s->rregs[R_INTR] |= INTR_TXINTA;
if (s->wregs[W_MINTR] & MINTR_STATUSHI)
s->otherchn->rregs[R_IVEC] = IVEC_HITXINTA;
else
s->otherchn->rregs[R_IVEC] = IVEC_LOTXINTA;
} else {
s->rregs[R_IVEC] = IVEC_TXINTB;
s->otherchn->rregs[R_INTR] |= INTR_TXINTB;
}
escc_update_irq(s);
}
}
| {
"code": [
" s->rregs[R_INTR] |= INTR_TXINTA;",
" s->otherchn->rregs[R_INTR] |= INTR_TXINTB;"
],
"line_no": [
13,
27
]
} | static inline void FUNC_0(ChannelState *VAR_0)
{
VAR_0->txint = 1;
if (!VAR_0->rxint_under_svc) {
VAR_0->txint_under_svc = 1;
if (VAR_0->chn == chn_a) {
VAR_0->rregs[R_INTR] |= INTR_TXINTA;
if (VAR_0->wregs[W_MINTR] & MINTR_STATUSHI)
VAR_0->otherchn->rregs[R_IVEC] = IVEC_HITXINTA;
else
VAR_0->otherchn->rregs[R_IVEC] = IVEC_LOTXINTA;
} else {
VAR_0->rregs[R_IVEC] = IVEC_TXINTB;
VAR_0->otherchn->rregs[R_INTR] |= INTR_TXINTB;
}
escc_update_irq(VAR_0);
}
}
| [
"static inline void FUNC_0(ChannelState *VAR_0)\n{",
"VAR_0->txint = 1;",
"if (!VAR_0->rxint_under_svc) {",
"VAR_0->txint_under_svc = 1;",
"if (VAR_0->chn == chn_a) {",
"VAR_0->rregs[R_INTR] |= INTR_TXINTA;",
"if (VAR_0->wregs[W_MINTR] & MINTR_STATUSHI)\nVAR_0->otherchn->rregs[R_IVEC] = IVEC_HITXINTA;",
"else\nVAR_0->otherchn->rregs[R_IVEC] = IVEC_LOTXINTA;",
"} else {",
"VAR_0->rregs[R_IVEC] = IVEC_TXINTB;",
"VAR_0->otherchn->rregs[R_INTR] |= INTR_TXINTB;",
"}",
"escc_update_irq(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
24,464 | static int rm_probe(AVProbeData *p)
{
/* check file header */
if (p->buf_size <= 32)
return 0;
if ((p->buf[0] == '.' && p->buf[1] == 'R' &&
p->buf[2] == 'M' && p->buf[3] == 'F' &&
p->buf[4] == 0 && p->buf[5] == 0) ||
(p->buf[0] == '.' && p->buf[1] == 'r' &&
p->buf[2] == 'a' && p->buf[3] == 0xfd))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int rm_probe(AVProbeData *p)
{
if (p->buf_size <= 32)
return 0;
if ((p->buf[0] == '.' && p->buf[1] == 'R' &&
p->buf[2] == 'M' && p->buf[3] == 'F' &&
p->buf[4] == 0 && p->buf[5] == 0) ||
(p->buf[0] == '.' && p->buf[1] == 'r' &&
p->buf[2] == 'a' && p->buf[3] == 0xfd))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
if (VAR_0->buf_size <= 32)
return 0;
if ((VAR_0->buf[0] == '.' && VAR_0->buf[1] == 'R' &&
VAR_0->buf[2] == 'M' && VAR_0->buf[3] == 'F' &&
VAR_0->buf[4] == 0 && VAR_0->buf[5] == 0) ||
(VAR_0->buf[0] == '.' && VAR_0->buf[1] == 'r' &&
VAR_0->buf[2] == 'a' && VAR_0->buf[3] == 0xfd))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"if (VAR_0->buf_size <= 32)\nreturn 0;",
"if ((VAR_0->buf[0] == '.' && VAR_0->buf[1] == 'R' &&\nVAR_0->buf[2] == 'M' && VAR_0->buf[3] == 'F' &&\nVAR_0->buf[4] == 0 && VAR_0->buf[5] == 0) ||\n(VAR_0->buf[0] == '.' && VAR_0->buf[1] == 'r' &&\nVAR_0->buf[2] == 'a' && VAR_0->buf[3] == 0xfd))\nreturn AVPROBE_SCORE_MAX;",
"else\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7,
9
],
[
11,
13,
15,
17,
19,
21
],
[
23,
25
],
[
27
]
] |
24,465 | static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
{
int count = ffio_read_varlen(bc);
int skip_start = 0;
int skip_end = 0;
int channels = 0;
int64_t channel_layout = 0;
int sample_rate = 0;
int width = 0;
int height = 0;
int i;
for (i=0; i<count; i++) {
uint8_t name[256], str_value[256], type_str[256];
int value;
if (avio_tell(bc) >= maxpos)
return AVERROR_INVALIDDATA;
get_str(bc, name, sizeof(name));
value = get_s(bc);
if (value == -1) {
get_str(bc, str_value, sizeof(str_value));
av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value);
} else if (value == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(bc, type_str, sizeof(type_str));
value_len = ffio_read_varlen(bc);
if (avio_tell(bc) + value_len >= maxpos)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(bc);
continue;
} else {
av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str);
avio_skip(bc, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(bc, dst, value_len);
} else if (value == -3) {
value = get_s(bc);
} else if (value == -4) {
value = ffio_read_varlen(bc);
} else if (value < -4) {
get_s(bc);
} else {
if (!strcmp(name, "SkipStart")) {
skip_start = value;
} else if (!strcmp(name, "SkipEnd")) {
skip_end = value;
} else if (!strcmp(name, "Channels")) {
channels = value;
} else if (!strcmp(name, "SampleRate")) {
sample_rate = value;
} else if (!strcmp(name, "Width")) {
width = value;
} else if (!strcmp(name, "Height")) {
height = value;
} else {
av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name);
}
}
}
if (channels || channel_layout || sample_rate || width || height) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!channels) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height))
);
if (channels)
bytestream_put_le32(&dst, channels);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (sample_rate)
bytestream_put_le32(&dst, sample_rate);
if (width || height){
bytestream_put_le32(&dst, width);
bytestream_put_le32(&dst, height);
}
}
if (skip_start || skip_end) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, skip_start);
AV_WL32(dst+4, skip_end);
}
return 0;
}
| false | FFmpeg | bb23a15df507440deb0dcf25099d321d0f73dc28 | static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
{
int count = ffio_read_varlen(bc);
int skip_start = 0;
int skip_end = 0;
int channels = 0;
int64_t channel_layout = 0;
int sample_rate = 0;
int width = 0;
int height = 0;
int i;
for (i=0; i<count; i++) {
uint8_t name[256], str_value[256], type_str[256];
int value;
if (avio_tell(bc) >= maxpos)
return AVERROR_INVALIDDATA;
get_str(bc, name, sizeof(name));
value = get_s(bc);
if (value == -1) {
get_str(bc, str_value, sizeof(str_value));
av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value);
} else if (value == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(bc, type_str, sizeof(type_str));
value_len = ffio_read_varlen(bc);
if (avio_tell(bc) + value_len >= maxpos)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(bc);
continue;
} else {
av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str);
avio_skip(bc, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(bc, dst, value_len);
} else if (value == -3) {
value = get_s(bc);
} else if (value == -4) {
value = ffio_read_varlen(bc);
} else if (value < -4) {
get_s(bc);
} else {
if (!strcmp(name, "SkipStart")) {
skip_start = value;
} else if (!strcmp(name, "SkipEnd")) {
skip_end = value;
} else if (!strcmp(name, "Channels")) {
channels = value;
} else if (!strcmp(name, "SampleRate")) {
sample_rate = value;
} else if (!strcmp(name, "Width")) {
width = value;
} else if (!strcmp(name, "Height")) {
height = value;
} else {
av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name);
}
}
}
if (channels || channel_layout || sample_rate || width || height) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!channels) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height))
);
if (channels)
bytestream_put_le32(&dst, channels);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (sample_rate)
bytestream_put_le32(&dst, sample_rate);
if (width || height){
bytestream_put_le32(&dst, width);
bytestream_put_le32(&dst, height);
}
}
if (skip_start || skip_end) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, skip_start);
AV_WL32(dst+4, skip_end);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVPacket *VAR_2, int VAR_3, int64_t VAR_4)
{
int VAR_5 = ffio_read_varlen(VAR_1);
int VAR_6 = 0;
int VAR_7 = 0;
int VAR_8 = 0;
int64_t channel_layout = 0;
int VAR_9 = 0;
int VAR_10 = 0;
int VAR_11 = 0;
int VAR_12;
for (VAR_12=0; VAR_12<VAR_5; VAR_12++) {
uint8_t name[256], str_value[256], type_str[256];
int VAR_13;
if (avio_tell(VAR_1) >= VAR_4)
return AVERROR_INVALIDDATA;
get_str(VAR_1, name, sizeof(name));
VAR_13 = get_s(VAR_1);
if (VAR_13 == -1) {
get_str(VAR_1, str_value, sizeof(str_value));
av_log(VAR_0, AV_LOG_WARNING, "Unknown string %VAR_0 / %VAR_0\n", name, str_value);
} else if (VAR_13 == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(VAR_1, type_str, sizeof(type_str));
value_len = ffio_read_varlen(VAR_1);
if (avio_tell(VAR_1) + value_len >= VAR_4)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(VAR_1);
continue;
} else {
av_log(VAR_0, AV_LOG_WARNING, "Unknown data %VAR_0 / %VAR_0\n", name, type_str);
avio_skip(VAR_1, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(VAR_1, dst, value_len);
} else if (VAR_13 == -3) {
VAR_13 = get_s(VAR_1);
} else if (VAR_13 == -4) {
VAR_13 = ffio_read_varlen(VAR_1);
} else if (VAR_13 < -4) {
get_s(VAR_1);
} else {
if (!strcmp(name, "SkipStart")) {
VAR_6 = VAR_13;
} else if (!strcmp(name, "SkipEnd")) {
VAR_7 = VAR_13;
} else if (!strcmp(name, "Channels")) {
VAR_8 = VAR_13;
} else if (!strcmp(name, "SampleRate")) {
VAR_9 = VAR_13;
} else if (!strcmp(name, "Width")) {
VAR_10 = VAR_13;
} else if (!strcmp(name, "Height")) {
VAR_11 = VAR_13;
} else {
av_log(VAR_0, AV_LOG_WARNING, "Unknown integer %VAR_0\n", name);
}
}
}
if (VAR_8 || channel_layout || VAR_9 || VAR_10 || VAR_11) {
uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!VAR_8) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!VAR_9) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(VAR_10|VAR_11))
);
if (VAR_8)
bytestream_put_le32(&dst, VAR_8);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (VAR_9)
bytestream_put_le32(&dst, VAR_9);
if (VAR_10 || VAR_11){
bytestream_put_le32(&dst, VAR_10);
bytestream_put_le32(&dst, VAR_11);
}
}
if (VAR_6 || VAR_7) {
uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, VAR_6);
AV_WL32(dst+4, VAR_7);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVPacket *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"int VAR_5 = ffio_read_varlen(VAR_1);",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"int VAR_8 = 0;",
"int64_t channel_layout = 0;",
"int VAR_9 = 0;",
"int VAR_10 = 0;",
"int VAR_11 = 0;",
"int VAR_12;",
"for (VAR_12=0; VAR_12<VAR_5; VAR_12++) {",
"uint8_t name[256], str_value[256], type_str[256];",
"int VAR_13;",
"if (avio_tell(VAR_1) >= VAR_4)\nreturn AVERROR_INVALIDDATA;",
"get_str(VAR_1, name, sizeof(name));",
"VAR_13 = get_s(VAR_1);",
"if (VAR_13 == -1) {",
"get_str(VAR_1, str_value, sizeof(str_value));",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown string %VAR_0 / %VAR_0\\n\", name, str_value);",
"} else if (VAR_13 == -2) {",
"uint8_t *dst = NULL;",
"int64_t v64, value_len;",
"get_str(VAR_1, type_str, sizeof(type_str));",
"value_len = ffio_read_varlen(VAR_1);",
"if (avio_tell(VAR_1) + value_len >= VAR_4)\nreturn AVERROR_INVALIDDATA;",
"if (!strcmp(name, \"Palette\")) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PALETTE, value_len);",
"} else if (!strcmp(name, \"Extradata\")) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_NEW_EXTRADATA, value_len);",
"} else if (sscanf(name, \"CodecSpecificSide%\"SCNd64\"\", &v64) == 1) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);",
"if(!dst)\nreturn AVERROR(ENOMEM);",
"AV_WB64(dst, v64);",
"dst += 8;",
"} else if (!strcmp(name, \"ChannelLayout\") && value_len == 8) {",
"channel_layout = avio_rl64(VAR_1);",
"continue;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown data %VAR_0 / %VAR_0\\n\", name, type_str);",
"avio_skip(VAR_1, value_len);",
"continue;",
"}",
"if(!dst)\nreturn AVERROR(ENOMEM);",
"avio_read(VAR_1, dst, value_len);",
"} else if (VAR_13 == -3) {",
"VAR_13 = get_s(VAR_1);",
"} else if (VAR_13 == -4) {",
"VAR_13 = ffio_read_varlen(VAR_1);",
"} else if (VAR_13 < -4) {",
"get_s(VAR_1);",
"} else {",
"if (!strcmp(name, \"SkipStart\")) {",
"VAR_6 = VAR_13;",
"} else if (!strcmp(name, \"SkipEnd\")) {",
"VAR_7 = VAR_13;",
"} else if (!strcmp(name, \"Channels\")) {",
"VAR_8 = VAR_13;",
"} else if (!strcmp(name, \"SampleRate\")) {",
"VAR_9 = VAR_13;",
"} else if (!strcmp(name, \"Width\")) {",
"VAR_10 = VAR_13;",
"} else if (!strcmp(name, \"Height\")) {",
"VAR_11 = VAR_13;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown integer %VAR_0\\n\", name);",
"}",
"}",
"}",
"if (VAR_8 || channel_layout || VAR_9 || VAR_10 || VAR_11) {",
"uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PARAM_CHANGE, 28);",
"if (!dst)\nreturn AVERROR(ENOMEM);",
"bytestream_put_le32(&dst,\nAV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!VAR_8) +\nAV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +\nAV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!VAR_9) +\nAV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(VAR_10|VAR_11))\n);",
"if (VAR_8)\nbytestream_put_le32(&dst, VAR_8);",
"if (channel_layout)\nbytestream_put_le64(&dst, channel_layout);",
"if (VAR_9)\nbytestream_put_le32(&dst, VAR_9);",
"if (VAR_10 || VAR_11){",
"bytestream_put_le32(&dst, VAR_10);",
"bytestream_put_le32(&dst, VAR_11);",
"}",
"}",
"if (VAR_6 || VAR_7) {",
"uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_SKIP_SAMPLES, 10);",
"if (!dst)\nreturn AVERROR(ENOMEM);",
"AV_WL32(dst, VAR_6);",
"AV_WL32(dst+4, VAR_7);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
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
],
[
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
],
[
163,
165,
167,
169,
171,
173
],
[
175,
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
]
] |
24,466 | static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
const float *la, int channel, int prev_type)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
int grouping = 0;
int uselongblock = 1;
int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
float clippings[AAC_NUM_BLOCKS_SHORT];
int i;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float hpfsmpl[AAC_BLOCK_SIZE_LONG];
float const *pf = hpfsmpl;
float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
const float *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);
int att_sum = 0;
/* LAME comment: apply high pass filter of fs/4 */
psy_hp_filter(firbuf, hpfsmpl, psy_fir_coeffs);
/* Calculate the energies of each sub-shortblock */
for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) {
energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
energy_short[0] += energy_subshort[i];
}
for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) {
float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; pf < pfe; pf++)
p = FFMAX(p, fabsf(*pf));
pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
/* NOTE: The indexes below are [i + 3 - 2] in the LAME source.
* Obviously the 3 and 2 have some significance, or this would be just [i + 1]
* (which is what we use here). What the 3 stands for is ambiguous, as it is both
* number of short blocks, and the number of sub-short blocks.
* It seems that LAME is comparing each sub-block to sub-block + 1 in the
* previous block.
*/
if (p > energy_subshort[i + 1])
p = p / energy_subshort[i + 1];
else if (energy_subshort[i + 1] > p * 10.0f)
p = energy_subshort[i + 1] / (p * 10.0f);
else
p = 0.0;
attack_intensity[i + PSY_LAME_NUM_SUBBLOCKS] = p;
}
/* compare energy between sub-short blocks */
for (i = 0; i < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; i++)
if (!attacks[i / PSY_LAME_NUM_SUBBLOCKS])
if (attack_intensity[i] > pch->attack_threshold)
attacks[i / PSY_LAME_NUM_SUBBLOCKS] = (i % PSY_LAME_NUM_SUBBLOCKS) + 1;
/* should have energy change between short blocks, in order to avoid periodic signals */
/* Good samples to show the effect are Trumpet test songs */
/* GB: tuned (1) to avoid too many short blocks for test sample TRUMPET */
/* RH: tuned (2) to let enough short blocks through for test sample FSOL and SNAPS */
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
float const u = energy_short[i - 1];
float const v = energy_short[i];
float const m = FFMAX(u, v);
if (m < 40000) { /* (2) */
if (u < 1.7f * v && v < 1.7f * u) { /* (1) */
if (i == 1 && attacks[0] < attacks[i])
attacks[0] = 0;
attacks[i] = 0;
}
}
att_sum += attacks[i];
}
if (attacks[0] <= pch->prev_attack)
attacks[0] = 0;
att_sum += attacks[0];
/* 3 below indicates the previous attack happened in the last sub-block of the previous sequence */
if (pch->prev_attack == 3 || att_sum) {
uselongblock = 0;
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++)
if (attacks[i] && attacks[i-1])
attacks[i] = 0;
}
} else {
/* We have no lookahead info, so just use same type as the previous sequence. */
uselongblock = !(prev_type == EIGHT_SHORT_SEQUENCE);
}
lame_apply_block_type(pch, &wi, uselongblock);
/* Calculate input sample maximums and evaluate clipping risk */
if (audio) {
for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) {
const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
clippings[i] = max;
}
} else {
for (i = 0; i < 8; i++)
clippings[i] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float clipping = 0.0f;
wi.num_windows = 1;
wi.grouping[0] = 1;
if (wi.window_type[0] == LONG_START_SEQUENCE)
wi.window_shape = 0;
else
wi.window_shape = 1;
for (i = 0; i < 8; i++)
clipping = FFMAX(clipping, clippings[i]);
wi.clipping[0] = clipping;
} else {
int lastgrp = 0;
wi.num_windows = 8;
wi.window_shape = 0;
for (i = 0; i < 8; i++) {
if (!((pch->next_grouping >> i) & 1))
lastgrp = i;
wi.grouping[lastgrp]++;
}
for (i = 0; i < 8; i += wi.grouping[i]) {
int w;
float clipping = 0.0f;
for (w = 0; w < wi.grouping[i]; w++)
clipping = FFMAX(clipping, clippings[i+w]);
for (w = 0; w < wi.grouping[i]; w++)
wi.clipping[i+w] = clipping;
}
}
/* Determine grouping, based on the location of the first attack, and save for
* the next frame.
* FIXME: Move this to analysis.
* TODO: Tune groupings depending on attack location
* TODO: Handle more than one attack in a group
*/
for (i = 0; i < 9; i++) {
if (attacks[i]) {
grouping = i;
break;
}
}
pch->next_grouping = window_grouping[grouping];
pch->prev_attack = attacks[8];
return wi;
}
| false | FFmpeg | 8005b6de4f88c9e3739a3a4ceda4288804788df9 | static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
const float *la, int channel, int prev_type)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
int grouping = 0;
int uselongblock = 1;
int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
float clippings[AAC_NUM_BLOCKS_SHORT];
int i;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float hpfsmpl[AAC_BLOCK_SIZE_LONG];
float const *pf = hpfsmpl;
float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
const float *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);
int att_sum = 0;
psy_hp_filter(firbuf, hpfsmpl, psy_fir_coeffs);
for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) {
energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
energy_short[0] += energy_subshort[i];
}
for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) {
float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; pf < pfe; pf++)
p = FFMAX(p, fabsf(*pf));
pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
if (p > energy_subshort[i + 1])
p = p / energy_subshort[i + 1];
else if (energy_subshort[i + 1] > p * 10.0f)
p = energy_subshort[i + 1] / (p * 10.0f);
else
p = 0.0;
attack_intensity[i + PSY_LAME_NUM_SUBBLOCKS] = p;
}
for (i = 0; i < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; i++)
if (!attacks[i / PSY_LAME_NUM_SUBBLOCKS])
if (attack_intensity[i] > pch->attack_threshold)
attacks[i / PSY_LAME_NUM_SUBBLOCKS] = (i % PSY_LAME_NUM_SUBBLOCKS) + 1;
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
float const u = energy_short[i - 1];
float const v = energy_short[i];
float const m = FFMAX(u, v);
if (m < 40000) {
if (u < 1.7f * v && v < 1.7f * u) {
if (i == 1 && attacks[0] < attacks[i])
attacks[0] = 0;
attacks[i] = 0;
}
}
att_sum += attacks[i];
}
if (attacks[0] <= pch->prev_attack)
attacks[0] = 0;
att_sum += attacks[0];
if (pch->prev_attack == 3 || att_sum) {
uselongblock = 0;
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++)
if (attacks[i] && attacks[i-1])
attacks[i] = 0;
}
} else {
uselongblock = !(prev_type == EIGHT_SHORT_SEQUENCE);
}
lame_apply_block_type(pch, &wi, uselongblock);
if (audio) {
for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) {
const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
clippings[i] = max;
}
} else {
for (i = 0; i < 8; i++)
clippings[i] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float clipping = 0.0f;
wi.num_windows = 1;
wi.grouping[0] = 1;
if (wi.window_type[0] == LONG_START_SEQUENCE)
wi.window_shape = 0;
else
wi.window_shape = 1;
for (i = 0; i < 8; i++)
clipping = FFMAX(clipping, clippings[i]);
wi.clipping[0] = clipping;
} else {
int lastgrp = 0;
wi.num_windows = 8;
wi.window_shape = 0;
for (i = 0; i < 8; i++) {
if (!((pch->next_grouping >> i) & 1))
lastgrp = i;
wi.grouping[lastgrp]++;
}
for (i = 0; i < 8; i += wi.grouping[i]) {
int w;
float clipping = 0.0f;
for (w = 0; w < wi.grouping[i]; w++)
clipping = FFMAX(clipping, clippings[i+w]);
for (w = 0; w < wi.grouping[i]; w++)
wi.clipping[i+w] = clipping;
}
}
for (i = 0; i < 9; i++) {
if (attacks[i]) {
grouping = i;
break;
}
}
pch->next_grouping = window_grouping[grouping];
pch->prev_attack = attacks[8];
return wi;
}
| {
"code": [],
"line_no": []
} | static FFPsyWindowInfo FUNC_0(FFPsyContext *ctx, const float *audio,
const float *la, int channel, int prev_type)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
int VAR_0 = 0;
int VAR_1 = 1;
int VAR_2[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
float VAR_3[AAC_NUM_BLOCKS_SHORT];
int VAR_4;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float VAR_5[AAC_BLOCK_SIZE_LONG];
float const *VAR_6 = VAR_5;
float VAR_7[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float VAR_8[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float VAR_9[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
const float *VAR_10 = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);
int VAR_11 = 0;
psy_hp_filter(VAR_10, VAR_5, psy_fir_coeffs);
for (VAR_4 = 0; VAR_4 < PSY_LAME_NUM_SUBBLOCKS; VAR_4++) {
VAR_8[VAR_4] = pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
assert(pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
VAR_7[VAR_4] = VAR_8[VAR_4] / pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
VAR_9[0] += VAR_8[VAR_4];
}
for (VAR_4 = 0; VAR_4 < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; VAR_4++) {
float const *const pfe = VAR_6 + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; VAR_6 < pfe; VAR_6++)
p = FFMAX(p, fabsf(*VAR_6));
pch->prev_energy_subshort[VAR_4] = VAR_8[VAR_4 + PSY_LAME_NUM_SUBBLOCKS] = p;
VAR_9[1 + VAR_4 / PSY_LAME_NUM_SUBBLOCKS] += p;
if (p > VAR_8[VAR_4 + 1])
p = p / VAR_8[VAR_4 + 1];
else if (VAR_8[VAR_4 + 1] > p * 10.0f)
p = VAR_8[VAR_4 + 1] / (p * 10.0f);
else
p = 0.0;
VAR_7[VAR_4 + PSY_LAME_NUM_SUBBLOCKS] = p;
}
for (VAR_4 = 0; VAR_4 < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; VAR_4++)
if (!VAR_2[VAR_4 / PSY_LAME_NUM_SUBBLOCKS])
if (VAR_7[VAR_4] > pch->attack_threshold)
VAR_2[VAR_4 / PSY_LAME_NUM_SUBBLOCKS] = (VAR_4 % PSY_LAME_NUM_SUBBLOCKS) + 1;
for (VAR_4 = 1; VAR_4 < AAC_NUM_BLOCKS_SHORT + 1; VAR_4++) {
float const u = VAR_9[VAR_4 - 1];
float const v = VAR_9[VAR_4];
float const m = FFMAX(u, v);
if (m < 40000) {
if (u < 1.7f * v && v < 1.7f * u) {
if (VAR_4 == 1 && VAR_2[0] < VAR_2[VAR_4])
VAR_2[0] = 0;
VAR_2[VAR_4] = 0;
}
}
VAR_11 += VAR_2[VAR_4];
}
if (VAR_2[0] <= pch->prev_attack)
VAR_2[0] = 0;
VAR_11 += VAR_2[0];
if (pch->prev_attack == 3 || VAR_11) {
VAR_1 = 0;
for (VAR_4 = 1; VAR_4 < AAC_NUM_BLOCKS_SHORT + 1; VAR_4++)
if (VAR_2[VAR_4] && VAR_2[VAR_4-1])
VAR_2[VAR_4] = 0;
}
} else {
VAR_1 = !(prev_type == EIGHT_SHORT_SEQUENCE);
}
lame_apply_block_type(pch, &wi, VAR_1);
if (audio) {
for (VAR_4 = 0; VAR_4 < AAC_NUM_BLOCKS_SHORT; VAR_4++) {
const float *wbuf = audio + VAR_4 * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
VAR_3[VAR_4] = max;
}
} else {
for (VAR_4 = 0; VAR_4 < 8; VAR_4++)
VAR_3[VAR_4] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float VAR_15 = 0.0f;
wi.num_windows = 1;
wi.VAR_0[0] = 1;
if (wi.window_type[0] == LONG_START_SEQUENCE)
wi.window_shape = 0;
else
wi.window_shape = 1;
for (VAR_4 = 0; VAR_4 < 8; VAR_4++)
VAR_15 = FFMAX(VAR_15, VAR_3[VAR_4]);
wi.VAR_15[0] = VAR_15;
} else {
int VAR_13 = 0;
wi.num_windows = 8;
wi.window_shape = 0;
for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {
if (!((pch->next_grouping >> VAR_4) & 1))
VAR_13 = VAR_4;
wi.VAR_0[VAR_13]++;
}
for (VAR_4 = 0; VAR_4 < 8; VAR_4 += wi.VAR_0[VAR_4]) {
int VAR_14;
float VAR_15 = 0.0f;
for (VAR_14 = 0; VAR_14 < wi.VAR_0[VAR_4]; VAR_14++)
VAR_15 = FFMAX(VAR_15, VAR_3[VAR_4+VAR_14]);
for (VAR_14 = 0; VAR_14 < wi.VAR_0[VAR_4]; VAR_14++)
wi.VAR_15[VAR_4+VAR_14] = VAR_15;
}
}
for (VAR_4 = 0; VAR_4 < 9; VAR_4++) {
if (VAR_2[VAR_4]) {
VAR_0 = VAR_4;
break;
}
}
pch->next_grouping = window_grouping[VAR_0];
pch->prev_attack = VAR_2[8];
return wi;
}
| [
"static FFPsyWindowInfo FUNC_0(FFPsyContext *ctx, const float *audio,\nconst float *la, int channel, int prev_type)\n{",
"AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;",
"AacPsyChannel *pch = &pctx->ch[channel];",
"int VAR_0 = 0;",
"int VAR_1 = 1;",
"int VAR_2[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };",
"float VAR_3[AAC_NUM_BLOCKS_SHORT];",
"int VAR_4;",
"FFPsyWindowInfo wi = { { 0 } };",
"if (la) {",
"float VAR_5[AAC_BLOCK_SIZE_LONG];",
"float const *VAR_6 = VAR_5;",
"float VAR_7[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];",
"float VAR_8[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];",
"float VAR_9[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };",
"const float *VAR_10 = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);",
"int VAR_11 = 0;",
"psy_hp_filter(VAR_10, VAR_5, psy_fir_coeffs);",
"for (VAR_4 = 0; VAR_4 < PSY_LAME_NUM_SUBBLOCKS; VAR_4++) {",
"VAR_8[VAR_4] = pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];",
"assert(pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);",
"VAR_7[VAR_4] = VAR_8[VAR_4] / pch->prev_energy_subshort[VAR_4 + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];",
"VAR_9[0] += VAR_8[VAR_4];",
"}",
"for (VAR_4 = 0; VAR_4 < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; VAR_4++) {",
"float const *const pfe = VAR_6 + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);",
"float p = 1.0f;",
"for (; VAR_6 < pfe; VAR_6++)",
"p = FFMAX(p, fabsf(*VAR_6));",
"pch->prev_energy_subshort[VAR_4] = VAR_8[VAR_4 + PSY_LAME_NUM_SUBBLOCKS] = p;",
"VAR_9[1 + VAR_4 / PSY_LAME_NUM_SUBBLOCKS] += p;",
"if (p > VAR_8[VAR_4 + 1])\np = p / VAR_8[VAR_4 + 1];",
"else if (VAR_8[VAR_4 + 1] > p * 10.0f)\np = VAR_8[VAR_4 + 1] / (p * 10.0f);",
"else\np = 0.0;",
"VAR_7[VAR_4 + PSY_LAME_NUM_SUBBLOCKS] = p;",
"}",
"for (VAR_4 = 0; VAR_4 < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; VAR_4++)",
"if (!VAR_2[VAR_4 / PSY_LAME_NUM_SUBBLOCKS])\nif (VAR_7[VAR_4] > pch->attack_threshold)\nVAR_2[VAR_4 / PSY_LAME_NUM_SUBBLOCKS] = (VAR_4 % PSY_LAME_NUM_SUBBLOCKS) + 1;",
"for (VAR_4 = 1; VAR_4 < AAC_NUM_BLOCKS_SHORT + 1; VAR_4++) {",
"float const u = VAR_9[VAR_4 - 1];",
"float const v = VAR_9[VAR_4];",
"float const m = FFMAX(u, v);",
"if (m < 40000) {",
"if (u < 1.7f * v && v < 1.7f * u) {",
"if (VAR_4 == 1 && VAR_2[0] < VAR_2[VAR_4])\nVAR_2[0] = 0;",
"VAR_2[VAR_4] = 0;",
"}",
"}",
"VAR_11 += VAR_2[VAR_4];",
"}",
"if (VAR_2[0] <= pch->prev_attack)\nVAR_2[0] = 0;",
"VAR_11 += VAR_2[0];",
"if (pch->prev_attack == 3 || VAR_11) {",
"VAR_1 = 0;",
"for (VAR_4 = 1; VAR_4 < AAC_NUM_BLOCKS_SHORT + 1; VAR_4++)",
"if (VAR_2[VAR_4] && VAR_2[VAR_4-1])\nVAR_2[VAR_4] = 0;",
"}",
"} else {",
"VAR_1 = !(prev_type == EIGHT_SHORT_SEQUENCE);",
"}",
"lame_apply_block_type(pch, &wi, VAR_1);",
"if (audio) {",
"for (VAR_4 = 0; VAR_4 < AAC_NUM_BLOCKS_SHORT; VAR_4++) {",
"const float *wbuf = audio + VAR_4 * AAC_BLOCK_SIZE_SHORT;",
"float max = 0;",
"int j;",
"for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)",
"max = FFMAX(max, fabsf(wbuf[j]));",
"VAR_3[VAR_4] = max;",
"}",
"} else {",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++)",
"VAR_3[VAR_4] = 0;",
"}",
"wi.window_type[1] = prev_type;",
"if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {",
"float VAR_15 = 0.0f;",
"wi.num_windows = 1;",
"wi.VAR_0[0] = 1;",
"if (wi.window_type[0] == LONG_START_SEQUENCE)\nwi.window_shape = 0;",
"else\nwi.window_shape = 1;",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++)",
"VAR_15 = FFMAX(VAR_15, VAR_3[VAR_4]);",
"wi.VAR_15[0] = VAR_15;",
"} else {",
"int VAR_13 = 0;",
"wi.num_windows = 8;",
"wi.window_shape = 0;",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {",
"if (!((pch->next_grouping >> VAR_4) & 1))\nVAR_13 = VAR_4;",
"wi.VAR_0[VAR_13]++;",
"}",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4 += wi.VAR_0[VAR_4]) {",
"int VAR_14;",
"float VAR_15 = 0.0f;",
"for (VAR_14 = 0; VAR_14 < wi.VAR_0[VAR_4]; VAR_14++)",
"VAR_15 = FFMAX(VAR_15, VAR_3[VAR_4+VAR_14]);",
"for (VAR_14 = 0; VAR_14 < wi.VAR_0[VAR_4]; VAR_14++)",
"wi.VAR_15[VAR_4+VAR_14] = VAR_15;",
"}",
"}",
"for (VAR_4 = 0; VAR_4 < 9; VAR_4++) {",
"if (VAR_2[VAR_4]) {",
"VAR_0 = VAR_4;",
"break;",
"}",
"}",
"pch->next_grouping = window_grouping[VAR_0];",
"pch->prev_attack = VAR_2[8];",
"return wi;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
93,
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
113
],
[
115,
117,
119
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
165
],
[
169
],
[
171
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
193
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239,
241
],
[
243,
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267,
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
329
],
[
331
]
] |
24,467 | static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
{
long y;
const long chromWidth= width>>1;
for(y=0; y<height; y++)
{
#ifdef HAVE_MMX
//FIXME handle 2 lines a once (fewer prefetch, reuse some chrom, but very likely limited by mem anyway)
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
PREFETCH" 32(%2, %%"REG_a") \n\t"
PREFETCH" 32(%3, %%"REG_a") \n\t"
"movq (%2, %%"REG_a"), %%mm0 \n\t" // U(0)
"movq %%mm0, %%mm2 \n\t" // U(0)
"movq (%3, %%"REG_a"), %%mm1 \n\t" // V(0)
"punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
"punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8)
"movq (%1, %%"REG_a",2), %%mm3 \n\t" // Y(0)
"movq 8(%1, %%"REG_a",2), %%mm5 \n\t" // Y(8)
"movq %%mm3, %%mm4 \n\t" // Y(0)
"movq %%mm5, %%mm6 \n\t" // Y(8)
"punpcklbw %%mm0, %%mm3 \n\t" // YUYV YUYV(0)
"punpckhbw %%mm0, %%mm4 \n\t" // YUYV YUYV(4)
"punpcklbw %%mm2, %%mm5 \n\t" // YUYV YUYV(8)
"punpckhbw %%mm2, %%mm6 \n\t" // YUYV YUYV(12)
MOVNTQ" %%mm3, (%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4)\n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
: "%"REG_a
);
#else
#if defined ARCH_ALPHA && defined HAVE_MVI
#define pl2yuy2(n) \
y1 = yc[n]; \
y2 = yc2[n]; \
u = uc[n]; \
v = vc[n]; \
asm("unpkbw %1, %0" : "=r"(y1) : "r"(y1)); \
asm("unpkbw %1, %0" : "=r"(y2) : "r"(y2)); \
asm("unpkbl %1, %0" : "=r"(u) : "r"(u)); \
asm("unpkbl %1, %0" : "=r"(v) : "r"(v)); \
yuv1 = (u << 8) + (v << 24); \
yuv2 = yuv1 + y2; \
yuv1 += y1; \
qdst[n] = yuv1; \
qdst2[n] = yuv2;
int i;
uint64_t *qdst = (uint64_t *) dst;
uint64_t *qdst2 = (uint64_t *) (dst + dstStride);
const uint32_t *yc = (uint32_t *) ysrc;
const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride);
const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc;
for(i = 0; i < chromWidth; i += 8){
uint64_t y1, y2, yuv1, yuv2;
uint64_t u, v;
/* Prefetch */
asm("ldq $31,64(%0)" :: "r"(yc));
asm("ldq $31,64(%0)" :: "r"(yc2));
asm("ldq $31,64(%0)" :: "r"(uc));
asm("ldq $31,64(%0)" :: "r"(vc));
pl2yuy2(0);
pl2yuy2(1);
pl2yuy2(2);
pl2yuy2(3);
yc += 4;
yc2 += 4;
uc += 4;
vc += 4;
qdst += 4;
qdst2 += 4;
}
y++;
ysrc += lumStride;
dst += dstStride;
#elif __WORDSIZE >= 64
int i;
uint64_t *ldst = (uint64_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i += 2){
uint64_t k, l;
k = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
l = yc[2] + (uc[1] << 8) +
(yc[3] << 16) + (vc[1] << 24);
*ldst++ = k + (l << 32);
yc += 4;
uc += 2;
vc += 2;
}
#else
int i, *idst = (int32_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i++){
#ifdef WORDS_BIGENDIAN
*idst++ = (yc[0] << 24)+ (uc[0] << 16) +
(yc[1] << 8) + (vc[0] << 0);
#else
*idst++ = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
#endif
if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) )
{
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
dst += dstStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| false | FFmpeg | 4bff9ef9d0781c4de228bf1f85634d2706fc589b | static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
{
long y;
const long chromWidth= width>>1;
for(y=0; y<height; y++)
{
#ifdef HAVE_MMX
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
PREFETCH" 32(%2, %%"REG_a") \n\t"
PREFETCH" 32(%3, %%"REG_a") \n\t"
"movq (%2, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq (%3, %%"REG_a"), %%mm1 \n\t"
"punpcklbw %%mm1, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm2 \n\t"
"movq (%1, %%"REG_a",2), %%mm3 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm5 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm5, %%mm6 \n\t"
"punpcklbw %%mm0, %%mm3 \n\t"
"punpckhbw %%mm0, %%mm4 \n\t"
"punpcklbw %%mm2, %%mm5 \n\t"
"punpckhbw %%mm2, %%mm6 \n\t"
MOVNTQ" %%mm3, (%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4)\n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
: "%"REG_a
);
#else
#if defined ARCH_ALPHA && defined HAVE_MVI
#define pl2yuy2(n) \
y1 = yc[n]; \
y2 = yc2[n]; \
u = uc[n]; \
v = vc[n]; \
asm("unpkbw %1, %0" : "=r"(y1) : "r"(y1)); \
asm("unpkbw %1, %0" : "=r"(y2) : "r"(y2)); \
asm("unpkbl %1, %0" : "=r"(u) : "r"(u)); \
asm("unpkbl %1, %0" : "=r"(v) : "r"(v)); \
yuv1 = (u << 8) + (v << 24); \
yuv2 = yuv1 + y2; \
yuv1 += y1; \
qdst[n] = yuv1; \
qdst2[n] = yuv2;
int i;
uint64_t *qdst = (uint64_t *) dst;
uint64_t *qdst2 = (uint64_t *) (dst + dstStride);
const uint32_t *yc = (uint32_t *) ysrc;
const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride);
const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc;
for(i = 0; i < chromWidth; i += 8){
uint64_t y1, y2, yuv1, yuv2;
uint64_t u, v;
asm("ldq $31,64(%0)" :: "r"(yc));
asm("ldq $31,64(%0)" :: "r"(yc2));
asm("ldq $31,64(%0)" :: "r"(uc));
asm("ldq $31,64(%0)" :: "r"(vc));
pl2yuy2(0);
pl2yuy2(1);
pl2yuy2(2);
pl2yuy2(3);
yc += 4;
yc2 += 4;
uc += 4;
vc += 4;
qdst += 4;
qdst2 += 4;
}
y++;
ysrc += lumStride;
dst += dstStride;
#elif __WORDSIZE >= 64
int i;
uint64_t *ldst = (uint64_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i += 2){
uint64_t k, l;
k = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
l = yc[2] + (uc[1] << 8) +
(yc[3] << 16) + (vc[1] << 24);
*ldst++ = k + (l << 32);
yc += 4;
uc += 2;
vc += 2;
}
#else
int i, *idst = (int32_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i++){
#ifdef WORDS_BIGENDIAN
*idst++ = (yc[0] << 24)+ (uc[0] << 16) +
(yc[1] << 8) + (vc[0] << 0);
#else
*idst++ = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
#endif
if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) )
{
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
dst += dstStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
{
long VAR_0;
const long VAR_1= width>>1;
for(VAR_0=0; VAR_0<height; VAR_0++)
{
#ifdef HAVE_MMX
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
PREFETCH" 32(%2, %%"REG_a") \n\t"
PREFETCH" 32(%3, %%"REG_a") \n\t"
"movq (%2, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq (%3, %%"REG_a"), %%mm1 \n\t"
"punpcklbw %%mm1, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm2 \n\t"
"movq (%1, %%"REG_a",2), %%mm3 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm5 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm5, %%mm6 \n\t"
"punpcklbw %%mm0, %%mm3 \n\t"
"punpckhbw %%mm0, %%mm4 \n\t"
"punpcklbw %%mm2, %%mm5 \n\t"
"punpckhbw %%mm2, %%mm6 \n\t"
MOVNTQ" %%mm3, (%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4)\n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (VAR_1)
: "%"REG_a
);
#else
#if defined ARCH_ALPHA && defined HAVE_MVI
#define pl2yuy2(n) \
y1 = yc[n]; \
y2 = yc2[n]; \
u = uc[n]; \
v = vc[n]; \
asm("unpkbw %1, %0" : "=r"(y1) : "r"(y1)); \
asm("unpkbw %1, %0" : "=r"(y2) : "r"(y2)); \
asm("unpkbl %1, %0" : "=r"(u) : "r"(u)); \
asm("unpkbl %1, %0" : "=r"(v) : "r"(v)); \
yuv1 = (u << 8) + (v << 24); \
yuv2 = yuv1 + y2; \
yuv1 += y1; \
qdst[n] = yuv1; \
qdst2[n] = yuv2;
int i;
uint64_t *qdst = (uint64_t *) dst;
uint64_t *qdst2 = (uint64_t *) (dst + dstStride);
const uint32_t *yc = (uint32_t *) ysrc;
const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride);
const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc;
for(i = 0; i < VAR_1; i += 8){
uint64_t y1, y2, yuv1, yuv2;
uint64_t u, v;
asm("ldq $31,64(%0)" :: "r"(yc));
asm("ldq $31,64(%0)" :: "r"(yc2));
asm("ldq $31,64(%0)" :: "r"(uc));
asm("ldq $31,64(%0)" :: "r"(vc));
pl2yuy2(0);
pl2yuy2(1);
pl2yuy2(2);
pl2yuy2(3);
yc += 4;
yc2 += 4;
uc += 4;
vc += 4;
qdst += 4;
qdst2 += 4;
}
VAR_0++;
ysrc += lumStride;
dst += dstStride;
#elif __WORDSIZE >= 64
int i;
uint64_t *ldst = (uint64_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < VAR_1; i += 2){
uint64_t k, l;
k = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
l = yc[2] + (uc[1] << 8) +
(yc[3] << 16) + (vc[1] << 24);
*ldst++ = k + (l << 32);
yc += 4;
uc += 2;
vc += 2;
}
#else
int i, *idst = (int32_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < VAR_1; i++){
#ifdef WORDS_BIGENDIAN
*idst++ = (yc[0] << 24)+ (uc[0] << 16) +
(yc[1] << 8) + (vc[0] << 0);
#else
*idst++ = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
#endif
if((VAR_0&(vertLumPerChroma-1))==(vertLumPerChroma-1) )
{
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
dst += dstStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| [
"static inline void FUNC_0(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\nlong width, long height,\nlong lumStride, long chromStride, long dstStride, long vertLumPerChroma)\n{",
"long VAR_0;",
"const long VAR_1= width>>1;",
"for(VAR_0=0; VAR_0<height; VAR_0++)",
"{",
"#ifdef HAVE_MMX\nasm volatile(\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 32(%1, %%\"REG_a\", 2)\t\\n\\t\"\nPREFETCH\" 32(%2, %%\"REG_a\")\t\\n\\t\"\nPREFETCH\" 32(%3, %%\"REG_a\")\t\\n\\t\"\n\"movq (%2, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movq %%mm0, %%mm2\t\t\\n\\t\"\n\"movq (%3, %%\"REG_a\"), %%mm1\t\\n\\t\"\n\"punpcklbw %%mm1, %%mm0\t\t\\n\\t\"\n\"punpckhbw %%mm1, %%mm2\t\t\\n\\t\"\n\"movq (%1, %%\"REG_a\",2), %%mm3\t\\n\\t\"\n\"movq 8(%1, %%\"REG_a\",2), %%mm5\t\\n\\t\"\n\"movq %%mm3, %%mm4\t\t\\n\\t\"\n\"movq %%mm5, %%mm6\t\t\\n\\t\"\n\"punpcklbw %%mm0, %%mm3\t\t\\n\\t\"\n\"punpckhbw %%mm0, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm2, %%mm5\t\t\\n\\t\"\n\"punpckhbw %%mm2, %%mm6\t\t\\n\\t\"\nMOVNTQ\" %%mm3, (%0, %%\"REG_a\", 4)\\n\\t\"\nMOVNTQ\" %%mm4, 8(%0, %%\"REG_a\", 4)\\n\\t\"\nMOVNTQ\" %%mm5, 16(%0, %%\"REG_a\", 4)\\n\\t\"\nMOVNTQ\" %%mm6, 24(%0, %%\"REG_a\", 4)\\n\\t\"\n\"add $8, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %4, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n::\"r\"(dst), \"r\"(ysrc), \"r\"(usrc), \"r\"(vsrc), \"g\" (VAR_1)\n: \"%\"REG_a\n);",
"#else\n#if defined ARCH_ALPHA && defined HAVE_MVI\n#define pl2yuy2(n)\t\t\t\t\t\\\ny1 = yc[n];\t\t\t\t\t\\",
"y2 = yc2[n];\t\t\t\t\t\\",
"u = uc[n];\t\t\t\t\t\\",
"v = vc[n];\t\t\t\t\t\\",
"asm(\"unpkbw %1, %0\" : \"=r\"(y1) : \"r\"(y1));\t\\",
"asm(\"unpkbw %1, %0\" : \"=r\"(y2) : \"r\"(y2));\t\\",
"asm(\"unpkbl %1, %0\" : \"=r\"(u) : \"r\"(u));\t\\",
"asm(\"unpkbl %1, %0\" : \"=r\"(v) : \"r\"(v));\t\\",
"yuv1 = (u << 8) + (v << 24);\t\t\t\\",
"yuv2 = yuv1 + y2;\t\t\t\t\\",
"yuv1 += y1;\t\t\t\t\t\\",
"qdst[n] = yuv1;\t\t\t\t\t\\",
"qdst2[n] = yuv2;",
"int i;",
"uint64_t *qdst = (uint64_t *) dst;",
"uint64_t *qdst2 = (uint64_t *) (dst + dstStride);",
"const uint32_t *yc = (uint32_t *) ysrc;",
"const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride);",
"const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc;",
"for(i = 0; i < VAR_1; i += 8){",
"uint64_t y1, y2, yuv1, yuv2;",
"uint64_t u, v;",
"asm(\"ldq $31,64(%0)\" :: \"r\"(yc));",
"asm(\"ldq $31,64(%0)\" :: \"r\"(yc2));",
"asm(\"ldq $31,64(%0)\" :: \"r\"(uc));",
"asm(\"ldq $31,64(%0)\" :: \"r\"(vc));",
"pl2yuy2(0);",
"pl2yuy2(1);",
"pl2yuy2(2);",
"pl2yuy2(3);",
"yc += 4;",
"yc2 += 4;",
"uc += 4;",
"vc += 4;",
"qdst += 4;",
"qdst2 += 4;",
"}",
"VAR_0++;",
"ysrc += lumStride;",
"dst += dstStride;",
"#elif __WORDSIZE >= 64\nint i;",
"uint64_t *ldst = (uint64_t *) dst;",
"const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;",
"for(i = 0; i < VAR_1; i += 2){",
"uint64_t k, l;",
"k = yc[0] + (uc[0] << 8) +\n(yc[1] << 16) + (vc[0] << 24);",
"l = yc[2] + (uc[1] << 8) +\n(yc[3] << 16) + (vc[1] << 24);",
"*ldst++ = k + (l << 32);",
"yc += 4;",
"uc += 2;",
"vc += 2;",
"}",
"#else\nint i, *idst = (int32_t *) dst;",
"const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;",
"for(i = 0; i < VAR_1; i++){",
"#ifdef WORDS_BIGENDIAN\n*idst++ = (yc[0] << 24)+ (uc[0] << 16) +\n(yc[1] << 8) + (vc[0] << 0);",
"#else\n*idst++ = yc[0] + (uc[0] << 8) +\n(yc[1] << 16) + (vc[0] << 24);",
"#endif\nyc += 2;",
"uc++;",
"vc++;",
"}",
"#endif\n#endif\nif((VAR_0&(vertLumPerChroma-1))==(vertLumPerChroma-1) )\n{",
"usrc += chromStride;",
"vsrc += chromStride;",
"}",
"ysrc += lumStride;",
"dst += dstStride;",
"}",
"#ifdef HAVE_MMX\nasm( EMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n:::\"memory\");",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
47,
49,
51,
53,
55,
57,
59,
61,
65,
67,
69,
71,
75,
77,
79,
81,
83,
85
],
[
87,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217,
219
],
[
221
],
[
223
],
[
225,
227,
229
],
[
231,
233,
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247,
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267,
269,
271,
273
],
[
275,
277
]
] |
24,468 | static int ass_get_duration(const uint8_t *p)
{
int sh, sm, ss, sc, eh, em, es, ec;
uint64_t start, end;
if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
&sh, &sm, &ss, &sc, &eh, &em, &es, &ec) != 8)
return 0;
start = 3600000 * sh + 60000 * sm + 1000 * ss + 10 * sc;
end = 3600000 * eh + 60000 * em + 1000 * es + 10 * ec;
return end - start;
}
| false | FFmpeg | 69c1fe7c9c9bc85eebfc02c6a19caf7e88cd74ff | static int ass_get_duration(const uint8_t *p)
{
int sh, sm, ss, sc, eh, em, es, ec;
uint64_t start, end;
if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
&sh, &sm, &ss, &sc, &eh, &em, &es, &ec) != 8)
return 0;
start = 3600000 * sh + 60000 * sm + 1000 * ss + 10 * sc;
end = 3600000 * eh + 60000 * em + 1000 * es + 10 * ec;
return end - start;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
uint64_t start, end;
if (sscanf(VAR_0, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
&VAR_1, &VAR_2, &VAR_3, &VAR_4, &VAR_5, &VAR_6, &VAR_7, &VAR_8) != 8)
return 0;
start = 3600000 * VAR_1 + 60000 * VAR_2 + 1000 * VAR_3 + 10 * VAR_4;
end = 3600000 * VAR_5 + 60000 * VAR_6 + 1000 * VAR_7 + 10 * VAR_8;
return end - start;
}
| [
"static int FUNC_0(const uint8_t *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"uint64_t start, end;",
"if (sscanf(VAR_0, \"%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d\",\n&VAR_1, &VAR_2, &VAR_3, &VAR_4, &VAR_5, &VAR_6, &VAR_7, &VAR_8) != 8)\nreturn 0;",
"start = 3600000 * VAR_1 + 60000 * VAR_2 + 1000 * VAR_3 + 10 * VAR_4;",
"end = 3600000 * VAR_5 + 60000 * VAR_6 + 1000 * VAR_7 + 10 * VAR_8;",
"return end - start;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,470 | static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
struct msghdr *msgh)
{
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
abi_long msg_controllen;
abi_ulong target_cmsg_addr;
struct target_cmsghdr *target_cmsg, *target_cmsg_start;
socklen_t space = 0;
msg_controllen = tswapal(target_msgh->msg_controllen);
if (msg_controllen < sizeof (struct target_cmsghdr))
goto the_end;
target_cmsg_addr = tswapal(target_msgh->msg_control);
target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
target_cmsg_start = target_cmsg;
if (!target_cmsg)
return -TARGET_EFAULT;
while (cmsg && target_cmsg) {
void *data = CMSG_DATA(cmsg);
void *target_data = TARGET_CMSG_DATA(target_cmsg);
int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));
int tgt_len, tgt_space;
/* We never copy a half-header but may copy half-data;
* this is Linux's behaviour in put_cmsg(). Note that
* truncation here is a guest problem (which we report
* to the guest via the CTRUNC bit), unlike truncation
* in target_to_host_cmsg, which is a QEMU bug.
*/
if (msg_controllen < sizeof(struct cmsghdr)) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
break;
}
if (cmsg->cmsg_level == SOL_SOCKET) {
target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET);
} else {
target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
}
target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type);
tgt_len = TARGET_CMSG_LEN(len);
/* Payload types which need a different size of payload on
* the target must adjust tgt_len here.
*/
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SO_TIMESTAMP:
tgt_len = sizeof(struct target_timeval);
break;
default:
break;
}
default:
break;
}
if (msg_controllen < tgt_len) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
tgt_len = msg_controllen;
}
/* We must now copy-and-convert len bytes of payload
* into tgt_len bytes of destination space. Bear in mind
* that in both source and destination we may be dealing
* with a truncated value!
*/
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
{
int *fd = (int *)data;
int *target_fd = (int *)target_data;
int i, numfds = tgt_len / sizeof(int);
for (i = 0; i < numfds; i++) {
__put_user(fd[i], target_fd + i);
}
break;
}
case SO_TIMESTAMP:
{
struct timeval *tv = (struct timeval *)data;
struct target_timeval *target_tv =
(struct target_timeval *)target_data;
if (len != sizeof(struct timeval) ||
tgt_len != sizeof(struct target_timeval)) {
goto unimplemented;
}
/* copy struct timeval to target */
__put_user(tv->tv_sec, &target_tv->tv_sec);
__put_user(tv->tv_usec, &target_tv->tv_usec);
break;
}
case SCM_CREDENTIALS:
{
struct ucred *cred = (struct ucred *)data;
struct target_ucred *target_cred =
(struct target_ucred *)target_data;
__put_user(cred->pid, &target_cred->pid);
__put_user(cred->uid, &target_cred->uid);
__put_user(cred->gid, &target_cred->gid);
break;
}
default:
goto unimplemented;
}
break;
case SOL_IP:
switch (cmsg->cmsg_type) {
case IP_TTL:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IP_RECVERR:
{
struct errhdr_t {
struct sock_extended_err ee;
struct sockaddr_in offender;
};
struct errhdr_t *errh = (struct errhdr_t *)data;
struct errhdr_t *target_errh =
(struct errhdr_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
case SOL_IPV6:
switch (cmsg->cmsg_type) {
case IPV6_HOPLIMIT:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IPV6_RECVERR:
{
struct errhdr6_t {
struct sock_extended_err ee;
struct sockaddr_in6 offender;
};
struct errhdr6_t *errh = (struct errhdr6_t *)data;
struct errhdr6_t *target_errh =
(struct errhdr6_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
default:
unimplemented:
gemu_log("Unsupported ancillary data: %d/%d\n",
cmsg->cmsg_level, cmsg->cmsg_type);
memcpy(target_data, data, MIN(len, tgt_len));
if (tgt_len > len) {
memset(target_data + len, 0, tgt_len - len);
}
}
target_cmsg->cmsg_len = tswapal(tgt_len);
tgt_space = TARGET_CMSG_SPACE(len);
if (msg_controllen < tgt_space) {
tgt_space = msg_controllen;
}
msg_controllen -= tgt_space;
space += tgt_space;
cmsg = CMSG_NXTHDR(msgh, cmsg);
target_cmsg = TARGET_CMSG_NXTHDR(target_msgh, target_cmsg,
target_cmsg_start);
}
unlock_user(target_cmsg, target_cmsg_addr, space);
the_end:
target_msgh->msg_controllen = tswapal(space);
return 0;
}
| true | qemu | 7174970a94df10ee84143edc7c94a2472d654604 | static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
struct msghdr *msgh)
{
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
abi_long msg_controllen;
abi_ulong target_cmsg_addr;
struct target_cmsghdr *target_cmsg, *target_cmsg_start;
socklen_t space = 0;
msg_controllen = tswapal(target_msgh->msg_controllen);
if (msg_controllen < sizeof (struct target_cmsghdr))
goto the_end;
target_cmsg_addr = tswapal(target_msgh->msg_control);
target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
target_cmsg_start = target_cmsg;
if (!target_cmsg)
return -TARGET_EFAULT;
while (cmsg && target_cmsg) {
void *data = CMSG_DATA(cmsg);
void *target_data = TARGET_CMSG_DATA(target_cmsg);
int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));
int tgt_len, tgt_space;
if (msg_controllen < sizeof(struct cmsghdr)) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
break;
}
if (cmsg->cmsg_level == SOL_SOCKET) {
target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET);
} else {
target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
}
target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type);
tgt_len = TARGET_CMSG_LEN(len);
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SO_TIMESTAMP:
tgt_len = sizeof(struct target_timeval);
break;
default:
break;
}
default:
break;
}
if (msg_controllen < tgt_len) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
tgt_len = msg_controllen;
}
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
{
int *fd = (int *)data;
int *target_fd = (int *)target_data;
int i, numfds = tgt_len / sizeof(int);
for (i = 0; i < numfds; i++) {
__put_user(fd[i], target_fd + i);
}
break;
}
case SO_TIMESTAMP:
{
struct timeval *tv = (struct timeval *)data;
struct target_timeval *target_tv =
(struct target_timeval *)target_data;
if (len != sizeof(struct timeval) ||
tgt_len != sizeof(struct target_timeval)) {
goto unimplemented;
}
__put_user(tv->tv_sec, &target_tv->tv_sec);
__put_user(tv->tv_usec, &target_tv->tv_usec);
break;
}
case SCM_CREDENTIALS:
{
struct ucred *cred = (struct ucred *)data;
struct target_ucred *target_cred =
(struct target_ucred *)target_data;
__put_user(cred->pid, &target_cred->pid);
__put_user(cred->uid, &target_cred->uid);
__put_user(cred->gid, &target_cred->gid);
break;
}
default:
goto unimplemented;
}
break;
case SOL_IP:
switch (cmsg->cmsg_type) {
case IP_TTL:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IP_RECVERR:
{
struct errhdr_t {
struct sock_extended_err ee;
struct sockaddr_in offender;
};
struct errhdr_t *errh = (struct errhdr_t *)data;
struct errhdr_t *target_errh =
(struct errhdr_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
case SOL_IPV6:
switch (cmsg->cmsg_type) {
case IPV6_HOPLIMIT:
{
uint32_t *v = (uint32_t *)data;
uint32_t *t_int = (uint32_t *)target_data;
__put_user(*v, t_int);
break;
}
case IPV6_RECVERR:
{
struct errhdr6_t {
struct sock_extended_err ee;
struct sockaddr_in6 offender;
};
struct errhdr6_t *errh = (struct errhdr6_t *)data;
struct errhdr6_t *target_errh =
(struct errhdr6_t *)target_data;
__put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
__put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad);
__put_user(errh->ee.ee_info, &target_errh->ee.ee_info);
__put_user(errh->ee.ee_data, &target_errh->ee.ee_data);
host_to_target_sockaddr((unsigned long) &target_errh->offender,
(void *) &errh->offender, sizeof(errh->offender));
break;
}
default:
goto unimplemented;
}
break;
default:
unimplemented:
gemu_log("Unsupported ancillary data: %d/%d\n",
cmsg->cmsg_level, cmsg->cmsg_type);
memcpy(target_data, data, MIN(len, tgt_len));
if (tgt_len > len) {
memset(target_data + len, 0, tgt_len - len);
}
}
target_cmsg->cmsg_len = tswapal(tgt_len);
tgt_space = TARGET_CMSG_SPACE(len);
if (msg_controllen < tgt_space) {
tgt_space = msg_controllen;
}
msg_controllen -= tgt_space;
space += tgt_space;
cmsg = CMSG_NXTHDR(msgh, cmsg);
target_cmsg = TARGET_CMSG_NXTHDR(target_msgh, target_cmsg,
target_cmsg_start);
}
unlock_user(target_cmsg, target_cmsg_addr, space);
the_end:
target_msgh->msg_controllen = tswapal(space);
return 0;
}
| {
"code": [
" if (msg_controllen < sizeof(struct cmsghdr)) {",
" tgt_len = TARGET_CMSG_LEN(len);",
" if (msg_controllen < tgt_len) {",
" tgt_len = msg_controllen;",
" target_cmsg->cmsg_len = tswapal(tgt_len);",
" tgt_space = TARGET_CMSG_SPACE(len);"
],
"line_no": [
63,
87,
123,
127,
399,
401
]
} | static inline abi_long FUNC_0(struct target_msghdr *target_msgh,
struct msghdr *msgh)
{
struct cmsghdr *VAR_0 = CMSG_FIRSTHDR(msgh);
abi_long msg_controllen;
abi_ulong target_cmsg_addr;
struct target_cmsghdr *VAR_1, *VAR_2;
socklen_t space = 0;
msg_controllen = tswapal(target_msgh->msg_controllen);
if (msg_controllen < sizeof (struct target_cmsghdr))
goto the_end;
target_cmsg_addr = tswapal(target_msgh->msg_control);
VAR_1 = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);
VAR_2 = VAR_1;
if (!VAR_1)
return -TARGET_EFAULT;
while (VAR_0 && VAR_1) {
void *VAR_3 = CMSG_DATA(VAR_0);
void *VAR_4 = TARGET_CMSG_DATA(VAR_1);
int VAR_5 = VAR_0->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));
int VAR_6, VAR_7;
if (msg_controllen < sizeof(struct cmsghdr)) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
break;
}
if (VAR_0->cmsg_level == SOL_SOCKET) {
VAR_1->cmsg_level = tswap32(TARGET_SOL_SOCKET);
} else {
VAR_1->cmsg_level = tswap32(VAR_0->cmsg_level);
}
VAR_1->cmsg_type = tswap32(VAR_0->cmsg_type);
VAR_6 = TARGET_CMSG_LEN(VAR_5);
switch (VAR_0->cmsg_level) {
case SOL_SOCKET:
switch (VAR_0->cmsg_type) {
case SO_TIMESTAMP:
VAR_6 = sizeof(struct target_timeval);
break;
default:
break;
}
default:
break;
}
if (msg_controllen < VAR_6) {
target_msgh->msg_flags |= tswap32(MSG_CTRUNC);
VAR_6 = msg_controllen;
}
switch (VAR_0->cmsg_level) {
case SOL_SOCKET:
switch (VAR_0->cmsg_type) {
case SCM_RIGHTS:
{
int *VAR_8 = (int *)VAR_3;
int *VAR_9 = (int *)VAR_4;
int VAR_10, VAR_11 = VAR_6 / sizeof(int);
for (VAR_10 = 0; VAR_10 < VAR_11; VAR_10++) {
__put_user(VAR_8[VAR_10], VAR_9 + VAR_10);
}
break;
}
case SO_TIMESTAMP:
{
struct timeval *VAR_12 = (struct timeval *)VAR_3;
struct target_timeval *VAR_13 =
(struct target_timeval *)VAR_4;
if (VAR_5 != sizeof(struct timeval) ||
VAR_6 != sizeof(struct target_timeval)) {
goto unimplemented;
}
__put_user(VAR_12->tv_sec, &VAR_13->tv_sec);
__put_user(VAR_12->tv_usec, &VAR_13->tv_usec);
break;
}
case SCM_CREDENTIALS:
{
struct ucred *VAR_14 = (struct ucred *)VAR_3;
struct target_ucred *VAR_15 =
(struct target_ucred *)VAR_4;
__put_user(VAR_14->pid, &VAR_15->pid);
__put_user(VAR_14->uid, &VAR_15->uid);
__put_user(VAR_14->gid, &VAR_15->gid);
break;
}
default:
goto unimplemented;
}
break;
case SOL_IP:
switch (VAR_0->cmsg_type) {
case IP_TTL:
{
uint32_t *v = (uint32_t *)VAR_3;
uint32_t *t_int = (uint32_t *)VAR_4;
__put_user(*v, t_int);
break;
}
case IP_RECVERR:
{
struct errhdr_t {
struct sock_extended_err ee;
struct sockaddr_in offender;
};
struct errhdr_t *VAR_18 = (struct errhdr_t *)VAR_3;
struct errhdr_t *VAR_18 =
(struct errhdr_t *)VAR_4;
__put_user(VAR_18->ee.ee_errno, &VAR_18->ee.ee_errno);
__put_user(VAR_18->ee.ee_origin, &VAR_18->ee.ee_origin);
__put_user(VAR_18->ee.ee_type, &VAR_18->ee.ee_type);
__put_user(VAR_18->ee.ee_code, &VAR_18->ee.ee_code);
__put_user(VAR_18->ee.ee_pad, &VAR_18->ee.ee_pad);
__put_user(VAR_18->ee.ee_info, &VAR_18->ee.ee_info);
__put_user(VAR_18->ee.ee_data, &VAR_18->ee.ee_data);
host_to_target_sockaddr((unsigned long) &VAR_18->offender,
(void *) &VAR_18->offender, sizeof(VAR_18->offender));
break;
}
default:
goto unimplemented;
}
break;
case SOL_IPV6:
switch (VAR_0->cmsg_type) {
case IPV6_HOPLIMIT:
{
uint32_t *v = (uint32_t *)VAR_3;
uint32_t *t_int = (uint32_t *)VAR_4;
__put_user(*v, t_int);
break;
}
case IPV6_RECVERR:
{
struct errhdr6_t {
struct sock_extended_err ee;
struct sockaddr_in6 offender;
};
struct errhdr6_t *VAR_18 = (struct errhdr6_t *)VAR_3;
struct errhdr6_t *VAR_18 =
(struct errhdr6_t *)VAR_4;
__put_user(VAR_18->ee.ee_errno, &VAR_18->ee.ee_errno);
__put_user(VAR_18->ee.ee_origin, &VAR_18->ee.ee_origin);
__put_user(VAR_18->ee.ee_type, &VAR_18->ee.ee_type);
__put_user(VAR_18->ee.ee_code, &VAR_18->ee.ee_code);
__put_user(VAR_18->ee.ee_pad, &VAR_18->ee.ee_pad);
__put_user(VAR_18->ee.ee_info, &VAR_18->ee.ee_info);
__put_user(VAR_18->ee.ee_data, &VAR_18->ee.ee_data);
host_to_target_sockaddr((unsigned long) &VAR_18->offender,
(void *) &VAR_18->offender, sizeof(VAR_18->offender));
break;
}
default:
goto unimplemented;
}
break;
default:
unimplemented:
gemu_log("Unsupported ancillary VAR_3: %d/%d\n",
VAR_0->cmsg_level, VAR_0->cmsg_type);
memcpy(VAR_4, VAR_3, MIN(VAR_5, VAR_6));
if (VAR_6 > VAR_5) {
memset(VAR_4 + VAR_5, 0, VAR_6 - VAR_5);
}
}
VAR_1->cmsg_len = tswapal(VAR_6);
VAR_7 = TARGET_CMSG_SPACE(VAR_5);
if (msg_controllen < VAR_7) {
VAR_7 = msg_controllen;
}
msg_controllen -= VAR_7;
space += VAR_7;
VAR_0 = CMSG_NXTHDR(msgh, VAR_0);
VAR_1 = TARGET_CMSG_NXTHDR(target_msgh, VAR_1,
VAR_2);
}
unlock_user(VAR_1, target_cmsg_addr, space);
the_end:
target_msgh->msg_controllen = tswapal(space);
return 0;
}
| [
"static inline abi_long FUNC_0(struct target_msghdr *target_msgh,\nstruct msghdr *msgh)\n{",
"struct cmsghdr *VAR_0 = CMSG_FIRSTHDR(msgh);",
"abi_long msg_controllen;",
"abi_ulong target_cmsg_addr;",
"struct target_cmsghdr *VAR_1, *VAR_2;",
"socklen_t space = 0;",
"msg_controllen = tswapal(target_msgh->msg_controllen);",
"if (msg_controllen < sizeof (struct target_cmsghdr))\ngoto the_end;",
"target_cmsg_addr = tswapal(target_msgh->msg_control);",
"VAR_1 = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0);",
"VAR_2 = VAR_1;",
"if (!VAR_1)\nreturn -TARGET_EFAULT;",
"while (VAR_0 && VAR_1) {",
"void *VAR_3 = CMSG_DATA(VAR_0);",
"void *VAR_4 = TARGET_CMSG_DATA(VAR_1);",
"int VAR_5 = VAR_0->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));",
"int VAR_6, VAR_7;",
"if (msg_controllen < sizeof(struct cmsghdr)) {",
"target_msgh->msg_flags |= tswap32(MSG_CTRUNC);",
"break;",
"}",
"if (VAR_0->cmsg_level == SOL_SOCKET) {",
"VAR_1->cmsg_level = tswap32(TARGET_SOL_SOCKET);",
"} else {",
"VAR_1->cmsg_level = tswap32(VAR_0->cmsg_level);",
"}",
"VAR_1->cmsg_type = tswap32(VAR_0->cmsg_type);",
"VAR_6 = TARGET_CMSG_LEN(VAR_5);",
"switch (VAR_0->cmsg_level) {",
"case SOL_SOCKET:\nswitch (VAR_0->cmsg_type) {",
"case SO_TIMESTAMP:\nVAR_6 = sizeof(struct target_timeval);",
"break;",
"default:\nbreak;",
"}",
"default:\nbreak;",
"}",
"if (msg_controllen < VAR_6) {",
"target_msgh->msg_flags |= tswap32(MSG_CTRUNC);",
"VAR_6 = msg_controllen;",
"}",
"switch (VAR_0->cmsg_level) {",
"case SOL_SOCKET:\nswitch (VAR_0->cmsg_type) {",
"case SCM_RIGHTS:\n{",
"int *VAR_8 = (int *)VAR_3;",
"int *VAR_9 = (int *)VAR_4;",
"int VAR_10, VAR_11 = VAR_6 / sizeof(int);",
"for (VAR_10 = 0; VAR_10 < VAR_11; VAR_10++) {",
"__put_user(VAR_8[VAR_10], VAR_9 + VAR_10);",
"}",
"break;",
"}",
"case SO_TIMESTAMP:\n{",
"struct timeval *VAR_12 = (struct timeval *)VAR_3;",
"struct target_timeval *VAR_13 =\n(struct target_timeval *)VAR_4;",
"if (VAR_5 != sizeof(struct timeval) ||\nVAR_6 != sizeof(struct target_timeval)) {",
"goto unimplemented;",
"}",
"__put_user(VAR_12->tv_sec, &VAR_13->tv_sec);",
"__put_user(VAR_12->tv_usec, &VAR_13->tv_usec);",
"break;",
"}",
"case SCM_CREDENTIALS:\n{",
"struct ucred *VAR_14 = (struct ucred *)VAR_3;",
"struct target_ucred *VAR_15 =\n(struct target_ucred *)VAR_4;",
"__put_user(VAR_14->pid, &VAR_15->pid);",
"__put_user(VAR_14->uid, &VAR_15->uid);",
"__put_user(VAR_14->gid, &VAR_15->gid);",
"break;",
"}",
"default:\ngoto unimplemented;",
"}",
"break;",
"case SOL_IP:\nswitch (VAR_0->cmsg_type) {",
"case IP_TTL:\n{",
"uint32_t *v = (uint32_t *)VAR_3;",
"uint32_t *t_int = (uint32_t *)VAR_4;",
"__put_user(*v, t_int);",
"break;",
"}",
"case IP_RECVERR:\n{",
"struct errhdr_t {",
"struct sock_extended_err ee;",
"struct sockaddr_in offender;",
"};",
"struct errhdr_t *VAR_18 = (struct errhdr_t *)VAR_3;",
"struct errhdr_t *VAR_18 =\n(struct errhdr_t *)VAR_4;",
"__put_user(VAR_18->ee.ee_errno, &VAR_18->ee.ee_errno);",
"__put_user(VAR_18->ee.ee_origin, &VAR_18->ee.ee_origin);",
"__put_user(VAR_18->ee.ee_type, &VAR_18->ee.ee_type);",
"__put_user(VAR_18->ee.ee_code, &VAR_18->ee.ee_code);",
"__put_user(VAR_18->ee.ee_pad, &VAR_18->ee.ee_pad);",
"__put_user(VAR_18->ee.ee_info, &VAR_18->ee.ee_info);",
"__put_user(VAR_18->ee.ee_data, &VAR_18->ee.ee_data);",
"host_to_target_sockaddr((unsigned long) &VAR_18->offender,\n(void *) &VAR_18->offender, sizeof(VAR_18->offender));",
"break;",
"}",
"default:\ngoto unimplemented;",
"}",
"break;",
"case SOL_IPV6:\nswitch (VAR_0->cmsg_type) {",
"case IPV6_HOPLIMIT:\n{",
"uint32_t *v = (uint32_t *)VAR_3;",
"uint32_t *t_int = (uint32_t *)VAR_4;",
"__put_user(*v, t_int);",
"break;",
"}",
"case IPV6_RECVERR:\n{",
"struct errhdr6_t {",
"struct sock_extended_err ee;",
"struct sockaddr_in6 offender;",
"};",
"struct errhdr6_t *VAR_18 = (struct errhdr6_t *)VAR_3;",
"struct errhdr6_t *VAR_18 =\n(struct errhdr6_t *)VAR_4;",
"__put_user(VAR_18->ee.ee_errno, &VAR_18->ee.ee_errno);",
"__put_user(VAR_18->ee.ee_origin, &VAR_18->ee.ee_origin);",
"__put_user(VAR_18->ee.ee_type, &VAR_18->ee.ee_type);",
"__put_user(VAR_18->ee.ee_code, &VAR_18->ee.ee_code);",
"__put_user(VAR_18->ee.ee_pad, &VAR_18->ee.ee_pad);",
"__put_user(VAR_18->ee.ee_info, &VAR_18->ee.ee_info);",
"__put_user(VAR_18->ee.ee_data, &VAR_18->ee.ee_data);",
"host_to_target_sockaddr((unsigned long) &VAR_18->offender,\n(void *) &VAR_18->offender, sizeof(VAR_18->offender));",
"break;",
"}",
"default:\ngoto unimplemented;",
"}",
"break;",
"default:\nunimplemented:\ngemu_log(\"Unsupported ancillary VAR_3: %d/%d\\n\",\nVAR_0->cmsg_level, VAR_0->cmsg_type);",
"memcpy(VAR_4, VAR_3, MIN(VAR_5, VAR_6));",
"if (VAR_6 > VAR_5) {",
"memset(VAR_4 + VAR_5, 0, VAR_6 - VAR_5);",
"}",
"}",
"VAR_1->cmsg_len = tswapal(VAR_6);",
"VAR_7 = TARGET_CMSG_SPACE(VAR_5);",
"if (msg_controllen < VAR_7) {",
"VAR_7 = msg_controllen;",
"}",
"msg_controllen -= VAR_7;",
"space += VAR_7;",
"VAR_0 = CMSG_NXTHDR(msgh, VAR_0);",
"VAR_1 = TARGET_CMSG_NXTHDR(target_msgh, VAR_1,\nVAR_2);",
"}",
"unlock_user(VAR_1, target_cmsg_addr, space);",
"the_end:\ntarget_msgh->msg_controllen = tswapal(space);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
97
],
[
99,
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179
],
[
183,
185
],
[
187
],
[
189
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209,
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
235,
237
],
[
239,
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269,
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297,
299
],
[
301
],
[
303
],
[
307,
309
],
[
311,
313
],
[
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
367
],
[
369,
371
],
[
373
],
[
375
],
[
379,
381,
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
419
],
[
421
],
[
423,
425
],
[
427
],
[
429
]
] |
24,473 | static void ib700_pc_init(PCIBus *unused)
{
register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL);
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL);
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL);
}
| true | qemu | 09aaa1602f9381c0e0fb539390b1793e51bdfc7b | static void ib700_pc_init(PCIBus *unused)
{
register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL);
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL);
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL);
}
| {
"code": [
"static void ib700_pc_init(PCIBus *unused)"
],
"line_no": [
1
]
} | static void FUNC_0(PCIBus *VAR_0)
{
register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL);
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL);
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL);
}
| [
"static void FUNC_0(PCIBus *VAR_0)\n{",
"register_savevm(\"ib700_wdt\", -1, 0, ib700_save, ib700_load, NULL);",
"register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL);",
"register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL);",
"}"
] | [
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
24,474 | static int vscsi_srp_indirect_data(VSCSIState *s, vscsi_req *req,
uint8_t *buf, uint32_t len)
{
struct srp_direct_buf *td = &req->ind_desc->table_desc;
struct srp_direct_buf *md = req->cur_desc;
int rc = 0;
uint32_t llen, total = 0;
dprintf("VSCSI: indirect segment 0x%x bytes, td va=0x%llx len=0x%x\n",
len, (unsigned long long)td->va, td->len);
/* While we have data ... */
while (len) {
/* If we have a descriptor but it's empty, go fetch a new one */
if (md && md->len == 0) {
/* More local available, use one */
if (req->local_desc) {
md = ++req->cur_desc;
--req->local_desc;
--req->total_desc;
td->va += sizeof(struct srp_direct_buf);
} else {
md = req->cur_desc = NULL;
}
}
/* No descriptor at hand, fetch one */
if (!md) {
if (!req->total_desc) {
dprintf("VSCSI: Out of descriptors !\n");
break;
}
md = req->cur_desc = &req->ext_desc;
dprintf("VSCSI: Reading desc from 0x%llx\n",
(unsigned long long)td->va);
rc = spapr_tce_dma_read(&s->vdev, td->va, md,
sizeof(struct srp_direct_buf));
if (rc) {
dprintf("VSCSI: tce_dma_read -> %d reading ext_desc\n", rc);
break;
}
vscsi_swap_desc(md);
td->va += sizeof(struct srp_direct_buf);
--req->total_desc;
}
dprintf("VSCSI: [desc va=0x%llx,len=0x%x] remaining=0x%x\n",
(unsigned long long)md->va, md->len, len);
/* Perform transfer */
llen = MIN(len, md->len);
if (req->writing) { /* writing = to device = reading from memory */
rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);
} else {
rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);
}
if (rc) {
dprintf("VSCSI: tce_dma_r/w(%d) -> %d\n", req->writing, rc);
break;
}
dprintf("VSCSI: data: %02x %02x %02x %02x...\n",
buf[0], buf[1], buf[2], buf[3]);
len -= llen;
buf += llen;
total += llen;
md->va += llen;
md->len -= llen;
}
return rc ? -1 : total;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | static int vscsi_srp_indirect_data(VSCSIState *s, vscsi_req *req,
uint8_t *buf, uint32_t len)
{
struct srp_direct_buf *td = &req->ind_desc->table_desc;
struct srp_direct_buf *md = req->cur_desc;
int rc = 0;
uint32_t llen, total = 0;
dprintf("VSCSI: indirect segment 0x%x bytes, td va=0x%llx len=0x%x\n",
len, (unsigned long long)td->va, td->len);
while (len) {
if (md && md->len == 0) {
if (req->local_desc) {
md = ++req->cur_desc;
--req->local_desc;
--req->total_desc;
td->va += sizeof(struct srp_direct_buf);
} else {
md = req->cur_desc = NULL;
}
}
if (!md) {
if (!req->total_desc) {
dprintf("VSCSI: Out of descriptors !\n");
break;
}
md = req->cur_desc = &req->ext_desc;
dprintf("VSCSI: Reading desc from 0x%llx\n",
(unsigned long long)td->va);
rc = spapr_tce_dma_read(&s->vdev, td->va, md,
sizeof(struct srp_direct_buf));
if (rc) {
dprintf("VSCSI: tce_dma_read -> %d reading ext_desc\n", rc);
break;
}
vscsi_swap_desc(md);
td->va += sizeof(struct srp_direct_buf);
--req->total_desc;
}
dprintf("VSCSI: [desc va=0x%llx,len=0x%x] remaining=0x%x\n",
(unsigned long long)md->va, md->len, len);
llen = MIN(len, md->len);
if (req->writing) {
rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);
} else {
rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);
}
if (rc) {
dprintf("VSCSI: tce_dma_r/w(%d) -> %d\n", req->writing, rc);
break;
}
dprintf("VSCSI: data: %02x %02x %02x %02x...\n",
buf[0], buf[1], buf[2], buf[3]);
len -= llen;
buf += llen;
total += llen;
md->va += llen;
md->len -= llen;
}
return rc ? -1 : total;
}
| {
"code": [
" rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);",
" rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);",
" rc = spapr_tce_dma_read(&s->vdev, td->va, md,",
" dprintf(\"VSCSI: tce_dma_read -> %d reading ext_desc\\n\", rc);",
" rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);",
" rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);",
" dprintf(\"VSCSI: tce_dma_r/w(%d) -> %d\\n\", req->writing, rc);"
],
"line_no": [
101,
105,
69,
75,
101,
105,
111
]
} | static int FUNC_0(VSCSIState *VAR_0, vscsi_req *VAR_1,
uint8_t *VAR_2, uint32_t VAR_3)
{
struct srp_direct_buf *VAR_4 = &VAR_1->ind_desc->table_desc;
struct srp_direct_buf *VAR_5 = VAR_1->cur_desc;
int VAR_6 = 0;
uint32_t llen, total = 0;
dprintf("VSCSI: indirect segment 0x%x bytes, VAR_4 va=0x%llx VAR_3=0x%x\n",
VAR_3, (unsigned long long)VAR_4->va, VAR_4->VAR_3);
while (VAR_3) {
if (VAR_5 && VAR_5->VAR_3 == 0) {
if (VAR_1->local_desc) {
VAR_5 = ++VAR_1->cur_desc;
--VAR_1->local_desc;
--VAR_1->total_desc;
VAR_4->va += sizeof(struct srp_direct_buf);
} else {
VAR_5 = VAR_1->cur_desc = NULL;
}
}
if (!VAR_5) {
if (!VAR_1->total_desc) {
dprintf("VSCSI: Out of descriptors !\n");
break;
}
VAR_5 = VAR_1->cur_desc = &VAR_1->ext_desc;
dprintf("VSCSI: Reading desc from 0x%llx\n",
(unsigned long long)VAR_4->va);
VAR_6 = spapr_tce_dma_read(&VAR_0->vdev, VAR_4->va, VAR_5,
sizeof(struct srp_direct_buf));
if (VAR_6) {
dprintf("VSCSI: tce_dma_read -> %d reading ext_desc\n", VAR_6);
break;
}
vscsi_swap_desc(VAR_5);
VAR_4->va += sizeof(struct srp_direct_buf);
--VAR_1->total_desc;
}
dprintf("VSCSI: [desc va=0x%llx,VAR_3=0x%x] remaining=0x%x\n",
(unsigned long long)VAR_5->va, VAR_5->VAR_3, VAR_3);
llen = MIN(VAR_3, VAR_5->VAR_3);
if (VAR_1->writing) {
VAR_6 = spapr_tce_dma_read(&VAR_0->vdev, VAR_5->va, VAR_2, llen);
} else {
VAR_6 = spapr_tce_dma_write(&VAR_0->vdev, VAR_5->va, VAR_2, llen);
}
if (VAR_6) {
dprintf("VSCSI: tce_dma_r/w(%d) -> %d\n", VAR_1->writing, VAR_6);
break;
}
dprintf("VSCSI: data: %02x %02x %02x %02x...\n",
VAR_2[0], VAR_2[1], VAR_2[2], VAR_2[3]);
VAR_3 -= llen;
VAR_2 += llen;
total += llen;
VAR_5->va += llen;
VAR_5->VAR_3 -= llen;
}
return VAR_6 ? -1 : total;
}
| [
"static int FUNC_0(VSCSIState *VAR_0, vscsi_req *VAR_1,\nuint8_t *VAR_2, uint32_t VAR_3)\n{",
"struct srp_direct_buf *VAR_4 = &VAR_1->ind_desc->table_desc;",
"struct srp_direct_buf *VAR_5 = VAR_1->cur_desc;",
"int VAR_6 = 0;",
"uint32_t llen, total = 0;",
"dprintf(\"VSCSI: indirect segment 0x%x bytes, VAR_4 va=0x%llx VAR_3=0x%x\\n\",\nVAR_3, (unsigned long long)VAR_4->va, VAR_4->VAR_3);",
"while (VAR_3) {",
"if (VAR_5 && VAR_5->VAR_3 == 0) {",
"if (VAR_1->local_desc) {",
"VAR_5 = ++VAR_1->cur_desc;",
"--VAR_1->local_desc;",
"--VAR_1->total_desc;",
"VAR_4->va += sizeof(struct srp_direct_buf);",
"} else {",
"VAR_5 = VAR_1->cur_desc = NULL;",
"}",
"}",
"if (!VAR_5) {",
"if (!VAR_1->total_desc) {",
"dprintf(\"VSCSI: Out of descriptors !\\n\");",
"break;",
"}",
"VAR_5 = VAR_1->cur_desc = &VAR_1->ext_desc;",
"dprintf(\"VSCSI: Reading desc from 0x%llx\\n\",\n(unsigned long long)VAR_4->va);",
"VAR_6 = spapr_tce_dma_read(&VAR_0->vdev, VAR_4->va, VAR_5,\nsizeof(struct srp_direct_buf));",
"if (VAR_6) {",
"dprintf(\"VSCSI: tce_dma_read -> %d reading ext_desc\\n\", VAR_6);",
"break;",
"}",
"vscsi_swap_desc(VAR_5);",
"VAR_4->va += sizeof(struct srp_direct_buf);",
"--VAR_1->total_desc;",
"}",
"dprintf(\"VSCSI: [desc va=0x%llx,VAR_3=0x%x] remaining=0x%x\\n\",\n(unsigned long long)VAR_5->va, VAR_5->VAR_3, VAR_3);",
"llen = MIN(VAR_3, VAR_5->VAR_3);",
"if (VAR_1->writing) {",
"VAR_6 = spapr_tce_dma_read(&VAR_0->vdev, VAR_5->va, VAR_2, llen);",
"} else {",
"VAR_6 = spapr_tce_dma_write(&VAR_0->vdev, VAR_5->va, VAR_2, llen);",
"}",
"if (VAR_6) {",
"dprintf(\"VSCSI: tce_dma_r/w(%d) -> %d\\n\", VAR_1->writing, VAR_6);",
"break;",
"}",
"dprintf(\"VSCSI: data: %02x %02x %02x %02x...\\n\",\nVAR_2[0], VAR_2[1], VAR_2[2], VAR_2[3]);",
"VAR_3 -= llen;",
"VAR_2 += llen;",
"total += llen;",
"VAR_5->va += llen;",
"VAR_5->VAR_3 -= llen;",
"}",
"return VAR_6 ? -1 : total;",
"}"
] | [
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,
0,
0,
0,
1,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
24,475 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
BinkAudioContext *s = avctx->priv_data;
AVFrame *frame = data;
GetBitContext *gb = &s->gb;
int ret, consumed = 0;
if (!get_bits_left(gb)) {
uint8_t *buf;
/* handle end-of-stream */
if (!avpkt->size) {
*got_frame_ptr = 0;
return 0;
}
if (avpkt->size < 4) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf)
return AVERROR(ENOMEM);
s->packet_buffer = buf;
memcpy(s->packet_buffer, avpkt->data, avpkt->size);
if ((ret = init_get_bits8(gb, s->packet_buffer, avpkt->size)) < 0)
return ret;
consumed = avpkt->size;
/* skip reported size */
skip_bits_long(gb, 32);
}
/* get output buffer */
frame->nb_samples = s->frame_len;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (decode_block(s, (float **)frame->extended_data,
avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {
av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
return AVERROR_INVALIDDATA;
}
get_bits_align32(gb);
frame->nb_samples = s->block_size / avctx->channels;
*got_frame_ptr = 1;
return consumed;
} | true | FFmpeg | 07728a111583be6865b7ce2adea705af9d207588 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
BinkAudioContext *s = avctx->priv_data;
AVFrame *frame = data;
GetBitContext *gb = &s->gb;
int ret, consumed = 0;
if (!get_bits_left(gb)) {
uint8_t *buf;
if (!avpkt->size) {
*got_frame_ptr = 0;
return 0;
}
if (avpkt->size < 4) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf)
return AVERROR(ENOMEM);
s->packet_buffer = buf;
memcpy(s->packet_buffer, avpkt->data, avpkt->size);
if ((ret = init_get_bits8(gb, s->packet_buffer, avpkt->size)) < 0)
return ret;
consumed = avpkt->size;
skip_bits_long(gb, 32);
}
frame->nb_samples = s->frame_len;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (decode_block(s, (float **)frame->extended_data,
avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {
av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
return AVERROR_INVALIDDATA;
}
get_bits_align32(gb);
frame->nb_samples = s->block_size / avctx->channels;
*got_frame_ptr = 1;
return consumed;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
BinkAudioContext *s = VAR_0->priv_data;
AVFrame *frame = VAR_1;
GetBitContext *gb = &s->gb;
int VAR_4, VAR_5 = 0;
if (!get_bits_left(gb)) {
uint8_t *buf;
if (!VAR_3->size) {
*VAR_2 = 0;
return 0;
}
if (VAR_3->size < 4) {
av_log(VAR_0, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
buf = av_realloc(s->packet_buffer, VAR_3->size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf)
return AVERROR(ENOMEM);
s->packet_buffer = buf;
memcpy(s->packet_buffer, VAR_3->VAR_1, VAR_3->size);
if ((VAR_4 = init_get_bits8(gb, s->packet_buffer, VAR_3->size)) < 0)
return VAR_4;
VAR_5 = VAR_3->size;
skip_bits_long(gb, 32);
}
frame->nb_samples = s->frame_len;
if ((VAR_4 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_4;
if (decode_block(s, (float **)frame->extended_data,
VAR_0->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {
av_log(VAR_0, AV_LOG_ERROR, "Incomplete packet\n");
return AVERROR_INVALIDDATA;
}
get_bits_align32(gb);
frame->nb_samples = s->block_size / VAR_0->channels;
*VAR_2 = 1;
return VAR_5;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"BinkAudioContext *s = VAR_0->priv_data;",
"AVFrame *frame = VAR_1;",
"GetBitContext *gb = &s->gb;",
"int VAR_4, VAR_5 = 0;",
"if (!get_bits_left(gb)) {",
"uint8_t *buf;",
"if (!VAR_3->size) {",
"*VAR_2 = 0;",
"return 0;",
"}",
"if (VAR_3->size < 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet is too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"buf = av_realloc(s->packet_buffer, VAR_3->size + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!buf)\nreturn AVERROR(ENOMEM);",
"s->packet_buffer = buf;",
"memcpy(s->packet_buffer, VAR_3->VAR_1, VAR_3->size);",
"if ((VAR_4 = init_get_bits8(gb, s->packet_buffer, VAR_3->size)) < 0)\nreturn VAR_4;",
"VAR_5 = VAR_3->size;",
"skip_bits_long(gb, 32);",
"}",
"frame->nb_samples = s->frame_len;",
"if ((VAR_4 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_4;",
"if (decode_block(s, (float **)frame->extended_data,\nVAR_0->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Incomplete packet\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"get_bits_align32(gb);",
"frame->nb_samples = s->block_size / VAR_0->channels;",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
46
],
[
48
],
[
50,
52
],
[
54
],
[
60
],
[
62
],
[
68
],
[
70,
72
],
[
76,
78
],
[
80
],
[
82
],
[
84
],
[
86
],
[
90
],
[
92
],
[
96
],
[
98
]
] |
24,476 | static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_slice) {
uint8_t *state= &h->cabac_state[ctx_base];
int mb_type;
if(intra_slice){
MpegEncContext * const s = &h->s;
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx=0;
if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) )
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) )
ctx++;
if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 )
return 0; /* I4x4 */
state += 2;
}else{
if( get_cabac_noinline( &h->cabac, state ) == 0 )
return 0; /* I4x4 */
}
if( get_cabac_terminate( &h->cabac ) )
return 25; /* PCM */
mb_type = 1; /* I16x16 */
mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] ); /* cbp_luma != 0 */
if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */
mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] );
mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] );
mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] );
return mb_type;
}
| false | FFmpeg | 5806e8cd1f60c67d936fa44dd4421428489503f5 | static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_slice) {
uint8_t *state= &h->cabac_state[ctx_base];
int mb_type;
if(intra_slice){
MpegEncContext * const s = &h->s;
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx=0;
if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) )
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) )
ctx++;
if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 )
return 0;
state += 2;
}else{
if( get_cabac_noinline( &h->cabac, state ) == 0 )
return 0;
}
if( get_cabac_terminate( &h->cabac ) )
return 25;
mb_type = 1;
mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] );
if( get_cabac_noinline( &h->cabac, &state[2] ) )
mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] );
mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] );
mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] );
return mb_type;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0, int VAR_1, int VAR_2) {
uint8_t *state= &VAR_0->cabac_state[VAR_1];
int VAR_3;
if(VAR_2){
MpegEncContext * const s = &VAR_0->s;
const int VAR_4 = VAR_0->left_mb_xy[0];
const int VAR_5 = VAR_0->top_mb_xy;
int VAR_6=0;
if( VAR_0->slice_table[VAR_4] == VAR_0->slice_num && !IS_INTRA4x4( s->current_picture.VAR_3[VAR_4] ) )
VAR_6++;
if( VAR_0->slice_table[VAR_5] == VAR_0->slice_num && !IS_INTRA4x4( s->current_picture.VAR_3[VAR_5] ) )
VAR_6++;
if( get_cabac_noinline( &VAR_0->cabac, &state[VAR_6] ) == 0 )
return 0;
state += 2;
}else{
if( get_cabac_noinline( &VAR_0->cabac, state ) == 0 )
return 0;
}
if( get_cabac_terminate( &VAR_0->cabac ) )
return 25;
VAR_3 = 1;
VAR_3 += 12 * get_cabac_noinline( &VAR_0->cabac, &state[1] );
if( get_cabac_noinline( &VAR_0->cabac, &state[2] ) )
VAR_3 += 4 + 4 * get_cabac_noinline( &VAR_0->cabac, &state[2+VAR_2] );
VAR_3 += 2 * get_cabac_noinline( &VAR_0->cabac, &state[3+VAR_2] );
VAR_3 += 1 * get_cabac_noinline( &VAR_0->cabac, &state[3+2*VAR_2] );
return VAR_3;
}
| [
"static int FUNC_0(H264Context *VAR_0, int VAR_1, int VAR_2) {",
"uint8_t *state= &VAR_0->cabac_state[VAR_1];",
"int VAR_3;",
"if(VAR_2){",
"MpegEncContext * const s = &VAR_0->s;",
"const int VAR_4 = VAR_0->left_mb_xy[0];",
"const int VAR_5 = VAR_0->top_mb_xy;",
"int VAR_6=0;",
"if( VAR_0->slice_table[VAR_4] == VAR_0->slice_num && !IS_INTRA4x4( s->current_picture.VAR_3[VAR_4] ) )\nVAR_6++;",
"if( VAR_0->slice_table[VAR_5] == VAR_0->slice_num && !IS_INTRA4x4( s->current_picture.VAR_3[VAR_5] ) )\nVAR_6++;",
"if( get_cabac_noinline( &VAR_0->cabac, &state[VAR_6] ) == 0 )\nreturn 0;",
"state += 2;",
"}else{",
"if( get_cabac_noinline( &VAR_0->cabac, state ) == 0 )\nreturn 0;",
"}",
"if( get_cabac_terminate( &VAR_0->cabac ) )\nreturn 25;",
"VAR_3 = 1;",
"VAR_3 += 12 * get_cabac_noinline( &VAR_0->cabac, &state[1] );",
"if( get_cabac_noinline( &VAR_0->cabac, &state[2] ) )\nVAR_3 += 4 + 4 * get_cabac_noinline( &VAR_0->cabac, &state[2+VAR_2] );",
"VAR_3 += 2 * get_cabac_noinline( &VAR_0->cabac, &state[3+VAR_2] );",
"VAR_3 += 1 * get_cabac_noinline( &VAR_0->cabac, &state[3+2*VAR_2] );",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
24,477 | static int decode_p_picture_header(VC9Context *v)
{
/* INTERFRM, FRMCNT, RANGEREDFRM read in caller */
int lowquant, pqindex;
pqindex = get_bits(&v->gb, 5);
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = pquant_table[0][pqindex];
else
{
v->pq = pquant_table[v->quantizer_mode-1][pqindex];
}
if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1);
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits(&v->gb, 1);
av_log(v->avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n",
v->pq, v->halfpq);
if (v->extended_mv == 1) v->mvrange = get_prefix(&v->gb, 0, 3);
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
if (v->postprocflag) v->postproc = get_bits(&v->gb, 1);
}
else
#endif
if (v->multires) v->respic = get_bits(&v->gb, 2);
lowquant = (v->pquantizer>12) ? 0 : 1;
v->mv_mode = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 4)];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP)
{
v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 3)];
v->lumscale = get_bits(&v->gb, 6);
v->lumshift = get_bits(&v->gb, 6);
}
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV)
|| v->mv_mode == MV_PMODE_MIXED_MV)
{
if (bitplane_decoding(v->mv_type_mb_plane, v->width_mb,
v->height_mb, v) < 0)
return -1;
}
if (bitplane_decoding(v->skip_mb_plane, v->width_mb,
v->height_mb, v) < 0)
return -1;
/* Hopefully this is correct for P frames */
v->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&v->gb, 2)];
v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&v->gb, 2)];
if (v->dquant)
{
av_log(v->avctx, AV_LOG_INFO, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
if (v->vstransform)
{
v->ttmbf = get_bits(&v->gb, 1);
if (v->ttmbf)
{
v->ttfrm = get_bits(&v->gb, 2);
av_log(v->avctx, AV_LOG_INFO, "Transform used: %ix%i\n",
(v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8);
}
}
/* Epilog should be done in caller */
return 0;
}
| false | FFmpeg | e5540b3fd30367ce3cc33b2f34a04b660dbc4b38 | static int decode_p_picture_header(VC9Context *v)
{
int lowquant, pqindex;
pqindex = get_bits(&v->gb, 5);
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = pquant_table[0][pqindex];
else
{
v->pq = pquant_table[v->quantizer_mode-1][pqindex];
}
if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1);
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits(&v->gb, 1);
av_log(v->avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n",
v->pq, v->halfpq);
if (v->extended_mv == 1) v->mvrange = get_prefix(&v->gb, 0, 3);
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
if (v->postprocflag) v->postproc = get_bits(&v->gb, 1);
}
else
#endif
if (v->multires) v->respic = get_bits(&v->gb, 2);
lowquant = (v->pquantizer>12) ? 0 : 1;
v->mv_mode = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 4)];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP)
{
v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 3)];
v->lumscale = get_bits(&v->gb, 6);
v->lumshift = get_bits(&v->gb, 6);
}
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV)
|| v->mv_mode == MV_PMODE_MIXED_MV)
{
if (bitplane_decoding(v->mv_type_mb_plane, v->width_mb,
v->height_mb, v) < 0)
return -1;
}
if (bitplane_decoding(v->skip_mb_plane, v->width_mb,
v->height_mb, v) < 0)
return -1;
v->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&v->gb, 2)];
v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&v->gb, 2)];
if (v->dquant)
{
av_log(v->avctx, AV_LOG_INFO, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
if (v->vstransform)
{
v->ttmbf = get_bits(&v->gb, 1);
if (v->ttmbf)
{
v->ttfrm = get_bits(&v->gb, 2);
av_log(v->avctx, AV_LOG_INFO, "Transform used: %ix%i\n",
(v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VC9Context *VAR_0)
{
int VAR_1, VAR_2;
VAR_2 = get_bits(&VAR_0->gb, 5);
if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)
VAR_0->pq = pquant_table[0][VAR_2];
else
{
VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_2];
}
if (VAR_2 < 9) VAR_0->halfpq = get_bits(&VAR_0->gb, 1);
if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)
VAR_0->pquantizer = get_bits(&VAR_0->gb, 1);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n",
VAR_0->pq, VAR_0->halfpq);
if (VAR_0->extended_mv == 1) VAR_0->mvrange = get_prefix(&VAR_0->gb, 0, 3);
#if HAS_ADVANCED_PROFILE
if (VAR_0->profile > PROFILE_MAIN)
{
if (VAR_0->postprocflag) VAR_0->postproc = get_bits(&VAR_0->gb, 1);
}
else
#endif
if (VAR_0->multires) VAR_0->respic = get_bits(&VAR_0->gb, 2);
VAR_1 = (VAR_0->pquantizer>12) ? 0 : 1;
VAR_0->mv_mode = mv_pmode_table[VAR_1][get_prefix(&VAR_0->gb, 1, 4)];
if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)
{
VAR_0->mv_mode2 = mv_pmode_table[VAR_1][get_prefix(&VAR_0->gb, 1, 3)];
VAR_0->lumscale = get_bits(&VAR_0->gb, 6);
VAR_0->lumshift = get_bits(&VAR_0->gb, 6);
}
if ((VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP &&
VAR_0->mv_mode2 == MV_PMODE_MIXED_MV)
|| VAR_0->mv_mode == MV_PMODE_MIXED_MV)
{
if (bitplane_decoding(VAR_0->mv_type_mb_plane, VAR_0->width_mb,
VAR_0->height_mb, VAR_0) < 0)
return -1;
}
if (bitplane_decoding(VAR_0->skip_mb_plane, VAR_0->width_mb,
VAR_0->height_mb, VAR_0) < 0)
return -1;
VAR_0->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&VAR_0->gb, 2)];
VAR_0->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&VAR_0->gb, 2)];
if (VAR_0->dquant)
{
av_log(VAR_0->avctx, AV_LOG_INFO, "VOP DQuant info\n");
vop_dquant_decoding(VAR_0);
}
if (VAR_0->vstransform)
{
VAR_0->ttmbf = get_bits(&VAR_0->gb, 1);
if (VAR_0->ttmbf)
{
VAR_0->ttfrm = get_bits(&VAR_0->gb, 2);
av_log(VAR_0->avctx, AV_LOG_INFO, "Transform used: %ix%i\n",
(VAR_0->ttfrm & 2) ? 4 : 8, (VAR_0->ttfrm & 1) ? 4 : 8);
}
}
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"int VAR_1, VAR_2;",
"VAR_2 = get_bits(&VAR_0->gb, 5);",
"if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)\nVAR_0->pq = pquant_table[0][VAR_2];",
"else\n{",
"VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_2];",
"}",
"if (VAR_2 < 9) VAR_0->halfpq = get_bits(&VAR_0->gb, 1);",
"if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)\nVAR_0->pquantizer = get_bits(&VAR_0->gb, 1);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"P Frame: QP=%i (+%i/2)\\n\",\nVAR_0->pq, VAR_0->halfpq);",
"if (VAR_0->extended_mv == 1) VAR_0->mvrange = get_prefix(&VAR_0->gb, 0, 3);",
"#if HAS_ADVANCED_PROFILE\nif (VAR_0->profile > PROFILE_MAIN)\n{",
"if (VAR_0->postprocflag) VAR_0->postproc = get_bits(&VAR_0->gb, 1);",
"}",
"else\n#endif\nif (VAR_0->multires) VAR_0->respic = get_bits(&VAR_0->gb, 2);",
"VAR_1 = (VAR_0->pquantizer>12) ? 0 : 1;",
"VAR_0->mv_mode = mv_pmode_table[VAR_1][get_prefix(&VAR_0->gb, 1, 4)];",
"if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)\n{",
"VAR_0->mv_mode2 = mv_pmode_table[VAR_1][get_prefix(&VAR_0->gb, 1, 3)];",
"VAR_0->lumscale = get_bits(&VAR_0->gb, 6);",
"VAR_0->lumshift = get_bits(&VAR_0->gb, 6);",
"}",
"if ((VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP &&\nVAR_0->mv_mode2 == MV_PMODE_MIXED_MV)\n|| VAR_0->mv_mode == MV_PMODE_MIXED_MV)\n{",
"if (bitplane_decoding(VAR_0->mv_type_mb_plane, VAR_0->width_mb,\nVAR_0->height_mb, VAR_0) < 0)\nreturn -1;",
"}",
"if (bitplane_decoding(VAR_0->skip_mb_plane, VAR_0->width_mb,\nVAR_0->height_mb, VAR_0) < 0)\nreturn -1;",
"VAR_0->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&VAR_0->gb, 2)];",
"VAR_0->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&VAR_0->gb, 2)];",
"if (VAR_0->dquant)\n{",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"VOP DQuant info\\n\");",
"vop_dquant_decoding(VAR_0);",
"}",
"if (VAR_0->vstransform)\n{",
"VAR_0->ttmbf = get_bits(&VAR_0->gb, 1);",
"if (VAR_0->ttmbf)\n{",
"VAR_0->ttfrm = get_bits(&VAR_0->gb, 2);",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"Transform used: %ix%i\\n\",\n(VAR_0->ttfrm & 2) ? 4 : 8, (VAR_0->ttfrm & 1) ? 4 : 8);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73,
75,
77
],
[
79,
81,
83
],
[
85
],
[
89,
91,
93
],
[
99
],
[
101
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
139
],
[
141
]
] |
24,479 | void ff_avg_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2,
stride, dst, stride, 8, 0);
}
| false | FFmpeg | 72dbc610be3272ba36603f78a39cc2d2d8fe0cc3 | void ff_avg_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2,
stride, dst, stride, 8, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2, 8, 0);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_midh_qrt_and_aver_dst_8w_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2, 8, 0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
24,480 | static void sbr_hf_assemble(float Y[2][38][64][2], const float X_high[64][40][2],
SpectralBandReplication *sbr, SBRData *ch_data,
const int e_a[2])
{
int e, i, j, m;
const int h_SL = 4 * !sbr->bs_smoothing_mode;
const int kx = sbr->kx[1];
const int m_max = sbr->m[1];
static const float h_smooth[5] = {
0.33333333333333,
0.30150283239582,
0.21816949906249,
0.11516383427084,
0.03183050093751,
};
static const int8_t phi[2][4] = {
{ 1, 0, -1, 0}, // real
{ 0, 1, 0, -1}, // imaginary
};
float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp;
int indexnoise = ch_data->f_indexnoise;
int indexsine = ch_data->f_indexsine;
memcpy(Y[0], Y[1], sizeof(Y[0]));
if (sbr->reset) {
for (i = 0; i < h_SL; i++) {
memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0]));
}
} else if (h_SL) {
memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0]));
memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
}
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
int phi_sign = (1 - 2*(kx & 1));
if (h_SL && e != e_a[0] && e != e_a[1]) {
for (m = 0; m < m_max; m++) {
const int idx1 = i + h_SL;
float g_filt = 0.0f;
for (j = 0; j <= h_SL; j++)
g_filt += g_temp[idx1 - j][m] * h_smooth[j];
Y[1][i][m + kx][0] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
Y[1][i][m + kx][1] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
} else {
for (m = 0; m < m_max; m++) {
const float g_filt = g_temp[i + h_SL][m];
Y[1][i][m + kx][0] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
Y[1][i][m + kx][1] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
}
if (e != e_a[0] && e != e_a[1]) {
for (m = 0; m < m_max; m++) {
indexnoise = (indexnoise + 1) & 0x1ff;
if (sbr->s_m[e][m]) {
Y[1][i][m + kx][0] +=
sbr->s_m[e][m] * phi[0][indexsine];
Y[1][i][m + kx][1] +=
sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign);
} else {
float q_filt;
if (h_SL) {
const int idx1 = i + h_SL;
q_filt = 0.0f;
for (j = 0; j <= h_SL; j++)
q_filt += q_temp[idx1 - j][m] * h_smooth[j];
} else {
q_filt = q_temp[i][m];
}
Y[1][i][m + kx][0] +=
q_filt * sbr_noise_table[indexnoise][0];
Y[1][i][m + kx][1] +=
q_filt * sbr_noise_table[indexnoise][1];
}
phi_sign = -phi_sign;
}
} else {
indexnoise = (indexnoise + m_max) & 0x1ff;
for (m = 0; m < m_max; m++) {
Y[1][i][m + kx][0] +=
sbr->s_m[e][m] * phi[0][indexsine];
Y[1][i][m + kx][1] +=
sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign);
phi_sign = -phi_sign;
}
}
indexsine = (indexsine + 1) & 3;
}
}
ch_data->f_indexnoise = indexnoise;
ch_data->f_indexsine = indexsine;
}
| false | FFmpeg | aac46e088d67a390489af686b846dea4987d8ffb | static void sbr_hf_assemble(float Y[2][38][64][2], const float X_high[64][40][2],
SpectralBandReplication *sbr, SBRData *ch_data,
const int e_a[2])
{
int e, i, j, m;
const int h_SL = 4 * !sbr->bs_smoothing_mode;
const int kx = sbr->kx[1];
const int m_max = sbr->m[1];
static const float h_smooth[5] = {
0.33333333333333,
0.30150283239582,
0.21816949906249,
0.11516383427084,
0.03183050093751,
};
static const int8_t phi[2][4] = {
{ 1, 0, -1, 0},
{ 0, 1, 0, -1},
};
float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp;
int indexnoise = ch_data->f_indexnoise;
int indexsine = ch_data->f_indexsine;
memcpy(Y[0], Y[1], sizeof(Y[0]));
if (sbr->reset) {
for (i = 0; i < h_SL; i++) {
memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0]));
}
} else if (h_SL) {
memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0]));
memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
}
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
int phi_sign = (1 - 2*(kx & 1));
if (h_SL && e != e_a[0] && e != e_a[1]) {
for (m = 0; m < m_max; m++) {
const int idx1 = i + h_SL;
float g_filt = 0.0f;
for (j = 0; j <= h_SL; j++)
g_filt += g_temp[idx1 - j][m] * h_smooth[j];
Y[1][i][m + kx][0] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
Y[1][i][m + kx][1] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
} else {
for (m = 0; m < m_max; m++) {
const float g_filt = g_temp[i + h_SL][m];
Y[1][i][m + kx][0] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
Y[1][i][m + kx][1] =
X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
}
if (e != e_a[0] && e != e_a[1]) {
for (m = 0; m < m_max; m++) {
indexnoise = (indexnoise + 1) & 0x1ff;
if (sbr->s_m[e][m]) {
Y[1][i][m + kx][0] +=
sbr->s_m[e][m] * phi[0][indexsine];
Y[1][i][m + kx][1] +=
sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign);
} else {
float q_filt;
if (h_SL) {
const int idx1 = i + h_SL;
q_filt = 0.0f;
for (j = 0; j <= h_SL; j++)
q_filt += q_temp[idx1 - j][m] * h_smooth[j];
} else {
q_filt = q_temp[i][m];
}
Y[1][i][m + kx][0] +=
q_filt * sbr_noise_table[indexnoise][0];
Y[1][i][m + kx][1] +=
q_filt * sbr_noise_table[indexnoise][1];
}
phi_sign = -phi_sign;
}
} else {
indexnoise = (indexnoise + m_max) & 0x1ff;
for (m = 0; m < m_max; m++) {
Y[1][i][m + kx][0] +=
sbr->s_m[e][m] * phi[0][indexsine];
Y[1][i][m + kx][1] +=
sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign);
phi_sign = -phi_sign;
}
}
indexsine = (indexsine + 1) & 3;
}
}
ch_data->f_indexnoise = indexnoise;
ch_data->f_indexsine = indexsine;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(float VAR_0[2][38][64][2], const float VAR_1[64][40][2],
SpectralBandReplication *VAR_2, SBRData *VAR_3,
const int VAR_4[2])
{
int VAR_5, VAR_6, VAR_7, VAR_8;
const int VAR_9 = 4 * !VAR_2->bs_smoothing_mode;
const int VAR_10 = VAR_2->VAR_10[1];
const int VAR_11 = VAR_2->VAR_8[1];
static const float VAR_12[5] = {
0.33333333333333,
0.30150283239582,
0.21816949906249,
0.11516383427084,
0.03183050093751,
};
static const int8_t VAR_13[2][4] = {
{ 1, 0, -1, 0},
{ 0, 1, 0, -1},
};
float (*VAR_14)[48] = VAR_3->VAR_14, (*VAR_15)[48] = VAR_3->VAR_15;
int VAR_16 = VAR_3->f_indexnoise;
int VAR_17 = VAR_3->f_indexsine;
memcpy(VAR_0[0], VAR_0[1], sizeof(VAR_0[0]));
if (VAR_2->reset) {
for (VAR_6 = 0; VAR_6 < VAR_9; VAR_6++) {
memcpy(VAR_14[VAR_6 + 2*VAR_3->t_env[0]], VAR_2->gain[0], VAR_11 * sizeof(VAR_2->gain[0][0]));
memcpy(VAR_15[VAR_6 + 2*VAR_3->t_env[0]], VAR_2->q_m[0], VAR_11 * sizeof(VAR_2->q_m[0][0]));
}
} else if (VAR_9) {
memcpy(VAR_14[2*VAR_3->t_env[0]], VAR_14[2*VAR_3->t_env_num_env_old], 4*sizeof(VAR_14[0]));
memcpy(VAR_15[2*VAR_3->t_env[0]], VAR_15[2*VAR_3->t_env_num_env_old], 4*sizeof(VAR_15[0]));
}
for (VAR_5 = 0; VAR_5 < VAR_3->bs_num_env; VAR_5++) {
for (VAR_6 = 2 * VAR_3->t_env[VAR_5]; VAR_6 < 2 * VAR_3->t_env[VAR_5 + 1]; VAR_6++) {
memcpy(VAR_14[VAR_9 + VAR_6], VAR_2->gain[VAR_5], VAR_11 * sizeof(VAR_2->gain[0][0]));
memcpy(VAR_15[VAR_9 + VAR_6], VAR_2->q_m[VAR_5], VAR_11 * sizeof(VAR_2->q_m[0][0]));
}
}
for (VAR_5 = 0; VAR_5 < VAR_3->bs_num_env; VAR_5++) {
for (VAR_6 = 2 * VAR_3->t_env[VAR_5]; VAR_6 < 2 * VAR_3->t_env[VAR_5 + 1]; VAR_6++) {
int phi_sign = (1 - 2*(VAR_10 & 1));
if (VAR_9 && VAR_5 != VAR_4[0] && VAR_5 != VAR_4[1]) {
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
const int idx1 = VAR_6 + VAR_9;
float g_filt = 0.0f;
for (VAR_7 = 0; VAR_7 <= VAR_9; VAR_7++)
g_filt += VAR_14[idx1 - VAR_7][VAR_8] * VAR_12[VAR_7];
VAR_0[1][VAR_6][VAR_8 + VAR_10][0] =
VAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
VAR_0[1][VAR_6][VAR_8 + VAR_10][1] =
VAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
} else {
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
const float g_filt = VAR_14[VAR_6 + VAR_9][VAR_8];
VAR_0[1][VAR_6][VAR_8 + VAR_10][0] =
VAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;
VAR_0[1][VAR_6][VAR_8 + VAR_10][1] =
VAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;
}
}
if (VAR_5 != VAR_4[0] && VAR_5 != VAR_4[1]) {
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
VAR_16 = (VAR_16 + 1) & 0x1ff;
if (VAR_2->s_m[VAR_5][VAR_8]) {
VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=
VAR_2->s_m[VAR_5][VAR_8] * VAR_13[0][VAR_17];
VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=
VAR_2->s_m[VAR_5][VAR_8] * (VAR_13[1][VAR_17] * phi_sign);
} else {
float q_filt;
if (VAR_9) {
const int idx1 = VAR_6 + VAR_9;
q_filt = 0.0f;
for (VAR_7 = 0; VAR_7 <= VAR_9; VAR_7++)
q_filt += VAR_15[idx1 - VAR_7][VAR_8] * VAR_12[VAR_7];
} else {
q_filt = VAR_15[VAR_6][VAR_8];
}
VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=
q_filt * sbr_noise_table[VAR_16][0];
VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=
q_filt * sbr_noise_table[VAR_16][1];
}
phi_sign = -phi_sign;
}
} else {
VAR_16 = (VAR_16 + VAR_11) & 0x1ff;
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=
VAR_2->s_m[VAR_5][VAR_8] * VAR_13[0][VAR_17];
VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=
VAR_2->s_m[VAR_5][VAR_8] * (VAR_13[1][VAR_17] * phi_sign);
phi_sign = -phi_sign;
}
}
VAR_17 = (VAR_17 + 1) & 3;
}
}
VAR_3->f_indexnoise = VAR_16;
VAR_3->f_indexsine = VAR_17;
}
| [
"static void FUNC_0(float VAR_0[2][38][64][2], const float VAR_1[64][40][2],\nSpectralBandReplication *VAR_2, SBRData *VAR_3,\nconst int VAR_4[2])\n{",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"const int VAR_9 = 4 * !VAR_2->bs_smoothing_mode;",
"const int VAR_10 = VAR_2->VAR_10[1];",
"const int VAR_11 = VAR_2->VAR_8[1];",
"static const float VAR_12[5] = {",
"0.33333333333333,\n0.30150283239582,\n0.21816949906249,\n0.11516383427084,\n0.03183050093751,\n};",
"static const int8_t VAR_13[2][4] = {",
"{ 1, 0, -1, 0},",
"{ 0, 1, 0, -1},",
"};",
"float (*VAR_14)[48] = VAR_3->VAR_14, (*VAR_15)[48] = VAR_3->VAR_15;",
"int VAR_16 = VAR_3->f_indexnoise;",
"int VAR_17 = VAR_3->f_indexsine;",
"memcpy(VAR_0[0], VAR_0[1], sizeof(VAR_0[0]));",
"if (VAR_2->reset) {",
"for (VAR_6 = 0; VAR_6 < VAR_9; VAR_6++) {",
"memcpy(VAR_14[VAR_6 + 2*VAR_3->t_env[0]], VAR_2->gain[0], VAR_11 * sizeof(VAR_2->gain[0][0]));",
"memcpy(VAR_15[VAR_6 + 2*VAR_3->t_env[0]], VAR_2->q_m[0], VAR_11 * sizeof(VAR_2->q_m[0][0]));",
"}",
"} else if (VAR_9) {",
"memcpy(VAR_14[2*VAR_3->t_env[0]], VAR_14[2*VAR_3->t_env_num_env_old], 4*sizeof(VAR_14[0]));",
"memcpy(VAR_15[2*VAR_3->t_env[0]], VAR_15[2*VAR_3->t_env_num_env_old], 4*sizeof(VAR_15[0]));",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_3->bs_num_env; VAR_5++) {",
"for (VAR_6 = 2 * VAR_3->t_env[VAR_5]; VAR_6 < 2 * VAR_3->t_env[VAR_5 + 1]; VAR_6++) {",
"memcpy(VAR_14[VAR_9 + VAR_6], VAR_2->gain[VAR_5], VAR_11 * sizeof(VAR_2->gain[0][0]));",
"memcpy(VAR_15[VAR_9 + VAR_6], VAR_2->q_m[VAR_5], VAR_11 * sizeof(VAR_2->q_m[0][0]));",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_3->bs_num_env; VAR_5++) {",
"for (VAR_6 = 2 * VAR_3->t_env[VAR_5]; VAR_6 < 2 * VAR_3->t_env[VAR_5 + 1]; VAR_6++) {",
"int phi_sign = (1 - 2*(VAR_10 & 1));",
"if (VAR_9 && VAR_5 != VAR_4[0] && VAR_5 != VAR_4[1]) {",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"const int idx1 = VAR_6 + VAR_9;",
"float g_filt = 0.0f;",
"for (VAR_7 = 0; VAR_7 <= VAR_9; VAR_7++)",
"g_filt += VAR_14[idx1 - VAR_7][VAR_8] * VAR_12[VAR_7];",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][0] =\nVAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][1] =\nVAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;",
"}",
"} else {",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"const float g_filt = VAR_14[VAR_6 + VAR_9][VAR_8];",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][0] =\nVAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt;",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][1] =\nVAR_1[VAR_8 + VAR_10][VAR_6 + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt;",
"}",
"}",
"if (VAR_5 != VAR_4[0] && VAR_5 != VAR_4[1]) {",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"VAR_16 = (VAR_16 + 1) & 0x1ff;",
"if (VAR_2->s_m[VAR_5][VAR_8]) {",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=\nVAR_2->s_m[VAR_5][VAR_8] * VAR_13[0][VAR_17];",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=\nVAR_2->s_m[VAR_5][VAR_8] * (VAR_13[1][VAR_17] * phi_sign);",
"} else {",
"float q_filt;",
"if (VAR_9) {",
"const int idx1 = VAR_6 + VAR_9;",
"q_filt = 0.0f;",
"for (VAR_7 = 0; VAR_7 <= VAR_9; VAR_7++)",
"q_filt += VAR_15[idx1 - VAR_7][VAR_8] * VAR_12[VAR_7];",
"} else {",
"q_filt = VAR_15[VAR_6][VAR_8];",
"}",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=\nq_filt * sbr_noise_table[VAR_16][0];",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=\nq_filt * sbr_noise_table[VAR_16][1];",
"}",
"phi_sign = -phi_sign;",
"}",
"} else {",
"VAR_16 = (VAR_16 + VAR_11) & 0x1ff;",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][0] +=\nVAR_2->s_m[VAR_5][VAR_8] * VAR_13[0][VAR_17];",
"VAR_0[1][VAR_6][VAR_8 + VAR_10][1] +=\nVAR_2->s_m[VAR_5][VAR_8] * (VAR_13[1][VAR_17] * phi_sign);",
"phi_sign = -phi_sign;",
"}",
"}",
"VAR_17 = (VAR_17 + 1) & 3;",
"}",
"}",
"VAR_3->f_indexnoise = VAR_16;",
"VAR_3->f_indexsine = VAR_17;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23,
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123,
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
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
]
] |
24,481 | int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
{
const SPS *sps = h->ps.sps;
const int max_frame_num = 1 << sps->log2_max_frame_num;
int field_poc[2];
h->frame_num_offset = h->prev_frame_num_offset;
if (h->frame_num < h->prev_frame_num)
h->frame_num_offset += max_frame_num;
if (sps->poc_type == 0) {
const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
if (h->poc_lsb < h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb + max_poc_lsb;
else if (h->poc_lsb > h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb - max_poc_lsb;
else
h->poc_msb = h->prev_poc_msb;
field_poc[0] =
field_poc[1] = h->poc_msb + h->poc_lsb;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc_bottom;
} else if (sps->poc_type == 1) {
int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
int i;
if (sps->poc_cycle_length != 0)
abs_frame_num = h->frame_num_offset + h->frame_num;
else
abs_frame_num = 0;
if (h->nal_ref_idc == 0 && abs_frame_num > 0)
abs_frame_num--;
expected_delta_per_poc_cycle = 0;
for (i = 0; i < sps->poc_cycle_length; i++)
// FIXME integrate during sps parse
expected_delta_per_poc_cycle += sps->offset_for_ref_frame[i];
if (abs_frame_num > 0) {
int poc_cycle_cnt = (abs_frame_num - 1) / sps->poc_cycle_length;
int frame_num_in_poc_cycle = (abs_frame_num - 1) % sps->poc_cycle_length;
expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
for (i = 0; i <= frame_num_in_poc_cycle; i++)
expectedpoc = expectedpoc + sps->offset_for_ref_frame[i];
} else
expectedpoc = 0;
if (h->nal_ref_idc == 0)
expectedpoc = expectedpoc + sps->offset_for_non_ref_pic;
field_poc[0] = expectedpoc + h->delta_poc[0];
field_poc[1] = field_poc[0] + sps->offset_for_top_to_bottom_field;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc[1];
} else {
int poc = 2 * (h->frame_num_offset + h->frame_num);
if (!h->nal_ref_idc)
poc--;
field_poc[0] = poc;
field_poc[1] = poc;
}
if (h->picture_structure != PICT_BOTTOM_FIELD)
pic_field_poc[0] = field_poc[0];
if (h->picture_structure != PICT_TOP_FIELD)
pic_field_poc[1] = field_poc[1];
*pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
return 0;
}
| false | FFmpeg | c8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8 | int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
{
const SPS *sps = h->ps.sps;
const int max_frame_num = 1 << sps->log2_max_frame_num;
int field_poc[2];
h->frame_num_offset = h->prev_frame_num_offset;
if (h->frame_num < h->prev_frame_num)
h->frame_num_offset += max_frame_num;
if (sps->poc_type == 0) {
const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
if (h->poc_lsb < h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb + max_poc_lsb;
else if (h->poc_lsb > h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb - max_poc_lsb;
else
h->poc_msb = h->prev_poc_msb;
field_poc[0] =
field_poc[1] = h->poc_msb + h->poc_lsb;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc_bottom;
} else if (sps->poc_type == 1) {
int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
int i;
if (sps->poc_cycle_length != 0)
abs_frame_num = h->frame_num_offset + h->frame_num;
else
abs_frame_num = 0;
if (h->nal_ref_idc == 0 && abs_frame_num > 0)
abs_frame_num--;
expected_delta_per_poc_cycle = 0;
for (i = 0; i < sps->poc_cycle_length; i++)
expected_delta_per_poc_cycle += sps->offset_for_ref_frame[i];
if (abs_frame_num > 0) {
int poc_cycle_cnt = (abs_frame_num - 1) / sps->poc_cycle_length;
int frame_num_in_poc_cycle = (abs_frame_num - 1) % sps->poc_cycle_length;
expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
for (i = 0; i <= frame_num_in_poc_cycle; i++)
expectedpoc = expectedpoc + sps->offset_for_ref_frame[i];
} else
expectedpoc = 0;
if (h->nal_ref_idc == 0)
expectedpoc = expectedpoc + sps->offset_for_non_ref_pic;
field_poc[0] = expectedpoc + h->delta_poc[0];
field_poc[1] = field_poc[0] + sps->offset_for_top_to_bottom_field;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc[1];
} else {
int poc = 2 * (h->frame_num_offset + h->frame_num);
if (!h->nal_ref_idc)
poc--;
field_poc[0] = poc;
field_poc[1] = poc;
}
if (h->picture_structure != PICT_BOTTOM_FIELD)
pic_field_poc[0] = field_poc[0];
if (h->picture_structure != PICT_TOP_FIELD)
pic_field_poc[1] = field_poc[1];
*pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(H264Context *VAR_0, int VAR_1[2], int *VAR_2)
{
const SPS *VAR_3 = VAR_0->ps.VAR_3;
const int VAR_4 = 1 << VAR_3->log2_max_frame_num;
int VAR_5[2];
VAR_0->frame_num_offset = VAR_0->prev_frame_num_offset;
if (VAR_0->frame_num < VAR_0->prev_frame_num)
VAR_0->frame_num_offset += VAR_4;
if (VAR_3->poc_type == 0) {
const int VAR_6 = 1 << VAR_3->log2_max_poc_lsb;
if (VAR_0->poc_lsb < VAR_0->prev_poc_lsb &&
VAR_0->prev_poc_lsb - VAR_0->poc_lsb >= VAR_6 / 2)
VAR_0->poc_msb = VAR_0->prev_poc_msb + VAR_6;
else if (VAR_0->poc_lsb > VAR_0->prev_poc_lsb &&
VAR_0->prev_poc_lsb - VAR_0->poc_lsb < -VAR_6 / 2)
VAR_0->poc_msb = VAR_0->prev_poc_msb - VAR_6;
else
VAR_0->poc_msb = VAR_0->prev_poc_msb;
VAR_5[0] =
VAR_5[1] = VAR_0->poc_msb + VAR_0->poc_lsb;
if (VAR_0->picture_structure == PICT_FRAME)
VAR_5[1] += VAR_0->delta_poc_bottom;
} else if (VAR_3->poc_type == 1) {
int VAR_7, VAR_8, VAR_9;
int VAR_10;
if (VAR_3->poc_cycle_length != 0)
VAR_7 = VAR_0->frame_num_offset + VAR_0->frame_num;
else
VAR_7 = 0;
if (VAR_0->nal_ref_idc == 0 && VAR_7 > 0)
VAR_7--;
VAR_8 = 0;
for (VAR_10 = 0; VAR_10 < VAR_3->poc_cycle_length; VAR_10++)
VAR_8 += VAR_3->offset_for_ref_frame[VAR_10];
if (VAR_7 > 0) {
int VAR_11 = (VAR_7 - 1) / VAR_3->poc_cycle_length;
int VAR_12 = (VAR_7 - 1) % VAR_3->poc_cycle_length;
VAR_9 = VAR_11 * VAR_8;
for (VAR_10 = 0; VAR_10 <= VAR_12; VAR_10++)
VAR_9 = VAR_9 + VAR_3->offset_for_ref_frame[VAR_10];
} else
VAR_9 = 0;
if (VAR_0->nal_ref_idc == 0)
VAR_9 = VAR_9 + VAR_3->offset_for_non_ref_pic;
VAR_5[0] = VAR_9 + VAR_0->delta_poc[0];
VAR_5[1] = VAR_5[0] + VAR_3->offset_for_top_to_bottom_field;
if (VAR_0->picture_structure == PICT_FRAME)
VAR_5[1] += VAR_0->delta_poc[1];
} else {
int VAR_13 = 2 * (VAR_0->frame_num_offset + VAR_0->frame_num);
if (!VAR_0->nal_ref_idc)
VAR_13--;
VAR_5[0] = VAR_13;
VAR_5[1] = VAR_13;
}
if (VAR_0->picture_structure != PICT_BOTTOM_FIELD)
VAR_1[0] = VAR_5[0];
if (VAR_0->picture_structure != PICT_TOP_FIELD)
VAR_1[1] = VAR_5[1];
*VAR_2 = FFMIN(VAR_1[0], VAR_1[1]);
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0, int VAR_1[2], int *VAR_2)\n{",
"const SPS *VAR_3 = VAR_0->ps.VAR_3;",
"const int VAR_4 = 1 << VAR_3->log2_max_frame_num;",
"int VAR_5[2];",
"VAR_0->frame_num_offset = VAR_0->prev_frame_num_offset;",
"if (VAR_0->frame_num < VAR_0->prev_frame_num)\nVAR_0->frame_num_offset += VAR_4;",
"if (VAR_3->poc_type == 0) {",
"const int VAR_6 = 1 << VAR_3->log2_max_poc_lsb;",
"if (VAR_0->poc_lsb < VAR_0->prev_poc_lsb &&\nVAR_0->prev_poc_lsb - VAR_0->poc_lsb >= VAR_6 / 2)\nVAR_0->poc_msb = VAR_0->prev_poc_msb + VAR_6;",
"else if (VAR_0->poc_lsb > VAR_0->prev_poc_lsb &&\nVAR_0->prev_poc_lsb - VAR_0->poc_lsb < -VAR_6 / 2)\nVAR_0->poc_msb = VAR_0->prev_poc_msb - VAR_6;",
"else\nVAR_0->poc_msb = VAR_0->prev_poc_msb;",
"VAR_5[0] =\nVAR_5[1] = VAR_0->poc_msb + VAR_0->poc_lsb;",
"if (VAR_0->picture_structure == PICT_FRAME)\nVAR_5[1] += VAR_0->delta_poc_bottom;",
"} else if (VAR_3->poc_type == 1) {",
"int VAR_7, VAR_8, VAR_9;",
"int VAR_10;",
"if (VAR_3->poc_cycle_length != 0)\nVAR_7 = VAR_0->frame_num_offset + VAR_0->frame_num;",
"else\nVAR_7 = 0;",
"if (VAR_0->nal_ref_idc == 0 && VAR_7 > 0)\nVAR_7--;",
"VAR_8 = 0;",
"for (VAR_10 = 0; VAR_10 < VAR_3->poc_cycle_length; VAR_10++)",
"VAR_8 += VAR_3->offset_for_ref_frame[VAR_10];",
"if (VAR_7 > 0) {",
"int VAR_11 = (VAR_7 - 1) / VAR_3->poc_cycle_length;",
"int VAR_12 = (VAR_7 - 1) % VAR_3->poc_cycle_length;",
"VAR_9 = VAR_11 * VAR_8;",
"for (VAR_10 = 0; VAR_10 <= VAR_12; VAR_10++)",
"VAR_9 = VAR_9 + VAR_3->offset_for_ref_frame[VAR_10];",
"} else",
"VAR_9 = 0;",
"if (VAR_0->nal_ref_idc == 0)\nVAR_9 = VAR_9 + VAR_3->offset_for_non_ref_pic;",
"VAR_5[0] = VAR_9 + VAR_0->delta_poc[0];",
"VAR_5[1] = VAR_5[0] + VAR_3->offset_for_top_to_bottom_field;",
"if (VAR_0->picture_structure == PICT_FRAME)\nVAR_5[1] += VAR_0->delta_poc[1];",
"} else {",
"int VAR_13 = 2 * (VAR_0->frame_num_offset + VAR_0->frame_num);",
"if (!VAR_0->nal_ref_idc)\nVAR_13--;",
"VAR_5[0] = VAR_13;",
"VAR_5[1] = VAR_13;",
"}",
"if (VAR_0->picture_structure != PICT_BOTTOM_FIELD)\nVAR_1[0] = VAR_5[0];",
"if (VAR_0->picture_structure != PICT_TOP_FIELD)\nVAR_1[1] = VAR_5[1];",
"*VAR_2 = FFMIN(VAR_1[0], VAR_1[1]);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
27,
29,
31
],
[
33,
35,
37
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63,
65
],
[
69,
71
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
127,
129
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145,
147
],
[
149
],
[
153
],
[
155
]
] |
24,482 | static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
int64_t speed, int64_t granularity,
int64_t buf_size,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
BlockDriverCompletionFunc *cb,
void *opaque, Error **errp,
const BlockJobDriver *driver,
bool is_none_mode, BlockDriverState *base)
{
MirrorBlockJob *s;
if (granularity == 0) {
/* Choose the default granularity based on the target file's cluster
* size, clamped between 4k and 64k. */
BlockDriverInfo bdi;
if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) {
granularity = MAX(4096, bdi.cluster_size);
granularity = MIN(65536, granularity);
} else {
granularity = 65536;
}
}
assert ((granularity & (granularity - 1)) == 0);
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
return;
}
s = block_job_create(driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
s->on_source_error = on_source_error;
s->on_target_error = on_target_error;
s->target = target;
s->is_none_mode = is_none_mode;
s->base = base;
s->granularity = granularity;
s->buf_size = MAX(buf_size, granularity);
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity);
bdrv_set_enable_write_cache(s->target, true);
bdrv_set_on_error(s->target, on_target_error, on_target_error);
bdrv_iostatus_enable(s->target);
s->common.co = qemu_coroutine_create(mirror_run);
trace_mirror_start(bs, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
| true | qemu | b8afb520e479e693c227aa39c2fb7670743e104f | static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
int64_t speed, int64_t granularity,
int64_t buf_size,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
BlockDriverCompletionFunc *cb,
void *opaque, Error **errp,
const BlockJobDriver *driver,
bool is_none_mode, BlockDriverState *base)
{
MirrorBlockJob *s;
if (granularity == 0) {
BlockDriverInfo bdi;
if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) {
granularity = MAX(4096, bdi.cluster_size);
granularity = MIN(65536, granularity);
} else {
granularity = 65536;
}
}
assert ((granularity & (granularity - 1)) == 0);
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
return;
}
s = block_job_create(driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
s->on_source_error = on_source_error;
s->on_target_error = on_target_error;
s->target = target;
s->is_none_mode = is_none_mode;
s->base = base;
s->granularity = granularity;
s->buf_size = MAX(buf_size, granularity);
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity);
bdrv_set_enable_write_cache(s->target, true);
bdrv_set_on_error(s->target, on_target_error, on_target_error);
bdrv_iostatus_enable(s->target);
s->common.co = qemu_coroutine_create(mirror_run);
trace_mirror_start(bs, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
| {
"code": [
" s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity);"
],
"line_no": [
95
]
} | static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
int64_t VAR_2, int64_t VAR_3,
int64_t VAR_4,
BlockdevOnError VAR_5,
BlockdevOnError VAR_6,
BlockDriverCompletionFunc *VAR_7,
void *VAR_8, Error **VAR_9,
const BlockJobDriver *VAR_10,
bool VAR_11, BlockDriverState *VAR_12)
{
MirrorBlockJob *s;
if (VAR_3 == 0) {
BlockDriverInfo bdi;
if (bdrv_get_info(VAR_1, &bdi) >= 0 && bdi.cluster_size != 0) {
VAR_3 = MAX(4096, bdi.cluster_size);
VAR_3 = MIN(65536, VAR_3);
} else {
VAR_3 = 65536;
}
}
assert ((VAR_3 & (VAR_3 - 1)) == 0);
if ((VAR_5 == BLOCKDEV_ON_ERROR_STOP ||
VAR_5 == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(VAR_0)) {
error_set(VAR_9, QERR_INVALID_PARAMETER, "on-source-error");
return;
}
s = block_job_create(VAR_10, VAR_0, VAR_2, VAR_7, VAR_8, VAR_9);
if (!s) {
return;
}
s->VAR_5 = VAR_5;
s->VAR_6 = VAR_6;
s->VAR_1 = VAR_1;
s->VAR_11 = VAR_11;
s->VAR_12 = VAR_12;
s->VAR_3 = VAR_3;
s->VAR_4 = MAX(VAR_4, VAR_3);
s->dirty_bitmap = bdrv_create_dirty_bitmap(VAR_0, VAR_3);
bdrv_set_enable_write_cache(s->VAR_1, true);
bdrv_set_on_error(s->VAR_1, VAR_6, VAR_6);
bdrv_iostatus_enable(s->VAR_1);
s->common.co = qemu_coroutine_create(mirror_run);
trace_mirror_start(VAR_0, s, s->common.co, VAR_8);
qemu_coroutine_enter(s->common.co, s);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nint64_t VAR_2, int64_t VAR_3,\nint64_t VAR_4,\nBlockdevOnError VAR_5,\nBlockdevOnError VAR_6,\nBlockDriverCompletionFunc *VAR_7,\nvoid *VAR_8, Error **VAR_9,\nconst BlockJobDriver *VAR_10,\nbool VAR_11, BlockDriverState *VAR_12)\n{",
"MirrorBlockJob *s;",
"if (VAR_3 == 0) {",
"BlockDriverInfo bdi;",
"if (bdrv_get_info(VAR_1, &bdi) >= 0 && bdi.cluster_size != 0) {",
"VAR_3 = MAX(4096, bdi.cluster_size);",
"VAR_3 = MIN(65536, VAR_3);",
"} else {",
"VAR_3 = 65536;",
"}",
"}",
"assert ((VAR_3 & (VAR_3 - 1)) == 0);",
"if ((VAR_5 == BLOCKDEV_ON_ERROR_STOP ||\nVAR_5 == BLOCKDEV_ON_ERROR_ENOSPC) &&\n!bdrv_iostatus_is_enabled(VAR_0)) {",
"error_set(VAR_9, QERR_INVALID_PARAMETER, \"on-source-error\");",
"return;",
"}",
"s = block_job_create(VAR_10, VAR_0, VAR_2, VAR_7, VAR_8, VAR_9);",
"if (!s) {",
"return;",
"}",
"s->VAR_5 = VAR_5;",
"s->VAR_6 = VAR_6;",
"s->VAR_1 = VAR_1;",
"s->VAR_11 = VAR_11;",
"s->VAR_12 = VAR_12;",
"s->VAR_3 = VAR_3;",
"s->VAR_4 = MAX(VAR_4, VAR_3);",
"s->dirty_bitmap = bdrv_create_dirty_bitmap(VAR_0, VAR_3);",
"bdrv_set_enable_write_cache(s->VAR_1, true);",
"bdrv_set_on_error(s->VAR_1, VAR_6, VAR_6);",
"bdrv_iostatus_enable(s->VAR_1);",
"s->common.co = qemu_coroutine_create(mirror_run);",
"trace_mirror_start(VAR_0, s, s->common.co, VAR_8);",
"qemu_coroutine_enter(s->common.co, 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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19
],
[
21
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
24,487 | static int sdp_parse_rtpmap(AVFormatContext *s,
AVStream *st, RTSPStream *rtsp_st,
int payload_type, const char *p)
{
AVCodecContext *codec = st->codec;
char buf[256];
int i;
AVCodec *c;
const char *c_name;
/* See if we can handle this kind of payload.
* The space should normally not be there but some Real streams or
* particular servers ("RealServer Version 6.1.3.970", see issue 1658)
* have a trailing space. */
get_word_sep(buf, sizeof(buf), "/ ", &p);
if (payload_type < RTP_PT_PRIVATE) {
/* We are in a standard case
* (from http://www.iana.org/assignments/rtp-parameters). */
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
if (codec->codec_id == AV_CODEC_ID_NONE) {
RTPDynamicProtocolHandler *handler =
ff_rtp_handler_find_by_name(buf, codec->codec_type);
init_rtp_handler(handler, rtsp_st, st);
/* If no dynamic handler was found, check with the list of standard
* allocated types, if such a stream for some reason happens to
* use a private payload type. This isn't handled in rtpdec.c, since
* the format name from the rtpmap line never is passed into rtpdec. */
if (!rtsp_st->dynamic_handler)
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
c = avcodec_find_decoder(codec->codec_id);
if (c && c->name)
c_name = c->name;
else
c_name = "(null)";
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (i > 0) {
codec->sample_rate = i;
avpriv_set_pts_info(st, 32, 1, codec->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
if (i > 0)
codec->channels = i;
}
av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
codec->sample_rate);
av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
codec->channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
if (i > 0)
avpriv_set_pts_info(st, 32, 1, i);
break;
default:
break;
}
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)
rtsp_st->dynamic_handler->init(s, st->index,
rtsp_st->dynamic_protocol_context);
return 0;
}
| true | FFmpeg | 078d43e23a7a3d64aafee8a58b380d3e139b3020 | static int sdp_parse_rtpmap(AVFormatContext *s,
AVStream *st, RTSPStream *rtsp_st,
int payload_type, const char *p)
{
AVCodecContext *codec = st->codec;
char buf[256];
int i;
AVCodec *c;
const char *c_name;
get_word_sep(buf, sizeof(buf), "/ ", &p);
if (payload_type < RTP_PT_PRIVATE) {
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
if (codec->codec_id == AV_CODEC_ID_NONE) {
RTPDynamicProtocolHandler *handler =
ff_rtp_handler_find_by_name(buf, codec->codec_type);
init_rtp_handler(handler, rtsp_st, st);
if (!rtsp_st->dynamic_handler)
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
c = avcodec_find_decoder(codec->codec_id);
if (c && c->name)
c_name = c->name;
else
c_name = "(null)";
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (i > 0) {
codec->sample_rate = i;
avpriv_set_pts_info(st, 32, 1, codec->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
if (i > 0)
codec->channels = i;
}
av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
codec->sample_rate);
av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
codec->channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
if (i > 0)
avpriv_set_pts_info(st, 32, 1, i);
break;
default:
break;
}
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)
rtsp_st->dynamic_handler->init(s, st->index,
rtsp_st->dynamic_protocol_context);
return 0;
}
| {
"code": [
" if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)",
" rtsp_st->dynamic_handler->init(s, st->index,",
" rtsp_st->dynamic_protocol_context);"
],
"line_no": [
135,
137,
139
]
} | static int FUNC_0(AVFormatContext *VAR_0,
AVStream *VAR_1, RTSPStream *VAR_2,
int VAR_3, const char *VAR_4)
{
AVCodecContext *codec = VAR_1->codec;
char VAR_5[256];
int VAR_6;
AVCodec *c;
const char *VAR_7;
get_word_sep(VAR_5, sizeof(VAR_5), "/ ", &VAR_4);
if (VAR_3 < RTP_PT_PRIVATE) {
codec->codec_id = ff_rtp_codec_id(VAR_5, codec->codec_type);
}
if (codec->codec_id == AV_CODEC_ID_NONE) {
RTPDynamicProtocolHandler *handler =
ff_rtp_handler_find_by_name(VAR_5, codec->codec_type);
init_rtp_handler(handler, VAR_2, VAR_1);
if (!VAR_2->dynamic_handler)
codec->codec_id = ff_rtp_codec_id(VAR_5, codec->codec_type);
}
c = avcodec_find_decoder(codec->codec_id);
if (c && c->name)
VAR_7 = c->name;
else
VAR_7 = "(null)";
get_word_sep(VAR_5, sizeof(VAR_5), "/", &VAR_4);
VAR_6 = atoi(VAR_5);
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_log(VAR_0, AV_LOG_DEBUG, "audio codec set to: %VAR_0\n", VAR_7);
codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (VAR_6 > 0) {
codec->sample_rate = VAR_6;
avpriv_set_pts_info(VAR_1, 32, 1, codec->sample_rate);
get_word_sep(VAR_5, sizeof(VAR_5), "/", &VAR_4);
VAR_6 = atoi(VAR_5);
if (VAR_6 > 0)
codec->channels = VAR_6;
}
av_log(VAR_0, AV_LOG_DEBUG, "audio samplerate set to: %VAR_6\n",
codec->sample_rate);
av_log(VAR_0, AV_LOG_DEBUG, "audio channels set to: %VAR_6\n",
codec->channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(VAR_0, AV_LOG_DEBUG, "video codec set to: %VAR_0\n", VAR_7);
if (VAR_6 > 0)
avpriv_set_pts_info(VAR_1, 32, 1, VAR_6);
break;
default:
break;
}
if (VAR_2->dynamic_handler && VAR_2->dynamic_handler->init)
VAR_2->dynamic_handler->init(VAR_0, VAR_1->index,
VAR_2->dynamic_protocol_context);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVStream *VAR_1, RTSPStream *VAR_2,\nint VAR_3, const char *VAR_4)\n{",
"AVCodecContext *codec = VAR_1->codec;",
"char VAR_5[256];",
"int VAR_6;",
"AVCodec *c;",
"const char *VAR_7;",
"get_word_sep(VAR_5, sizeof(VAR_5), \"/ \", &VAR_4);",
"if (VAR_3 < RTP_PT_PRIVATE) {",
"codec->codec_id = ff_rtp_codec_id(VAR_5, codec->codec_type);",
"}",
"if (codec->codec_id == AV_CODEC_ID_NONE) {",
"RTPDynamicProtocolHandler *handler =\nff_rtp_handler_find_by_name(VAR_5, codec->codec_type);",
"init_rtp_handler(handler, VAR_2, VAR_1);",
"if (!VAR_2->dynamic_handler)\ncodec->codec_id = ff_rtp_codec_id(VAR_5, codec->codec_type);",
"}",
"c = avcodec_find_decoder(codec->codec_id);",
"if (c && c->name)\nVAR_7 = c->name;",
"else\nVAR_7 = \"(null)\";",
"get_word_sep(VAR_5, sizeof(VAR_5), \"/\", &VAR_4);",
"VAR_6 = atoi(VAR_5);",
"switch (codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nav_log(VAR_0, AV_LOG_DEBUG, \"audio codec set to: %VAR_0\\n\", VAR_7);",
"codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;",
"codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;",
"if (VAR_6 > 0) {",
"codec->sample_rate = VAR_6;",
"avpriv_set_pts_info(VAR_1, 32, 1, codec->sample_rate);",
"get_word_sep(VAR_5, sizeof(VAR_5), \"/\", &VAR_4);",
"VAR_6 = atoi(VAR_5);",
"if (VAR_6 > 0)\ncodec->channels = VAR_6;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"audio samplerate set to: %VAR_6\\n\",\ncodec->sample_rate);",
"av_log(VAR_0, AV_LOG_DEBUG, \"audio channels set to: %VAR_6\\n\",\ncodec->channels);",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nav_log(VAR_0, AV_LOG_DEBUG, \"video codec set to: %VAR_0\\n\", VAR_7);",
"if (VAR_6 > 0)\navpriv_set_pts_info(VAR_1, 32, 1, VAR_6);",
"break;",
"default:\nbreak;",
"}",
"if (VAR_2->dynamic_handler && VAR_2->dynamic_handler->init)\nVAR_2->dynamic_handler->init(VAR_0, VAR_1->index,\nVAR_2->dynamic_protocol_context);",
"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,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
29
],
[
31
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
59,
61
],
[
63
],
[
67
],
[
69,
71
],
[
73,
75
],
[
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
]
] |
24,489 | void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
// Common optimizations whether AltiVec is available or not
c->prefetch = prefetch_ppc;
if (!high_bit_depth) {
switch (check_dcbzl_effect()) {
case 32:
c->clear_blocks = clear_blocks_dcbz32_ppc;
break;
case 128:
c->clear_blocks = clear_blocks_dcbz128_ppc;
break;
default:
break;
}
}
#if HAVE_ALTIVEC
if(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(c, avctx);
if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
ff_dsputil_init_altivec(c, avctx);
ff_float_init_altivec(c, avctx);
ff_int_init_altivec(c, avctx);
c->gmc1 = ff_gmc1_altivec;
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample <= 8 &&
(avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC)) {
c->fdct = ff_fdct_altivec;
}
#endif //CONFIG_ENCODERS
if (avctx->bits_per_raw_sample <= 8) {
if ((avctx->idct_algo == FF_IDCT_AUTO) ||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) {
c->idct_put = ff_idct_put_altivec;
c->idct_add = ff_idct_add_altivec;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) &&
avctx->idct_algo==FF_IDCT_VP3){
c->idct_put = ff_vp3_idct_put_altivec;
c->idct_add = ff_vp3_idct_add_altivec;
c->idct = ff_vp3_idct_altivec;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}
}
}
#endif /* HAVE_ALTIVEC */
}
| false | FFmpeg | 28f9ab7029bd1a02f659995919f899f84ee7361b | void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
c->prefetch = prefetch_ppc;
if (!high_bit_depth) {
switch (check_dcbzl_effect()) {
case 32:
c->clear_blocks = clear_blocks_dcbz32_ppc;
break;
case 128:
c->clear_blocks = clear_blocks_dcbz128_ppc;
break;
default:
break;
}
}
#if HAVE_ALTIVEC
if(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(c, avctx);
if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
ff_dsputil_init_altivec(c, avctx);
ff_float_init_altivec(c, avctx);
ff_int_init_altivec(c, avctx);
c->gmc1 = ff_gmc1_altivec;
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample <= 8 &&
(avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC)) {
c->fdct = ff_fdct_altivec;
}
#endif
if (avctx->bits_per_raw_sample <= 8) {
if ((avctx->idct_algo == FF_IDCT_AUTO) ||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) {
c->idct_put = ff_idct_put_altivec;
c->idct_add = ff_idct_add_altivec;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) &&
avctx->idct_algo==FF_IDCT_VP3){
c->idct_put = ff_vp3_idct_put_altivec;
c->idct_add = ff_vp3_idct_add_altivec;
c->idct = ff_vp3_idct_altivec;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}
}
}
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DSPContext* VAR_0, AVCodecContext *VAR_1)
{
const int VAR_2 = VAR_1->bits_per_raw_sample > 8;
VAR_0->prefetch = prefetch_ppc;
if (!VAR_2) {
switch (check_dcbzl_effect()) {
case 32:
VAR_0->clear_blocks = clear_blocks_dcbz32_ppc;
break;
case 128:
VAR_0->clear_blocks = clear_blocks_dcbz128_ppc;
break;
default:
break;
}
}
#if HAVE_ALTIVEC
if(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(VAR_0, VAR_1);
if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
ff_dsputil_init_altivec(VAR_0, VAR_1);
ff_float_init_altivec(VAR_0, VAR_1);
ff_int_init_altivec(VAR_0, VAR_1);
VAR_0->gmc1 = ff_gmc1_altivec;
#if CONFIG_ENCODERS
if (VAR_1->bits_per_raw_sample <= 8 &&
(VAR_1->dct_algo == FF_DCT_AUTO ||
VAR_1->dct_algo == FF_DCT_ALTIVEC)) {
VAR_0->fdct = ff_fdct_altivec;
}
#endif
if (VAR_1->bits_per_raw_sample <= 8) {
if ((VAR_1->idct_algo == FF_IDCT_AUTO) ||
(VAR_1->idct_algo == FF_IDCT_ALTIVEC)) {
VAR_0->idct_put = ff_idct_put_altivec;
VAR_0->idct_add = ff_idct_add_altivec;
VAR_0->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) &&
VAR_1->idct_algo==FF_IDCT_VP3){
VAR_0->idct_put = ff_vp3_idct_put_altivec;
VAR_0->idct_add = ff_vp3_idct_add_altivec;
VAR_0->idct = ff_vp3_idct_altivec;
VAR_0->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}
}
}
#endif
}
| [
"void FUNC_0(DSPContext* VAR_0, AVCodecContext *VAR_1)\n{",
"const int VAR_2 = VAR_1->bits_per_raw_sample > 8;",
"VAR_0->prefetch = prefetch_ppc;",
"if (!VAR_2) {",
"switch (check_dcbzl_effect()) {",
"case 32:\nVAR_0->clear_blocks = clear_blocks_dcbz32_ppc;",
"break;",
"case 128:\nVAR_0->clear_blocks = clear_blocks_dcbz128_ppc;",
"break;",
"default:\nbreak;",
"}",
"}",
"#if HAVE_ALTIVEC\nif(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(VAR_0, VAR_1);",
"if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {",
"ff_dsputil_init_altivec(VAR_0, VAR_1);",
"ff_float_init_altivec(VAR_0, VAR_1);",
"ff_int_init_altivec(VAR_0, VAR_1);",
"VAR_0->gmc1 = ff_gmc1_altivec;",
"#if CONFIG_ENCODERS\nif (VAR_1->bits_per_raw_sample <= 8 &&\n(VAR_1->dct_algo == FF_DCT_AUTO ||\nVAR_1->dct_algo == FF_DCT_ALTIVEC)) {",
"VAR_0->fdct = ff_fdct_altivec;",
"}",
"#endif\nif (VAR_1->bits_per_raw_sample <= 8) {",
"if ((VAR_1->idct_algo == FF_IDCT_AUTO) ||\n(VAR_1->idct_algo == FF_IDCT_ALTIVEC)) {",
"VAR_0->idct_put = ff_idct_put_altivec;",
"VAR_0->idct_add = ff_idct_add_altivec;",
"VAR_0->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;",
"}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) &&",
"VAR_1->idct_algo==FF_IDCT_VP3){",
"VAR_0->idct_put = ff_vp3_idct_put_altivec;",
"VAR_0->idct_add = ff_vp3_idct_add_altivec;",
"VAR_0->idct = ff_vp3_idct_altivec;",
"VAR_0->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;",
"}",
"}",
"}",
"#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,
3
],
[
5
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61,
63
],
[
65
],
[
67
],
[
69,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105,
107
]
] |
24,490 | bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
/* Compute position and bit in the last layer. */
uint64_t pos = item >> hb->granularity;
unsigned long bit = 1UL << (pos & (BITS_PER_LONG - 1));
return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & bit) != 0;
} | true | qemu | 0e321191224c8cd137eef41da3257e096965c3d6 | bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
uint64_t pos = item >> hb->granularity;
unsigned long bit = 1UL << (pos & (BITS_PER_LONG - 1));
return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & bit) != 0;
} | {
"code": [],
"line_no": []
} | bool FUNC_0(const HBitmap *hb, uint64_t item)
{
uint64_t pos = item >> hb->granularity;
unsigned long VAR_0 = 1UL << (pos & (BITS_PER_LONG - 1));
return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & VAR_0) != 0;
} | [
"bool FUNC_0(const HBitmap *hb, uint64_t item)\n{",
"uint64_t pos = item >> hb->granularity;",
"unsigned long VAR_0 = 1UL << (pos & (BITS_PER_LONG - 1));",
"return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & VAR_0) != 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
14
],
[
16
]
] |
24,491 | static int ffm_is_avail_data(AVFormatContext *s, int size)
{
FFMContext *ffm = s->priv_data;
int64_t pos, avail_size;
int len;
len = ffm->packet_end - ffm->packet_ptr;
if (size <= len)
return 1;
pos = avio_tell(s->pb);
if (!ffm->write_index) {
if (pos == ffm->file_size)
return AVERROR_EOF;
avail_size = ffm->file_size - pos;
} else {
if (pos == ffm->write_index) {
/* exactly at the end of stream */
if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
} else if (pos < ffm->write_index) {
avail_size = ffm->write_index - pos;
} else {
avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
}
}
avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
if (size <= avail_size)
return 1;
else if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
}
| true | FFmpeg | f6e1c96730ebbcebbd0341329d51d3d3a36b4fa1 | static int ffm_is_avail_data(AVFormatContext *s, int size)
{
FFMContext *ffm = s->priv_data;
int64_t pos, avail_size;
int len;
len = ffm->packet_end - ffm->packet_ptr;
if (size <= len)
return 1;
pos = avio_tell(s->pb);
if (!ffm->write_index) {
if (pos == ffm->file_size)
return AVERROR_EOF;
avail_size = ffm->file_size - pos;
} else {
if (pos == ffm->write_index) {
if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
} else if (pos < ffm->write_index) {
avail_size = ffm->write_index - pos;
} else {
avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
}
}
avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
if (size <= avail_size)
return 1;
else if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
}
| {
"code": [
" int len;"
],
"line_no": [
9
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
FFMContext *ffm = VAR_0->priv_data;
int64_t pos, avail_size;
int VAR_2;
VAR_2 = ffm->packet_end - ffm->packet_ptr;
if (VAR_1 <= VAR_2)
return 1;
pos = avio_tell(VAR_0->pb);
if (!ffm->write_index) {
if (pos == ffm->file_size)
return AVERROR_EOF;
avail_size = ffm->file_size - pos;
} else {
if (pos == ffm->write_index) {
if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
} else if (pos < ffm->write_index) {
avail_size = ffm->write_index - pos;
} else {
avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
}
}
avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + VAR_2;
if (VAR_1 <= avail_size)
return 1;
else if (ffm->server_attached)
return AVERROR(EAGAIN);
else
return AVERROR_INVALIDDATA;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"FFMContext *ffm = VAR_0->priv_data;",
"int64_t pos, avail_size;",
"int VAR_2;",
"VAR_2 = ffm->packet_end - ffm->packet_ptr;",
"if (VAR_1 <= VAR_2)\nreturn 1;",
"pos = avio_tell(VAR_0->pb);",
"if (!ffm->write_index) {",
"if (pos == ffm->file_size)\nreturn AVERROR_EOF;",
"avail_size = ffm->file_size - pos;",
"} else {",
"if (pos == ffm->write_index) {",
"if (ffm->server_attached)\nreturn AVERROR(EAGAIN);",
"else\nreturn AVERROR_INVALIDDATA;",
"} else if (pos < ffm->write_index) {",
"avail_size = ffm->write_index - pos;",
"} else {",
"avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);",
"}",
"}",
"avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + VAR_2;",
"if (VAR_1 <= avail_size)\nreturn 1;",
"else if (ffm->server_attached)\nreturn AVERROR(EAGAIN);",
"else\nreturn AVERROR_INVALIDDATA;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65,
67
],
[
69
]
] |
24,492 | int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
{
int arch = !!(key & FW_CFG_ARCH_LOCAL);
key &= FW_CFG_ENTRY_MASK;
if (key >= FW_CFG_MAX_ENTRY)
return 0;
s->entries[arch][key].data = data;
s->entries[arch][key].len = len;
return 1;
}
| true | qemu | 4cad3867b6df2c0826ae508a9fe15dd0b9d8936a | int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
{
int arch = !!(key & FW_CFG_ARCH_LOCAL);
key &= FW_CFG_ENTRY_MASK;
if (key >= FW_CFG_MAX_ENTRY)
return 0;
s->entries[arch][key].data = data;
s->entries[arch][key].len = len;
return 1;
}
| {
"code": [
"int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)",
" if (key >= FW_CFG_MAX_ENTRY)",
" return 0;",
" return 1;",
" return 0;",
" return 0;",
" return 1;",
" return 0;",
" return 1;"
],
"line_no": [
1,
13,
15,
25,
15,
15,
25,
15,
25
]
} | int FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint8_t *VAR_2, uint32_t VAR_3)
{
int VAR_4 = !!(VAR_1 & FW_CFG_ARCH_LOCAL);
VAR_1 &= FW_CFG_ENTRY_MASK;
if (VAR_1 >= FW_CFG_MAX_ENTRY)
return 0;
VAR_0->entries[VAR_4][VAR_1].VAR_2 = VAR_2;
VAR_0->entries[VAR_4][VAR_1].VAR_3 = VAR_3;
return 1;
}
| [
"int FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint8_t *VAR_2, uint32_t VAR_3)\n{",
"int VAR_4 = !!(VAR_1 & FW_CFG_ARCH_LOCAL);",
"VAR_1 &= FW_CFG_ENTRY_MASK;",
"if (VAR_1 >= FW_CFG_MAX_ENTRY)\nreturn 0;",
"VAR_0->entries[VAR_4][VAR_1].VAR_2 = VAR_2;",
"VAR_0->entries[VAR_4][VAR_1].VAR_3 = VAR_3;",
"return 1;",
"}"
] | [
1,
0,
0,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.