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,767 | static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
{
enable_compat_apic_id_mode();
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
pc_init_pci(args);
}
| true | qemu | 9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838 | static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
{
enable_compat_apic_id_mode();
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
pc_init_pci(args);
}
| {
"code": [
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;"
],
"line_no": [
7,
7,
7,
7
]
} | static void FUNC_0(QEMUMachineInitArgs *VAR_0)
{
enable_compat_apic_id_mode();
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
pc_init_pci(VAR_0);
}
| [
"static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"enable_compat_apic_id_mode();",
"pc_sysfw_flash_vs_rom_bug_compatible = true;",
"has_pvpanic = false;",
"pc_init_pci(VAR_0);",
"}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
24,769 | static uint8_t get_sot(Jpeg2000DecoderContext *s, int n)
{
Jpeg2000TilePart *tp;
uint16_t Isot;
uint32_t Psot;
uint8_t TPsot;
if (s->buf_end - s->buf < 4)
return AVERROR(EINVAL);
Isot = bytestream_get_be16(&s->buf); // Isot
if (Isot) {
av_log(s->avctx, AV_LOG_ERROR,
"Not a DCINEMA JP2K file: more than one tile\n");
return -1;
}
Psot = bytestream_get_be32(&s->buf); // Psot
TPsot = bytestream_get_byte(&s->buf); // TPsot
/* Read TNSot but not used */
bytestream_get_byte(&s->buf); // TNsot
tp = s->tile[s->curtileno].tile_part + TPsot;
tp->tile_index = Isot;
tp->tp_len = Psot;
tp->tp_idx = TPsot;
/* Start of bit stream. Pointer to SOD marker
* Check SOD marker is present. */
if (JPEG2000_SOD == bytestream_get_be16(&s->buf))
tp->tp_start_bstrm = s->buf;
else {
av_log(s->avctx, AV_LOG_ERROR, "SOD marker not found \n");
return -1;
}
/* End address of bit stream =
* start address + (Psot - size of SOT HEADER(n)
* - size of SOT MARKER(2) - size of SOD marker(2) */
tp->tp_end_bstrm = s->buf + (tp->tp_len - n - 4);
// set buffer pointer to end of tile part header
s->buf = tp->tp_end_bstrm;
return 0;
}
| false | FFmpeg | 0b42631641d998e509cde6fa344edc6ab5cb4ac8 | static uint8_t get_sot(Jpeg2000DecoderContext *s, int n)
{
Jpeg2000TilePart *tp;
uint16_t Isot;
uint32_t Psot;
uint8_t TPsot;
if (s->buf_end - s->buf < 4)
return AVERROR(EINVAL);
Isot = bytestream_get_be16(&s->buf);
if (Isot) {
av_log(s->avctx, AV_LOG_ERROR,
"Not a DCINEMA JP2K file: more than one tile\n");
return -1;
}
Psot = bytestream_get_be32(&s->buf);
TPsot = bytestream_get_byte(&s->buf);
bytestream_get_byte(&s->buf);
tp = s->tile[s->curtileno].tile_part + TPsot;
tp->tile_index = Isot;
tp->tp_len = Psot;
tp->tp_idx = TPsot;
if (JPEG2000_SOD == bytestream_get_be16(&s->buf))
tp->tp_start_bstrm = s->buf;
else {
av_log(s->avctx, AV_LOG_ERROR, "SOD marker not found \n");
return -1;
}
tp->tp_end_bstrm = s->buf + (tp->tp_len - n - 4);
s->buf = tp->tp_end_bstrm;
return 0;
}
| {
"code": [],
"line_no": []
} | static uint8_t FUNC_0(Jpeg2000DecoderContext *s, int n)
{
Jpeg2000TilePart *tp;
uint16_t Isot;
uint32_t Psot;
uint8_t TPsot;
if (s->buf_end - s->buf < 4)
return AVERROR(EINVAL);
Isot = bytestream_get_be16(&s->buf);
if (Isot) {
av_log(s->avctx, AV_LOG_ERROR,
"Not a DCINEMA JP2K file: more than one tile\n");
return -1;
}
Psot = bytestream_get_be32(&s->buf);
TPsot = bytestream_get_byte(&s->buf);
bytestream_get_byte(&s->buf);
tp = s->tile[s->curtileno].tile_part + TPsot;
tp->tile_index = Isot;
tp->tp_len = Psot;
tp->tp_idx = TPsot;
if (JPEG2000_SOD == bytestream_get_be16(&s->buf))
tp->tp_start_bstrm = s->buf;
else {
av_log(s->avctx, AV_LOG_ERROR, "SOD marker not found \n");
return -1;
}
tp->tp_end_bstrm = s->buf + (tp->tp_len - n - 4);
s->buf = tp->tp_end_bstrm;
return 0;
}
| [
"static uint8_t FUNC_0(Jpeg2000DecoderContext *s, int n)\n{",
"Jpeg2000TilePart *tp;",
"uint16_t Isot;",
"uint32_t Psot;",
"uint8_t TPsot;",
"if (s->buf_end - s->buf < 4)\nreturn AVERROR(EINVAL);",
"Isot = bytestream_get_be16(&s->buf);",
"if (Isot) {",
"av_log(s->avctx, AV_LOG_ERROR,\n\"Not a DCINEMA JP2K file: more than one tile\\n\");",
"return -1;",
"}",
"Psot = bytestream_get_be32(&s->buf);",
"TPsot = bytestream_get_byte(&s->buf);",
"bytestream_get_byte(&s->buf);",
"tp = s->tile[s->curtileno].tile_part + TPsot;",
"tp->tile_index = Isot;",
"tp->tp_len = Psot;",
"tp->tp_idx = TPsot;",
"if (JPEG2000_SOD == bytestream_get_be16(&s->buf))\ntp->tp_start_bstrm = s->buf;",
"else {",
"av_log(s->avctx, AV_LOG_ERROR, \"SOD marker not found \\n\");",
"return -1;",
"}",
"tp->tp_end_bstrm = s->buf + (tp->tp_len - n - 4);",
"s->buf = tp->tp_end_bstrm;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
79
],
[
85
],
[
89
],
[
91
]
] |
24,770 | static int xa_probe(AVProbeData *p)
{
switch(AV_RL32(p->buf)) {
case XA00_TAG:
case XAI0_TAG:
case XAJ0_TAG:
return AVPROBE_SCORE_MAX;
}
return 0;
}
| true | FFmpeg | ddbb7c9be2f8a006325ec64cd5b90e1ade5bc476 | static int xa_probe(AVProbeData *p)
{
switch(AV_RL32(p->buf)) {
case XA00_TAG:
case XAI0_TAG:
case XAJ0_TAG:
return AVPROBE_SCORE_MAX;
}
return 0;
}
| {
"code": [
" return AVPROBE_SCORE_MAX;",
" return 0;"
],
"line_no": [
13,
17
]
} | static int FUNC_0(AVProbeData *VAR_0)
{
switch(AV_RL32(VAR_0->buf)) {
case XA00_TAG:
case XAI0_TAG:
case XAJ0_TAG:
return AVPROBE_SCORE_MAX;
}
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"switch(AV_RL32(VAR_0->buf)) {",
"case XA00_TAG:\ncase XAI0_TAG:\ncase XAJ0_TAG:\nreturn AVPROBE_SCORE_MAX;",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
]
] |
24,772 | static void qemu_chr_fe_write_log(CharDriverState *s,
const uint8_t *buf, size_t len)
{
size_t done = 0;
ssize_t ret;
if (s->logfd < 0) {
return;
}
while (done < len) {
do {
ret = write(s->logfd, buf + done, len - done);
if (ret == -1 && errno == EAGAIN) {
g_usleep(100);
}
} while (ret == -1 && errno == EAGAIN);
if (ret <= 0) {
return;
}
done += ret;
}
}
| true | qemu | 53628efbc8aa7a7ab5354d24b971f4d69452151d | static void qemu_chr_fe_write_log(CharDriverState *s,
const uint8_t *buf, size_t len)
{
size_t done = 0;
ssize_t ret;
if (s->logfd < 0) {
return;
}
while (done < len) {
do {
ret = write(s->logfd, buf + done, len - done);
if (ret == -1 && errno == EAGAIN) {
g_usleep(100);
}
} while (ret == -1 && errno == EAGAIN);
if (ret <= 0) {
return;
}
done += ret;
}
}
| {
"code": [
" do {",
" ret = write(s->logfd, buf + done, len - done);",
" if (ret == -1 && errno == EAGAIN) {",
" g_usleep(100);",
" } while (ret == -1 && errno == EAGAIN);",
" do {",
" g_usleep(100);",
" do {",
" g_usleep(100);"
],
"line_no": [
23,
25,
27,
29,
33,
23,
29,
23,
29
]
} | static void FUNC_0(CharDriverState *VAR_0,
const uint8_t *VAR_1, size_t VAR_2)
{
size_t done = 0;
ssize_t ret;
if (VAR_0->logfd < 0) {
return;
}
while (done < VAR_2) {
do {
ret = write(VAR_0->logfd, VAR_1 + done, VAR_2 - done);
if (ret == -1 && errno == EAGAIN) {
g_usleep(100);
}
} while (ret == -1 && errno == EAGAIN);
if (ret <= 0) {
return;
}
done += ret;
}
}
| [
"static void FUNC_0(CharDriverState *VAR_0,\nconst uint8_t *VAR_1, size_t VAR_2)\n{",
"size_t done = 0;",
"ssize_t ret;",
"if (VAR_0->logfd < 0) {",
"return;",
"}",
"while (done < VAR_2) {",
"do {",
"ret = write(VAR_0->logfd, VAR_1 + done, VAR_2 - done);",
"if (ret == -1 && errno == EAGAIN) {",
"g_usleep(100);",
"}",
"} while (ret == -1 && errno == EAGAIN);",
"if (ret <= 0) {",
"return;",
"}",
"done += ret;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
24,773 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
{
if(av_log_callback)
av_log_callback(avcl, level, fmt, vl);
}
| true | FFmpeg | 3ed65d98c616d52e2544c8b81aa3997f28bb88f5 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
{
if(av_log_callback)
av_log_callback(avcl, level, fmt, vl);
}
| {
"code": [
" if(av_log_callback)",
" av_log_callback(avcl, level, fmt, vl);"
],
"line_no": [
5,
7
]
} | void FUNC_0(void* VAR_0, int VAR_1, const char *VAR_2, va_list VAR_3)
{
if(av_log_callback)
av_log_callback(VAR_0, VAR_1, VAR_2, VAR_3);
}
| [
"void FUNC_0(void* VAR_0, int VAR_1, const char *VAR_2, va_list VAR_3)\n{",
"if(av_log_callback)\nav_log_callback(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
]
] |
24,774 | void kvm_setup_guest_memory(void *start, size_t size)
{
if (!kvm_has_sync_mmu()) {
#ifdef MADV_DONTFORK
int ret = madvise(start, size, MADV_DONTFORK);
if (ret) {
perror("madvice");
exit(1);
}
#else
fprintf(stderr,
"Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
exit(1);
#endif
}
}
| true | qemu | e78815a554adaa551d62a71be10ee2fcf128e473 | void kvm_setup_guest_memory(void *start, size_t size)
{
if (!kvm_has_sync_mmu()) {
#ifdef MADV_DONTFORK
int ret = madvise(start, size, MADV_DONTFORK);
if (ret) {
perror("madvice");
exit(1);
}
#else
fprintf(stderr,
"Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
exit(1);
#endif
}
}
| {
"code": [
"#endif",
"#endif",
"#ifdef MADV_DONTFORK",
" int ret = madvise(start, size, MADV_DONTFORK);",
" perror(\"madvice\");",
"#else",
" fprintf(stderr,",
" \"Need MADV_DONTFORK in absence of synchronous KVM MMU\\n\");",
" exit(1);",
"#endif"
],
"line_no": [
29,
29,
7,
9,
15,
21,
23,
25,
27,
29
]
} | void FUNC_0(void *VAR_0, size_t VAR_1)
{
if (!kvm_has_sync_mmu()) {
#ifdef MADV_DONTFORK
int ret = madvise(VAR_0, VAR_1, MADV_DONTFORK);
if (ret) {
perror("madvice");
exit(1);
}
#else
fprintf(stderr,
"Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
exit(1);
#endif
}
}
| [
"void FUNC_0(void *VAR_0, size_t VAR_1)\n{",
"if (!kvm_has_sync_mmu()) {",
"#ifdef MADV_DONTFORK\nint ret = madvise(VAR_0, VAR_1, MADV_DONTFORK);",
"if (ret) {",
"perror(\"madvice\");",
"exit(1);",
"}",
"#else\nfprintf(stderr,\n\"Need MADV_DONTFORK in absence of synchronous KVM MMU\\n\");",
"exit(1);",
"#endif\n}",
"}"
] | [
0,
0,
1,
0,
1,
0,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29,
31
],
[
33
]
] |
24,775 | static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
ASSContext *ass = s->priv_data;
uint8_t *p, *end;
if (ass->event_index >= ass->event_count)
return AVERROR(EIO);
p = ass->event[ass->event_index];
end = strchr(p, '\n');
av_new_packet(pkt, end ? end - p + 1 : strlen(p));
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pos = p - ass->event_buffer + s->streams[0]->codec->extradata_size;
pkt->pts = pkt->dts = get_pts(p);
memcpy(pkt->data, p, pkt->size);
ass->event_index++;
return 0;
}
| false | FFmpeg | e9ba3098319f78c91470c05da988d865491852c5 | static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
ASSContext *ass = s->priv_data;
uint8_t *p, *end;
if (ass->event_index >= ass->event_count)
return AVERROR(EIO);
p = ass->event[ass->event_index];
end = strchr(p, '\n');
av_new_packet(pkt, end ? end - p + 1 : strlen(p));
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pos = p - ass->event_buffer + s->streams[0]->codec->extradata_size;
pkt->pts = pkt->dts = get_pts(p);
memcpy(pkt->data, p, pkt->size);
ass->event_index++;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
ASSContext *ass = VAR_0->priv_data;
uint8_t *p, *end;
if (ass->event_index >= ass->event_count)
return AVERROR(EIO);
p = ass->event[ass->event_index];
end = strchr(p, '\n');
av_new_packet(VAR_1, end ? end - p + 1 : strlen(p));
VAR_1->flags |= AV_PKT_FLAG_KEY;
VAR_1->pos = p - ass->event_buffer + VAR_0->streams[0]->codec->extradata_size;
VAR_1->pts = VAR_1->dts = get_pts(p);
memcpy(VAR_1->data, p, VAR_1->size);
ass->event_index++;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"ASSContext *ass = VAR_0->priv_data;",
"uint8_t *p, *end;",
"if (ass->event_index >= ass->event_count)\nreturn AVERROR(EIO);",
"p = ass->event[ass->event_index];",
"end = strchr(p, '\\n');",
"av_new_packet(VAR_1, end ? end - p + 1 : strlen(p));",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"VAR_1->pos = p - ass->event_buffer + VAR_0->streams[0]->codec->extradata_size;",
"VAR_1->pts = VAR_1->dts = get_pts(p);",
"memcpy(VAR_1->data, p, VAR_1->size);",
"ass->event_index++;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
]
] |
24,776 | static av_cold int xwd_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int xwd_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"av_freep(&avctx->coded_frame);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
24,777 | av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags)) {
if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->perm_type = FF_IDCT_PERM_SIMPLE;
}
}
if (EXTERNAL_MMX(cpu_flags)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;
c->put_pixels_clamped = ff_put_pixels_clamped_sse2;
c->add_pixels_clamped = ff_add_pixels_clamped_sse2;
}
if (ARCH_X86_64 &&
avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLE)) {
if (EXTERNAL_SSE2(cpu_flags)) {
c->idct_put = ff_simple_idct10_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct10_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
if (EXTERNAL_AVX(cpu_flags)) {
c->idct_put = ff_simple_idct10_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct10_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
}
}
| true | FFmpeg | 7ece8b50b19e140ace13eda6f1a9f45f868c2528 | av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags)) {
if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->perm_type = FF_IDCT_PERM_SIMPLE;
}
}
if (EXTERNAL_MMX(cpu_flags)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;
c->put_pixels_clamped = ff_put_pixels_clamped_sse2;
c->add_pixels_clamped = ff_add_pixels_clamped_sse2;
}
if (ARCH_X86_64 &&
avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLE)) {
if (EXTERNAL_SSE2(cpu_flags)) {
c->idct_put = ff_simple_idct10_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct10_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
if (EXTERNAL_AVX(cpu_flags)) {
c->idct_put = ff_simple_idct10_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct10_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
}
}
| {
"code": [
" if (ARCH_X86_64 &&",
" avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&"
],
"line_no": [
57,
59
]
} | av_cold void FUNC_0(IDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int VAR_0 = av_get_cpu_flags();
if (INLINE_MMX(VAR_0)) {
if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->perm_type = FF_IDCT_PERM_SIMPLE;
}
}
if (EXTERNAL_MMX(VAR_0)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
}
if (EXTERNAL_SSE2(VAR_0)) {
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;
c->put_pixels_clamped = ff_put_pixels_clamped_sse2;
c->add_pixels_clamped = ff_add_pixels_clamped_sse2;
}
if (ARCH_X86_64 &&
avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLE)) {
if (EXTERNAL_SSE2(VAR_0)) {
c->idct_put = ff_simple_idct10_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct10_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
if (EXTERNAL_AVX(VAR_0)) {
c->idct_put = ff_simple_idct10_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct10_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
}
}
| [
"av_cold void FUNC_0(IDCTDSPContext *c, AVCodecContext *avctx,\nunsigned high_bit_depth)\n{",
"int VAR_0 = av_get_cpu_flags();",
"if (INLINE_MMX(VAR_0)) {",
"if (!high_bit_depth &&\navctx->lowres == 0 &&\n(avctx->idct_algo == FF_IDCT_AUTO ||\navctx->idct_algo == FF_IDCT_SIMPLEAUTO ||\navctx->idct_algo == FF_IDCT_SIMPLEMMX)) {",
"c->idct_put = ff_simple_idct_put_mmx;",
"c->idct_add = ff_simple_idct_add_mmx;",
"c->idct = ff_simple_idct_mmx;",
"c->perm_type = FF_IDCT_PERM_SIMPLE;",
"}",
"}",
"if (EXTERNAL_MMX(VAR_0)) {",
"c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;",
"c->put_pixels_clamped = ff_put_pixels_clamped_mmx;",
"c->add_pixels_clamped = ff_add_pixels_clamped_mmx;",
"}",
"if (EXTERNAL_SSE2(VAR_0)) {",
"c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;",
"c->put_pixels_clamped = ff_put_pixels_clamped_sse2;",
"c->add_pixels_clamped = ff_add_pixels_clamped_sse2;",
"}",
"if (ARCH_X86_64 &&\navctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&\n(avctx->idct_algo == FF_IDCT_AUTO ||\navctx->idct_algo == FF_IDCT_SIMPLEAUTO ||\navctx->idct_algo == FF_IDCT_SIMPLE)) {",
"if (EXTERNAL_SSE2(VAR_0)) {",
"c->idct_put = ff_simple_idct10_put_sse2;",
"c->idct_add = NULL;",
"c->idct = ff_simple_idct10_sse2;",
"c->perm_type = FF_IDCT_PERM_TRANSPOSE;",
"}",
"if (EXTERNAL_AVX(VAR_0)) {",
"c->idct_put = ff_simple_idct10_put_avx;",
"c->idct_add = NULL;",
"c->idct = ff_simple_idct10_avx;",
"c->perm_type = FF_IDCT_PERM_TRANSPOSE;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
24,778 | static void send_msg(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMIRcvBufEntry *msg;
uint8_t *buf;
uint8_t netfn, rqLun, rsLun, rqSeq;
IPMI_CHECK_CMD_LEN(3);
if (cmd[2] != 0) {
/* We only handle channel 0 with no options */
rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
return;
}
IPMI_CHECK_CMD_LEN(10);
if (cmd[3] != 0x40) {
/* We only emulate a MC at address 0x40. */
rsp[2] = 0x83; /* NAK on write */
return;
}
cmd += 3; /* Skip the header. */
cmd_len -= 3;
/*
* At this point we "send" the message successfully. Any error will
* be returned in the response.
*/
if (ipmb_checksum(cmd, cmd_len, 0) != 0 ||
cmd[3] != 0x20) { /* Improper response address */
return; /* No response */
}
netfn = cmd[1] >> 2;
rqLun = cmd[4] & 0x3;
rsLun = cmd[1] & 0x3;
rqSeq = cmd[4] >> 2;
if (rqLun != 2) {
/* We only support LUN 2 coming back to us. */
return;
}
msg = g_malloc(sizeof(*msg));
msg->buf[0] = ((netfn | 1) << 2) | rqLun; /* NetFN, and make a response */
msg->buf[1] = ipmb_checksum(msg->buf, 1, 0);
msg->buf[2] = cmd[0]; /* rsSA */
msg->buf[3] = (rqSeq << 2) | rsLun;
msg->buf[4] = cmd[5]; /* Cmd */
msg->buf[5] = 0; /* Completion Code */
msg->len = 6;
if ((cmd[1] >> 2) != IPMI_NETFN_APP || cmd[5] != IPMI_CMD_GET_DEVICE_ID) {
/* Not a command we handle. */
msg->buf[5] = IPMI_CC_INVALID_CMD;
goto end_msg;
}
buf = msg->buf + msg->len; /* After the CC */
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
buf[4] = 0x51;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = 0;
buf[9] = 0;
buf[10] = 0;
msg->len += 11;
end_msg:
msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
msg->len++;
qemu_mutex_lock(&ibs->lock);
QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
k->set_atn(s, 1, attn_irq_enabled(ibs));
qemu_mutex_unlock(&ibs->lock);
}
| true | qemu | 4f298a4b2957b7833bc607c951ca27c458d98d88 | static void send_msg(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMIRcvBufEntry *msg;
uint8_t *buf;
uint8_t netfn, rqLun, rsLun, rqSeq;
IPMI_CHECK_CMD_LEN(3);
if (cmd[2] != 0) {
rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
return;
}
IPMI_CHECK_CMD_LEN(10);
if (cmd[3] != 0x40) {
rsp[2] = 0x83;
return;
}
cmd += 3;
cmd_len -= 3;
if (ipmb_checksum(cmd, cmd_len, 0) != 0 ||
cmd[3] != 0x20) {
return;
}
netfn = cmd[1] >> 2;
rqLun = cmd[4] & 0x3;
rsLun = cmd[1] & 0x3;
rqSeq = cmd[4] >> 2;
if (rqLun != 2) {
return;
}
msg = g_malloc(sizeof(*msg));
msg->buf[0] = ((netfn | 1) << 2) | rqLun;
msg->buf[1] = ipmb_checksum(msg->buf, 1, 0);
msg->buf[2] = cmd[0];
msg->buf[3] = (rqSeq << 2) | rsLun;
msg->buf[4] = cmd[5];
msg->buf[5] = 0;
msg->len = 6;
if ((cmd[1] >> 2) != IPMI_NETFN_APP || cmd[5] != IPMI_CMD_GET_DEVICE_ID) {
msg->buf[5] = IPMI_CC_INVALID_CMD;
goto end_msg;
}
buf = msg->buf + msg->len;
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
buf[4] = 0x51;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = 0;
buf[9] = 0;
buf[10] = 0;
msg->len += 11;
end_msg:
msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
msg->len++;
qemu_mutex_lock(&ibs->lock);
QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
k->set_atn(s, 1, attn_irq_enabled(ibs));
qemu_mutex_unlock(&ibs->lock);
}
| {
"code": [
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(10);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);"
],
"line_no": [
23,
23,
23,
23,
39,
23,
23,
23,
23
]
} | static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{
IPMIInterface *s = VAR_0->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMIRcvBufEntry *msg;
uint8_t *buf;
uint8_t netfn, rqLun, rsLun, rqSeq;
IPMI_CHECK_CMD_LEN(3);
if (VAR_1[2] != 0) {
VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;
return;
}
IPMI_CHECK_CMD_LEN(10);
if (VAR_1[3] != 0x40) {
VAR_3[2] = 0x83;
return;
}
VAR_1 += 3;
VAR_2 -= 3;
if (ipmb_checksum(VAR_1, VAR_2, 0) != 0 ||
VAR_1[3] != 0x20) {
return;
}
netfn = VAR_1[1] >> 2;
rqLun = VAR_1[4] & 0x3;
rsLun = VAR_1[1] & 0x3;
rqSeq = VAR_1[4] >> 2;
if (rqLun != 2) {
return;
}
msg = g_malloc(sizeof(*msg));
msg->buf[0] = ((netfn | 1) << 2) | rqLun;
msg->buf[1] = ipmb_checksum(msg->buf, 1, 0);
msg->buf[2] = VAR_1[0];
msg->buf[3] = (rqSeq << 2) | rsLun;
msg->buf[4] = VAR_1[5];
msg->buf[5] = 0;
msg->len = 6;
if ((VAR_1[1] >> 2) != IPMI_NETFN_APP || VAR_1[5] != IPMI_CMD_GET_DEVICE_ID) {
msg->buf[5] = IPMI_CC_INVALID_CMD;
goto end_msg;
}
buf = msg->buf + msg->len;
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
buf[4] = 0x51;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = 0;
buf[9] = 0;
buf[10] = 0;
msg->len += 11;
end_msg:
msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
msg->len++;
qemu_mutex_lock(&VAR_0->lock);
QTAILQ_INSERT_TAIL(&VAR_0->rcvbufs, msg, entry);
VAR_0->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
k->set_atn(s, 1, attn_irq_enabled(VAR_0));
qemu_mutex_unlock(&VAR_0->lock);
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{",
"IPMIInterface *s = VAR_0->parent.intf;",
"IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);",
"IPMIRcvBufEntry *msg;",
"uint8_t *buf;",
"uint8_t netfn, rqLun, rsLun, rqSeq;",
"IPMI_CHECK_CMD_LEN(3);",
"if (VAR_1[2] != 0) {",
"VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;",
"return;",
"}",
"IPMI_CHECK_CMD_LEN(10);",
"if (VAR_1[3] != 0x40) {",
"VAR_3[2] = 0x83;",
"return;",
"}",
"VAR_1 += 3;",
"VAR_2 -= 3;",
"if (ipmb_checksum(VAR_1, VAR_2, 0) != 0 ||\nVAR_1[3] != 0x20) {",
"return;",
"}",
"netfn = VAR_1[1] >> 2;",
"rqLun = VAR_1[4] & 0x3;",
"rsLun = VAR_1[1] & 0x3;",
"rqSeq = VAR_1[4] >> 2;",
"if (rqLun != 2) {",
"return;",
"}",
"msg = g_malloc(sizeof(*msg));",
"msg->buf[0] = ((netfn | 1) << 2) | rqLun;",
"msg->buf[1] = ipmb_checksum(msg->buf, 1, 0);",
"msg->buf[2] = VAR_1[0];",
"msg->buf[3] = (rqSeq << 2) | rsLun;",
"msg->buf[4] = VAR_1[5];",
"msg->buf[5] = 0;",
"msg->len = 6;",
"if ((VAR_1[1] >> 2) != IPMI_NETFN_APP || VAR_1[5] != IPMI_CMD_GET_DEVICE_ID) {",
"msg->buf[5] = IPMI_CC_INVALID_CMD;",
"goto end_msg;",
"}",
"buf = msg->buf + msg->len;",
"buf[0] = 0;",
"buf[1] = 0;",
"buf[2] = 0;",
"buf[3] = 0;",
"buf[4] = 0x51;",
"buf[5] = 0;",
"buf[6] = 0;",
"buf[7] = 0;",
"buf[8] = 0;",
"buf[9] = 0;",
"buf[10] = 0;",
"msg->len += 11;",
"end_msg:\nmsg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);",
"msg->len++;",
"qemu_mutex_lock(&VAR_0->lock);",
"QTAILQ_INSERT_TAIL(&VAR_0->rcvbufs, msg, entry);",
"VAR_0->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;",
"k->set_atn(s, 1, attn_irq_enabled(VAR_0));",
"qemu_mutex_unlock(&VAR_0->lock);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
]
] |
24,779 | static void render_slice(Vp3DecodeContext *s, int slice)
{
int x, y, i, j, fragment;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
int motion_halfpel_index;
uint8_t *motion_source;
int plane, first_pixel;
if (slice >= s->c_superblock_height)
return;
for (plane = 0; plane < 3; plane++) {
uint8_t *output_plane = s->current_frame.data [plane] + s->data_offset[plane];
uint8_t * last_plane = s-> last_frame.data [plane] + s->data_offset[plane];
uint8_t *golden_plane = s-> golden_frame.data [plane] + s->data_offset[plane];
int stride = s->current_frame.linesize[plane];
int plane_width = s->width >> (plane && s->chroma_x_shift);
int plane_height = s->height >> (plane && s->chroma_y_shift);
int8_t (*motion_val)[2] = s->motion_val[!!plane];
int sb_x, sb_y = slice << (!plane && s->chroma_y_shift);
int slice_height = sb_y + 1 + (!plane && s->chroma_y_shift);
int slice_width = plane ? s->c_superblock_width : s->y_superblock_width;
int fragment_width = s->fragment_width[!!plane];
int fragment_height = s->fragment_height[!!plane];
int fragment_start = s->fragment_start[plane];
int do_await = !plane && HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME);
if (!s->flipped_image) stride = -stride;
if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY))
continue;
/* for each superblock row in the slice (both of them)... */
for (; sb_y < slice_height; sb_y++) {
/* for each superblock in a row... */
for (sb_x = 0; sb_x < slice_width; sb_x++) {
/* for each block in a superblock... */
for (j = 0; j < 16; j++) {
x = 4*sb_x + hilbert_offset[j][0];
y = 4*sb_y + hilbert_offset[j][1];
fragment = y*fragment_width + x;
i = fragment_start + fragment;
// bounds check
if (x >= fragment_width || y >= fragment_height)
continue;
first_pixel = 8*y*stride + 8*x;
if (do_await && s->all_fragments[i].coding_method != MODE_INTRA)
await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift);
/* transform if this block was coded */
if (s->all_fragments[i].coding_method != MODE_COPY) {
if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
(s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
motion_source= golden_plane;
else
motion_source= last_plane;
motion_source += first_pixel;
motion_halfpel_index = 0;
/* sort out the motion vector if this fragment is coded
* using a motion vector method */
if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
(s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
int src_x, src_y;
motion_x = motion_val[fragment][0];
motion_y = motion_val[fragment][1];
src_x= (motion_x>>1) + 8*x;
src_y= (motion_y>>1) + 8*y;
motion_halfpel_index = motion_x & 0x01;
motion_source += (motion_x >> 1);
motion_halfpel_index |= (motion_y & 0x01) << 1;
motion_source += ((motion_y >> 1) * stride);
if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
uint8_t *temp= s->edge_emu_buffer;
if(stride<0) temp -= 8*stride;
s->dsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
motion_source= temp;
}
}
/* first, take care of copying a block from either the
* previous or the golden frame */
if (s->all_fragments[i].coding_method != MODE_INTRA) {
/* Note, it is possible to implement all MC cases with
put_no_rnd_pixels_l2 which would look more like the
VP3 source but this would be slower as
put_no_rnd_pixels_tab is better optimzed */
if(motion_halfpel_index != 3){
s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
output_plane + first_pixel,
motion_source, stride, 8);
}else{
int d= (motion_x ^ motion_y)>>31; // d is 0 if motion_x and _y have the same sign, else -1
s->dsp.put_no_rnd_pixels_l2[1](
output_plane + first_pixel,
motion_source - d,
motion_source + stride + 1 + d,
stride, 8);
}
}
s->dsp.clear_block(block);
/* invert DCT and place (or add) in final output */
if (s->all_fragments[i].coding_method == MODE_INTRA) {
int index;
index = vp3_dequant(s, s->all_fragments + i, plane, 0, block);
if (index > 63)
continue;
if(s->avctx->idct_algo!=FF_IDCT_VP3)
block[0] += 128<<3;
s->dsp.idct_put(
output_plane + first_pixel,
stride,
block);
} else {
int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block);
if (index > 63)
continue;
if (index > 0) {
s->dsp.idct_add(
output_plane + first_pixel,
stride,
block);
} else {
s->dsp.vp3_idct_dc_add(output_plane + first_pixel, stride, block);
}
}
} else {
/* copy directly from the previous frame */
s->dsp.put_pixels_tab[1][0](
output_plane + first_pixel,
last_plane + first_pixel,
stride, 8);
}
}
}
// Filter up to the last row in the superblock row
if (!s->skip_loop_filter)
apply_loop_filter(s, plane, 4*sb_y - !!sb_y, FFMIN(4*sb_y+3, fragment_height-1));
}
}
/* this looks like a good place for slice dispatch... */
/* algorithm:
* if (slice == s->macroblock_height - 1)
* dispatch (both last slice & 2nd-to-last slice);
* else if (slice > 0)
* dispatch (slice - 1);
*/
vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
}
| true | FFmpeg | a2a12e3358c3bbdc0246ffc94973e58eba50ee30 | static void render_slice(Vp3DecodeContext *s, int slice)
{
int x, y, i, j, fragment;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
int motion_halfpel_index;
uint8_t *motion_source;
int plane, first_pixel;
if (slice >= s->c_superblock_height)
return;
for (plane = 0; plane < 3; plane++) {
uint8_t *output_plane = s->current_frame.data [plane] + s->data_offset[plane];
uint8_t * last_plane = s-> last_frame.data [plane] + s->data_offset[plane];
uint8_t *golden_plane = s-> golden_frame.data [plane] + s->data_offset[plane];
int stride = s->current_frame.linesize[plane];
int plane_width = s->width >> (plane && s->chroma_x_shift);
int plane_height = s->height >> (plane && s->chroma_y_shift);
int8_t (*motion_val)[2] = s->motion_val[!!plane];
int sb_x, sb_y = slice << (!plane && s->chroma_y_shift);
int slice_height = sb_y + 1 + (!plane && s->chroma_y_shift);
int slice_width = plane ? s->c_superblock_width : s->y_superblock_width;
int fragment_width = s->fragment_width[!!plane];
int fragment_height = s->fragment_height[!!plane];
int fragment_start = s->fragment_start[plane];
int do_await = !plane && HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME);
if (!s->flipped_image) stride = -stride;
if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY))
continue;
for (; sb_y < slice_height; sb_y++) {
for (sb_x = 0; sb_x < slice_width; sb_x++) {
for (j = 0; j < 16; j++) {
x = 4*sb_x + hilbert_offset[j][0];
y = 4*sb_y + hilbert_offset[j][1];
fragment = y*fragment_width + x;
i = fragment_start + fragment;
if (x >= fragment_width || y >= fragment_height)
continue;
first_pixel = 8*y*stride + 8*x;
if (do_await && s->all_fragments[i].coding_method != MODE_INTRA)
await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift);
if (s->all_fragments[i].coding_method != MODE_COPY) {
if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
(s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
motion_source= golden_plane;
else
motion_source= last_plane;
motion_source += first_pixel;
motion_halfpel_index = 0;
if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
(s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
int src_x, src_y;
motion_x = motion_val[fragment][0];
motion_y = motion_val[fragment][1];
src_x= (motion_x>>1) + 8*x;
src_y= (motion_y>>1) + 8*y;
motion_halfpel_index = motion_x & 0x01;
motion_source += (motion_x >> 1);
motion_halfpel_index |= (motion_y & 0x01) << 1;
motion_source += ((motion_y >> 1) * stride);
if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
uint8_t *temp= s->edge_emu_buffer;
if(stride<0) temp -= 8*stride;
s->dsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
motion_source= temp;
}
}
if (s->all_fragments[i].coding_method != MODE_INTRA) {
if(motion_halfpel_index != 3){
s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
output_plane + first_pixel,
motion_source, stride, 8);
}else{
int d= (motion_x ^ motion_y)>>31;
s->dsp.put_no_rnd_pixels_l2[1](
output_plane + first_pixel,
motion_source - d,
motion_source + stride + 1 + d,
stride, 8);
}
}
s->dsp.clear_block(block);
if (s->all_fragments[i].coding_method == MODE_INTRA) {
int index;
index = vp3_dequant(s, s->all_fragments + i, plane, 0, block);
if (index > 63)
continue;
if(s->avctx->idct_algo!=FF_IDCT_VP3)
block[0] += 128<<3;
s->dsp.idct_put(
output_plane + first_pixel,
stride,
block);
} else {
int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block);
if (index > 63)
continue;
if (index > 0) {
s->dsp.idct_add(
output_plane + first_pixel,
stride,
block);
} else {
s->dsp.vp3_idct_dc_add(output_plane + first_pixel, stride, block);
}
}
} else {
s->dsp.put_pixels_tab[1][0](
output_plane + first_pixel,
last_plane + first_pixel,
stride, 8);
}
}
}
if (!s->skip_loop_filter)
apply_loop_filter(s, plane, 4*sb_y - !!sb_y, FFMIN(4*sb_y+3, fragment_height-1));
}
}
vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
}
| {
"code": [
" int index;",
" index = vp3_dequant(s, s->all_fragments + i, plane, 0, block);",
" if (index > 63)",
" continue;",
" int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block);",
" if (index > 63)",
" continue;",
" if (index > 0) {"
],
"line_no": [
243,
245,
247,
249,
265,
247,
249,
271
]
} | static void FUNC_0(Vp3DecodeContext *VAR_0, int VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
int VAR_7 = 0xdeadbeef, VAR_8 = 0xdeadbeef;
int VAR_9;
uint8_t *motion_source;
int VAR_10, VAR_11;
if (VAR_1 >= VAR_0->c_superblock_height)
return;
for (VAR_10 = 0; VAR_10 < 3; VAR_10++) {
uint8_t *output_plane = VAR_0->current_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];
uint8_t * last_plane = VAR_0-> last_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];
uint8_t *golden_plane = VAR_0-> golden_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];
int VAR_12 = VAR_0->current_frame.linesize[VAR_10];
int VAR_13 = VAR_0->width >> (VAR_10 && VAR_0->chroma_x_shift);
int VAR_14 = VAR_0->height >> (VAR_10 && VAR_0->chroma_y_shift);
int8_t (*motion_val)[2] = VAR_0->motion_val[!!VAR_10];
int VAR_15, VAR_16 = VAR_1 << (!VAR_10 && VAR_0->chroma_y_shift);
int VAR_17 = VAR_16 + 1 + (!VAR_10 && VAR_0->chroma_y_shift);
int VAR_18 = VAR_10 ? VAR_0->c_superblock_width : VAR_0->y_superblock_width;
int VAR_19 = VAR_0->VAR_19[!!VAR_10];
int VAR_20 = VAR_0->VAR_20[!!VAR_10];
int VAR_21 = VAR_0->VAR_21[VAR_10];
int VAR_22 = !VAR_10 && HAVE_THREADS && (VAR_0->avctx->active_thread_type&FF_THREAD_FRAME);
if (!VAR_0->flipped_image) VAR_12 = -VAR_12;
if (CONFIG_GRAY && VAR_10 && (VAR_0->avctx->flags & CODEC_FLAG_GRAY))
continue;
for (; VAR_16 < VAR_17; VAR_16++) {
for (VAR_15 = 0; VAR_15 < VAR_18; VAR_15++) {
for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {
VAR_2 = 4*VAR_15 + hilbert_offset[VAR_5][0];
VAR_3 = 4*VAR_16 + hilbert_offset[VAR_5][1];
VAR_6 = VAR_3*VAR_19 + VAR_2;
VAR_4 = VAR_21 + VAR_6;
if (VAR_2 >= VAR_19 || VAR_3 >= VAR_20)
continue;
VAR_11 = 8*VAR_3*VAR_12 + 8*VAR_2;
if (VAR_22 && VAR_0->all_fragments[VAR_4].coding_method != MODE_INTRA)
await_reference_row(VAR_0, &VAR_0->all_fragments[VAR_4], motion_val[VAR_6][1], (16*VAR_3) >> VAR_0->chroma_y_shift);
if (VAR_0->all_fragments[VAR_4].coding_method != MODE_COPY) {
if ((VAR_0->all_fragments[VAR_4].coding_method == MODE_USING_GOLDEN) ||
(VAR_0->all_fragments[VAR_4].coding_method == MODE_GOLDEN_MV))
motion_source= golden_plane;
else
motion_source= last_plane;
motion_source += VAR_11;
VAR_9 = 0;
if ((VAR_0->all_fragments[VAR_4].coding_method > MODE_INTRA) &&
(VAR_0->all_fragments[VAR_4].coding_method != MODE_USING_GOLDEN)) {
int VAR_23, VAR_24;
VAR_7 = motion_val[VAR_6][0];
VAR_8 = motion_val[VAR_6][1];
VAR_23= (VAR_7>>1) + 8*VAR_2;
VAR_24= (VAR_8>>1) + 8*VAR_3;
VAR_9 = VAR_7 & 0x01;
motion_source += (VAR_7 >> 1);
VAR_9 |= (VAR_8 & 0x01) << 1;
motion_source += ((VAR_8 >> 1) * VAR_12);
if(VAR_23<0 || VAR_24<0 || VAR_23 + 9 >= VAR_13 || VAR_24 + 9 >= VAR_14){
uint8_t *temp= VAR_0->edge_emu_buffer;
if(VAR_12<0) temp -= 8*VAR_12;
VAR_0->dsp.emulated_edge_mc(temp, motion_source, VAR_12, 9, 9, VAR_23, VAR_24, VAR_13, VAR_14);
motion_source= temp;
}
}
if (VAR_0->all_fragments[VAR_4].coding_method != MODE_INTRA) {
if(VAR_9 != 3){
VAR_0->dsp.put_no_rnd_pixels_tab[1][VAR_9](
output_plane + VAR_11,
motion_source, VAR_12, 8);
}else{
int VAR_25= (VAR_7 ^ VAR_8)>>31;
VAR_0->dsp.put_no_rnd_pixels_l2[1](
output_plane + VAR_11,
motion_source - VAR_25,
motion_source + VAR_12 + 1 + VAR_25,
VAR_12, 8);
}
}
VAR_0->dsp.clear_block(block);
if (VAR_0->all_fragments[VAR_4].coding_method == MODE_INTRA) {
int VAR_27;
VAR_27 = vp3_dequant(VAR_0, VAR_0->all_fragments + VAR_4, VAR_10, 0, block);
if (VAR_27 > 63)
continue;
if(VAR_0->avctx->idct_algo!=FF_IDCT_VP3)
block[0] += 128<<3;
VAR_0->dsp.idct_put(
output_plane + VAR_11,
VAR_12,
block);
} else {
int VAR_27 = vp3_dequant(VAR_0, VAR_0->all_fragments + VAR_4, VAR_10, 1, block);
if (VAR_27 > 63)
continue;
if (VAR_27 > 0) {
VAR_0->dsp.idct_add(
output_plane + VAR_11,
VAR_12,
block);
} else {
VAR_0->dsp.vp3_idct_dc_add(output_plane + VAR_11, VAR_12, block);
}
}
} else {
VAR_0->dsp.put_pixels_tab[1][0](
output_plane + VAR_11,
last_plane + VAR_11,
VAR_12, 8);
}
}
}
if (!VAR_0->skip_loop_filter)
apply_loop_filter(VAR_0, VAR_10, 4*VAR_16 - !!VAR_16, FFMIN(4*VAR_16+3, VAR_20-1));
}
}
vp3_draw_horiz_band(VAR_0, FFMIN((32 << VAR_0->chroma_y_shift) * (VAR_1 + 1) -16, VAR_0->height-16));
}
| [
"static void FUNC_0(Vp3DecodeContext *VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"LOCAL_ALIGNED_16(DCTELEM, block, [64]);",
"int VAR_7 = 0xdeadbeef, VAR_8 = 0xdeadbeef;",
"int VAR_9;",
"uint8_t *motion_source;",
"int VAR_10, VAR_11;",
"if (VAR_1 >= VAR_0->c_superblock_height)\nreturn;",
"for (VAR_10 = 0; VAR_10 < 3; VAR_10++) {",
"uint8_t *output_plane = VAR_0->current_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];",
"uint8_t * last_plane = VAR_0-> last_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];",
"uint8_t *golden_plane = VAR_0-> golden_frame.data [VAR_10] + VAR_0->data_offset[VAR_10];",
"int VAR_12 = VAR_0->current_frame.linesize[VAR_10];",
"int VAR_13 = VAR_0->width >> (VAR_10 && VAR_0->chroma_x_shift);",
"int VAR_14 = VAR_0->height >> (VAR_10 && VAR_0->chroma_y_shift);",
"int8_t (*motion_val)[2] = VAR_0->motion_val[!!VAR_10];",
"int VAR_15, VAR_16 = VAR_1 << (!VAR_10 && VAR_0->chroma_y_shift);",
"int VAR_17 = VAR_16 + 1 + (!VAR_10 && VAR_0->chroma_y_shift);",
"int VAR_18 = VAR_10 ? VAR_0->c_superblock_width : VAR_0->y_superblock_width;",
"int VAR_19 = VAR_0->VAR_19[!!VAR_10];",
"int VAR_20 = VAR_0->VAR_20[!!VAR_10];",
"int VAR_21 = VAR_0->VAR_21[VAR_10];",
"int VAR_22 = !VAR_10 && HAVE_THREADS && (VAR_0->avctx->active_thread_type&FF_THREAD_FRAME);",
"if (!VAR_0->flipped_image) VAR_12 = -VAR_12;",
"if (CONFIG_GRAY && VAR_10 && (VAR_0->avctx->flags & CODEC_FLAG_GRAY))\ncontinue;",
"for (; VAR_16 < VAR_17; VAR_16++) {",
"for (VAR_15 = 0; VAR_15 < VAR_18; VAR_15++) {",
"for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {",
"VAR_2 = 4*VAR_15 + hilbert_offset[VAR_5][0];",
"VAR_3 = 4*VAR_16 + hilbert_offset[VAR_5][1];",
"VAR_6 = VAR_3*VAR_19 + VAR_2;",
"VAR_4 = VAR_21 + VAR_6;",
"if (VAR_2 >= VAR_19 || VAR_3 >= VAR_20)\ncontinue;",
"VAR_11 = 8*VAR_3*VAR_12 + 8*VAR_2;",
"if (VAR_22 && VAR_0->all_fragments[VAR_4].coding_method != MODE_INTRA)\nawait_reference_row(VAR_0, &VAR_0->all_fragments[VAR_4], motion_val[VAR_6][1], (16*VAR_3) >> VAR_0->chroma_y_shift);",
"if (VAR_0->all_fragments[VAR_4].coding_method != MODE_COPY) {",
"if ((VAR_0->all_fragments[VAR_4].coding_method == MODE_USING_GOLDEN) ||\n(VAR_0->all_fragments[VAR_4].coding_method == MODE_GOLDEN_MV))\nmotion_source= golden_plane;",
"else\nmotion_source= last_plane;",
"motion_source += VAR_11;",
"VAR_9 = 0;",
"if ((VAR_0->all_fragments[VAR_4].coding_method > MODE_INTRA) &&\n(VAR_0->all_fragments[VAR_4].coding_method != MODE_USING_GOLDEN)) {",
"int VAR_23, VAR_24;",
"VAR_7 = motion_val[VAR_6][0];",
"VAR_8 = motion_val[VAR_6][1];",
"VAR_23= (VAR_7>>1) + 8*VAR_2;",
"VAR_24= (VAR_8>>1) + 8*VAR_3;",
"VAR_9 = VAR_7 & 0x01;",
"motion_source += (VAR_7 >> 1);",
"VAR_9 |= (VAR_8 & 0x01) << 1;",
"motion_source += ((VAR_8 >> 1) * VAR_12);",
"if(VAR_23<0 || VAR_24<0 || VAR_23 + 9 >= VAR_13 || VAR_24 + 9 >= VAR_14){",
"uint8_t *temp= VAR_0->edge_emu_buffer;",
"if(VAR_12<0) temp -= 8*VAR_12;",
"VAR_0->dsp.emulated_edge_mc(temp, motion_source, VAR_12, 9, 9, VAR_23, VAR_24, VAR_13, VAR_14);",
"motion_source= temp;",
"}",
"}",
"if (VAR_0->all_fragments[VAR_4].coding_method != MODE_INTRA) {",
"if(VAR_9 != 3){",
"VAR_0->dsp.put_no_rnd_pixels_tab[1][VAR_9](\noutput_plane + VAR_11,\nmotion_source, VAR_12, 8);",
"}else{",
"int VAR_25= (VAR_7 ^ VAR_8)>>31;",
"VAR_0->dsp.put_no_rnd_pixels_l2[1](\noutput_plane + VAR_11,\nmotion_source - VAR_25,\nmotion_source + VAR_12 + 1 + VAR_25,\nVAR_12, 8);",
"}",
"}",
"VAR_0->dsp.clear_block(block);",
"if (VAR_0->all_fragments[VAR_4].coding_method == MODE_INTRA) {",
"int VAR_27;",
"VAR_27 = vp3_dequant(VAR_0, VAR_0->all_fragments + VAR_4, VAR_10, 0, block);",
"if (VAR_27 > 63)\ncontinue;",
"if(VAR_0->avctx->idct_algo!=FF_IDCT_VP3)\nblock[0] += 128<<3;",
"VAR_0->dsp.idct_put(\noutput_plane + VAR_11,\nVAR_12,\nblock);",
"} else {",
"int VAR_27 = vp3_dequant(VAR_0, VAR_0->all_fragments + VAR_4, VAR_10, 1, block);",
"if (VAR_27 > 63)\ncontinue;",
"if (VAR_27 > 0) {",
"VAR_0->dsp.idct_add(\noutput_plane + VAR_11,\nVAR_12,\nblock);",
"} else {",
"VAR_0->dsp.vp3_idct_dc_add(output_plane + VAR_11, VAR_12, block);",
"}",
"}",
"} else {",
"VAR_0->dsp.put_pixels_tab[1][0](\noutput_plane + VAR_11,\nlast_plane + VAR_11,\nVAR_12, 8);",
"}",
"}",
"}",
"if (!VAR_0->skip_loop_filter)\napply_loop_filter(VAR_0, VAR_10, 4*VAR_16 - !!VAR_16, FFMIN(4*VAR_16+3, VAR_20-1));",
"}",
"}",
"vp3_draw_horiz_band(VAR_0, FFMIN((32 << VAR_0->chroma_y_shift) * (VAR_1 + 1) -16, VAR_0->height-16));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
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
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
71
],
[
77
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
99,
101
],
[
105
],
[
109,
111
],
[
117
],
[
119,
121,
123
],
[
125,
127
],
[
131
],
[
133
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
195
],
[
205
],
[
207,
209,
211
],
[
213
],
[
215
],
[
217,
219,
221,
223,
225
],
[
227
],
[
229
],
[
233
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251,
253
],
[
255,
257,
259,
261
],
[
263
],
[
265
],
[
267,
269
],
[
271
],
[
273,
275,
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
295,
297,
299,
301
],
[
305
],
[
307
],
[
309
],
[
315,
317
],
[
319
],
[
321
],
[
341
],
[
343
]
] |
24,780 | static void disas_xtensa_insn(DisasContext *dc)
{
#define HAS_OPTION(opt) do { \
if (!option_enabled(dc, opt)) { \
qemu_log("Option %d is not enabled %s:%d\n", \
(opt), __FILE__, __LINE__); \
goto invalid_opcode; \
} \
} while (0)
#ifdef TARGET_WORDS_BIGENDIAN
#define OP0 (((b0) & 0xf0) >> 4)
#define OP1 (((b2) & 0xf0) >> 4)
#define OP2 ((b2) & 0xf)
#define RRR_R ((b1) & 0xf)
#define RRR_S (((b1) & 0xf0) >> 4)
#define RRR_T ((b0) & 0xf)
#else
#define OP0 (((b0) & 0xf))
#define OP1 (((b2) & 0xf))
#define OP2 (((b2) & 0xf0) >> 4)
#define RRR_R (((b1) & 0xf0) >> 4)
#define RRR_S (((b1) & 0xf))
#define RRR_T (((b0) & 0xf0) >> 4)
#endif
#define RRRN_R RRR_R
#define RRRN_S RRR_S
#define RRRN_T RRR_T
#define RRI8_R RRR_R
#define RRI8_S RRR_S
#define RRI8_T RRR_T
#define RRI8_IMM8 (b2)
#define RRI8_IMM8_SE ((((b2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8)
#ifdef TARGET_WORDS_BIGENDIAN
#define RI16_IMM16 (((b1) << 8) | (b2))
#else
#define RI16_IMM16 (((b2) << 8) | (b1))
#endif
#ifdef TARGET_WORDS_BIGENDIAN
#define CALL_N (((b0) & 0xc) >> 2)
#define CALL_OFFSET ((((b0) & 0x3) << 16) | ((b1) << 8) | (b2))
#else
#define CALL_N (((b0) & 0x30) >> 4)
#define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((b1) << 2) | ((b2) << 10))
#endif
#define CALL_OFFSET_SE \
(((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET)
#define CALLX_N CALL_N
#ifdef TARGET_WORDS_BIGENDIAN
#define CALLX_M ((b0) & 0x3)
#else
#define CALLX_M (((b0) & 0xc0) >> 6)
#endif
#define CALLX_S RRR_S
#define BRI12_M CALLX_M
#define BRI12_S RRR_S
#ifdef TARGET_WORDS_BIGENDIAN
#define BRI12_IMM12 ((((b1) & 0xf) << 8) | (b2))
#else
#define BRI12_IMM12 ((((b1) & 0xf0) >> 4) | ((b2) << 4))
#endif
#define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12)
#define BRI8_M BRI12_M
#define BRI8_R RRI8_R
#define BRI8_S RRI8_S
#define BRI8_IMM8 RRI8_IMM8
#define BRI8_IMM8_SE RRI8_IMM8_SE
#define RSR_SR (b1)
uint8_t b0 = ldub_code(dc->pc);
uint8_t b1 = ldub_code(dc->pc + 1);
uint8_t b2 = ldub_code(dc->pc + 2);
static const uint32_t B4CONST[] = {
0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
static const uint32_t B4CONSTU[] = {
32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
if (OP0 >= 8) {
dc->next_pc = dc->pc + 2;
HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
} else {
dc->next_pc = dc->pc + 3;
}
switch (OP0) {
case 0: /*QRST*/
switch (OP1) {
case 0: /*RST0*/
switch (OP2) {
case 0: /*ST0*/
if ((RRR_R & 0xc) == 0x8) {
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
}
switch (RRR_R) {
case 0: /*SNM0*/
switch (CALLX_M) {
case 0: /*ILL*/
break;
case 1: /*reserved*/
break;
case 2: /*JR*/
switch (CALLX_N) {
case 0: /*RET*/
case 2: /*JX*/
gen_jump(dc, cpu_R[CALLX_S]);
break;
case 1: /*RETWw*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 3: /*reserved*/
break;
}
break;
case 3: /*CALLX*/
switch (CALLX_N) {
case 0: /*CALLX0*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jump(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 1: /*CALLX4w*/
case 2: /*CALLX8w*/
case 3: /*CALLX12w*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
}
break;
case 1: /*MOVSPw*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 2: /*SYNC*/
break;
case 3:
break;
}
break;
case 1: /*AND*/
tcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 2: /*OR*/
tcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 3: /*XOR*/
tcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 4: /*ST1*/
switch (RRR_R) {
case 0: /*SSR*/
gen_right_shift_sar(dc, cpu_R[RRR_S]);
break;
case 1: /*SSL*/
gen_left_shift_sar(dc, cpu_R[RRR_S]);
break;
case 2: /*SSA8L*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 3: /*SSA8B*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_left_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 4: /*SSAI*/
{
TCGv_i32 tmp = tcg_const_i32(
RRR_S | ((RRR_T & 1) << 4));
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 6: /*RER*/
break;
case 7: /*WER*/
break;
case 8: /*ROTWw*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 14: /*NSAu*/
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
case 15: /*NSAUu*/
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
default: /*reserved*/
break;
}
break;
case 5: /*TLB*/
break;
case 6: /*RT0*/
switch (RRR_S) {
case 0: /*NEG*/
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
break;
case 1: /*ABS*/
{
int label = gen_new_label();
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
tcg_gen_brcondi_i32(
TCG_COND_GE, cpu_R[RRR_R], 0, label);
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
gen_set_label(label);
}
break;
default: /*reserved*/
break;
}
break;
case 7: /*reserved*/
break;
case 8: /*ADD*/
tcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 9: /*ADD**/
case 10:
case 11:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8);
tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
case 12: /*SUB*/
tcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 13: /*SUB**/
case 14:
case 15:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12);
tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
}
break;
case 1: /*RST1*/
switch (OP2) {
case 0: /*SLLI*/
case 1:
tcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S],
32 - (RRR_T | ((OP2 & 1) << 4)));
break;
case 2: /*SRAI*/
case 3:
tcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T],
RRR_S | ((OP2 & 1) << 4));
break;
case 4: /*SRLI*/
tcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S);
break;
case 6: /*XSR*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
gen_wsr(dc, RSR_SR, tmp);
tcg_temp_free(tmp);
}
break;
/*
* Note: 64 bit ops are used here solely because SAR values
* have range 0..63
*/
#define gen_shift_reg(cmd, reg) do { \
TCGv_i64 tmp = tcg_temp_new_i64(); \
tcg_gen_extu_i32_i64(tmp, reg); \
tcg_gen_##cmd##_i64(v, v, tmp); \
tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \
tcg_temp_free_i64(v); \
tcg_temp_free_i64(tmp); \
} while (0)
#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
case 8: /*SRC*/
{
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]);
gen_shift(shr);
}
break;
case 9: /*SRL*/
if (dc->sar_5bit) {
tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]);
gen_shift(shr);
}
break;
case 10: /*SLL*/
if (dc->sar_m32_5bit) {
tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], dc->sar_m32);
} else {
TCGv_i64 v = tcg_temp_new_i64();
TCGv_i32 s = tcg_const_i32(32);
tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
tcg_gen_andi_i32(s, s, 0x3f);
tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]);
gen_shift_reg(shl, s);
tcg_temp_free(s);
}
break;
case 11: /*SRA*/
if (dc->sar_5bit) {
tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]);
gen_shift(sar);
}
break;
#undef gen_shift
#undef gen_shift_reg
case 12: /*MUL16U*/
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
case 13: /*MUL16S*/
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
default: /*reserved*/
break;
}
break;
case 2: /*RST2*/
break;
case 3: /*RST3*/
switch (OP2) {
case 0: /*RSR*/
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
break;
case 1: /*WSR*/
gen_wsr(dc, RSR_SR, cpu_R[RRR_T]);
break;
case 2: /*SEXTu*/
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
int shift = 24 - RRR_T;
if (shift == 24) {
tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else if (shift == 16) {
tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else {
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift);
tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift);
tcg_temp_free(tmp);
}
}
break;
case 3: /*CLAMPSu*/
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
TCGv_i32 tmp1 = tcg_temp_new_i32();
TCGv_i32 tmp2 = tcg_temp_new_i32();
int label = gen_new_label();
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T);
tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]);
tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7));
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label);
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31);
tcg_gen_xori_i32(cpu_R[RRR_R], tmp1,
0xffffffff >> (25 - RRR_T));
gen_set_label(label);
tcg_temp_free(tmp1);
tcg_temp_free(tmp2);
}
break;
case 4: /*MINu*/
case 5: /*MAXu*/
case 6: /*MINUu*/
case 7: /*MAXUu*/
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
static const TCGCond cond[] = {
TCG_COND_LE,
TCG_COND_GE,
TCG_COND_LEU,
TCG_COND_GEU
};
int label = gen_new_label();
if (RRR_R != RRR_T) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_S], cpu_R[RRR_T], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
} else {
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_T], cpu_R[RRR_S], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
}
gen_set_label(label);
}
break;
case 8: /*MOVEQZ*/
case 9: /*MOVNEZ*/
case 10: /*MOVLTZ*/
case 11: /*MOVGEZ*/
{
static const TCGCond cond[] = {
TCG_COND_NE,
TCG_COND_EQ,
TCG_COND_GE,
TCG_COND_LT
};
int label = gen_new_label();
tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
gen_set_label(label);
}
break;
case 12: /*MOVFp*/
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 13: /*MOVTp*/
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 14: /*RUR*/
{
int st = (RRR_S << 4) + RRR_T;
if (uregnames[st]) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]);
} else {
qemu_log("RUR %d not implemented, ", st);
}
}
break;
case 15: /*WUR*/
{
if (uregnames[RSR_SR]) {
tcg_gen_mov_i32(cpu_UR[RSR_SR], cpu_R[RRR_T]);
} else {
qemu_log("WUR %d not implemented, ", RSR_SR);
}
}
break;
}
break;
case 4: /*EXTUI*/
case 5:
{
int shiftimm = RRR_S | (OP1 << 4);
int maskimm = (1 << (OP2 + 1)) - 1;
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
tcg_temp_free(tmp);
}
break;
case 6: /*CUST0*/
break;
case 7: /*CUST1*/
break;
case 8: /*LSCXp*/
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 9: /*LSC4*/
break;
case 10: /*FP0*/
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
case 11: /*FP1*/
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
default: /*reserved*/
break;
}
break;
case 1: /*L32R*/
{
TCGv_i32 tmp = tcg_const_i32(
(0xfffc0000 | (RI16_IMM16 << 2)) +
((dc->pc + 3) & ~3));
/* no ext L32R */
tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, 0);
tcg_temp_free(tmp);
}
break;
case 2: /*LSAI*/
#define gen_load_store(type, shift) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \
tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
switch (RRI8_R) {
case 0: /*L8UI*/
gen_load_store(ld8u, 0);
break;
case 1: /*L16UI*/
gen_load_store(ld16u, 1);
break;
case 2: /*L32I*/
gen_load_store(ld32u, 2);
break;
case 4: /*S8I*/
gen_load_store(st8, 0);
break;
case 5: /*S16I*/
gen_load_store(st16, 1);
break;
case 6: /*S32I*/
gen_load_store(st32, 2);
break;
case 7: /*CACHEc*/
break;
case 9: /*L16SI*/
gen_load_store(ld16s, 1);
break;
case 10: /*MOVI*/
tcg_gen_movi_i32(cpu_R[RRI8_T],
RRI8_IMM8 | (RRI8_S << 8) |
((RRI8_S & 0x8) ? 0xfffff000 : 0));
break;
case 11: /*L32AIy*/
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(ld32u, 2); /*TODO acquire?*/
break;
case 12: /*ADDI*/
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE);
break;
case 13: /*ADDMI*/
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8);
break;
case 14: /*S32C1Iy*/
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_local_new_i32();
TCGv_i32 addr = tcg_temp_local_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]);
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);
tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0);
tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T],
cpu_SR[SCOMPARE1], label);
tcg_gen_qemu_st32(tmp, addr, 0);
gen_set_label(label);
tcg_temp_free(addr);
tcg_temp_free(tmp);
}
break;
case 15: /*S32RIy*/
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(st32, 2); /*TODO release?*/
break;
default: /*reserved*/
break;
}
break;
#undef gen_load_store
case 3: /*LSCIp*/
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 4: /*MAC16d*/
HAS_OPTION(XTENSA_OPTION_MAC16);
break;
case 5: /*CALLN*/
switch (CALL_N) {
case 0: /*CALL0*/
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jumpi(dc, (dc->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);
break;
case 1: /*CALL4w*/
case 2: /*CALL8w*/
case 3: /*CALL12w*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
case 6: /*SI*/
switch (CALL_N) {
case 0: /*J*/
gen_jumpi(dc, dc->pc + 4 + CALL_OFFSET_SE, 0);
break;
case 1: /*BZ*/
{
static const TCGCond cond[] = {
TCG_COND_EQ, /*BEQZ*/
TCG_COND_NE, /*BNEZ*/
TCG_COND_LT, /*BLTZ*/
TCG_COND_GE, /*BGEZ*/
};
gen_brcondi(dc, cond[BRI12_M & 3], cpu_R[BRI12_S], 0,
4 + BRI12_IMM12_SE);
}
break;
case 2: /*BI0*/
{
static const TCGCond cond[] = {
TCG_COND_EQ, /*BEQI*/
TCG_COND_NE, /*BNEI*/
TCG_COND_LT, /*BLTI*/
TCG_COND_GE, /*BGEI*/
};
gen_brcondi(dc, cond[BRI8_M & 3],
cpu_R[BRI8_S], B4CONST[BRI8_R], 4 + BRI8_IMM8_SE);
}
break;
case 3: /*BI1*/
switch (BRI8_M) {
case 0: /*ENTRYw*/
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 1: /*B1*/
switch (BRI8_R) {
case 0: /*BFp*/
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 1: /*BTp*/
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 8: /*LOOP*/
break;
case 9: /*LOOPNEZ*/
break;
case 10: /*LOOPGTZ*/
break;
default: /*reserved*/
break;
}
break;
case 2: /*BLTUI*/
case 3: /*BGEUI*/
gen_brcondi(dc, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU,
cpu_R[BRI8_S], B4CONSTU[BRI8_R], 4 + BRI8_IMM8_SE);
break;
}
break;
}
break;
case 7: /*B*/
{
TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ;
switch (RRI8_R & 7) {
case 0: /*BNONE*/ /*BANY*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 1: /*BEQ*/ /*BNE*/
case 2: /*BLT*/ /*BGE*/
case 3: /*BLTU*/ /*BGEU*/
{
static const TCGCond cond[] = {
[1] = TCG_COND_EQ,
[2] = TCG_COND_LT,
[3] = TCG_COND_LTU,
[9] = TCG_COND_NE,
[10] = TCG_COND_GE,
[11] = TCG_COND_GEU,
};
gen_brcond(dc, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
}
break;
case 4: /*BALL*/ /*BNALL*/
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcond(dc, eq_ne, tmp, cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 5: /*BBC*/ /*BBS*/
{
TCGv_i32 bit = tcg_const_i32(1);
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f);
tcg_gen_shl_i32(bit, bit, tmp);
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
tcg_temp_free(bit);
}
break;
case 6: /*BBCI*/ /*BBSI*/
case 7:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_S],
1 << (((RRI8_R & 1) << 4) | RRI8_T));
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
}
}
break;
#define gen_narrow_load_store(type) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \
tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
case 8: /*L32I.Nn*/
gen_narrow_load_store(ld32u);
break;
case 9: /*S32I.Nn*/
gen_narrow_load_store(st32);
break;
#undef gen_narrow_load_store
case 10: /*ADD.Nn*/
tcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]);
break;
case 11: /*ADDI.Nn*/
tcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1);
break;
case 12: /*ST2n*/
if (RRRN_T < 8) { /*MOVI.Nn*/
tcg_gen_movi_i32(cpu_R[RRRN_S],
RRRN_R | (RRRN_T << 4) |
((RRRN_T & 6) == 6 ? 0xffffff80 : 0));
} else { /*BEQZ.Nn*/ /*BNEZ.Nn*/
TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ;
gen_brcondi(dc, eq_ne, cpu_R[RRRN_S], 0,
4 + (RRRN_R | ((RRRN_T & 3) << 4)));
}
break;
case 13: /*ST3n*/
switch (RRRN_R) {
case 0: /*MOV.Nn*/
tcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]);
break;
case 15: /*S3*/
switch (RRRN_T) {
case 0: /*RET.Nn*/
gen_jump(dc, cpu_R[0]);
break;
case 1: /*RETW.Nn*/
break;
case 2: /*BREAK.Nn*/
break;
case 3: /*NOP.Nn*/
break;
case 6: /*ILL.Nn*/
break;
default: /*reserved*/
break;
}
break;
default: /*reserved*/
break;
}
break;
default: /*reserved*/
break;
}
dc->pc = dc->next_pc;
return;
invalid_opcode:
qemu_log("INVALID(pc = %08x)\n", dc->pc);
dc->pc = dc->next_pc;
#undef HAS_OPTION
}
| true | qemu | 91a5bb76d47e1b06f0b7b67cae8497d8efc6ab87 | static void disas_xtensa_insn(DisasContext *dc)
{
#define HAS_OPTION(opt) do { \
if (!option_enabled(dc, opt)) { \
qemu_log("Option %d is not enabled %s:%d\n", \
(opt), __FILE__, __LINE__); \
goto invalid_opcode; \
} \
} while (0)
#ifdef TARGET_WORDS_BIGENDIAN
#define OP0 (((b0) & 0xf0) >> 4)
#define OP1 (((b2) & 0xf0) >> 4)
#define OP2 ((b2) & 0xf)
#define RRR_R ((b1) & 0xf)
#define RRR_S (((b1) & 0xf0) >> 4)
#define RRR_T ((b0) & 0xf)
#else
#define OP0 (((b0) & 0xf))
#define OP1 (((b2) & 0xf))
#define OP2 (((b2) & 0xf0) >> 4)
#define RRR_R (((b1) & 0xf0) >> 4)
#define RRR_S (((b1) & 0xf))
#define RRR_T (((b0) & 0xf0) >> 4)
#endif
#define RRRN_R RRR_R
#define RRRN_S RRR_S
#define RRRN_T RRR_T
#define RRI8_R RRR_R
#define RRI8_S RRR_S
#define RRI8_T RRR_T
#define RRI8_IMM8 (b2)
#define RRI8_IMM8_SE ((((b2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8)
#ifdef TARGET_WORDS_BIGENDIAN
#define RI16_IMM16 (((b1) << 8) | (b2))
#else
#define RI16_IMM16 (((b2) << 8) | (b1))
#endif
#ifdef TARGET_WORDS_BIGENDIAN
#define CALL_N (((b0) & 0xc) >> 2)
#define CALL_OFFSET ((((b0) & 0x3) << 16) | ((b1) << 8) | (b2))
#else
#define CALL_N (((b0) & 0x30) >> 4)
#define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((b1) << 2) | ((b2) << 10))
#endif
#define CALL_OFFSET_SE \
(((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET)
#define CALLX_N CALL_N
#ifdef TARGET_WORDS_BIGENDIAN
#define CALLX_M ((b0) & 0x3)
#else
#define CALLX_M (((b0) & 0xc0) >> 6)
#endif
#define CALLX_S RRR_S
#define BRI12_M CALLX_M
#define BRI12_S RRR_S
#ifdef TARGET_WORDS_BIGENDIAN
#define BRI12_IMM12 ((((b1) & 0xf) << 8) | (b2))
#else
#define BRI12_IMM12 ((((b1) & 0xf0) >> 4) | ((b2) << 4))
#endif
#define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12)
#define BRI8_M BRI12_M
#define BRI8_R RRI8_R
#define BRI8_S RRI8_S
#define BRI8_IMM8 RRI8_IMM8
#define BRI8_IMM8_SE RRI8_IMM8_SE
#define RSR_SR (b1)
uint8_t b0 = ldub_code(dc->pc);
uint8_t b1 = ldub_code(dc->pc + 1);
uint8_t b2 = ldub_code(dc->pc + 2);
static const uint32_t B4CONST[] = {
0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
static const uint32_t B4CONSTU[] = {
32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
if (OP0 >= 8) {
dc->next_pc = dc->pc + 2;
HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
} else {
dc->next_pc = dc->pc + 3;
}
switch (OP0) {
case 0:
switch (OP1) {
case 0:
switch (OP2) {
case 0:
if ((RRR_R & 0xc) == 0x8) {
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
}
switch (RRR_R) {
case 0:
switch (CALLX_M) {
case 0:
break;
case 1:
break;
case 2:
switch (CALLX_N) {
case 0:
case 2:
gen_jump(dc, cpu_R[CALLX_S]);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 3:
break;
}
break;
case 3:
switch (CALLX_N) {
case 0:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jump(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
}
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 2:
break;
case 3:
break;
}
break;
case 1:
tcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 2:
tcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 3:
tcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 4:
switch (RRR_R) {
case 0:
gen_right_shift_sar(dc, cpu_R[RRR_S]);
break;
case 1:
gen_left_shift_sar(dc, cpu_R[RRR_S]);
break;
case 2:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 3:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_left_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 4:
{
TCGv_i32 tmp = tcg_const_i32(
RRR_S | ((RRR_T & 1) << 4));
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 6:
break;
case 7:
break;
case 8:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 14:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
default:
break;
}
break;
case 5:
break;
case 6:
switch (RRR_S) {
case 0:
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
break;
case 1:
{
int label = gen_new_label();
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
tcg_gen_brcondi_i32(
TCG_COND_GE, cpu_R[RRR_R], 0, label);
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
gen_set_label(label);
}
break;
default:
break;
}
break;
case 7:
break;
case 8:
tcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 9:
case 10:
case 11:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8);
tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
case 12:
tcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 13:
case 14:
case 15:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12);
tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
}
break;
case 1:
switch (OP2) {
case 0:
case 1:
tcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S],
32 - (RRR_T | ((OP2 & 1) << 4)));
break;
case 2:
case 3:
tcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T],
RRR_S | ((OP2 & 1) << 4));
break;
case 4:
tcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S);
break;
case 6:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
gen_wsr(dc, RSR_SR, tmp);
tcg_temp_free(tmp);
}
break;
#define gen_shift_reg(cmd, reg) do { \
TCGv_i64 tmp = tcg_temp_new_i64(); \
tcg_gen_extu_i32_i64(tmp, reg); \
tcg_gen_##cmd##_i64(v, v, tmp); \
tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \
tcg_temp_free_i64(v); \
tcg_temp_free_i64(tmp); \
} while (0)
#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
case 8:
{
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]);
gen_shift(shr);
}
break;
case 9:
if (dc->sar_5bit) {
tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]);
gen_shift(shr);
}
break;
case 10:
if (dc->sar_m32_5bit) {
tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], dc->sar_m32);
} else {
TCGv_i64 v = tcg_temp_new_i64();
TCGv_i32 s = tcg_const_i32(32);
tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
tcg_gen_andi_i32(s, s, 0x3f);
tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]);
gen_shift_reg(shl, s);
tcg_temp_free(s);
}
break;
case 11:
if (dc->sar_5bit) {
tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]);
gen_shift(sar);
}
break;
#undef gen_shift
#undef gen_shift_reg
case 12:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
case 13:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
default:
break;
}
break;
case 2:
break;
case 3:
switch (OP2) {
case 0:
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
break;
case 1:
gen_wsr(dc, RSR_SR, cpu_R[RRR_T]);
break;
case 2:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
int shift = 24 - RRR_T;
if (shift == 24) {
tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else if (shift == 16) {
tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else {
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift);
tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift);
tcg_temp_free(tmp);
}
}
break;
case 3:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
TCGv_i32 tmp1 = tcg_temp_new_i32();
TCGv_i32 tmp2 = tcg_temp_new_i32();
int label = gen_new_label();
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T);
tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]);
tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7));
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label);
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31);
tcg_gen_xori_i32(cpu_R[RRR_R], tmp1,
0xffffffff >> (25 - RRR_T));
gen_set_label(label);
tcg_temp_free(tmp1);
tcg_temp_free(tmp2);
}
break;
case 4:
case 5:
case 6:
case 7:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
static const TCGCond cond[] = {
TCG_COND_LE,
TCG_COND_GE,
TCG_COND_LEU,
TCG_COND_GEU
};
int label = gen_new_label();
if (RRR_R != RRR_T) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_S], cpu_R[RRR_T], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
} else {
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_T], cpu_R[RRR_S], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
}
gen_set_label(label);
}
break;
case 8:
case 9:
case 10:
case 11:
{
static const TCGCond cond[] = {
TCG_COND_NE,
TCG_COND_EQ,
TCG_COND_GE,
TCG_COND_LT
};
int label = gen_new_label();
tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
gen_set_label(label);
}
break;
case 12:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 13:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 14:
{
int st = (RRR_S << 4) + RRR_T;
if (uregnames[st]) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]);
} else {
qemu_log("RUR %d not implemented, ", st);
}
}
break;
case 15:
{
if (uregnames[RSR_SR]) {
tcg_gen_mov_i32(cpu_UR[RSR_SR], cpu_R[RRR_T]);
} else {
qemu_log("WUR %d not implemented, ", RSR_SR);
}
}
break;
}
break;
case 4:
case 5:
{
int shiftimm = RRR_S | (OP1 << 4);
int maskimm = (1 << (OP2 + 1)) - 1;
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
tcg_temp_free(tmp);
}
break;
case 6:
break;
case 7:
break;
case 8:
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 9:
break;
case 10:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
case 11:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
default:
break;
}
break;
case 1:
{
TCGv_i32 tmp = tcg_const_i32(
(0xfffc0000 | (RI16_IMM16 << 2)) +
((dc->pc + 3) & ~3));
tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, 0);
tcg_temp_free(tmp);
}
break;
case 2:
#define gen_load_store(type, shift) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \
tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
switch (RRI8_R) {
case 0:
gen_load_store(ld8u, 0);
break;
case 1:
gen_load_store(ld16u, 1);
break;
case 2:
gen_load_store(ld32u, 2);
break;
case 4:
gen_load_store(st8, 0);
break;
case 5:
gen_load_store(st16, 1);
break;
case 6:
gen_load_store(st32, 2);
break;
case 7:
break;
case 9:
gen_load_store(ld16s, 1);
break;
case 10:
tcg_gen_movi_i32(cpu_R[RRI8_T],
RRI8_IMM8 | (RRI8_S << 8) |
((RRI8_S & 0x8) ? 0xfffff000 : 0));
break;
case 11:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(ld32u, 2);
break;
case 12:
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE);
break;
case 13:
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8);
break;
case 14:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_local_new_i32();
TCGv_i32 addr = tcg_temp_local_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]);
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);
tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0);
tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T],
cpu_SR[SCOMPARE1], label);
tcg_gen_qemu_st32(tmp, addr, 0);
gen_set_label(label);
tcg_temp_free(addr);
tcg_temp_free(tmp);
}
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(st32, 2);
break;
default:
break;
}
break;
#undef gen_load_store
case 3:
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 4:
HAS_OPTION(XTENSA_OPTION_MAC16);
break;
case 5:
switch (CALL_N) {
case 0:
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jumpi(dc, (dc->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
case 6:
switch (CALL_N) {
case 0:
gen_jumpi(dc, dc->pc + 4 + CALL_OFFSET_SE, 0);
break;
case 1:
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(dc, cond[BRI12_M & 3], cpu_R[BRI12_S], 0,
4 + BRI12_IMM12_SE);
}
break;
case 2:
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(dc, cond[BRI8_M & 3],
cpu_R[BRI8_S], B4CONST[BRI8_R], 4 + BRI8_IMM8_SE);
}
break;
case 3:
switch (BRI8_M) {
case 0:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 1:
switch (BRI8_R) {
case 0:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 8:
break;
case 9:
break;
case 10:
break;
default:
break;
}
break;
case 2:
case 3:
gen_brcondi(dc, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU,
cpu_R[BRI8_S], B4CONSTU[BRI8_R], 4 + BRI8_IMM8_SE);
break;
}
break;
}
break;
case 7:
{
TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ;
switch (RRI8_R & 7) {
case 0:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
{
static const TCGCond cond[] = {
[1] = TCG_COND_EQ,
[2] = TCG_COND_LT,
[3] = TCG_COND_LTU,
[9] = TCG_COND_NE,
[10] = TCG_COND_GE,
[11] = TCG_COND_GEU,
};
gen_brcond(dc, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
}
break;
case 4:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcond(dc, eq_ne, tmp, cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 5:
{
TCGv_i32 bit = tcg_const_i32(1);
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f);
tcg_gen_shl_i32(bit, bit, tmp);
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
tcg_temp_free(bit);
}
break;
case 6:
case 7:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_S],
1 << (((RRI8_R & 1) << 4) | RRI8_T));
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
}
}
break;
#define gen_narrow_load_store(type) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \
tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
case 8:
gen_narrow_load_store(ld32u);
break;
case 9:
gen_narrow_load_store(st32);
break;
#undef gen_narrow_load_store
case 10:
tcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]);
break;
case 11:
tcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1);
break;
case 12:
if (RRRN_T < 8) {
tcg_gen_movi_i32(cpu_R[RRRN_S],
RRRN_R | (RRRN_T << 4) |
((RRRN_T & 6) == 6 ? 0xffffff80 : 0));
} else {
TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ;
gen_brcondi(dc, eq_ne, cpu_R[RRRN_S], 0,
4 + (RRRN_R | ((RRRN_T & 3) << 4)));
}
break;
case 13:
switch (RRRN_R) {
case 0:
tcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]);
break;
case 15:
switch (RRRN_T) {
case 0:
gen_jump(dc, cpu_R[0]);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 6:
break;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
dc->pc = dc->next_pc;
return;
invalid_opcode:
qemu_log("INVALID(pc = %08x)\n", dc->pc);
dc->pc = dc->next_pc;
#undef HAS_OPTION
}
| {
"code": [
" case 3:"
],
"line_no": [
321
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#define HAS_OPTION(opt) do { \
if (!option_enabled(VAR_0, opt)) { \
qemu_log("Option %d is not enabled %s:%d\n", \
(opt), __FILE__, __LINE__); \
goto invalid_opcode; \
} \
} while (0)
#ifdef TARGET_WORDS_BIGENDIAN
#define OP0 (((b0) & 0xf0) >> 4)
#define OP1 (((VAR_2) & 0xf0) >> 4)
#define OP2 ((VAR_2) & 0xf)
#define RRR_R ((VAR_1) & 0xf)
#define RRR_S (((VAR_1) & 0xf0) >> 4)
#define RRR_T ((b0) & 0xf)
#else
#define OP0 (((b0) & 0xf))
#define OP1 (((VAR_2) & 0xf))
#define OP2 (((VAR_2) & 0xf0) >> 4)
#define RRR_R (((VAR_1) & 0xf0) >> 4)
#define RRR_S (((VAR_1) & 0xf))
#define RRR_T (((b0) & 0xf0) >> 4)
#endif
#define RRRN_R RRR_R
#define RRRN_S RRR_S
#define RRRN_T RRR_T
#define RRI8_R RRR_R
#define RRI8_S RRR_S
#define RRI8_T RRR_T
#define RRI8_IMM8 (VAR_2)
#define RRI8_IMM8_SE ((((VAR_2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8)
#ifdef TARGET_WORDS_BIGENDIAN
#define RI16_IMM16 (((VAR_1) << 8) | (VAR_2))
#else
#define RI16_IMM16 (((VAR_2) << 8) | (VAR_1))
#endif
#ifdef TARGET_WORDS_BIGENDIAN
#define CALL_N (((b0) & 0xc) >> 2)
#define CALL_OFFSET ((((b0) & 0x3) << 16) | ((VAR_1) << 8) | (VAR_2))
#else
#define CALL_N (((b0) & 0x30) >> 4)
#define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((VAR_1) << 2) | ((VAR_2) << 10))
#endif
#define CALL_OFFSET_SE \
(((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET)
#define CALLX_N CALL_N
#ifdef TARGET_WORDS_BIGENDIAN
#define CALLX_M ((b0) & 0x3)
#else
#define CALLX_M (((b0) & 0xc0) >> 6)
#endif
#define CALLX_S RRR_S
#define BRI12_M CALLX_M
#define BRI12_S RRR_S
#ifdef TARGET_WORDS_BIGENDIAN
#define BRI12_IMM12 ((((VAR_1) & 0xf) << 8) | (VAR_2))
#else
#define BRI12_IMM12 ((((VAR_1) & 0xf0) >> 4) | ((VAR_2) << 4))
#endif
#define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12)
#define BRI8_M BRI12_M
#define BRI8_R RRI8_R
#define BRI8_S RRI8_S
#define BRI8_IMM8 RRI8_IMM8
#define BRI8_IMM8_SE RRI8_IMM8_SE
#define RSR_SR (VAR_1)
uint8_t b0 = ldub_code(VAR_0->pc);
uint8_t VAR_1 = ldub_code(VAR_0->pc + 1);
uint8_t VAR_2 = ldub_code(VAR_0->pc + 2);
static const uint32_t VAR_3[] = {
0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
static const uint32_t VAR_4[] = {
32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
if (OP0 >= 8) {
VAR_0->next_pc = VAR_0->pc + 2;
HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
} else {
VAR_0->next_pc = VAR_0->pc + 3;
}
switch (OP0) {
case 0:
switch (OP1) {
case 0:
switch (OP2) {
case 0:
if ((RRR_R & 0xc) == 0x8) {
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
}
switch (RRR_R) {
case 0:
switch (CALLX_M) {
case 0:
break;
case 1:
break;
case 2:
switch (CALLX_N) {
case 0:
case 2:
gen_jump(VAR_0, cpu_R[CALLX_S]);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 3:
break;
}
break;
case 3:
switch (CALLX_N) {
case 0:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);
tcg_gen_movi_i32(cpu_R[0], VAR_0->next_pc);
gen_jump(VAR_0, tmp);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
}
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 2:
break;
case 3:
break;
}
break;
case 1:
tcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 2:
tcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 3:
tcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 4:
switch (RRR_R) {
case 0:
gen_right_shift_sar(VAR_0, cpu_R[RRR_S]);
break;
case 1:
gen_left_shift_sar(VAR_0, cpu_R[RRR_S]);
break;
case 2:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_right_shift_sar(VAR_0, tmp);
tcg_temp_free(tmp);
}
break;
case 3:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_left_shift_sar(VAR_0, tmp);
tcg_temp_free(tmp);
}
break;
case 4:
{
TCGv_i32 tmp = tcg_const_i32(
RRR_S | ((RRR_T & 1) << 4));
gen_right_shift_sar(VAR_0, tmp);
tcg_temp_free(tmp);
}
break;
case 6:
break;
case 7:
break;
case 8:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 14:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
default:
break;
}
break;
case 5:
break;
case 6:
switch (RRR_S) {
case 0:
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
break;
case 1:
{
int label = gen_new_label();
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
tcg_gen_brcondi_i32(
TCG_COND_GE, cpu_R[RRR_R], 0, label);
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
gen_set_label(label);
}
break;
default:
break;
}
break;
case 7:
break;
case 8:
tcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 9:
case 10:
case 11:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8);
tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
case 12:
tcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 13:
case 14:
case 15:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12);
tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
}
break;
case 1:
switch (OP2) {
case 0:
case 1:
tcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S],
32 - (RRR_T | ((OP2 & 1) << 4)));
break;
case 2:
case 3:
tcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T],
RRR_S | ((OP2 & 1) << 4));
break;
case 4:
tcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S);
break;
case 6:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);
gen_rsr(VAR_0, cpu_R[RRR_T], RSR_SR);
gen_wsr(VAR_0, RSR_SR, tmp);
tcg_temp_free(tmp);
}
break;
#define gen_shift_reg(cmd, reg) do { \
TCGv_i64 tmp = tcg_temp_new_i64(); \
tcg_gen_extu_i32_i64(tmp, reg); \
tcg_gen_##cmd##_i64(v, v, tmp); \
tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \
tcg_temp_free_i64(v); \
tcg_temp_free_i64(tmp); \
} while (0)
#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
case 8:
{
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]);
gen_shift(shr);
}
break;
case 9:
if (VAR_0->sar_5bit) {
tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]);
gen_shift(shr);
}
break;
case 10:
if (VAR_0->sar_m32_5bit) {
tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], VAR_0->sar_m32);
} else {
TCGv_i64 v = tcg_temp_new_i64();
TCGv_i32 s = tcg_const_i32(32);
tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
tcg_gen_andi_i32(s, s, 0x3f);
tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]);
gen_shift_reg(shl, s);
tcg_temp_free(s);
}
break;
case 11:
if (VAR_0->sar_5bit) {
tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]);
gen_shift(sar);
}
break;
#undef gen_shift
#undef gen_shift_reg
case 12:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
case 13:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
default:
break;
}
break;
case 2:
break;
case 3:
switch (OP2) {
case 0:
gen_rsr(VAR_0, cpu_R[RRR_T], RSR_SR);
break;
case 1:
gen_wsr(VAR_0, RSR_SR, cpu_R[RRR_T]);
break;
case 2:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
int shift = 24 - RRR_T;
if (shift == 24) {
tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else if (shift == 16) {
tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else {
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift);
tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift);
tcg_temp_free(tmp);
}
}
break;
case 3:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
TCGv_i32 tmp1 = tcg_temp_new_i32();
TCGv_i32 tmp2 = tcg_temp_new_i32();
int label = gen_new_label();
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T);
tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]);
tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7));
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label);
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31);
tcg_gen_xori_i32(cpu_R[RRR_R], tmp1,
0xffffffff >> (25 - RRR_T));
gen_set_label(label);
tcg_temp_free(tmp1);
tcg_temp_free(tmp2);
}
break;
case 4:
case 5:
case 6:
case 7:
HAS_OPTION(XTENSA_OPTION_MISC_OP);
{
static const TCGCond cond[] = {
TCG_COND_LE,
TCG_COND_GE,
TCG_COND_LEU,
TCG_COND_GEU
};
int label = gen_new_label();
if (RRR_R != RRR_T) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_S], cpu_R[RRR_T], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
} else {
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_T], cpu_R[RRR_S], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
}
gen_set_label(label);
}
break;
case 8:
case 9:
case 10:
case 11:
{
static const TCGCond cond[] = {
TCG_COND_NE,
TCG_COND_EQ,
TCG_COND_GE,
TCG_COND_LT
};
int label = gen_new_label();
tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
gen_set_label(label);
}
break;
case 12:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 13:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 14:
{
int st = (RRR_S << 4) + RRR_T;
if (uregnames[st]) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]);
} else {
qemu_log("RUR %d not implemented, ", st);
}
}
break;
case 15:
{
if (uregnames[RSR_SR]) {
tcg_gen_mov_i32(cpu_UR[RSR_SR], cpu_R[RRR_T]);
} else {
qemu_log("WUR %d not implemented, ", RSR_SR);
}
}
break;
}
break;
case 4:
case 5:
{
int shiftimm = RRR_S | (OP1 << 4);
int maskimm = (1 << (OP2 + 1)) - 1;
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
tcg_temp_free(tmp);
}
break;
case 6:
break;
case 7:
break;
case 8:
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 9:
break;
case 10:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
case 11:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
break;
default:
break;
}
break;
case 1:
{
TCGv_i32 tmp = tcg_const_i32(
(0xfffc0000 | (RI16_IMM16 << 2)) +
((VAR_0->pc + 3) & ~3));
tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, 0);
tcg_temp_free(tmp);
}
break;
case 2:
#define gen_load_store(type, shift) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \
tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
switch (RRI8_R) {
case 0:
gen_load_store(ld8u, 0);
break;
case 1:
gen_load_store(ld16u, 1);
break;
case 2:
gen_load_store(ld32u, 2);
break;
case 4:
gen_load_store(st8, 0);
break;
case 5:
gen_load_store(st16, 1);
break;
case 6:
gen_load_store(st32, 2);
break;
case 7:
break;
case 9:
gen_load_store(ld16s, 1);
break;
case 10:
tcg_gen_movi_i32(cpu_R[RRI8_T],
RRI8_IMM8 | (RRI8_S << 8) |
((RRI8_S & 0x8) ? 0xfffff000 : 0));
break;
case 11:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(ld32u, 2);
break;
case 12:
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE);
break;
case 13:
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8);
break;
case 14:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_local_new_i32();
TCGv_i32 addr = tcg_temp_local_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]);
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);
tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0);
tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T],
cpu_SR[SCOMPARE1], label);
tcg_gen_qemu_st32(tmp, addr, 0);
gen_set_label(label);
tcg_temp_free(addr);
tcg_temp_free(tmp);
}
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store(st32, 2);
break;
default:
break;
}
break;
#undef gen_load_store
case 3:
HAS_OPTION(XTENSA_OPTION_COPROCESSOR);
break;
case 4:
HAS_OPTION(XTENSA_OPTION_MAC16);
break;
case 5:
switch (CALL_N) {
case 0:
tcg_gen_movi_i32(cpu_R[0], VAR_0->next_pc);
gen_jumpi(VAR_0, (VAR_0->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
}
break;
case 6:
switch (CALL_N) {
case 0:
gen_jumpi(VAR_0, VAR_0->pc + 4 + CALL_OFFSET_SE, 0);
break;
case 1:
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(VAR_0, cond[BRI12_M & 3], cpu_R[BRI12_S], 0,
4 + BRI12_IMM12_SE);
}
break;
case 2:
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(VAR_0, cond[BRI8_M & 3],
cpu_R[BRI8_S], VAR_3[BRI8_R], 4 + BRI8_IMM8_SE);
}
break;
case 3:
switch (BRI8_M) {
case 0:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
break;
case 1:
switch (BRI8_R) {
case 0:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
break;
case 8:
break;
case 9:
break;
case 10:
break;
default:
break;
}
break;
case 2:
case 3:
gen_brcondi(VAR_0, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU,
cpu_R[BRI8_S], VAR_4[BRI8_R], 4 + BRI8_IMM8_SE);
break;
}
break;
}
break;
case 7:
{
TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ;
switch (RRI8_R & 7) {
case 0:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
{
static const TCGCond cond[] = {
[1] = TCG_COND_EQ,
[2] = TCG_COND_LT,
[3] = TCG_COND_LTU,
[9] = TCG_COND_NE,
[10] = TCG_COND_GE,
[11] = TCG_COND_GEU,
};
gen_brcond(VAR_0, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
}
break;
case 4:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcond(VAR_0, eq_ne, tmp, cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 5:
{
TCGv_i32 bit = tcg_const_i32(1);
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f);
tcg_gen_shl_i32(bit, bit, tmp);
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit);
gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
tcg_temp_free(bit);
}
break;
case 6:
case 7:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_S],
1 << (((RRI8_R & 1) << 4) | RRI8_T));
gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
}
}
break;
#define gen_narrow_load_store(type) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \
tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, 0); \
tcg_temp_free(addr); \
} while (0)
case 8:
gen_narrow_load_store(ld32u);
break;
case 9:
gen_narrow_load_store(st32);
break;
#undef gen_narrow_load_store
case 10:
tcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]);
break;
case 11:
tcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1);
break;
case 12:
if (RRRN_T < 8) {
tcg_gen_movi_i32(cpu_R[RRRN_S],
RRRN_R | (RRRN_T << 4) |
((RRRN_T & 6) == 6 ? 0xffffff80 : 0));
} else {
TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ;
gen_brcondi(VAR_0, eq_ne, cpu_R[RRRN_S], 0,
4 + (RRRN_R | ((RRRN_T & 3) << 4)));
}
break;
case 13:
switch (RRRN_R) {
case 0:
tcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]);
break;
case 15:
switch (RRRN_T) {
case 0:
gen_jump(VAR_0, cpu_R[0]);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 6:
break;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
VAR_0->pc = VAR_0->next_pc;
return;
invalid_opcode:
qemu_log("INVALID(pc = %08x)\n", VAR_0->pc);
VAR_0->pc = VAR_0->next_pc;
#undef HAS_OPTION
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#define HAS_OPTION(opt) do { \\",
"if (!option_enabled(VAR_0, opt)) { \\",
"qemu_log(\"Option %d is not enabled %s:%d\\n\", \\\n(opt), __FILE__, __LINE__); \\",
"goto invalid_opcode; \\",
"} \\",
"} while (0)",
"#ifdef TARGET_WORDS_BIGENDIAN\n#define OP0 (((b0) & 0xf0) >> 4)\n#define OP1 (((VAR_2) & 0xf0) >> 4)\n#define OP2 ((VAR_2) & 0xf)\n#define RRR_R ((VAR_1) & 0xf)\n#define RRR_S (((VAR_1) & 0xf0) >> 4)\n#define RRR_T ((b0) & 0xf)\n#else\n#define OP0 (((b0) & 0xf))\n#define OP1 (((VAR_2) & 0xf))\n#define OP2 (((VAR_2) & 0xf0) >> 4)\n#define RRR_R (((VAR_1) & 0xf0) >> 4)\n#define RRR_S (((VAR_1) & 0xf))\n#define RRR_T (((b0) & 0xf0) >> 4)\n#endif\n#define RRRN_R RRR_R\n#define RRRN_S RRR_S\n#define RRRN_T RRR_T\n#define RRI8_R RRR_R\n#define RRI8_S RRR_S\n#define RRI8_T RRR_T\n#define RRI8_IMM8 (VAR_2)\n#define RRI8_IMM8_SE ((((VAR_2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8)\n#ifdef TARGET_WORDS_BIGENDIAN\n#define RI16_IMM16 (((VAR_1) << 8) | (VAR_2))\n#else\n#define RI16_IMM16 (((VAR_2) << 8) | (VAR_1))\n#endif\n#ifdef TARGET_WORDS_BIGENDIAN\n#define CALL_N (((b0) & 0xc) >> 2)\n#define CALL_OFFSET ((((b0) & 0x3) << 16) | ((VAR_1) << 8) | (VAR_2))\n#else\n#define CALL_N (((b0) & 0x30) >> 4)\n#define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((VAR_1) << 2) | ((VAR_2) << 10))\n#endif\n#define CALL_OFFSET_SE \\\n(((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET)\n#define CALLX_N CALL_N\n#ifdef TARGET_WORDS_BIGENDIAN\n#define CALLX_M ((b0) & 0x3)\n#else\n#define CALLX_M (((b0) & 0xc0) >> 6)\n#endif\n#define CALLX_S RRR_S\n#define BRI12_M CALLX_M\n#define BRI12_S RRR_S\n#ifdef TARGET_WORDS_BIGENDIAN\n#define BRI12_IMM12 ((((VAR_1) & 0xf) << 8) | (VAR_2))\n#else\n#define BRI12_IMM12 ((((VAR_1) & 0xf0) >> 4) | ((VAR_2) << 4))\n#endif\n#define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12)\n#define BRI8_M BRI12_M\n#define BRI8_R RRI8_R\n#define BRI8_S RRI8_S\n#define BRI8_IMM8 RRI8_IMM8\n#define BRI8_IMM8_SE RRI8_IMM8_SE\n#define RSR_SR (VAR_1)\nuint8_t b0 = ldub_code(VAR_0->pc);",
"uint8_t VAR_1 = ldub_code(VAR_0->pc + 1);",
"uint8_t VAR_2 = ldub_code(VAR_0->pc + 2);",
"static const uint32_t VAR_3[] = {",
"0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256\n};",
"static const uint32_t VAR_4[] = {",
"32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256\n};",
"if (OP0 >= 8) {",
"VAR_0->next_pc = VAR_0->pc + 2;",
"HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);",
"} else {",
"VAR_0->next_pc = VAR_0->pc + 3;",
"}",
"switch (OP0) {",
"case 0:\nswitch (OP1) {",
"case 0:\nswitch (OP2) {",
"case 0:\nif ((RRR_R & 0xc) == 0x8) {",
"HAS_OPTION(XTENSA_OPTION_BOOLEAN);",
"}",
"switch (RRR_R) {",
"case 0:\nswitch (CALLX_M) {",
"case 0:\nbreak;",
"case 1:\nbreak;",
"case 2:\nswitch (CALLX_N) {",
"case 0:\ncase 2:\ngen_jump(VAR_0, cpu_R[CALLX_S]);",
"break;",
"case 1:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"case 3:\nbreak;",
"}",
"break;",
"case 3:\nswitch (CALLX_N) {",
"case 0:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);",
"tcg_gen_movi_i32(cpu_R[0], VAR_0->next_pc);",
"gen_jump(VAR_0, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 1:\ncase 2:\ncase 3:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"}",
"break;",
"}",
"break;",
"case 1:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"case 2:\nbreak;",
"case 3:\nbreak;",
"}",
"break;",
"case 1:\ntcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);",
"break;",
"case 2:\ntcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);",
"break;",
"case 3:\ntcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);",
"break;",
"case 4:\nswitch (RRR_R) {",
"case 0:\ngen_right_shift_sar(VAR_0, cpu_R[RRR_S]);",
"break;",
"case 1:\ngen_left_shift_sar(VAR_0, cpu_R[RRR_S]);",
"break;",
"case 2:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);",
"gen_right_shift_sar(VAR_0, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 3:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);",
"gen_left_shift_sar(VAR_0, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 4:\n{",
"TCGv_i32 tmp = tcg_const_i32(\nRRR_S | ((RRR_T & 1) << 4));",
"gen_right_shift_sar(VAR_0, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 6:\nbreak;",
"case 7:\nbreak;",
"case 8:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"case 14:\nHAS_OPTION(XTENSA_OPTION_MISC_OP);",
"gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);",
"break;",
"case 15:\nHAS_OPTION(XTENSA_OPTION_MISC_OP);",
"gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);",
"break;",
"default:\nbreak;",
"}",
"break;",
"case 5:\nbreak;",
"case 6:\nswitch (RRR_S) {",
"case 0:\ntcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);",
"break;",
"case 1:\n{",
"int label = gen_new_label();",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);",
"tcg_gen_brcondi_i32(\nTCG_COND_GE, cpu_R[RRR_R], 0, label);",
"tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);",
"gen_set_label(label);",
"}",
"break;",
"default:\nbreak;",
"}",
"break;",
"case 7:\nbreak;",
"case 8:\ntcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);",
"break;",
"case 9:\ncase 10:\ncase 11:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8);",
"tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 12:\ntcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);",
"break;",
"case 13:\ncase 14:\ncase 15:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12);",
"tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);",
"tcg_temp_free(tmp);",
"}",
"break;",
"}",
"break;",
"case 1:\nswitch (OP2) {",
"case 0:\ncase 1:\ntcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S],\n32 - (RRR_T | ((OP2 & 1) << 4)));",
"break;",
"case 2:\ncase 3:\ntcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T],\nRRR_S | ((OP2 & 1) << 4));",
"break;",
"case 4:\ntcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S);",
"break;",
"case 6:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);",
"gen_rsr(VAR_0, cpu_R[RRR_T], RSR_SR);",
"gen_wsr(VAR_0, RSR_SR, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"#define gen_shift_reg(cmd, reg) do { \\",
"TCGv_i64 tmp = tcg_temp_new_i64(); \\",
"tcg_gen_extu_i32_i64(tmp, reg); \\",
"tcg_gen_##cmd##_i64(v, v, tmp); \\",
"tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \\",
"tcg_temp_free_i64(v); \\",
"tcg_temp_free_i64(tmp); \\",
"} while (0)",
"#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])\ncase 8:\n{",
"TCGv_i64 v = tcg_temp_new_i64();",
"tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]);",
"gen_shift(shr);",
"}",
"break;",
"case 9:\nif (VAR_0->sar_5bit) {",
"tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);",
"} else {",
"TCGv_i64 v = tcg_temp_new_i64();",
"tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]);",
"gen_shift(shr);",
"}",
"break;",
"case 10:\nif (VAR_0->sar_m32_5bit) {",
"tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], VAR_0->sar_m32);",
"} else {",
"TCGv_i64 v = tcg_temp_new_i64();",
"TCGv_i32 s = tcg_const_i32(32);",
"tcg_gen_sub_i32(s, s, cpu_SR[SAR]);",
"tcg_gen_andi_i32(s, s, 0x3f);",
"tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]);",
"gen_shift_reg(shl, s);",
"tcg_temp_free(s);",
"}",
"break;",
"case 11:\nif (VAR_0->sar_5bit) {",
"tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);",
"} else {",
"TCGv_i64 v = tcg_temp_new_i64();",
"tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]);",
"gen_shift(sar);",
"}",
"break;",
"#undef gen_shift\n#undef gen_shift_reg\ncase 12:\nHAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);",
"{",
"TCGv_i32 v1 = tcg_temp_new_i32();",
"TCGv_i32 v2 = tcg_temp_new_i32();",
"tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]);",
"tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]);",
"tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);",
"tcg_temp_free(v2);",
"tcg_temp_free(v1);",
"}",
"break;",
"case 13:\nHAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);",
"{",
"TCGv_i32 v1 = tcg_temp_new_i32();",
"TCGv_i32 v2 = tcg_temp_new_i32();",
"tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]);",
"tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]);",
"tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);",
"tcg_temp_free(v2);",
"tcg_temp_free(v1);",
"}",
"break;",
"default:\nbreak;",
"}",
"break;",
"case 2:\nbreak;",
"case 3:\nswitch (OP2) {",
"case 0:\ngen_rsr(VAR_0, cpu_R[RRR_T], RSR_SR);",
"break;",
"case 1:\ngen_wsr(VAR_0, RSR_SR, cpu_R[RRR_T]);",
"break;",
"case 2:\nHAS_OPTION(XTENSA_OPTION_MISC_OP);",
"{",
"int shift = 24 - RRR_T;",
"if (shift == 24) {",
"tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"} else if (shift == 16) {",
"tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"} else {",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift);",
"tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift);",
"tcg_temp_free(tmp);",
"}",
"}",
"break;",
"case 3:\nHAS_OPTION(XTENSA_OPTION_MISC_OP);",
"{",
"TCGv_i32 tmp1 = tcg_temp_new_i32();",
"TCGv_i32 tmp2 = tcg_temp_new_i32();",
"int label = gen_new_label();",
"tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T);",
"tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]);",
"tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7));",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label);",
"tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31);",
"tcg_gen_xori_i32(cpu_R[RRR_R], tmp1,\n0xffffffff >> (25 - RRR_T));",
"gen_set_label(label);",
"tcg_temp_free(tmp1);",
"tcg_temp_free(tmp2);",
"}",
"break;",
"case 4:\ncase 5:\ncase 6:\ncase 7:\nHAS_OPTION(XTENSA_OPTION_MISC_OP);",
"{",
"static const TCGCond cond[] = {",
"TCG_COND_LE,\nTCG_COND_GE,\nTCG_COND_LEU,\nTCG_COND_GEU\n};",
"int label = gen_new_label();",
"if (RRR_R != RRR_T) {",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"tcg_gen_brcond_i32(cond[OP2 - 4],\ncpu_R[RRR_S], cpu_R[RRR_T], label);",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);",
"} else {",
"tcg_gen_brcond_i32(cond[OP2 - 4],\ncpu_R[RRR_T], cpu_R[RRR_S], label);",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"}",
"gen_set_label(label);",
"}",
"break;",
"case 8:\ncase 9:\ncase 10:\ncase 11:\n{",
"static const TCGCond cond[] = {",
"TCG_COND_NE,\nTCG_COND_EQ,\nTCG_COND_GE,\nTCG_COND_LT\n};",
"int label = gen_new_label();",
"tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);",
"gen_set_label(label);",
"}",
"break;",
"case 12:\nHAS_OPTION(XTENSA_OPTION_BOOLEAN);",
"break;",
"case 13:\nHAS_OPTION(XTENSA_OPTION_BOOLEAN);",
"break;",
"case 14:\n{",
"int st = (RRR_S << 4) + RRR_T;",
"if (uregnames[st]) {",
"tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]);",
"} else {",
"qemu_log(\"RUR %d not implemented, \", st);",
"}",
"}",
"break;",
"case 15:\n{",
"if (uregnames[RSR_SR]) {",
"tcg_gen_mov_i32(cpu_UR[RSR_SR], cpu_R[RRR_T]);",
"} else {",
"qemu_log(\"WUR %d not implemented, \", RSR_SR);",
"}",
"}",
"break;",
"}",
"break;",
"case 4:\ncase 5:\n{",
"int shiftimm = RRR_S | (OP1 << 4);",
"int maskimm = (1 << (OP2 + 1)) - 1;",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);",
"tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 6:\nbreak;",
"case 7:\nbreak;",
"case 8:\nHAS_OPTION(XTENSA_OPTION_COPROCESSOR);",
"break;",
"case 9:\nbreak;",
"case 10:\nHAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);",
"break;",
"case 11:\nHAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);",
"break;",
"default:\nbreak;",
"}",
"break;",
"case 1:\n{",
"TCGv_i32 tmp = tcg_const_i32(\n(0xfffc0000 | (RI16_IMM16 << 2)) +\n((VAR_0->pc + 3) & ~3));",
"tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, 0);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 2:\n#define gen_load_store(type, shift) do { \\",
"TCGv_i32 addr = tcg_temp_new_i32(); \\",
"tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \\",
"tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \\",
"tcg_temp_free(addr); \\",
"} while (0)",
"switch (RRI8_R) {",
"case 0:\ngen_load_store(ld8u, 0);",
"break;",
"case 1:\ngen_load_store(ld16u, 1);",
"break;",
"case 2:\ngen_load_store(ld32u, 2);",
"break;",
"case 4:\ngen_load_store(st8, 0);",
"break;",
"case 5:\ngen_load_store(st16, 1);",
"break;",
"case 6:\ngen_load_store(st32, 2);",
"break;",
"case 7:\nbreak;",
"case 9:\ngen_load_store(ld16s, 1);",
"break;",
"case 10:\ntcg_gen_movi_i32(cpu_R[RRI8_T],\nRRI8_IMM8 | (RRI8_S << 8) |\n((RRI8_S & 0x8) ? 0xfffff000 : 0));",
"break;",
"case 11:\nHAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);",
"gen_load_store(ld32u, 2);",
"break;",
"case 12:\ntcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE);",
"break;",
"case 13:\ntcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8);",
"break;",
"case 14:\nHAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);",
"{",
"int label = gen_new_label();",
"TCGv_i32 tmp = tcg_temp_local_new_i32();",
"TCGv_i32 addr = tcg_temp_local_new_i32();",
"tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]);",
"tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);",
"tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0);",
"tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T],\ncpu_SR[SCOMPARE1], label);",
"tcg_gen_qemu_st32(tmp, addr, 0);",
"gen_set_label(label);",
"tcg_temp_free(addr);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 15:\nHAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);",
"gen_load_store(st32, 2);",
"break;",
"default:\nbreak;",
"}",
"break;",
"#undef gen_load_store\ncase 3:\nHAS_OPTION(XTENSA_OPTION_COPROCESSOR);",
"break;",
"case 4:\nHAS_OPTION(XTENSA_OPTION_MAC16);",
"break;",
"case 5:\nswitch (CALL_N) {",
"case 0:\ntcg_gen_movi_i32(cpu_R[0], VAR_0->next_pc);",
"gen_jumpi(VAR_0, (VAR_0->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);",
"break;",
"case 1:\ncase 2:\ncase 3:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"}",
"break;",
"case 6:\nswitch (CALL_N) {",
"case 0:\ngen_jumpi(VAR_0, VAR_0->pc + 4 + CALL_OFFSET_SE, 0);",
"break;",
"case 1:\n{",
"static const TCGCond cond[] = {",
"TCG_COND_EQ,\nTCG_COND_NE,\nTCG_COND_LT,\nTCG_COND_GE,\n};",
"gen_brcondi(VAR_0, cond[BRI12_M & 3], cpu_R[BRI12_S], 0,\n4 + BRI12_IMM12_SE);",
"}",
"break;",
"case 2:\n{",
"static const TCGCond cond[] = {",
"TCG_COND_EQ,\nTCG_COND_NE,\nTCG_COND_LT,\nTCG_COND_GE,\n};",
"gen_brcondi(VAR_0, cond[BRI8_M & 3],\ncpu_R[BRI8_S], VAR_3[BRI8_R], 4 + BRI8_IMM8_SE);",
"}",
"break;",
"case 3:\nswitch (BRI8_M) {",
"case 0:\nHAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);",
"break;",
"case 1:\nswitch (BRI8_R) {",
"case 0:\nHAS_OPTION(XTENSA_OPTION_BOOLEAN);",
"break;",
"case 1:\nHAS_OPTION(XTENSA_OPTION_BOOLEAN);",
"break;",
"case 8:\nbreak;",
"case 9:\nbreak;",
"case 10:\nbreak;",
"default:\nbreak;",
"}",
"break;",
"case 2:\ncase 3:\ngen_brcondi(VAR_0, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU,\ncpu_R[BRI8_S], VAR_4[BRI8_R], 4 + BRI8_IMM8_SE);",
"break;",
"}",
"break;",
"}",
"break;",
"case 7:\n{",
"TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ;",
"switch (RRI8_R & 7) {",
"case 0:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);",
"gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 1:\ncase 2:\ncase 3:\n{",
"static const TCGCond cond[] = {",
"[1] = TCG_COND_EQ,\n[2] = TCG_COND_LT,\n[3] = TCG_COND_LTU,\n[9] = TCG_COND_NE,\n[10] = TCG_COND_GE,\n[11] = TCG_COND_GEU,\n};",
"gen_brcond(VAR_0, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T],\n4 + RRI8_IMM8_SE);",
"}",
"break;",
"case 4:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);",
"gen_brcond(VAR_0, eq_ne, tmp, cpu_R[RRI8_T],\n4 + RRI8_IMM8_SE);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 5:\n{",
"TCGv_i32 bit = tcg_const_i32(1);",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f);",
"tcg_gen_shl_i32(bit, bit, tmp);",
"tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit);",
"gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);",
"tcg_temp_free(tmp);",
"tcg_temp_free(bit);",
"}",
"break;",
"case 6:\ncase 7:\n{",
"TCGv_i32 tmp = tcg_temp_new_i32();",
"tcg_gen_andi_i32(tmp, cpu_R[RRI8_S],\n1 << (((RRI8_R & 1) << 4) | RRI8_T));",
"gen_brcondi(VAR_0, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);",
"tcg_temp_free(tmp);",
"}",
"break;",
"}",
"}",
"break;",
"#define gen_narrow_load_store(type) do { \\",
"TCGv_i32 addr = tcg_temp_new_i32(); \\",
"tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \\",
"tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, 0); \\",
"tcg_temp_free(addr); \\",
"} while (0)",
"case 8:\ngen_narrow_load_store(ld32u);",
"break;",
"case 9:\ngen_narrow_load_store(st32);",
"break;",
"#undef gen_narrow_load_store\ncase 10:\ntcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]);",
"break;",
"case 11:\ntcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1);",
"break;",
"case 12:\nif (RRRN_T < 8) {",
"tcg_gen_movi_i32(cpu_R[RRRN_S],\nRRRN_R | (RRRN_T << 4) |\n((RRRN_T & 6) == 6 ? 0xffffff80 : 0));",
"} else {",
"TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ;",
"gen_brcondi(VAR_0, eq_ne, cpu_R[RRRN_S], 0,\n4 + (RRRN_R | ((RRRN_T & 3) << 4)));",
"}",
"break;",
"case 13:\nswitch (RRRN_R) {",
"case 0:\ntcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]);",
"break;",
"case 15:\nswitch (RRRN_T) {",
"case 0:\ngen_jump(VAR_0, cpu_R[0]);",
"break;",
"case 1:\nbreak;",
"case 2:\nbreak;",
"case 3:\nbreak;",
"case 6:\nbreak;",
"default:\nbreak;",
"}",
"break;",
"default:\nbreak;",
"}",
"break;",
"default:\nbreak;",
"}",
"VAR_0->pc = VAR_0->next_pc;",
"return;",
"invalid_opcode:\nqemu_log(\"INVALID(pc = %08x)\\n\", VAR_0->pc);",
"VAR_0->pc = VAR_0->next_pc;",
"#undef HAS_OPTION\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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
53,
55,
57,
61,
63,
65,
67,
69,
73,
75,
77,
79,
81,
85,
87,
89,
91,
93,
95,
97,
99,
101,
105,
107,
109,
111,
113,
115,
117,
121,
123,
125,
127,
129,
131,
133,
135,
139,
141,
143,
145,
147,
151,
155
],
[
157
],
[
159
],
[
163
],
[
165,
167
],
[
171
],
[
173,
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195,
197
],
[
199,
201
],
[
203,
205
],
[
207
],
[
209
],
[
213
],
[
215,
217
],
[
219,
221
],
[
225,
227
],
[
231,
233
],
[
235,
237,
239
],
[
241
],
[
245,
247
],
[
249
],
[
253,
255
],
[
257
],
[
259
],
[
263,
265
],
[
267,
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287,
289,
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307,
309
],
[
311
],
[
315,
317
],
[
321,
323
],
[
327
],
[
329
],
[
333,
335
],
[
337
],
[
341,
343
],
[
345
],
[
349,
351
],
[
353
],
[
357,
359
],
[
361,
363
],
[
365
],
[
369,
371
],
[
373
],
[
377,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
413,
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431,
433
],
[
437,
439
],
[
443,
445
],
[
447
],
[
451,
453
],
[
455
],
[
457
],
[
461,
463
],
[
465
],
[
467
],
[
471,
473
],
[
475
],
[
477
],
[
481,
483
],
[
487,
489
],
[
491,
493
],
[
495
],
[
499,
501
],
[
503
],
[
505
],
[
507,
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
521,
523
],
[
525
],
[
527
],
[
531,
533
],
[
537,
539
],
[
541
],
[
545,
547,
549,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
567,
569
],
[
571
],
[
575,
577,
579,
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
601,
603
],
[
605,
607,
609,
611
],
[
613
],
[
617,
619,
621,
623
],
[
625
],
[
629,
631
],
[
633
],
[
637,
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
683,
687,
689
],
[
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
703,
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723,
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
747
],
[
751,
753
],
[
755
],
[
757
],
[
759
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769,
771,
775,
777
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
801,
803
],
[
805
],
[
807
],
[
809
],
[
811
],
[
813
],
[
815
],
[
817
],
[
819
],
[
821
],
[
823
],
[
827,
829
],
[
831
],
[
833
],
[
837,
839
],
[
843,
845
],
[
847,
849
],
[
851
],
[
855,
857
],
[
859
],
[
863,
865
],
[
867
],
[
869
],
[
873
],
[
875
],
[
877
],
[
879
],
[
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
899,
901
],
[
903
],
[
905
],
[
907
],
[
909
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
925
],
[
927,
929
],
[
933
],
[
937
],
[
939
],
[
941
],
[
943
],
[
947,
949,
951,
953,
955
],
[
957
],
[
959
],
[
961,
963,
965,
967,
969
],
[
971
],
[
975
],
[
977
],
[
979,
981
],
[
983
],
[
985
],
[
987,
989
],
[
991
],
[
993
],
[
995
],
[
997
],
[
999
],
[
1003,
1005,
1007,
1009,
1011
],
[
1013
],
[
1015,
1017,
1019,
1021,
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033
],
[
1035
],
[
1039,
1041
],
[
1043
],
[
1047,
1049
],
[
1051
],
[
1055,
1057
],
[
1059
],
[
1061
],
[
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1077,
1079
],
[
1081
],
[
1083
],
[
1085
],
[
1087
],
[
1089
],
[
1091
],
[
1093
],
[
1097
],
[
1099
],
[
1103,
1105,
1107
],
[
1109
],
[
1111
],
[
1115
],
[
1117
],
[
1119
],
[
1121
],
[
1123
],
[
1125
],
[
1129,
1131
],
[
1135,
1137
],
[
1141,
1143
],
[
1145
],
[
1149,
1151
],
[
1155,
1157
],
[
1159
],
[
1163,
1165
],
[
1167
],
[
1171,
1173
],
[
1175
],
[
1177
],
[
1181,
1183
],
[
1185,
1187,
1189
],
[
1197
],
[
1199
],
[
1201
],
[
1203
],
[
1207,
1209
],
[
1211
],
[
1213
],
[
1215
],
[
1217
],
[
1219
],
[
1223
],
[
1225,
1227
],
[
1229
],
[
1233,
1235
],
[
1237
],
[
1241,
1243
],
[
1245
],
[
1249,
1251
],
[
1253
],
[
1257,
1259
],
[
1261
],
[
1265,
1267
],
[
1269
],
[
1273,
1275
],
[
1279,
1281
],
[
1283
],
[
1287,
1289,
1291,
1293
],
[
1295
],
[
1299,
1301
],
[
1303
],
[
1305
],
[
1309,
1311
],
[
1313
],
[
1317,
1319
],
[
1321
],
[
1325,
1327
],
[
1329
],
[
1331
],
[
1333
],
[
1335
],
[
1339
],
[
1341
],
[
1343
],
[
1345,
1347
],
[
1351
],
[
1355
],
[
1357
],
[
1359
],
[
1361
],
[
1363
],
[
1367,
1369
],
[
1371
],
[
1373
],
[
1377,
1379
],
[
1381
],
[
1383
],
[
1385,
1389,
1391
],
[
1393
],
[
1397,
1399
],
[
1401
],
[
1405,
1407
],
[
1409,
1411
],
[
1413
],
[
1415
],
[
1419,
1421,
1423,
1425
],
[
1427
],
[
1429
],
[
1431
],
[
1435,
1437
],
[
1439,
1441
],
[
1443
],
[
1447,
1449
],
[
1451
],
[
1453,
1455,
1457,
1459,
1461
],
[
1465,
1467
],
[
1469
],
[
1471
],
[
1475,
1477
],
[
1479
],
[
1481,
1483,
1485,
1487,
1489
],
[
1493,
1495
],
[
1497
],
[
1499
],
[
1503,
1505
],
[
1507,
1509
],
[
1511
],
[
1515,
1517
],
[
1519,
1521
],
[
1523
],
[
1527,
1529
],
[
1531
],
[
1535,
1537
],
[
1541,
1543
],
[
1547,
1549
],
[
1553,
1555
],
[
1559
],
[
1561
],
[
1565,
1567,
1569,
1571
],
[
1573
],
[
1575
],
[
1577
],
[
1581
],
[
1583
],
[
1587,
1589
],
[
1591
],
[
1595
],
[
1597,
1599
],
[
1601
],
[
1603
],
[
1605
],
[
1607
],
[
1609
],
[
1611
],
[
1615,
1617,
1619,
1621
],
[
1623
],
[
1625,
1627,
1629,
1631,
1633,
1635,
1637
],
[
1639,
1641
],
[
1643
],
[
1645
],
[
1649,
1651
],
[
1653
],
[
1655
],
[
1657,
1659
],
[
1661
],
[
1663
],
[
1665
],
[
1669,
1671
],
[
1673
],
[
1675
],
[
1677
],
[
1679
],
[
1681
],
[
1683
],
[
1685
],
[
1687
],
[
1689
],
[
1691
],
[
1695,
1697,
1699
],
[
1701
],
[
1703,
1705
],
[
1707
],
[
1709
],
[
1711
],
[
1713
],
[
1717
],
[
1719
],
[
1721
],
[
1725
],
[
1727
],
[
1729
],
[
1731
],
[
1733
],
[
1735
],
[
1739,
1741
],
[
1743
],
[
1747,
1749
],
[
1751
],
[
1753,
1757,
1759
],
[
1761
],
[
1765,
1767
],
[
1769
],
[
1773,
1775
],
[
1777,
1779,
1781
],
[
1783
],
[
1785
],
[
1789,
1791
],
[
1793
],
[
1795
],
[
1799,
1801
],
[
1803,
1805
],
[
1807
],
[
1811,
1813
],
[
1815,
1817
],
[
1819
],
[
1823,
1825
],
[
1829,
1831
],
[
1835,
1837
],
[
1841,
1843
],
[
1847,
1849
],
[
1851
],
[
1853
],
[
1857,
1859
],
[
1861
],
[
1863
],
[
1867,
1869
],
[
1871
],
[
1875
],
[
1877
],
[
1881,
1883
],
[
1885
],
[
1887,
1889
]
] |
24,781 | void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BdrvChild *child;
Error *local_err = NULL;
int ret;
if (!bs->drv) {
return;
}
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
return;
}
bs->open_flags &= ~BDRV_O_INACTIVE;
if (bs->drv->bdrv_invalidate_cache) {
bs->drv->bdrv_invalidate_cache(bs, &local_err);
if (local_err) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_invalidate_cache(child->bs, &local_err);
if (local_err) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
bs->open_flags |= BDRV_O_INACTIVE;
error_setg_errno(errp, -ret, "Could not refresh total sector count");
return;
}
}
| true | qemu | 16e977d506bcc2d9f7daa4a9f7cc2b48536d9da6 | void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BdrvChild *child;
Error *local_err = NULL;
int ret;
if (!bs->drv) {
return;
}
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
return;
}
bs->open_flags &= ~BDRV_O_INACTIVE;
if (bs->drv->bdrv_invalidate_cache) {
bs->drv->bdrv_invalidate_cache(bs, &local_err);
if (local_err) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_invalidate_cache(child->bs, &local_err);
if (local_err) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
bs->open_flags |= BDRV_O_INACTIVE;
error_setg_errno(errp, -ret, "Could not refresh total sector count");
return;
}
}
| {
"code": [
" bs->open_flags &= ~BDRV_O_INACTIVE;",
" if (bs->drv->bdrv_invalidate_cache) {",
" bs->drv->bdrv_invalidate_cache(bs, &local_err);",
" bs->open_flags |= BDRV_O_INACTIVE;",
" QLIST_FOREACH(child, &bs->children, next) {",
" bdrv_invalidate_cache(child->bs, &local_err);"
],
"line_no": [
27,
31,
33,
37,
49,
51
]
} | void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{
BdrvChild *child;
Error *local_err = NULL;
int VAR_2;
if (!VAR_0->drv) {
return;
}
if (!(VAR_0->open_flags & BDRV_O_INACTIVE)) {
return;
}
VAR_0->open_flags &= ~BDRV_O_INACTIVE;
if (VAR_0->drv->FUNC_0) {
VAR_0->drv->FUNC_0(VAR_0, &local_err);
if (local_err) {
VAR_0->open_flags |= BDRV_O_INACTIVE;
error_propagate(VAR_1, local_err);
return;
}
}
QLIST_FOREACH(child, &VAR_0->children, next) {
FUNC_0(child->VAR_0, &local_err);
if (local_err) {
VAR_0->open_flags |= BDRV_O_INACTIVE;
error_propagate(VAR_1, local_err);
return;
}
}
VAR_2 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);
if (VAR_2 < 0) {
VAR_0->open_flags |= BDRV_O_INACTIVE;
error_setg_errno(VAR_1, -VAR_2, "Could not refresh total sector count");
return;
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{",
"BdrvChild *child;",
"Error *local_err = NULL;",
"int VAR_2;",
"if (!VAR_0->drv) {",
"return;",
"}",
"if (!(VAR_0->open_flags & BDRV_O_INACTIVE)) {",
"return;",
"}",
"VAR_0->open_flags &= ~BDRV_O_INACTIVE;",
"if (VAR_0->drv->FUNC_0) {",
"VAR_0->drv->FUNC_0(VAR_0, &local_err);",
"if (local_err) {",
"VAR_0->open_flags |= BDRV_O_INACTIVE;",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"}",
"QLIST_FOREACH(child, &VAR_0->children, next) {",
"FUNC_0(child->VAR_0, &local_err);",
"if (local_err) {",
"VAR_0->open_flags |= BDRV_O_INACTIVE;",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"}",
"VAR_2 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);",
"if (VAR_2 < 0) {",
"VAR_0->open_flags |= BDRV_O_INACTIVE;",
"error_setg_errno(VAR_1, -VAR_2, \"Could not refresh total sector count\");",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
24,782 | static int context_init(H264Context *h){
MpegEncContext * const s = &h->s;
CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
// edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer,
(s->width+64)*2*21*2); //(width + edge + align)*interlaced*MBsize*tolerance
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;
return 0;
fail:
return -1; // free_tables will clean up for us
}
| true | FFmpeg | 79db7ac6ef235a06c3049d7792eda39da28ee3fd | static int context_init(H264Context *h){
MpegEncContext * const s = &h->s;
CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer,
(s->width+64)*2*21*2);
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;
return 0;
fail:
return -1;
}
| {
"code": [
" CHECKED_ALLOCZ(s->allocated_edge_emu_buffer,",
" s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;"
],
"line_no": [
15,
19
]
} | static int FUNC_0(H264Context *VAR_0){
MpegEncContext * const s = &VAR_0->s;
CHECKED_ALLOCZ(VAR_0->top_borders[0], VAR_0->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(VAR_0->top_borders[1], VAR_0->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer,
(s->width+64)*2*21*2);
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;
return 0;
fail:
return -1;
}
| [
"static int FUNC_0(H264Context *VAR_0){",
"MpegEncContext * const s = &VAR_0->s;",
"CHECKED_ALLOCZ(VAR_0->top_borders[0], VAR_0->s.mb_width * (16+8+8) * sizeof(uint8_t))\nCHECKED_ALLOCZ(VAR_0->top_borders[1], VAR_0->s.mb_width * (16+8+8) * sizeof(uint8_t))\nCHECKED_ALLOCZ(s->allocated_edge_emu_buffer,\n(s->width+64)*2*21*2);",
"s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;",
"return 0;",
"fail:\nreturn -1;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
7,
9,
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
]
] |
24,783 | int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
int i, stuffing_count, ret;
int context_count = s->slice_context_count;
s->picture_in_gop_number++;
if (load_input_picture(s, pic_arg) < 0)
return -1;
if (select_input_picture(s) < 0) {
return -1;
}
/* output? */
if (s->new_picture.f.data[0]) {
if ((ret = ff_alloc_packet2(avctx, pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
return ret;
if (s->mb_info) {
s->mb_info_ptr = av_packet_new_side_data(pkt,
AV_PKT_DATA_H263_MB_INFO,
s->mb_width*s->mb_height*12);
s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0;
}
for (i = 0; i < context_count; i++) {
int start_y = s->thread_context[i]->start_mb_y;
int end_y = s->thread_context[i]-> end_mb_y;
int h = s->mb_height;
uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h);
uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h);
init_put_bits(&s->thread_context[i]->pb, start, end - start);
}
s->pict_type = s->new_picture.f.pict_type;
//emms_c();
//printf("qs:%f %f %d\n", s->new_picture.quality,
// s->current_picture.quality, s->qscale);
ff_MPV_frame_start(s, avctx);
vbv_retry:
if (encode_picture(s, s->picture_number) < 0)
return -1;
avctx->header_bits = s->header_bits;
avctx->mv_bits = s->mv_bits;
avctx->misc_bits = s->misc_bits;
avctx->i_tex_bits = s->i_tex_bits;
avctx->p_tex_bits = s->p_tex_bits;
avctx->i_count = s->i_count;
// FIXME f/b_count in avctx
avctx->p_count = s->mb_num - s->i_count - s->skip_count;
avctx->skip_count = s->skip_count;
ff_MPV_frame_end(s);
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
ff_mjpeg_encode_picture_trailer(s);
if (avctx->rc_buffer_size) {
RateControlContext *rcc = &s->rc_context;
int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use;
if (put_bits_count(&s->pb) > max_size &&
s->lambda < s->avctx->lmax) {
s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale);
if (s->adaptive_quant) {
int i;
for (i = 0; i < s->mb_height * s->mb_stride; i++)
s->lambda_table[i] =
FFMAX(s->lambda_table[i] + 1,
s->lambda_table[i] * (s->qscale + 1) /
s->qscale);
}
s->mb_skipped = 0; // done in MPV_frame_start()
// done in encode_picture() so we must undo it
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (s->flipflop_rounding ||
s->codec_id == CODEC_ID_H263P ||
s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->time_base = s->last_time_base;
s->last_non_b_time = s->time - s->pp_time;
}
//av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda);
for (i = 0; i < context_count; i++) {
PutBitContext *pb = &s->thread_context[i]->pb;
init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);
}
goto vbv_retry;
}
assert(s->avctx->rc_max_rate);
}
if (s->flags & CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
for (i = 0; i < 4; i++) {
s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i];
avctx->error[i] += s->current_picture_ptr->f.error[i];
}
if (s->flags & CODEC_FLAG_PASS1)
assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits +
avctx->i_tex_bits + avctx->p_tex_bits ==
put_bits_count(&s->pb));
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
stuffing_count = ff_vbv_update(s, s->frame_bits);
if (stuffing_count) {
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) <
stuffing_count + 50) {
av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n");
return -1;
}
switch (s->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
while (stuffing_count--) {
put_bits(&s->pb, 8, 0);
}
break;
case CODEC_ID_MPEG4:
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, 0x1C3);
stuffing_count -= 4;
while (stuffing_count--) {
put_bits(&s->pb, 8, 0xFF);
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n");
}
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
}
/* update mpeg1/2 vbv_delay for CBR */
if (s->avctx->rc_max_rate &&
s->avctx->rc_min_rate == s->avctx->rc_max_rate &&
s->out_format == FMT_MPEG1 &&
90000LL * (avctx->rc_buffer_size - 1) <=
s->avctx->rc_max_rate * 0xFFFFLL) {
int vbv_delay, min_delay;
double inbits = s->avctx->rc_max_rate *
av_q2d(s->avctx->time_base);
int minbits = s->frame_bits - 8 *
(s->vbv_delay_ptr - s->pb.buf - 1);
double bits = s->rc_context.buffer_index + minbits - inbits;
if (bits < 0)
av_log(s->avctx, AV_LOG_ERROR,
"Internal error, negative bits\n");
assert(s->repeat_first_field == 0);
vbv_delay = bits * 90000 / s->avctx->rc_max_rate;
min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) /
s->avctx->rc_max_rate;
vbv_delay = FFMAX(vbv_delay, min_delay);
assert(vbv_delay < 0xFFFF);
s->vbv_delay_ptr[0] &= 0xF8;
s->vbv_delay_ptr[0] |= vbv_delay >> 13;
s->vbv_delay_ptr[1] = vbv_delay >> 5;
s->vbv_delay_ptr[2] &= 0x07;
s->vbv_delay_ptr[2] |= vbv_delay << 3;
avctx->vbv_delay = vbv_delay * 300;
}
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
pkt->pts = s->current_picture.f.pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
if (!s->current_picture.f.coded_picture_number)
pkt->dts = pkt->pts - s->dts_delta;
else
pkt->dts = s->reordered_pts;
s->reordered_pts = pkt->pts;
} else
pkt->dts = pkt->pts;
if (s->current_picture.f.key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
if (s->mb_info)
av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);
} else {
assert((put_bits_ptr(&s->pb) == s->pb.buf));
s->frame_bits = 0;
}
assert((s->frame_bits & 7) == 0);
pkt->size = s->frame_bits / 8;
*got_packet = !!pkt->size;
return 0;
}
| true | FFmpeg | f72e0d9a9f516be77d20c6a37dcd34add8f932e3 | int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
int i, stuffing_count, ret;
int context_count = s->slice_context_count;
s->picture_in_gop_number++;
if (load_input_picture(s, pic_arg) < 0)
return -1;
if (select_input_picture(s) < 0) {
return -1;
}
if (s->new_picture.f.data[0]) {
if ((ret = ff_alloc_packet2(avctx, pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
return ret;
if (s->mb_info) {
s->mb_info_ptr = av_packet_new_side_data(pkt,
AV_PKT_DATA_H263_MB_INFO,
s->mb_width*s->mb_height*12);
s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0;
}
for (i = 0; i < context_count; i++) {
int start_y = s->thread_context[i]->start_mb_y;
int end_y = s->thread_context[i]-> end_mb_y;
int h = s->mb_height;
uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h);
uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h);
init_put_bits(&s->thread_context[i]->pb, start, end - start);
}
s->pict_type = s->new_picture.f.pict_type;
ff_MPV_frame_start(s, avctx);
vbv_retry:
if (encode_picture(s, s->picture_number) < 0)
return -1;
avctx->header_bits = s->header_bits;
avctx->mv_bits = s->mv_bits;
avctx->misc_bits = s->misc_bits;
avctx->i_tex_bits = s->i_tex_bits;
avctx->p_tex_bits = s->p_tex_bits;
avctx->i_count = s->i_count;
avctx->p_count = s->mb_num - s->i_count - s->skip_count;
avctx->skip_count = s->skip_count;
ff_MPV_frame_end(s);
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
ff_mjpeg_encode_picture_trailer(s);
if (avctx->rc_buffer_size) {
RateControlContext *rcc = &s->rc_context;
int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use;
if (put_bits_count(&s->pb) > max_size &&
s->lambda < s->avctx->lmax) {
s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale);
if (s->adaptive_quant) {
int i;
for (i = 0; i < s->mb_height * s->mb_stride; i++)
s->lambda_table[i] =
FFMAX(s->lambda_table[i] + 1,
s->lambda_table[i] * (s->qscale + 1) /
s->qscale);
}
s->mb_skipped = 0;
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (s->flipflop_rounding ||
s->codec_id == CODEC_ID_H263P ||
s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->time_base = s->last_time_base;
s->last_non_b_time = s->time - s->pp_time;
}
for (i = 0; i < context_count; i++) {
PutBitContext *pb = &s->thread_context[i]->pb;
init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);
}
goto vbv_retry;
}
assert(s->avctx->rc_max_rate);
}
if (s->flags & CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
for (i = 0; i < 4; i++) {
s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i];
avctx->error[i] += s->current_picture_ptr->f.error[i];
}
if (s->flags & CODEC_FLAG_PASS1)
assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits +
avctx->i_tex_bits + avctx->p_tex_bits ==
put_bits_count(&s->pb));
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
stuffing_count = ff_vbv_update(s, s->frame_bits);
if (stuffing_count) {
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) <
stuffing_count + 50) {
av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n");
return -1;
}
switch (s->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
while (stuffing_count--) {
put_bits(&s->pb, 8, 0);
}
break;
case CODEC_ID_MPEG4:
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, 0x1C3);
stuffing_count -= 4;
while (stuffing_count--) {
put_bits(&s->pb, 8, 0xFF);
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n");
}
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
}
if (s->avctx->rc_max_rate &&
s->avctx->rc_min_rate == s->avctx->rc_max_rate &&
s->out_format == FMT_MPEG1 &&
90000LL * (avctx->rc_buffer_size - 1) <=
s->avctx->rc_max_rate * 0xFFFFLL) {
int vbv_delay, min_delay;
double inbits = s->avctx->rc_max_rate *
av_q2d(s->avctx->time_base);
int minbits = s->frame_bits - 8 *
(s->vbv_delay_ptr - s->pb.buf - 1);
double bits = s->rc_context.buffer_index + minbits - inbits;
if (bits < 0)
av_log(s->avctx, AV_LOG_ERROR,
"Internal error, negative bits\n");
assert(s->repeat_first_field == 0);
vbv_delay = bits * 90000 / s->avctx->rc_max_rate;
min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) /
s->avctx->rc_max_rate;
vbv_delay = FFMAX(vbv_delay, min_delay);
assert(vbv_delay < 0xFFFF);
s->vbv_delay_ptr[0] &= 0xF8;
s->vbv_delay_ptr[0] |= vbv_delay >> 13;
s->vbv_delay_ptr[1] = vbv_delay >> 5;
s->vbv_delay_ptr[2] &= 0x07;
s->vbv_delay_ptr[2] |= vbv_delay << 3;
avctx->vbv_delay = vbv_delay * 300;
}
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
pkt->pts = s->current_picture.f.pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
if (!s->current_picture.f.coded_picture_number)
pkt->dts = pkt->pts - s->dts_delta;
else
pkt->dts = s->reordered_pts;
s->reordered_pts = pkt->pts;
} else
pkt->dts = pkt->pts;
if (s->current_picture.f.key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
if (s->mb_info)
av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);
} else {
assert((put_bits_ptr(&s->pb) == s->pb.buf));
s->frame_bits = 0;
}
assert((s->frame_bits & 7) == 0);
pkt->size = s->frame_bits / 8;
*got_packet = !!pkt->size;
return 0;
}
| {
"code": [
" assert((put_bits_ptr(&s->pb) == s->pb.buf));"
],
"line_no": [
393
]
} | int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
AVFrame *VAR_2, int *VAR_3)
{
MpegEncContext *s = VAR_0->priv_data;
int VAR_12, VAR_5, VAR_6;
int VAR_7 = s->slice_context_count;
s->picture_in_gop_number++;
if (load_input_picture(s, VAR_2) < 0)
return -1;
if (select_input_picture(s) < 0) {
return -1;
}
if (s->new_picture.f.data[0]) {
if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
return VAR_6;
if (s->mb_info) {
s->mb_info_ptr = av_packet_new_side_data(VAR_1,
AV_PKT_DATA_H263_MB_INFO,
s->mb_width*s->mb_height*12);
s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0;
}
for (VAR_12 = 0; VAR_12 < VAR_7; VAR_12++) {
int VAR_8 = s->thread_context[VAR_12]->start_mb_y;
int VAR_9 = s->thread_context[VAR_12]-> end_mb_y;
int VAR_10 = s->mb_height;
uint8_t *start = VAR_1->data + (size_t)(((int64_t) VAR_1->size) * VAR_8 / VAR_10);
uint8_t *end = VAR_1->data + (size_t)(((int64_t) VAR_1->size) * VAR_9 / VAR_10);
init_put_bits(&s->thread_context[VAR_12]->pb, start, end - start);
}
s->pict_type = s->new_picture.f.pict_type;
ff_MPV_frame_start(s, VAR_0);
vbv_retry:
if (encode_picture(s, s->picture_number) < 0)
return -1;
VAR_0->header_bits = s->header_bits;
VAR_0->mv_bits = s->mv_bits;
VAR_0->misc_bits = s->misc_bits;
VAR_0->i_tex_bits = s->i_tex_bits;
VAR_0->p_tex_bits = s->p_tex_bits;
VAR_0->i_count = s->i_count;
VAR_0->p_count = s->mb_num - s->i_count - s->skip_count;
VAR_0->skip_count = s->skip_count;
ff_MPV_frame_end(s);
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
ff_mjpeg_encode_picture_trailer(s);
if (VAR_0->rc_buffer_size) {
RateControlContext *rcc = &s->rc_context;
int VAR_11 = rcc->buffer_index * VAR_0->rc_max_available_vbv_use;
if (put_bits_count(&s->pb) > VAR_11 &&
s->lambda < s->VAR_0->lmax) {
s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale);
if (s->adaptive_quant) {
int VAR_12;
for (VAR_12 = 0; VAR_12 < s->mb_height * s->mb_stride; VAR_12++)
s->lambda_table[VAR_12] =
FFMAX(s->lambda_table[VAR_12] + 1,
s->lambda_table[VAR_12] * (s->qscale + 1) /
s->qscale);
}
s->mb_skipped = 0;
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (s->flipflop_rounding ||
s->codec_id == CODEC_ID_H263P ||
s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->time_base = s->last_time_base;
s->last_non_b_time = s->time - s->pp_time;
}
for (VAR_12 = 0; VAR_12 < VAR_7; VAR_12++) {
PutBitContext *pb = &s->thread_context[VAR_12]->pb;
init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);
}
goto vbv_retry;
}
assert(s->VAR_0->rc_max_rate);
}
if (s->flags & CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
for (VAR_12 = 0; VAR_12 < 4; VAR_12++) {
s->current_picture_ptr->f.error[VAR_12] = s->current_picture.f.error[VAR_12];
VAR_0->error[VAR_12] += s->current_picture_ptr->f.error[VAR_12];
}
if (s->flags & CODEC_FLAG_PASS1)
assert(VAR_0->header_bits + VAR_0->mv_bits + VAR_0->misc_bits +
VAR_0->i_tex_bits + VAR_0->p_tex_bits ==
put_bits_count(&s->pb));
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
VAR_5 = ff_vbv_update(s, s->frame_bits);
if (VAR_5) {
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) <
VAR_5 + 50) {
av_log(s->VAR_0, AV_LOG_ERROR, "stuffing too large\n");
return -1;
}
switch (s->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
while (VAR_5--) {
put_bits(&s->pb, 8, 0);
}
break;
case CODEC_ID_MPEG4:
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, 0x1C3);
VAR_5 -= 4;
while (VAR_5--) {
put_bits(&s->pb, 8, 0xFF);
}
break;
default:
av_log(s->VAR_0, AV_LOG_ERROR, "vbv buffer overflow\n");
}
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
}
if (s->VAR_0->rc_max_rate &&
s->VAR_0->rc_min_rate == s->VAR_0->rc_max_rate &&
s->out_format == FMT_MPEG1 &&
90000LL * (VAR_0->rc_buffer_size - 1) <=
s->VAR_0->rc_max_rate * 0xFFFFLL) {
int VAR_12, VAR_13;
double VAR_14 = s->VAR_0->rc_max_rate *
av_q2d(s->VAR_0->time_base);
int VAR_15 = s->frame_bits - 8 *
(s->vbv_delay_ptr - s->pb.buf - 1);
double VAR_16 = s->rc_context.buffer_index + VAR_15 - VAR_14;
if (VAR_16 < 0)
av_log(s->VAR_0, AV_LOG_ERROR,
"Internal error, negative VAR_16\n");
assert(s->repeat_first_field == 0);
VAR_12 = VAR_16 * 90000 / s->VAR_0->rc_max_rate;
VAR_13 = (VAR_15 * 90000LL + s->VAR_0->rc_max_rate - 1) /
s->VAR_0->rc_max_rate;
VAR_12 = FFMAX(VAR_12, VAR_13);
assert(VAR_12 < 0xFFFF);
s->vbv_delay_ptr[0] &= 0xF8;
s->vbv_delay_ptr[0] |= VAR_12 >> 13;
s->vbv_delay_ptr[1] = VAR_12 >> 5;
s->vbv_delay_ptr[2] &= 0x07;
s->vbv_delay_ptr[2] |= VAR_12 << 3;
VAR_0->VAR_12 = VAR_12 * 300;
}
s->total_bits += s->frame_bits;
VAR_0->frame_bits = s->frame_bits;
VAR_1->pts = s->current_picture.f.pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
if (!s->current_picture.f.coded_picture_number)
VAR_1->dts = VAR_1->pts - s->dts_delta;
else
VAR_1->dts = s->reordered_pts;
s->reordered_pts = VAR_1->pts;
} else
VAR_1->dts = VAR_1->pts;
if (s->current_picture.f.key_frame)
VAR_1->flags |= AV_PKT_FLAG_KEY;
if (s->mb_info)
av_packet_shrink_side_data(VAR_1, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);
} else {
assert((put_bits_ptr(&s->pb) == s->pb.buf));
s->frame_bits = 0;
}
assert((s->frame_bits & 7) == 0);
VAR_1->size = s->frame_bits / 8;
*VAR_3 = !!VAR_1->size;
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nAVFrame *VAR_2, int *VAR_3)\n{",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_12, VAR_5, VAR_6;",
"int VAR_7 = s->slice_context_count;",
"s->picture_in_gop_number++;",
"if (load_input_picture(s, VAR_2) < 0)\nreturn -1;",
"if (select_input_picture(s) < 0) {",
"return -1;",
"}",
"if (s->new_picture.f.data[0]) {",
"if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)\nreturn VAR_6;",
"if (s->mb_info) {",
"s->mb_info_ptr = av_packet_new_side_data(VAR_1,\nAV_PKT_DATA_H263_MB_INFO,\ns->mb_width*s->mb_height*12);",
"s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0;",
"}",
"for (VAR_12 = 0; VAR_12 < VAR_7; VAR_12++) {",
"int VAR_8 = s->thread_context[VAR_12]->start_mb_y;",
"int VAR_9 = s->thread_context[VAR_12]-> end_mb_y;",
"int VAR_10 = s->mb_height;",
"uint8_t *start = VAR_1->data + (size_t)(((int64_t) VAR_1->size) * VAR_8 / VAR_10);",
"uint8_t *end = VAR_1->data + (size_t)(((int64_t) VAR_1->size) * VAR_9 / VAR_10);",
"init_put_bits(&s->thread_context[VAR_12]->pb, start, end - start);",
"}",
"s->pict_type = s->new_picture.f.pict_type;",
"ff_MPV_frame_start(s, VAR_0);",
"vbv_retry:\nif (encode_picture(s, s->picture_number) < 0)\nreturn -1;",
"VAR_0->header_bits = s->header_bits;",
"VAR_0->mv_bits = s->mv_bits;",
"VAR_0->misc_bits = s->misc_bits;",
"VAR_0->i_tex_bits = s->i_tex_bits;",
"VAR_0->p_tex_bits = s->p_tex_bits;",
"VAR_0->i_count = s->i_count;",
"VAR_0->p_count = s->mb_num - s->i_count - s->skip_count;",
"VAR_0->skip_count = s->skip_count;",
"ff_MPV_frame_end(s);",
"if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)\nff_mjpeg_encode_picture_trailer(s);",
"if (VAR_0->rc_buffer_size) {",
"RateControlContext *rcc = &s->rc_context;",
"int VAR_11 = rcc->buffer_index * VAR_0->rc_max_available_vbv_use;",
"if (put_bits_count(&s->pb) > VAR_11 &&\ns->lambda < s->VAR_0->lmax) {",
"s->next_lambda = FFMAX(s->lambda + 1, s->lambda *\n(s->qscale + 1) / s->qscale);",
"if (s->adaptive_quant) {",
"int VAR_12;",
"for (VAR_12 = 0; VAR_12 < s->mb_height * s->mb_stride; VAR_12++)",
"s->lambda_table[VAR_12] =\nFFMAX(s->lambda_table[VAR_12] + 1,\ns->lambda_table[VAR_12] * (s->qscale + 1) /\ns->qscale);",
"}",
"s->mb_skipped = 0;",
"if (s->pict_type == AV_PICTURE_TYPE_P) {",
"if (s->flipflop_rounding ||\ns->codec_id == CODEC_ID_H263P ||\ns->codec_id == CODEC_ID_MPEG4)\ns->no_rounding ^= 1;",
"}",
"if (s->pict_type != AV_PICTURE_TYPE_B) {",
"s->time_base = s->last_time_base;",
"s->last_non_b_time = s->time - s->pp_time;",
"}",
"for (VAR_12 = 0; VAR_12 < VAR_7; VAR_12++) {",
"PutBitContext *pb = &s->thread_context[VAR_12]->pb;",
"init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);",
"}",
"goto vbv_retry;",
"}",
"assert(s->VAR_0->rc_max_rate);",
"}",
"if (s->flags & CODEC_FLAG_PASS1)\nff_write_pass1_stats(s);",
"for (VAR_12 = 0; VAR_12 < 4; VAR_12++) {",
"s->current_picture_ptr->f.error[VAR_12] = s->current_picture.f.error[VAR_12];",
"VAR_0->error[VAR_12] += s->current_picture_ptr->f.error[VAR_12];",
"}",
"if (s->flags & CODEC_FLAG_PASS1)\nassert(VAR_0->header_bits + VAR_0->mv_bits + VAR_0->misc_bits +\nVAR_0->i_tex_bits + VAR_0->p_tex_bits ==\nput_bits_count(&s->pb));",
"flush_put_bits(&s->pb);",
"s->frame_bits = put_bits_count(&s->pb);",
"VAR_5 = ff_vbv_update(s, s->frame_bits);",
"if (VAR_5) {",
"if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) <\nVAR_5 + 50) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"stuffing too large\\n\");",
"return -1;",
"}",
"switch (s->codec_id) {",
"case CODEC_ID_MPEG1VIDEO:\ncase CODEC_ID_MPEG2VIDEO:\nwhile (VAR_5--) {",
"put_bits(&s->pb, 8, 0);",
"}",
"break;",
"case CODEC_ID_MPEG4:\nput_bits(&s->pb, 16, 0);",
"put_bits(&s->pb, 16, 0x1C3);",
"VAR_5 -= 4;",
"while (VAR_5--) {",
"put_bits(&s->pb, 8, 0xFF);",
"}",
"break;",
"default:\nav_log(s->VAR_0, AV_LOG_ERROR, \"vbv buffer overflow\\n\");",
"}",
"flush_put_bits(&s->pb);",
"s->frame_bits = put_bits_count(&s->pb);",
"}",
"if (s->VAR_0->rc_max_rate &&\ns->VAR_0->rc_min_rate == s->VAR_0->rc_max_rate &&\ns->out_format == FMT_MPEG1 &&\n90000LL * (VAR_0->rc_buffer_size - 1) <=\ns->VAR_0->rc_max_rate * 0xFFFFLL) {",
"int VAR_12, VAR_13;",
"double VAR_14 = s->VAR_0->rc_max_rate *\nav_q2d(s->VAR_0->time_base);",
"int VAR_15 = s->frame_bits - 8 *\n(s->vbv_delay_ptr - s->pb.buf - 1);",
"double VAR_16 = s->rc_context.buffer_index + VAR_15 - VAR_14;",
"if (VAR_16 < 0)\nav_log(s->VAR_0, AV_LOG_ERROR,\n\"Internal error, negative VAR_16\\n\");",
"assert(s->repeat_first_field == 0);",
"VAR_12 = VAR_16 * 90000 / s->VAR_0->rc_max_rate;",
"VAR_13 = (VAR_15 * 90000LL + s->VAR_0->rc_max_rate - 1) /\ns->VAR_0->rc_max_rate;",
"VAR_12 = FFMAX(VAR_12, VAR_13);",
"assert(VAR_12 < 0xFFFF);",
"s->vbv_delay_ptr[0] &= 0xF8;",
"s->vbv_delay_ptr[0] |= VAR_12 >> 13;",
"s->vbv_delay_ptr[1] = VAR_12 >> 5;",
"s->vbv_delay_ptr[2] &= 0x07;",
"s->vbv_delay_ptr[2] |= VAR_12 << 3;",
"VAR_0->VAR_12 = VAR_12 * 300;",
"}",
"s->total_bits += s->frame_bits;",
"VAR_0->frame_bits = s->frame_bits;",
"VAR_1->pts = s->current_picture.f.pts;",
"if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {",
"if (!s->current_picture.f.coded_picture_number)\nVAR_1->dts = VAR_1->pts - s->dts_delta;",
"else\nVAR_1->dts = s->reordered_pts;",
"s->reordered_pts = VAR_1->pts;",
"} else",
"VAR_1->dts = VAR_1->pts;",
"if (s->current_picture.f.key_frame)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"if (s->mb_info)\nav_packet_shrink_side_data(VAR_1, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);",
"} else {",
"assert((put_bits_ptr(&s->pb) == s->pb.buf));",
"s->frame_bits = 0;",
"}",
"assert((s->frame_bits & 7) == 0);",
"VAR_1->size = s->frame_bits / 8;",
"*VAR_3 = !!VAR_1->size;",
"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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
83
],
[
85,
87,
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
113
],
[
117,
119
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145,
147,
149,
151
],
[
153
],
[
155
],
[
159
],
[
161,
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
201,
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217,
219,
221,
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
293,
295,
297,
299,
301
],
[
303
],
[
305,
307
],
[
309,
311
],
[
313
],
[
317,
319,
321
],
[
325
],
[
329
],
[
331,
333
],
[
337
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369,
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403
],
[
405
],
[
407
],
[
409
]
] |
24,784 | static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
{
int bits;
if(s->mb_y >= s->mb_height)
return 1;
if(!s->mb_num_left)
return 1;
if(r->s.mb_skip_run > 1)
return 0;
bits = get_bits_left(&s->gb);
if(bits < 0 || (bits < 8 && !show_bits(&s->gb, bits)))
return 1;
return 0;
}
| false | FFmpeg | 2d0b4bc4cf92dd961dbafbff3f1f4a9e08a9565b | static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
{
int bits;
if(s->mb_y >= s->mb_height)
return 1;
if(!s->mb_num_left)
return 1;
if(r->s.mb_skip_run > 1)
return 0;
bits = get_bits_left(&s->gb);
if(bits < 0 || (bits < 8 && !show_bits(&s->gb, bits)))
return 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RV34DecContext *VAR_0, MpegEncContext *VAR_1)
{
int VAR_2;
if(VAR_1->mb_y >= VAR_1->mb_height)
return 1;
if(!VAR_1->mb_num_left)
return 1;
if(VAR_0->VAR_1.mb_skip_run > 1)
return 0;
VAR_2 = get_bits_left(&VAR_1->gb);
if(VAR_2 < 0 || (VAR_2 < 8 && !show_bits(&VAR_1->gb, VAR_2)))
return 1;
return 0;
}
| [
"static int FUNC_0(RV34DecContext *VAR_0, MpegEncContext *VAR_1)\n{",
"int VAR_2;",
"if(VAR_1->mb_y >= VAR_1->mb_height)\nreturn 1;",
"if(!VAR_1->mb_num_left)\nreturn 1;",
"if(VAR_0->VAR_1.mb_skip_run > 1)\nreturn 0;",
"VAR_2 = get_bits_left(&VAR_1->gb);",
"if(VAR_2 < 0 || (VAR_2 < 8 && !show_bits(&VAR_1->gb, VAR_2)))\nreturn 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
]
] |
24,785 | static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,
MotionEstContext *me, ScratchpadContext *sc,
int chroma_x_shift, int chroma_y_shift,
int linesize, int uvlinesize)
{
int edges_needed = av_codec_is_encoder(avctx->codec);
int r, ret;
pic->tf.f = pic->f;
if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
avctx->codec_id != AV_CODEC_ID_MSS2) {
if (edges_needed) {
pic->f->width = avctx->width + 2 * EDGE_WIDTH;
pic->f->height = avctx->height + 2 * EDGE_WIDTH;
}
r = ff_thread_get_buffer(avctx, &pic->tf,
pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
} else {
pic->f->width = avctx->width;
pic->f->height = avctx->height;
pic->f->format = avctx->pix_fmt;
r = avcodec_default_get_buffer2(avctx, pic->f, 0);
}
if (r < 0 || !pic->f->buf[0]) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
r, pic->f->data[0]);
return -1;
}
if (edges_needed) {
int i;
for (i = 0; pic->f->data[i]; i++) {
int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *
pic->f->linesize[i] +
(EDGE_WIDTH >> (i ? chroma_x_shift : 0));
pic->f->data[i] += offset;
}
pic->f->width = avctx->width;
pic->f->height = avctx->height;
}
if (avctx->hwaccel) {
assert(!pic->hwaccel_picture_private);
if (avctx->hwaccel->frame_priv_data_size) {
pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size);
if (!pic->hwaccel_priv_buf) {
av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
}
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
if (linesize && (linesize != pic->f->linesize[0] ||
uvlinesize != pic->f->linesize[1])) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
ff_mpeg_unref_picture(avctx, pic);
return -1;
}
if (pic->f->linesize[1] != pic->f->linesize[2]) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
ff_mpeg_unref_picture(avctx, pic);
return -1;
}
if (!sc->edge_emu_buffer &&
(ret = ff_mpeg_framesize_alloc(avctx, me, sc,
pic->f->linesize[0])) < 0) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
ff_mpeg_unref_picture(avctx, pic);
return ret;
}
return 0;
}
| false | FFmpeg | bb4c9d0a8ead02f7d943c2bae3e36b30e605b30b | static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,
MotionEstContext *me, ScratchpadContext *sc,
int chroma_x_shift, int chroma_y_shift,
int linesize, int uvlinesize)
{
int edges_needed = av_codec_is_encoder(avctx->codec);
int r, ret;
pic->tf.f = pic->f;
if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
avctx->codec_id != AV_CODEC_ID_MSS2) {
if (edges_needed) {
pic->f->width = avctx->width + 2 * EDGE_WIDTH;
pic->f->height = avctx->height + 2 * EDGE_WIDTH;
}
r = ff_thread_get_buffer(avctx, &pic->tf,
pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
} else {
pic->f->width = avctx->width;
pic->f->height = avctx->height;
pic->f->format = avctx->pix_fmt;
r = avcodec_default_get_buffer2(avctx, pic->f, 0);
}
if (r < 0 || !pic->f->buf[0]) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
r, pic->f->data[0]);
return -1;
}
if (edges_needed) {
int i;
for (i = 0; pic->f->data[i]; i++) {
int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *
pic->f->linesize[i] +
(EDGE_WIDTH >> (i ? chroma_x_shift : 0));
pic->f->data[i] += offset;
}
pic->f->width = avctx->width;
pic->f->height = avctx->height;
}
if (avctx->hwaccel) {
assert(!pic->hwaccel_picture_private);
if (avctx->hwaccel->frame_priv_data_size) {
pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size);
if (!pic->hwaccel_priv_buf) {
av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
}
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
if (linesize && (linesize != pic->f->linesize[0] ||
uvlinesize != pic->f->linesize[1])) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
ff_mpeg_unref_picture(avctx, pic);
return -1;
}
if (pic->f->linesize[1] != pic->f->linesize[2]) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
ff_mpeg_unref_picture(avctx, pic);
return -1;
}
if (!sc->edge_emu_buffer &&
(ret = ff_mpeg_framesize_alloc(avctx, me, sc,
pic->f->linesize[0])) < 0) {
av_log(avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
ff_mpeg_unref_picture(avctx, pic);
return ret;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, Picture *VAR_1,
MotionEstContext *VAR_2, ScratchpadContext *VAR_3,
int VAR_4, int VAR_5,
int VAR_6, int VAR_7)
{
int VAR_8 = av_codec_is_encoder(VAR_0->codec);
int VAR_9, VAR_10;
VAR_1->tf.f = VAR_1->f;
if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_MSS2) {
if (VAR_8) {
VAR_1->f->width = VAR_0->width + 2 * EDGE_WIDTH;
VAR_1->f->height = VAR_0->height + 2 * EDGE_WIDTH;
}
VAR_9 = ff_thread_get_buffer(VAR_0, &VAR_1->tf,
VAR_1->reference ? AV_GET_BUFFER_FLAG_REF : 0);
} else {
VAR_1->f->width = VAR_0->width;
VAR_1->f->height = VAR_0->height;
VAR_1->f->format = VAR_0->pix_fmt;
VAR_9 = avcodec_default_get_buffer2(VAR_0, VAR_1->f, 0);
}
if (VAR_9 < 0 || !VAR_1->f->buf[0]) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
VAR_9, VAR_1->f->data[0]);
return -1;
}
if (VAR_8) {
int VAR_11;
for (VAR_11 = 0; VAR_1->f->data[VAR_11]; VAR_11++) {
int offset = (EDGE_WIDTH >> (VAR_11 ? VAR_5 : 0)) *
VAR_1->f->VAR_6[VAR_11] +
(EDGE_WIDTH >> (VAR_11 ? VAR_4 : 0));
VAR_1->f->data[VAR_11] += offset;
}
VAR_1->f->width = VAR_0->width;
VAR_1->f->height = VAR_0->height;
}
if (VAR_0->hwaccel) {
assert(!VAR_1->hwaccel_picture_private);
if (VAR_0->hwaccel->frame_priv_data_size) {
VAR_1->hwaccel_priv_buf = av_buffer_allocz(VAR_0->hwaccel->frame_priv_data_size);
if (!VAR_1->hwaccel_priv_buf) {
av_log(VAR_0, AV_LOG_ERROR, "FUNC_0() failed (hwaccel private data allocation)\n");
return -1;
}
VAR_1->hwaccel_picture_private = VAR_1->hwaccel_priv_buf->data;
}
}
if (VAR_6 && (VAR_6 != VAR_1->f->VAR_6[0] ||
VAR_7 != VAR_1->f->VAR_6[1])) {
av_log(VAR_0, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
ff_mpeg_unref_picture(VAR_0, VAR_1);
return -1;
}
if (VAR_1->f->VAR_6[1] != VAR_1->f->VAR_6[2]) {
av_log(VAR_0, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
ff_mpeg_unref_picture(VAR_0, VAR_1);
return -1;
}
if (!VAR_3->edge_emu_buffer &&
(VAR_10 = ff_mpeg_framesize_alloc(VAR_0, VAR_2, VAR_3,
VAR_1->f->VAR_6[0])) < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
ff_mpeg_unref_picture(VAR_0, VAR_1);
return VAR_10;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, Picture *VAR_1,\nMotionEstContext *VAR_2, ScratchpadContext *VAR_3,\nint VAR_4, int VAR_5,\nint VAR_6, int VAR_7)\n{",
"int VAR_8 = av_codec_is_encoder(VAR_0->codec);",
"int VAR_9, VAR_10;",
"VAR_1->tf.f = VAR_1->f;",
"if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_MSS2) {",
"if (VAR_8) {",
"VAR_1->f->width = VAR_0->width + 2 * EDGE_WIDTH;",
"VAR_1->f->height = VAR_0->height + 2 * EDGE_WIDTH;",
"}",
"VAR_9 = ff_thread_get_buffer(VAR_0, &VAR_1->tf,\nVAR_1->reference ? AV_GET_BUFFER_FLAG_REF : 0);",
"} else {",
"VAR_1->f->width = VAR_0->width;",
"VAR_1->f->height = VAR_0->height;",
"VAR_1->f->format = VAR_0->pix_fmt;",
"VAR_9 = avcodec_default_get_buffer2(VAR_0, VAR_1->f, 0);",
"}",
"if (VAR_9 < 0 || !VAR_1->f->buf[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed (%d %p)\\n\",\nVAR_9, VAR_1->f->data[0]);",
"return -1;",
"}",
"if (VAR_8) {",
"int VAR_11;",
"for (VAR_11 = 0; VAR_1->f->data[VAR_11]; VAR_11++) {",
"int offset = (EDGE_WIDTH >> (VAR_11 ? VAR_5 : 0)) *\nVAR_1->f->VAR_6[VAR_11] +\n(EDGE_WIDTH >> (VAR_11 ? VAR_4 : 0));",
"VAR_1->f->data[VAR_11] += offset;",
"}",
"VAR_1->f->width = VAR_0->width;",
"VAR_1->f->height = VAR_0->height;",
"}",
"if (VAR_0->hwaccel) {",
"assert(!VAR_1->hwaccel_picture_private);",
"if (VAR_0->hwaccel->frame_priv_data_size) {",
"VAR_1->hwaccel_priv_buf = av_buffer_allocz(VAR_0->hwaccel->frame_priv_data_size);",
"if (!VAR_1->hwaccel_priv_buf) {",
"av_log(VAR_0, AV_LOG_ERROR, \"FUNC_0() failed (hwaccel private data allocation)\\n\");",
"return -1;",
"}",
"VAR_1->hwaccel_picture_private = VAR_1->hwaccel_priv_buf->data;",
"}",
"}",
"if (VAR_6 && (VAR_6 != VAR_1->f->VAR_6[0] ||\nVAR_7 != VAR_1->f->VAR_6[1])) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"get_buffer() failed (stride changed)\\n\");",
"ff_mpeg_unref_picture(VAR_0, VAR_1);",
"return -1;",
"}",
"if (VAR_1->f->VAR_6[1] != VAR_1->f->VAR_6[2]) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"get_buffer() failed (uv stride mismatch)\\n\");",
"ff_mpeg_unref_picture(VAR_0, VAR_1);",
"return -1;",
"}",
"if (!VAR_3->edge_emu_buffer &&\n(VAR_10 = ff_mpeg_framesize_alloc(VAR_0, VAR_2, VAR_3,\nVAR_1->f->VAR_6[0])) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"get_buffer() failed to allocate context scratch buffers.\\n\");",
"ff_mpeg_unref_picture(VAR_0, VAR_1);",
"return VAR_10;",
"}",
"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,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143,
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
]
] |
24,786 | void ff_avg_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2,
stride, dst, stride, 4, 1);
}
| false | FFmpeg | 72dbc610be3272ba36603f78a39cc2d2d8fe0cc3 | void ff_avg_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2,
stride, dst, stride, 4, 1);
}
| {
"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_4w_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2, 4, 1);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_midh_qrt_and_aver_dst_4w_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2, 4, 1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
24,788 | static void show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
{
int i;
writer_print_section_header(w, SECTION_ID_PROGRAMS);
for (i = 0; i < fmt_ctx->nb_programs; i++) {
AVProgram *program = fmt_ctx->programs[i];
if (!program)
continue;
show_program(w, fmt_ctx, program);
}
writer_print_section_footer(w);
}
| false | FFmpeg | e87190f5d20d380608f792ceb14d0def1d80e24b | static void show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
{
int i;
writer_print_section_header(w, SECTION_ID_PROGRAMS);
for (i = 0; i < fmt_ctx->nb_programs; i++) {
AVProgram *program = fmt_ctx->programs[i];
if (!program)
continue;
show_program(w, fmt_ctx, program);
}
writer_print_section_footer(w);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1)
{
int VAR_2;
writer_print_section_header(VAR_0, SECTION_ID_PROGRAMS);
for (VAR_2 = 0; VAR_2 < VAR_1->nb_programs; VAR_2++) {
AVProgram *program = VAR_1->programs[VAR_2];
if (!program)
continue;
show_program(VAR_0, VAR_1, program);
}
writer_print_section_footer(VAR_0);
}
| [
"static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1)\n{",
"int VAR_2;",
"writer_print_section_header(VAR_0, SECTION_ID_PROGRAMS);",
"for (VAR_2 = 0; VAR_2 < VAR_1->nb_programs; VAR_2++) {",
"AVProgram *program = VAR_1->programs[VAR_2];",
"if (!program)\ncontinue;",
"show_program(VAR_0, VAR_1, program);",
"}",
"writer_print_section_footer(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
24,789 | static int put_flac_codecpriv(AVFormatContext *s,
AVIOContext *pb, AVCodecContext *codec)
{
int write_comment = (codec->channel_layout &&
!(codec->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(codec->channel_layout));
int ret = ff_flac_write_header(pb, codec->extradata, codec->extradata_size,
!write_comment);
if (ret < 0)
return ret;
if (write_comment) {
const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ?
"Lavf" : LIBAVFORMAT_IDENT;
AVDictionary *dict = NULL;
uint8_t buf[32], *data, *p;
int len;
snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
len = ff_vorbiscomment_length(dict, vendor);
data = av_malloc(len + 4);
if (!data) {
av_dict_free(&dict);
return AVERROR(ENOMEM);
}
data[0] = 0x84;
AV_WB24(data + 1, len);
p = data + 4;
ff_vorbiscomment_write(&p, &dict, vendor);
avio_write(pb, data, len + 4);
av_freep(&data);
av_dict_free(&dict);
}
return 0;
}
| false | FFmpeg | 66f26b3e8ec075298e7ba329a55893d085bafe96 | static int put_flac_codecpriv(AVFormatContext *s,
AVIOContext *pb, AVCodecContext *codec)
{
int write_comment = (codec->channel_layout &&
!(codec->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(codec->channel_layout));
int ret = ff_flac_write_header(pb, codec->extradata, codec->extradata_size,
!write_comment);
if (ret < 0)
return ret;
if (write_comment) {
const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ?
"Lavf" : LIBAVFORMAT_IDENT;
AVDictionary *dict = NULL;
uint8_t buf[32], *data, *p;
int len;
snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
len = ff_vorbiscomment_length(dict, vendor);
data = av_malloc(len + 4);
if (!data) {
av_dict_free(&dict);
return AVERROR(ENOMEM);
}
data[0] = 0x84;
AV_WB24(data + 1, len);
p = data + 4;
ff_vorbiscomment_write(&p, &dict, vendor);
avio_write(pb, data, len + 4);
av_freep(&data);
av_dict_free(&dict);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVIOContext *VAR_1, AVCodecContext *VAR_2)
{
int VAR_3 = (VAR_2->channel_layout &&
!(VAR_2->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(VAR_2->channel_layout));
int VAR_4 = ff_flac_write_header(VAR_1, VAR_2->extradata, VAR_2->extradata_size,
!VAR_3);
if (VAR_4 < 0)
return VAR_4;
if (VAR_3) {
const char *VAR_5 = (VAR_0->flags & AVFMT_FLAG_BITEXACT) ?
"Lavf" : LIBAVFORMAT_IDENT;
AVDictionary *dict = NULL;
uint8_t buf[32], *data, *p;
int VAR_6;
snprintf(buf, sizeof(buf), "0x%"PRIx64, VAR_2->channel_layout);
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
VAR_6 = ff_vorbiscomment_length(dict, VAR_5);
data = av_malloc(VAR_6 + 4);
if (!data) {
av_dict_free(&dict);
return AVERROR(ENOMEM);
}
data[0] = 0x84;
AV_WB24(data + 1, VAR_6);
p = data + 4;
ff_vorbiscomment_write(&p, &dict, VAR_5);
avio_write(VAR_1, data, VAR_6 + 4);
av_freep(&data);
av_dict_free(&dict);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVIOContext *VAR_1, AVCodecContext *VAR_2)\n{",
"int VAR_3 = (VAR_2->channel_layout &&\n!(VAR_2->channel_layout & ~0x3ffffULL) &&\n!ff_flac_is_native_layout(VAR_2->channel_layout));",
"int VAR_4 = ff_flac_write_header(VAR_1, VAR_2->extradata, VAR_2->extradata_size,\n!VAR_3);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"if (VAR_3) {",
"const char *VAR_5 = (VAR_0->flags & AVFMT_FLAG_BITEXACT) ?\n\"Lavf\" : LIBAVFORMAT_IDENT;",
"AVDictionary *dict = NULL;",
"uint8_t buf[32], *data, *p;",
"int VAR_6;",
"snprintf(buf, sizeof(buf), \"0x%\"PRIx64, VAR_2->channel_layout);",
"av_dict_set(&dict, \"WAVEFORMATEXTENSIBLE_CHANNEL_MASK\", buf, 0);",
"VAR_6 = ff_vorbiscomment_length(dict, VAR_5);",
"data = av_malloc(VAR_6 + 4);",
"if (!data) {",
"av_dict_free(&dict);",
"return AVERROR(ENOMEM);",
"}",
"data[0] = 0x84;",
"AV_WB24(data + 1, VAR_6);",
"p = data + 4;",
"ff_vorbiscomment_write(&p, &dict, VAR_5);",
"avio_write(VAR_1, data, VAR_6 + 4);",
"av_freep(&data);",
"av_dict_free(&dict);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9,
11
],
[
13,
15
],
[
19,
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
24,791 | static uint64_t get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int *num)
{
BDRVQcowState *s = bs->opaque;
int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
int index_in_cluster, nb_available, nb_needed, nb_clusters;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
/* compute how many bytes there are between the offset and
* the end of the l1 entry
*/
nb_available = (1 << l1_bits) - (offset & ((1 << l1_bits) - 1));
/* compute the number of available sectors */
nb_available = (nb_available >> 9) + index_in_cluster;
cluster_offset = 0;
/* seek the the l2 offset in the l1 table */
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
/* seek the l2 table of the given l2 offset */
if (!l2_offset)
goto out;
/* load the l2 table in memory */
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
/* find the cluster offset for the given disk offset */
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
/* how many empty clusters ? */
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
/* how many allocated clusters ? */
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED; | true | qemu | f8de16605cf9864e258d91e95be0ed76bdeac744 | static uint64_t get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int *num)
{
BDRVQcowState *s = bs->opaque;
int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
int index_in_cluster, nb_available, nb_needed, nb_clusters;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
nb_available = (1 << l1_bits) - (offset & ((1 << l1_bits) - 1));
nb_available = (nb_available >> 9) + index_in_cluster;
cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED; | {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(BlockDriverState *bs,
uint64_t offset, int *num)
{
BDRVQcowState *s = bs->opaque;
int VAR_0, VAR_1;
uint64_t l2_offset, *l2_table, cluster_offset;
int VAR_2, VAR_3;
int VAR_4, VAR_5, VAR_6, VAR_7;
VAR_4 = (offset >> 9) & (s->cluster_sectors - 1);
VAR_6 = *num + VAR_4;
VAR_2 = s->l2_bits + s->cluster_bits;
VAR_5 = (1 << VAR_2) - (offset & ((1 << VAR_2) - 1));
VAR_5 = (VAR_5 >> 9) + VAR_4;
cluster_offset = 0;
VAR_0 = offset >> VAR_2;
if (VAR_0 >= s->l1_size)
goto out;
l2_offset = s->l1_table[VAR_0];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
VAR_1 = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[VAR_1]);
VAR_7 = size_to_clusters(s, VAR_6 << 9);
if (!cluster_offset) {
VAR_3 = count_contiguous_free_clusters(VAR_7, &l2_table[VAR_1]);
} else {
VAR_3 = count_contiguous_clusters(VAR_7, s->cluster_size,
&l2_table[VAR_1], 0, QCOW_OFLAG_COPIED);
VAR_5 = (VAR_3 * s->cluster_sectors);
out:
if (VAR_5 > VAR_6)
VAR_5 = VAR_6;
*num = VAR_5 - VAR_4;
return cluster_offset & ~QCOW_OFLAG_COPIED; | [
"static uint64_t FUNC_0(BlockDriverState *bs,\nuint64_t offset, int *num)\n{",
"BDRVQcowState *s = bs->opaque;",
"int VAR_0, VAR_1;",
"uint64_t l2_offset, *l2_table, cluster_offset;",
"int VAR_2, VAR_3;",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"VAR_4 = (offset >> 9) & (s->cluster_sectors - 1);",
"VAR_6 = *num + VAR_4;",
"VAR_2 = s->l2_bits + s->cluster_bits;",
"VAR_5 = (1 << VAR_2) - (offset & ((1 << VAR_2) - 1));",
"VAR_5 = (VAR_5 >> 9) + VAR_4;",
"cluster_offset = 0;",
"VAR_0 = offset >> VAR_2;",
"if (VAR_0 >= s->l1_size)\ngoto out;",
"l2_offset = s->l1_table[VAR_0];",
"if (!l2_offset)\ngoto out;",
"l2_offset &= ~QCOW_OFLAG_COPIED;",
"l2_table = l2_load(bs, l2_offset);",
"if (l2_table == NULL)\nreturn 0;",
"VAR_1 = (offset >> s->cluster_bits) & (s->l2_size - 1);",
"cluster_offset = be64_to_cpu(l2_table[VAR_1]);",
"VAR_7 = size_to_clusters(s, VAR_6 << 9);",
"if (!cluster_offset) {",
"VAR_3 = count_contiguous_free_clusters(VAR_7, &l2_table[VAR_1]);",
"} else {",
"VAR_3 = count_contiguous_clusters(VAR_7, s->cluster_size,\n&l2_table[VAR_1], 0, QCOW_OFLAG_COPIED);",
"VAR_5 = (VAR_3 * s->cluster_sectors);",
"out:\nif (VAR_5 > VAR_6)\nVAR_5 = VAR_6;",
"*num = VAR_5 - VAR_4;",
"return cluster_offset & ~QCOW_OFLAG_COPIED;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
15
],
[
17
],
[
18
],
[
20
],
[
21,
22
],
[
23
],
[
25,
26
],
[
28
],
[
29
],
[
30,
31
],
[
33
],
[
34
],
[
35
],
[
36
],
[
38
],
[
39
],
[
41,
42
],
[
43
],
[
44,
45,
46
],
[
47
],
[
48
]
] |
24,792 | static int rscc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
RsccContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = data;
const uint8_t *pixels, *raw;
uint8_t *inflated_tiles = NULL;
int tiles_nb, packed_size, pixel_size = 0;
int i, ret = 0;
bytestream2_init(gbc, avpkt->data, avpkt->size);
/* Size check */
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
/* Read number of tiles, and allocate the array */
tiles_nb = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
tiles_nb * sizeof(*ctx->tiles));
if (!ctx->tiles) {
ret = AVERROR(ENOMEM);
av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb);
/* When there are more than 5 tiles, they are packed together with
* a size header. When that size does not match the number of tiles
* times the tile size, it means it needs to be inflated as well */
if (tiles_nb > 5) {
uLongf packed_tiles_size;
if (tiles_nb < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size);
/* If necessary, uncompress tiles, and hijack the bytestream reader */
if (packed_tiles_size != tiles_nb * TILE_SIZE) {
uLongf length = tiles_nb * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
ret = AVERROR(ENOMEM);
ret = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
/* Skip the compressed tile section in the main byte reader,
* and point it to read the newly uncompressed data */
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
/* Fill in array of tiles, keeping track of how many pixels are updated */
for (i = 0; i < tiles_nb; i++) {
ctx->tiles[i].x = bytestream2_get_le16(gbc);
ctx->tiles[i].w = bytestream2_get_le16(gbc);
ctx->tiles[i].y = bytestream2_get_le16(gbc);
ctx->tiles[i].h = bytestream2_get_le16(gbc);
pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
av_log(avctx, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
} else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
av_log(avctx, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
/* Reset the reader in case it had been modified before */
gbc = &ctx->gbc;
/* Extract how much pixel data the tiles contain */
if (pixel_size < 0x100)
packed_size = bytestream2_get_byte(gbc);
else if (pixel_size < 0x10000)
packed_size = bytestream2_get_le16(gbc);
else if (pixel_size < 0x1000000)
packed_size = bytestream2_get_le24(gbc);
else
packed_size = bytestream2_get_le32(gbc);
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
if (packed_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
/* Get pixels buffer, it may be deflated or just raw */
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size);
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
pixels = ctx->inflated_buf;
/* Allocate when needed */
ret = ff_reget_buffer(avctx, ctx->reference);
if (ret < 0)
/* Pointer to actual pixels, will be updated when data is consumed */
raw = pixels;
for (i = 0; i < tiles_nb; i++) {
uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
(avctx->height - ctx->tiles[i].y - 1) +
ctx->tiles[i].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].h);
raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
/* Frame is ready to be output */
ret = av_frame_ref(frame, ctx->reference);
if (ret < 0)
/* Keyframe when the number of pixels updated matches the whole surface */
if (pixel_size == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
*got_frame = 1;
end:
av_free(inflated_tiles);
return ret;
| true | FFmpeg | b2244fa0a624f7e38893d58265e9c039bed2e4de | static int rscc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
RsccContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = data;
const uint8_t *pixels, *raw;
uint8_t *inflated_tiles = NULL;
int tiles_nb, packed_size, pixel_size = 0;
int i, ret = 0;
bytestream2_init(gbc, avpkt->data, avpkt->size);
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
tiles_nb = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
tiles_nb * sizeof(*ctx->tiles));
if (!ctx->tiles) {
ret = AVERROR(ENOMEM);
av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb);
if (tiles_nb > 5) {
uLongf packed_tiles_size;
if (tiles_nb < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size);
if (packed_tiles_size != tiles_nb * TILE_SIZE) {
uLongf length = tiles_nb * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
ret = AVERROR(ENOMEM);
ret = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
for (i = 0; i < tiles_nb; i++) {
ctx->tiles[i].x = bytestream2_get_le16(gbc);
ctx->tiles[i].w = bytestream2_get_le16(gbc);
ctx->tiles[i].y = bytestream2_get_le16(gbc);
ctx->tiles[i].h = bytestream2_get_le16(gbc);
pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
av_log(avctx, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
} else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
av_log(avctx, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
gbc = &ctx->gbc;
if (pixel_size < 0x100)
packed_size = bytestream2_get_byte(gbc);
else if (pixel_size < 0x10000)
packed_size = bytestream2_get_le16(gbc);
else if (pixel_size < 0x1000000)
packed_size = bytestream2_get_le24(gbc);
else
packed_size = bytestream2_get_le32(gbc);
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
if (packed_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size);
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
pixels = ctx->inflated_buf;
ret = ff_reget_buffer(avctx, ctx->reference);
if (ret < 0)
raw = pixels;
for (i = 0; i < tiles_nb; i++) {
uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
(avctx->height - ctx->tiles[i].y - 1) +
ctx->tiles[i].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].h);
raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
ret = av_frame_ref(frame, ctx->reference);
if (ret < 0)
if (pixel_size == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
*got_frame = 1;
end:
av_free(inflated_tiles);
return ret;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
RsccContext *ctx = VAR_0->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = VAR_1;
const uint8_t *VAR_4, *raw;
uint8_t *inflated_tiles = NULL;
int VAR_5, VAR_6, VAR_7 = 0;
int VAR_8, VAR_9 = 0;
bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->size);
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(VAR_0, AV_LOG_ERROR, "Packet too small (%d)\n", VAR_3->size);
return AVERROR_INVALIDDATA;
VAR_5 = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
VAR_5 * sizeof(*ctx->tiles));
if (!ctx->tiles) {
VAR_9 = AVERROR(ENOMEM);
av_log(VAR_0, AV_LOG_DEBUG, "Frame with %d tiles.\n", VAR_5);
if (VAR_5 > 5) {
uLongf packed_tiles_size;
if (VAR_5 < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(VAR_0, "packed tiles of size %lu.\n", packed_tiles_size);
if (packed_tiles_size != VAR_5 * TILE_SIZE) {
uLongf length = VAR_5 * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
VAR_9 = AVERROR(ENOMEM);
VAR_9 = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "Tile deflate error %d.\n", VAR_9);
VAR_9 = AVERROR_UNKNOWN;
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {
ctx->tiles[VAR_8].x = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].w = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].y = bytestream2_get_le16(gbc);
ctx->tiles[VAR_8].h = bytestream2_get_le16(gbc);
VAR_7 += ctx->tiles[VAR_8].w * ctx->tiles[VAR_8].h * ctx->component_size;
ff_dlog(VAR_0, "tile %d orig(%d,%d) %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
if (ctx->tiles[VAR_8].w == 0 || ctx->tiles[VAR_8].h == 0) {
av_log(VAR_0, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
} else if (ctx->tiles[VAR_8].x + ctx->tiles[VAR_8].w > VAR_0->width ||
ctx->tiles[VAR_8].y + ctx->tiles[VAR_8].h > VAR_0->height) {
av_log(VAR_0, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", VAR_8,
ctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,
ctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);
gbc = &ctx->gbc;
if (VAR_7 < 0x100)
VAR_6 = bytestream2_get_byte(gbc);
else if (VAR_7 < 0x10000)
VAR_6 = bytestream2_get_le16(gbc);
else if (VAR_7 < 0x1000000)
VAR_6 = bytestream2_get_le24(gbc);
else
VAR_6 = bytestream2_get_le32(gbc);
ff_dlog(VAR_0, "VAR_7 %d VAR_6 %d.\n", VAR_7, VAR_6);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid tile size %d\n", VAR_6);
if (VAR_7 == VAR_6) {
if (bytestream2_get_bytes_left(gbc) < VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Insufficient input for %d\n", VAR_7);
VAR_4 = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
VAR_9 = uncompress(ctx->inflated_buf, &len, gbc->buffer, VAR_6);
if (VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "Pixel deflate error %d.\n", VAR_9);
VAR_9 = AVERROR_UNKNOWN;
VAR_4 = ctx->inflated_buf;
VAR_9 = ff_reget_buffer(VAR_0, ctx->reference);
if (VAR_9 < 0)
raw = VAR_4;
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {
uint8_t *dst = ctx->reference->VAR_1[0] + ctx->reference->linesize[0] *
(VAR_0->height - ctx->tiles[VAR_8].y - 1) +
ctx->tiles[VAR_8].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[VAR_8].w * ctx->component_size,
ctx->tiles[VAR_8].w * ctx->component_size,
ctx->tiles[VAR_8].h);
raw += ctx->tiles[VAR_8].w * ctx->component_size * ctx->tiles[VAR_8].h;
VAR_9 = av_frame_ref(frame, ctx->reference);
if (VAR_9 < 0)
if (VAR_7 == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
*VAR_2 = 1;
end:
av_free(inflated_tiles);
return VAR_9;
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"RsccContext *ctx = VAR_0->priv_data;",
"GetByteContext *gbc = &ctx->gbc;",
"GetByteContext tiles_gbc;",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4, *raw;",
"uint8_t *inflated_tiles = NULL;",
"int VAR_5, VAR_6, VAR_7 = 0;",
"int VAR_8, VAR_9 = 0;",
"bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->size);",
"if (bytestream2_get_bytes_left(gbc) < 12) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet too small (%d)\\n\", VAR_3->size);",
"return AVERROR_INVALIDDATA;",
"VAR_5 = bytestream2_get_le16(gbc);",
"av_fast_malloc(&ctx->tiles, &ctx->tiles_size,\nVAR_5 * sizeof(*ctx->tiles));",
"if (!ctx->tiles) {",
"VAR_9 = AVERROR(ENOMEM);",
"av_log(VAR_0, AV_LOG_DEBUG, \"Frame with %d tiles.\\n\", VAR_5);",
"if (VAR_5 > 5) {",
"uLongf packed_tiles_size;",
"if (VAR_5 < 32)\npacked_tiles_size = bytestream2_get_byte(gbc);",
"else\npacked_tiles_size = bytestream2_get_le16(gbc);",
"ff_dlog(VAR_0, \"packed tiles of size %lu.\\n\", packed_tiles_size);",
"if (packed_tiles_size != VAR_5 * TILE_SIZE) {",
"uLongf length = VAR_5 * TILE_SIZE;",
"inflated_tiles = av_malloc(length);",
"if (!inflated_tiles) {",
"VAR_9 = AVERROR(ENOMEM);",
"VAR_9 = uncompress(inflated_tiles, &length,\ngbc->buffer, packed_tiles_size);",
"if (VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Tile deflate error %d.\\n\", VAR_9);",
"VAR_9 = AVERROR_UNKNOWN;",
"bytestream2_skip(gbc, packed_tiles_size);",
"bytestream2_init(&tiles_gbc, inflated_tiles, length);",
"gbc = &tiles_gbc;",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {",
"ctx->tiles[VAR_8].x = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].w = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].y = bytestream2_get_le16(gbc);",
"ctx->tiles[VAR_8].h = bytestream2_get_le16(gbc);",
"VAR_7 += ctx->tiles[VAR_8].w * ctx->tiles[VAR_8].h * ctx->component_size;",
"ff_dlog(VAR_0, \"tile %d orig(%d,%d) %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"if (ctx->tiles[VAR_8].w == 0 || ctx->tiles[VAR_8].h == 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"invalid tile %d at (%d.%d) with size %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"} else if (ctx->tiles[VAR_8].x + ctx->tiles[VAR_8].w > VAR_0->width ||",
"ctx->tiles[VAR_8].y + ctx->tiles[VAR_8].h > VAR_0->height) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"out of bounds tile %d at (%d.%d) with size %dx%d.\\n\", VAR_8,\nctx->tiles[VAR_8].x, ctx->tiles[VAR_8].y,\nctx->tiles[VAR_8].w, ctx->tiles[VAR_8].h);",
"gbc = &ctx->gbc;",
"if (VAR_7 < 0x100)\nVAR_6 = bytestream2_get_byte(gbc);",
"else if (VAR_7 < 0x10000)\nVAR_6 = bytestream2_get_le16(gbc);",
"else if (VAR_7 < 0x1000000)\nVAR_6 = bytestream2_get_le24(gbc);",
"else\nVAR_6 = bytestream2_get_le32(gbc);",
"ff_dlog(VAR_0, \"VAR_7 %d VAR_6 %d.\\n\", VAR_7, VAR_6);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid tile size %d\\n\", VAR_6);",
"if (VAR_7 == VAR_6) {",
"if (bytestream2_get_bytes_left(gbc) < VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Insufficient input for %d\\n\", VAR_7);",
"VAR_4 = gbc->buffer;",
"} else {",
"uLongf len = ctx->inflated_size;",
"VAR_9 = uncompress(ctx->inflated_buf, &len, gbc->buffer, VAR_6);",
"if (VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Pixel deflate error %d.\\n\", VAR_9);",
"VAR_9 = AVERROR_UNKNOWN;",
"VAR_4 = ctx->inflated_buf;",
"VAR_9 = ff_reget_buffer(VAR_0, ctx->reference);",
"if (VAR_9 < 0)\nraw = VAR_4;",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {",
"uint8_t *dst = ctx->reference->VAR_1[0] + ctx->reference->linesize[0] *\n(VAR_0->height - ctx->tiles[VAR_8].y - 1) +\nctx->tiles[VAR_8].x * ctx->component_size;",
"av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],\nraw, ctx->tiles[VAR_8].w * ctx->component_size,\nctx->tiles[VAR_8].w * ctx->component_size,\nctx->tiles[VAR_8].h);",
"raw += ctx->tiles[VAR_8].w * ctx->component_size * ctx->tiles[VAR_8].h;",
"VAR_9 = av_frame_ref(frame, ctx->reference);",
"if (VAR_9 < 0)\nif (VAR_7 == ctx->inflated_size) {",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"frame->key_frame = 1;",
"} else {",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"*VAR_2 = 1;",
"end:\nav_free(inflated_tiles);",
"return VAR_9;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31
],
[
33
],
[
35
],
[
42
],
[
44,
46
],
[
48
],
[
50
],
[
56
],
[
66
],
[
68
],
[
72,
74
],
[
76,
78
],
[
82
],
[
88
],
[
90
],
[
92
],
[
94
],
[
96
],
[
102,
104
],
[
106
],
[
108
],
[
110
],
[
120
],
[
122
],
[
124
],
[
132
],
[
134
],
[
136
],
[
138
],
[
140
],
[
144
],
[
148,
150,
152
],
[
156
],
[
158,
160,
162,
164
],
[
168
],
[
170
],
[
172,
174,
176,
178
],
[
188
],
[
194,
196
],
[
198,
200
],
[
202,
204
],
[
206,
208
],
[
212
],
[
216
],
[
218
],
[
227
],
[
229
],
[
231
],
[
236
],
[
238
],
[
240
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
264
],
[
266,
273
],
[
275
],
[
277,
279,
281
],
[
283,
285,
287,
289
],
[
291
],
[
298
],
[
300,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
318
],
[
322,
324
],
[
326
]
] |
24,793 | static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)
{
if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&
st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
timestamp < st->pts_wrap_reference)
return timestamp + (1LL<<st->pts_wrap_bits);
else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
timestamp >= st->pts_wrap_reference)
return timestamp - (1LL<<st->pts_wrap_bits);
}
return timestamp;
}
| true | FFmpeg | 1662bd350a470f1cbd5c2cc9a0e1bfaa8543033f | static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)
{
if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&
st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
timestamp < st->pts_wrap_reference)
return timestamp + (1LL<<st->pts_wrap_bits);
else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
timestamp >= st->pts_wrap_reference)
return timestamp - (1LL<<st->pts_wrap_bits);
}
return timestamp;
}
| {
"code": [
" return timestamp + (1LL<<st->pts_wrap_bits);",
" return timestamp - (1LL<<st->pts_wrap_bits);"
],
"line_no": [
13,
19
]
} | static int64_t FUNC_0(AVStream *st, int64_t timestamp)
{
if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&
st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
timestamp < st->pts_wrap_reference)
return timestamp + (1LL<<st->pts_wrap_bits);
else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
timestamp >= st->pts_wrap_reference)
return timestamp - (1LL<<st->pts_wrap_bits);
}
return timestamp;
}
| [
"static int64_t FUNC_0(AVStream *st, int64_t timestamp)\n{",
"if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&\nst->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {",
"if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&\ntimestamp < st->pts_wrap_reference)\nreturn timestamp + (1LL<<st->pts_wrap_bits);",
"else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&\ntimestamp >= st->pts_wrap_reference)\nreturn timestamp - (1LL<<st->pts_wrap_bits);",
"}",
"return timestamp;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
]
] |
24,795 | static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
MpegTSContext *ts = s->priv_data;
MpegTSSectionFilter *tss = &tss1->u.section_filter;
int len;
if (is_start) {
memcpy(tss->section_buf, buf, buf_size);
tss->section_index = buf_size;
tss->section_h_size = -1;
tss->end_of_section_reached = 0;
} else {
if (tss->end_of_section_reached)
return;
len = 4096 - tss->section_index;
if (buf_size < len)
len = buf_size;
memcpy(tss->section_buf + tss->section_index, buf, len);
tss->section_index += len;
}
/* compute section length if possible */
if (tss->section_h_size == -1 && tss->section_index >= 3) {
len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
if (len > 4096)
return;
tss->section_h_size = len;
}
if (tss->section_h_size != -1 &&
tss->section_index >= tss->section_h_size) {
int crc_valid = 1;
tss->end_of_section_reached = 1;
if (tss->check_crc) {
crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
if (crc_valid) {
ts->crc_validity[ tss1->pid ] = 100;
}else if (ts->crc_validity[ tss1->pid ] > -10) {
ts->crc_validity[ tss1->pid ]--;
}else
crc_valid = 2;
}
if (crc_valid)
tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
}
}
| true | FFmpeg | 8635954335061ea4c03d3f492b7bc803ea740d9c | static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
MpegTSContext *ts = s->priv_data;
MpegTSSectionFilter *tss = &tss1->u.section_filter;
int len;
if (is_start) {
memcpy(tss->section_buf, buf, buf_size);
tss->section_index = buf_size;
tss->section_h_size = -1;
tss->end_of_section_reached = 0;
} else {
if (tss->end_of_section_reached)
return;
len = 4096 - tss->section_index;
if (buf_size < len)
len = buf_size;
memcpy(tss->section_buf + tss->section_index, buf, len);
tss->section_index += len;
}
if (tss->section_h_size == -1 && tss->section_index >= 3) {
len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
if (len > 4096)
return;
tss->section_h_size = len;
}
if (tss->section_h_size != -1 &&
tss->section_index >= tss->section_h_size) {
int crc_valid = 1;
tss->end_of_section_reached = 1;
if (tss->check_crc) {
crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
if (crc_valid) {
ts->crc_validity[ tss1->pid ] = 100;
}else if (ts->crc_validity[ tss1->pid ] > -10) {
ts->crc_validity[ tss1->pid ]--;
}else
crc_valid = 2;
}
if (crc_valid)
tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
}
}
| {
"code": [
"static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,",
" MpegTSContext *ts = s->priv_data;"
],
"line_no": [
1,
7
]
} | static void FUNC_0(AVFormatContext *VAR_0, MpegTSFilter *VAR_1,
const uint8_t *VAR_2, int VAR_3, int VAR_4)
{
MpegTSContext *ts = VAR_0->priv_data;
MpegTSSectionFilter *tss = &VAR_1->u.section_filter;
int VAR_5;
if (VAR_4) {
memcpy(tss->section_buf, VAR_2, VAR_3);
tss->section_index = VAR_3;
tss->section_h_size = -1;
tss->end_of_section_reached = 0;
} else {
if (tss->end_of_section_reached)
return;
VAR_5 = 4096 - tss->section_index;
if (VAR_3 < VAR_5)
VAR_5 = VAR_3;
memcpy(tss->section_buf + tss->section_index, VAR_2, VAR_5);
tss->section_index += VAR_5;
}
if (tss->section_h_size == -1 && tss->section_index >= 3) {
VAR_5 = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
if (VAR_5 > 4096)
return;
tss->section_h_size = VAR_5;
}
if (tss->section_h_size != -1 &&
tss->section_index >= tss->section_h_size) {
int VAR_6 = 1;
tss->end_of_section_reached = 1;
if (tss->check_crc) {
VAR_6 = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
if (VAR_6) {
ts->crc_validity[ VAR_1->pid ] = 100;
}else if (ts->crc_validity[ VAR_1->pid ] > -10) {
ts->crc_validity[ VAR_1->pid ]--;
}else
VAR_6 = 2;
}
if (VAR_6)
tss->section_cb(VAR_1, tss->section_buf, tss->section_h_size);
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, MpegTSFilter *VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int VAR_4)\n{",
"MpegTSContext *ts = VAR_0->priv_data;",
"MpegTSSectionFilter *tss = &VAR_1->u.section_filter;",
"int VAR_5;",
"if (VAR_4) {",
"memcpy(tss->section_buf, VAR_2, VAR_3);",
"tss->section_index = VAR_3;",
"tss->section_h_size = -1;",
"tss->end_of_section_reached = 0;",
"} else {",
"if (tss->end_of_section_reached)\nreturn;",
"VAR_5 = 4096 - tss->section_index;",
"if (VAR_3 < VAR_5)\nVAR_5 = VAR_3;",
"memcpy(tss->section_buf + tss->section_index, VAR_2, VAR_5);",
"tss->section_index += VAR_5;",
"}",
"if (tss->section_h_size == -1 && tss->section_index >= 3) {",
"VAR_5 = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;",
"if (VAR_5 > 4096)\nreturn;",
"tss->section_h_size = VAR_5;",
"}",
"if (tss->section_h_size != -1 &&\ntss->section_index >= tss->section_h_size) {",
"int VAR_6 = 1;",
"tss->end_of_section_reached = 1;",
"if (tss->check_crc) {",
"VAR_6 = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);",
"if (VAR_6) {",
"ts->crc_validity[ VAR_1->pid ] = 100;",
"}else if (ts->crc_validity[ VAR_1->pid ] > -10) {",
"ts->crc_validity[ VAR_1->pid ]--;",
"}else",
"VAR_6 = 2;",
"}",
"if (VAR_6)\ntss->section_cb(VAR_1, tss->section_buf, tss->section_h_size);",
"}",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
]
] |
24,796 | bool migrate_auto_converge(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | bool migrate_auto_converge(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
}
| [
"bool FUNC_0(void)\n{",
"MigrationState *s;",
"s = migrate_get_current();",
"return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
]
] |
24,797 | static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_end = buf + buf_size;
DPCMContext *s = avctx->priv_data;
int out = 0, ret;
int predictor[2];
int ch = 0;
int stereo = s->channels - 1;
int16_t *output_samples;
/* calculate output size */
switch(avctx->codec->id) {
case CODEC_ID_ROQ_DPCM:
out = buf_size - 8;
break;
case CODEC_ID_INTERPLAY_DPCM:
out = buf_size - 6 - s->channels;
break;
case CODEC_ID_XAN_DPCM:
out = buf_size - 2 * s->channels;
break;
case CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3)
out = buf_size * 2;
else
out = buf_size;
break;
}
if (out <= 0) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
/* get output buffer */
s->frame.nb_samples = out / s->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
output_samples = (int16_t *)s->frame.data[0];
switch(avctx->codec->id) {
case CODEC_ID_ROQ_DPCM:
buf += 6;
if (stereo) {
predictor[1] = (int16_t)(bytestream_get_byte(&buf) << 8);
predictor[0] = (int16_t)(bytestream_get_byte(&buf) << 8);
} else {
predictor[0] = (int16_t)bytestream_get_le16(&buf);
}
/* decode the samples */
while (buf < buf_end) {
predictor[ch] += s->roq_square_array[*buf++];
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
/* toggle channel */
ch ^= stereo;
}
break;
case CODEC_ID_INTERPLAY_DPCM:
buf += 6; /* skip over the stream mask and stream length */
for (ch = 0; ch < s->channels; ch++) {
predictor[ch] = (int16_t)bytestream_get_le16(&buf);
*output_samples++ = predictor[ch];
}
ch = 0;
while (buf < buf_end) {
predictor[ch] += interplay_delta_table[*buf++];
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
/* toggle channel */
ch ^= stereo;
}
break;
case CODEC_ID_XAN_DPCM:
{
int shift[2] = { 4, 4 };
for (ch = 0; ch < s->channels; ch++)
predictor[ch] = (int16_t)bytestream_get_le16(&buf);
ch = 0;
while (buf < buf_end) {
uint8_t n = *buf++;
int16_t diff = (n & 0xFC) << 8;
if ((n & 0x03) == 3)
shift[ch]++;
else
shift[ch] -= (2 * (n & 3));
/* saturate the shifter to a lower limit of 0 */
if (shift[ch] < 0)
shift[ch] = 0;
diff >>= shift[ch];
predictor[ch] += diff;
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
/* toggle channel */
ch ^= stereo;
}
break;
}
case CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3) {
uint8_t *output_samples_u8 = data;
while (buf < buf_end) {
uint8_t n = *buf++;
s->sample[0] += s->sol_table[n >> 4];
s->sample[0] = av_clip_uint8(s->sample[0]);
*output_samples_u8++ = s->sample[0];
s->sample[stereo] += s->sol_table[n & 0x0F];
s->sample[stereo] = av_clip_uint8(s->sample[stereo]);
*output_samples_u8++ = s->sample[stereo];
}
} else {
while (buf < buf_end) {
uint8_t n = *buf++;
if (n & 0x80) s->sample[ch] -= sol_table_16[n & 0x7F];
else s->sample[ch] += sol_table_16[n & 0x7F];
s->sample[ch] = av_clip_int16(s->sample[ch]);
*output_samples++ = s->sample[ch];
/* toggle channel */
ch ^= stereo;
}
}
break;
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return buf_size;
}
| true | FFmpeg | 529a25d6e5c3ff889257a57042872d84dc2312d5 | static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_end = buf + buf_size;
DPCMContext *s = avctx->priv_data;
int out = 0, ret;
int predictor[2];
int ch = 0;
int stereo = s->channels - 1;
int16_t *output_samples;
switch(avctx->codec->id) {
case CODEC_ID_ROQ_DPCM:
out = buf_size - 8;
break;
case CODEC_ID_INTERPLAY_DPCM:
out = buf_size - 6 - s->channels;
break;
case CODEC_ID_XAN_DPCM:
out = buf_size - 2 * s->channels;
break;
case CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3)
out = buf_size * 2;
else
out = buf_size;
break;
}
if (out <= 0) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
s->frame.nb_samples = out / s->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
output_samples = (int16_t *)s->frame.data[0];
switch(avctx->codec->id) {
case CODEC_ID_ROQ_DPCM:
buf += 6;
if (stereo) {
predictor[1] = (int16_t)(bytestream_get_byte(&buf) << 8);
predictor[0] = (int16_t)(bytestream_get_byte(&buf) << 8);
} else {
predictor[0] = (int16_t)bytestream_get_le16(&buf);
}
while (buf < buf_end) {
predictor[ch] += s->roq_square_array[*buf++];
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
ch ^= stereo;
}
break;
case CODEC_ID_INTERPLAY_DPCM:
buf += 6;
for (ch = 0; ch < s->channels; ch++) {
predictor[ch] = (int16_t)bytestream_get_le16(&buf);
*output_samples++ = predictor[ch];
}
ch = 0;
while (buf < buf_end) {
predictor[ch] += interplay_delta_table[*buf++];
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
ch ^= stereo;
}
break;
case CODEC_ID_XAN_DPCM:
{
int shift[2] = { 4, 4 };
for (ch = 0; ch < s->channels; ch++)
predictor[ch] = (int16_t)bytestream_get_le16(&buf);
ch = 0;
while (buf < buf_end) {
uint8_t n = *buf++;
int16_t diff = (n & 0xFC) << 8;
if ((n & 0x03) == 3)
shift[ch]++;
else
shift[ch] -= (2 * (n & 3));
if (shift[ch] < 0)
shift[ch] = 0;
diff >>= shift[ch];
predictor[ch] += diff;
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
ch ^= stereo;
}
break;
}
case CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3) {
uint8_t *output_samples_u8 = data;
while (buf < buf_end) {
uint8_t n = *buf++;
s->sample[0] += s->sol_table[n >> 4];
s->sample[0] = av_clip_uint8(s->sample[0]);
*output_samples_u8++ = s->sample[0];
s->sample[stereo] += s->sol_table[n & 0x0F];
s->sample[stereo] = av_clip_uint8(s->sample[stereo]);
*output_samples_u8++ = s->sample[stereo];
}
} else {
while (buf < buf_end) {
uint8_t n = *buf++;
if (n & 0x80) s->sample[ch] -= sol_table_16[n & 0x7F];
else s->sample[ch] += sol_table_16[n & 0x7F];
s->sample[ch] = av_clip_int16(s->sample[ch]);
*output_samples++ = s->sample[ch];
ch ^= stereo;
}
}
break;
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return buf_size;
}
| {
"code": [
" uint8_t *output_samples_u8 = data;"
],
"line_no": [
237
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
const uint8_t *VAR_6 = VAR_4 + VAR_5;
DPCMContext *s = VAR_0->priv_data;
int VAR_7 = 0, VAR_8;
int VAR_9[2];
int VAR_10 = 0;
int VAR_11 = s->channels - 1;
int16_t *output_samples;
switch(VAR_0->codec->id) {
case CODEC_ID_ROQ_DPCM:
VAR_7 = VAR_5 - 8;
break;
case CODEC_ID_INTERPLAY_DPCM:
VAR_7 = VAR_5 - 6 - s->channels;
break;
case CODEC_ID_XAN_DPCM:
VAR_7 = VAR_5 - 2 * s->channels;
break;
case CODEC_ID_SOL_DPCM:
if (VAR_0->codec_tag != 3)
VAR_7 = VAR_5 * 2;
else
VAR_7 = VAR_5;
break;
}
if (VAR_7 <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
s->frame.nb_samples = VAR_7 / s->channels;
if ((VAR_8 = VAR_0->get_buffer(VAR_0, &s->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_8;
}
output_samples = (int16_t *)s->frame.VAR_1[0];
switch(VAR_0->codec->id) {
case CODEC_ID_ROQ_DPCM:
VAR_4 += 6;
if (VAR_11) {
VAR_9[1] = (int16_t)(bytestream_get_byte(&VAR_4) << 8);
VAR_9[0] = (int16_t)(bytestream_get_byte(&VAR_4) << 8);
} else {
VAR_9[0] = (int16_t)bytestream_get_le16(&VAR_4);
}
while (VAR_4 < VAR_6) {
VAR_9[VAR_10] += s->roq_square_array[*VAR_4++];
VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);
*output_samples++ = VAR_9[VAR_10];
VAR_10 ^= VAR_11;
}
break;
case CODEC_ID_INTERPLAY_DPCM:
VAR_4 += 6;
for (VAR_10 = 0; VAR_10 < s->channels; VAR_10++) {
VAR_9[VAR_10] = (int16_t)bytestream_get_le16(&VAR_4);
*output_samples++ = VAR_9[VAR_10];
}
VAR_10 = 0;
while (VAR_4 < VAR_6) {
VAR_9[VAR_10] += interplay_delta_table[*VAR_4++];
VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);
*output_samples++ = VAR_9[VAR_10];
VAR_10 ^= VAR_11;
}
break;
case CODEC_ID_XAN_DPCM:
{
int VAR_12[2] = { 4, 4 };
for (VAR_10 = 0; VAR_10 < s->channels; VAR_10++)
VAR_9[VAR_10] = (int16_t)bytestream_get_le16(&VAR_4);
VAR_10 = 0;
while (VAR_4 < VAR_6) {
uint8_t n = *VAR_4++;
int16_t diff = (n & 0xFC) << 8;
if ((n & 0x03) == 3)
VAR_12[VAR_10]++;
else
VAR_12[VAR_10] -= (2 * (n & 3));
if (VAR_12[VAR_10] < 0)
VAR_12[VAR_10] = 0;
diff >>= VAR_12[VAR_10];
VAR_9[VAR_10] += diff;
VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);
*output_samples++ = VAR_9[VAR_10];
VAR_10 ^= VAR_11;
}
break;
}
case CODEC_ID_SOL_DPCM:
if (VAR_0->codec_tag != 3) {
uint8_t *output_samples_u8 = VAR_1;
while (VAR_4 < VAR_6) {
uint8_t n = *VAR_4++;
s->sample[0] += s->sol_table[n >> 4];
s->sample[0] = av_clip_uint8(s->sample[0]);
*output_samples_u8++ = s->sample[0];
s->sample[VAR_11] += s->sol_table[n & 0x0F];
s->sample[VAR_11] = av_clip_uint8(s->sample[VAR_11]);
*output_samples_u8++ = s->sample[VAR_11];
}
} else {
while (VAR_4 < VAR_6) {
uint8_t n = *VAR_4++;
if (n & 0x80) s->sample[VAR_10] -= sol_table_16[n & 0x7F];
else s->sample[VAR_10] += sol_table_16[n & 0x7F];
s->sample[VAR_10] = av_clip_int16(s->sample[VAR_10]);
*output_samples++ = s->sample[VAR_10];
VAR_10 ^= VAR_11;
}
}
break;
}
*VAR_2 = 1;
*(AVFrame *)VAR_1 = s->frame;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"const uint8_t *VAR_6 = VAR_4 + VAR_5;",
"DPCMContext *s = VAR_0->priv_data;",
"int VAR_7 = 0, VAR_8;",
"int VAR_9[2];",
"int VAR_10 = 0;",
"int VAR_11 = s->channels - 1;",
"int16_t *output_samples;",
"switch(VAR_0->codec->id) {",
"case CODEC_ID_ROQ_DPCM:\nVAR_7 = VAR_5 - 8;",
"break;",
"case CODEC_ID_INTERPLAY_DPCM:\nVAR_7 = VAR_5 - 6 - s->channels;",
"break;",
"case CODEC_ID_XAN_DPCM:\nVAR_7 = VAR_5 - 2 * s->channels;",
"break;",
"case CODEC_ID_SOL_DPCM:\nif (VAR_0->codec_tag != 3)\nVAR_7 = VAR_5 * 2;",
"else\nVAR_7 = VAR_5;",
"break;",
"}",
"if (VAR_7 <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"packet is too small\\n\");",
"return AVERROR(EINVAL);",
"}",
"s->frame.nb_samples = VAR_7 / s->channels;",
"if ((VAR_8 = VAR_0->get_buffer(VAR_0, &s->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_8;",
"}",
"output_samples = (int16_t *)s->frame.VAR_1[0];",
"switch(VAR_0->codec->id) {",
"case CODEC_ID_ROQ_DPCM:\nVAR_4 += 6;",
"if (VAR_11) {",
"VAR_9[1] = (int16_t)(bytestream_get_byte(&VAR_4) << 8);",
"VAR_9[0] = (int16_t)(bytestream_get_byte(&VAR_4) << 8);",
"} else {",
"VAR_9[0] = (int16_t)bytestream_get_le16(&VAR_4);",
"}",
"while (VAR_4 < VAR_6) {",
"VAR_9[VAR_10] += s->roq_square_array[*VAR_4++];",
"VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);",
"*output_samples++ = VAR_9[VAR_10];",
"VAR_10 ^= VAR_11;",
"}",
"break;",
"case CODEC_ID_INTERPLAY_DPCM:\nVAR_4 += 6;",
"for (VAR_10 = 0; VAR_10 < s->channels; VAR_10++) {",
"VAR_9[VAR_10] = (int16_t)bytestream_get_le16(&VAR_4);",
"*output_samples++ = VAR_9[VAR_10];",
"}",
"VAR_10 = 0;",
"while (VAR_4 < VAR_6) {",
"VAR_9[VAR_10] += interplay_delta_table[*VAR_4++];",
"VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);",
"*output_samples++ = VAR_9[VAR_10];",
"VAR_10 ^= VAR_11;",
"}",
"break;",
"case CODEC_ID_XAN_DPCM:\n{",
"int VAR_12[2] = { 4, 4 };",
"for (VAR_10 = 0; VAR_10 < s->channels; VAR_10++)",
"VAR_9[VAR_10] = (int16_t)bytestream_get_le16(&VAR_4);",
"VAR_10 = 0;",
"while (VAR_4 < VAR_6) {",
"uint8_t n = *VAR_4++;",
"int16_t diff = (n & 0xFC) << 8;",
"if ((n & 0x03) == 3)\nVAR_12[VAR_10]++;",
"else\nVAR_12[VAR_10] -= (2 * (n & 3));",
"if (VAR_12[VAR_10] < 0)\nVAR_12[VAR_10] = 0;",
"diff >>= VAR_12[VAR_10];",
"VAR_9[VAR_10] += diff;",
"VAR_9[VAR_10] = av_clip_int16(VAR_9[VAR_10]);",
"*output_samples++ = VAR_9[VAR_10];",
"VAR_10 ^= VAR_11;",
"}",
"break;",
"}",
"case CODEC_ID_SOL_DPCM:\nif (VAR_0->codec_tag != 3) {",
"uint8_t *output_samples_u8 = VAR_1;",
"while (VAR_4 < VAR_6) {",
"uint8_t n = *VAR_4++;",
"s->sample[0] += s->sol_table[n >> 4];",
"s->sample[0] = av_clip_uint8(s->sample[0]);",
"*output_samples_u8++ = s->sample[0];",
"s->sample[VAR_11] += s->sol_table[n & 0x0F];",
"s->sample[VAR_11] = av_clip_uint8(s->sample[VAR_11]);",
"*output_samples_u8++ = s->sample[VAR_11];",
"}",
"} else {",
"while (VAR_4 < VAR_6) {",
"uint8_t n = *VAR_4++;",
"if (n & 0x80) s->sample[VAR_10] -= sol_table_16[n & 0x7F];",
"else s->sample[VAR_10] += sol_table_16[n & 0x7F];",
"s->sample[VAR_10] = av_clip_int16(s->sample[VAR_10]);",
"*output_samples++ = s->sample[VAR_10];",
"VAR_10 ^= VAR_11;",
"}",
"}",
"break;",
"}",
"*VAR_2 = 1;",
"*(AVFrame *)VAR_1 = s->frame;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
127
],
[
129
],
[
131
],
[
135,
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199,
201
],
[
205,
207
],
[
211
],
[
213
],
[
217
],
[
219
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
295
],
[
297
]
] |
24,798 | static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
uint64_t **new_l2_table,
uint64_t *new_l2_offset,
int *new_l2_index)
{
BDRVQcowState *s = bs->opaque;
unsigned int l1_index, l2_index;
uint64_t l2_offset;
uint64_t *l2_table = NULL;
int ret;
/* seek the the l2 offset in the l1 table */
l1_index = offset >> (s->l2_bits + s->cluster_bits);
if (l1_index >= s->l1_size) {
ret = qcow2_grow_l1_table(bs, l1_index + 1, false);
if (ret < 0) {
return ret;
}
}
l2_offset = s->l1_table[l1_index];
/* seek the l2 table of the given l2 offset */
if (l2_offset & QCOW_OFLAG_COPIED) {
/* load the l2 table in memory */
l2_offset &= ~QCOW_OFLAG_COPIED;
ret = l2_load(bs, l2_offset, &l2_table);
if (ret < 0) {
return ret;
}
} else {
/* FIXME Order */
if (l2_offset)
qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
ret = l2_allocate(bs, l1_index, &l2_table);
if (ret < 0) {
return ret;
}
l2_offset = s->l1_table[l1_index] & ~QCOW_OFLAG_COPIED;
}
/* find the cluster offset for the given disk offset */
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
*new_l2_table = l2_table;
*new_l2_offset = l2_offset;
*new_l2_index = l2_index;
return 0;
}
| true | qemu | 16fde5f2c2788232b16c06d34d0459a5c1ec1f6c | static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
uint64_t **new_l2_table,
uint64_t *new_l2_offset,
int *new_l2_index)
{
BDRVQcowState *s = bs->opaque;
unsigned int l1_index, l2_index;
uint64_t l2_offset;
uint64_t *l2_table = NULL;
int ret;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
if (l1_index >= s->l1_size) {
ret = qcow2_grow_l1_table(bs, l1_index + 1, false);
if (ret < 0) {
return ret;
}
}
l2_offset = s->l1_table[l1_index];
if (l2_offset & QCOW_OFLAG_COPIED) {
l2_offset &= ~QCOW_OFLAG_COPIED;
ret = l2_load(bs, l2_offset, &l2_table);
if (ret < 0) {
return ret;
}
} else {
if (l2_offset)
qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
ret = l2_allocate(bs, l1_index, &l2_table);
if (ret < 0) {
return ret;
}
l2_offset = s->l1_table[l1_index] & ~QCOW_OFLAG_COPIED;
}
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
*new_l2_table = l2_table;
*new_l2_offset = l2_offset;
*new_l2_index = l2_index;
return 0;
}
| {
"code": [
" if (l2_offset)",
" qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));"
],
"line_no": [
67,
69
]
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t **VAR_2,
uint64_t *VAR_3,
int *VAR_4)
{
BDRVQcowState *s = VAR_0->opaque;
unsigned int VAR_5, VAR_6;
uint64_t l2_offset;
uint64_t *l2_table = NULL;
int VAR_7;
VAR_5 = VAR_1 >> (s->l2_bits + s->cluster_bits);
if (VAR_5 >= s->l1_size) {
VAR_7 = qcow2_grow_l1_table(VAR_0, VAR_5 + 1, false);
if (VAR_7 < 0) {
return VAR_7;
}
}
l2_offset = s->l1_table[VAR_5];
if (l2_offset & QCOW_OFLAG_COPIED) {
l2_offset &= ~QCOW_OFLAG_COPIED;
VAR_7 = l2_load(VAR_0, l2_offset, &l2_table);
if (VAR_7 < 0) {
return VAR_7;
}
} else {
if (l2_offset)
qcow2_free_clusters(VAR_0, l2_offset, s->l2_size * sizeof(uint64_t));
VAR_7 = l2_allocate(VAR_0, VAR_5, &l2_table);
if (VAR_7 < 0) {
return VAR_7;
}
l2_offset = s->l1_table[VAR_5] & ~QCOW_OFLAG_COPIED;
}
VAR_6 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);
*VAR_2 = l2_table;
*VAR_3 = l2_offset;
*VAR_4 = VAR_6;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t **VAR_2,\nuint64_t *VAR_3,\nint *VAR_4)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"unsigned int VAR_5, VAR_6;",
"uint64_t l2_offset;",
"uint64_t *l2_table = NULL;",
"int VAR_7;",
"VAR_5 = VAR_1 >> (s->l2_bits + s->cluster_bits);",
"if (VAR_5 >= s->l1_size) {",
"VAR_7 = qcow2_grow_l1_table(VAR_0, VAR_5 + 1, false);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"}",
"l2_offset = s->l1_table[VAR_5];",
"if (l2_offset & QCOW_OFLAG_COPIED) {",
"l2_offset &= ~QCOW_OFLAG_COPIED;",
"VAR_7 = l2_load(VAR_0, l2_offset, &l2_table);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"} else {",
"if (l2_offset)\nqcow2_free_clusters(VAR_0, l2_offset, s->l2_size * sizeof(uint64_t));",
"VAR_7 = l2_allocate(VAR_0, VAR_5, &l2_table);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"l2_offset = s->l1_table[VAR_5] & ~QCOW_OFLAG_COPIED;",
"}",
"VAR_6 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);",
"*VAR_2 = l2_table;",
"*VAR_3 = l2_offset;",
"*VAR_4 = VAR_6;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
]
] |
24,799 | static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height)
{
const uint8_t *frame_start = frame;
const uint8_t *frame_end = frame + width * height;
int mask = 0x10000, bitbuf = 0;
int i, v, offset, count, segments;
segments = bytestream2_get_le16(gb);
while (segments--) {
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
if (mask == 0x10000) {
bitbuf = bytestream2_get_le16u(gb);
mask = 1;
}
if (bitbuf & mask) {
v = bytestream2_get_le16(gb);
offset = (v & 0x1FFF) << 2;
count = ((v >> 13) + 2) << 1;
if (frame - frame_start < offset || frame_end - frame < count*2 + width)
return AVERROR_INVALIDDATA;
for (i = 0; i < count; i++) {
frame[0] = frame[1] =
frame[width] = frame[width + 1] = frame[-offset];
frame += 2;
}
} else if (bitbuf & (mask << 1)) {
v = bytestream2_get_le16(gb)*2;
if (frame - frame_end < v)
return AVERROR_INVALIDDATA;
frame += v;
} else {
if (frame_end - frame < width + 3)
return AVERROR_INVALIDDATA;
frame[0] = frame[1] =
frame[width] = frame[width + 1] = bytestream2_get_byte(gb);
frame += 2;
frame[0] = frame[1] =
frame[width] = frame[width + 1] = bytestream2_get_byte(gb);
frame += 2;
}
mask <<= 2;
}
return 0;
}
| true | FFmpeg | f52fbf4f3ed02a7d872d8a102006f29b4421f360 | static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height)
{
const uint8_t *frame_start = frame;
const uint8_t *frame_end = frame + width * height;
int mask = 0x10000, bitbuf = 0;
int i, v, offset, count, segments;
segments = bytestream2_get_le16(gb);
while (segments--) {
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
if (mask == 0x10000) {
bitbuf = bytestream2_get_le16u(gb);
mask = 1;
}
if (bitbuf & mask) {
v = bytestream2_get_le16(gb);
offset = (v & 0x1FFF) << 2;
count = ((v >> 13) + 2) << 1;
if (frame - frame_start < offset || frame_end - frame < count*2 + width)
return AVERROR_INVALIDDATA;
for (i = 0; i < count; i++) {
frame[0] = frame[1] =
frame[width] = frame[width + 1] = frame[-offset];
frame += 2;
}
} else if (bitbuf & (mask << 1)) {
v = bytestream2_get_le16(gb)*2;
if (frame - frame_end < v)
return AVERROR_INVALIDDATA;
frame += v;
} else {
if (frame_end - frame < width + 3)
return AVERROR_INVALIDDATA;
frame[0] = frame[1] =
frame[width] = frame[width + 1] = bytestream2_get_byte(gb);
frame += 2;
frame[0] = frame[1] =
frame[width] = frame[width + 1] = bytestream2_get_byte(gb);
frame += 2;
}
mask <<= 2;
}
return 0;
}
| {
"code": [
" if (frame_end - frame < width + 3)"
],
"line_no": [
69
]
} | static int FUNC_0(GetByteContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3)
{
const uint8_t *VAR_4 = VAR_1;
const uint8_t *VAR_5 = VAR_1 + VAR_2 * VAR_3;
int VAR_6 = 0x10000, VAR_7 = 0;
int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
VAR_12 = bytestream2_get_le16(VAR_0);
while (VAR_12--) {
if (bytestream2_get_bytes_left(VAR_0) < 2)
return AVERROR_INVALIDDATA;
if (VAR_6 == 0x10000) {
VAR_7 = bytestream2_get_le16u(VAR_0);
VAR_6 = 1;
}
if (VAR_7 & VAR_6) {
VAR_9 = bytestream2_get_le16(VAR_0);
VAR_10 = (VAR_9 & 0x1FFF) << 2;
VAR_11 = ((VAR_9 >> 13) + 2) << 1;
if (VAR_1 - VAR_4 < VAR_10 || VAR_5 - VAR_1 < VAR_11*2 + VAR_2)
return AVERROR_INVALIDDATA;
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
VAR_1[0] = VAR_1[1] =
VAR_1[VAR_2] = VAR_1[VAR_2 + 1] = VAR_1[-VAR_10];
VAR_1 += 2;
}
} else if (VAR_7 & (VAR_6 << 1)) {
VAR_9 = bytestream2_get_le16(VAR_0)*2;
if (VAR_1 - VAR_5 < VAR_9)
return AVERROR_INVALIDDATA;
VAR_1 += VAR_9;
} else {
if (VAR_5 - VAR_1 < VAR_2 + 3)
return AVERROR_INVALIDDATA;
VAR_1[0] = VAR_1[1] =
VAR_1[VAR_2] = VAR_1[VAR_2 + 1] = bytestream2_get_byte(VAR_0);
VAR_1 += 2;
VAR_1[0] = VAR_1[1] =
VAR_1[VAR_2] = VAR_1[VAR_2 + 1] = bytestream2_get_byte(VAR_0);
VAR_1 += 2;
}
VAR_6 <<= 2;
}
return 0;
}
| [
"static int FUNC_0(GetByteContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_1;",
"const uint8_t *VAR_5 = VAR_1 + VAR_2 * VAR_3;",
"int VAR_6 = 0x10000, VAR_7 = 0;",
"int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"VAR_12 = bytestream2_get_le16(VAR_0);",
"while (VAR_12--) {",
"if (bytestream2_get_bytes_left(VAR_0) < 2)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_6 == 0x10000) {",
"VAR_7 = bytestream2_get_le16u(VAR_0);",
"VAR_6 = 1;",
"}",
"if (VAR_7 & VAR_6) {",
"VAR_9 = bytestream2_get_le16(VAR_0);",
"VAR_10 = (VAR_9 & 0x1FFF) << 2;",
"VAR_11 = ((VAR_9 >> 13) + 2) << 1;",
"if (VAR_1 - VAR_4 < VAR_10 || VAR_5 - VAR_1 < VAR_11*2 + VAR_2)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"VAR_1[0] = VAR_1[1] =\nVAR_1[VAR_2] = VAR_1[VAR_2 + 1] = VAR_1[-VAR_10];",
"VAR_1 += 2;",
"}",
"} else if (VAR_7 & (VAR_6 << 1)) {",
"VAR_9 = bytestream2_get_le16(VAR_0)*2;",
"if (VAR_1 - VAR_5 < VAR_9)\nreturn AVERROR_INVALIDDATA;",
"VAR_1 += VAR_9;",
"} else {",
"if (VAR_5 - VAR_1 < VAR_2 + 3)\nreturn AVERROR_INVALIDDATA;",
"VAR_1[0] = VAR_1[1] =\nVAR_1[VAR_2] = VAR_1[VAR_2 + 1] = bytestream2_get_byte(VAR_0);",
"VAR_1 += 2;",
"VAR_1[0] = VAR_1[1] =\nVAR_1[VAR_2] = VAR_1[VAR_2 + 1] = bytestream2_get_byte(VAR_0);",
"VAR_1 += 2;",
"}",
"VAR_6 <<= 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
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
],
[
93
],
[
95
]
] |
24,800 | int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
{
uint8_t rps_predict = 0;
int delta_poc;
int k0 = 0;
int k1 = 0;
int k = 0;
int i;
if (rps != sps->st_rps && sps->nb_st_rps)
rps_predict = get_bits1(gb);
if (rps_predict) {
const ShortTermRPS *rps_ridx;
int delta_rps;
unsigned abs_delta_rps;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (is_slice_header) {
unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) {
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
delta_idx, sps->nb_st_rps);
rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
rps->rps_idx_num_delta_pocs = rps_ridx->num_delta_pocs;
} else
rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
delta_rps_sign = get_bits1(gb);
abs_delta_rps = get_ue_golomb_long(gb) + 1;
if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
"Invalid value of abs_delta_rps: %d\n",
abs_delta_rps);
delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
int used = rps->used[k] = get_bits1(gb);
if (!used)
use_delta_flag = get_bits1(gb);
if (used || use_delta_flag) {
if (i < rps_ridx->num_delta_pocs)
delta_poc = delta_rps + rps_ridx->delta_poc[i];
else
delta_poc = delta_rps;
rps->delta_poc[k] = delta_poc;
if (delta_poc < 0)
k0++;
else
k1++;
k++;
if (k >= FF_ARRAY_ELEMS(rps->used)) {
"Invalid num_delta_pocs: %d\n", k);
rps->num_delta_pocs = k;
rps->num_negative_pics = k0;
// sort in increasing order (smallest first)
if (rps->num_delta_pocs != 0) {
int used, tmp;
for (i = 1; i < rps->num_delta_pocs; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
for (k = i - 1; k >= 0; k--) {
tmp = rps->delta_poc[k];
if (delta_poc < tmp) {
rps->delta_poc[k + 1] = tmp;
rps->used[k + 1] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
if ((rps->num_negative_pics >> 1) != 0) {
int used;
k = rps->num_negative_pics - 1;
// flip the negative values to largest first
for (i = 0; i < rps->num_negative_pics >> 1; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
rps->delta_poc[i] = rps->delta_poc[k];
rps->used[i] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
k--;
} else {
unsigned int prev, nb_positive_pics;
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
if (rps->num_negative_pics >= HEVC_MAX_REFS ||
nb_positive_pics >= HEVC_MAX_REFS) {
av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
if (rps->num_delta_pocs) {
prev = 0;
for (i = 0; i < rps->num_negative_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev -= delta_poc;
rps->delta_poc[i] = prev;
rps->used[i] = get_bits1(gb);
prev = 0;
for (i = 0; i < nb_positive_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev += delta_poc;
rps->delta_poc[rps->num_negative_pics + i] = prev;
rps->used[rps->num_negative_pics + i] = get_bits1(gb);
return 0;
| true | FFmpeg | 2b44dcbc44e99daf9515753e9fd4c2e1ea53a2fa | int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
{
uint8_t rps_predict = 0;
int delta_poc;
int k0 = 0;
int k1 = 0;
int k = 0;
int i;
if (rps != sps->st_rps && sps->nb_st_rps)
rps_predict = get_bits1(gb);
if (rps_predict) {
const ShortTermRPS *rps_ridx;
int delta_rps;
unsigned abs_delta_rps;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (is_slice_header) {
unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) {
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
delta_idx, sps->nb_st_rps);
rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
rps->rps_idx_num_delta_pocs = rps_ridx->num_delta_pocs;
} else
rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
delta_rps_sign = get_bits1(gb);
abs_delta_rps = get_ue_golomb_long(gb) + 1;
if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
"Invalid value of abs_delta_rps: %d\n",
abs_delta_rps);
delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
int used = rps->used[k] = get_bits1(gb);
if (!used)
use_delta_flag = get_bits1(gb);
if (used || use_delta_flag) {
if (i < rps_ridx->num_delta_pocs)
delta_poc = delta_rps + rps_ridx->delta_poc[i];
else
delta_poc = delta_rps;
rps->delta_poc[k] = delta_poc;
if (delta_poc < 0)
k0++;
else
k1++;
k++;
if (k >= FF_ARRAY_ELEMS(rps->used)) {
"Invalid num_delta_pocs: %d\n", k);
rps->num_delta_pocs = k;
rps->num_negative_pics = k0;
if (rps->num_delta_pocs != 0) {
int used, tmp;
for (i = 1; i < rps->num_delta_pocs; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
for (k = i - 1; k >= 0; k--) {
tmp = rps->delta_poc[k];
if (delta_poc < tmp) {
rps->delta_poc[k + 1] = tmp;
rps->used[k + 1] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
if ((rps->num_negative_pics >> 1) != 0) {
int used;
k = rps->num_negative_pics - 1;
for (i = 0; i < rps->num_negative_pics >> 1; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
rps->delta_poc[i] = rps->delta_poc[k];
rps->used[i] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
k--;
} else {
unsigned int prev, nb_positive_pics;
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
if (rps->num_negative_pics >= HEVC_MAX_REFS ||
nb_positive_pics >= HEVC_MAX_REFS) {
av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
if (rps->num_delta_pocs) {
prev = 0;
for (i = 0; i < rps->num_negative_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev -= delta_poc;
rps->delta_poc[i] = prev;
rps->used[i] = get_bits1(gb);
prev = 0;
for (i = 0; i < nb_positive_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev += delta_poc;
rps->delta_poc[rps->num_negative_pics + i] = prev;
rps->used[rps->num_negative_pics + i] = get_bits1(gb);
return 0;
| {
"code": [],
"line_no": []
} | int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,
ShortTermRPS *VAR_2, const HEVCSPS *VAR_3, int VAR_4)
{
uint8_t rps_predict = 0;
int VAR_5;
int VAR_6 = 0;
int VAR_7 = 0;
int VAR_8 = 0;
int VAR_9;
if (VAR_2 != VAR_3->st_rps && VAR_3->nb_st_rps)
rps_predict = get_bits1(VAR_0);
if (rps_predict) {
const ShortTermRPS *VAR_10;
int VAR_11;
unsigned VAR_12;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (VAR_4) {
unsigned int VAR_13 = get_ue_golomb_long(VAR_0) + 1;
if (VAR_13 > VAR_3->nb_st_rps) {
"Invalid value of VAR_13 in slice header RPS: %d > %d.\n",
VAR_13, VAR_3->nb_st_rps);
VAR_10 = &VAR_3->st_rps[VAR_3->nb_st_rps - VAR_13];
VAR_2->rps_idx_num_delta_pocs = VAR_10->num_delta_pocs;
} else
VAR_10 = &VAR_3->st_rps[VAR_2 - VAR_3->st_rps - 1];
delta_rps_sign = get_bits1(VAR_0);
VAR_12 = get_ue_golomb_long(VAR_0) + 1;
if (VAR_12 < 1 || VAR_12 > 32768) {
"Invalid value of VAR_12: %d\n",
VAR_12);
VAR_11 = (1 - (delta_rps_sign << 1)) * VAR_12;
for (VAR_9 = 0; VAR_9 <= VAR_10->num_delta_pocs; VAR_9++) {
int used = VAR_2->used[VAR_8] = get_bits1(VAR_0);
if (!used)
use_delta_flag = get_bits1(VAR_0);
if (used || use_delta_flag) {
if (VAR_9 < VAR_10->num_delta_pocs)
VAR_5 = VAR_11 + VAR_10->VAR_5[VAR_9];
else
VAR_5 = VAR_11;
VAR_2->VAR_5[VAR_8] = VAR_5;
if (VAR_5 < 0)
VAR_6++;
else
VAR_7++;
VAR_8++;
if (VAR_8 >= FF_ARRAY_ELEMS(VAR_2->used)) {
"Invalid num_delta_pocs: %d\n", VAR_8);
VAR_2->num_delta_pocs = VAR_8;
VAR_2->num_negative_pics = VAR_6;
if (VAR_2->num_delta_pocs != 0) {
int used, tmp;
for (VAR_9 = 1; VAR_9 < VAR_2->num_delta_pocs; VAR_9++) {
VAR_5 = VAR_2->VAR_5[VAR_9];
used = VAR_2->used[VAR_9];
for (VAR_8 = VAR_9 - 1; VAR_8 >= 0; VAR_8--) {
tmp = VAR_2->VAR_5[VAR_8];
if (VAR_5 < tmp) {
VAR_2->VAR_5[VAR_8 + 1] = tmp;
VAR_2->used[VAR_8 + 1] = VAR_2->used[VAR_8];
VAR_2->VAR_5[VAR_8] = VAR_5;
VAR_2->used[VAR_8] = used;
if ((VAR_2->num_negative_pics >> 1) != 0) {
int used;
VAR_8 = VAR_2->num_negative_pics - 1;
for (VAR_9 = 0; VAR_9 < VAR_2->num_negative_pics >> 1; VAR_9++) {
VAR_5 = VAR_2->VAR_5[VAR_9];
used = VAR_2->used[VAR_9];
VAR_2->VAR_5[VAR_9] = VAR_2->VAR_5[VAR_8];
VAR_2->used[VAR_9] = VAR_2->used[VAR_8];
VAR_2->VAR_5[VAR_8] = VAR_5;
VAR_2->used[VAR_8] = used;
VAR_8--;
} else {
unsigned int prev, nb_positive_pics;
VAR_2->num_negative_pics = get_ue_golomb_long(VAR_0);
nb_positive_pics = get_ue_golomb_long(VAR_0);
if (VAR_2->num_negative_pics >= HEVC_MAX_REFS ||
nb_positive_pics >= HEVC_MAX_REFS) {
av_log(VAR_1, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
VAR_2->num_delta_pocs = VAR_2->num_negative_pics + nb_positive_pics;
if (VAR_2->num_delta_pocs) {
prev = 0;
for (VAR_9 = 0; VAR_9 < VAR_2->num_negative_pics; VAR_9++) {
VAR_5 = get_ue_golomb_long(VAR_0) + 1;
prev -= VAR_5;
VAR_2->VAR_5[VAR_9] = prev;
VAR_2->used[VAR_9] = get_bits1(VAR_0);
prev = 0;
for (VAR_9 = 0; VAR_9 < nb_positive_pics; VAR_9++) {
VAR_5 = get_ue_golomb_long(VAR_0) + 1;
prev += VAR_5;
VAR_2->VAR_5[VAR_2->num_negative_pics + VAR_9] = prev;
VAR_2->used[VAR_2->num_negative_pics + VAR_9] = get_bits1(VAR_0);
return 0;
| [
"int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,\nShortTermRPS *VAR_2, const HEVCSPS *VAR_3, int VAR_4)\n{",
"uint8_t rps_predict = 0;",
"int VAR_5;",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"int VAR_8 = 0;",
"int VAR_9;",
"if (VAR_2 != VAR_3->st_rps && VAR_3->nb_st_rps)\nrps_predict = get_bits1(VAR_0);",
"if (rps_predict) {",
"const ShortTermRPS *VAR_10;",
"int VAR_11;",
"unsigned VAR_12;",
"uint8_t use_delta_flag = 0;",
"uint8_t delta_rps_sign;",
"if (VAR_4) {",
"unsigned int VAR_13 = get_ue_golomb_long(VAR_0) + 1;",
"if (VAR_13 > VAR_3->nb_st_rps) {",
"\"Invalid value of VAR_13 in slice header RPS: %d > %d.\\n\",\nVAR_13, VAR_3->nb_st_rps);",
"VAR_10 = &VAR_3->st_rps[VAR_3->nb_st_rps - VAR_13];",
"VAR_2->rps_idx_num_delta_pocs = VAR_10->num_delta_pocs;",
"} else",
"VAR_10 = &VAR_3->st_rps[VAR_2 - VAR_3->st_rps - 1];",
"delta_rps_sign = get_bits1(VAR_0);",
"VAR_12 = get_ue_golomb_long(VAR_0) + 1;",
"if (VAR_12 < 1 || VAR_12 > 32768) {",
"\"Invalid value of VAR_12: %d\\n\",\nVAR_12);",
"VAR_11 = (1 - (delta_rps_sign << 1)) * VAR_12;",
"for (VAR_9 = 0; VAR_9 <= VAR_10->num_delta_pocs; VAR_9++) {",
"int used = VAR_2->used[VAR_8] = get_bits1(VAR_0);",
"if (!used)\nuse_delta_flag = get_bits1(VAR_0);",
"if (used || use_delta_flag) {",
"if (VAR_9 < VAR_10->num_delta_pocs)\nVAR_5 = VAR_11 + VAR_10->VAR_5[VAR_9];",
"else\nVAR_5 = VAR_11;",
"VAR_2->VAR_5[VAR_8] = VAR_5;",
"if (VAR_5 < 0)\nVAR_6++;",
"else\nVAR_7++;",
"VAR_8++;",
"if (VAR_8 >= FF_ARRAY_ELEMS(VAR_2->used)) {",
"\"Invalid num_delta_pocs: %d\\n\", VAR_8);",
"VAR_2->num_delta_pocs = VAR_8;",
"VAR_2->num_negative_pics = VAR_6;",
"if (VAR_2->num_delta_pocs != 0) {",
"int used, tmp;",
"for (VAR_9 = 1; VAR_9 < VAR_2->num_delta_pocs; VAR_9++) {",
"VAR_5 = VAR_2->VAR_5[VAR_9];",
"used = VAR_2->used[VAR_9];",
"for (VAR_8 = VAR_9 - 1; VAR_8 >= 0; VAR_8--) {",
"tmp = VAR_2->VAR_5[VAR_8];",
"if (VAR_5 < tmp) {",
"VAR_2->VAR_5[VAR_8 + 1] = tmp;",
"VAR_2->used[VAR_8 + 1] = VAR_2->used[VAR_8];",
"VAR_2->VAR_5[VAR_8] = VAR_5;",
"VAR_2->used[VAR_8] = used;",
"if ((VAR_2->num_negative_pics >> 1) != 0) {",
"int used;",
"VAR_8 = VAR_2->num_negative_pics - 1;",
"for (VAR_9 = 0; VAR_9 < VAR_2->num_negative_pics >> 1; VAR_9++) {",
"VAR_5 = VAR_2->VAR_5[VAR_9];",
"used = VAR_2->used[VAR_9];",
"VAR_2->VAR_5[VAR_9] = VAR_2->VAR_5[VAR_8];",
"VAR_2->used[VAR_9] = VAR_2->used[VAR_8];",
"VAR_2->VAR_5[VAR_8] = VAR_5;",
"VAR_2->used[VAR_8] = used;",
"VAR_8--;",
"} else {",
"unsigned int prev, nb_positive_pics;",
"VAR_2->num_negative_pics = get_ue_golomb_long(VAR_0);",
"nb_positive_pics = get_ue_golomb_long(VAR_0);",
"if (VAR_2->num_negative_pics >= HEVC_MAX_REFS ||\nnb_positive_pics >= HEVC_MAX_REFS) {",
"av_log(VAR_1, AV_LOG_ERROR, \"Too many refs in a short term RPS.\\n\");",
"VAR_2->num_delta_pocs = VAR_2->num_negative_pics + nb_positive_pics;",
"if (VAR_2->num_delta_pocs) {",
"prev = 0;",
"for (VAR_9 = 0; VAR_9 < VAR_2->num_negative_pics; VAR_9++) {",
"VAR_5 = get_ue_golomb_long(VAR_0) + 1;",
"prev -= VAR_5;",
"VAR_2->VAR_5[VAR_9] = prev;",
"VAR_2->used[VAR_9] = get_bits1(VAR_0);",
"prev = 0;",
"for (VAR_9 = 0; VAR_9 < nb_positive_pics; VAR_9++) {",
"VAR_5 = get_ue_golomb_long(VAR_0) + 1;",
"prev += VAR_5;",
"VAR_2->VAR_5[VAR_2->num_negative_pics + VAR_9] = prev;",
"VAR_2->used[VAR_2->num_negative_pics + VAR_9] = get_bits1(VAR_0);",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
48,
50
],
[
54
],
[
56
],
[
58
],
[
60
],
[
64
],
[
66
],
[
68
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
91
],
[
93,
95
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
117
],
[
120
],
[
126
],
[
128
],
[
132
],
[
134
],
[
136
],
[
138
],
[
140
],
[
142
],
[
144
],
[
146
],
[
148
],
[
150
],
[
152
],
[
154
],
[
160
],
[
162
],
[
164
],
[
168
],
[
170
],
[
172
],
[
174
],
[
176
],
[
178
],
[
180
],
[
182
],
[
186
],
[
188
],
[
190
],
[
192
],
[
196,
198
],
[
200
],
[
206
],
[
208
],
[
210
],
[
212
],
[
214
],
[
222
],
[
224
],
[
226
],
[
229
],
[
231
],
[
233
],
[
241
],
[
243
],
[
245
],
[
250
]
] |
24,801 | static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
{
/* TODO:
* - Magic packets should set bit 30 in power management driver register.
* - Interesting packets should set bit 29 in power management driver register.
*/
EEPRO100State *s = vc->opaque;
uint16_t rfd_status = 0xa000;
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* TODO: check multiple IA bit. */
assert(!(s->configuration[20] & BIT(6)));
if (s->configuration[8] & 0x80) {
/* CSMA is disabled. */
logout("%p received while CSMA is disabled\n", s);
return -1;
} else if (size < 64 && (s->configuration[7] & 1)) {
/* Short frame and configuration byte 7/0 (discard short receive) set:
* Short frame is discarded */
logout("%p received short frame (%zu byte)\n", s, size);
s->statistics.rx_short_frame_errors++;
//~ return -1;
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & 8)) {
/* Long frame and configuration byte 18/3 (long receive ok) not set:
* Long frames are discarded. */
logout("%p received long frame (%zu byte), ignored\n", s, size);
return -1;
} else if (memcmp(buf, s->macaddr, 6) == 0) { // !!!
/* Frame matches individual address. */
/* TODO: check configuration byte 15/4 (ignore U/L). */
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
} else if (memcmp(buf, broadcast_macaddr, 6) == 0) {
/* Broadcast frame. */
TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
rfd_status |= 0x0002;
} else if (buf[0] & 0x01) { // !!!
/* Multicast frame. */
TRACE(RXTX, logout("%p received multicast, len=%zu\n", s, size));
/* TODO: check multicast all bit. */
assert(!(s->configuration[21] & BIT(3)));
int mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) {
return size;
}
rfd_status |= 0x0002;
} else if (s->configuration[15] & 1) {
/* Promiscuous: receive all. */
TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
rfd_status |= 0x0004;
} else {
TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
nic_dump(buf, size)));
return size;
}
if (get_ru_state(s) != ru_ready) {
/* No resources available. */
logout("no resources, state=%u\n", get_ru_state(s));
s->statistics.rx_resource_errors++;
//~ assert(!"no resources");
return -1;
}
//~ !!!
//~ $3 = {status = 0x0, command = 0xc000, link = 0x2d220, rx_buf_addr = 0x207dc, count = 0x0, size = 0x5f8, packet = {0x0 <repeats 1518 times>}}
eepro100_rx_t rx;
cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,
offsetof(eepro100_rx_t, packet));
uint16_t rfd_command = le16_to_cpu(rx.command);
uint16_t rfd_size = le16_to_cpu(rx.size);
assert(size <= rfd_size);
if (size < 64) {
rfd_status |= 0x0080;
}
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
rfd_status);
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);
/* Early receive interrupt not supported. */
//~ eepro100_er_interrupt(s);
/* Receive CRC Transfer not supported. */
assert(!(s->configuration[18] & 4));
/* TODO: check stripping enable bit. */
//~ assert(!(s->configuration[17] & 1));
cpu_physical_memory_write(s->ru_base + s->ru_offset +
offsetof(eepro100_rx_t, packet), buf, size);
s->statistics.rx_good_frames++;
eepro100_fr_interrupt(s);
s->ru_offset = le32_to_cpu(rx.link);
if (rfd_command & 0x8000) {
/* EL bit is set, so this was the last frame. */
assert(0);
}
if (rfd_command & 0x4000) {
/* S bit is set. */
set_ru_state(s, ru_suspended);
}
return size;
}
| true | qemu | 7f1e9d4e138f5baf1e862a1221ba13eee7dcce9e | static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
{
EEPRO100State *s = vc->opaque;
uint16_t rfd_status = 0xa000;
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
assert(!(s->configuration[20] & BIT(6)));
if (s->configuration[8] & 0x80) {
logout("%p received while CSMA is disabled\n", s);
return -1;
} else if (size < 64 && (s->configuration[7] & 1)) {
logout("%p received short frame (%zu byte)\n", s, size);
s->statistics.rx_short_frame_errors++;
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & 8)) {
logout("%p received long frame (%zu byte), ignored\n", s, size);
return -1;
} else if (memcmp(buf, s->macaddr, 6) == 0) {
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
} else if (memcmp(buf, broadcast_macaddr, 6) == 0) {
TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
rfd_status |= 0x0002;
} else if (buf[0] & 0x01) {
TRACE(RXTX, logout("%p received multicast, len=%zu\n", s, size));
assert(!(s->configuration[21] & BIT(3)));
int mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) {
return size;
}
rfd_status |= 0x0002;
} else if (s->configuration[15] & 1) {
TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
rfd_status |= 0x0004;
} else {
TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
nic_dump(buf, size)));
return size;
}
if (get_ru_state(s) != ru_ready) {
logout("no resources, state=%u\n", get_ru_state(s));
s->statistics.rx_resource_errors++;
return -1;
}
eepro100_rx_t rx;
cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,
offsetof(eepro100_rx_t, packet));
uint16_t rfd_command = le16_to_cpu(rx.command);
uint16_t rfd_size = le16_to_cpu(rx.size);
assert(size <= rfd_size);
if (size < 64) {
rfd_status |= 0x0080;
}
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
rfd_status);
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);
assert(!(s->configuration[18] & 4));
cpu_physical_memory_write(s->ru_base + s->ru_offset +
offsetof(eepro100_rx_t, packet), buf, size);
s->statistics.rx_good_frames++;
eepro100_fr_interrupt(s);
s->ru_offset = le32_to_cpu(rx.link);
if (rfd_command & 0x8000) {
assert(0);
}
if (rfd_command & 0x4000) {
set_ru_state(s, ru_suspended);
}
return size;
}
| {
"code": [
" assert(!(s->configuration[20] & BIT(6)));",
" assert(!(s->configuration[21] & BIT(3)));",
" assert(size <= rfd_size);",
" assert(!(s->configuration[18] & 4));",
" assert(0);"
],
"line_no": [
25,
83,
143,
167,
187
]
} | static ssize_t FUNC_0(VLANClientState *vc, const uint8_t * buf, size_t size)
{
EEPRO100State *s = vc->opaque;
uint16_t rfd_status = 0xa000;
static const uint8_t VAR_0[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
assert(!(s->configuration[20] & BIT(6)));
if (s->configuration[8] & 0x80) {
logout("%p received while CSMA is disabled\n", s);
return -1;
} else if (size < 64 && (s->configuration[7] & 1)) {
logout("%p received short frame (%zu byte)\n", s, size);
s->statistics.rx_short_frame_errors++;
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & 8)) {
logout("%p received long frame (%zu byte), ignored\n", s, size);
return -1;
} else if (memcmp(buf, s->macaddr, 6) == 0) {
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
} else if (memcmp(buf, VAR_0, 6) == 0) {
TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
rfd_status |= 0x0002;
} else if (buf[0] & 0x01) {
TRACE(RXTX, logout("%p received multicast, len=%zu\n", s, size));
assert(!(s->configuration[21] & BIT(3)));
int VAR_1 = compute_mcast_idx(buf);
if (!(s->mult[VAR_1 >> 3] & (1 << (VAR_1 & 7)))) {
return size;
}
rfd_status |= 0x0002;
} else if (s->configuration[15] & 1) {
TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
rfd_status |= 0x0004;
} else {
TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
nic_dump(buf, size)));
return size;
}
if (get_ru_state(s) != ru_ready) {
logout("no resources, state=%u\n", get_ru_state(s));
s->statistics.rx_resource_errors++;
return -1;
}
eepro100_rx_t rx;
cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,
offsetof(eepro100_rx_t, packet));
uint16_t rfd_command = le16_to_cpu(rx.command);
uint16_t rfd_size = le16_to_cpu(rx.size);
assert(size <= rfd_size);
if (size < 64) {
rfd_status |= 0x0080;
}
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
rfd_status);
stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);
assert(!(s->configuration[18] & 4));
cpu_physical_memory_write(s->ru_base + s->ru_offset +
offsetof(eepro100_rx_t, packet), buf, size);
s->statistics.rx_good_frames++;
eepro100_fr_interrupt(s);
s->ru_offset = le32_to_cpu(rx.link);
if (rfd_command & 0x8000) {
assert(0);
}
if (rfd_command & 0x4000) {
set_ru_state(s, ru_suspended);
}
return size;
}
| [
"static ssize_t FUNC_0(VLANClientState *vc, const uint8_t * buf, size_t size)\n{",
"EEPRO100State *s = vc->opaque;",
"uint16_t rfd_status = 0xa000;",
"static const uint8_t VAR_0[6] =\n{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };",
"assert(!(s->configuration[20] & BIT(6)));",
"if (s->configuration[8] & 0x80) {",
"logout(\"%p received while CSMA is disabled\\n\", s);",
"return -1;",
"} else if (size < 64 && (s->configuration[7] & 1)) {",
"logout(\"%p received short frame (%zu byte)\\n\", s, size);",
"s->statistics.rx_short_frame_errors++;",
"} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & 8)) {",
"logout(\"%p received long frame (%zu byte), ignored\\n\", s, size);",
"return -1;",
"} else if (memcmp(buf, s->macaddr, 6) == 0) {",
"TRACE(RXTX, logout(\"%p received frame for me, len=%zu\\n\", s, size));",
"} else if (memcmp(buf, VAR_0, 6) == 0) {",
"TRACE(RXTX, logout(\"%p received broadcast, len=%zu\\n\", s, size));",
"rfd_status |= 0x0002;",
"} else if (buf[0] & 0x01) {",
"TRACE(RXTX, logout(\"%p received multicast, len=%zu\\n\", s, size));",
"assert(!(s->configuration[21] & BIT(3)));",
"int VAR_1 = compute_mcast_idx(buf);",
"if (!(s->mult[VAR_1 >> 3] & (1 << (VAR_1 & 7)))) {",
"return size;",
"}",
"rfd_status |= 0x0002;",
"} else if (s->configuration[15] & 1) {",
"TRACE(RXTX, logout(\"%p received frame in promiscuous mode, len=%zu\\n\", s, size));",
"rfd_status |= 0x0004;",
"} else {",
"TRACE(RXTX, logout(\"%p received frame, ignored, len=%zu,%s\\n\", s, size,\nnic_dump(buf, size)));",
"return size;",
"}",
"if (get_ru_state(s) != ru_ready) {",
"logout(\"no resources, state=%u\\n\", get_ru_state(s));",
"s->statistics.rx_resource_errors++;",
"return -1;",
"}",
"eepro100_rx_t rx;",
"cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,\noffsetof(eepro100_rx_t, packet));",
"uint16_t rfd_command = le16_to_cpu(rx.command);",
"uint16_t rfd_size = le16_to_cpu(rx.size);",
"assert(size <= rfd_size);",
"if (size < 64) {",
"rfd_status |= 0x0080;",
"}",
"TRACE(OTHER, logout(\"command 0x%04x, link 0x%08x, addr 0x%08x, size %u\\n\",\nrfd_command, rx.link, rx.rx_buf_addr, rfd_size));",
"stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),\nrfd_status);",
"stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);",
"assert(!(s->configuration[18] & 4));",
"cpu_physical_memory_write(s->ru_base + s->ru_offset +\noffsetof(eepro100_rx_t, packet), buf, size);",
"s->statistics.rx_good_frames++;",
"eepro100_fr_interrupt(s);",
"s->ru_offset = le32_to_cpu(rx.link);",
"if (rfd_command & 0x8000) {",
"assert(0);",
"}",
"if (rfd_command & 0x4000) {",
"set_ru_state(s, ru_suspended);",
"}",
"return size;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
13
],
[
15
],
[
17,
19
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
49
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155,
157
],
[
159
],
[
167
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
]
] |
24,802 | static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb)
{
BDRVQuorumState *s = acb->common.bs->opaque;
int i;
for (i = 0; i < s->num_children; i++) {
acb->qcrs[i].buf = qemu_blockalign(s->children[i]->bs, acb->qiov->size);
qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov);
qemu_iovec_clone(&acb->qcrs[i].qiov, acb->qiov, acb->qcrs[i].buf);
}
for (i = 0; i < s->num_children; i++) {
bdrv_aio_readv(s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov,
acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]);
}
return &acb->common;
}
| true | qemu | b9c600d20716b3d942cb07188ff998fb236a8365 | static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb)
{
BDRVQuorumState *s = acb->common.bs->opaque;
int i;
for (i = 0; i < s->num_children; i++) {
acb->qcrs[i].buf = qemu_blockalign(s->children[i]->bs, acb->qiov->size);
qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov);
qemu_iovec_clone(&acb->qcrs[i].qiov, acb->qiov, acb->qcrs[i].buf);
}
for (i = 0; i < s->num_children; i++) {
bdrv_aio_readv(s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov,
acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]);
}
return &acb->common;
}
| {
"code": [
" bdrv_aio_readv(s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov,",
" acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]);"
],
"line_no": [
25,
27
]
} | static BlockAIOCB *FUNC_0(QuorumAIOCB *acb)
{
BDRVQuorumState *s = acb->common.bs->opaque;
int VAR_0;
for (VAR_0 = 0; VAR_0 < s->num_children; VAR_0++) {
acb->qcrs[VAR_0].buf = qemu_blockalign(s->children[VAR_0]->bs, acb->qiov->size);
qemu_iovec_init(&acb->qcrs[VAR_0].qiov, acb->qiov->niov);
qemu_iovec_clone(&acb->qcrs[VAR_0].qiov, acb->qiov, acb->qcrs[VAR_0].buf);
}
for (VAR_0 = 0; VAR_0 < s->num_children; VAR_0++) {
bdrv_aio_readv(s->children[VAR_0]->bs, acb->sector_num, &acb->qcrs[VAR_0].qiov,
acb->nb_sectors, quorum_aio_cb, &acb->qcrs[VAR_0]);
}
return &acb->common;
}
| [
"static BlockAIOCB *FUNC_0(QuorumAIOCB *acb)\n{",
"BDRVQuorumState *s = acb->common.bs->opaque;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < s->num_children; VAR_0++) {",
"acb->qcrs[VAR_0].buf = qemu_blockalign(s->children[VAR_0]->bs, acb->qiov->size);",
"qemu_iovec_init(&acb->qcrs[VAR_0].qiov, acb->qiov->niov);",
"qemu_iovec_clone(&acb->qcrs[VAR_0].qiov, acb->qiov, acb->qcrs[VAR_0].buf);",
"}",
"for (VAR_0 = 0; VAR_0 < s->num_children; VAR_0++) {",
"bdrv_aio_readv(s->children[VAR_0]->bs, acb->sector_num, &acb->qcrs[VAR_0].qiov,\nacb->nb_sectors, quorum_aio_cb, &acb->qcrs[VAR_0]);",
"}",
"return &acb->common;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
]
] |
24,803 | static int flac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
FLACContext *s = avctx->priv_data;
int metadata_last, metadata_type, metadata_size;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples = data;
if(s->max_framesize == 0){
s->max_framesize= 8192; // should hopefully be enough for the first header
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if(1 && s->max_framesize){//FIXME truncated
buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size= buf_size;
if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){
// printf("memmove\n");
memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size);
buf= &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size= buf_size;
if(buf_size < s->max_framesize){
// printf("wanna more data ...\n");
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size*8);
/* fLaC signature (be) */
if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("fLaC")))
{
skip_bits(&s->gb, 32);
av_log(s->avctx, AV_LOG_DEBUG, "STREAM HEADER\n");
do {
metadata_last = get_bits(&s->gb, 1);
metadata_type = get_bits(&s->gb, 7);
metadata_size = get_bits_long(&s->gb, 24);
av_log(s->avctx, AV_LOG_DEBUG, " metadata block: flag = %d, type = %d, size = %d\n",
metadata_last, metadata_type,
metadata_size);
if(metadata_size){
switch(metadata_type)
{
case METADATA_TYPE_STREAMINFO:{
int bits_count= get_bits_count(&s->gb);
metadata_streaminfo(s);
buf= &s->bitstream[s->bitstream_index];
init_get_bits(&s->gb, buf, buf_size*8);
skip_bits(&s->gb, bits_count);
dump_headers(s);
break;}
default:
for(i=0; i<metadata_size; i++)
skip_bits(&s->gb, 8);
}
}
} while(!metadata_last);
}
else
{
tmp = show_bits(&s->gb, 16);
if(tmp != 0xFFF8){
av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
while(get_bits_count(&s->gb)/8+2 < buf_size && show_bits(&s->gb, 16) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end; // we may not have enough bits left to decode a frame, so try next time
}
skip_bits(&s->gb, 16);
if (decode_frame(s) < 0){
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
}
#if 0
/* fix the channel order here */
if (s->order == MID_SIDE)
{
short *left = samples;
short *right = samples + s->blocksize;
for (i = 0; i < s->blocksize; i += 2)
{
uint32_t x = s->decoded[0][i];
uint32_t y = s->decoded[0][i+1];
right[i] = x - (y / 2);
left[i] = right[i] + y;
}
*data_size = 2 * s->blocksize;
}
else
{
for (i = 0; i < s->channels; i++)
{
switch(s->order)
{
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[i][j];
break;
case LEFT_SIDE:
case RIGHT_SIDE:
if (i == 0)
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[0][j];
else
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[0][j] - s->decoded[i][j];
break;
// case MID_SIDE:
// av_log(s->avctx, AV_LOG_DEBUG, "mid-side unsupported\n");
}
*data_size += s->blocksize;
}
}
#else
switch(s->decorrelation)
{
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++)
{
for (i = 0; i < s->channels; i++)
*(samples++) = s->decoded[i][j];
}
break;
case LEFT_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
*(samples++) = s->decoded[0][i];
*(samples++) = s->decoded[0][i] - s->decoded[1][i];
}
break;
case RIGHT_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
*(samples++) = s->decoded[0][i] + s->decoded[1][i];
*(samples++) = s->decoded[1][i];
}
break;
case MID_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
int mid, side;
mid = s->decoded[0][i];
side = s->decoded[1][i];
#if 1 //needs to be checked but IMHO it should be binary identical
mid -= side>>1;
*(samples++) = mid + side;
*(samples++) = mid;
#else
mid <<= 1;
if (side & 1)
mid++;
*(samples++) = (mid + side) >> 1;
*(samples++) = (mid - side) >> 1;
#endif
}
break;
}
#endif
*data_size = (int8_t *)samples - (int8_t *)data;
// av_log(s->avctx, AV_LOG_DEBUG, "data size: %d\n", *data_size);
// s->last_blocksize = s->blocksize;
end:
i= (get_bits_count(&s->gb)+7)/8;;
if(i > buf_size){
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if(s->bitstream_size){
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
}else
return i;
}
| true | FFmpeg | 09f20d37867baaa0122ffdd75f0481b2b3a08079 | static int flac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
FLACContext *s = avctx->priv_data;
int metadata_last, metadata_type, metadata_size;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples = data;
if(s->max_framesize == 0){
s->max_framesize= 8192;
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if(1 && s->max_framesize){
buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size= buf_size;
if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){
memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size);
buf= &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size= buf_size;
if(buf_size < s->max_framesize){
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size*8);
if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("fLaC")))
{
skip_bits(&s->gb, 32);
av_log(s->avctx, AV_LOG_DEBUG, "STREAM HEADER\n");
do {
metadata_last = get_bits(&s->gb, 1);
metadata_type = get_bits(&s->gb, 7);
metadata_size = get_bits_long(&s->gb, 24);
av_log(s->avctx, AV_LOG_DEBUG, " metadata block: flag = %d, type = %d, size = %d\n",
metadata_last, metadata_type,
metadata_size);
if(metadata_size){
switch(metadata_type)
{
case METADATA_TYPE_STREAMINFO:{
int bits_count= get_bits_count(&s->gb);
metadata_streaminfo(s);
buf= &s->bitstream[s->bitstream_index];
init_get_bits(&s->gb, buf, buf_size*8);
skip_bits(&s->gb, bits_count);
dump_headers(s);
break;}
default:
for(i=0; i<metadata_size; i++)
skip_bits(&s->gb, 8);
}
}
} while(!metadata_last);
}
else
{
tmp = show_bits(&s->gb, 16);
if(tmp != 0xFFF8){
av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
while(get_bits_count(&s->gb)/8+2 < buf_size && show_bits(&s->gb, 16) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end;
}
skip_bits(&s->gb, 16);
if (decode_frame(s) < 0){
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
}
#if 0
if (s->order == MID_SIDE)
{
short *left = samples;
short *right = samples + s->blocksize;
for (i = 0; i < s->blocksize; i += 2)
{
uint32_t x = s->decoded[0][i];
uint32_t y = s->decoded[0][i+1];
right[i] = x - (y / 2);
left[i] = right[i] + y;
}
*data_size = 2 * s->blocksize;
}
else
{
for (i = 0; i < s->channels; i++)
{
switch(s->order)
{
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[i][j];
break;
case LEFT_SIDE:
case RIGHT_SIDE:
if (i == 0)
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[0][j];
else
for (j = 0; j < s->blocksize; j++)
samples[(s->blocksize*i)+j] = s->decoded[0][j] - s->decoded[i][j];
break;
}
*data_size += s->blocksize;
}
}
#else
switch(s->decorrelation)
{
case INDEPENDENT:
for (j = 0; j < s->blocksize; j++)
{
for (i = 0; i < s->channels; i++)
*(samples++) = s->decoded[i][j];
}
break;
case LEFT_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
*(samples++) = s->decoded[0][i];
*(samples++) = s->decoded[0][i] - s->decoded[1][i];
}
break;
case RIGHT_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
*(samples++) = s->decoded[0][i] + s->decoded[1][i];
*(samples++) = s->decoded[1][i];
}
break;
case MID_SIDE:
assert(s->channels == 2);
for (i = 0; i < s->blocksize; i++)
{
int mid, side;
mid = s->decoded[0][i];
side = s->decoded[1][i];
#if 1
mid -= side>>1;
*(samples++) = mid + side;
*(samples++) = mid;
#else
mid <<= 1;
if (side & 1)
mid++;
*(samples++) = (mid + side) >> 1;
*(samples++) = (mid - side) >> 1;
#endif
}
break;
}
#endif
*data_size = (int8_t *)samples - (int8_t *)data;
end:
i= (get_bits_count(&s->gb)+7)/8;;
if(i > buf_size){
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if(s->bitstream_size){
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
}else
return i;
}
| {
"code": [
" buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size);",
" buf= &s->bitstream[s->bitstream_index];",
" init_get_bits(&s->gb, buf, buf_size*8);",
" skip_bits(&s->gb, bits_count);"
],
"line_no": [
31,
115,
117,
119
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
FLACContext *s = VAR_0->priv_data;
int VAR_5, VAR_6, VAR_7;
int VAR_8 = 0, VAR_9, VAR_10 = 0, VAR_11 = 0;
int16_t *samples = VAR_1;
if(s->max_framesize == 0){
s->max_framesize= 8192;
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if(1 && s->max_framesize){
VAR_4= FFMIN(VAR_4, s->max_framesize - s->bitstream_size);
VAR_11= VAR_4;
if(s->bitstream_index + s->bitstream_size + VAR_4 > s->allocated_bitstream_size){
memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], VAR_3, VAR_4);
VAR_3= &s->bitstream[s->bitstream_index];
VAR_4 += s->bitstream_size;
s->bitstream_size= VAR_4;
if(VAR_4 < s->max_framesize){
return VAR_11;
}
}
init_get_bits(&s->gb, VAR_3, VAR_4*8);
if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("fLaC")))
{
skip_bits(&s->gb, 32);
av_log(s->VAR_0, AV_LOG_DEBUG, "STREAM HEADER\n");
do {
VAR_5 = get_bits(&s->gb, 1);
VAR_6 = get_bits(&s->gb, 7);
VAR_7 = get_bits_long(&s->gb, 24);
av_log(s->VAR_0, AV_LOG_DEBUG, " metadata block: flag = %d, type = %d, size = %d\n",
VAR_5, VAR_6,
VAR_7);
if(VAR_7){
switch(VAR_6)
{
case METADATA_TYPE_STREAMINFO:{
int VAR_12= get_bits_count(&s->gb);
metadata_streaminfo(s);
VAR_3= &s->bitstream[s->bitstream_index];
init_get_bits(&s->gb, VAR_3, VAR_4*8);
skip_bits(&s->gb, VAR_12);
dump_headers(s);
break;}
default:
for(VAR_9=0; VAR_9<VAR_7; VAR_9++)
skip_bits(&s->gb, 8);
}
}
} while(!VAR_5);
}
else
{
VAR_8 = show_bits(&s->gb, 16);
if(VAR_8 != 0xFFF8){
av_log(s->VAR_0, AV_LOG_ERROR, "FRAME HEADER not here\n");
while(get_bits_count(&s->gb)/8+2 < VAR_4 && show_bits(&s->gb, 16) != 0xFFF8)
skip_bits(&s->gb, 8);
goto end;
}
skip_bits(&s->gb, 16);
if (decode_frame(s) < 0){
av_log(s->VAR_0, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
}
#if 0
if (s->order == MID_SIDE)
{
short *left = samples;
short *right = samples + s->blocksize;
for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9 += 2)
{
uint32_t x = s->decoded[0][VAR_9];
uint32_t y = s->decoded[0][VAR_9+1];
right[VAR_9] = x - (y / 2);
left[VAR_9] = right[VAR_9] + y;
}
*VAR_2 = 2 * s->blocksize;
}
else
{
for (VAR_9 = 0; VAR_9 < s->channels; VAR_9++)
{
switch(s->order)
{
case INDEPENDENT:
for (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)
samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[VAR_9][VAR_10];
break;
case LEFT_SIDE:
case RIGHT_SIDE:
if (VAR_9 == 0)
for (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)
samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[0][VAR_10];
else
for (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)
samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[0][VAR_10] - s->decoded[VAR_9][VAR_10];
break;
}
*VAR_2 += s->blocksize;
}
}
#else
switch(s->decorrelation)
{
case INDEPENDENT:
for (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)
{
for (VAR_9 = 0; VAR_9 < s->channels; VAR_9++)
*(samples++) = s->decoded[VAR_9][VAR_10];
}
break;
case LEFT_SIDE:
assert(s->channels == 2);
for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)
{
*(samples++) = s->decoded[0][VAR_9];
*(samples++) = s->decoded[0][VAR_9] - s->decoded[1][VAR_9];
}
break;
case RIGHT_SIDE:
assert(s->channels == 2);
for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)
{
*(samples++) = s->decoded[0][VAR_9] + s->decoded[1][VAR_9];
*(samples++) = s->decoded[1][VAR_9];
}
break;
case MID_SIDE:
assert(s->channels == 2);
for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)
{
int mid, side;
mid = s->decoded[0][VAR_9];
side = s->decoded[1][VAR_9];
#if 1
mid -= side>>1;
*(samples++) = mid + side;
*(samples++) = mid;
#else
mid <<= 1;
if (side & 1)
mid++;
*(samples++) = (mid + side) >> 1;
*(samples++) = (mid - side) >> 1;
#endif
}
break;
}
#endif
*VAR_2 = (int8_t *)samples - (int8_t *)VAR_1;
end:
VAR_9= (get_bits_count(&s->gb)+7)/8;;
if(VAR_9 > VAR_4){
av_log(s->VAR_0, AV_LOG_ERROR, "overread: %d\n", VAR_9 - VAR_4);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if(s->bitstream_size){
s->bitstream_index += VAR_9;
s->bitstream_size -= VAR_9;
return VAR_11;
}else
return VAR_9;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"FLACContext *s = VAR_0->priv_data;",
"int VAR_5, VAR_6, VAR_7;",
"int VAR_8 = 0, VAR_9, VAR_10 = 0, VAR_11 = 0;",
"int16_t *samples = VAR_1;",
"if(s->max_framesize == 0){",
"s->max_framesize= 8192;",
"s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);",
"}",
"if(1 && s->max_framesize){",
"VAR_4= FFMIN(VAR_4, s->max_framesize - s->bitstream_size);",
"VAR_11= VAR_4;",
"if(s->bitstream_index + s->bitstream_size + VAR_4 > s->allocated_bitstream_size){",
"memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);",
"s->bitstream_index=0;",
"}",
"memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], VAR_3, VAR_4);",
"VAR_3= &s->bitstream[s->bitstream_index];",
"VAR_4 += s->bitstream_size;",
"s->bitstream_size= VAR_4;",
"if(VAR_4 < s->max_framesize){",
"return VAR_11;",
"}",
"}",
"init_get_bits(&s->gb, VAR_3, VAR_4*8);",
"if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc(\"fLaC\")))\n{",
"skip_bits(&s->gb, 32);",
"av_log(s->VAR_0, AV_LOG_DEBUG, \"STREAM HEADER\\n\");",
"do {",
"VAR_5 = get_bits(&s->gb, 1);",
"VAR_6 = get_bits(&s->gb, 7);",
"VAR_7 = get_bits_long(&s->gb, 24);",
"av_log(s->VAR_0, AV_LOG_DEBUG, \" metadata block: flag = %d, type = %d, size = %d\\n\",\nVAR_5, VAR_6,\nVAR_7);",
"if(VAR_7){",
"switch(VAR_6)\n{",
"case METADATA_TYPE_STREAMINFO:{",
"int VAR_12= get_bits_count(&s->gb);",
"metadata_streaminfo(s);",
"VAR_3= &s->bitstream[s->bitstream_index];",
"init_get_bits(&s->gb, VAR_3, VAR_4*8);",
"skip_bits(&s->gb, VAR_12);",
"dump_headers(s);",
"break;}",
"default:\nfor(VAR_9=0; VAR_9<VAR_7; VAR_9++)",
"skip_bits(&s->gb, 8);",
"}",
"}",
"} while(!VAR_5);",
"}",
"else\n{",
"VAR_8 = show_bits(&s->gb, 16);",
"if(VAR_8 != 0xFFF8){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"FRAME HEADER not here\\n\");",
"while(get_bits_count(&s->gb)/8+2 < VAR_4 && show_bits(&s->gb, 16) != 0xFFF8)\nskip_bits(&s->gb, 8);",
"goto end;",
"}",
"skip_bits(&s->gb, 16);",
"if (decode_frame(s) < 0){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"decode_frame() failed\\n\");",
"s->bitstream_size=0;",
"s->bitstream_index=0;",
"return -1;",
"}",
"}",
"#if 0\nif (s->order == MID_SIDE)\n{",
"short *left = samples;",
"short *right = samples + s->blocksize;",
"for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9 += 2)",
"{",
"uint32_t x = s->decoded[0][VAR_9];",
"uint32_t y = s->decoded[0][VAR_9+1];",
"right[VAR_9] = x - (y / 2);",
"left[VAR_9] = right[VAR_9] + y;",
"}",
"*VAR_2 = 2 * s->blocksize;",
"}",
"else\n{",
"for (VAR_9 = 0; VAR_9 < s->channels; VAR_9++)",
"{",
"switch(s->order)\n{",
"case INDEPENDENT:\nfor (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)",
"samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[VAR_9][VAR_10];",
"break;",
"case LEFT_SIDE:\ncase RIGHT_SIDE:\nif (VAR_9 == 0)\nfor (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)",
"samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[0][VAR_10];",
"else\nfor (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)",
"samples[(s->blocksize*VAR_9)+VAR_10] = s->decoded[0][VAR_10] - s->decoded[VAR_9][VAR_10];",
"break;",
"}",
"*VAR_2 += s->blocksize;",
"}",
"}",
"#else\nswitch(s->decorrelation)\n{",
"case INDEPENDENT:\nfor (VAR_10 = 0; VAR_10 < s->blocksize; VAR_10++)",
"{",
"for (VAR_9 = 0; VAR_9 < s->channels; VAR_9++)",
"*(samples++) = s->decoded[VAR_9][VAR_10];",
"}",
"break;",
"case LEFT_SIDE:\nassert(s->channels == 2);",
"for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)",
"{",
"*(samples++) = s->decoded[0][VAR_9];",
"*(samples++) = s->decoded[0][VAR_9] - s->decoded[1][VAR_9];",
"}",
"break;",
"case RIGHT_SIDE:\nassert(s->channels == 2);",
"for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)",
"{",
"*(samples++) = s->decoded[0][VAR_9] + s->decoded[1][VAR_9];",
"*(samples++) = s->decoded[1][VAR_9];",
"}",
"break;",
"case MID_SIDE:\nassert(s->channels == 2);",
"for (VAR_9 = 0; VAR_9 < s->blocksize; VAR_9++)",
"{",
"int mid, side;",
"mid = s->decoded[0][VAR_9];",
"side = s->decoded[1][VAR_9];",
"#if 1\nmid -= side>>1;",
"*(samples++) = mid + side;",
"*(samples++) = mid;",
"#else\nmid <<= 1;",
"if (side & 1)\nmid++;",
"*(samples++) = (mid + side) >> 1;",
"*(samples++) = (mid - side) >> 1;",
"#endif\n}",
"break;",
"}",
"#endif\n*VAR_2 = (int8_t *)samples - (int8_t *)VAR_1;",
"end:\nVAR_9= (get_bits_count(&s->gb)+7)/8;;",
"if(VAR_9 > VAR_4){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"overread: %d\\n\", VAR_9 - VAR_4);",
"s->bitstream_size=0;",
"s->bitstream_index=0;",
"return -1;",
"}",
"if(s->bitstream_size){",
"s->bitstream_index += VAR_9;",
"s->bitstream_size -= VAR_9;",
"return VAR_11;",
"}else",
"return VAR_9;",
"}"
] | [
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
75,
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181,
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225,
227
],
[
229
],
[
231
],
[
233,
235,
237,
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265,
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
331,
333
],
[
335
],
[
337
],
[
339,
343
],
[
345,
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
361,
365
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
]
] |
24,804 | static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
mfxExtBuffer **coding_opts)
{
mfxInfoMFX *info = &q->param.mfx;
mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[0];
#if QSV_HAVE_CO2
mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
#endif
#if QSV_HAVE_CO3
mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
#endif
av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
print_profile(info->CodecProfile), info->CodecLevel);
av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ",
info->GopPicSize, info->GopRefDist);
if (info->GopOptFlag & MFX_GOP_CLOSED)
av_log(avctx, AV_LOG_VERBOSE, "closed ");
if (info->GopOptFlag & MFX_GOP_STRICT)
av_log(avctx, AV_LOG_VERBOSE, "strict ");
av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval);
av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n",
info->TargetUsage, print_ratecontrol(info->RateControlMethod));
if (info->RateControlMethod == MFX_RATECONTROL_CBR ||
info->RateControlMethod == MFX_RATECONTROL_VBR
#if QSV_HAVE_VCM
|| info->RateControlMethod == MFX_RATECONTROL_VCM
#endif
) {
av_log(avctx, AV_LOG_VERBOSE,
"InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n",
info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);
} else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
} else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
av_log(avctx, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: %"PRIu16"\n",
info->TargetKbps, info->Accuracy, info->Convergence);
}
#if QSV_HAVE_LA
else if (info->RateControlMethod == MFX_RATECONTROL_LA
#if QSV_HAVE_LA_HRD
|| info->RateControlMethod == MFX_RATECONTROL_LA_HRD
#endif
) {
av_log(avctx, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->TargetKbps, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_ICQ
else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) {
av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality);
} else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {
av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->ICQQuality, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_QVBR
else if (info->RateControlMethod == MFX_RATECONTROL_QVBR) {
av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n",
co3->QVBRQuality);
}
#endif
av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n",
info->NumSlice, info->NumRefFrame);
av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n",
print_threestate(co->RateDistortionOpt));
#if QSV_HAVE_CO2
av_log(avctx, AV_LOG_VERBOSE,
"RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %"PRIu16"; ", co2->MaxFrameSize);
#if QSV_VERSION_ATLEAST(1, 9)
av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %"PRIu16"; ", co2->MaxSliceSize);
#endif
av_log(avctx, AV_LOG_VERBOSE, "\n");
av_log(avctx, AV_LOG_VERBOSE,
"BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC),
print_threestate(co2->ExtBRC));
#if QSV_HAVE_TRELLIS
av_log(avctx, AV_LOG_VERBOSE, "Trellis: ");
if (co2->Trellis & MFX_TRELLIS_OFF) {
av_log(avctx, AV_LOG_VERBOSE, "off");
} else if (!co2->Trellis) {
av_log(avctx, AV_LOG_VERBOSE, "auto");
} else {
if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I");
if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P");
if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B");
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 8)
av_log(avctx, AV_LOG_VERBOSE,
"RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ",
print_threestate(co2->RepeatPPS), co2->NumMbPerSlice);
switch (co2->LookAheadDS) {
case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break;
case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break;
case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break;
default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break;
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ",
print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB));
switch (co2->BRefType) {
case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break;
case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break;
default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break;
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 9)
av_log(avctx, AV_LOG_VERBOSE,
"MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n",
co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
#endif
#endif
if (avctx->codec_id == AV_CODEC_ID_H264) {
av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n",
co->CAVLC == MFX_CODINGOPTION_ON ? "CAVLC" : "CABAC", co->MaxDecFrameBuffering);
av_log(avctx, AV_LOG_VERBOSE,
"NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
print_threestate(co->NalHrdConformance), print_threestate(co->SingleSeiNalUnit),
print_threestate(co->VuiVclHrdParameters), print_threestate(co->VuiNalHrdParameters));
}
}
| false | FFmpeg | fc4c27c4edfc6a5f9bc7c696e823652474a65ce8 | static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
mfxExtBuffer **coding_opts)
{
mfxInfoMFX *info = &q->param.mfx;
mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[0];
#if QSV_HAVE_CO2
mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
#endif
#if QSV_HAVE_CO3
mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
#endif
av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
print_profile(info->CodecProfile), info->CodecLevel);
av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ",
info->GopPicSize, info->GopRefDist);
if (info->GopOptFlag & MFX_GOP_CLOSED)
av_log(avctx, AV_LOG_VERBOSE, "closed ");
if (info->GopOptFlag & MFX_GOP_STRICT)
av_log(avctx, AV_LOG_VERBOSE, "strict ");
av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval);
av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n",
info->TargetUsage, print_ratecontrol(info->RateControlMethod));
if (info->RateControlMethod == MFX_RATECONTROL_CBR ||
info->RateControlMethod == MFX_RATECONTROL_VBR
#if QSV_HAVE_VCM
|| info->RateControlMethod == MFX_RATECONTROL_VCM
#endif
) {
av_log(avctx, AV_LOG_VERBOSE,
"InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n",
info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);
} else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
} else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
av_log(avctx, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: %"PRIu16"\n",
info->TargetKbps, info->Accuracy, info->Convergence);
}
#if QSV_HAVE_LA
else if (info->RateControlMethod == MFX_RATECONTROL_LA
#if QSV_HAVE_LA_HRD
|| info->RateControlMethod == MFX_RATECONTROL_LA_HRD
#endif
) {
av_log(avctx, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->TargetKbps, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_ICQ
else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) {
av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality);
} else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {
av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->ICQQuality, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_QVBR
else if (info->RateControlMethod == MFX_RATECONTROL_QVBR) {
av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n",
co3->QVBRQuality);
}
#endif
av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n",
info->NumSlice, info->NumRefFrame);
av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n",
print_threestate(co->RateDistortionOpt));
#if QSV_HAVE_CO2
av_log(avctx, AV_LOG_VERBOSE,
"RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %"PRIu16"; ", co2->MaxFrameSize);
#if QSV_VERSION_ATLEAST(1, 9)
av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %"PRIu16"; ", co2->MaxSliceSize);
#endif
av_log(avctx, AV_LOG_VERBOSE, "\n");
av_log(avctx, AV_LOG_VERBOSE,
"BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC),
print_threestate(co2->ExtBRC));
#if QSV_HAVE_TRELLIS
av_log(avctx, AV_LOG_VERBOSE, "Trellis: ");
if (co2->Trellis & MFX_TRELLIS_OFF) {
av_log(avctx, AV_LOG_VERBOSE, "off");
} else if (!co2->Trellis) {
av_log(avctx, AV_LOG_VERBOSE, "auto");
} else {
if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I");
if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P");
if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B");
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 8)
av_log(avctx, AV_LOG_VERBOSE,
"RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ",
print_threestate(co2->RepeatPPS), co2->NumMbPerSlice);
switch (co2->LookAheadDS) {
case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break;
case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break;
case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break;
default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break;
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ",
print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB));
switch (co2->BRefType) {
case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break;
case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break;
default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break;
}
av_log(avctx, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 9)
av_log(avctx, AV_LOG_VERBOSE,
"MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n",
co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
#endif
#endif
if (avctx->codec_id == AV_CODEC_ID_H264) {
av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n",
co->CAVLC == MFX_CODINGOPTION_ON ? "CAVLC" : "CABAC", co->MaxDecFrameBuffering);
av_log(avctx, AV_LOG_VERBOSE,
"NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
print_threestate(co->NalHrdConformance), print_threestate(co->SingleSeiNalUnit),
print_threestate(co->VuiVclHrdParameters), print_threestate(co->VuiNalHrdParameters));
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1,
mfxExtBuffer **VAR_2)
{
mfxInfoMFX *info = &VAR_1->param.mfx;
mfxExtCodingOption *co = (mfxExtCodingOption*)VAR_2[0];
#if QSV_HAVE_CO2
mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)VAR_2[1];
#endif
#if QSV_HAVE_CO3
mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)VAR_2[2];
#endif
av_log(VAR_0, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
print_profile(info->CodecProfile), info->CodecLevel);
av_log(VAR_0, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ",
info->GopPicSize, info->GopRefDist);
if (info->GopOptFlag & MFX_GOP_CLOSED)
av_log(VAR_0, AV_LOG_VERBOSE, "closed ");
if (info->GopOptFlag & MFX_GOP_STRICT)
av_log(VAR_0, AV_LOG_VERBOSE, "strict ");
av_log(VAR_0, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval);
av_log(VAR_0, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n",
info->TargetUsage, print_ratecontrol(info->RateControlMethod));
if (info->RateControlMethod == MFX_RATECONTROL_CBR ||
info->RateControlMethod == MFX_RATECONTROL_VBR
#if QSV_HAVE_VCM
|| info->RateControlMethod == MFX_RATECONTROL_VCM
#endif
) {
av_log(VAR_0, AV_LOG_VERBOSE,
"InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n",
info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);
} else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
av_log(VAR_0, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
} else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
av_log(VAR_0, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: %"PRIu16"\n",
info->TargetKbps, info->Accuracy, info->Convergence);
}
#if QSV_HAVE_LA
else if (info->RateControlMethod == MFX_RATECONTROL_LA
#if QSV_HAVE_LA_HRD
|| info->RateControlMethod == MFX_RATECONTROL_LA_HRD
#endif
) {
av_log(VAR_0, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->TargetKbps, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_ICQ
else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) {
av_log(VAR_0, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality);
} else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {
av_log(VAR_0, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
info->ICQQuality, co2->LookAheadDepth);
}
#endif
#if QSV_HAVE_QVBR
else if (info->RateControlMethod == MFX_RATECONTROL_QVBR) {
av_log(VAR_0, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n",
co3->QVBRQuality);
}
#endif
av_log(VAR_0, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n",
info->NumSlice, info->NumRefFrame);
av_log(VAR_0, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n",
print_threestate(co->RateDistortionOpt));
#if QSV_HAVE_CO2
av_log(VAR_0, AV_LOG_VERBOSE,
"RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
av_log(VAR_0, AV_LOG_VERBOSE, "MaxFrameSize: %"PRIu16"; ", co2->MaxFrameSize);
#if QSV_VERSION_ATLEAST(1, 9)
av_log(VAR_0, AV_LOG_VERBOSE, "MaxSliceSize: %"PRIu16"; ", co2->MaxSliceSize);
#endif
av_log(VAR_0, AV_LOG_VERBOSE, "\n");
av_log(VAR_0, AV_LOG_VERBOSE,
"BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC),
print_threestate(co2->ExtBRC));
#if QSV_HAVE_TRELLIS
av_log(VAR_0, AV_LOG_VERBOSE, "Trellis: ");
if (co2->Trellis & MFX_TRELLIS_OFF) {
av_log(VAR_0, AV_LOG_VERBOSE, "off");
} else if (!co2->Trellis) {
av_log(VAR_0, AV_LOG_VERBOSE, "auto");
} else {
if (co2->Trellis & MFX_TRELLIS_I) av_log(VAR_0, AV_LOG_VERBOSE, "I");
if (co2->Trellis & MFX_TRELLIS_P) av_log(VAR_0, AV_LOG_VERBOSE, "P");
if (co2->Trellis & MFX_TRELLIS_B) av_log(VAR_0, AV_LOG_VERBOSE, "B");
}
av_log(VAR_0, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 8)
av_log(VAR_0, AV_LOG_VERBOSE,
"RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ",
print_threestate(co2->RepeatPPS), co2->NumMbPerSlice);
switch (co2->LookAheadDS) {
case MFX_LOOKAHEAD_DS_OFF: av_log(VAR_0, AV_LOG_VERBOSE, "off"); break;
case MFX_LOOKAHEAD_DS_2x: av_log(VAR_0, AV_LOG_VERBOSE, "2x"); break;
case MFX_LOOKAHEAD_DS_4x: av_log(VAR_0, AV_LOG_VERBOSE, "4x"); break;
default: av_log(VAR_0, AV_LOG_VERBOSE, "unknown"); break;
}
av_log(VAR_0, AV_LOG_VERBOSE, "\n");
av_log(VAR_0, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ",
print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB));
switch (co2->BRefType) {
case MFX_B_REF_OFF: av_log(VAR_0, AV_LOG_VERBOSE, "off"); break;
case MFX_B_REF_PYRAMID: av_log(VAR_0, AV_LOG_VERBOSE, "pyramid"); break;
default: av_log(VAR_0, AV_LOG_VERBOSE, "auto"); break;
}
av_log(VAR_0, AV_LOG_VERBOSE, "\n");
#endif
#if QSV_VERSION_ATLEAST(1, 9)
av_log(VAR_0, AV_LOG_VERBOSE,
"MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n",
co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
#endif
#endif
if (VAR_0->codec_id == AV_CODEC_ID_H264) {
av_log(VAR_0, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n",
co->CAVLC == MFX_CODINGOPTION_ON ? "CAVLC" : "CABAC", co->MaxDecFrameBuffering);
av_log(VAR_0, AV_LOG_VERBOSE,
"NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
print_threestate(co->NalHrdConformance), print_threestate(co->SingleSeiNalUnit),
print_threestate(co->VuiVclHrdParameters), print_threestate(co->VuiNalHrdParameters));
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1,\nmfxExtBuffer **VAR_2)\n{",
"mfxInfoMFX *info = &VAR_1->param.mfx;",
"mfxExtCodingOption *co = (mfxExtCodingOption*)VAR_2[0];",
"#if QSV_HAVE_CO2\nmfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)VAR_2[1];",
"#endif\n#if QSV_HAVE_CO3\nmfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)VAR_2[2];",
"#endif\nav_log(VAR_0, AV_LOG_VERBOSE, \"profile: %s; level: %\"PRIu16\"\\n\",",
"print_profile(info->CodecProfile), info->CodecLevel);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"GopPicSize: %\"PRIu16\"; GopRefDist: %\"PRIu16\"; GopOptFlag: \",",
"info->GopPicSize, info->GopRefDist);",
"if (info->GopOptFlag & MFX_GOP_CLOSED)\nav_log(VAR_0, AV_LOG_VERBOSE, \"closed \");",
"if (info->GopOptFlag & MFX_GOP_STRICT)\nav_log(VAR_0, AV_LOG_VERBOSE, \"strict \");",
"av_log(VAR_0, AV_LOG_VERBOSE, \"; IdrInterval: %\"PRIu16\"\\n\", info->IdrInterval);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"TargetUsage: %\"PRIu16\"; RateControlMethod: %s\\n\",",
"info->TargetUsage, print_ratecontrol(info->RateControlMethod));",
"if (info->RateControlMethod == MFX_RATECONTROL_CBR ||\ninfo->RateControlMethod == MFX_RATECONTROL_VBR\n#if QSV_HAVE_VCM\n|| info->RateControlMethod == MFX_RATECONTROL_VCM\n#endif\n) {",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"InitialDelayInKB: %\"PRIu16\"; TargetKbps: %\"PRIu16\"; MaxKbps: %\"PRIu16\"\\n\",",
"info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);",
"} else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"QPI: %\"PRIu16\"; QPP: %\"PRIu16\"; QPB: %\"PRIu16\"\\n\",",
"info->QPI, info->QPP, info->QPB);",
"} else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"TargetKbps: %\"PRIu16\"; Accuracy: %\"PRIu16\"; Convergence: %\"PRIu16\"\\n\",",
"info->TargetKbps, info->Accuracy, info->Convergence);",
"}",
"#if QSV_HAVE_LA\nelse if (info->RateControlMethod == MFX_RATECONTROL_LA\n#if QSV_HAVE_LA_HRD\n|| info->RateControlMethod == MFX_RATECONTROL_LA_HRD\n#endif\n) {",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"TargetKbps: %\"PRIu16\"; LookAheadDepth: %\"PRIu16\"\\n\",",
"info->TargetKbps, co2->LookAheadDepth);",
"}",
"#endif\n#if QSV_HAVE_ICQ\nelse if (info->RateControlMethod == MFX_RATECONTROL_ICQ) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"ICQQuality: %\"PRIu16\"\\n\", info->ICQQuality);",
"} else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"ICQQuality: %\"PRIu16\"; LookAheadDepth: %\"PRIu16\"\\n\",",
"info->ICQQuality, co2->LookAheadDepth);",
"}",
"#endif\n#if QSV_HAVE_QVBR\nelse if (info->RateControlMethod == MFX_RATECONTROL_QVBR) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"QVBRQuality: %\"PRIu16\"\\n\",\nco3->QVBRQuality);",
"}",
"#endif\nav_log(VAR_0, AV_LOG_VERBOSE, \"NumSlice: %\"PRIu16\"; NumRefFrame: %\"PRIu16\"\\n\",",
"info->NumSlice, info->NumRefFrame);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"RateDistortionOpt: %s\\n\",\nprint_threestate(co->RateDistortionOpt));",
"#if QSV_HAVE_CO2\nav_log(VAR_0, AV_LOG_VERBOSE,\n\"RecoveryPointSEI: %s IntRefType: %\"PRIu16\"; IntRefCycleSize: %\"PRIu16\"; IntRefQPDelta: %\"PRId16\"\\n\",",
"print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"MaxFrameSize: %\"PRIu16\"; \", co2->MaxFrameSize);",
"#if QSV_VERSION_ATLEAST(1, 9)\nav_log(VAR_0, AV_LOG_VERBOSE, \"MaxSliceSize: %\"PRIu16\"; \", co2->MaxSliceSize);",
"#endif\nav_log(VAR_0, AV_LOG_VERBOSE, \"\\n\");",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\\n\",",
"print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC),\nprint_threestate(co2->ExtBRC));",
"#if QSV_HAVE_TRELLIS\nav_log(VAR_0, AV_LOG_VERBOSE, \"Trellis: \");",
"if (co2->Trellis & MFX_TRELLIS_OFF) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"off\");",
"} else if (!co2->Trellis) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"auto\");",
"} else {",
"if (co2->Trellis & MFX_TRELLIS_I) av_log(VAR_0, AV_LOG_VERBOSE, \"I\");",
"if (co2->Trellis & MFX_TRELLIS_P) av_log(VAR_0, AV_LOG_VERBOSE, \"P\");",
"if (co2->Trellis & MFX_TRELLIS_B) av_log(VAR_0, AV_LOG_VERBOSE, \"B\");",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"\\n\");",
"#endif\n#if QSV_VERSION_ATLEAST(1, 8)\nav_log(VAR_0, AV_LOG_VERBOSE,\n\"RepeatPPS: %s; NumMbPerSlice: %\"PRIu16\"; LookAheadDS: \",",
"print_threestate(co2->RepeatPPS), co2->NumMbPerSlice);",
"switch (co2->LookAheadDS) {",
"case MFX_LOOKAHEAD_DS_OFF: av_log(VAR_0, AV_LOG_VERBOSE, \"off\"); break;",
"case MFX_LOOKAHEAD_DS_2x: av_log(VAR_0, AV_LOG_VERBOSE, \"2x\"); break;",
"case MFX_LOOKAHEAD_DS_4x: av_log(VAR_0, AV_LOG_VERBOSE, \"4x\"); break;",
"default: av_log(VAR_0, AV_LOG_VERBOSE, \"unknown\"); break;",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"\\n\");",
"av_log(VAR_0, AV_LOG_VERBOSE, \"AdaptiveI: %s; AdaptiveB: %s; BRefType: \",",
"print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB));",
"switch (co2->BRefType) {",
"case MFX_B_REF_OFF: av_log(VAR_0, AV_LOG_VERBOSE, \"off\"); break;",
"case MFX_B_REF_PYRAMID: av_log(VAR_0, AV_LOG_VERBOSE, \"pyramid\"); break;",
"default: av_log(VAR_0, AV_LOG_VERBOSE, \"auto\"); break;",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"\\n\");",
"#endif\n#if QSV_VERSION_ATLEAST(1, 9)\nav_log(VAR_0, AV_LOG_VERBOSE,\n\"MinQPI: %\"PRIu8\"; MaxQPI: %\"PRIu8\"; MinQPP: %\"PRIu8\"; MaxQPP: %\"PRIu8\"; MinQPB: %\"PRIu8\"; MaxQPB: %\"PRIu8\"\\n\",",
"co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);",
"#endif\n#endif\nif (VAR_0->codec_id == AV_CODEC_ID_H264) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Entropy coding: %s; MaxDecFrameBuffering: %\"PRIu16\"\\n\",",
"co->CAVLC == MFX_CODINGOPTION_ON ? \"CAVLC\" : \"CABAC\", co->MaxDecFrameBuffering);",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\\n\",",
"print_threestate(co->NalHrdConformance), print_threestate(co->SingleSeiNalUnit),\nprint_threestate(co->VuiVclHrdParameters), print_threestate(co->VuiNalHrdParameters));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19,
21
],
[
23,
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
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,
141
],
[
143
],
[
145,
147
],
[
151,
153,
155
],
[
157
],
[
161
],
[
163,
165
],
[
167,
169
],
[
173,
175
],
[
177,
179
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207,
211,
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
255,
257,
259
],
[
261
],
[
263,
265,
269
],
[
271
],
[
273
],
[
275,
277
],
[
279,
281
],
[
283
],
[
285
]
] |
24,805 | static void *alloc_buffer(FFVAContext *vactx, int type, unsigned int size, uint32_t *buf_id)
{
void *data = NULL;
*buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS)
vaMapBuffer(vactx->display, *buf_id, &data);
return data;
}
| false | FFmpeg | 8813d55fa5978660d9f4e7dbe1f50da9922be08d | static void *alloc_buffer(FFVAContext *vactx, int type, unsigned int size, uint32_t *buf_id)
{
void *data = NULL;
*buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS)
vaMapBuffer(vactx->display, *buf_id, &data);
return data;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(FFVAContext *VAR_0, int VAR_1, unsigned int VAR_2, uint32_t *VAR_3)
{
void *VAR_4 = NULL;
*VAR_3 = 0;
if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,
VAR_1, VAR_2, 1, NULL, VAR_3) == VA_STATUS_SUCCESS)
vaMapBuffer(VAR_0->display, *VAR_3, &VAR_4);
return VAR_4;
}
| [
"static void *FUNC_0(FFVAContext *VAR_0, int VAR_1, unsigned int VAR_2, uint32_t *VAR_3)\n{",
"void *VAR_4 = NULL;",
"*VAR_3 = 0;",
"if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,\nVAR_1, VAR_2, 1, NULL, VAR_3) == VA_STATUS_SUCCESS)\nvaMapBuffer(VAR_0->display, *VAR_3, &VAR_4);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13,
15
],
[
19
],
[
21
]
] |
24,807 | void ff_http_auth_handle_header(HTTPAuthState *state, const char *key,
const char *value)
{
if (!strcmp(key, "WWW-Authenticate") || !strcmp(key, "Proxy-Authenticate")) {
const char *p;
if (av_stristart(value, "Basic ", &p) &&
state->auth_type <= HTTP_AUTH_BASIC) {
state->auth_type = HTTP_AUTH_BASIC;
state->realm[0] = 0;
state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_basic_params,
state);
} else if (av_stristart(value, "Digest ", &p) &&
state->auth_type <= HTTP_AUTH_DIGEST) {
state->auth_type = HTTP_AUTH_DIGEST;
memset(&state->digest_params, 0, sizeof(DigestParams));
state->realm[0] = 0;
state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_digest_params,
state);
choose_qop(state->digest_params.qop,
sizeof(state->digest_params.qop));
if (!av_strcasecmp(state->digest_params.stale, "true"))
state->stale = 1;
}
} else if (!strcmp(key, "Authentication-Info")) {
ff_parse_key_value(value, (ff_parse_key_val_cb) handle_digest_update,
state);
}
}
| false | FFmpeg | 8f0bd1d9bad5b8aa42b5b4cec103cc4afed5eab6 | void ff_http_auth_handle_header(HTTPAuthState *state, const char *key,
const char *value)
{
if (!strcmp(key, "WWW-Authenticate") || !strcmp(key, "Proxy-Authenticate")) {
const char *p;
if (av_stristart(value, "Basic ", &p) &&
state->auth_type <= HTTP_AUTH_BASIC) {
state->auth_type = HTTP_AUTH_BASIC;
state->realm[0] = 0;
state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_basic_params,
state);
} else if (av_stristart(value, "Digest ", &p) &&
state->auth_type <= HTTP_AUTH_DIGEST) {
state->auth_type = HTTP_AUTH_DIGEST;
memset(&state->digest_params, 0, sizeof(DigestParams));
state->realm[0] = 0;
state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_digest_params,
state);
choose_qop(state->digest_params.qop,
sizeof(state->digest_params.qop));
if (!av_strcasecmp(state->digest_params.stale, "true"))
state->stale = 1;
}
} else if (!strcmp(key, "Authentication-Info")) {
ff_parse_key_value(value, (ff_parse_key_val_cb) handle_digest_update,
state);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(HTTPAuthState *VAR_0, const char *VAR_1,
const char *VAR_2)
{
if (!strcmp(VAR_1, "WWW-Authenticate") || !strcmp(VAR_1, "Proxy-Authenticate")) {
const char *VAR_3;
if (av_stristart(VAR_2, "Basic ", &VAR_3) &&
VAR_0->auth_type <= HTTP_AUTH_BASIC) {
VAR_0->auth_type = HTTP_AUTH_BASIC;
VAR_0->realm[0] = 0;
VAR_0->stale = 0;
ff_parse_key_value(VAR_3, (ff_parse_key_val_cb) handle_basic_params,
VAR_0);
} else if (av_stristart(VAR_2, "Digest ", &VAR_3) &&
VAR_0->auth_type <= HTTP_AUTH_DIGEST) {
VAR_0->auth_type = HTTP_AUTH_DIGEST;
memset(&VAR_0->digest_params, 0, sizeof(DigestParams));
VAR_0->realm[0] = 0;
VAR_0->stale = 0;
ff_parse_key_value(VAR_3, (ff_parse_key_val_cb) handle_digest_params,
VAR_0);
choose_qop(VAR_0->digest_params.qop,
sizeof(VAR_0->digest_params.qop));
if (!av_strcasecmp(VAR_0->digest_params.stale, "true"))
VAR_0->stale = 1;
}
} else if (!strcmp(VAR_1, "Authentication-Info")) {
ff_parse_key_value(VAR_2, (ff_parse_key_val_cb) handle_digest_update,
VAR_0);
}
}
| [
"void FUNC_0(HTTPAuthState *VAR_0, const char *VAR_1,\nconst char *VAR_2)\n{",
"if (!strcmp(VAR_1, \"WWW-Authenticate\") || !strcmp(VAR_1, \"Proxy-Authenticate\")) {",
"const char *VAR_3;",
"if (av_stristart(VAR_2, \"Basic \", &VAR_3) &&\nVAR_0->auth_type <= HTTP_AUTH_BASIC) {",
"VAR_0->auth_type = HTTP_AUTH_BASIC;",
"VAR_0->realm[0] = 0;",
"VAR_0->stale = 0;",
"ff_parse_key_value(VAR_3, (ff_parse_key_val_cb) handle_basic_params,\nVAR_0);",
"} else if (av_stristart(VAR_2, \"Digest \", &VAR_3) &&",
"VAR_0->auth_type <= HTTP_AUTH_DIGEST) {",
"VAR_0->auth_type = HTTP_AUTH_DIGEST;",
"memset(&VAR_0->digest_params, 0, sizeof(DigestParams));",
"VAR_0->realm[0] = 0;",
"VAR_0->stale = 0;",
"ff_parse_key_value(VAR_3, (ff_parse_key_val_cb) handle_digest_params,\nVAR_0);",
"choose_qop(VAR_0->digest_params.qop,\nsizeof(VAR_0->digest_params.qop));",
"if (!av_strcasecmp(VAR_0->digest_params.stale, \"true\"))\nVAR_0->stale = 1;",
"}",
"} else if (!strcmp(VAR_1, \"Authentication-Info\")) {",
"ff_parse_key_value(VAR_2, (ff_parse_key_val_cb) handle_digest_update,\nVAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
]
] |
24,808 | void ff_thread_report_progress(ThreadFrame *f, int n, int field)
{
PerThreadContext *p;
atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL;
if (!progress ||
atomic_load_explicit(&progress[field], memory_order_acquire) >= n)
return;
p = f->owner->internal->thread_ctx;
if (f->owner->debug&FF_DEBUG_THREADS)
av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
pthread_mutex_lock(&p->progress_mutex);
atomic_store(&progress[field], n);
pthread_cond_broadcast(&p->progress_cond);
pthread_mutex_unlock(&p->progress_mutex);
}
| false | FFmpeg | 343e2833994655c252d5236a3394bf6db7a4d8b1 | void ff_thread_report_progress(ThreadFrame *f, int n, int field)
{
PerThreadContext *p;
atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL;
if (!progress ||
atomic_load_explicit(&progress[field], memory_order_acquire) >= n)
return;
p = f->owner->internal->thread_ctx;
if (f->owner->debug&FF_DEBUG_THREADS)
av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
pthread_mutex_lock(&p->progress_mutex);
atomic_store(&progress[field], n);
pthread_cond_broadcast(&p->progress_cond);
pthread_mutex_unlock(&p->progress_mutex);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ThreadFrame *VAR_0, int VAR_1, int VAR_2)
{
PerThreadContext *p;
atomic_int *progress = VAR_0->progress ? (atomic_int*)VAR_0->progress->data : NULL;
if (!progress ||
atomic_load_explicit(&progress[VAR_2], memory_order_acquire) >= VAR_1)
return;
p = VAR_0->owner->internal->thread_ctx;
if (VAR_0->owner->debug&FF_DEBUG_THREADS)
av_log(VAR_0->owner, AV_LOG_DEBUG, "%p finished %d VAR_2 %d\VAR_1", progress, VAR_1, VAR_2);
pthread_mutex_lock(&p->progress_mutex);
atomic_store(&progress[VAR_2], VAR_1);
pthread_cond_broadcast(&p->progress_cond);
pthread_mutex_unlock(&p->progress_mutex);
}
| [
"void FUNC_0(ThreadFrame *VAR_0, int VAR_1, int VAR_2)\n{",
"PerThreadContext *p;",
"atomic_int *progress = VAR_0->progress ? (atomic_int*)VAR_0->progress->data : NULL;",
"if (!progress ||\natomic_load_explicit(&progress[VAR_2], memory_order_acquire) >= VAR_1)\nreturn;",
"p = VAR_0->owner->internal->thread_ctx;",
"if (VAR_0->owner->debug&FF_DEBUG_THREADS)\nav_log(VAR_0->owner, AV_LOG_DEBUG, \"%p finished %d VAR_2 %d\\VAR_1\", progress, VAR_1, VAR_2);",
"pthread_mutex_lock(&p->progress_mutex);",
"atomic_store(&progress[VAR_2], VAR_1);",
"pthread_cond_broadcast(&p->progress_cond);",
"pthread_mutex_unlock(&p->progress_mutex);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
19
],
[
23,
25
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
]
] |
24,809 | static void mxf_write_system_item(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
unsigned frame;
uint32_t time_code;
frame = mxf->last_indexed_edit_unit + mxf->edit_units_count;
// write system metadata pack
avio_write(pb, system_metadata_pack_key, 16);
klv_encode_ber4_length(pb, 57);
avio_w8(pb, 0x5c); // UL, user date/time stamp, picture and sound item present
avio_w8(pb, 0x04); // content package rate
avio_w8(pb, 0x00); // content package type
avio_wb16(pb, 0x00); // channel handle
avio_wb16(pb, mxf->tc.start + frame); // continuity count
if (mxf->essence_container_count > 1)
avio_write(pb, multiple_desc_ul, 16);
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
avio_w8(pb, 0);
avio_wb64(pb, 0);
avio_wb64(pb, 0); // creation date/time stamp
avio_w8(pb, 0x81); // SMPTE 12M time code
time_code = av_timecode_get_smpte_from_framenum(&mxf->tc, frame);
avio_wb32(pb, time_code);
avio_wb32(pb, 0); // binary group data
avio_wb64(pb, 0);
// write system metadata package set
avio_write(pb, system_metadata_package_set_key, 16);
klv_encode_ber4_length(pb, 35);
avio_w8(pb, 0x83); // UMID
avio_wb16(pb, 0x20);
mxf_write_umid(s, 1);
}
| true | FFmpeg | 3896cd11a107f241f06b06a336322aef2f372fdd | static void mxf_write_system_item(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
unsigned frame;
uint32_t time_code;
frame = mxf->last_indexed_edit_unit + mxf->edit_units_count;
avio_write(pb, system_metadata_pack_key, 16);
klv_encode_ber4_length(pb, 57);
avio_w8(pb, 0x5c);
avio_w8(pb, 0x04);
avio_w8(pb, 0x00);
avio_wb16(pb, 0x00);
avio_wb16(pb, mxf->tc.start + frame);
if (mxf->essence_container_count > 1)
avio_write(pb, multiple_desc_ul, 16);
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
avio_w8(pb, 0);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_w8(pb, 0x81);
time_code = av_timecode_get_smpte_from_framenum(&mxf->tc, frame);
avio_wb32(pb, time_code);
avio_wb32(pb, 0);
avio_wb64(pb, 0);
age set
avio_write(pb, system_metadata_package_set_key, 16);
klv_encode_ber4_length(pb, 35);
avio_w8(pb, 0x83);
avio_wb16(pb, 0x20);
mxf_write_umid(s, 1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0)
{
MXFContext *mxf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
unsigned VAR_1;
uint32_t time_code;
VAR_1 = mxf->last_indexed_edit_unit + mxf->edit_units_count;
avio_write(pb, system_metadata_pack_key, 16);
klv_encode_ber4_length(pb, 57);
avio_w8(pb, 0x5c);
avio_w8(pb, 0x04);
avio_w8(pb, 0x00);
avio_wb16(pb, 0x00);
avio_wb16(pb, mxf->tc.start + VAR_1);
if (mxf->essence_container_count > 1)
avio_write(pb, multiple_desc_ul, 16);
else {
MXFStreamContext *sc = VAR_0->streams[0]->priv_data;
avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
avio_w8(pb, 0);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_w8(pb, 0x81);
time_code = av_timecode_get_smpte_from_framenum(&mxf->tc, VAR_1);
avio_wb32(pb, time_code);
avio_wb32(pb, 0);
avio_wb64(pb, 0);
age set
avio_write(pb, system_metadata_package_set_key, 16);
klv_encode_ber4_length(pb, 35);
avio_w8(pb, 0x83);
avio_wb16(pb, 0x20);
mxf_write_umid(VAR_0, 1);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"MXFContext *mxf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned VAR_1;",
"uint32_t time_code;",
"VAR_1 = mxf->last_indexed_edit_unit + mxf->edit_units_count;",
"avio_write(pb, system_metadata_pack_key, 16);",
"klv_encode_ber4_length(pb, 57);",
"avio_w8(pb, 0x5c);",
"avio_w8(pb, 0x04);",
"avio_w8(pb, 0x00);",
"avio_wb16(pb, 0x00);",
"avio_wb16(pb, mxf->tc.start + VAR_1);",
"if (mxf->essence_container_count > 1)\navio_write(pb, multiple_desc_ul, 16);",
"else {",
"MXFStreamContext *sc = VAR_0->streams[0]->priv_data;",
"avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);",
"}",
"avio_w8(pb, 0);",
"avio_wb64(pb, 0);",
"avio_wb64(pb, 0);",
"avio_w8(pb, 0x81);",
"time_code = av_timecode_get_smpte_from_framenum(&mxf->tc, VAR_1);",
"avio_wb32(pb, time_code);",
"avio_wb32(pb, 0);",
"avio_wb64(pb, 0);",
"age set\navio_write(pb, system_metadata_package_set_key, 16);",
"klv_encode_ber4_length(pb, 35);",
"avio_w8(pb, 0x83);",
"avio_wb16(pb, 0x20);",
"mxf_write_umid(VAR_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
24,810 | petalogix_ml605_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
MemoryRegion *address_space_mem = get_system_memory();
DeviceState *dev, *dma, *eth0;
Object *ds, *cs;
MicroBlazeCPU *cpu;
SysBusDevice *busdev;
DriveInfo *dinfo;
int i;
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
/* init CPUs */
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
/* Use FPU but don't use floating point conversion and square
* root instructions
*/
object_property_set_int(OBJECT(cpu), 1, "use-fpu", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "dcache-writeback",
&error_abort);
object_property_set_bool(OBJECT(cpu), true, "endianness", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "realized", &error_abort);
/* Attach emulated BRAM through the LMB. */
memory_region_init_ram(phys_lmb_bram, NULL, "petalogix_ml605.lmb_bram",
LMB_BRAM_SIZE, &error_abort);
vmstate_register_ram_global(phys_lmb_bram);
memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram);
memory_region_init_ram(phys_ram, NULL, "petalogix_ml605.ram", ram_size,
&error_abort);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
/* 5th parameter 2 means bank-width
* 10th paremeter 0 means little-endian */
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_ml605.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
(64 * 1024), FLASH_SIZE >> 16,
2, 0x89, 0x18, 0x0000, 0x0, 0);
dev = qdev_create(NULL, "xlnx.xps-intc");
qdev_prop_set_uint32(dev, "kind-of-intr", 1 << TIMER_IRQ);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(dev, i);
}
serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2,
irq[UART16550_IRQ], 115200, serial_hds[0],
DEVICE_LITTLE_ENDIAN);
/* 2 timers at irq 2 @ 100 Mhz. */
dev = qdev_create(NULL, "xlnx.xps-timer");
qdev_prop_set_uint32(dev, "one-timer-only", 0);
qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);
/* axi ethernet and dma initialization. */
qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet");
eth0 = qdev_create(NULL, "xlnx.axi-ethernet");
dma = qdev_create(NULL, "xlnx.axi-dma");
/* FIXME: attach to the sysbus instead */
object_property_add_child(qdev_get_machine(), "xilinx-eth", OBJECT(eth0),
NULL);
object_property_add_child(qdev_get_machine(), "xilinx-dma", OBJECT(dma),
NULL);
ds = object_property_get_link(OBJECT(dma),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(dma),
"axistream-control-connected-target", NULL);
qdev_set_nic_properties(eth0, &nd_table[0]);
qdev_prop_set_uint32(eth0, "rxmem", 0x1000);
qdev_prop_set_uint32(eth0, "txmem", 0x1000);
object_property_set_link(OBJECT(eth0), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(eth0), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(eth0);
sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(eth0), 0, irq[AXIENET_IRQ]);
ds = object_property_get_link(OBJECT(eth0),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(eth0),
"axistream-control-connected-target", NULL);
qdev_prop_set_uint32(dma, "freqhz", 100 * 1000000);
object_property_set_link(OBJECT(dma), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(dma), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(dma);
sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 0, irq[AXIDMA_IRQ0]);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 1, irq[AXIDMA_IRQ1]);
{
SSIBus *spi;
dev = qdev_create(NULL, "xlnx.xps-spi");
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, SPI_BASEADDR);
sysbus_connect_irq(busdev, 0, irq[SPI_IRQ]);
spi = (SSIBus *)qdev_get_child_bus(dev, "spi");
for (i = 0; i < NUM_SPI_FLASHES; i++) {
qemu_irq cs_line;
dev = ssi_create_slave(spi, "n25q128");
cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
sysbus_connect_irq(busdev, i+1, cs_line);
}
}
/* setup PVR to match kernel settings */
cpu->env.pvr.regs[4] = 0xc56b8000;
cpu->env.pvr.regs[5] = 0xc56be000;
cpu->env.pvr.regs[10] = 0x0e000000; /* virtex 6 */
microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size,
machine->initrd_filename,
BINARY_DEVICE_TREE_FILE,
NULL);
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | petalogix_ml605_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
MemoryRegion *address_space_mem = get_system_memory();
DeviceState *dev, *dma, *eth0;
Object *ds, *cs;
MicroBlazeCPU *cpu;
SysBusDevice *busdev;
DriveInfo *dinfo;
int i;
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
object_property_set_int(OBJECT(cpu), 1, "use-fpu", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "dcache-writeback",
&error_abort);
object_property_set_bool(OBJECT(cpu), true, "endianness", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "realized", &error_abort);
memory_region_init_ram(phys_lmb_bram, NULL, "petalogix_ml605.lmb_bram",
LMB_BRAM_SIZE, &error_abort);
vmstate_register_ram_global(phys_lmb_bram);
memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram);
memory_region_init_ram(phys_ram, NULL, "petalogix_ml605.ram", ram_size,
&error_abort);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_ml605.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
(64 * 1024), FLASH_SIZE >> 16,
2, 0x89, 0x18, 0x0000, 0x0, 0);
dev = qdev_create(NULL, "xlnx.xps-intc");
qdev_prop_set_uint32(dev, "kind-of-intr", 1 << TIMER_IRQ);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(dev, i);
}
serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2,
irq[UART16550_IRQ], 115200, serial_hds[0],
DEVICE_LITTLE_ENDIAN);
dev = qdev_create(NULL, "xlnx.xps-timer");
qdev_prop_set_uint32(dev, "one-timer-only", 0);
qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);
qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet");
eth0 = qdev_create(NULL, "xlnx.axi-ethernet");
dma = qdev_create(NULL, "xlnx.axi-dma");
object_property_add_child(qdev_get_machine(), "xilinx-eth", OBJECT(eth0),
NULL);
object_property_add_child(qdev_get_machine(), "xilinx-dma", OBJECT(dma),
NULL);
ds = object_property_get_link(OBJECT(dma),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(dma),
"axistream-control-connected-target", NULL);
qdev_set_nic_properties(eth0, &nd_table[0]);
qdev_prop_set_uint32(eth0, "rxmem", 0x1000);
qdev_prop_set_uint32(eth0, "txmem", 0x1000);
object_property_set_link(OBJECT(eth0), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(eth0), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(eth0);
sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(eth0), 0, irq[AXIENET_IRQ]);
ds = object_property_get_link(OBJECT(eth0),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(eth0),
"axistream-control-connected-target", NULL);
qdev_prop_set_uint32(dma, "freqhz", 100 * 1000000);
object_property_set_link(OBJECT(dma), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(dma), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(dma);
sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 0, irq[AXIDMA_IRQ0]);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 1, irq[AXIDMA_IRQ1]);
{
SSIBus *spi;
dev = qdev_create(NULL, "xlnx.xps-spi");
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, SPI_BASEADDR);
sysbus_connect_irq(busdev, 0, irq[SPI_IRQ]);
spi = (SSIBus *)qdev_get_child_bus(dev, "spi");
for (i = 0; i < NUM_SPI_FLASHES; i++) {
qemu_irq cs_line;
dev = ssi_create_slave(spi, "n25q128");
cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
sysbus_connect_irq(busdev, i+1, cs_line);
}
}
cpu->env.pvr.regs[4] = 0xc56b8000;
cpu->env.pvr.regs[5] = 0xc56be000;
cpu->env.pvr.regs[10] = 0x0e000000;
microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size,
machine->initrd_filename,
BINARY_DEVICE_TREE_FILE,
NULL);
}
| {
"code": [
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" LMB_BRAM_SIZE, &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);"
],
"line_no": [
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
55,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65,
65
]
} | FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
MemoryRegion *address_space_mem = get_system_memory();
DeviceState *dev, *dma, *eth0;
Object *ds, *cs;
MicroBlazeCPU *cpu;
SysBusDevice *busdev;
DriveInfo *dinfo;
int VAR_1;
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
object_property_set_int(OBJECT(cpu), 1, "use-fpu", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "dcache-writeback",
&error_abort);
object_property_set_bool(OBJECT(cpu), true, "endianness", &error_abort);
object_property_set_bool(OBJECT(cpu), true, "realized", &error_abort);
memory_region_init_ram(phys_lmb_bram, NULL, "petalogix_ml605.lmb_bram",
LMB_BRAM_SIZE, &error_abort);
vmstate_register_ram_global(phys_lmb_bram);
memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram);
memory_region_init_ram(phys_ram, NULL, "petalogix_ml605.ram", ram_size,
&error_abort);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_ml605.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
(64 * 1024), FLASH_SIZE >> 16,
2, 0x89, 0x18, 0x0000, 0x0, 0);
dev = qdev_create(NULL, "xlnx.xps-intc");
qdev_prop_set_uint32(dev, "kind-of-intr", 1 << TIMER_IRQ);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));
for (VAR_1 = 0; VAR_1 < 32; VAR_1++) {
irq[VAR_1] = qdev_get_gpio_in(dev, VAR_1);
}
serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2,
irq[UART16550_IRQ], 115200, serial_hds[0],
DEVICE_LITTLE_ENDIAN);
dev = qdev_create(NULL, "xlnx.xps-timer");
qdev_prop_set_uint32(dev, "one-timer-only", 0);
qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);
qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet");
eth0 = qdev_create(NULL, "xlnx.axi-ethernet");
dma = qdev_create(NULL, "xlnx.axi-dma");
object_property_add_child(qdev_get_machine(), "xilinx-eth", OBJECT(eth0),
NULL);
object_property_add_child(qdev_get_machine(), "xilinx-dma", OBJECT(dma),
NULL);
ds = object_property_get_link(OBJECT(dma),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(dma),
"axistream-control-connected-target", NULL);
qdev_set_nic_properties(eth0, &nd_table[0]);
qdev_prop_set_uint32(eth0, "rxmem", 0x1000);
qdev_prop_set_uint32(eth0, "txmem", 0x1000);
object_property_set_link(OBJECT(eth0), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(eth0), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(eth0);
sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(eth0), 0, irq[AXIENET_IRQ]);
ds = object_property_get_link(OBJECT(eth0),
"axistream-connected-target", NULL);
cs = object_property_get_link(OBJECT(eth0),
"axistream-control-connected-target", NULL);
qdev_prop_set_uint32(dma, "freqhz", 100 * 1000000);
object_property_set_link(OBJECT(dma), OBJECT(ds),
"axistream-connected", &error_abort);
object_property_set_link(OBJECT(dma), OBJECT(cs),
"axistream-control-connected", &error_abort);
qdev_init_nofail(dma);
sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 0, irq[AXIDMA_IRQ0]);
sysbus_connect_irq(SYS_BUS_DEVICE(dma), 1, irq[AXIDMA_IRQ1]);
{
SSIBus *spi;
dev = qdev_create(NULL, "xlnx.xps-spi");
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, SPI_BASEADDR);
sysbus_connect_irq(busdev, 0, irq[SPI_IRQ]);
spi = (SSIBus *)qdev_get_child_bus(dev, "spi");
for (VAR_1 = 0; VAR_1 < NUM_SPI_FLASHES; VAR_1++) {
qemu_irq cs_line;
dev = ssi_create_slave(spi, "n25q128");
cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
sysbus_connect_irq(busdev, VAR_1+1, cs_line);
}
}
cpu->env.pvr.regs[4] = 0xc56b8000;
cpu->env.pvr.regs[5] = 0xc56be000;
cpu->env.pvr.regs[10] = 0x0e000000;
microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size,
VAR_0->initrd_filename,
BINARY_DEVICE_TREE_FILE,
NULL);
}
| [
"FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"MemoryRegion *address_space_mem = get_system_memory();",
"DeviceState *dev, *dma, *eth0;",
"Object *ds, *cs;",
"MicroBlazeCPU *cpu;",
"SysBusDevice *busdev;",
"DriveInfo *dinfo;",
"int VAR_1;",
"MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);",
"MemoryRegion *phys_ram = g_new(MemoryRegion, 1);",
"qemu_irq irq[32];",
"cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));",
"object_property_set_int(OBJECT(cpu), 1, \"use-fpu\", &error_abort);",
"object_property_set_bool(OBJECT(cpu), true, \"dcache-writeback\",\n&error_abort);",
"object_property_set_bool(OBJECT(cpu), true, \"endianness\", &error_abort);",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", &error_abort);",
"memory_region_init_ram(phys_lmb_bram, NULL, \"petalogix_ml605.lmb_bram\",\nLMB_BRAM_SIZE, &error_abort);",
"vmstate_register_ram_global(phys_lmb_bram);",
"memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram);",
"memory_region_init_ram(phys_ram, NULL, \"petalogix_ml605.ram\", ram_size,\n&error_abort);",
"vmstate_register_ram_global(phys_ram);",
"memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram);",
"dinfo = drive_get(IF_PFLASH, 0, 0);",
"pflash_cfi01_register(FLASH_BASEADDR,\nNULL, \"petalogix_ml605.flash\", FLASH_SIZE,\ndinfo ? blk_by_legacy_dinfo(dinfo) : NULL,\n(64 * 1024), FLASH_SIZE >> 16,\n2, 0x89, 0x18, 0x0000, 0x0, 0);",
"dev = qdev_create(NULL, \"xlnx.xps-intc\");",
"qdev_prop_set_uint32(dev, \"kind-of-intr\", 1 << TIMER_IRQ);",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,\nqdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));",
"for (VAR_1 = 0; VAR_1 < 32; VAR_1++) {",
"irq[VAR_1] = qdev_get_gpio_in(dev, VAR_1);",
"}",
"serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2,\nirq[UART16550_IRQ], 115200, serial_hds[0],\nDEVICE_LITTLE_ENDIAN);",
"dev = qdev_create(NULL, \"xlnx.xps-timer\");",
"qdev_prop_set_uint32(dev, \"one-timer-only\", 0);",
"qdev_prop_set_uint32(dev, \"clock-frequency\", 100 * 1000000);",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);",
"qemu_check_nic_model(&nd_table[0], \"xlnx.axi-ethernet\");",
"eth0 = qdev_create(NULL, \"xlnx.axi-ethernet\");",
"dma = qdev_create(NULL, \"xlnx.axi-dma\");",
"object_property_add_child(qdev_get_machine(), \"xilinx-eth\", OBJECT(eth0),\nNULL);",
"object_property_add_child(qdev_get_machine(), \"xilinx-dma\", OBJECT(dma),\nNULL);",
"ds = object_property_get_link(OBJECT(dma),\n\"axistream-connected-target\", NULL);",
"cs = object_property_get_link(OBJECT(dma),\n\"axistream-control-connected-target\", NULL);",
"qdev_set_nic_properties(eth0, &nd_table[0]);",
"qdev_prop_set_uint32(eth0, \"rxmem\", 0x1000);",
"qdev_prop_set_uint32(eth0, \"txmem\", 0x1000);",
"object_property_set_link(OBJECT(eth0), OBJECT(ds),\n\"axistream-connected\", &error_abort);",
"object_property_set_link(OBJECT(eth0), OBJECT(cs),\n\"axistream-control-connected\", &error_abort);",
"qdev_init_nofail(eth0);",
"sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR);",
"sysbus_connect_irq(SYS_BUS_DEVICE(eth0), 0, irq[AXIENET_IRQ]);",
"ds = object_property_get_link(OBJECT(eth0),\n\"axistream-connected-target\", NULL);",
"cs = object_property_get_link(OBJECT(eth0),\n\"axistream-control-connected-target\", NULL);",
"qdev_prop_set_uint32(dma, \"freqhz\", 100 * 1000000);",
"object_property_set_link(OBJECT(dma), OBJECT(ds),\n\"axistream-connected\", &error_abort);",
"object_property_set_link(OBJECT(dma), OBJECT(cs),\n\"axistream-control-connected\", &error_abort);",
"qdev_init_nofail(dma);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dma), 0, irq[AXIDMA_IRQ0]);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dma), 1, irq[AXIDMA_IRQ1]);",
"{",
"SSIBus *spi;",
"dev = qdev_create(NULL, \"xlnx.xps-spi\");",
"qdev_prop_set_uint8(dev, \"num-ss-bits\", NUM_SPI_FLASHES);",
"qdev_init_nofail(dev);",
"busdev = SYS_BUS_DEVICE(dev);",
"sysbus_mmio_map(busdev, 0, SPI_BASEADDR);",
"sysbus_connect_irq(busdev, 0, irq[SPI_IRQ]);",
"spi = (SSIBus *)qdev_get_child_bus(dev, \"spi\");",
"for (VAR_1 = 0; VAR_1 < NUM_SPI_FLASHES; VAR_1++) {",
"qemu_irq cs_line;",
"dev = ssi_create_slave(spi, \"n25q128\");",
"cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);",
"sysbus_connect_irq(busdev, VAR_1+1, cs_line);",
"}",
"}",
"cpu->env.pvr.regs[4] = 0xc56b8000;",
"cpu->env.pvr.regs[5] = 0xc56be000;",
"cpu->env.pvr.regs[10] = 0x0e000000;",
"microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size,\nVAR_0->initrd_filename,\nBINARY_DEVICE_TREE_FILE,\nNULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
53,
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
79,
81,
83,
85,
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
113,
115,
117
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
139
],
[
141
],
[
143
],
[
149,
151
],
[
153,
155
],
[
159,
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
189,
191
],
[
193,
195
],
[
197
],
[
199,
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
261
],
[
263
],
[
265
],
[
269,
271,
273,
275
],
[
279
]
] |
24,811 | static FILE *probe_splashfile(char *filename, int *file_sizep, int *file_typep)
{
FILE *fp = NULL;
int fop_ret;
int file_size;
int file_type = -1;
unsigned char buf[2] = {0, 0};
unsigned int filehead_value = 0;
int bmp_bpp;
fp = fopen(filename, "rb");
if (fp == NULL) {
error_report("failed to open file '%s'.", filename);
/* check file size */
fseek(fp, 0L, SEEK_END);
file_size = ftell(fp);
if (file_size < 2) {
error_report("file size is less than 2 bytes '%s'.", filename);
/* check magic ID */
fseek(fp, 0L, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
filehead_value = (buf[0] + (buf[1] << 8)) & 0xffff;
if (filehead_value == 0xd8ff) {
file_type = JPG_FILE;
} else {
if (filehead_value == 0x4d42) {
file_type = BMP_FILE;
if (file_type < 0) {
error_report("'%s' not jpg/bmp file,head:0x%x.",
filename, filehead_value);
/* check BMP bpp */
if (file_type == BMP_FILE) {
fseek(fp, 28, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
bmp_bpp = (buf[0] + (buf[1] << 8)) & 0xffff;
if (bmp_bpp != 24) {
error_report("only 24bpp bmp file is supported.");
/* return values */
*file_sizep = file_size;
*file_typep = file_type;
| true | qemu | 257a7375582e4c3b32687c72d0f52279d28b2d85 | static FILE *probe_splashfile(char *filename, int *file_sizep, int *file_typep)
{
FILE *fp = NULL;
int fop_ret;
int file_size;
int file_type = -1;
unsigned char buf[2] = {0, 0};
unsigned int filehead_value = 0;
int bmp_bpp;
fp = fopen(filename, "rb");
if (fp == NULL) {
error_report("failed to open file '%s'.", filename);
fseek(fp, 0L, SEEK_END);
file_size = ftell(fp);
if (file_size < 2) {
error_report("file size is less than 2 bytes '%s'.", filename);
fseek(fp, 0L, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
filehead_value = (buf[0] + (buf[1] << 8)) & 0xffff;
if (filehead_value == 0xd8ff) {
file_type = JPG_FILE;
} else {
if (filehead_value == 0x4d42) {
file_type = BMP_FILE;
if (file_type < 0) {
error_report("'%s' not jpg/bmp file,head:0x%x.",
filename, filehead_value);
if (file_type == BMP_FILE) {
fseek(fp, 28, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
bmp_bpp = (buf[0] + (buf[1] << 8)) & 0xffff;
if (bmp_bpp != 24) {
error_report("only 24bpp bmp file is supported.");
*file_sizep = file_size;
*file_typep = file_type;
| {
"code": [],
"line_no": []
} | static FILE *FUNC_0(char *filename, int *file_sizep, int *file_typep)
{
FILE *fp = NULL;
int VAR_0;
int VAR_1;
int VAR_2 = -1;
unsigned char VAR_3[2] = {0, 0};
unsigned int VAR_4 = 0;
int VAR_5;
fp = fopen(filename, "rb");
if (fp == NULL) {
error_report("failed to open file '%s'.", filename);
fseek(fp, 0L, SEEK_END);
VAR_1 = ftell(fp);
if (VAR_1 < 2) {
error_report("file size is less than 2 bytes '%s'.", filename);
fseek(fp, 0L, SEEK_SET);
VAR_0 = fread(VAR_3, 1, 2, fp);
VAR_4 = (VAR_3[0] + (VAR_3[1] << 8)) & 0xffff;
if (VAR_4 == 0xd8ff) {
VAR_2 = JPG_FILE;
} else {
if (VAR_4 == 0x4d42) {
VAR_2 = BMP_FILE;
if (VAR_2 < 0) {
error_report("'%s' not jpg/bmp file,head:0x%x.",
filename, VAR_4);
if (VAR_2 == BMP_FILE) {
fseek(fp, 28, SEEK_SET);
VAR_0 = fread(VAR_3, 1, 2, fp);
VAR_5 = (VAR_3[0] + (VAR_3[1] << 8)) & 0xffff;
if (VAR_5 != 24) {
error_report("only 24bpp bmp file is supported.");
*file_sizep = VAR_1;
*file_typep = VAR_2;
| [
"static FILE *FUNC_0(char *filename, int *file_sizep, int *file_typep)\n{",
"FILE *fp = NULL;",
"int VAR_0;",
"int VAR_1;",
"int VAR_2 = -1;",
"unsigned char VAR_3[2] = {0, 0};",
"unsigned int VAR_4 = 0;",
"int VAR_5;",
"fp = fopen(filename, \"rb\");",
"if (fp == NULL) {",
"error_report(\"failed to open file '%s'.\", filename);",
"fseek(fp, 0L, SEEK_END);",
"VAR_1 = ftell(fp);",
"if (VAR_1 < 2) {",
"error_report(\"file size is less than 2 bytes '%s'.\", filename);",
"fseek(fp, 0L, SEEK_SET);",
"VAR_0 = fread(VAR_3, 1, 2, fp);",
"VAR_4 = (VAR_3[0] + (VAR_3[1] << 8)) & 0xffff;",
"if (VAR_4 == 0xd8ff) {",
"VAR_2 = JPG_FILE;",
"} else {",
"if (VAR_4 == 0x4d42) {",
"VAR_2 = BMP_FILE;",
"if (VAR_2 < 0) {",
"error_report(\"'%s' not jpg/bmp file,head:0x%x.\",\nfilename, VAR_4);",
"if (VAR_2 == BMP_FILE) {",
"fseek(fp, 28, SEEK_SET);",
"VAR_0 = fread(VAR_3, 1, 2, fp);",
"VAR_5 = (VAR_3[0] + (VAR_3[1] << 8)) & 0xffff;",
"if (VAR_5 != 24) {",
"error_report(\"only 24bpp bmp file is supported.\");",
"*file_sizep = VAR_1;",
"*file_typep = VAR_2;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
45
],
[
47
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
70
],
[
72,
74
],
[
82
],
[
84
],
[
86
],
[
88
],
[
90
],
[
92
],
[
101
],
[
103
]
] |
24,812 | vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,
struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)
{
Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];
*didx = vmxnet3_ring_curr_cell_idx(ring);
vmxnet3_ring_read_curr_cell(ring, dbuf);
}
| true | qemu | c508277335e3b6b20cf18e6ea3a35c1fa835c64a | vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,
struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)
{
Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];
*didx = vmxnet3_ring_curr_cell_idx(ring);
vmxnet3_ring_read_curr_cell(ring, dbuf);
}
| {
"code": [
" vmxnet3_ring_read_curr_cell(ring, dbuf);"
],
"line_no": [
11
]
} | FUNC_0(VMXNET3State *VAR_0, int VAR_1, int VAR_2,
struct Vmxnet3_RxDesc *VAR_3, uint32_t *VAR_4)
{
Vmxnet3Ring *ring = &VAR_0->rxq_descr[VAR_1].rx_ring[VAR_2];
*VAR_4 = vmxnet3_ring_curr_cell_idx(ring);
vmxnet3_ring_read_curr_cell(ring, VAR_3);
}
| [
"FUNC_0(VMXNET3State *VAR_0, int VAR_1, int VAR_2,\nstruct Vmxnet3_RxDesc *VAR_3, uint32_t *VAR_4)\n{",
"Vmxnet3Ring *ring = &VAR_0->rxq_descr[VAR_1].rx_ring[VAR_2];",
"*VAR_4 = vmxnet3_ring_curr_cell_idx(ring);",
"vmxnet3_ring_read_curr_cell(ring, VAR_3);",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
24,814 | static av_cold int aac_encode_end(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
ff_mdct_end(&s->mdct1024);
ff_mdct_end(&s->mdct128);
ff_psy_end(&s->psy);
ff_psy_preprocess_end(s->psypp);
av_freep(&s->samples);
av_freep(&s->cpe);
return 0;
}
| true | FFmpeg | 17ae608127324cabd083202a32a8dc210d30c3a1 | static av_cold int aac_encode_end(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
ff_mdct_end(&s->mdct1024);
ff_mdct_end(&s->mdct128);
ff_psy_end(&s->psy);
ff_psy_preprocess_end(s->psypp);
av_freep(&s->samples);
av_freep(&s->cpe);
return 0;
}
| {
"code": [
"static av_cold int aac_encode_end(AVCodecContext *avctx)",
" AACEncContext *s = avctx->priv_data;",
" ff_mdct_end(&s->mdct1024);",
" ff_mdct_end(&s->mdct128);",
" ff_psy_end(&s->psy);",
" ff_psy_preprocess_end(s->psypp);",
" av_freep(&s->samples);",
" av_freep(&s->cpe);",
" return 0;"
],
"line_no": [
1,
5,
9,
11,
13,
15,
17,
19,
21
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
ff_mdct_end(&s->mdct1024);
ff_mdct_end(&s->mdct128);
ff_psy_end(&s->psy);
ff_psy_preprocess_end(s->psypp);
av_freep(&s->samples);
av_freep(&s->cpe);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"AACEncContext *s = avctx->priv_data;",
"ff_mdct_end(&s->mdct1024);",
"ff_mdct_end(&s->mdct128);",
"ff_psy_end(&s->psy);",
"ff_psy_preprocess_end(s->psypp);",
"av_freep(&s->samples);",
"av_freep(&s->cpe);",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,816 | static int rice_count_exact(int32_t *res, int n, int k)
{
int i;
int count = 0;
for (i = 0; i < n; i++) {
int32_t v = -2 * res[i] - 1;
v ^= v >> 31;
count += (v >> k) + 1 + k;
}
return count;
}
| true | FFmpeg | 5ff998a233d759d0de83ea6f95c383d03d25d88e | static int rice_count_exact(int32_t *res, int n, int k)
{
int i;
int count = 0;
for (i = 0; i < n; i++) {
int32_t v = -2 * res[i] - 1;
v ^= v >> 31;
count += (v >> k) + 1 + k;
}
return count;
}
| {
"code": [
"static int rice_count_exact(int32_t *res, int n, int k)",
" int count = 0;",
" int count = 0;"
],
"line_no": [
1,
7,
7
]
} | static int FUNC_0(int32_t *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3;
int VAR_4 = 0;
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {
int32_t v = -2 * VAR_0[VAR_3] - 1;
v ^= v >> 31;
VAR_4 += (v >> VAR_2) + 1 + VAR_2;
}
return VAR_4;
}
| [
"static int FUNC_0(int32_t *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3;",
"int VAR_4 = 0;",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {",
"int32_t v = -2 * VAR_0[VAR_3] - 1;",
"v ^= v >> 31;",
"VAR_4 += (v >> VAR_2) + 1 + VAR_2;",
"}",
"return VAR_4;",
"}"
] | [
1,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,817 | static uint64_t boston_lcd_read(void *opaque, hwaddr addr,
unsigned size)
{
BostonState *s = opaque;
uint64_t val = 0;
switch (size) {
case 8:
val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;
val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;
val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;
val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;
/* fall through */
case 4:
val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;
val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;
/* fall through */
case 2:
val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;
/* fall through */
case 1:
val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];
break;
}
return val;
}
| true | qemu | 2d896b454a0e19ec4c1ddbb0e0b65b7e54fcedf3 | static uint64_t boston_lcd_read(void *opaque, hwaddr addr,
unsigned size)
{
BostonState *s = opaque;
uint64_t val = 0;
switch (size) {
case 8:
val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;
val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;
val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;
val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;
case 4:
val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;
val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;
case 2:
val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;
case 1:
val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];
break;
}
return val;
}
| {
"code": [
" BostonState *s = opaque;",
"static uint64_t boston_lcd_read(void *opaque, hwaddr addr,",
" unsigned size)",
" BostonState *s = opaque;",
" uint64_t val = 0;",
" switch (size) {",
" case 8:",
" val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;",
" val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;",
" val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;",
" val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;",
" case 4:",
" val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;",
" val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;",
" case 2:",
" val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;",
" case 1:",
" val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];",
" break;",
" return val;",
" BostonState *s = opaque;",
" switch (size) {",
" case 8:",
" case 4:",
" case 2:",
" case 1:",
" break;",
" BostonState *s = opaque;",
" break;",
" break;",
" break;"
],
"line_no": [
7,
1,
3,
7,
9,
13,
15,
17,
19,
21,
23,
27,
29,
31,
35,
37,
41,
43,
45,
51,
7,
13,
15,
27,
35,
41,
45,
7,
45,
45,
45
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
BostonState *s = opaque;
uint64_t val = 0;
switch (size) {
case 8:
val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;
val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;
val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;
val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;
case 4:
val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;
val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;
case 2:
val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;
case 1:
val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];
break;
}
return val;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"BostonState *s = opaque;",
"uint64_t val = 0;",
"switch (size) {",
"case 8:\nval |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;",
"val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;",
"val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;",
"val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;",
"case 4:\nval |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;",
"val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;",
"case 2:\nval |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;",
"case 1:\nval |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];",
"break;",
"}",
"return val;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
35,
37
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
]
] |
24,819 | static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){
#if CONFIG_SMALL
#define ROT(x,s) ((x<<s)|(x>>(32-s)))
return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);
#else
return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d];
#endif
}
| true | FFmpeg | 5d20f19be25c973fe10d0d17db9245002585710d | static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){
#if CONFIG_SMALL
#define ROT(x,s) ((x<<s)|(x>>(32-s)))
return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);
#else
return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d];
#endif
}
| {
"code": [
"#define ROT(x,s) ((x<<s)|(x>>(32-s)))"
],
"line_no": [
5
]
} | static inline int FUNC_0(uint32_t VAR_0[][256], int VAR_1, int VAR_2, int VAR_3, int VAR_4){
#if CONFIG_SMALL
#define ROT(x,s) ((x<<s)|(x>>(32-s)))
return VAR_0[0][VAR_1] ^ ROT(VAR_0[0][VAR_2], 8) ^ ROT(VAR_0[0][VAR_3], 16) ^ ROT(VAR_0[0][VAR_4], 24);
#else
return VAR_0[0][VAR_1] ^ VAR_0[1][VAR_2] ^ VAR_0[2][VAR_3] ^ VAR_0[3][VAR_4];
#endif
}
| [
"static inline int FUNC_0(uint32_t VAR_0[][256], int VAR_1, int VAR_2, int VAR_3, int VAR_4){",
"#if CONFIG_SMALL\n#define ROT(x,s) ((x<<s)|(x>>(32-s)))\nreturn VAR_0[0][VAR_1] ^ ROT(VAR_0[0][VAR_2], 8) ^ ROT(VAR_0[0][VAR_3], 16) ^ ROT(VAR_0[0][VAR_4], 24);",
"#else\nreturn VAR_0[0][VAR_1] ^ VAR_0[1][VAR_2] ^ VAR_0[2][VAR_3] ^ VAR_0[3][VAR_4];",
"#endif\n}"
] | [
0,
1,
0,
0
] | [
[
1
],
[
3,
5,
7
],
[
9,
11
],
[
13,
15
]
] |
24,820 | void ff_generate_sliding_window_mmcos(H264Context *h) {
MpegEncContext * const s = &h->s;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
h->mmco_index= 0;
if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {
h->mmco[0].opcode= MMCO_SHORT2UNUSED;
h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
h->mmco_index= 1;
if (FIELD_PICTURE) {
h->mmco[0].short_pic_num *= 2;
h->mmco[1].opcode= MMCO_SHORT2UNUSED;
h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;
h->mmco_index= 2;
}
}
}
| true | FFmpeg | bad446e251405dc250c3cbee199072e083a1e4b9 | void ff_generate_sliding_window_mmcos(H264Context *h) {
MpegEncContext * const s = &h->s;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
h->mmco_index= 0;
if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {
h->mmco[0].opcode= MMCO_SHORT2UNUSED;
h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
h->mmco_index= 1;
if (FIELD_PICTURE) {
h->mmco[0].short_pic_num *= 2;
h->mmco[1].opcode= MMCO_SHORT2UNUSED;
h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;
h->mmco_index= 2;
}
}
}
| {
"code": [
"void ff_generate_sliding_window_mmcos(H264Context *h) {",
" h->mmco_index= 0;",
" if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&",
" !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {",
" h->mmco[0].opcode= MMCO_SHORT2UNUSED;",
" h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;",
" h->mmco_index= 1;",
" h->mmco[0].short_pic_num *= 2;",
" h->mmco[1].opcode= MMCO_SHORT2UNUSED;",
" h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;",
" h->mmco_index= 2;",
" h->mmco_index= 0;"
],
"line_no": [
1,
9,
11,
13,
15,
17,
19,
23,
25,
27,
29,
9
]
} | void FUNC_0(H264Context *VAR_0) {
MpegEncContext * const s = &VAR_0->s;
assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);
VAR_0->mmco_index= 0;
if(VAR_0->short_ref_count && VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&
!(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {
VAR_0->mmco[0].opcode= MMCO_SHORT2UNUSED;
VAR_0->mmco[0].short_pic_num= VAR_0->short_ref[ VAR_0->short_ref_count - 1 ]->frame_num;
VAR_0->mmco_index= 1;
if (FIELD_PICTURE) {
VAR_0->mmco[0].short_pic_num *= 2;
VAR_0->mmco[1].opcode= MMCO_SHORT2UNUSED;
VAR_0->mmco[1].short_pic_num= VAR_0->mmco[0].short_pic_num + 1;
VAR_0->mmco_index= 2;
}
}
}
| [
"void FUNC_0(H264Context *VAR_0) {",
"MpegEncContext * const s = &VAR_0->s;",
"assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);",
"VAR_0->mmco_index= 0;",
"if(VAR_0->short_ref_count && VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&\n!(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {",
"VAR_0->mmco[0].opcode= MMCO_SHORT2UNUSED;",
"VAR_0->mmco[0].short_pic_num= VAR_0->short_ref[ VAR_0->short_ref_count - 1 ]->frame_num;",
"VAR_0->mmco_index= 1;",
"if (FIELD_PICTURE) {",
"VAR_0->mmco[0].short_pic_num *= 2;",
"VAR_0->mmco[1].opcode= MMCO_SHORT2UNUSED;",
"VAR_0->mmco[1].short_pic_num= VAR_0->mmco[0].short_pic_num + 1;",
"VAR_0->mmco_index= 2;",
"}",
"}",
"}"
] | [
1,
0,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
24,821 | static unsigned long copy_elf_strings(int argc,char ** argv, void **page,
unsigned long p)
{
char *tmp, *tmp1, *pag = NULL;
int len, offset = 0;
if (!p) {
return 0; /* bullet-proofing */
}
while (argc-- > 0) {
tmp = argv[argc];
if (!tmp) {
fprintf(stderr, "VFS: argc is wrong");
exit(-1);
}
tmp1 = tmp;
while (*tmp++);
len = tmp - tmp1;
if (p < len) { /* this shouldn't happen - 128kB */
return 0;
}
while (len) {
--p; --tmp; --len;
if (--offset < 0) {
offset = p % TARGET_PAGE_SIZE;
pag = (char *)page[p/TARGET_PAGE_SIZE];
if (!pag) {
pag = (char *)malloc(TARGET_PAGE_SIZE);
page[p/TARGET_PAGE_SIZE] = pag;
if (!pag)
return 0;
}
}
if (len == 0 || offset == 0) {
*(pag + offset) = *tmp;
}
else {
int bytes_to_copy = (len > offset) ? offset : len;
tmp -= bytes_to_copy;
p -= bytes_to_copy;
offset -= bytes_to_copy;
len -= bytes_to_copy;
memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1);
}
}
}
return p;
}
| true | qemu | 4118a97030aa9bd1d520d1d06bbe0655d829df04 | static unsigned long copy_elf_strings(int argc,char ** argv, void **page,
unsigned long p)
{
char *tmp, *tmp1, *pag = NULL;
int len, offset = 0;
if (!p) {
return 0;
}
while (argc-- > 0) {
tmp = argv[argc];
if (!tmp) {
fprintf(stderr, "VFS: argc is wrong");
exit(-1);
}
tmp1 = tmp;
while (*tmp++);
len = tmp - tmp1;
if (p < len) {
return 0;
}
while (len) {
--p; --tmp; --len;
if (--offset < 0) {
offset = p % TARGET_PAGE_SIZE;
pag = (char *)page[p/TARGET_PAGE_SIZE];
if (!pag) {
pag = (char *)malloc(TARGET_PAGE_SIZE);
page[p/TARGET_PAGE_SIZE] = pag;
if (!pag)
return 0;
}
}
if (len == 0 || offset == 0) {
*(pag + offset) = *tmp;
}
else {
int bytes_to_copy = (len > offset) ? offset : len;
tmp -= bytes_to_copy;
p -= bytes_to_copy;
offset -= bytes_to_copy;
len -= bytes_to_copy;
memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1);
}
}
}
return p;
}
| {
"code": [
" unsigned long p)"
],
"line_no": [
3
]
} | static unsigned long FUNC_0(int VAR_0,char ** VAR_1, void **VAR_2,
unsigned long VAR_3)
{
char *VAR_4, *VAR_5, *VAR_6 = NULL;
int VAR_7, VAR_8 = 0;
if (!VAR_3) {
return 0;
}
while (VAR_0-- > 0) {
VAR_4 = VAR_1[VAR_0];
if (!VAR_4) {
fprintf(stderr, "VFS: VAR_0 is wrong");
exit(-1);
}
VAR_5 = VAR_4;
while (*VAR_4++);
VAR_7 = VAR_4 - VAR_5;
if (VAR_3 < VAR_7) {
return 0;
}
while (VAR_7) {
--VAR_3; --VAR_4; --VAR_7;
if (--VAR_8 < 0) {
VAR_8 = VAR_3 % TARGET_PAGE_SIZE;
VAR_6 = (char *)VAR_2[VAR_3/TARGET_PAGE_SIZE];
if (!VAR_6) {
VAR_6 = (char *)malloc(TARGET_PAGE_SIZE);
VAR_2[VAR_3/TARGET_PAGE_SIZE] = VAR_6;
if (!VAR_6)
return 0;
}
}
if (VAR_7 == 0 || VAR_8 == 0) {
*(VAR_6 + VAR_8) = *VAR_4;
}
else {
int VAR_9 = (VAR_7 > VAR_8) ? VAR_8 : VAR_7;
VAR_4 -= VAR_9;
VAR_3 -= VAR_9;
VAR_8 -= VAR_9;
VAR_7 -= VAR_9;
memcpy_fromfs(VAR_6 + VAR_8, VAR_4, VAR_9 + 1);
}
}
}
return VAR_3;
}
| [
"static unsigned long FUNC_0(int VAR_0,char ** VAR_1, void **VAR_2,\nunsigned long VAR_3)\n{",
"char *VAR_4, *VAR_5, *VAR_6 = NULL;",
"int VAR_7, VAR_8 = 0;",
"if (!VAR_3) {",
"return 0;",
"}",
"while (VAR_0-- > 0) {",
"VAR_4 = VAR_1[VAR_0];",
"if (!VAR_4) {",
"fprintf(stderr, \"VFS: VAR_0 is wrong\");",
"exit(-1);",
"}",
"VAR_5 = VAR_4;",
"while (*VAR_4++);",
"VAR_7 = VAR_4 - VAR_5;",
"if (VAR_3 < VAR_7) {",
"return 0;",
"}",
"while (VAR_7) {",
"--VAR_3; --VAR_4; --VAR_7;",
"if (--VAR_8 < 0) {",
"VAR_8 = VAR_3 % TARGET_PAGE_SIZE;",
"VAR_6 = (char *)VAR_2[VAR_3/TARGET_PAGE_SIZE];",
"if (!VAR_6) {",
"VAR_6 = (char *)malloc(TARGET_PAGE_SIZE);",
"VAR_2[VAR_3/TARGET_PAGE_SIZE] = VAR_6;",
"if (!VAR_6)\nreturn 0;",
"}",
"}",
"if (VAR_7 == 0 || VAR_8 == 0) {",
"*(VAR_6 + VAR_8) = *VAR_4;",
"}",
"else {",
"int VAR_9 = (VAR_7 > VAR_8) ? VAR_8 : VAR_7;",
"VAR_4 -= VAR_9;",
"VAR_3 -= VAR_9;",
"VAR_8 -= VAR_9;",
"VAR_7 -= VAR_9;",
"memcpy_fromfs(VAR_6 + VAR_8, VAR_4, VAR_9 + 1);",
"}",
"}",
"}",
"return VAR_3;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
24,822 | void fork_end(int child)
{
mmap_fork_end(child);
if (child) {
CPUState *cpu, *next_cpu;
/* Child processes created by fork() only have a single thread.
Discard information about the parent threads. */
CPU_FOREACH_SAFE(cpu, next_cpu) {
if (cpu != thread_cpu) {
QTAILQ_REMOVE(&cpus, cpu, node);
}
}
qemu_mutex_init(&tb_ctx.tb_lock);
qemu_init_cpu_list();
gdbserver_fork(thread_cpu);
} else {
qemu_mutex_unlock(&tb_ctx.tb_lock);
cpu_list_unlock();
}
} | true | qemu | 06065c451f10c7ef62cfb575a87f323a70ae1c9e | void fork_end(int child)
{
mmap_fork_end(child);
if (child) {
CPUState *cpu, *next_cpu;
CPU_FOREACH_SAFE(cpu, next_cpu) {
if (cpu != thread_cpu) {
QTAILQ_REMOVE(&cpus, cpu, node);
}
}
qemu_mutex_init(&tb_ctx.tb_lock);
qemu_init_cpu_list();
gdbserver_fork(thread_cpu);
} else {
qemu_mutex_unlock(&tb_ctx.tb_lock);
cpu_list_unlock();
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0)
{
mmap_fork_end(VAR_0);
if (VAR_0) {
CPUState *cpu, *next_cpu;
CPU_FOREACH_SAFE(cpu, next_cpu) {
if (cpu != thread_cpu) {
QTAILQ_REMOVE(&cpus, cpu, node);
}
}
qemu_mutex_init(&tb_ctx.tb_lock);
qemu_init_cpu_list();
gdbserver_fork(thread_cpu);
} else {
qemu_mutex_unlock(&tb_ctx.tb_lock);
cpu_list_unlock();
}
} | [
"void FUNC_0(int VAR_0)\n{",
"mmap_fork_end(VAR_0);",
"if (VAR_0) {",
"CPUState *cpu, *next_cpu;",
"CPU_FOREACH_SAFE(cpu, next_cpu) {",
"if (cpu != thread_cpu) {",
"QTAILQ_REMOVE(&cpus, cpu, node);",
"}",
"}",
"qemu_mutex_init(&tb_ctx.tb_lock);",
"qemu_init_cpu_list();",
"gdbserver_fork(thread_cpu);",
"} else {",
"qemu_mutex_unlock(&tb_ctx.tb_lock);",
"cpu_list_unlock();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
34
],
[
36
],
[
38
],
[
41
],
[
43
]
] |
24,823 | static int mpc8_probe(AVProbeData *p)
{
const uint8_t *bs = p->buf + 4;
const uint8_t *bs_end = bs + p->buf_size;
int64_t size;
if (p->buf_size < 16)
return 0;
if (AV_RL32(p->buf) != TAG_MPCK)
return 0;
while (bs < bs_end + 3) {
int header_found = (bs[0] == 'S' && bs[1] == 'H');
if (bs[0] < 'A' || bs[0] > 'Z' || bs[1] < 'A' || bs[1] > 'Z')
return 0;
bs += 2;
size = bs_get_v(&bs);
if (size < 2)
return 0;
if (bs + size - 2 >= bs_end)
return AVPROBE_SCORE_EXTENSION - 1; // seems to be valid MPC but no header yet
if (header_found) {
if (size < 11 || size > 28)
return 0;
if (!AV_RL32(bs)) //zero CRC is invalid
return 0;
return AVPROBE_SCORE_MAX;
} else {
bs += size - 2;
}
}
return 0;
}
| true | FFmpeg | b737a2c52857b214be246ff615c6293730033cfa | static int mpc8_probe(AVProbeData *p)
{
const uint8_t *bs = p->buf + 4;
const uint8_t *bs_end = bs + p->buf_size;
int64_t size;
if (p->buf_size < 16)
return 0;
if (AV_RL32(p->buf) != TAG_MPCK)
return 0;
while (bs < bs_end + 3) {
int header_found = (bs[0] == 'S' && bs[1] == 'H');
if (bs[0] < 'A' || bs[0] > 'Z' || bs[1] < 'A' || bs[1] > 'Z')
return 0;
bs += 2;
size = bs_get_v(&bs);
if (size < 2)
return 0;
if (bs + size - 2 >= bs_end)
return AVPROBE_SCORE_EXTENSION - 1;
if (header_found) {
if (size < 11 || size > 28)
return 0;
if (!AV_RL32(bs))
return 0;
return AVPROBE_SCORE_MAX;
} else {
bs += size - 2;
}
}
return 0;
}
| {
"code": [
" if (bs + size - 2 >= bs_end)"
],
"line_no": [
37
]
} | static int FUNC_0(AVProbeData *VAR_0)
{
const uint8_t *VAR_1 = VAR_0->buf + 4;
const uint8_t *VAR_2 = VAR_1 + VAR_0->buf_size;
int64_t size;
if (VAR_0->buf_size < 16)
return 0;
if (AV_RL32(VAR_0->buf) != TAG_MPCK)
return 0;
while (VAR_1 < VAR_2 + 3) {
int VAR_3 = (VAR_1[0] == 'S' && VAR_1[1] == 'H');
if (VAR_1[0] < 'A' || VAR_1[0] > 'Z' || VAR_1[1] < 'A' || VAR_1[1] > 'Z')
return 0;
VAR_1 += 2;
size = bs_get_v(&VAR_1);
if (size < 2)
return 0;
if (VAR_1 + size - 2 >= VAR_2)
return AVPROBE_SCORE_EXTENSION - 1;
if (VAR_3) {
if (size < 11 || size > 28)
return 0;
if (!AV_RL32(VAR_1))
return 0;
return AVPROBE_SCORE_MAX;
} else {
VAR_1 += size - 2;
}
}
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"const uint8_t *VAR_1 = VAR_0->buf + 4;",
"const uint8_t *VAR_2 = VAR_1 + VAR_0->buf_size;",
"int64_t size;",
"if (VAR_0->buf_size < 16)\nreturn 0;",
"if (AV_RL32(VAR_0->buf) != TAG_MPCK)\nreturn 0;",
"while (VAR_1 < VAR_2 + 3) {",
"int VAR_3 = (VAR_1[0] == 'S' && VAR_1[1] == 'H');",
"if (VAR_1[0] < 'A' || VAR_1[0] > 'Z' || VAR_1[1] < 'A' || VAR_1[1] > 'Z')\nreturn 0;",
"VAR_1 += 2;",
"size = bs_get_v(&VAR_1);",
"if (size < 2)\nreturn 0;",
"if (VAR_1 + size - 2 >= VAR_2)\nreturn AVPROBE_SCORE_EXTENSION - 1;",
"if (VAR_3) {",
"if (size < 11 || size > 28)\nreturn 0;",
"if (!AV_RL32(VAR_1))\nreturn 0;",
"return AVPROBE_SCORE_MAX;",
"} else {",
"VAR_1 += size - 2;",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
24,825 | static TranslationBlock *tb_find_slow(target_ulong pc,
target_ulong cs_base,
uint64_t flags)
{
TranslationBlock *tb, **ptb1;
int code_gen_size;
unsigned int h;
target_ulong phys_pc, phys_page1, phys_page2, virt_page2;
uint8_t *tc_ptr;
spin_lock(&tb_lock);
tb_invalidated_flag = 0;
regs_to_env(); /* XXX: do it just before cpu_gen_code() */
/* find translated block using physical mappings */
phys_pc = get_phys_addr_code(env, pc);
phys_page1 = phys_pc & TARGET_PAGE_MASK;
phys_page2 = -1;
h = tb_phys_hash_func(phys_pc);
ptb1 = &tb_phys_hash[h];
for(;;) {
tb = *ptb1;
if (!tb)
goto not_found;
if (tb->pc == pc &&
tb->page_addr[0] == phys_page1 &&
tb->cs_base == cs_base &&
tb->flags == flags) {
/* check next page if needed */
if (tb->page_addr[1] != -1) {
virt_page2 = (pc & TARGET_PAGE_MASK) +
TARGET_PAGE_SIZE;
phys_page2 = get_phys_addr_code(env, virt_page2);
if (tb->page_addr[1] == phys_page2)
goto found;
} else {
goto found;
}
}
ptb1 = &tb->phys_hash_next;
}
not_found:
/* if no translated code available, then translate it now */
tb = tb_alloc(pc);
if (!tb) {
/* flush must be done */
tb_flush(env);
/* cannot fail at this point */
tb = tb_alloc(pc);
/* don't forget to invalidate previous TB info */
tb_invalidated_flag = 1;
}
tc_ptr = code_gen_ptr;
tb->tc_ptr = tc_ptr;
tb->cs_base = cs_base;
tb->flags = flags;
cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
/* check next page if needed */
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_phys_addr_code(env, virt_page2);
}
tb_link_phys(tb, phys_pc, phys_page2);
found:
/* we add the TB in the virtual pc hash table */
env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
spin_unlock(&tb_lock);
return tb;
}
| true | qemu | d07bde88a52bf293c3f8846cfd162e0a57e1557c | static TranslationBlock *tb_find_slow(target_ulong pc,
target_ulong cs_base,
uint64_t flags)
{
TranslationBlock *tb, **ptb1;
int code_gen_size;
unsigned int h;
target_ulong phys_pc, phys_page1, phys_page2, virt_page2;
uint8_t *tc_ptr;
spin_lock(&tb_lock);
tb_invalidated_flag = 0;
regs_to_env();
phys_pc = get_phys_addr_code(env, pc);
phys_page1 = phys_pc & TARGET_PAGE_MASK;
phys_page2 = -1;
h = tb_phys_hash_func(phys_pc);
ptb1 = &tb_phys_hash[h];
for(;;) {
tb = *ptb1;
if (!tb)
goto not_found;
if (tb->pc == pc &&
tb->page_addr[0] == phys_page1 &&
tb->cs_base == cs_base &&
tb->flags == flags) {
if (tb->page_addr[1] != -1) {
virt_page2 = (pc & TARGET_PAGE_MASK) +
TARGET_PAGE_SIZE;
phys_page2 = get_phys_addr_code(env, virt_page2);
if (tb->page_addr[1] == phys_page2)
goto found;
} else {
goto found;
}
}
ptb1 = &tb->phys_hash_next;
}
not_found:
tb = tb_alloc(pc);
if (!tb) {
tb_flush(env);
tb = tb_alloc(pc);
tb_invalidated_flag = 1;
}
tc_ptr = code_gen_ptr;
tb->tc_ptr = tc_ptr;
tb->cs_base = cs_base;
tb->flags = flags;
cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_phys_addr_code(env, virt_page2);
}
tb_link_phys(tb, phys_pc, phys_page2);
found:
env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
spin_unlock(&tb_lock);
return tb;
}
| {
"code": [
" cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);",
" cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);"
],
"line_no": [
117,
117
]
} | static TranslationBlock *FUNC_0(target_ulong pc,
target_ulong cs_base,
uint64_t flags)
{
TranslationBlock *tb, **ptb1;
int VAR_0;
unsigned int VAR_1;
target_ulong phys_pc, phys_page1, phys_page2, virt_page2;
uint8_t *tc_ptr;
spin_lock(&tb_lock);
tb_invalidated_flag = 0;
regs_to_env();
phys_pc = get_phys_addr_code(env, pc);
phys_page1 = phys_pc & TARGET_PAGE_MASK;
phys_page2 = -1;
VAR_1 = tb_phys_hash_func(phys_pc);
ptb1 = &tb_phys_hash[VAR_1];
for(;;) {
tb = *ptb1;
if (!tb)
goto not_found;
if (tb->pc == pc &&
tb->page_addr[0] == phys_page1 &&
tb->cs_base == cs_base &&
tb->flags == flags) {
if (tb->page_addr[1] != -1) {
virt_page2 = (pc & TARGET_PAGE_MASK) +
TARGET_PAGE_SIZE;
phys_page2 = get_phys_addr_code(env, virt_page2);
if (tb->page_addr[1] == phys_page2)
goto found;
} else {
goto found;
}
}
ptb1 = &tb->phys_hash_next;
}
not_found:
tb = tb_alloc(pc);
if (!tb) {
tb_flush(env);
tb = tb_alloc(pc);
tb_invalidated_flag = 1;
}
tc_ptr = code_gen_ptr;
tb->tc_ptr = tc_ptr;
tb->cs_base = cs_base;
tb->flags = flags;
cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &VAR_0);
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + VAR_0 + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_phys_addr_code(env, virt_page2);
}
tb_link_phys(tb, phys_pc, phys_page2);
found:
env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
spin_unlock(&tb_lock);
return tb;
}
| [
"static TranslationBlock *FUNC_0(target_ulong pc,\ntarget_ulong cs_base,\nuint64_t flags)\n{",
"TranslationBlock *tb, **ptb1;",
"int VAR_0;",
"unsigned int VAR_1;",
"target_ulong phys_pc, phys_page1, phys_page2, virt_page2;",
"uint8_t *tc_ptr;",
"spin_lock(&tb_lock);",
"tb_invalidated_flag = 0;",
"regs_to_env();",
"phys_pc = get_phys_addr_code(env, pc);",
"phys_page1 = phys_pc & TARGET_PAGE_MASK;",
"phys_page2 = -1;",
"VAR_1 = tb_phys_hash_func(phys_pc);",
"ptb1 = &tb_phys_hash[VAR_1];",
"for(;;) {",
"tb = *ptb1;",
"if (!tb)\ngoto not_found;",
"if (tb->pc == pc &&\ntb->page_addr[0] == phys_page1 &&\ntb->cs_base == cs_base &&\ntb->flags == flags) {",
"if (tb->page_addr[1] != -1) {",
"virt_page2 = (pc & TARGET_PAGE_MASK) +\nTARGET_PAGE_SIZE;",
"phys_page2 = get_phys_addr_code(env, virt_page2);",
"if (tb->page_addr[1] == phys_page2)\ngoto found;",
"} else {",
"goto found;",
"}",
"}",
"ptb1 = &tb->phys_hash_next;",
"}",
"not_found:\ntb = tb_alloc(pc);",
"if (!tb) {",
"tb_flush(env);",
"tb = tb_alloc(pc);",
"tb_invalidated_flag = 1;",
"}",
"tc_ptr = code_gen_ptr;",
"tb->tc_ptr = tc_ptr;",
"tb->cs_base = cs_base;",
"tb->flags = flags;",
"cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &VAR_0);",
"code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + VAR_0 + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));",
"virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;",
"phys_page2 = -1;",
"if ((pc & TARGET_PAGE_MASK) != virt_page2) {",
"phys_page2 = get_phys_addr_code(env, virt_page2);",
"}",
"tb_link_phys(tb, phys_pc, phys_page2);",
"found:\nenv->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;",
"spin_unlock(&tb_lock);",
"return tb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55,
57,
59
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
91
],
[
93
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139,
143
],
[
145
],
[
147
],
[
149
]
] |
24,826 | static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
int component, int dc_index, int ac_index, int16_t *quant_matrix)
{
int code, i, j, level, val;
VLC *ac_vlc;
/* DC coef */
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xffff) {
dprintf("error dc\n");
return -1;
}
val = val * quant_matrix[0] + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
/* AC coefs */
ac_vlc = &s->vlcs[1][ac_index];
i = 0;
{OPEN_READER(re, &s->gb)
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
/* EOB */
if (code == 0x10)
break;
if (code == 0x100) {
i += 16;
} else {
i += ((unsigned)code) >> 4;
code &= 0xf;
if(code > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &s->gb)
}
{
int cache=GET_CACHE(re,gb);
int sign=(~cache)>>31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code)
if (i >= 63) {
if(i == 63){
j = s->scantable.permutated[63];
block[j] = level * quant_matrix[j];
break;
}
dprintf("error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j];
}
}
CLOSE_READER(re, &s->gb)}
return 0;
}
| false | FFmpeg | 002a7414b5852418f9a66245fc414c0416c4b4c1 | static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
int component, int dc_index, int ac_index, int16_t *quant_matrix)
{
int code, i, j, level, val;
VLC *ac_vlc;
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xffff) {
dprintf("error dc\n");
return -1;
}
val = val * quant_matrix[0] + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
ac_vlc = &s->vlcs[1][ac_index];
i = 0;
{OPEN_READER(re, &s->gb)
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
if (code == 0x10)
break;
if (code == 0x100) {
i += 16;
} else {
i += ((unsigned)code) >> 4;
code &= 0xf;
if(code > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &s->gb)
}
{
int cache=GET_CACHE(re,gb);
int sign=(~cache)>>31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code)
if (i >= 63) {
if(i == 63){
j = s->scantable.permutated[63];
block[j] = level * quant_matrix[j];
break;
}
dprintf("error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j];
}
}
CLOSE_READER(re, &s->gb)}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MJpegDecodeContext *VAR_0, DCTELEM *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int16_t *VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
VLC *ac_vlc;
VAR_10 = mjpeg_decode_dc(VAR_0, VAR_3);
if (VAR_10 == 0xffff) {
dprintf("error dc\n");
return -1;
}
VAR_10 = VAR_10 * VAR_5[0] + VAR_0->last_dc[VAR_2];
VAR_0->last_dc[VAR_2] = VAR_10;
VAR_1[0] = VAR_10;
ac_vlc = &VAR_0->vlcs[1][VAR_4];
VAR_7 = 0;
{OPEN_READER(re, &VAR_0->gb)
for(;;) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_VLC(VAR_6, re, &VAR_0->gb, VAR_0->vlcs[1][VAR_4].table, 9, 2)
if (VAR_6 == 0x10)
break;
if (VAR_6 == 0x100) {
VAR_7 += 16;
} else {
VAR_7 += ((unsigned)VAR_6) >> 4;
VAR_6 &= 0xf;
if(VAR_6 > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &VAR_0->gb)
}
{
int cache=GET_CACHE(re,gb);
int sign=(~cache)>>31;
VAR_9 = (NEG_USR32(sign ^ cache,VAR_6) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &VAR_0->gb, VAR_6)
if (VAR_7 >= 63) {
if(VAR_7 == 63){
VAR_8 = VAR_0->scantable.permutated[63];
VAR_1[VAR_8] = VAR_9 * VAR_5[VAR_8];
break;
}
dprintf("error count: %d\n", VAR_7);
return -1;
}
VAR_8 = VAR_0->scantable.permutated[VAR_7];
VAR_1[VAR_8] = VAR_9 * VAR_5[VAR_8];
}
}
CLOSE_READER(re, &VAR_0->gb)}
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0, DCTELEM *VAR_1,\nint VAR_2, int VAR_3, int VAR_4, int16_t *VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"VLC *ac_vlc;",
"VAR_10 = mjpeg_decode_dc(VAR_0, VAR_3);",
"if (VAR_10 == 0xffff) {",
"dprintf(\"error dc\\n\");",
"return -1;",
"}",
"VAR_10 = VAR_10 * VAR_5[0] + VAR_0->last_dc[VAR_2];",
"VAR_0->last_dc[VAR_2] = VAR_10;",
"VAR_1[0] = VAR_10;",
"ac_vlc = &VAR_0->vlcs[1][VAR_4];",
"VAR_7 = 0;",
"{OPEN_READER(re, &VAR_0->gb)",
"for(;;) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_VLC(VAR_6, re, &VAR_0->gb, VAR_0->vlcs[1][VAR_4].table, 9, 2)\nif (VAR_6 == 0x10)\nbreak;",
"if (VAR_6 == 0x100) {",
"VAR_7 += 16;",
"} else {",
"VAR_7 += ((unsigned)VAR_6) >> 4;",
"VAR_6 &= 0xf;",
"if(VAR_6 > MIN_CACHE_BITS - 16){",
"UPDATE_CACHE(re, &VAR_0->gb)\n}",
"{",
"int cache=GET_CACHE(re,gb);",
"int sign=(~cache)>>31;",
"VAR_9 = (NEG_USR32(sign ^ cache,VAR_6) ^ sign) - sign;",
"}",
"LAST_SKIP_BITS(re, &VAR_0->gb, VAR_6)\nif (VAR_7 >= 63) {",
"if(VAR_7 == 63){",
"VAR_8 = VAR_0->scantable.permutated[63];",
"VAR_1[VAR_8] = VAR_9 * VAR_5[VAR_8];",
"break;",
"}",
"dprintf(\"error count: %d\\n\", VAR_7);",
"return -1;",
"}",
"VAR_8 = VAR_0->scantable.permutated[VAR_7];",
"VAR_1[VAR_8] = VAR_9 * VAR_5[VAR_8];",
"}",
"}",
"CLOSE_READER(re, &VAR_0->gb)}",
"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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
]
] |
24,828 | static int gif_read_image(GifState *s, AVFrame *frame)
{
int left, top, width, height, bits_per_pixel, code_size, flags;
int is_interleaved, has_local_palette, y, pass, y1, linesize, n, i;
uint8_t *ptr, *spal, *palette, *ptr1;
left = bytestream_get_le16(&s->bytestream);
top = bytestream_get_le16(&s->bytestream);
width = bytestream_get_le16(&s->bytestream);
height = bytestream_get_le16(&s->bytestream);
flags = bytestream_get_byte(&s->bytestream);
is_interleaved = flags & 0x40;
has_local_palette = flags & 0x80;
bits_per_pixel = (flags & 0x07) + 1;
av_dlog(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
if (has_local_palette) {
bytestream_get_buffer(&s->bytestream, s->local_palette, 3 * (1 << bits_per_pixel));
palette = s->local_palette;
} else {
palette = s->global_palette;
bits_per_pixel = s->bits_per_pixel;
}
/* verify that all the image is inside the screen dimensions */
if (left + width > s->screen_width ||
top + height > s->screen_height)
return AVERROR(EINVAL);
/* build the palette */
n = (1 << bits_per_pixel);
spal = palette;
for(i = 0; i < n; i++) {
s->image_palette[i] = (0xffu << 24) | AV_RB24(spal);
spal += 3;
}
for(; i < 256; i++)
s->image_palette[i] = (0xffu << 24);
/* handle transparency */
if (s->transparent_color_index >= 0)
s->image_palette[s->transparent_color_index] = 0;
/* now get the image data */
code_size = bytestream_get_byte(&s->bytestream);
ff_lzw_decode_init(s->lzw, code_size, s->bytestream,
s->bytestream_end - s->bytestream, FF_LZW_GIF);
/* read all the image */
linesize = frame->linesize[0];
ptr1 = frame->data[0] + top * linesize + left;
ptr = ptr1;
pass = 0;
y1 = 0;
for (y = 0; y < height; y++) {
ff_lzw_decode(s->lzw, ptr, width);
if (is_interleaved) {
switch(pass) {
default:
case 0:
case 1:
y1 += 8;
ptr += linesize * 8;
if (y1 >= height) {
y1 = pass ? 2 : 4;
ptr = ptr1 + linesize * y1;
pass++;
}
break;
case 2:
y1 += 4;
ptr += linesize * 4;
if (y1 >= height) {
y1 = 1;
ptr = ptr1 + linesize;
pass++;
}
break;
case 3:
y1 += 2;
ptr += linesize * 2;
break;
}
} else {
ptr += linesize;
}
}
/* read the garbage data until end marker is found */
ff_lzw_decode_tail(s->lzw);
s->bytestream = ff_lzw_cur_ptr(s->lzw);
return 0;
}
| false | FFmpeg | c453723ad7d14abc5e82677eebaa6025fa598f08 | static int gif_read_image(GifState *s, AVFrame *frame)
{
int left, top, width, height, bits_per_pixel, code_size, flags;
int is_interleaved, has_local_palette, y, pass, y1, linesize, n, i;
uint8_t *ptr, *spal, *palette, *ptr1;
left = bytestream_get_le16(&s->bytestream);
top = bytestream_get_le16(&s->bytestream);
width = bytestream_get_le16(&s->bytestream);
height = bytestream_get_le16(&s->bytestream);
flags = bytestream_get_byte(&s->bytestream);
is_interleaved = flags & 0x40;
has_local_palette = flags & 0x80;
bits_per_pixel = (flags & 0x07) + 1;
av_dlog(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
if (has_local_palette) {
bytestream_get_buffer(&s->bytestream, s->local_palette, 3 * (1 << bits_per_pixel));
palette = s->local_palette;
} else {
palette = s->global_palette;
bits_per_pixel = s->bits_per_pixel;
}
if (left + width > s->screen_width ||
top + height > s->screen_height)
return AVERROR(EINVAL);
n = (1 << bits_per_pixel);
spal = palette;
for(i = 0; i < n; i++) {
s->image_palette[i] = (0xffu << 24) | AV_RB24(spal);
spal += 3;
}
for(; i < 256; i++)
s->image_palette[i] = (0xffu << 24);
if (s->transparent_color_index >= 0)
s->image_palette[s->transparent_color_index] = 0;
code_size = bytestream_get_byte(&s->bytestream);
ff_lzw_decode_init(s->lzw, code_size, s->bytestream,
s->bytestream_end - s->bytestream, FF_LZW_GIF);
linesize = frame->linesize[0];
ptr1 = frame->data[0] + top * linesize + left;
ptr = ptr1;
pass = 0;
y1 = 0;
for (y = 0; y < height; y++) {
ff_lzw_decode(s->lzw, ptr, width);
if (is_interleaved) {
switch(pass) {
default:
case 0:
case 1:
y1 += 8;
ptr += linesize * 8;
if (y1 >= height) {
y1 = pass ? 2 : 4;
ptr = ptr1 + linesize * y1;
pass++;
}
break;
case 2:
y1 += 4;
ptr += linesize * 4;
if (y1 >= height) {
y1 = 1;
ptr = ptr1 + linesize;
pass++;
}
break;
case 3:
y1 += 2;
ptr += linesize * 2;
break;
}
} else {
ptr += linesize;
}
}
ff_lzw_decode_tail(s->lzw);
s->bytestream = ff_lzw_cur_ptr(s->lzw);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GifState *VAR_0, AVFrame *VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16;
uint8_t *ptr, *spal, *palette, *ptr1;
VAR_2 = bytestream_get_le16(&VAR_0->bytestream);
VAR_3 = bytestream_get_le16(&VAR_0->bytestream);
VAR_4 = bytestream_get_le16(&VAR_0->bytestream);
VAR_5 = bytestream_get_le16(&VAR_0->bytestream);
VAR_8 = bytestream_get_byte(&VAR_0->bytestream);
VAR_9 = VAR_8 & 0x40;
VAR_10 = VAR_8 & 0x80;
VAR_6 = (VAR_8 & 0x07) + 1;
av_dlog(VAR_0->avctx, "gif: image x=%d VAR_11=%d w=%d h=%d\VAR_15", VAR_2, VAR_3, VAR_4, VAR_5);
if (VAR_10) {
bytestream_get_buffer(&VAR_0->bytestream, VAR_0->local_palette, 3 * (1 << VAR_6));
palette = VAR_0->local_palette;
} else {
palette = VAR_0->global_palette;
VAR_6 = VAR_0->VAR_6;
}
if (VAR_2 + VAR_4 > VAR_0->screen_width ||
VAR_3 + VAR_5 > VAR_0->screen_height)
return AVERROR(EINVAL);
VAR_15 = (1 << VAR_6);
spal = palette;
for(VAR_16 = 0; VAR_16 < VAR_15; VAR_16++) {
VAR_0->image_palette[VAR_16] = (0xffu << 24) | AV_RB24(spal);
spal += 3;
}
for(; VAR_16 < 256; VAR_16++)
VAR_0->image_palette[VAR_16] = (0xffu << 24);
if (VAR_0->transparent_color_index >= 0)
VAR_0->image_palette[VAR_0->transparent_color_index] = 0;
VAR_7 = bytestream_get_byte(&VAR_0->bytestream);
ff_lzw_decode_init(VAR_0->lzw, VAR_7, VAR_0->bytestream,
VAR_0->bytestream_end - VAR_0->bytestream, FF_LZW_GIF);
VAR_14 = VAR_1->VAR_14[0];
ptr1 = VAR_1->data[0] + VAR_3 * VAR_14 + VAR_2;
ptr = ptr1;
VAR_12 = 0;
VAR_13 = 0;
for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++) {
ff_lzw_decode(VAR_0->lzw, ptr, VAR_4);
if (VAR_9) {
switch(VAR_12) {
default:
case 0:
case 1:
VAR_13 += 8;
ptr += VAR_14 * 8;
if (VAR_13 >= VAR_5) {
VAR_13 = VAR_12 ? 2 : 4;
ptr = ptr1 + VAR_14 * VAR_13;
VAR_12++;
}
break;
case 2:
VAR_13 += 4;
ptr += VAR_14 * 4;
if (VAR_13 >= VAR_5) {
VAR_13 = 1;
ptr = ptr1 + VAR_14;
VAR_12++;
}
break;
case 3:
VAR_13 += 2;
ptr += VAR_14 * 2;
break;
}
} else {
ptr += VAR_14;
}
}
ff_lzw_decode_tail(VAR_0->lzw);
VAR_0->bytestream = ff_lzw_cur_ptr(VAR_0->lzw);
return 0;
}
| [
"static int FUNC_0(GifState *VAR_0, AVFrame *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16;",
"uint8_t *ptr, *spal, *palette, *ptr1;",
"VAR_2 = bytestream_get_le16(&VAR_0->bytestream);",
"VAR_3 = bytestream_get_le16(&VAR_0->bytestream);",
"VAR_4 = bytestream_get_le16(&VAR_0->bytestream);",
"VAR_5 = bytestream_get_le16(&VAR_0->bytestream);",
"VAR_8 = bytestream_get_byte(&VAR_0->bytestream);",
"VAR_9 = VAR_8 & 0x40;",
"VAR_10 = VAR_8 & 0x80;",
"VAR_6 = (VAR_8 & 0x07) + 1;",
"av_dlog(VAR_0->avctx, \"gif: image x=%d VAR_11=%d w=%d h=%d\\VAR_15\", VAR_2, VAR_3, VAR_4, VAR_5);",
"if (VAR_10) {",
"bytestream_get_buffer(&VAR_0->bytestream, VAR_0->local_palette, 3 * (1 << VAR_6));",
"palette = VAR_0->local_palette;",
"} else {",
"palette = VAR_0->global_palette;",
"VAR_6 = VAR_0->VAR_6;",
"}",
"if (VAR_2 + VAR_4 > VAR_0->screen_width ||\nVAR_3 + VAR_5 > VAR_0->screen_height)\nreturn AVERROR(EINVAL);",
"VAR_15 = (1 << VAR_6);",
"spal = palette;",
"for(VAR_16 = 0; VAR_16 < VAR_15; VAR_16++) {",
"VAR_0->image_palette[VAR_16] = (0xffu << 24) | AV_RB24(spal);",
"spal += 3;",
"}",
"for(; VAR_16 < 256; VAR_16++)",
"VAR_0->image_palette[VAR_16] = (0xffu << 24);",
"if (VAR_0->transparent_color_index >= 0)\nVAR_0->image_palette[VAR_0->transparent_color_index] = 0;",
"VAR_7 = bytestream_get_byte(&VAR_0->bytestream);",
"ff_lzw_decode_init(VAR_0->lzw, VAR_7, VAR_0->bytestream,\nVAR_0->bytestream_end - VAR_0->bytestream, FF_LZW_GIF);",
"VAR_14 = VAR_1->VAR_14[0];",
"ptr1 = VAR_1->data[0] + VAR_3 * VAR_14 + VAR_2;",
"ptr = ptr1;",
"VAR_12 = 0;",
"VAR_13 = 0;",
"for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++) {",
"ff_lzw_decode(VAR_0->lzw, ptr, VAR_4);",
"if (VAR_9) {",
"switch(VAR_12) {",
"default:\ncase 0:\ncase 1:\nVAR_13 += 8;",
"ptr += VAR_14 * 8;",
"if (VAR_13 >= VAR_5) {",
"VAR_13 = VAR_12 ? 2 : 4;",
"ptr = ptr1 + VAR_14 * VAR_13;",
"VAR_12++;",
"}",
"break;",
"case 2:\nVAR_13 += 4;",
"ptr += VAR_14 * 4;",
"if (VAR_13 >= VAR_5) {",
"VAR_13 = 1;",
"ptr = ptr1 + VAR_14;",
"VAR_12++;",
"}",
"break;",
"case 3:\nVAR_13 += 2;",
"ptr += VAR_14 * 2;",
"break;",
"}",
"} else {",
"ptr += VAR_14;",
"}",
"}",
"ff_lzw_decode_tail(VAR_0->lzw);",
"VAR_0->bytestream = ff_lzw_cur_ptr(VAR_0->lzw);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53,
55,
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
89
],
[
91,
93
],
[
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
],
[
177
],
[
179
],
[
181
],
[
183
]
] |
24,831 | static int oss_poll_in (HWVoiceIn *hw)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
}
| true | qemu | b027a538c6790bcfc93ef7f4819fe3e581445959 | static int oss_poll_in (HWVoiceIn *hw)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
}
| {
"code": [
"static int oss_poll_in (HWVoiceIn *hw)",
" return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);"
],
"line_no": [
1,
9
]
} | static int FUNC_0 (HWVoiceIn *VAR_0)
{
OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0;
return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
}
| [
"static int FUNC_0 (HWVoiceIn *VAR_0)\n{",
"OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0;",
"return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);",
"}"
] | [
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
24,832 | static int parse_fade(struct sbg_parser *p, struct sbg_fade *fr)
{
struct sbg_fade f;
if (lex_char(p, '<'))
f.in = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.in = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.in = SBG_FADE_ADAPT;
else
return 0;
if (lex_char(p, '>'))
f.out = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.out = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.out = SBG_FADE_ADAPT;
else
return AVERROR_INVALIDDATA;
*fr = f;
return 1;
}
| true | FFmpeg | e9b8523d52ca84d5012168db24fec2d50e73cf22 | static int parse_fade(struct sbg_parser *p, struct sbg_fade *fr)
{
struct sbg_fade f;
if (lex_char(p, '<'))
f.in = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.in = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.in = SBG_FADE_ADAPT;
else
return 0;
if (lex_char(p, '>'))
f.out = SBG_FADE_SILENCE;
else if (lex_char(p, '-'))
f.out = SBG_FADE_SAME;
else if (lex_char(p, '='))
f.out = SBG_FADE_ADAPT;
else
return AVERROR_INVALIDDATA;
*fr = f;
return 1;
}
| {
"code": [
" struct sbg_fade f;"
],
"line_no": [
5
]
} | static int FUNC_0(struct sbg_parser *VAR_0, struct sbg_fade *VAR_1)
{
struct sbg_fade VAR_2;
if (lex_char(VAR_0, '<'))
VAR_2.in = SBG_FADE_SILENCE;
else if (lex_char(VAR_0, '-'))
VAR_2.in = SBG_FADE_SAME;
else if (lex_char(VAR_0, '='))
VAR_2.in = SBG_FADE_ADAPT;
else
return 0;
if (lex_char(VAR_0, '>'))
VAR_2.out = SBG_FADE_SILENCE;
else if (lex_char(VAR_0, '-'))
VAR_2.out = SBG_FADE_SAME;
else if (lex_char(VAR_0, '='))
VAR_2.out = SBG_FADE_ADAPT;
else
return AVERROR_INVALIDDATA;
*VAR_1 = VAR_2;
return 1;
}
| [
"static int FUNC_0(struct sbg_parser *VAR_0, struct sbg_fade *VAR_1)\n{",
"struct sbg_fade VAR_2;",
"if (lex_char(VAR_0, '<'))\nVAR_2.in = SBG_FADE_SILENCE;",
"else if (lex_char(VAR_0, '-'))\nVAR_2.in = SBG_FADE_SAME;",
"else if (lex_char(VAR_0, '='))\nVAR_2.in = SBG_FADE_ADAPT;",
"else\nreturn 0;",
"if (lex_char(VAR_0, '>'))\nVAR_2.out = SBG_FADE_SILENCE;",
"else if (lex_char(VAR_0, '-'))\nVAR_2.out = SBG_FADE_SAME;",
"else if (lex_char(VAR_0, '='))\nVAR_2.out = SBG_FADE_ADAPT;",
"else\nreturn AVERROR_INVALIDDATA;",
"*VAR_1 = VAR_2;",
"return 1;",
"}"
] | [
0,
1,
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
]
] |
24,833 | void qdev_prop_register_global(GlobalProperty *prop)
{
QTAILQ_INSERT_TAIL(&global_props, prop, next);
}
| true | qemu | f9a8b5530d438f836f9697639814f585aaec554d | void qdev_prop_register_global(GlobalProperty *prop)
{
QTAILQ_INSERT_TAIL(&global_props, prop, next);
}
| {
"code": [
" QTAILQ_INSERT_TAIL(&global_props, prop, next);"
],
"line_no": [
5
]
} | void FUNC_0(GlobalProperty *VAR_0)
{
QTAILQ_INSERT_TAIL(&global_props, VAR_0, next);
}
| [
"void FUNC_0(GlobalProperty *VAR_0)\n{",
"QTAILQ_INSERT_TAIL(&global_props, VAR_0, next);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,834 | int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
const HEVCSPS *sps, int is_slice_header)
{
HEVCLocalContext *lc = s->HEVClc;
uint8_t rps_predict = 0;
int delta_poc;
int k0 = 0;
int k1 = 0;
int k = 0;
int i;
GetBitContext *gb = &lc->gb;
if (rps != sps->st_rps && sps->nb_st_rps)
rps_predict = get_bits1(gb);
if (rps_predict) {
const ShortTermRPS *rps_ridx;
int delta_rps, abs_delta_rps;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (is_slice_header) {
unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
delta_idx, sps->nb_st_rps);
return AVERROR_INVALIDDATA;
}
rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
} else
rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
delta_rps_sign = get_bits1(gb);
abs_delta_rps = get_ue_golomb_long(gb) + 1;
delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
int used = rps->used[k] = get_bits1(gb);
if (!used)
use_delta_flag = get_bits1(gb);
if (used || use_delta_flag) {
if (i < rps_ridx->num_delta_pocs)
delta_poc = delta_rps + rps_ridx->delta_poc[i];
else
delta_poc = delta_rps;
rps->delta_poc[k] = delta_poc;
if (delta_poc < 0)
k0++;
else
k1++;
k++;
}
}
rps->num_delta_pocs = k;
rps->num_negative_pics = k0;
// sort in increasing order (smallest first)
if (rps->num_delta_pocs != 0) {
int used, tmp;
for (i = 1; i < rps->num_delta_pocs; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
for (k = i - 1; k >= 0; k--) {
tmp = rps->delta_poc[k];
if (delta_poc < tmp) {
rps->delta_poc[k + 1] = tmp;
rps->used[k + 1] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
}
}
}
}
if ((rps->num_negative_pics >> 1) != 0) {
int used;
k = rps->num_negative_pics - 1;
// flip the negative values to largest first
for (i = 0; i < rps->num_negative_pics >> 1; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
rps->delta_poc[i] = rps->delta_poc[k];
rps->used[i] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
k--;
}
}
} else {
unsigned int prev, nb_positive_pics;
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
if (rps->num_negative_pics >= MAX_REFS ||
nb_positive_pics >= MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
return AVERROR_INVALIDDATA;
}
rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
if (rps->num_delta_pocs) {
prev = 0;
for (i = 0; i < rps->num_negative_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev -= delta_poc;
rps->delta_poc[i] = prev;
rps->used[i] = get_bits1(gb);
}
prev = 0;
for (i = 0; i < nb_positive_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev += delta_poc;
rps->delta_poc[rps->num_negative_pics + i] = prev;
rps->used[rps->num_negative_pics + i] = get_bits1(gb);
}
}
}
return 0;
}
| true | FFmpeg | d13a731fc149d3fdbe679078479ec1950674e762 | int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
const HEVCSPS *sps, int is_slice_header)
{
HEVCLocalContext *lc = s->HEVClc;
uint8_t rps_predict = 0;
int delta_poc;
int k0 = 0;
int k1 = 0;
int k = 0;
int i;
GetBitContext *gb = &lc->gb;
if (rps != sps->st_rps && sps->nb_st_rps)
rps_predict = get_bits1(gb);
if (rps_predict) {
const ShortTermRPS *rps_ridx;
int delta_rps, abs_delta_rps;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (is_slice_header) {
unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
delta_idx, sps->nb_st_rps);
return AVERROR_INVALIDDATA;
}
rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx];
} else
rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
delta_rps_sign = get_bits1(gb);
abs_delta_rps = get_ue_golomb_long(gb) + 1;
delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
int used = rps->used[k] = get_bits1(gb);
if (!used)
use_delta_flag = get_bits1(gb);
if (used || use_delta_flag) {
if (i < rps_ridx->num_delta_pocs)
delta_poc = delta_rps + rps_ridx->delta_poc[i];
else
delta_poc = delta_rps;
rps->delta_poc[k] = delta_poc;
if (delta_poc < 0)
k0++;
else
k1++;
k++;
}
}
rps->num_delta_pocs = k;
rps->num_negative_pics = k0;
if (rps->num_delta_pocs != 0) {
int used, tmp;
for (i = 1; i < rps->num_delta_pocs; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
for (k = i - 1; k >= 0; k--) {
tmp = rps->delta_poc[k];
if (delta_poc < tmp) {
rps->delta_poc[k + 1] = tmp;
rps->used[k + 1] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
}
}
}
}
if ((rps->num_negative_pics >> 1) != 0) {
int used;
k = rps->num_negative_pics - 1;
for (i = 0; i < rps->num_negative_pics >> 1; i++) {
delta_poc = rps->delta_poc[i];
used = rps->used[i];
rps->delta_poc[i] = rps->delta_poc[k];
rps->used[i] = rps->used[k];
rps->delta_poc[k] = delta_poc;
rps->used[k] = used;
k--;
}
}
} else {
unsigned int prev, nb_positive_pics;
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
if (rps->num_negative_pics >= MAX_REFS ||
nb_positive_pics >= MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
return AVERROR_INVALIDDATA;
}
rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
if (rps->num_delta_pocs) {
prev = 0;
for (i = 0; i < rps->num_negative_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev -= delta_poc;
rps->delta_poc[i] = prev;
rps->used[i] = get_bits1(gb);
}
prev = 0;
for (i = 0; i < nb_positive_pics; i++) {
delta_poc = get_ue_golomb_long(gb) + 1;
prev += delta_poc;
rps->delta_poc[rps->num_negative_pics + i] = prev;
rps->used[rps->num_negative_pics + i] = get_bits1(gb);
}
}
}
return 0;
}
| {
"code": [
" int delta_rps, abs_delta_rps;"
],
"line_no": [
37
]
} | int FUNC_0(HEVCContext *VAR_0, ShortTermRPS *VAR_1,
const HEVCSPS *VAR_2, int VAR_3)
{
HEVCLocalContext *lc = VAR_0->HEVClc;
uint8_t rps_predict = 0;
int VAR_4;
int VAR_5 = 0;
int VAR_6 = 0;
int VAR_7 = 0;
int VAR_8;
GetBitContext *gb = &lc->gb;
if (VAR_1 != VAR_2->st_rps && VAR_2->nb_st_rps)
rps_predict = get_bits1(gb);
if (rps_predict) {
const ShortTermRPS *VAR_9;
int VAR_10, VAR_11;
uint8_t use_delta_flag = 0;
uint8_t delta_rps_sign;
if (VAR_3) {
unsigned int VAR_12 = get_ue_golomb_long(gb) + 1;
if (VAR_12 > VAR_2->nb_st_rps) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid value of VAR_12 in slice header RPS: %d > %d.\n",
VAR_12, VAR_2->nb_st_rps);
return AVERROR_INVALIDDATA;
}
VAR_9 = &VAR_2->st_rps[VAR_2->nb_st_rps - VAR_12];
} else
VAR_9 = &VAR_2->st_rps[VAR_1 - VAR_2->st_rps - 1];
delta_rps_sign = get_bits1(gb);
VAR_11 = get_ue_golomb_long(gb) + 1;
VAR_10 = (1 - (delta_rps_sign << 1)) * VAR_11;
for (VAR_8 = 0; VAR_8 <= VAR_9->num_delta_pocs; VAR_8++) {
int VAR_15 = VAR_1->VAR_15[VAR_7] = get_bits1(gb);
if (!VAR_15)
use_delta_flag = get_bits1(gb);
if (VAR_15 || use_delta_flag) {
if (VAR_8 < VAR_9->num_delta_pocs)
VAR_4 = VAR_10 + VAR_9->VAR_4[VAR_8];
else
VAR_4 = VAR_10;
VAR_1->VAR_4[VAR_7] = VAR_4;
if (VAR_4 < 0)
VAR_5++;
else
VAR_6++;
VAR_7++;
}
}
VAR_1->num_delta_pocs = VAR_7;
VAR_1->num_negative_pics = VAR_5;
if (VAR_1->num_delta_pocs != 0) {
int VAR_15, VAR_14;
for (VAR_8 = 1; VAR_8 < VAR_1->num_delta_pocs; VAR_8++) {
VAR_4 = VAR_1->VAR_4[VAR_8];
VAR_15 = VAR_1->VAR_15[VAR_8];
for (VAR_7 = VAR_8 - 1; VAR_7 >= 0; VAR_7--) {
VAR_14 = VAR_1->VAR_4[VAR_7];
if (VAR_4 < VAR_14) {
VAR_1->VAR_4[VAR_7 + 1] = VAR_14;
VAR_1->VAR_15[VAR_7 + 1] = VAR_1->VAR_15[VAR_7];
VAR_1->VAR_4[VAR_7] = VAR_4;
VAR_1->VAR_15[VAR_7] = VAR_15;
}
}
}
}
if ((VAR_1->num_negative_pics >> 1) != 0) {
int VAR_15;
VAR_7 = VAR_1->num_negative_pics - 1;
for (VAR_8 = 0; VAR_8 < VAR_1->num_negative_pics >> 1; VAR_8++) {
VAR_4 = VAR_1->VAR_4[VAR_8];
VAR_15 = VAR_1->VAR_15[VAR_8];
VAR_1->VAR_4[VAR_8] = VAR_1->VAR_4[VAR_7];
VAR_1->VAR_15[VAR_8] = VAR_1->VAR_15[VAR_7];
VAR_1->VAR_4[VAR_7] = VAR_4;
VAR_1->VAR_15[VAR_7] = VAR_15;
VAR_7--;
}
}
} else {
unsigned int VAR_15, VAR_16;
VAR_1->num_negative_pics = get_ue_golomb_long(gb);
VAR_16 = get_ue_golomb_long(gb);
if (VAR_1->num_negative_pics >= MAX_REFS ||
VAR_16 >= MAX_REFS) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
return AVERROR_INVALIDDATA;
}
VAR_1->num_delta_pocs = VAR_1->num_negative_pics + VAR_16;
if (VAR_1->num_delta_pocs) {
VAR_15 = 0;
for (VAR_8 = 0; VAR_8 < VAR_1->num_negative_pics; VAR_8++) {
VAR_4 = get_ue_golomb_long(gb) + 1;
VAR_15 -= VAR_4;
VAR_1->VAR_4[VAR_8] = VAR_15;
VAR_1->VAR_15[VAR_8] = get_bits1(gb);
}
VAR_15 = 0;
for (VAR_8 = 0; VAR_8 < VAR_16; VAR_8++) {
VAR_4 = get_ue_golomb_long(gb) + 1;
VAR_15 += VAR_4;
VAR_1->VAR_4[VAR_1->num_negative_pics + VAR_8] = VAR_15;
VAR_1->VAR_15[VAR_1->num_negative_pics + VAR_8] = get_bits1(gb);
}
}
}
return 0;
}
| [
"int FUNC_0(HEVCContext *VAR_0, ShortTermRPS *VAR_1,\nconst HEVCSPS *VAR_2, int VAR_3)\n{",
"HEVCLocalContext *lc = VAR_0->HEVClc;",
"uint8_t rps_predict = 0;",
"int VAR_4;",
"int VAR_5 = 0;",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"int VAR_8;",
"GetBitContext *gb = &lc->gb;",
"if (VAR_1 != VAR_2->st_rps && VAR_2->nb_st_rps)\nrps_predict = get_bits1(gb);",
"if (rps_predict) {",
"const ShortTermRPS *VAR_9;",
"int VAR_10, VAR_11;",
"uint8_t use_delta_flag = 0;",
"uint8_t delta_rps_sign;",
"if (VAR_3) {",
"unsigned int VAR_12 = get_ue_golomb_long(gb) + 1;",
"if (VAR_12 > VAR_2->nb_st_rps) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid value of VAR_12 in slice header RPS: %d > %d.\\n\",\nVAR_12, VAR_2->nb_st_rps);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = &VAR_2->st_rps[VAR_2->nb_st_rps - VAR_12];",
"} else",
"VAR_9 = &VAR_2->st_rps[VAR_1 - VAR_2->st_rps - 1];",
"delta_rps_sign = get_bits1(gb);",
"VAR_11 = get_ue_golomb_long(gb) + 1;",
"VAR_10 = (1 - (delta_rps_sign << 1)) * VAR_11;",
"for (VAR_8 = 0; VAR_8 <= VAR_9->num_delta_pocs; VAR_8++) {",
"int VAR_15 = VAR_1->VAR_15[VAR_7] = get_bits1(gb);",
"if (!VAR_15)\nuse_delta_flag = get_bits1(gb);",
"if (VAR_15 || use_delta_flag) {",
"if (VAR_8 < VAR_9->num_delta_pocs)\nVAR_4 = VAR_10 + VAR_9->VAR_4[VAR_8];",
"else\nVAR_4 = VAR_10;",
"VAR_1->VAR_4[VAR_7] = VAR_4;",
"if (VAR_4 < 0)\nVAR_5++;",
"else\nVAR_6++;",
"VAR_7++;",
"}",
"}",
"VAR_1->num_delta_pocs = VAR_7;",
"VAR_1->num_negative_pics = VAR_5;",
"if (VAR_1->num_delta_pocs != 0) {",
"int VAR_15, VAR_14;",
"for (VAR_8 = 1; VAR_8 < VAR_1->num_delta_pocs; VAR_8++) {",
"VAR_4 = VAR_1->VAR_4[VAR_8];",
"VAR_15 = VAR_1->VAR_15[VAR_8];",
"for (VAR_7 = VAR_8 - 1; VAR_7 >= 0; VAR_7--) {",
"VAR_14 = VAR_1->VAR_4[VAR_7];",
"if (VAR_4 < VAR_14) {",
"VAR_1->VAR_4[VAR_7 + 1] = VAR_14;",
"VAR_1->VAR_15[VAR_7 + 1] = VAR_1->VAR_15[VAR_7];",
"VAR_1->VAR_4[VAR_7] = VAR_4;",
"VAR_1->VAR_15[VAR_7] = VAR_15;",
"}",
"}",
"}",
"}",
"if ((VAR_1->num_negative_pics >> 1) != 0) {",
"int VAR_15;",
"VAR_7 = VAR_1->num_negative_pics - 1;",
"for (VAR_8 = 0; VAR_8 < VAR_1->num_negative_pics >> 1; VAR_8++) {",
"VAR_4 = VAR_1->VAR_4[VAR_8];",
"VAR_15 = VAR_1->VAR_15[VAR_8];",
"VAR_1->VAR_4[VAR_8] = VAR_1->VAR_4[VAR_7];",
"VAR_1->VAR_15[VAR_8] = VAR_1->VAR_15[VAR_7];",
"VAR_1->VAR_4[VAR_7] = VAR_4;",
"VAR_1->VAR_15[VAR_7] = VAR_15;",
"VAR_7--;",
"}",
"}",
"} else {",
"unsigned int VAR_15, VAR_16;",
"VAR_1->num_negative_pics = get_ue_golomb_long(gb);",
"VAR_16 = get_ue_golomb_long(gb);",
"if (VAR_1->num_negative_pics >= MAX_REFS ||\nVAR_16 >= MAX_REFS) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Too many refs in a short term RPS.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_1->num_delta_pocs = VAR_1->num_negative_pics + VAR_16;",
"if (VAR_1->num_delta_pocs) {",
"VAR_15 = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_1->num_negative_pics; VAR_8++) {",
"VAR_4 = get_ue_golomb_long(gb) + 1;",
"VAR_15 -= VAR_4;",
"VAR_1->VAR_4[VAR_8] = VAR_15;",
"VAR_1->VAR_15[VAR_8] = get_bits1(gb);",
"}",
"VAR_15 = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_16; VAR_8++) {",
"VAR_4 = get_ue_golomb_long(gb) + 1;",
"VAR_15 += VAR_4;",
"VAR_1->VAR_4[VAR_1->num_negative_pics + VAR_8] = VAR_15;",
"VAR_1->VAR_15[VAR_1->num_negative_pics + VAR_8] = get_bits1(gb);",
"}",
"}",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99,
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
]
] |
24,835 | iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsilun->iscsi, sector_num, nb_sectors, opaque, acb);
acb->nb_sectors = nb_sectors;
acb->sector_num = sector_num;
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_readv_acb(acb) != 0) {
qemu_aio_release(acb);
iscsi_set_events(iscsilun);
return &acb->common; | true | qemu | 91bea4e2bb1a5f7954a3b3a4f2e28e96bd25c458 | iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsilun->iscsi, sector_num, nb_sectors, opaque, acb);
acb->nb_sectors = nb_sectors;
acb->sector_num = sector_num;
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_readv_acb(acb) != 0) {
qemu_aio_release(acb);
iscsi_set_events(iscsilun);
return &acb->common; | {
"code": [],
"line_no": []
} | FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
QEMUIOVector *VAR_2, int VAR_3,
BlockDriverCompletionFunc *VAR_4,
void *VAR_5)
{
IscsiLun *iscsilun = VAR_0->VAR_5;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);
trace_iscsi_aio_readv(iscsilun->iscsi, VAR_1, VAR_3, VAR_5, acb);
acb->VAR_3 = VAR_3;
acb->VAR_1 = VAR_1;
acb->iscsilun = iscsilun;
acb->VAR_2 = VAR_2;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_readv_acb(acb) != 0) {
qemu_aio_release(acb);
iscsi_set_events(iscsilun);
return &acb->common; | [
"FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nQEMUIOVector *VAR_2, int VAR_3,\nBlockDriverCompletionFunc *VAR_4,\nvoid *VAR_5)\n{",
"IscsiLun *iscsilun = VAR_0->VAR_5;",
"IscsiAIOCB *acb;",
"acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);",
"trace_iscsi_aio_readv(iscsilun->iscsi, VAR_1, VAR_3, VAR_5, acb);",
"acb->VAR_3 = VAR_3;",
"acb->VAR_1 = VAR_1;",
"acb->iscsilun = iscsilun;",
"acb->VAR_2 = VAR_2;",
"acb->retries = ISCSI_CMD_RETRIES;",
"if (iscsi_aio_readv_acb(acb) != 0) {",
"qemu_aio_release(acb);",
"iscsi_set_events(iscsilun);",
"return &acb->common;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
]
] |
24,836 | static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
QemuConsole *con, int idx,
GSList *group, GtkWidget *view_menu)
{
Error *local_err = NULL;
Object *obj;
obj = object_property_get_link(OBJECT(con), "device", &local_err);
if (obj) {
vc->label = g_strdup_printf("%s", object_get_typename(obj));
} else {
vc->label = g_strdup_printf("VGA");
}
vc->s = s;
vc->gfx.scale_x = 1.0;
vc->gfx.scale_y = 1.0;
vc->gfx.drawing_area = gtk_drawing_area_new();
gtk_widget_add_events(vc->gfx.drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE);
vc->type = GD_VC_GFX;
vc->tab_item = vc->gfx.drawing_area;
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
vc->tab_item, gtk_label_new(vc->label));
gd_connect_vc_gfx_signals(vc);
group = gd_vc_menu_init(s, vc, idx, group, view_menu);
vc->gfx.dcl.ops = &dcl_ops;
vc->gfx.dcl.con = con;
register_displaychangelistener(&vc->gfx.dcl);
return group;
}
| true | qemu | 8a0f9b5263bb3a96d574ca78ad3b8f1d7bf8b12b | static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
QemuConsole *con, int idx,
GSList *group, GtkWidget *view_menu)
{
Error *local_err = NULL;
Object *obj;
obj = object_property_get_link(OBJECT(con), "device", &local_err);
if (obj) {
vc->label = g_strdup_printf("%s", object_get_typename(obj));
} else {
vc->label = g_strdup_printf("VGA");
}
vc->s = s;
vc->gfx.scale_x = 1.0;
vc->gfx.scale_y = 1.0;
vc->gfx.drawing_area = gtk_drawing_area_new();
gtk_widget_add_events(vc->gfx.drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE);
vc->type = GD_VC_GFX;
vc->tab_item = vc->gfx.drawing_area;
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
vc->tab_item, gtk_label_new(vc->label));
gd_connect_vc_gfx_signals(vc);
group = gd_vc_menu_init(s, vc, idx, group, view_menu);
vc->gfx.dcl.ops = &dcl_ops;
vc->gfx.dcl.con = con;
register_displaychangelistener(&vc->gfx.dcl);
return group;
}
| {
"code": [
" Error *local_err = NULL;",
" obj = object_property_get_link(OBJECT(con), \"device\", &local_err);"
],
"line_no": [
9,
15
]
} | static GSList *FUNC_0(GtkDisplayState *s, VirtualConsole *vc,
QemuConsole *con, int idx,
GSList *group, GtkWidget *view_menu)
{
Error *local_err = NULL;
Object *obj;
obj = object_property_get_link(OBJECT(con), "device", &local_err);
if (obj) {
vc->label = g_strdup_printf("%s", object_get_typename(obj));
} else {
vc->label = g_strdup_printf("VGA");
}
vc->s = s;
vc->gfx.scale_x = 1.0;
vc->gfx.scale_y = 1.0;
vc->gfx.drawing_area = gtk_drawing_area_new();
gtk_widget_add_events(vc->gfx.drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE);
vc->type = GD_VC_GFX;
vc->tab_item = vc->gfx.drawing_area;
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
vc->tab_item, gtk_label_new(vc->label));
gd_connect_vc_gfx_signals(vc);
group = gd_vc_menu_init(s, vc, idx, group, view_menu);
vc->gfx.dcl.ops = &dcl_ops;
vc->gfx.dcl.con = con;
register_displaychangelistener(&vc->gfx.dcl);
return group;
}
| [
"static GSList *FUNC_0(GtkDisplayState *s, VirtualConsole *vc,\nQemuConsole *con, int idx,\nGSList *group, GtkWidget *view_menu)\n{",
"Error *local_err = NULL;",
"Object *obj;",
"obj = object_property_get_link(OBJECT(con), \"device\", &local_err);",
"if (obj) {",
"vc->label = g_strdup_printf(\"%s\", object_get_typename(obj));",
"} else {",
"vc->label = g_strdup_printf(\"VGA\");",
"}",
"vc->s = s;",
"vc->gfx.scale_x = 1.0;",
"vc->gfx.scale_y = 1.0;",
"vc->gfx.drawing_area = gtk_drawing_area_new();",
"gtk_widget_add_events(vc->gfx.drawing_area,\nGDK_POINTER_MOTION_MASK |\nGDK_BUTTON_PRESS_MASK |\nGDK_BUTTON_RELEASE_MASK |\nGDK_BUTTON_MOTION_MASK |\nGDK_ENTER_NOTIFY_MASK |\nGDK_LEAVE_NOTIFY_MASK |\nGDK_SCROLL_MASK |\nGDK_KEY_PRESS_MASK);",
"gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE);",
"vc->type = GD_VC_GFX;",
"vc->tab_item = vc->gfx.drawing_area;",
"gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),\nvc->tab_item, gtk_label_new(vc->label));",
"gd_connect_vc_gfx_signals(vc);",
"group = gd_vc_menu_init(s, vc, idx, group, view_menu);",
"vc->gfx.dcl.ops = &dcl_ops;",
"vc->gfx.dcl.con = con;",
"register_displaychangelistener(&vc->gfx.dcl);",
"return group;",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41,
43,
45,
47,
49,
51,
53,
55
],
[
57
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
24,837 | int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
{
int port;
const char *p;
char buf[200], opts[50] = "";
struct addrinfo hints = { 0 }, *ai = NULL;
const char *proxy_path;
int use_proxy;
set_options(c, uri);
if (c->listen)
snprintf(opts, sizeof(opts), "?listen=1");
av_url_split(NULL, 0, NULL, 0, c->host, sizeof(c->host), &port, NULL, 0, uri);
p = strchr(uri, '?');
if (!p) {
p = opts;
} else {
if (av_find_info_tag(opts, sizeof(opts), "listen", p))
c->listen = 1;
}
ff_url_join(buf, sizeof(buf), "tcp", NULL, c->host, port, "%s", p);
hints.ai_flags = AI_NUMERICHOST;
if (!getaddrinfo(c->host, NULL, &hints, &ai)) {
c->numerichost = 1;
freeaddrinfo(ai);
}
proxy_path = getenv("http_proxy");
use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), c->host) &&
proxy_path && av_strstart(proxy_path, "http://", NULL);
if (use_proxy) {
char proxy_host[200], proxy_auth[200], dest[200];
int proxy_port;
av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),
proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,
proxy_path);
ff_url_join(dest, sizeof(dest), NULL, NULL, c->host, port, NULL);
ff_url_join(buf, sizeof(buf), "httpproxy", proxy_auth, proxy_host,
proxy_port, "/%s", dest);
}
return ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE,
&parent->interrupt_callback, options);
}
| true | FFmpeg | 6dd5371e34c6602591766f73aa647b369d77853b | int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
{
int port;
const char *p;
char buf[200], opts[50] = "";
struct addrinfo hints = { 0 }, *ai = NULL;
const char *proxy_path;
int use_proxy;
set_options(c, uri);
if (c->listen)
snprintf(opts, sizeof(opts), "?listen=1");
av_url_split(NULL, 0, NULL, 0, c->host, sizeof(c->host), &port, NULL, 0, uri);
p = strchr(uri, '?');
if (!p) {
p = opts;
} else {
if (av_find_info_tag(opts, sizeof(opts), "listen", p))
c->listen = 1;
}
ff_url_join(buf, sizeof(buf), "tcp", NULL, c->host, port, "%s", p);
hints.ai_flags = AI_NUMERICHOST;
if (!getaddrinfo(c->host, NULL, &hints, &ai)) {
c->numerichost = 1;
freeaddrinfo(ai);
}
proxy_path = getenv("http_proxy");
use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), c->host) &&
proxy_path && av_strstart(proxy_path, "http:
if (use_proxy) {
char proxy_host[200], proxy_auth[200], dest[200];
int proxy_port;
av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),
proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,
proxy_path);
ff_url_join(dest, sizeof(dest), NULL, NULL, c->host, port, NULL);
ff_url_join(buf, sizeof(buf), "httpproxy", proxy_auth, proxy_host,
proxy_port, "/%s", dest);
}
return ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE,
&parent->interrupt_callback, options);
}
| {
"code": [
" av_url_split(NULL, 0, NULL, 0, c->host, sizeof(c->host), &port, NULL, 0, uri);",
" ff_url_join(buf, sizeof(buf), \"tcp\", NULL, c->host, port, \"%s\", p);",
" if (!getaddrinfo(c->host, NULL, &hints, &ai)) {",
" use_proxy = !ff_http_match_no_proxy(getenv(\"no_proxy\"), c->host) &&",
" ff_url_join(dest, sizeof(dest), NULL, NULL, c->host, port, NULL);"
],
"line_no": [
29,
51,
57,
69,
87
]
} | int FUNC_0(TLSShared *VAR_0, URLContext *VAR_1, const char *VAR_2, AVDictionary **VAR_3)
{
int VAR_4;
const char *VAR_5;
char VAR_6[200], VAR_7[50] = "";
struct addrinfo VAR_8 = { 0 }, *VAR_9 = NULL;
const char *VAR_10;
int VAR_11;
set_options(VAR_0, VAR_2);
if (VAR_0->listen)
snprintf(VAR_7, sizeof(VAR_7), "?listen=1");
av_url_split(NULL, 0, NULL, 0, VAR_0->host, sizeof(VAR_0->host), &VAR_4, NULL, 0, VAR_2);
VAR_5 = strchr(VAR_2, '?');
if (!VAR_5) {
VAR_5 = VAR_7;
} else {
if (av_find_info_tag(VAR_7, sizeof(VAR_7), "listen", VAR_5))
VAR_0->listen = 1;
}
ff_url_join(VAR_6, sizeof(VAR_6), "tcp", NULL, VAR_0->host, VAR_4, "%s", VAR_5);
VAR_8.ai_flags = AI_NUMERICHOST;
if (!getaddrinfo(VAR_0->host, NULL, &VAR_8, &VAR_9)) {
VAR_0->numerichost = 1;
freeaddrinfo(VAR_9);
}
VAR_10 = getenv("http_proxy");
VAR_11 = !ff_http_match_no_proxy(getenv("no_proxy"), VAR_0->host) &&
VAR_10 && av_strstart(VAR_10, "http:
if (VAR_11) {
char proxy_host[200], proxy_auth[200], dest[200];
int proxy_port;
av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),
proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,
VAR_10);
ff_url_join(dest, sizeof(dest), NULL, NULL, VAR_0->host, VAR_4, NULL);
ff_url_join(VAR_6, sizeof(VAR_6), "httpproxy", proxy_auth, proxy_host,
proxy_port, "/%s", dest);
}
return ffurl_open(&VAR_0->tcp, VAR_6, AVIO_FLAG_READ_WRITE,
&VAR_1->interrupt_callback, VAR_3);
}
| [
"int FUNC_0(TLSShared *VAR_0, URLContext *VAR_1, const char *VAR_2, AVDictionary **VAR_3)\n{",
"int VAR_4;",
"const char *VAR_5;",
"char VAR_6[200], VAR_7[50] = \"\";",
"struct addrinfo VAR_8 = { 0 }, *VAR_9 = NULL;",
"const char *VAR_10;",
"int VAR_11;",
"set_options(VAR_0, VAR_2);",
"if (VAR_0->listen)\nsnprintf(VAR_7, sizeof(VAR_7), \"?listen=1\");",
"av_url_split(NULL, 0, NULL, 0, VAR_0->host, sizeof(VAR_0->host), &VAR_4, NULL, 0, VAR_2);",
"VAR_5 = strchr(VAR_2, '?');",
"if (!VAR_5) {",
"VAR_5 = VAR_7;",
"} else {",
"if (av_find_info_tag(VAR_7, sizeof(VAR_7), \"listen\", VAR_5))\nVAR_0->listen = 1;",
"}",
"ff_url_join(VAR_6, sizeof(VAR_6), \"tcp\", NULL, VAR_0->host, VAR_4, \"%s\", VAR_5);",
"VAR_8.ai_flags = AI_NUMERICHOST;",
"if (!getaddrinfo(VAR_0->host, NULL, &VAR_8, &VAR_9)) {",
"VAR_0->numerichost = 1;",
"freeaddrinfo(VAR_9);",
"}",
"VAR_10 = getenv(\"http_proxy\");",
"VAR_11 = !ff_http_match_no_proxy(getenv(\"no_proxy\"), VAR_0->host) &&\nVAR_10 && av_strstart(VAR_10, \"http:\nif (VAR_11) {",
"char proxy_host[200], proxy_auth[200], dest[200];",
"int proxy_port;",
"av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),\nproxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,\nVAR_10);",
"ff_url_join(dest, sizeof(dest), NULL, NULL, VAR_0->host, VAR_4, NULL);",
"ff_url_join(VAR_6, sizeof(VAR_6), \"httpproxy\", proxy_auth, proxy_host,\nproxy_port, \"/%s\", dest);",
"}",
"return ffurl_open(&VAR_0->tcp, VAR_6, AVIO_FLAG_READ_WRITE,\n&VAR_1->interrupt_callback, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71,
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
97,
99
],
[
101
]
] |
24,838 | static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)
{
static int apic_mapped;
CPUX86State *env = &cpu->env;
APICCommonState *apic;
const char *apic_type = "apic";
if (kvm_irqchip_in_kernel()) {
apic_type = "kvm-apic";
} else if (xen_enabled()) {
apic_type = "xen-apic";
}
env->apic_state = qdev_try_create(NULL, apic_type);
if (env->apic_state == NULL) {
error_setg(errp, "APIC device '%s' could not be created", apic_type);
return;
}
object_property_add_child(OBJECT(cpu), "apic",
OBJECT(env->apic_state), NULL);
qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
/* TODO: convert to link<> */
apic = APIC_COMMON(env->apic_state);
apic->cpu = cpu;
if (qdev_init(env->apic_state)) {
error_setg(errp, "APIC device '%s' could not be initialized",
object_get_typename(OBJECT(env->apic_state)));
return;
}
/* XXX: mapping more APICs at the same memory location */
if (apic_mapped == 0) {
/* NOTE: the APIC is directly connected to the CPU - it is not
on the global memory bus. */
/* XXX: what if the base changes? */
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(env->apic_state), 0,
APIC_DEFAULT_ADDRESS, 0x1000);
apic_mapped = 1;
}
}
| true | qemu | d3c64d6a1874f94246af91963927fb4d924332f1 | static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)
{
static int apic_mapped;
CPUX86State *env = &cpu->env;
APICCommonState *apic;
const char *apic_type = "apic";
if (kvm_irqchip_in_kernel()) {
apic_type = "kvm-apic";
} else if (xen_enabled()) {
apic_type = "xen-apic";
}
env->apic_state = qdev_try_create(NULL, apic_type);
if (env->apic_state == NULL) {
error_setg(errp, "APIC device '%s' could not be created", apic_type);
return;
}
object_property_add_child(OBJECT(cpu), "apic",
OBJECT(env->apic_state), NULL);
qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
apic = APIC_COMMON(env->apic_state);
apic->cpu = cpu;
if (qdev_init(env->apic_state)) {
error_setg(errp, "APIC device '%s' could not be initialized",
object_get_typename(OBJECT(env->apic_state)));
return;
}
if (apic_mapped == 0) {
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(env->apic_state), 0,
APIC_DEFAULT_ADDRESS, 0x1000);
apic_mapped = 1;
}
}
| {
"code": [
"static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)",
" static int apic_mapped;"
],
"line_no": [
1,
5
]
} | static void FUNC_0(X86CPU *VAR_0, Error **VAR_1)
{
static int VAR_2;
CPUX86State *env = &VAR_0->env;
APICCommonState *apic;
const char *VAR_3 = "apic";
if (kvm_irqchip_in_kernel()) {
VAR_3 = "kvm-apic";
} else if (xen_enabled()) {
VAR_3 = "xen-apic";
}
env->apic_state = qdev_try_create(NULL, VAR_3);
if (env->apic_state == NULL) {
error_setg(VAR_1, "APIC device '%s' could not be created", VAR_3);
return;
}
object_property_add_child(OBJECT(VAR_0), "apic",
OBJECT(env->apic_state), NULL);
qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
apic = APIC_COMMON(env->apic_state);
apic->VAR_0 = VAR_0;
if (qdev_init(env->apic_state)) {
error_setg(VAR_1, "APIC device '%s' could not be initialized",
object_get_typename(OBJECT(env->apic_state)));
return;
}
if (VAR_2 == 0) {
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(env->apic_state), 0,
APIC_DEFAULT_ADDRESS, 0x1000);
VAR_2 = 1;
}
}
| [
"static void FUNC_0(X86CPU *VAR_0, Error **VAR_1)\n{",
"static int VAR_2;",
"CPUX86State *env = &VAR_0->env;",
"APICCommonState *apic;",
"const char *VAR_3 = \"apic\";",
"if (kvm_irqchip_in_kernel()) {",
"VAR_3 = \"kvm-apic\";",
"} else if (xen_enabled()) {",
"VAR_3 = \"xen-apic\";",
"}",
"env->apic_state = qdev_try_create(NULL, VAR_3);",
"if (env->apic_state == NULL) {",
"error_setg(VAR_1, \"APIC device '%s' could not be created\", VAR_3);",
"return;",
"}",
"object_property_add_child(OBJECT(VAR_0), \"apic\",\nOBJECT(env->apic_state), NULL);",
"qdev_prop_set_uint8(env->apic_state, \"id\", env->cpuid_apic_id);",
"apic = APIC_COMMON(env->apic_state);",
"apic->VAR_0 = VAR_0;",
"if (qdev_init(env->apic_state)) {",
"error_setg(VAR_1, \"APIC device '%s' could not be initialized\",\nobject_get_typename(OBJECT(env->apic_state)));",
"return;",
"}",
"if (VAR_2 == 0) {",
"sysbus_mmio_map_overlap(SYS_BUS_DEVICE(env->apic_state), 0,\nAPIC_DEFAULT_ADDRESS, 0x1000);",
"VAR_2 = 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
67
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
] |
24,839 | static inline int clamp(int value, int min, int max)
{
if (value < min)
return min;
else if (value > max)
return max;
else
return value;
}
| false | FFmpeg | eb5b0422b595d488f5c2f2a37a62cd46dfbb6aa7 | static inline int clamp(int value, int min, int max)
{
if (value < min)
return min;
else if (value > max)
return max;
else
return value;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(int VAR_0, int VAR_1, int VAR_2)
{
if (VAR_0 < VAR_1)
return VAR_1;
else if (VAR_0 > VAR_2)
return VAR_2;
else
return VAR_0;
}
| [
"static inline int FUNC_0(int VAR_0, int VAR_1, int VAR_2)\n{",
"if (VAR_0 < VAR_1)\nreturn VAR_1;",
"else if (VAR_0 > VAR_2)\nreturn VAR_2;",
"else\nreturn VAR_0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
],
[
17
]
] |
24,840 | void audio_init(ISABus *isa_bus, PCIBus *pci_bus)
{
}
| false | qemu | ffa48cf5ab719e1e181e51b87bc0f5d397b791fa | void audio_init(ISABus *isa_bus, PCIBus *pci_bus)
{
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ISABus *VAR_0, PCIBus *VAR_1)
{
}
| [
"void FUNC_0(ISABus *VAR_0, PCIBus *VAR_1)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
5
]
] |
24,841 | static void nand_command(NANDFlashState *s)
{
unsigned int offset;
switch (s->cmd) {
case NAND_CMD_READ0:
s->iolen = 0;
break;
case NAND_CMD_READID:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->manf_id);
nand_pushio_byte(s, s->chip_id);
nand_pushio_byte(s, 'Q'); /* Don't-care byte (often 0xa5) */
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {
/* Page Size, Block Size, Spare Size; bit 6 indicates
* 8 vs 16 bit width NAND.
*/
nand_pushio_byte(s, (s->buswidth == 2) ? 0x55 : 0x15);
} else {
nand_pushio_byte(s, 0xc0); /* Multi-plane */
}
break;
case NAND_CMD_RANDOMREAD2:
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
break;
offset = s->addr & ((1 << s->addr_shift) - 1);
s->blk_load(s, s->addr, offset);
if (s->gnd)
s->iolen = (1 << s->page_shift) - offset;
else
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
break;
case NAND_CMD_RESET:
nand_reset(DEVICE(s));
break;
case NAND_CMD_PAGEPROGRAM1:
s->ioaddr = s->io;
s->iolen = 0;
break;
case NAND_CMD_PAGEPROGRAM2:
if (s->wp) {
s->blk_write(s);
}
break;
case NAND_CMD_BLOCKERASE1:
break;
case NAND_CMD_BLOCKERASE2:
s->addr &= (1ull << s->addrlen * 8) - 1;
s->addr <<= nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP ?
16 : 8;
if (s->wp) {
s->blk_erase(s);
}
break;
case NAND_CMD_READSTATUS:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->status);
break;
default:
printf("%s: Unknown NAND command 0x%02x\n", __FUNCTION__, s->cmd);
}
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void nand_command(NANDFlashState *s)
{
unsigned int offset;
switch (s->cmd) {
case NAND_CMD_READ0:
s->iolen = 0;
break;
case NAND_CMD_READID:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->manf_id);
nand_pushio_byte(s, s->chip_id);
nand_pushio_byte(s, 'Q');
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {
nand_pushio_byte(s, (s->buswidth == 2) ? 0x55 : 0x15);
} else {
nand_pushio_byte(s, 0xc0);
}
break;
case NAND_CMD_RANDOMREAD2:
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
break;
offset = s->addr & ((1 << s->addr_shift) - 1);
s->blk_load(s, s->addr, offset);
if (s->gnd)
s->iolen = (1 << s->page_shift) - offset;
else
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
break;
case NAND_CMD_RESET:
nand_reset(DEVICE(s));
break;
case NAND_CMD_PAGEPROGRAM1:
s->ioaddr = s->io;
s->iolen = 0;
break;
case NAND_CMD_PAGEPROGRAM2:
if (s->wp) {
s->blk_write(s);
}
break;
case NAND_CMD_BLOCKERASE1:
break;
case NAND_CMD_BLOCKERASE2:
s->addr &= (1ull << s->addrlen * 8) - 1;
s->addr <<= nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP ?
16 : 8;
if (s->wp) {
s->blk_erase(s);
}
break;
case NAND_CMD_READSTATUS:
s->ioaddr = s->io;
s->iolen = 0;
nand_pushio_byte(s, s->status);
break;
default:
printf("%s: Unknown NAND command 0x%02x\n", __FUNCTION__, s->cmd);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NANDFlashState *VAR_0)
{
unsigned int VAR_1;
switch (VAR_0->cmd) {
case NAND_CMD_READ0:
VAR_0->iolen = 0;
break;
case NAND_CMD_READID:
VAR_0->ioaddr = VAR_0->io;
VAR_0->iolen = 0;
nand_pushio_byte(VAR_0, VAR_0->manf_id);
nand_pushio_byte(VAR_0, VAR_0->chip_id);
nand_pushio_byte(VAR_0, 'Q');
if (nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP) {
nand_pushio_byte(VAR_0, (VAR_0->buswidth == 2) ? 0x55 : 0x15);
} else {
nand_pushio_byte(VAR_0, 0xc0);
}
break;
case NAND_CMD_RANDOMREAD2:
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP))
break;
VAR_1 = VAR_0->addr & ((1 << VAR_0->addr_shift) - 1);
VAR_0->blk_load(VAR_0, VAR_0->addr, VAR_1);
if (VAR_0->gnd)
VAR_0->iolen = (1 << VAR_0->page_shift) - VAR_1;
else
VAR_0->iolen = (1 << VAR_0->page_shift) + (1 << VAR_0->oob_shift) - VAR_1;
break;
case NAND_CMD_RESET:
nand_reset(DEVICE(VAR_0));
break;
case NAND_CMD_PAGEPROGRAM1:
VAR_0->ioaddr = VAR_0->io;
VAR_0->iolen = 0;
break;
case NAND_CMD_PAGEPROGRAM2:
if (VAR_0->wp) {
VAR_0->blk_write(VAR_0);
}
break;
case NAND_CMD_BLOCKERASE1:
break;
case NAND_CMD_BLOCKERASE2:
VAR_0->addr &= (1ull << VAR_0->addrlen * 8) - 1;
VAR_0->addr <<= nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP ?
16 : 8;
if (VAR_0->wp) {
VAR_0->blk_erase(VAR_0);
}
break;
case NAND_CMD_READSTATUS:
VAR_0->ioaddr = VAR_0->io;
VAR_0->iolen = 0;
nand_pushio_byte(VAR_0, VAR_0->status);
break;
default:
printf("%VAR_0: Unknown NAND command 0x%02x\n", __FUNCTION__, VAR_0->cmd);
}
}
| [
"static void FUNC_0(NANDFlashState *VAR_0)\n{",
"unsigned int VAR_1;",
"switch (VAR_0->cmd) {",
"case NAND_CMD_READ0:\nVAR_0->iolen = 0;",
"break;",
"case NAND_CMD_READID:\nVAR_0->ioaddr = VAR_0->io;",
"VAR_0->iolen = 0;",
"nand_pushio_byte(VAR_0, VAR_0->manf_id);",
"nand_pushio_byte(VAR_0, VAR_0->chip_id);",
"nand_pushio_byte(VAR_0, 'Q');",
"if (nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP) {",
"nand_pushio_byte(VAR_0, (VAR_0->buswidth == 2) ? 0x55 : 0x15);",
"} else {",
"nand_pushio_byte(VAR_0, 0xc0);",
"}",
"break;",
"case NAND_CMD_RANDOMREAD2:\ncase NAND_CMD_NOSERIALREAD2:\nif (!(nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP))\nbreak;",
"VAR_1 = VAR_0->addr & ((1 << VAR_0->addr_shift) - 1);",
"VAR_0->blk_load(VAR_0, VAR_0->addr, VAR_1);",
"if (VAR_0->gnd)\nVAR_0->iolen = (1 << VAR_0->page_shift) - VAR_1;",
"else\nVAR_0->iolen = (1 << VAR_0->page_shift) + (1 << VAR_0->oob_shift) - VAR_1;",
"break;",
"case NAND_CMD_RESET:\nnand_reset(DEVICE(VAR_0));",
"break;",
"case NAND_CMD_PAGEPROGRAM1:\nVAR_0->ioaddr = VAR_0->io;",
"VAR_0->iolen = 0;",
"break;",
"case NAND_CMD_PAGEPROGRAM2:\nif (VAR_0->wp) {",
"VAR_0->blk_write(VAR_0);",
"}",
"break;",
"case NAND_CMD_BLOCKERASE1:\nbreak;",
"case NAND_CMD_BLOCKERASE2:\nVAR_0->addr &= (1ull << VAR_0->addrlen * 8) - 1;",
"VAR_0->addr <<= nand_flash_ids[VAR_0->chip_id].options & NAND_SAMSUNG_LP ?\n16 : 8;",
"if (VAR_0->wp) {",
"VAR_0->blk_erase(VAR_0);",
"}",
"break;",
"case NAND_CMD_READSTATUS:\nVAR_0->ioaddr = VAR_0->io;",
"VAR_0->iolen = 0;",
"nand_pushio_byte(VAR_0, VAR_0->status);",
"break;",
"default:\nprintf(\"%VAR_0: Unknown NAND command 0x%02x\\n\", __FUNCTION__, VAR_0->cmd);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53,
55
],
[
57
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
73,
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
109,
111
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
]
] |
24,843 | int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
{
int64_t deadline = -1;
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
QLIST_FOREACH(timer_list, &clock->timerlists, list) {
deadline = qemu_soonest_timeout(deadline,
timerlist_deadline_ns(timer_list));
}
return deadline;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
{
int64_t deadline = -1;
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
QLIST_FOREACH(timer_list, &clock->timerlists, list) {
deadline = qemu_soonest_timeout(deadline,
timerlist_deadline_ns(timer_list));
}
return deadline;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(QEMUClockType type)
{
int64_t deadline = -1;
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
QLIST_FOREACH(timer_list, &clock->timerlists, list) {
deadline = qemu_soonest_timeout(deadline,
timerlist_deadline_ns(timer_list));
}
return deadline;
}
| [
"int64_t FUNC_0(QEMUClockType type)\n{",
"int64_t deadline = -1;",
"QEMUTimerList *timer_list;",
"QEMUClock *clock = qemu_clock_ptr(type);",
"QLIST_FOREACH(timer_list, &clock->timerlists, list) {",
"deadline = qemu_soonest_timeout(deadline,\ntimerlist_deadline_ns(timer_list));",
"}",
"return deadline;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
]
] |
24,844 | UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a,
bool has_udb1, UserDefOne *ud1b,
Error **errp)
{
UserDefTwo *ret;
UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));
UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));
ud1c->string = strdup(ud1a->string);
ud1c->base = g_new0(UserDefZero, 1);
ud1c->base->integer = ud1a->base->integer;
ud1d->string = strdup(has_udb1 ? ud1b->string : "blah0");
ud1d->base = g_new0(UserDefZero, 1);
ud1d->base->integer = has_udb1 ? ud1b->base->integer : 0;
ret = g_new0(UserDefTwo, 1);
ret->string0 = strdup("blah1");
ret->dict1 = g_new0(UserDefTwoDict, 1);
ret->dict1->string1 = strdup("blah2");
ret->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->dict2->userdef = ud1c;
ret->dict1->dict2->string = strdup("blah3");
ret->dict1->dict3 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->has_dict3 = true;
ret->dict1->dict3->userdef = ud1d;
ret->dict1->dict3->string = strdup("blah4");
return ret;
}
| false | qemu | ddf21908961073199f3d186204da4810f2ea150b | UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a,
bool has_udb1, UserDefOne *ud1b,
Error **errp)
{
UserDefTwo *ret;
UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));
UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));
ud1c->string = strdup(ud1a->string);
ud1c->base = g_new0(UserDefZero, 1);
ud1c->base->integer = ud1a->base->integer;
ud1d->string = strdup(has_udb1 ? ud1b->string : "blah0");
ud1d->base = g_new0(UserDefZero, 1);
ud1d->base->integer = has_udb1 ? ud1b->base->integer : 0;
ret = g_new0(UserDefTwo, 1);
ret->string0 = strdup("blah1");
ret->dict1 = g_new0(UserDefTwoDict, 1);
ret->dict1->string1 = strdup("blah2");
ret->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->dict2->userdef = ud1c;
ret->dict1->dict2->string = strdup("blah3");
ret->dict1->dict3 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->has_dict3 = true;
ret->dict1->dict3->userdef = ud1d;
ret->dict1->dict3->string = strdup("blah4");
return ret;
}
| {
"code": [],
"line_no": []
} | UserDefTwo *FUNC_0(UserDefOne *ud1a,
bool has_udb1, UserDefOne *ud1b,
Error **errp)
{
UserDefTwo *ret;
UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));
UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));
ud1c->string = strdup(ud1a->string);
ud1c->base = g_new0(UserDefZero, 1);
ud1c->base->integer = ud1a->base->integer;
ud1d->string = strdup(has_udb1 ? ud1b->string : "blah0");
ud1d->base = g_new0(UserDefZero, 1);
ud1d->base->integer = has_udb1 ? ud1b->base->integer : 0;
ret = g_new0(UserDefTwo, 1);
ret->string0 = strdup("blah1");
ret->dict1 = g_new0(UserDefTwoDict, 1);
ret->dict1->string1 = strdup("blah2");
ret->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->dict2->userdef = ud1c;
ret->dict1->dict2->string = strdup("blah3");
ret->dict1->dict3 = g_new0(UserDefTwoDictDict, 1);
ret->dict1->has_dict3 = true;
ret->dict1->dict3->userdef = ud1d;
ret->dict1->dict3->string = strdup("blah4");
return ret;
}
| [
"UserDefTwo *FUNC_0(UserDefOne *ud1a,\nbool has_udb1, UserDefOne *ud1b,\nError **errp)\n{",
"UserDefTwo *ret;",
"UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));",
"UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));",
"ud1c->string = strdup(ud1a->string);",
"ud1c->base = g_new0(UserDefZero, 1);",
"ud1c->base->integer = ud1a->base->integer;",
"ud1d->string = strdup(has_udb1 ? ud1b->string : \"blah0\");",
"ud1d->base = g_new0(UserDefZero, 1);",
"ud1d->base->integer = has_udb1 ? ud1b->base->integer : 0;",
"ret = g_new0(UserDefTwo, 1);",
"ret->string0 = strdup(\"blah1\");",
"ret->dict1 = g_new0(UserDefTwoDict, 1);",
"ret->dict1->string1 = strdup(\"blah2\");",
"ret->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);",
"ret->dict1->dict2->userdef = ud1c;",
"ret->dict1->dict2->string = strdup(\"blah3\");",
"ret->dict1->dict3 = g_new0(UserDefTwoDictDict, 1);",
"ret->dict1->has_dict3 = true;",
"ret->dict1->dict3->userdef = ud1d;",
"ret->dict1->dict3->string = strdup(\"blah4\");",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
24,845 | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
int maskshift = extract32(value, 0, 3);
if (arm_feature(env, ARM_FEATURE_LPAE) && (value & (1 << 31))) {
value &= ~((7 << 19) | (3 << 14) | (0xf << 3));
} else {
value &= 7;
}
/* Note that we always calculate c2_mask and c2_base_mask, but
* they are only used for short-descriptor tables (ie if EAE is 0);
* for long-descriptor tables the TTBCR fields are used differently
* and the c2_mask and c2_base_mask values are meaningless.
*/
env->cp15.c2_control = value;
env->cp15.c2_mask = ~(((uint32_t)0xffffffffu) >> maskshift);
env->cp15.c2_base_mask = ~((uint32_t)0x3fffu >> maskshift);
}
| false | qemu | 8d5c773e323b22402abdd0beef4c7d2fc91dd0eb | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
int maskshift = extract32(value, 0, 3);
if (arm_feature(env, ARM_FEATURE_LPAE) && (value & (1 << 31))) {
value &= ~((7 << 19) | (3 << 14) | (0xf << 3));
} else {
value &= 7;
}
env->cp15.c2_control = value;
env->cp15.c2_mask = ~(((uint32_t)0xffffffffu) >> maskshift);
env->cp15.c2_base_mask = ~((uint32_t)0x3fffu >> maskshift);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,
uint64_t VAR_2)
{
int VAR_3 = extract32(VAR_2, 0, 3);
if (arm_feature(VAR_0, ARM_FEATURE_LPAE) && (VAR_2 & (1 << 31))) {
VAR_2 &= ~((7 << 19) | (3 << 14) | (0xf << 3));
} else {
VAR_2 &= 7;
}
VAR_0->cp15.c2_control = VAR_2;
VAR_0->cp15.c2_mask = ~(((uint32_t)0xffffffffu) >> VAR_3);
VAR_0->cp15.c2_base_mask = ~((uint32_t)0x3fffu >> VAR_3);
}
| [
"static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,\nuint64_t VAR_2)\n{",
"int VAR_3 = extract32(VAR_2, 0, 3);",
"if (arm_feature(VAR_0, ARM_FEATURE_LPAE) && (VAR_2 & (1 << 31))) {",
"VAR_2 &= ~((7 << 19) | (3 << 14) | (0xf << 3));",
"} else {",
"VAR_2 &= 7;",
"}",
"VAR_0->cp15.c2_control = VAR_2;",
"VAR_0->cp15.c2_mask = ~(((uint32_t)0xffffffffu) >> VAR_3);",
"VAR_0->cp15.c2_base_mask = ~((uint32_t)0x3fffu >> VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
24,846 | static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
int idx)
{
openpic_t *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
uint32_t retval;
int n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x00: /* Block Revision Register1 (BRR1) */
retval = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
break;
case 0x80: /* PCTP */
retval = dst->pctp;
break;
case 0x90: /* WHOAMI */
retval = idx;
break;
case 0xA0: /* PIAC */
DPRINTF("Lower OpenPIC INT output\n");
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
n_IRQ = IRQ_get_next(opp, &dst->raised);
DPRINTF("PIAC: irq=%d\n", n_IRQ);
if (n_IRQ == -1) {
/* No more interrupt pending */
retval = IPVP_VECTOR(opp->spve);
} else {
src = &opp->src[n_IRQ];
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
/* - Spurious level-sensitive IRQ
* - Priorities has been changed
* and the pending IRQ isn't allowed anymore
*/
reset_bit(&src->ipvp, IPVP_ACTIVITY);
retval = IPVP_VECTOR(opp->spve);
} else {
/* IRQ enter servicing state */
IRQ_setbit(&dst->servicing, n_IRQ);
retval = IPVP_VECTOR(src->ipvp);
}
IRQ_resetbit(&dst->raised, n_IRQ);
dst->raised.next = -1;
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
/* edge-sensitive IRQ */
reset_bit(&src->ipvp, IPVP_ACTIVITY);
src->pending = 0;
}
if ((n_IRQ >= opp->irq_ipi0) && (n_IRQ < (opp->irq_ipi0 + MAX_IPI))) {
src->ide &= ~(1 << idx);
if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {
/* trigger on CPUs that didn't know about it yet */
openpic_set_irq(opp, n_IRQ, 1);
openpic_set_irq(opp, n_IRQ, 0);
/* if all CPUs knew about it, set active bit again */
set_bit(&src->ipvp, IPVP_ACTIVITY);
}
}
}
break;
case 0xB0: /* PEOI */
retval = 0;
break;
default:
break;
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| false | qemu | 1945dbc15f0f1ffdc9a10526448e9eba7c599d98 | static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
int idx)
{
openpic_t *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
uint32_t retval;
int n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x00:
retval = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
break;
case 0x80:
retval = dst->pctp;
break;
case 0x90:
retval = idx;
break;
case 0xA0:
DPRINTF("Lower OpenPIC INT output\n");
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
n_IRQ = IRQ_get_next(opp, &dst->raised);
DPRINTF("PIAC: irq=%d\n", n_IRQ);
if (n_IRQ == -1) {
retval = IPVP_VECTOR(opp->spve);
} else {
src = &opp->src[n_IRQ];
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
retval = IPVP_VECTOR(opp->spve);
} else {
IRQ_setbit(&dst->servicing, n_IRQ);
retval = IPVP_VECTOR(src->ipvp);
}
IRQ_resetbit(&dst->raised, n_IRQ);
dst->raised.next = -1;
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
src->pending = 0;
}
if ((n_IRQ >= opp->irq_ipi0) && (n_IRQ < (opp->irq_ipi0 + MAX_IPI))) {
src->ide &= ~(1 << idx);
if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {
openpic_set_irq(opp, n_IRQ, 1);
openpic_set_irq(opp, n_IRQ, 0);
set_bit(&src->ipvp, IPVP_ACTIVITY);
}
}
}
break;
case 0xB0:
retval = 0;
break;
default:
break;
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, hwaddr addr,
int idx)
{
openpic_t *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
uint32_t retval;
int VAR_0;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x00:
retval = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
break;
case 0x80:
retval = dst->pctp;
break;
case 0x90:
retval = idx;
break;
case 0xA0:
DPRINTF("Lower OpenPIC INT output\n");
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
VAR_0 = IRQ_get_next(opp, &dst->raised);
DPRINTF("PIAC: irq=%d\n", VAR_0);
if (VAR_0 == -1) {
retval = IPVP_VECTOR(opp->spve);
} else {
src = &opp->src[VAR_0];
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
retval = IPVP_VECTOR(opp->spve);
} else {
IRQ_setbit(&dst->servicing, VAR_0);
retval = IPVP_VECTOR(src->ipvp);
}
IRQ_resetbit(&dst->raised, VAR_0);
dst->raised.next = -1;
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
reset_bit(&src->ipvp, IPVP_ACTIVITY);
src->pending = 0;
}
if ((VAR_0 >= opp->irq_ipi0) && (VAR_0 < (opp->irq_ipi0 + MAX_IPI))) {
src->ide &= ~(1 << idx);
if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {
openpic_set_irq(opp, VAR_0, 1);
openpic_set_irq(opp, VAR_0, 0);
set_bit(&src->ipvp, IPVP_ACTIVITY);
}
}
}
break;
case 0xB0:
retval = 0;
break;
default:
break;
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| [
"static uint32_t FUNC_0(void *opaque, hwaddr addr,\nint idx)\n{",
"openpic_t *opp = opaque;",
"IRQ_src_t *src;",
"IRQ_dst_t *dst;",
"uint32_t retval;",
"int VAR_0;",
"DPRINTF(\"%s: cpu %d addr \" TARGET_FMT_plx \"\\n\", __func__, idx, addr);",
"retval = 0xFFFFFFFF;",
"if (addr & 0xF)\nreturn retval;",
"dst = &opp->dst[idx];",
"addr &= 0xFF0;",
"switch (addr) {",
"case 0x00:\nretval = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;",
"break;",
"case 0x80:\nretval = dst->pctp;",
"break;",
"case 0x90:\nretval = idx;",
"break;",
"case 0xA0:\nDPRINTF(\"Lower OpenPIC INT output\\n\");",
"qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);",
"VAR_0 = IRQ_get_next(opp, &dst->raised);",
"DPRINTF(\"PIAC: irq=%d\\n\", VAR_0);",
"if (VAR_0 == -1) {",
"retval = IPVP_VECTOR(opp->spve);",
"} else {",
"src = &opp->src[VAR_0];",
"if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||\n!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {",
"reset_bit(&src->ipvp, IPVP_ACTIVITY);",
"retval = IPVP_VECTOR(opp->spve);",
"} else {",
"IRQ_setbit(&dst->servicing, VAR_0);",
"retval = IPVP_VECTOR(src->ipvp);",
"}",
"IRQ_resetbit(&dst->raised, VAR_0);",
"dst->raised.next = -1;",
"if (!test_bit(&src->ipvp, IPVP_SENSE)) {",
"reset_bit(&src->ipvp, IPVP_ACTIVITY);",
"src->pending = 0;",
"}",
"if ((VAR_0 >= opp->irq_ipi0) && (VAR_0 < (opp->irq_ipi0 + MAX_IPI))) {",
"src->ide &= ~(1 << idx);",
"if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {",
"openpic_set_irq(opp, VAR_0, 1);",
"openpic_set_irq(opp, VAR_0, 0);",
"set_bit(&src->ipvp, IPVP_ACTIVITY);",
"}",
"}",
"}",
"break;",
"case 0xB0:\nretval = 0;",
"break;",
"default:\nbreak;",
"}",
"DPRINTF(\"%s: => %08x\\n\", __func__, retval);",
"return retval;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155
]
] |
24,848 | static int faac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
FAACContext *s = (FAACContext *) avctx->priv_data;
#ifndef FAAD2_VERSION
unsigned long bytesconsumed;
short *sample_buffer = NULL;
unsigned long samples;
int out;
#else
faacDecFrameInfo frame_info;
void *out;
#endif
if(buf_size == 0)
return 0;
#ifndef FAAD2_VERSION
out = s->faacDecDecode(s->faac_handle,
(unsigned char*)buf,
&bytesconsumed,
data,
&samples);
samples *= s->sample_size;
if (data_size)
*data_size = samples;
return (buf_size < (int)bytesconsumed)
? buf_size : (int)bytesconsumed;
#else
if(!s->init){
unsigned long srate;
unsigned char channels;
int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
if(r < 0){
av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
avctx->sample_rate = srate;
avctx->channels = channels;
s->init = 1;
}
out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
if (frame_info.error > 0) {
av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
frame_info.samples *= s->sample_size;
memcpy(data, out, frame_info.samples); // CHECKME - can we cheat this one
if (data_size)
*data_size = frame_info.samples;
return (buf_size < (int)frame_info.bytesconsumed)
? buf_size : (int)frame_info.bytesconsumed;
#endif
}
| false | FFmpeg | 980bbb13d653561d83619350db32ccb5e5248f95 | static int faac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
FAACContext *s = (FAACContext *) avctx->priv_data;
#ifndef FAAD2_VERSION
unsigned long bytesconsumed;
short *sample_buffer = NULL;
unsigned long samples;
int out;
#else
faacDecFrameInfo frame_info;
void *out;
#endif
if(buf_size == 0)
return 0;
#ifndef FAAD2_VERSION
out = s->faacDecDecode(s->faac_handle,
(unsigned char*)buf,
&bytesconsumed,
data,
&samples);
samples *= s->sample_size;
if (data_size)
*data_size = samples;
return (buf_size < (int)bytesconsumed)
? buf_size : (int)bytesconsumed;
#else
if(!s->init){
unsigned long srate;
unsigned char channels;
int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
if(r < 0){
av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
avctx->sample_rate = srate;
avctx->channels = channels;
s->init = 1;
}
out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
if (frame_info.error > 0) {
av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
frame_info.samples *= s->sample_size;
memcpy(data, out, frame_info.samples);
if (data_size)
*data_size = frame_info.samples;
return (buf_size < (int)frame_info.bytesconsumed)
? buf_size : (int)frame_info.bytesconsumed;
#endif
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
FAACContext *s = (FAACContext *) VAR_0->priv_data;
#ifndef FAAD2_VERSION
unsigned long VAR_5;
short *VAR_6 = NULL;
unsigned long VAR_7;
int VAR_8;
#else
faacDecFrameInfo frame_info;
void *VAR_8;
#endif
if(VAR_4 == 0)
return 0;
#ifndef FAAD2_VERSION
VAR_8 = s->faacDecDecode(s->faac_handle,
(unsigned char*)VAR_3,
&VAR_5,
VAR_1,
&VAR_7);
VAR_7 *= s->sample_size;
if (VAR_2)
*VAR_2 = VAR_7;
return (VAR_4 < (int)VAR_5)
? VAR_4 : (int)VAR_5;
#else
if(!s->init){
unsigned long srate;
unsigned char channels;
int r = s->faacDecInit(s->faac_handle, VAR_3, VAR_4, &srate, &channels);
if(r < 0){
av_log(VAR_0, AV_LOG_ERROR, "faac: codec init failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
VAR_0->sample_rate = srate;
VAR_0->channels = channels;
s->init = 1;
}
VAR_8 = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)VAR_3, (unsigned long)VAR_4);
if (frame_info.error > 0) {
av_log(VAR_0, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
frame_info.VAR_7 *= s->sample_size;
memcpy(VAR_1, VAR_8, frame_info.VAR_7);
if (VAR_2)
*VAR_2 = frame_info.VAR_7;
return (VAR_4 < (int)frame_info.VAR_5)
? VAR_4 : (int)frame_info.VAR_5;
#endif
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"FAACContext *s = (FAACContext *) VAR_0->priv_data;",
"#ifndef FAAD2_VERSION\nunsigned long VAR_5;",
"short *VAR_6 = NULL;",
"unsigned long VAR_7;",
"int VAR_8;",
"#else\nfaacDecFrameInfo frame_info;",
"void *VAR_8;",
"#endif\nif(VAR_4 == 0)\nreturn 0;",
"#ifndef FAAD2_VERSION\nVAR_8 = s->faacDecDecode(s->faac_handle,\n(unsigned char*)VAR_3,\n&VAR_5,\nVAR_1,\n&VAR_7);",
"VAR_7 *= s->sample_size;",
"if (VAR_2)\n*VAR_2 = VAR_7;",
"return (VAR_4 < (int)VAR_5)\n? VAR_4 : (int)VAR_5;",
"#else\nif(!s->init){",
"unsigned long srate;",
"unsigned char channels;",
"int r = s->faacDecInit(s->faac_handle, VAR_3, VAR_4, &srate, &channels);",
"if(r < 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"faac: codec init failed: %s\\n\",\ns->faacDecGetErrorMessage(frame_info.error));",
"return 0;",
"}",
"VAR_0->sample_rate = srate;",
"VAR_0->channels = channels;",
"s->init = 1;",
"}",
"VAR_8 = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)VAR_3, (unsigned long)VAR_4);",
"if (frame_info.error > 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"faac: frame decoding failed: %s\\n\",\ns->faacDecGetErrorMessage(frame_info.error));",
"return 0;",
"}",
"frame_info.VAR_7 *= s->sample_size;",
"memcpy(VAR_1, VAR_8, frame_info.VAR_7);",
"if (VAR_2)\n*VAR_2 = frame_info.VAR_7;",
"return (VAR_4 < (int)frame_info.VAR_5)\n? VAR_4 : (int)frame_info.VAR_5;",
"#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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29,
31
],
[
33,
35,
37,
39,
41,
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109,
111
],
[
115,
117
],
[
119,
121
]
] |
24,849 | void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr, uint64_t align, Error **errp)
{
int slot;
MachineState *machine = MACHINE(qdev_get_machine());
PCDIMMDevice *dimm = PC_DIMM(dev);
Error *local_err = NULL;
uint64_t existing_dimms_capacity = 0;
uint64_t addr;
addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
addr = pc_dimm_get_free_addr(hpms->base,
memory_region_size(&hpms->mr),
!addr ? NULL : &addr, align,
memory_region_size(mr), &local_err);
if (local_err) {
goto out;
}
existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);
if (local_err) {
goto out;
}
if (existing_dimms_capacity + memory_region_size(mr) >
machine->maxram_size - machine->ram_size) {
error_setg(&local_err, "not enough space, currently 0x%" PRIx64
" in use of total hot pluggable 0x" RAM_ADDR_FMT,
existing_dimms_capacity,
machine->maxram_size - machine->ram_size);
goto out;
}
object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_address(addr);
slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,
machine->ram_slots, &local_err);
if (local_err) {
goto out;
}
object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_slot(slot);
if (kvm_enabled() && !kvm_has_free_slot(machine)) {
error_setg(&local_err, "hypervisor has no free memory slots left");
goto out;
}
if (!vhost_has_free_slot()) {
error_setg(&local_err, "a used vhost backend has no free"
" memory slots left");
goto out;
}
memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr);
vmstate_register_ram(mr, dev);
numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node);
out:
error_propagate(errp, local_err);
}
| false | qemu | 8df1426e44176512be1b6456e90d100d1af907e1 | void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr, uint64_t align, Error **errp)
{
int slot;
MachineState *machine = MACHINE(qdev_get_machine());
PCDIMMDevice *dimm = PC_DIMM(dev);
Error *local_err = NULL;
uint64_t existing_dimms_capacity = 0;
uint64_t addr;
addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
addr = pc_dimm_get_free_addr(hpms->base,
memory_region_size(&hpms->mr),
!addr ? NULL : &addr, align,
memory_region_size(mr), &local_err);
if (local_err) {
goto out;
}
existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);
if (local_err) {
goto out;
}
if (existing_dimms_capacity + memory_region_size(mr) >
machine->maxram_size - machine->ram_size) {
error_setg(&local_err, "not enough space, currently 0x%" PRIx64
" in use of total hot pluggable 0x" RAM_ADDR_FMT,
existing_dimms_capacity,
machine->maxram_size - machine->ram_size);
goto out;
}
object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_address(addr);
slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,
machine->ram_slots, &local_err);
if (local_err) {
goto out;
}
object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_slot(slot);
if (kvm_enabled() && !kvm_has_free_slot(machine)) {
error_setg(&local_err, "hypervisor has no free memory slots left");
goto out;
}
if (!vhost_has_free_slot()) {
error_setg(&local_err, "a used vhost backend has no free"
" memory slots left");
goto out;
}
memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr);
vmstate_register_ram(mr, dev);
numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node);
out:
error_propagate(errp, local_err);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DeviceState *VAR_0, MemoryHotplugState *VAR_1,
MemoryRegion *VAR_2, uint64_t VAR_3, Error **VAR_4)
{
int VAR_5;
MachineState *machine = MACHINE(qdev_get_machine());
PCDIMMDevice *dimm = PC_DIMM(VAR_0);
Error *local_err = NULL;
uint64_t existing_dimms_capacity = 0;
uint64_t addr;
addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
addr = pc_dimm_get_free_addr(VAR_1->base,
memory_region_size(&VAR_1->VAR_2),
!addr ? NULL : &addr, VAR_3,
memory_region_size(VAR_2), &local_err);
if (local_err) {
goto out;
}
existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);
if (local_err) {
goto out;
}
if (existing_dimms_capacity + memory_region_size(VAR_2) >
machine->maxram_size - machine->ram_size) {
error_setg(&local_err, "not enough space, currently 0x%" PRIx64
" in use of total hot pluggable 0x" RAM_ADDR_FMT,
existing_dimms_capacity,
machine->maxram_size - machine->ram_size);
goto out;
}
object_property_set_int(OBJECT(VAR_0), addr, PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_address(addr);
VAR_5 = object_property_get_int(OBJECT(VAR_0), PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
VAR_5 = pc_dimm_get_free_slot(VAR_5 == PC_DIMM_UNASSIGNED_SLOT ? NULL : &VAR_5,
machine->ram_slots, &local_err);
if (local_err) {
goto out;
}
object_property_set_int(OBJECT(VAR_0), VAR_5, PC_DIMM_SLOT_PROP, &local_err);
if (local_err) {
goto out;
}
trace_mhp_pc_dimm_assigned_slot(VAR_5);
if (kvm_enabled() && !kvm_has_free_slot(machine)) {
error_setg(&local_err, "hypervisor has no free memory slots left");
goto out;
}
if (!vhost_has_free_slot()) {
error_setg(&local_err, "a used vhost backend has no free"
" memory slots left");
goto out;
}
memory_region_add_subregion(&VAR_1->VAR_2, addr - VAR_1->base, VAR_2);
vmstate_register_ram(VAR_2, VAR_0);
numa_set_mem_node_id(addr, memory_region_size(VAR_2), dimm->node);
out:
error_propagate(VAR_4, local_err);
}
| [
"void FUNC_0(DeviceState *VAR_0, MemoryHotplugState *VAR_1,\nMemoryRegion *VAR_2, uint64_t VAR_3, Error **VAR_4)\n{",
"int VAR_5;",
"MachineState *machine = MACHINE(qdev_get_machine());",
"PCDIMMDevice *dimm = PC_DIMM(VAR_0);",
"Error *local_err = NULL;",
"uint64_t existing_dimms_capacity = 0;",
"uint64_t addr;",
"addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"addr = pc_dimm_get_free_addr(VAR_1->base,\nmemory_region_size(&VAR_1->VAR_2),\n!addr ? NULL : &addr, VAR_3,\nmemory_region_size(VAR_2), &local_err);",
"if (local_err) {",
"goto out;",
"}",
"existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);",
"if (local_err) {",
"goto out;",
"}",
"if (existing_dimms_capacity + memory_region_size(VAR_2) >\nmachine->maxram_size - machine->ram_size) {",
"error_setg(&local_err, \"not enough space, currently 0x%\" PRIx64\n\" in use of total hot pluggable 0x\" RAM_ADDR_FMT,\nexisting_dimms_capacity,\nmachine->maxram_size - machine->ram_size);",
"goto out;",
"}",
"object_property_set_int(OBJECT(VAR_0), addr, PC_DIMM_ADDR_PROP, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"trace_mhp_pc_dimm_assigned_address(addr);",
"VAR_5 = object_property_get_int(OBJECT(VAR_0), PC_DIMM_SLOT_PROP, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"VAR_5 = pc_dimm_get_free_slot(VAR_5 == PC_DIMM_UNASSIGNED_SLOT ? NULL : &VAR_5,\nmachine->ram_slots, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"object_property_set_int(OBJECT(VAR_0), VAR_5, PC_DIMM_SLOT_PROP, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"trace_mhp_pc_dimm_assigned_slot(VAR_5);",
"if (kvm_enabled() && !kvm_has_free_slot(machine)) {",
"error_setg(&local_err, \"hypervisor has no free memory slots left\");",
"goto out;",
"}",
"if (!vhost_has_free_slot()) {",
"error_setg(&local_err, \"a used vhost backend has no free\"\n\" memory slots left\");",
"goto out;",
"}",
"memory_region_add_subregion(&VAR_1->VAR_2, addr - VAR_1->base, VAR_2);",
"vmstate_register_ram(VAR_2, VAR_0);",
"numa_set_mem_node_id(addr, memory_region_size(VAR_2), dimm->node);",
"out:\nerror_propagate(VAR_4, local_err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61,
63,
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
]
] |
24,850 | static BOOL WINAPI qemu_ctrl_handler(DWORD type)
{
exit(STATUS_CONTROL_C_EXIT);
return TRUE;
}
| false | qemu | b75a02829dde98723dfe16fa098338cb267b28b9 | static BOOL WINAPI qemu_ctrl_handler(DWORD type)
{
exit(STATUS_CONTROL_C_EXIT);
return TRUE;
}
| {
"code": [],
"line_no": []
} | static BOOL VAR_0 qemu_ctrl_handler(DWORD type)
{
exit(STATUS_CONTROL_C_EXIT);
return TRUE;
}
| [
"static BOOL VAR_0 qemu_ctrl_handler(DWORD type)\n{",
"exit(STATUS_CONTROL_C_EXIT);",
"return TRUE;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,851 | static int spapr_phb_init(SysBusDevice *s)
{
sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s);
char *namebuf;
int i;
PCIBus *bus;
sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid);
namebuf = alloca(strlen(sphb->dtbusname) + 32);
/* Initialize memory regions */
sprintf(namebuf, "%s.mmio", sphb->dtbusname);
memory_region_init(&sphb->memspace, namebuf, INT64_MAX);
sprintf(namebuf, "%s.mmio-alias", sphb->dtbusname);
memory_region_init_alias(&sphb->memwindow, namebuf, &sphb->memspace,
SPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_size);
memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr,
&sphb->memwindow);
/* On ppc, we only have MMIO no specific IO space from the CPU
* perspective. In theory we ought to be able to embed the PCI IO
* memory region direction in the system memory space. However,
* if any of the IO BAR subregions use the old_portio mechanism,
* that won't be processed properly unless accessed from the
* system io address space. This hack to bounce things via
* system_io works around the problem until all the users of
* old_portion are updated */
sprintf(namebuf, "%s.io", sphb->dtbusname);
memory_region_init(&sphb->iospace, namebuf, SPAPR_PCI_IO_WIN_SIZE);
/* FIXME: fix to support multiple PHBs */
memory_region_add_subregion(get_system_io(), 0, &sphb->iospace);
sprintf(namebuf, "%s.io-alias", sphb->dtbusname);
memory_region_init_io(&sphb->iowindow, &spapr_io_ops, sphb,
namebuf, SPAPR_PCI_IO_WIN_SIZE);
memory_region_add_subregion(get_system_memory(), sphb->io_win_addr,
&sphb->iowindow);
/* As MSI/MSIX interrupts trigger by writing at MSI/MSIX vectors,
* we need to allocate some memory to catch those writes coming
* from msi_notify()/msix_notify() */
if (msi_supported) {
sprintf(namebuf, "%s.msi", sphb->dtbusname);
memory_region_init_io(&sphb->msiwindow, &spapr_msi_ops, sphb,
namebuf, SPAPR_MSIX_MAX_DEVS * 0x10000);
memory_region_add_subregion(get_system_memory(), sphb->msi_win_addr,
&sphb->msiwindow);
}
bus = pci_register_bus(DEVICE(s),
sphb->busname ? sphb->busname : sphb->dtbusname,
pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS);
phb->bus = bus;
sphb->dma_liobn = SPAPR_PCI_BASE_LIOBN | (pci_find_domain(bus) << 16);
sphb->dma_window_start = 0;
sphb->dma_window_size = 0x40000000;
sphb->dma = spapr_tce_new_dma_context(sphb->dma_liobn, sphb->dma_window_size);
pci_setup_iommu(bus, spapr_pci_dma_context_fn, sphb);
QLIST_INSERT_HEAD(&spapr->phbs, sphb, list);
/* Initialize the LSI table */
for (i = 0; i < PCI_NUM_PINS; i++) {
uint32_t irq;
irq = spapr_allocate_lsi(0);
if (!irq) {
return -1;
}
sphb->lsi_table[i].irq = irq;
}
return 0;
}
| false | qemu | a178274efabcbbc5d44805b51def874e47051325 | static int spapr_phb_init(SysBusDevice *s)
{
sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s);
char *namebuf;
int i;
PCIBus *bus;
sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid);
namebuf = alloca(strlen(sphb->dtbusname) + 32);
sprintf(namebuf, "%s.mmio", sphb->dtbusname);
memory_region_init(&sphb->memspace, namebuf, INT64_MAX);
sprintf(namebuf, "%s.mmio-alias", sphb->dtbusname);
memory_region_init_alias(&sphb->memwindow, namebuf, &sphb->memspace,
SPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_size);
memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr,
&sphb->memwindow);
sprintf(namebuf, "%s.io", sphb->dtbusname);
memory_region_init(&sphb->iospace, namebuf, SPAPR_PCI_IO_WIN_SIZE);
memory_region_add_subregion(get_system_io(), 0, &sphb->iospace);
sprintf(namebuf, "%s.io-alias", sphb->dtbusname);
memory_region_init_io(&sphb->iowindow, &spapr_io_ops, sphb,
namebuf, SPAPR_PCI_IO_WIN_SIZE);
memory_region_add_subregion(get_system_memory(), sphb->io_win_addr,
&sphb->iowindow);
if (msi_supported) {
sprintf(namebuf, "%s.msi", sphb->dtbusname);
memory_region_init_io(&sphb->msiwindow, &spapr_msi_ops, sphb,
namebuf, SPAPR_MSIX_MAX_DEVS * 0x10000);
memory_region_add_subregion(get_system_memory(), sphb->msi_win_addr,
&sphb->msiwindow);
}
bus = pci_register_bus(DEVICE(s),
sphb->busname ? sphb->busname : sphb->dtbusname,
pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS);
phb->bus = bus;
sphb->dma_liobn = SPAPR_PCI_BASE_LIOBN | (pci_find_domain(bus) << 16);
sphb->dma_window_start = 0;
sphb->dma_window_size = 0x40000000;
sphb->dma = spapr_tce_new_dma_context(sphb->dma_liobn, sphb->dma_window_size);
pci_setup_iommu(bus, spapr_pci_dma_context_fn, sphb);
QLIST_INSERT_HEAD(&spapr->phbs, sphb, list);
for (i = 0; i < PCI_NUM_PINS; i++) {
uint32_t irq;
irq = spapr_allocate_lsi(0);
if (!irq) {
return -1;
}
sphb->lsi_table[i].irq = irq;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SysBusDevice *VAR_0)
{
sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(VAR_0);
PCIHostState *phb = PCI_HOST_BRIDGE(VAR_0);
char *VAR_1;
int VAR_2;
PCIBus *bus;
sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid);
VAR_1 = alloca(strlen(sphb->dtbusname) + 32);
sprintf(VAR_1, "%VAR_0.mmio", sphb->dtbusname);
memory_region_init(&sphb->memspace, VAR_1, INT64_MAX);
sprintf(VAR_1, "%VAR_0.mmio-alias", sphb->dtbusname);
memory_region_init_alias(&sphb->memwindow, VAR_1, &sphb->memspace,
SPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_size);
memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr,
&sphb->memwindow);
sprintf(VAR_1, "%VAR_0.io", sphb->dtbusname);
memory_region_init(&sphb->iospace, VAR_1, SPAPR_PCI_IO_WIN_SIZE);
memory_region_add_subregion(get_system_io(), 0, &sphb->iospace);
sprintf(VAR_1, "%VAR_0.io-alias", sphb->dtbusname);
memory_region_init_io(&sphb->iowindow, &spapr_io_ops, sphb,
VAR_1, SPAPR_PCI_IO_WIN_SIZE);
memory_region_add_subregion(get_system_memory(), sphb->io_win_addr,
&sphb->iowindow);
if (msi_supported) {
sprintf(VAR_1, "%VAR_0.msi", sphb->dtbusname);
memory_region_init_io(&sphb->msiwindow, &spapr_msi_ops, sphb,
VAR_1, SPAPR_MSIX_MAX_DEVS * 0x10000);
memory_region_add_subregion(get_system_memory(), sphb->msi_win_addr,
&sphb->msiwindow);
}
bus = pci_register_bus(DEVICE(VAR_0),
sphb->busname ? sphb->busname : sphb->dtbusname,
pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS);
phb->bus = bus;
sphb->dma_liobn = SPAPR_PCI_BASE_LIOBN | (pci_find_domain(bus) << 16);
sphb->dma_window_start = 0;
sphb->dma_window_size = 0x40000000;
sphb->dma = spapr_tce_new_dma_context(sphb->dma_liobn, sphb->dma_window_size);
pci_setup_iommu(bus, spapr_pci_dma_context_fn, sphb);
QLIST_INSERT_HEAD(&spapr->phbs, sphb, list);
for (VAR_2 = 0; VAR_2 < PCI_NUM_PINS; VAR_2++) {
uint32_t irq;
irq = spapr_allocate_lsi(0);
if (!irq) {
return -1;
}
sphb->lsi_table[VAR_2].irq = irq;
}
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(VAR_0);",
"PCIHostState *phb = PCI_HOST_BRIDGE(VAR_0);",
"char *VAR_1;",
"int VAR_2;",
"PCIBus *bus;",
"sphb->dtbusname = g_strdup_printf(\"pci@%\" PRIx64, sphb->buid);",
"VAR_1 = alloca(strlen(sphb->dtbusname) + 32);",
"sprintf(VAR_1, \"%VAR_0.mmio\", sphb->dtbusname);",
"memory_region_init(&sphb->memspace, VAR_1, INT64_MAX);",
"sprintf(VAR_1, \"%VAR_0.mmio-alias\", sphb->dtbusname);",
"memory_region_init_alias(&sphb->memwindow, VAR_1, &sphb->memspace,\nSPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_size);",
"memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr,\n&sphb->memwindow);",
"sprintf(VAR_1, \"%VAR_0.io\", sphb->dtbusname);",
"memory_region_init(&sphb->iospace, VAR_1, SPAPR_PCI_IO_WIN_SIZE);",
"memory_region_add_subregion(get_system_io(), 0, &sphb->iospace);",
"sprintf(VAR_1, \"%VAR_0.io-alias\", sphb->dtbusname);",
"memory_region_init_io(&sphb->iowindow, &spapr_io_ops, sphb,\nVAR_1, SPAPR_PCI_IO_WIN_SIZE);",
"memory_region_add_subregion(get_system_memory(), sphb->io_win_addr,\n&sphb->iowindow);",
"if (msi_supported) {",
"sprintf(VAR_1, \"%VAR_0.msi\", sphb->dtbusname);",
"memory_region_init_io(&sphb->msiwindow, &spapr_msi_ops, sphb,\nVAR_1, SPAPR_MSIX_MAX_DEVS * 0x10000);",
"memory_region_add_subregion(get_system_memory(), sphb->msi_win_addr,\n&sphb->msiwindow);",
"}",
"bus = pci_register_bus(DEVICE(VAR_0),\nsphb->busname ? sphb->busname : sphb->dtbusname,\npci_spapr_set_irq, pci_spapr_map_irq, sphb,\n&sphb->memspace, &sphb->iospace,\nPCI_DEVFN(0, 0), PCI_NUM_PINS);",
"phb->bus = bus;",
"sphb->dma_liobn = SPAPR_PCI_BASE_LIOBN | (pci_find_domain(bus) << 16);",
"sphb->dma_window_start = 0;",
"sphb->dma_window_size = 0x40000000;",
"sphb->dma = spapr_tce_new_dma_context(sphb->dma_liobn, sphb->dma_window_size);",
"pci_setup_iommu(bus, spapr_pci_dma_context_fn, sphb);",
"QLIST_INSERT_HEAD(&spapr->phbs, sphb, list);",
"for (VAR_2 = 0; VAR_2 < PCI_NUM_PINS; VAR_2++) {",
"uint32_t irq;",
"irq = spapr_allocate_lsi(0);",
"if (!irq) {",
"return -1;",
"}",
"sphb->lsi_table[VAR_2].irq = irq;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37,
39
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71,
73
],
[
75,
77
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
103,
105,
107,
109,
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157
],
[
159
]
] |
24,852 | static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
unsigned size)
{
IMXEPITState *s = IMX_EPIT(opaque);
uint32_t reg = offset >> 2;
uint64_t oldcr;
DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(reg), (uint32_t)value);
switch (reg) {
case 0: /* CR */
oldcr = s->cr;
s->cr = value & 0x03ffffff;
if (s->cr & CR_SWR) {
/* handle the reset */
imx_epit_reset(DEVICE(s));
} else {
imx_epit_set_freq(s);
}
if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
if (s->cr & CR_ENMOD) {
if (s->cr & CR_RLD) {
ptimer_set_limit(s->timer_reload, s->lr, 1);
ptimer_set_limit(s->timer_cmp, s->lr, 1);
} else {
ptimer_set_limit(s->timer_reload, TIMER_MAX, 1);
ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1);
}
}
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_reload, 0);
if (s->cr & CR_OCIEN) {
ptimer_run(s->timer_cmp, 0);
} else {
ptimer_stop(s->timer_cmp);
}
} else if (!(s->cr & CR_EN)) {
/* stop both timers */
ptimer_stop(s->timer_reload);
ptimer_stop(s->timer_cmp);
} else if (s->cr & CR_OCIEN) {
if (!(oldcr & CR_OCIEN)) {
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_cmp, 0);
}
} else {
ptimer_stop(s->timer_cmp);
}
break;
case 1: /* SR - ACK*/
/* writing 1 to OCIF clear the OCIF bit */
if (value & 0x01) {
s->sr = 0;
imx_epit_update_int(s);
}
break;
case 2: /* LR - set ticks */
s->lr = value;
if (s->cr & CR_RLD) {
/* Also set the limit if the LRD bit is set */
/* If IOVW bit is set then set the timer value */
ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);
ptimer_set_limit(s->timer_cmp, s->lr, 0);
} else if (s->cr & CR_IOVW) {
/* If IOVW bit is set then set the timer value */
ptimer_set_count(s->timer_reload, s->lr);
}
imx_epit_reload_compare_timer(s);
break;
case 3: /* CMP */
s->cmp = value;
imx_epit_reload_compare_timer(s);
break;
default:
IPRINTF("Bad offset %x\n", reg);
break;
}
}
| false | qemu | 203d65a4706be345c209f3408d3a011a3e48f0c9 | static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
unsigned size)
{
IMXEPITState *s = IMX_EPIT(opaque);
uint32_t reg = offset >> 2;
uint64_t oldcr;
DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(reg), (uint32_t)value);
switch (reg) {
case 0:
oldcr = s->cr;
s->cr = value & 0x03ffffff;
if (s->cr & CR_SWR) {
imx_epit_reset(DEVICE(s));
} else {
imx_epit_set_freq(s);
}
if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
if (s->cr & CR_ENMOD) {
if (s->cr & CR_RLD) {
ptimer_set_limit(s->timer_reload, s->lr, 1);
ptimer_set_limit(s->timer_cmp, s->lr, 1);
} else {
ptimer_set_limit(s->timer_reload, TIMER_MAX, 1);
ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1);
}
}
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_reload, 0);
if (s->cr & CR_OCIEN) {
ptimer_run(s->timer_cmp, 0);
} else {
ptimer_stop(s->timer_cmp);
}
} else if (!(s->cr & CR_EN)) {
ptimer_stop(s->timer_reload);
ptimer_stop(s->timer_cmp);
} else if (s->cr & CR_OCIEN) {
if (!(oldcr & CR_OCIEN)) {
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_cmp, 0);
}
} else {
ptimer_stop(s->timer_cmp);
}
break;
case 1:
if (value & 0x01) {
s->sr = 0;
imx_epit_update_int(s);
}
break;
case 2:
s->lr = value;
if (s->cr & CR_RLD) {
ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);
ptimer_set_limit(s->timer_cmp, s->lr, 0);
} else if (s->cr & CR_IOVW) {
ptimer_set_count(s->timer_reload, s->lr);
}
imx_epit_reload_compare_timer(s);
break;
case 3:
s->cmp = value;
imx_epit_reload_compare_timer(s);
break;
default:
IPRINTF("Bad offset %x\n", reg);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,
unsigned VAR_3)
{
IMXEPITState *s = IMX_EPIT(VAR_0);
uint32_t reg = VAR_1 >> 2;
uint64_t oldcr;
DPRINTF("(%s, VAR_2 = 0x%08x)\n", imx_epit_reg_name(reg), (uint32_t)VAR_2);
switch (reg) {
case 0:
oldcr = s->cr;
s->cr = VAR_2 & 0x03ffffff;
if (s->cr & CR_SWR) {
imx_epit_reset(DEVICE(s));
} else {
imx_epit_set_freq(s);
}
if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
if (s->cr & CR_ENMOD) {
if (s->cr & CR_RLD) {
ptimer_set_limit(s->timer_reload, s->lr, 1);
ptimer_set_limit(s->timer_cmp, s->lr, 1);
} else {
ptimer_set_limit(s->timer_reload, TIMER_MAX, 1);
ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1);
}
}
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_reload, 0);
if (s->cr & CR_OCIEN) {
ptimer_run(s->timer_cmp, 0);
} else {
ptimer_stop(s->timer_cmp);
}
} else if (!(s->cr & CR_EN)) {
ptimer_stop(s->timer_reload);
ptimer_stop(s->timer_cmp);
} else if (s->cr & CR_OCIEN) {
if (!(oldcr & CR_OCIEN)) {
imx_epit_reload_compare_timer(s);
ptimer_run(s->timer_cmp, 0);
}
} else {
ptimer_stop(s->timer_cmp);
}
break;
case 1:
if (VAR_2 & 0x01) {
s->sr = 0;
imx_epit_update_int(s);
}
break;
case 2:
s->lr = VAR_2;
if (s->cr & CR_RLD) {
ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);
ptimer_set_limit(s->timer_cmp, s->lr, 0);
} else if (s->cr & CR_IOVW) {
ptimer_set_count(s->timer_reload, s->lr);
}
imx_epit_reload_compare_timer(s);
break;
case 3:
s->cmp = VAR_2;
imx_epit_reload_compare_timer(s);
break;
default:
IPRINTF("Bad VAR_1 %x\n", reg);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{",
"IMXEPITState *s = IMX_EPIT(VAR_0);",
"uint32_t reg = VAR_1 >> 2;",
"uint64_t oldcr;",
"DPRINTF(\"(%s, VAR_2 = 0x%08x)\\n\", imx_epit_reg_name(reg), (uint32_t)VAR_2);",
"switch (reg) {",
"case 0:\noldcr = s->cr;",
"s->cr = VAR_2 & 0x03ffffff;",
"if (s->cr & CR_SWR) {",
"imx_epit_reset(DEVICE(s));",
"} else {",
"imx_epit_set_freq(s);",
"}",
"if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {",
"if (s->cr & CR_ENMOD) {",
"if (s->cr & CR_RLD) {",
"ptimer_set_limit(s->timer_reload, s->lr, 1);",
"ptimer_set_limit(s->timer_cmp, s->lr, 1);",
"} else {",
"ptimer_set_limit(s->timer_reload, TIMER_MAX, 1);",
"ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1);",
"}",
"}",
"imx_epit_reload_compare_timer(s);",
"ptimer_run(s->timer_reload, 0);",
"if (s->cr & CR_OCIEN) {",
"ptimer_run(s->timer_cmp, 0);",
"} else {",
"ptimer_stop(s->timer_cmp);",
"}",
"} else if (!(s->cr & CR_EN)) {",
"ptimer_stop(s->timer_reload);",
"ptimer_stop(s->timer_cmp);",
"} else if (s->cr & CR_OCIEN) {",
"if (!(oldcr & CR_OCIEN)) {",
"imx_epit_reload_compare_timer(s);",
"ptimer_run(s->timer_cmp, 0);",
"}",
"} else {",
"ptimer_stop(s->timer_cmp);",
"}",
"break;",
"case 1:\nif (VAR_2 & 0x01) {",
"s->sr = 0;",
"imx_epit_update_int(s);",
"}",
"break;",
"case 2:\ns->lr = VAR_2;",
"if (s->cr & CR_RLD) {",
"ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);",
"ptimer_set_limit(s->timer_cmp, s->lr, 0);",
"} else if (s->cr & CR_IOVW) {",
"ptimer_set_count(s->timer_reload, s->lr);",
"}",
"imx_epit_reload_compare_timer(s);",
"break;",
"case 3:\ns->cmp = VAR_2;",
"imx_epit_reload_compare_timer(s);",
"break;",
"default:\nIPRINTF(\"Bad VAR_1 %x\\n\", reg);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
129
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
149
],
[
151
],
[
155,
157
],
[
161
],
[
165
],
[
169,
171
],
[
175
],
[
177
],
[
179
]
] |
24,854 | uint32_t HELPER(rrbe)(uint32_t r1, uint64_t r2)
{
if (r2 > ram_size) {
return 0;
}
/* XXX implement */
#if 0
env->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED;
#endif
/*
* cc
*
* 0 Reference bit zero; change bit zero
* 1 Reference bit zero; change bit one
* 2 Reference bit one; change bit zero
* 3 Reference bit one; change bit one
*/
return 0;
}
| false | qemu | 17bb18ce16b45e61248c5238074fa9cf8bc547bf | uint32_t HELPER(rrbe)(uint32_t r1, uint64_t r2)
{
if (r2 > ram_size) {
return 0;
}
#if 0
env->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED;
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(rrbe)(uint32_t r1, uint64_t r2)
{
if (r2 > ram_size) {
return 0;
}
#if 0
env->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED;
#endif
return 0;
}
| [
"uint32_t FUNC_0(rrbe)(uint32_t r1, uint64_t r2)\n{",
"if (r2 > ram_size) {",
"return 0;",
"}",
"#if 0\nenv->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED;",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15,
17
],
[
19,
39
],
[
41
]
] |
24,856 | static void ivshmem_io_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
IVShmemState *s = opaque;
uint16_t dest = val >> 16;
uint16_t vector = val & 0xff;
addr &= 0xfc;
IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);
switch (addr)
{
case INTRMASK:
ivshmem_IntrMask_write(s, val);
break;
case INTRSTATUS:
ivshmem_IntrStatus_write(s, val);
break;
case DOORBELL:
/* check that dest VM ID is reasonable */
if (dest > s->max_peer) {
IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
break;
}
/* check doorbell range */
if (vector < s->peers[dest].nb_eventfds) {
IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest, vector);
event_notifier_set(&s->peers[dest].eventfds[vector]);
}
break;
default:
IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void ivshmem_io_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
IVShmemState *s = opaque;
uint16_t dest = val >> 16;
uint16_t vector = val & 0xff;
addr &= 0xfc;
IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);
switch (addr)
{
case INTRMASK:
ivshmem_IntrMask_write(s, val);
break;
case INTRSTATUS:
ivshmem_IntrStatus_write(s, val);
break;
case DOORBELL:
if (dest > s->max_peer) {
IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
break;
}
if (vector < s->peers[dest].nb_eventfds) {
IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest, vector);
event_notifier_set(&s->peers[dest].eventfds[vector]);
}
break;
default:
IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
IVShmemState *s = VAR_0;
uint16_t dest = VAR_2 >> 16;
uint16_t vector = VAR_2 & 0xff;
VAR_1 &= 0xfc;
IVSHMEM_DPRINTF("writing to VAR_1 " TARGET_FMT_plx "\n", VAR_1);
switch (VAR_1)
{
case INTRMASK:
ivshmem_IntrMask_write(s, VAR_2);
break;
case INTRSTATUS:
ivshmem_IntrStatus_write(s, VAR_2);
break;
case DOORBELL:
if (dest > s->max_peer) {
IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
break;
}
if (vector < s->peers[dest].nb_eventfds) {
IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest, vector);
event_notifier_set(&s->peers[dest].eventfds[vector]);
}
break;
default:
IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"IVShmemState *s = VAR_0;",
"uint16_t dest = VAR_2 >> 16;",
"uint16_t vector = VAR_2 & 0xff;",
"VAR_1 &= 0xfc;",
"IVSHMEM_DPRINTF(\"writing to VAR_1 \" TARGET_FMT_plx \"\\n\", VAR_1);",
"switch (VAR_1)\n{",
"case INTRMASK:\nivshmem_IntrMask_write(s, VAR_2);",
"break;",
"case INTRSTATUS:\nivshmem_IntrStatus_write(s, VAR_2);",
"break;",
"case DOORBELL:\nif (dest > s->max_peer) {",
"IVSHMEM_DPRINTF(\"Invalid destination VM ID (%d)\\n\", dest);",
"break;",
"}",
"if (vector < s->peers[dest].nb_eventfds) {",
"IVSHMEM_DPRINTF(\"Notifying VM %d on vector %d\\n\", dest, vector);",
"event_notifier_set(&s->peers[dest].eventfds[vector]);",
"}",
"break;",
"default:\nIVSHMEM_DPRINTF(\"Invalid VM Doorbell VM %d\\n\", dest);",
"}",
"}"
] | [
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
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
35,
37
],
[
39
],
[
43,
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
]
] |
24,857 | SpiceInfo *qmp_query_spice(Error **errp)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
int port, tls_port;
const char *addr;
SpiceInfo *info;
char version_string[20]; /* 12 = |255.255.255\0| is the max */
info = g_malloc0(sizeof(*info));
if (!spice_server || !opts) {
info->enabled = false;
return info;
}
info->enabled = true;
info->migrated = spice_migration_completed;
addr = qemu_opt_get(opts, "addr");
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
info->has_auth = true;
info->auth = g_strdup(auth);
info->has_host = true;
info->host = g_strdup(addr ? addr : "0.0.0.0");
info->has_compiled_version = true;
snprintf(version_string, sizeof(version_string), "%d.%d.%d",
(SPICE_SERVER_VERSION & 0xff0000) >> 16,
(SPICE_SERVER_VERSION & 0xff00) >> 8,
SPICE_SERVER_VERSION & 0xff);
info->compiled_version = g_strdup(version_string);
if (port) {
info->has_port = true;
info->port = port;
}
if (tls_port) {
info->has_tls_port = true;
info->tls_port = tls_port;
}
info->mouse_mode = spice_server_is_server_mouse(spice_server) ?
SPICE_QUERY_MOUSE_MODE_SERVER :
SPICE_QUERY_MOUSE_MODE_CLIENT;
/* for compatibility with the original command */
info->has_channels = true;
info->channels = qmp_query_spice_channels();
return info;
}
| false | qemu | 6735aa99a43c70c09b53af190b24600a61178b95 | SpiceInfo *qmp_query_spice(Error **errp)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
int port, tls_port;
const char *addr;
SpiceInfo *info;
char version_string[20];
info = g_malloc0(sizeof(*info));
if (!spice_server || !opts) {
info->enabled = false;
return info;
}
info->enabled = true;
info->migrated = spice_migration_completed;
addr = qemu_opt_get(opts, "addr");
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
info->has_auth = true;
info->auth = g_strdup(auth);
info->has_host = true;
info->host = g_strdup(addr ? addr : "0.0.0.0");
info->has_compiled_version = true;
snprintf(version_string, sizeof(version_string), "%d.%d.%d",
(SPICE_SERVER_VERSION & 0xff0000) >> 16,
(SPICE_SERVER_VERSION & 0xff00) >> 8,
SPICE_SERVER_VERSION & 0xff);
info->compiled_version = g_strdup(version_string);
if (port) {
info->has_port = true;
info->port = port;
}
if (tls_port) {
info->has_tls_port = true;
info->tls_port = tls_port;
}
info->mouse_mode = spice_server_is_server_mouse(spice_server) ?
SPICE_QUERY_MOUSE_MODE_SERVER :
SPICE_QUERY_MOUSE_MODE_CLIENT;
info->has_channels = true;
info->channels = qmp_query_spice_channels();
return info;
}
| {
"code": [],
"line_no": []
} | SpiceInfo *FUNC_0(Error **errp)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
int VAR_0, VAR_1;
const char *VAR_2;
SpiceInfo *info;
char VAR_3[20];
info = g_malloc0(sizeof(*info));
if (!spice_server || !opts) {
info->enabled = false;
return info;
}
info->enabled = true;
info->migrated = spice_migration_completed;
VAR_2 = qemu_opt_get(opts, "VAR_2");
VAR_0 = qemu_opt_get_number(opts, "VAR_0", 0);
VAR_1 = qemu_opt_get_number(opts, "tls-VAR_0", 0);
info->has_auth = true;
info->auth = g_strdup(auth);
info->has_host = true;
info->host = g_strdup(VAR_2 ? VAR_2 : "0.0.0.0");
info->has_compiled_version = true;
snprintf(VAR_3, sizeof(VAR_3), "%d.%d.%d",
(SPICE_SERVER_VERSION & 0xff0000) >> 16,
(SPICE_SERVER_VERSION & 0xff00) >> 8,
SPICE_SERVER_VERSION & 0xff);
info->compiled_version = g_strdup(VAR_3);
if (VAR_0) {
info->has_port = true;
info->VAR_0 = VAR_0;
}
if (VAR_1) {
info->has_tls_port = true;
info->VAR_1 = VAR_1;
}
info->mouse_mode = spice_server_is_server_mouse(spice_server) ?
SPICE_QUERY_MOUSE_MODE_SERVER :
SPICE_QUERY_MOUSE_MODE_CLIENT;
info->has_channels = true;
info->channels = qmp_query_spice_channels();
return info;
}
| [
"SpiceInfo *FUNC_0(Error **errp)\n{",
"QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);",
"int VAR_0, VAR_1;",
"const char *VAR_2;",
"SpiceInfo *info;",
"char VAR_3[20];",
"info = g_malloc0(sizeof(*info));",
"if (!spice_server || !opts) {",
"info->enabled = false;",
"return info;",
"}",
"info->enabled = true;",
"info->migrated = spice_migration_completed;",
"VAR_2 = qemu_opt_get(opts, \"VAR_2\");",
"VAR_0 = qemu_opt_get_number(opts, \"VAR_0\", 0);",
"VAR_1 = qemu_opt_get_number(opts, \"tls-VAR_0\", 0);",
"info->has_auth = true;",
"info->auth = g_strdup(auth);",
"info->has_host = true;",
"info->host = g_strdup(VAR_2 ? VAR_2 : \"0.0.0.0\");",
"info->has_compiled_version = true;",
"snprintf(VAR_3, sizeof(VAR_3), \"%d.%d.%d\",\n(SPICE_SERVER_VERSION & 0xff0000) >> 16,\n(SPICE_SERVER_VERSION & 0xff00) >> 8,\nSPICE_SERVER_VERSION & 0xff);",
"info->compiled_version = g_strdup(VAR_3);",
"if (VAR_0) {",
"info->has_port = true;",
"info->VAR_0 = VAR_0;",
"}",
"if (VAR_1) {",
"info->has_tls_port = true;",
"info->VAR_1 = VAR_1;",
"}",
"info->mouse_mode = spice_server_is_server_mouse(spice_server) ?\nSPICE_QUERY_MOUSE_MODE_SERVER :\nSPICE_QUERY_MOUSE_MODE_CLIENT;",
"info->has_channels = true;",
"info->channels = qmp_query_spice_channels();",
"return info;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59,
61,
63,
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91,
93
],
[
99
],
[
101
],
[
105
],
[
107
]
] |
24,858 | void memory_region_init_rom_device(MemoryRegion *mr,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->destructor = memory_region_destructor_rom_device;
mr->ram_addr = qemu_ram_alloc(size, mr);
mr->ram_addr |= cpu_register_io_memory(memory_region_read_thunk,
memory_region_write_thunk,
mr);
mr->ram_addr |= IO_MEM_ROMD;
mr->backend_registered = true;
}
| false | qemu | 26a83ad0e793465b74a8b06a65f2f6fdc5615413 | void memory_region_init_rom_device(MemoryRegion *mr,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->destructor = memory_region_destructor_rom_device;
mr->ram_addr = qemu_ram_alloc(size, mr);
mr->ram_addr |= cpu_register_io_memory(memory_region_read_thunk,
memory_region_write_thunk,
mr);
mr->ram_addr |= IO_MEM_ROMD;
mr->backend_registered = true;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0,
const MemoryRegionOps *VAR_1,
void *VAR_2,
const char *VAR_3,
uint64_t VAR_4)
{
memory_region_init(VAR_0, VAR_3, VAR_4);
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_2 = VAR_2;
VAR_0->terminates = true;
VAR_0->destructor = memory_region_destructor_rom_device;
VAR_0->ram_addr = qemu_ram_alloc(VAR_4, VAR_0);
VAR_0->ram_addr |= cpu_register_io_memory(memory_region_read_thunk,
memory_region_write_thunk,
VAR_0);
VAR_0->ram_addr |= IO_MEM_ROMD;
VAR_0->backend_registered = true;
}
| [
"void FUNC_0(MemoryRegion *VAR_0,\nconst MemoryRegionOps *VAR_1,\nvoid *VAR_2,\nconst char *VAR_3,\nuint64_t VAR_4)\n{",
"memory_region_init(VAR_0, VAR_3, VAR_4);",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->terminates = true;",
"VAR_0->destructor = memory_region_destructor_rom_device;",
"VAR_0->ram_addr = qemu_ram_alloc(VAR_4, VAR_0);",
"VAR_0->ram_addr |= cpu_register_io_memory(memory_region_read_thunk,\nmemory_region_write_thunk,\nVAR_0);",
"VAR_0->ram_addr |= IO_MEM_ROMD;",
"VAR_0->backend_registered = true;",
"}"
] | [
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
]
] |
24,860 | av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->width = avctx->width;
s->height = avctx->height;
r->s.avctx = avctx;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
if (MPV_common_init(s) < 0)
return -1;
ff_h264_pred_init(&r->h, CODEC_ID_RV40);
r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + s->b4_stride * 4;
r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
return 0;
}
| false | FFmpeg | 3df18b3ed1177037892ce5b3db113d52dcdcdbf3 | av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->width = avctx->width;
s->height = avctx->height;
r->s.avctx = avctx;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
if (MPV_common_init(s) < 0)
return -1;
ff_h264_pred_init(&r->h, CODEC_ID_RV40);
r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + s->b4_stride * 4;
r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->width = avctx->width;
s->height = avctx->height;
r->s.avctx = avctx;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
if (MPV_common_init(s) < 0)
return -1;
ff_h264_pred_init(&r->h, CODEC_ID_RV40);
r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + s->b4_stride * 4;
r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
return 0;
}
| [
"av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"RV34DecContext *r = avctx->priv_data;",
"MpegEncContext *s = &r->s;",
"MPV_decode_defaults(s);",
"s->avctx= avctx;",
"s->out_format = FMT_H263;",
"s->codec_id= avctx->codec_id;",
"s->width = avctx->width;",
"s->height = avctx->height;",
"r->s.avctx = avctx;",
"avctx->flags |= CODEC_FLAG_EMU_EDGE;",
"r->s.flags |= CODEC_FLAG_EMU_EDGE;",
"avctx->pix_fmt = PIX_FMT_YUV420P;",
"avctx->has_b_frames = 1;",
"s->low_delay = 0;",
"if (MPV_common_init(s) < 0)\nreturn -1;",
"ff_h264_pred_init(&r->h, CODEC_ID_RV40);",
"r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));",
"r->intra_types = r->intra_types_hist + s->b4_stride * 4;",
"r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));",
"r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));",
"r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));",
"r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));",
"if(!intra_vlcs[0].cbppattern[0].bits)\nrv34_init_tables();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
47
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
75
],
[
77
]
] |
24,861 | static inline void mix_2f_2r_to_stereo(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] += output[3][i];
output[2][i] += output[4][i];
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
}
| false | FFmpeg | 486637af8ef29ec215e0e0b7ecd3b5470f0e04e5 | static inline void mix_2f_2r_to_stereo(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] += output[3][i];
output[2][i] += output[4][i];
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(AC3DecodeContext *VAR_0)
{
int VAR_1;
float (*VAR_2)[256] = VAR_0->audio_block.block_output;
for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {
VAR_2[1][VAR_1] += VAR_2[3][VAR_1];
VAR_2[2][VAR_1] += VAR_2[4][VAR_1];
}
memset(VAR_2[3], 0, sizeof(VAR_2[3]));
memset(VAR_2[4], 0, sizeof(VAR_2[4]));
}
| [
"static inline void FUNC_0(AC3DecodeContext *VAR_0)\n{",
"int VAR_1;",
"float (*VAR_2)[256] = VAR_0->audio_block.block_output;",
"for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {",
"VAR_2[1][VAR_1] += VAR_2[3][VAR_1];",
"VAR_2[2][VAR_1] += VAR_2[4][VAR_1];",
"}",
"memset(VAR_2[3], 0, sizeof(VAR_2[3]));",
"memset(VAR_2[4], 0, sizeof(VAR_2[4]));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,862 | void *qemu_vmalloc(size_t size)
{
void *p;
unsigned long addr;
mmap_lock();
/* Use map and mark the pages as used. */
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
addr = (unsigned long)p;
if (addr == (target_ulong) addr) {
/* Allocated region overlaps guest address space.
This may recurse. */
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
| false | qemu | b035ffd11813524d7c0e44354f5c4bdd281f4b37 | void *qemu_vmalloc(size_t size)
{
void *p;
unsigned long addr;
mmap_lock();
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
addr = (unsigned long)p;
if (addr == (target_ulong) addr) {
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(size_t VAR_0)
{
void *VAR_1;
unsigned long VAR_2;
mmap_lock();
VAR_1 = mmap(NULL, VAR_0, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
VAR_2 = (unsigned long)VAR_1;
if (VAR_2 == (target_ulong) VAR_2) {
page_set_flags(VAR_2 & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(VAR_2 + VAR_0),
PAGE_RESERVED);
}
mmap_unlock();
return VAR_1;
}
| [
"void *FUNC_0(size_t VAR_0)\n{",
"void *VAR_1;",
"unsigned long VAR_2;",
"mmap_lock();",
"VAR_1 = mmap(NULL, VAR_0, PROT_READ | PROT_WRITE,\nMAP_PRIVATE | MAP_ANON, -1, 0);",
"VAR_2 = (unsigned long)VAR_1;",
"if (VAR_2 == (target_ulong) VAR_2) {",
"page_set_flags(VAR_2 & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(VAR_2 + VAR_0),\nPAGE_RESERVED);",
"}",
"mmap_unlock();",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
27,
29
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
24,864 | static void rtas_query_cpu_stopped_state(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
target_ulong id;
CPUState *cpu;
if (nargs != 1 || nret != 2) {
rtas_st(rets, 0, -3);
return;
}
id = rtas_ld(args, 0);
cpu = qemu_get_cpu(id);
if (cpu != NULL) {
if (cpu->halted) {
rtas_st(rets, 1, 0);
} else {
rtas_st(rets, 1, 2);
}
rtas_st(rets, 0, 0);
return;
}
/* Didn't find a matching cpu */
rtas_st(rets, 0, -3);
}
| false | qemu | 210b580b106fa798149e28aa13c66b325a43204e | static void rtas_query_cpu_stopped_state(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
target_ulong id;
CPUState *cpu;
if (nargs != 1 || nret != 2) {
rtas_st(rets, 0, -3);
return;
}
id = rtas_ld(args, 0);
cpu = qemu_get_cpu(id);
if (cpu != NULL) {
if (cpu->halted) {
rtas_st(rets, 1, 0);
} else {
rtas_st(rets, 1, 2);
}
rtas_st(rets, 0, 0);
return;
}
rtas_st(rets, 0, -3);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPREnvironment *VAR_0,
uint32_t VAR_1, uint32_t VAR_2,
target_ulong VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{
target_ulong id;
CPUState *cpu;
if (VAR_2 != 1 || VAR_4 != 2) {
rtas_st(VAR_5, 0, -3);
return;
}
id = rtas_ld(VAR_3, 0);
cpu = qemu_get_cpu(id);
if (cpu != NULL) {
if (cpu->halted) {
rtas_st(VAR_5, 1, 0);
} else {
rtas_st(VAR_5, 1, 2);
}
rtas_st(VAR_5, 0, 0);
return;
}
rtas_st(VAR_5, 0, -3);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2,\ntarget_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{",
"target_ulong id;",
"CPUState *cpu;",
"if (VAR_2 != 1 || VAR_4 != 2) {",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"id = rtas_ld(VAR_3, 0);",
"cpu = qemu_get_cpu(id);",
"if (cpu != NULL) {",
"if (cpu->halted) {",
"rtas_st(VAR_5, 1, 0);",
"} else {",
"rtas_st(VAR_5, 1, 2);",
"}",
"rtas_st(VAR_5, 0, 0);",
"return;",
"}",
"rtas_st(VAR_5, 0, -3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
]
] |
24,866 | static void nvic_recompute_state(NVICState *s)
{
int i;
int pend_prio = NVIC_NOEXC_PRIO;
int active_prio = NVIC_NOEXC_PRIO;
int pend_irq = 0;
for (i = 1; i < s->num_irq; i++) {
VecInfo *vec = &s->vectors[i];
if (vec->enabled && vec->pending && vec->prio < pend_prio) {
pend_prio = vec->prio;
pend_irq = i;
}
if (vec->active && vec->prio < active_prio) {
active_prio = vec->prio;
}
}
if (active_prio > 0) {
active_prio &= nvic_gprio_mask(s);
}
s->vectpending = pend_irq;
s->exception_prio = active_prio;
trace_nvic_recompute_state(s->vectpending, s->exception_prio);
}
| false | qemu | 5255fcf8e47acd059e2f0d414841c40231c1bd22 | static void nvic_recompute_state(NVICState *s)
{
int i;
int pend_prio = NVIC_NOEXC_PRIO;
int active_prio = NVIC_NOEXC_PRIO;
int pend_irq = 0;
for (i = 1; i < s->num_irq; i++) {
VecInfo *vec = &s->vectors[i];
if (vec->enabled && vec->pending && vec->prio < pend_prio) {
pend_prio = vec->prio;
pend_irq = i;
}
if (vec->active && vec->prio < active_prio) {
active_prio = vec->prio;
}
}
if (active_prio > 0) {
active_prio &= nvic_gprio_mask(s);
}
s->vectpending = pend_irq;
s->exception_prio = active_prio;
trace_nvic_recompute_state(s->vectpending, s->exception_prio);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NVICState *VAR_0)
{
int VAR_1;
int VAR_2 = NVIC_NOEXC_PRIO;
int VAR_3 = NVIC_NOEXC_PRIO;
int VAR_4 = 0;
for (VAR_1 = 1; VAR_1 < VAR_0->num_irq; VAR_1++) {
VecInfo *vec = &VAR_0->vectors[VAR_1];
if (vec->enabled && vec->pending && vec->prio < VAR_2) {
VAR_2 = vec->prio;
VAR_4 = VAR_1;
}
if (vec->active && vec->prio < VAR_3) {
VAR_3 = vec->prio;
}
}
if (VAR_3 > 0) {
VAR_3 &= nvic_gprio_mask(VAR_0);
}
VAR_0->vectpending = VAR_4;
VAR_0->exception_prio = VAR_3;
trace_nvic_recompute_state(VAR_0->vectpending, VAR_0->exception_prio);
}
| [
"static void FUNC_0(NVICState *VAR_0)\n{",
"int VAR_1;",
"int VAR_2 = NVIC_NOEXC_PRIO;",
"int VAR_3 = NVIC_NOEXC_PRIO;",
"int VAR_4 = 0;",
"for (VAR_1 = 1; VAR_1 < VAR_0->num_irq; VAR_1++) {",
"VecInfo *vec = &VAR_0->vectors[VAR_1];",
"if (vec->enabled && vec->pending && vec->prio < VAR_2) {",
"VAR_2 = vec->prio;",
"VAR_4 = VAR_1;",
"}",
"if (vec->active && vec->prio < VAR_3) {",
"VAR_3 = vec->prio;",
"}",
"}",
"if (VAR_3 > 0) {",
"VAR_3 &= nvic_gprio_mask(VAR_0);",
"}",
"VAR_0->vectpending = VAR_4;",
"VAR_0->exception_prio = VAR_3;",
"trace_nvic_recompute_state(VAR_0->vectpending, VAR_0->exception_prio);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
24,867 | static int local_fsync(FsContext *ctx, int fd)
{
if (0) /* Just to supress the warning. Will be removed in next patch. */
(void)local_set_xattr(NULL, NULL);
return fsync(fd);
}
| false | qemu | e95ead32efc48157de12e0a257ea1c52541a6ce1 | static int local_fsync(FsContext *ctx, int fd)
{
if (0)
(void)local_set_xattr(NULL, NULL);
return fsync(fd);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, int VAR_1)
{
if (0)
(void)local_set_xattr(NULL, NULL);
return fsync(VAR_1);
}
| [
"static int FUNC_0(FsContext *VAR_0, int VAR_1)\n{",
"if (0)\n(void)local_set_xattr(NULL, NULL);",
"return fsync(VAR_1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
]
] |
24,868 | void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
{
BlockDriverState *bs;
QObject *obj;
Visitor *v = qmp_output_visitor_new(&obj);
QDict *qdict;
Error *local_err = NULL;
visit_type_BlockdevOptions(v, NULL, &options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto fail;
}
visit_complete(v, &obj);
qdict = qobject_to_qdict(obj);
qdict_flatten(qdict);
if (!qdict_get_try_str(qdict, "node-name")) {
error_setg(errp, "'node-name' must be specified for the root node");
goto fail;
}
bs = bds_tree_init(qdict, errp);
if (!bs) {
goto fail;
}
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
if (bs && bdrv_key_required(bs)) {
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
bdrv_unref(bs);
error_setg(errp, "blockdev-add doesn't support encrypted devices");
goto fail;
}
fail:
visit_free(v);
}
| false | qemu | 7d5e199ade76c53ec316ab6779800581bb47c50a | void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
{
BlockDriverState *bs;
QObject *obj;
Visitor *v = qmp_output_visitor_new(&obj);
QDict *qdict;
Error *local_err = NULL;
visit_type_BlockdevOptions(v, NULL, &options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto fail;
}
visit_complete(v, &obj);
qdict = qobject_to_qdict(obj);
qdict_flatten(qdict);
if (!qdict_get_try_str(qdict, "node-name")) {
error_setg(errp, "'node-name' must be specified for the root node");
goto fail;
}
bs = bds_tree_init(qdict, errp);
if (!bs) {
goto fail;
}
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
if (bs && bdrv_key_required(bs)) {
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
bdrv_unref(bs);
error_setg(errp, "blockdev-add doesn't support encrypted devices");
goto fail;
}
fail:
visit_free(v);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockdevOptions *VAR_0, Error **VAR_1)
{
BlockDriverState *bs;
QObject *obj;
Visitor *v = qmp_output_visitor_new(&obj);
QDict *qdict;
Error *local_err = NULL;
visit_type_BlockdevOptions(v, NULL, &VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
goto fail;
}
visit_complete(v, &obj);
qdict = qobject_to_qdict(obj);
qdict_flatten(qdict);
if (!qdict_get_try_str(qdict, "node-name")) {
error_setg(VAR_1, "'node-name' must be specified for the root node");
goto fail;
}
bs = bds_tree_init(qdict, VAR_1);
if (!bs) {
goto fail;
}
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
if (bs && bdrv_key_required(bs)) {
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
bdrv_unref(bs);
error_setg(VAR_1, "blockdev-add doesn't support encrypted devices");
goto fail;
}
fail:
visit_free(v);
}
| [
"void FUNC_0(BlockdevOptions *VAR_0, Error **VAR_1)\n{",
"BlockDriverState *bs;",
"QObject *obj;",
"Visitor *v = qmp_output_visitor_new(&obj);",
"QDict *qdict;",
"Error *local_err = NULL;",
"visit_type_BlockdevOptions(v, NULL, &VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"goto fail;",
"}",
"visit_complete(v, &obj);",
"qdict = qobject_to_qdict(obj);",
"qdict_flatten(qdict);",
"if (!qdict_get_try_str(qdict, \"node-name\")) {",
"error_setg(VAR_1, \"'node-name' must be specified for the root node\");",
"goto fail;",
"}",
"bs = bds_tree_init(qdict, VAR_1);",
"if (!bs) {",
"goto fail;",
"}",
"QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);",
"if (bs && bdrv_key_required(bs)) {",
"QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);",
"bdrv_unref(bs);",
"error_setg(VAR_1, \"blockdev-add doesn't support encrypted devices\");",
"goto fail;",
"}",
"fail:\nvisit_free(v);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
]
] |
24,869 | static int segment_start(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
int err = 0;
if (seg->wrap)
seg->number %= seg->wrap;
if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
s->filename, seg->number++) < 0)
return AVERROR(EINVAL);
if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
return err;
if (!oc->priv_data && oc->oformat->priv_data_size > 0) {
oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
if (!oc->priv_data) {
avio_close(oc->pb);
return AVERROR(ENOMEM);
}
if (oc->oformat->priv_class) {
*(const AVClass**)oc->priv_data = oc->oformat->priv_class;
av_opt_set_defaults(oc->priv_data);
}
}
if ((err = oc->oformat->write_header(oc)) < 0) {
goto fail;
}
return 0;
fail:
av_log(oc, AV_LOG_ERROR, "Failure occurred when starting segment '%s'\n",
oc->filename);
avio_close(oc->pb);
av_freep(&oc->priv_data);
return err;
}
| false | FFmpeg | d8013f38ab73b15c5041f2489fc0b8bb45512e24 | static int segment_start(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
int err = 0;
if (seg->wrap)
seg->number %= seg->wrap;
if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
s->filename, seg->number++) < 0)
return AVERROR(EINVAL);
if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
return err;
if (!oc->priv_data && oc->oformat->priv_data_size > 0) {
oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
if (!oc->priv_data) {
avio_close(oc->pb);
return AVERROR(ENOMEM);
}
if (oc->oformat->priv_class) {
*(const AVClass**)oc->priv_data = oc->oformat->priv_class;
av_opt_set_defaults(oc->priv_data);
}
}
if ((err = oc->oformat->write_header(oc)) < 0) {
goto fail;
}
return 0;
fail:
av_log(oc, AV_LOG_ERROR, "Failure occurred when starting segment '%s'\n",
oc->filename);
avio_close(oc->pb);
av_freep(&oc->priv_data);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
SegmentContext *seg = VAR_0->priv_data;
AVFormatContext *oc = seg->avf;
int VAR_1 = 0;
if (seg->wrap)
seg->number %= seg->wrap;
if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
VAR_0->filename, seg->number++) < 0)
return AVERROR(EINVAL);
if ((VAR_1 = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&VAR_0->interrupt_callback, NULL)) < 0)
return VAR_1;
if (!oc->priv_data && oc->oformat->priv_data_size > 0) {
oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
if (!oc->priv_data) {
avio_close(oc->pb);
return AVERROR(ENOMEM);
}
if (oc->oformat->priv_class) {
*(const AVClass**)oc->priv_data = oc->oformat->priv_class;
av_opt_set_defaults(oc->priv_data);
}
}
if ((VAR_1 = oc->oformat->write_header(oc)) < 0) {
goto fail;
}
return 0;
fail:
av_log(oc, AV_LOG_ERROR, "Failure occurred when starting segment '%VAR_0'\n",
oc->filename);
avio_close(oc->pb);
av_freep(&oc->priv_data);
return VAR_1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"SegmentContext *seg = VAR_0->priv_data;",
"AVFormatContext *oc = seg->avf;",
"int VAR_1 = 0;",
"if (seg->wrap)\nseg->number %= seg->wrap;",
"if (av_get_frame_filename(oc->filename, sizeof(oc->filename),\nVAR_0->filename, seg->number++) < 0)\nreturn AVERROR(EINVAL);",
"if ((VAR_1 = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,\n&VAR_0->interrupt_callback, NULL)) < 0)\nreturn VAR_1;",
"if (!oc->priv_data && oc->oformat->priv_data_size > 0) {",
"oc->priv_data = av_mallocz(oc->oformat->priv_data_size);",
"if (!oc->priv_data) {",
"avio_close(oc->pb);",
"return AVERROR(ENOMEM);",
"}",
"if (oc->oformat->priv_class) {",
"*(const AVClass**)oc->priv_data = oc->oformat->priv_class;",
"av_opt_set_defaults(oc->priv_data);",
"}",
"}",
"if ((VAR_1 = oc->oformat->write_header(oc)) < 0) {",
"goto fail;",
"}",
"return 0;",
"fail:\nav_log(oc, AV_LOG_ERROR, \"Failure occurred when starting segment '%VAR_0'\\n\",\noc->filename);",
"avio_close(oc->pb);",
"av_freep(&oc->priv_data);",
"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,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19,
21,
23
],
[
27,
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71,
73,
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
24,870 | static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
if (vf->priv->in.fmt == vf->priv->out.fmt) { //nothing to do
dmpi = mpi;
} else {
int out_off_left, out_off_right;
int in_off_left = vf->priv->in.row_left * mpi->stride[0] +
vf->priv->in.off_left;
int in_off_right = vf->priv->in.row_right * mpi->stride[0] +
vf->priv->in.off_right;
dmpi = ff_vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP,
MP_IMGFLAG_ACCEPT_STRIDE,
vf->priv->out.width, vf->priv->out.height);
out_off_left = vf->priv->out.row_left * dmpi->stride[0] +
vf->priv->out.off_left;
out_off_right = vf->priv->out.row_right * dmpi->stride[0] +
vf->priv->out.off_right;
switch (vf->priv->out.fmt) {
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
memcpy_pic2(dmpi->planes[0] + out_off_left,
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
memcpy_pic2(dmpi->planes[0] + out_off_right,
mpi->planes[0] + in_off_right,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
break;
case MONO_L:
case MONO_R:
memcpy_pic(dmpi->planes[0],
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0],
mpi->stride[0]);
break;
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR: {
int i,x,y,il,ir,o;
unsigned char *source = mpi->planes[0];
unsigned char *dest = dmpi->planes[0];
unsigned int out_width = vf->priv->out.width;
int *ana_matrix[3];
for(i = 0; i < 3; i++)
ana_matrix[i] = vf->priv->ana_matrix[i];
for (y = 0; y < vf->priv->out.height; y++) {
o = dmpi->stride[0] * y;
il = in_off_left + y * mpi->stride[0];
ir = in_off_right + y * mpi->stride[0];
for (x = 0; x < out_width; x++) {
dest[o ] = ana_convert(
ana_matrix[0], source + il, source + ir); //red out
dest[o + 1] = ana_convert(
ana_matrix[1], source + il, source + ir); //green out
dest[o + 2] = ana_convert(
ana_matrix[2], source + il, source + ir); //blue out
il += 3;
ir += 3;
o += 3;
}
}
break;
}
default:
ff_mp_msg(MSGT_VFILTER, MSGL_WARN,
"[stereo3d] stereo format of output is not supported\n");
return 0;
break;
}
}
return ff_vf_next_put_image(vf, dmpi, pts);
}
| false | FFmpeg | 708ed15d8ccd5ae3d073cbd4dc69dafccec3fcc7 | static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
if (vf->priv->in.fmt == vf->priv->out.fmt) {
dmpi = mpi;
} else {
int out_off_left, out_off_right;
int in_off_left = vf->priv->in.row_left * mpi->stride[0] +
vf->priv->in.off_left;
int in_off_right = vf->priv->in.row_right * mpi->stride[0] +
vf->priv->in.off_right;
dmpi = ff_vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP,
MP_IMGFLAG_ACCEPT_STRIDE,
vf->priv->out.width, vf->priv->out.height);
out_off_left = vf->priv->out.row_left * dmpi->stride[0] +
vf->priv->out.off_left;
out_off_right = vf->priv->out.row_right * dmpi->stride[0] +
vf->priv->out.off_right;
switch (vf->priv->out.fmt) {
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
memcpy_pic2(dmpi->planes[0] + out_off_left,
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
memcpy_pic2(dmpi->planes[0] + out_off_right,
mpi->planes[0] + in_off_right,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
break;
case MONO_L:
case MONO_R:
memcpy_pic(dmpi->planes[0],
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0],
mpi->stride[0]);
break;
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR: {
int i,x,y,il,ir,o;
unsigned char *source = mpi->planes[0];
unsigned char *dest = dmpi->planes[0];
unsigned int out_width = vf->priv->out.width;
int *ana_matrix[3];
for(i = 0; i < 3; i++)
ana_matrix[i] = vf->priv->ana_matrix[i];
for (y = 0; y < vf->priv->out.height; y++) {
o = dmpi->stride[0] * y;
il = in_off_left + y * mpi->stride[0];
ir = in_off_right + y * mpi->stride[0];
for (x = 0; x < out_width; x++) {
dest[o ] = ana_convert(
ana_matrix[0], source + il, source + ir);
dest[o + 1] = ana_convert(
ana_matrix[1], source + il, source + ir);
dest[o + 2] = ana_convert(
ana_matrix[2], source + il, source + ir);
il += 3;
ir += 3;
o += 3;
}
}
break;
}
default:
ff_mp_msg(MSGT_VFILTER, MSGL_WARN,
"[stereo3d] stereo format of output is not supported\n");
return 0;
break;
}
}
return ff_vf_next_put_image(vf, dmpi, pts);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct vf_instance *VAR_0, mp_image_t *VAR_1, double VAR_2)
{
mp_image_t *dmpi;
if (VAR_0->priv->in.fmt == VAR_0->priv->out.fmt) {
dmpi = VAR_1;
} else {
int VAR_3, VAR_4;
int VAR_5 = VAR_0->priv->in.row_left * VAR_1->stride[0] +
VAR_0->priv->in.off_left;
int VAR_6 = VAR_0->priv->in.row_right * VAR_1->stride[0] +
VAR_0->priv->in.off_right;
dmpi = ff_vf_get_image(VAR_0->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP,
MP_IMGFLAG_ACCEPT_STRIDE,
VAR_0->priv->out.width, VAR_0->priv->out.height);
VAR_3 = VAR_0->priv->out.row_left * dmpi->stride[0] +
VAR_0->priv->out.off_left;
VAR_4 = VAR_0->priv->out.row_right * dmpi->stride[0] +
VAR_0->priv->out.off_right;
switch (VAR_0->priv->out.fmt) {
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
memcpy_pic2(dmpi->planes[0] + VAR_3,
VAR_1->planes[0] + VAR_5,
3 * VAR_0->priv->width,
VAR_0->priv->height,
dmpi->stride[0] * VAR_0->priv->row_step,
VAR_1->stride[0] * VAR_0->priv->row_step,
VAR_0->priv->row_step != 1);
memcpy_pic2(dmpi->planes[0] + VAR_4,
VAR_1->planes[0] + VAR_6,
3 * VAR_0->priv->width,
VAR_0->priv->height,
dmpi->stride[0] * VAR_0->priv->row_step,
VAR_1->stride[0] * VAR_0->priv->row_step,
VAR_0->priv->row_step != 1);
break;
case MONO_L:
case MONO_R:
memcpy_pic(dmpi->planes[0],
VAR_1->planes[0] + VAR_5,
3 * VAR_0->priv->width,
VAR_0->priv->height,
dmpi->stride[0],
VAR_1->stride[0]);
break;
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR: {
int VAR_7,VAR_8,VAR_9,VAR_10,VAR_11,VAR_12;
unsigned char *VAR_13 = VAR_1->planes[0];
unsigned char *VAR_14 = dmpi->planes[0];
unsigned int VAR_15 = VAR_0->priv->out.width;
int *VAR_16[3];
for(VAR_7 = 0; VAR_7 < 3; VAR_7++)
VAR_16[VAR_7] = VAR_0->priv->VAR_16[VAR_7];
for (VAR_9 = 0; VAR_9 < VAR_0->priv->out.height; VAR_9++) {
VAR_12 = dmpi->stride[0] * VAR_9;
VAR_10 = VAR_5 + VAR_9 * VAR_1->stride[0];
VAR_11 = VAR_6 + VAR_9 * VAR_1->stride[0];
for (VAR_8 = 0; VAR_8 < VAR_15; VAR_8++) {
VAR_14[VAR_12 ] = ana_convert(
VAR_16[0], VAR_13 + VAR_10, VAR_13 + VAR_11);
VAR_14[VAR_12 + 1] = ana_convert(
VAR_16[1], VAR_13 + VAR_10, VAR_13 + VAR_11);
VAR_14[VAR_12 + 2] = ana_convert(
VAR_16[2], VAR_13 + VAR_10, VAR_13 + VAR_11);
VAR_10 += 3;
VAR_11 += 3;
VAR_12 += 3;
}
}
break;
}
default:
ff_mp_msg(MSGT_VFILTER, MSGL_WARN,
"[stereo3d] stereo format of output is not supported\n");
return 0;
break;
}
}
return ff_vf_next_put_image(VAR_0, dmpi, VAR_2);
}
| [
"static int FUNC_0(struct vf_instance *VAR_0, mp_image_t *VAR_1, double VAR_2)\n{",
"mp_image_t *dmpi;",
"if (VAR_0->priv->in.fmt == VAR_0->priv->out.fmt) {",
"dmpi = VAR_1;",
"} else {",
"int VAR_3, VAR_4;",
"int VAR_5 = VAR_0->priv->in.row_left * VAR_1->stride[0] +\nVAR_0->priv->in.off_left;",
"int VAR_6 = VAR_0->priv->in.row_right * VAR_1->stride[0] +\nVAR_0->priv->in.off_right;",
"dmpi = ff_vf_get_image(VAR_0->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP,\nMP_IMGFLAG_ACCEPT_STRIDE,\nVAR_0->priv->out.width, VAR_0->priv->out.height);",
"VAR_3 = VAR_0->priv->out.row_left * dmpi->stride[0] +\nVAR_0->priv->out.off_left;",
"VAR_4 = VAR_0->priv->out.row_right * dmpi->stride[0] +\nVAR_0->priv->out.off_right;",
"switch (VAR_0->priv->out.fmt) {",
"case SIDE_BY_SIDE_LR:\ncase SIDE_BY_SIDE_RL:\ncase SIDE_BY_SIDE_2_LR:\ncase SIDE_BY_SIDE_2_RL:\ncase ABOVE_BELOW_LR:\ncase ABOVE_BELOW_RL:\ncase ABOVE_BELOW_2_LR:\ncase ABOVE_BELOW_2_RL:\ncase INTERLEAVE_ROWS_LR:\ncase INTERLEAVE_ROWS_RL:\nmemcpy_pic2(dmpi->planes[0] + VAR_3,\nVAR_1->planes[0] + VAR_5,\n3 * VAR_0->priv->width,\nVAR_0->priv->height,\ndmpi->stride[0] * VAR_0->priv->row_step,\nVAR_1->stride[0] * VAR_0->priv->row_step,\nVAR_0->priv->row_step != 1);",
"memcpy_pic2(dmpi->planes[0] + VAR_4,\nVAR_1->planes[0] + VAR_6,\n3 * VAR_0->priv->width,\nVAR_0->priv->height,\ndmpi->stride[0] * VAR_0->priv->row_step,\nVAR_1->stride[0] * VAR_0->priv->row_step,\nVAR_0->priv->row_step != 1);",
"break;",
"case MONO_L:\ncase MONO_R:\nmemcpy_pic(dmpi->planes[0],\nVAR_1->planes[0] + VAR_5,\n3 * VAR_0->priv->width,\nVAR_0->priv->height,\ndmpi->stride[0],\nVAR_1->stride[0]);",
"break;",
"case ANAGLYPH_RC_GRAY:\ncase ANAGLYPH_RC_HALF:\ncase ANAGLYPH_RC_COLOR:\ncase ANAGLYPH_RC_DUBOIS:\ncase ANAGLYPH_GM_GRAY:\ncase ANAGLYPH_GM_HALF:\ncase ANAGLYPH_GM_COLOR:\ncase ANAGLYPH_YB_GRAY:\ncase ANAGLYPH_YB_HALF:\ncase ANAGLYPH_YB_COLOR: {",
"int VAR_7,VAR_8,VAR_9,VAR_10,VAR_11,VAR_12;",
"unsigned char *VAR_13 = VAR_1->planes[0];",
"unsigned char *VAR_14 = dmpi->planes[0];",
"unsigned int VAR_15 = VAR_0->priv->out.width;",
"int *VAR_16[3];",
"for(VAR_7 = 0; VAR_7 < 3; VAR_7++)",
"VAR_16[VAR_7] = VAR_0->priv->VAR_16[VAR_7];",
"for (VAR_9 = 0; VAR_9 < VAR_0->priv->out.height; VAR_9++) {",
"VAR_12 = dmpi->stride[0] * VAR_9;",
"VAR_10 = VAR_5 + VAR_9 * VAR_1->stride[0];",
"VAR_11 = VAR_6 + VAR_9 * VAR_1->stride[0];",
"for (VAR_8 = 0; VAR_8 < VAR_15; VAR_8++) {",
"VAR_14[VAR_12 ] = ana_convert(\nVAR_16[0], VAR_13 + VAR_10, VAR_13 + VAR_11);",
"VAR_14[VAR_12 + 1] = ana_convert(\nVAR_16[1], VAR_13 + VAR_10, VAR_13 + VAR_11);",
"VAR_14[VAR_12 + 2] = ana_convert(\nVAR_16[2], VAR_13 + VAR_10, VAR_13 + VAR_11);",
"VAR_10 += 3;",
"VAR_11 += 3;",
"VAR_12 += 3;",
"}",
"}",
"break;",
"}",
"default:\nff_mp_msg(MSGT_VFILTER, MSGL_WARN,\n\"[stereo3d] stereo format of output is not supported\\n\");",
"return 0;",
"break;",
"}",
"}",
"return ff_vf_next_put_image(VAR_0, dmpi, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
25,
27,
29
],
[
31,
33
],
[
35,
37
],
[
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
],
[
143
],
[
145
],
[
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
]
] |
24,871 | static void vfio_platform_realize(DeviceState *dev, Error **errp)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
SysBusDevice *sbdev = SYS_BUS_DEVICE(dev);
VFIODevice *vbasedev = &vdev->vbasedev;
int i, ret;
vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
vbasedev->ops = &vfio_platform_ops;
trace_vfio_platform_realize(vbasedev->name, vdev->compat);
ret = vfio_base_device_init(vbasedev);
if (ret) {
error_setg(errp, "vfio: vfio_base_device_init failed for %s",
vbasedev->name);
return;
}
for (i = 0; i < vbasedev->num_regions; i++) {
vfio_map_region(vdev, i);
sysbus_init_mmio(sbdev, &vdev->regions[i]->mem);
}
}
| false | qemu | 7df9381b7aa56c897e344f3bfe43bf5848bbd3e0 | static void vfio_platform_realize(DeviceState *dev, Error **errp)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
SysBusDevice *sbdev = SYS_BUS_DEVICE(dev);
VFIODevice *vbasedev = &vdev->vbasedev;
int i, ret;
vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
vbasedev->ops = &vfio_platform_ops;
trace_vfio_platform_realize(vbasedev->name, vdev->compat);
ret = vfio_base_device_init(vbasedev);
if (ret) {
error_setg(errp, "vfio: vfio_base_device_init failed for %s",
vbasedev->name);
return;
}
for (i = 0; i < vbasedev->num_regions; i++) {
vfio_map_region(vdev, i);
sysbus_init_mmio(sbdev, &vdev->regions[i]->mem);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(VAR_0);
SysBusDevice *sbdev = SYS_BUS_DEVICE(VAR_0);
VFIODevice *vbasedev = &vdev->vbasedev;
int VAR_2, VAR_3;
vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
vbasedev->ops = &vfio_platform_ops;
trace_vfio_platform_realize(vbasedev->name, vdev->compat);
VAR_3 = vfio_base_device_init(vbasedev);
if (VAR_3) {
error_setg(VAR_1, "vfio: vfio_base_device_init failed for %s",
vbasedev->name);
return;
}
for (VAR_2 = 0; VAR_2 < vbasedev->num_regions; VAR_2++) {
vfio_map_region(vdev, VAR_2);
sysbus_init_mmio(sbdev, &vdev->regions[VAR_2]->mem);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(VAR_0);",
"SysBusDevice *sbdev = SYS_BUS_DEVICE(VAR_0);",
"VFIODevice *vbasedev = &vdev->vbasedev;",
"int VAR_2, VAR_3;",
"vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;",
"vbasedev->ops = &vfio_platform_ops;",
"trace_vfio_platform_realize(vbasedev->name, vdev->compat);",
"VAR_3 = vfio_base_device_init(vbasedev);",
"if (VAR_3) {",
"error_setg(VAR_1, \"vfio: vfio_base_device_init failed for %s\",\nvbasedev->name);",
"return;",
"}",
"for (VAR_2 = 0; VAR_2 < vbasedev->num_regions; VAR_2++) {",
"vfio_map_region(vdev, VAR_2);",
"sysbus_init_mmio(sbdev, &vdev->regions[VAR_2]->mem);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
24,873 | void json_lexer_destroy(JSONLexer *lexer)
{
QDECREF(lexer->token);
}
| false | qemu | d2ca7c0b0d876cf0e219ae7a92252626b0913a28 | void json_lexer_destroy(JSONLexer *lexer)
{
QDECREF(lexer->token);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(JSONLexer *VAR_0)
{
QDECREF(VAR_0->token);
}
| [
"void FUNC_0(JSONLexer *VAR_0)\n{",
"QDECREF(VAR_0->token);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,874 | static void pcnet_ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t data, unsigned size)
{
PCNetState *d = opaque;
if (addr < 16 && size == 1) {
return pcnet_aprom_writeb(d, addr, data);
} else if (addr >= 0x10 && addr < 0x20 && size == 2) {
return pcnet_ioport_writew(d, addr, data);
} else if (addr >= 0x10 && addr < 0x20 && size == 4) {
return pcnet_ioport_writel(d, addr, data);
}
}
| false | qemu | 7ba7974197090285fdb413c6e1c41aaacd44b9c4 | static void pcnet_ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t data, unsigned size)
{
PCNetState *d = opaque;
if (addr < 16 && size == 1) {
return pcnet_aprom_writeb(d, addr, data);
} else if (addr >= 0x10 && addr < 0x20 && size == 2) {
return pcnet_ioport_writew(d, addr, data);
} else if (addr >= 0x10 && addr < 0x20 && size == 4) {
return pcnet_ioport_writel(d, addr, data);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
PCNetState *d = VAR_0;
if (VAR_1 < 16 && VAR_3 == 1) {
return pcnet_aprom_writeb(d, VAR_1, VAR_2);
} else if (VAR_1 >= 0x10 && VAR_1 < 0x20 && VAR_3 == 2) {
return pcnet_ioport_writew(d, VAR_1, VAR_2);
} else if (VAR_1 >= 0x10 && VAR_1 < 0x20 && VAR_3 == 4) {
return pcnet_ioport_writel(d, VAR_1, VAR_2);
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"PCNetState *d = VAR_0;",
"if (VAR_1 < 16 && VAR_3 == 1) {",
"return pcnet_aprom_writeb(d, VAR_1, VAR_2);",
"} else if (VAR_1 >= 0x10 && VAR_1 < 0x20 && VAR_3 == 2) {",
"return pcnet_ioport_writew(d, VAR_1, VAR_2);",
"} else if (VAR_1 >= 0x10 && VAR_1 < 0x20 && VAR_3 == 4) {",
"return pcnet_ioport_writel(d, VAR_1, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
24,875 | build_hash_table (const sparc_opcode **opcode_table,
sparc_opcode_hash **hash_table,
int num_opcodes)
{
int i;
int hash_count[HASH_SIZE];
static sparc_opcode_hash *hash_buf = NULL;
/* Start at the end of the table and work backwards so that each
chain is sorted. */
memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
if (hash_buf != NULL)
free (hash_buf);
hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
for (i = num_opcodes - 1; i >= 0; --i)
{
int hash = HASH_INSN (opcode_table[i]->match);
sparc_opcode_hash *h = &hash_buf[i];
h->next = hash_table[hash];
h->opcode = opcode_table[i];
hash_table[hash] = h;
++hash_count[hash];
}
#if 0 /* for debugging */
{
int min_count = num_opcodes, max_count = 0;
int total;
for (i = 0; i < HASH_SIZE; ++i)
{
if (hash_count[i] < min_count)
min_count = hash_count[i];
if (hash_count[i] > max_count)
max_count = hash_count[i];
total += hash_count[i];
}
printf ("Opcode hash table stats: min %d, max %d, ave %f\n",
min_count, max_count, (double) total / HASH_SIZE);
}
#endif
}
| false | qemu | ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374 | build_hash_table (const sparc_opcode **opcode_table,
sparc_opcode_hash **hash_table,
int num_opcodes)
{
int i;
int hash_count[HASH_SIZE];
static sparc_opcode_hash *hash_buf = NULL;
memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
if (hash_buf != NULL)
free (hash_buf);
hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
for (i = num_opcodes - 1; i >= 0; --i)
{
int hash = HASH_INSN (opcode_table[i]->match);
sparc_opcode_hash *h = &hash_buf[i];
h->next = hash_table[hash];
h->opcode = opcode_table[i];
hash_table[hash] = h;
++hash_count[hash];
}
#if 0
{
int min_count = num_opcodes, max_count = 0;
int total;
for (i = 0; i < HASH_SIZE; ++i)
{
if (hash_count[i] < min_count)
min_count = hash_count[i];
if (hash_count[i] > max_count)
max_count = hash_count[i];
total += hash_count[i];
}
printf ("Opcode hash table stats: min %d, max %d, ave %f\n",
min_count, max_count, (double) total / HASH_SIZE);
}
#endif
}
| {
"code": [],
"line_no": []
} | FUNC_0 (const sparc_opcode **VAR_0,
sparc_opcode_hash **VAR_1,
int VAR_2)
{
int VAR_3;
int VAR_4[HASH_SIZE];
static sparc_opcode_hash *VAR_5 = NULL;
memset (VAR_1, 0, HASH_SIZE * sizeof (VAR_1[0]));
memset (VAR_4, 0, HASH_SIZE * sizeof (VAR_4[0]));
if (VAR_5 != NULL)
free (VAR_5);
VAR_5 = malloc (sizeof (* VAR_5) * VAR_2);
for (VAR_3 = VAR_2 - 1; VAR_3 >= 0; --VAR_3)
{
int VAR_6 = HASH_INSN (VAR_0[VAR_3]->match);
sparc_opcode_hash *h = &VAR_5[VAR_3];
h->next = VAR_1[VAR_6];
h->opcode = VAR_0[VAR_3];
VAR_1[VAR_6] = h;
++VAR_4[VAR_6];
}
#if 0
{
int min_count = VAR_2, max_count = 0;
int total;
for (VAR_3 = 0; VAR_3 < HASH_SIZE; ++VAR_3)
{
if (VAR_4[VAR_3] < min_count)
min_count = VAR_4[VAR_3];
if (VAR_4[VAR_3] > max_count)
max_count = VAR_4[VAR_3];
total += VAR_4[VAR_3];
}
printf ("Opcode VAR_6 table stats: min %d, max %d, ave %f\n",
min_count, max_count, (double) total / HASH_SIZE);
}
#endif
}
| [
"FUNC_0 (const sparc_opcode **VAR_0,\nsparc_opcode_hash **VAR_1,\nint VAR_2)\n{",
"int VAR_3;",
"int VAR_4[HASH_SIZE];",
"static sparc_opcode_hash *VAR_5 = NULL;",
"memset (VAR_1, 0, HASH_SIZE * sizeof (VAR_1[0]));",
"memset (VAR_4, 0, HASH_SIZE * sizeof (VAR_4[0]));",
"if (VAR_5 != NULL)\nfree (VAR_5);",
"VAR_5 = malloc (sizeof (* VAR_5) * VAR_2);",
"for (VAR_3 = VAR_2 - 1; VAR_3 >= 0; --VAR_3)",
"{",
"int VAR_6 = HASH_INSN (VAR_0[VAR_3]->match);",
"sparc_opcode_hash *h = &VAR_5[VAR_3];",
"h->next = VAR_1[VAR_6];",
"h->opcode = VAR_0[VAR_3];",
"VAR_1[VAR_6] = h;",
"++VAR_4[VAR_6];",
"}",
"#if 0\n{",
"int min_count = VAR_2, max_count = 0;",
"int total;",
"for (VAR_3 = 0; VAR_3 < HASH_SIZE; ++VAR_3)",
"{",
"if (VAR_4[VAR_3] < min_count)\nmin_count = VAR_4[VAR_3];",
"if (VAR_4[VAR_3] > max_count)\nmax_count = VAR_4[VAR_3];",
"total += VAR_4[VAR_3];",
"}",
"printf (\"Opcode VAR_6 table stats: min %d, max %d, ave %f\\n\",\nmin_count, max_count, (double) total / HASH_SIZE);",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
89,
91
]
] |
24,876 | void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
nbd_client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| false | qemu | f53a829bb9ef14be800556cbc02d8b20fc1050a7 | void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
nbd_client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(NBDExport *VAR_0)
{
NBDClient *client, *next;
nbd_export_get(VAR_0);
QTAILQ_FOREACH_SAFE(client, &VAR_0->clients, next, next) {
nbd_client_close(client);
}
nbd_export_set_name(VAR_0, NULL);
nbd_export_put(VAR_0);
if (VAR_0->blk) {
blk_remove_aio_context_notifier(VAR_0->blk, blk_aio_attached,
blk_aio_detach, VAR_0);
blk_unref(VAR_0->blk);
VAR_0->blk = NULL;
}
}
| [
"void FUNC_0(NBDExport *VAR_0)\n{",
"NBDClient *client, *next;",
"nbd_export_get(VAR_0);",
"QTAILQ_FOREACH_SAFE(client, &VAR_0->clients, next, next) {",
"nbd_client_close(client);",
"}",
"nbd_export_set_name(VAR_0, NULL);",
"nbd_export_put(VAR_0);",
"if (VAR_0->blk) {",
"blk_remove_aio_context_notifier(VAR_0->blk, blk_aio_attached,\nblk_aio_detach, VAR_0);",
"blk_unref(VAR_0->blk);",
"VAR_0->blk = NULL;",
"}",
"}"
] | [
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
]
] |
24,877 | static void gen_spr_power8_book4(CPUPPCState *env)
{
/* Add a number of P8 book4 registers */
#if !defined(CONFIG_USER_ONLY)
spr_register_kvm(env, SPR_ACOP, "ACOP",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_ACOP, 0);
spr_register_kvm(env, SPR_BOOKS_PID, "PID",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_PID, 0);
spr_register_kvm(env, SPR_WORT, "WORT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_WORT, 0);
#endif
}
| false | qemu | 31b2b0f8463533c32b5ad76e73668e2e9fca8ae2 | static void gen_spr_power8_book4(CPUPPCState *env)
{
#if !defined(CONFIG_USER_ONLY)
spr_register_kvm(env, SPR_ACOP, "ACOP",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_ACOP, 0);
spr_register_kvm(env, SPR_BOOKS_PID, "PID",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_PID, 0);
spr_register_kvm(env, SPR_WORT, "WORT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_WORT, 0);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUPPCState *VAR_0)
{
#if !defined(CONFIG_USER_ONLY)
spr_register_kvm(VAR_0, SPR_ACOP, "ACOP",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_ACOP, 0);
spr_register_kvm(VAR_0, SPR_BOOKS_PID, "PID",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_PID, 0);
spr_register_kvm(VAR_0, SPR_WORT, "WORT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_WORT, 0);
#endif
}
| [
"static void FUNC_0(CPUPPCState *VAR_0)\n{",
"#if !defined(CONFIG_USER_ONLY)\nspr_register_kvm(VAR_0, SPR_ACOP, \"ACOP\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nKVM_REG_PPC_ACOP, 0);",
"spr_register_kvm(VAR_0, SPR_BOOKS_PID, \"PID\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nKVM_REG_PPC_PID, 0);",
"spr_register_kvm(VAR_0, SPR_WORT, \"WORT\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nKVM_REG_PPC_WORT, 0);",
"#endif\n}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7,
9,
11,
13,
15
],
[
17,
19,
21,
23
],
[
25,
27,
29,
31
],
[
33,
35
]
] |
24,878 | int cpu_m68k_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int mmu_idx, int is_softmmu)
{
int prot;
address &= TARGET_PAGE_MASK;
prot = PAGE_READ | PAGE_WRITE;
return tlb_set_page(env, address, address, prot, mmu_idx, is_softmmu);
}
| false | qemu | d4c430a80f000d722bb70287af4d4c184a8d7006 | int cpu_m68k_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int mmu_idx, int is_softmmu)
{
int prot;
address &= TARGET_PAGE_MASK;
prot = PAGE_READ | PAGE_WRITE;
return tlb_set_page(env, address, address, prot, mmu_idx, is_softmmu);
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,
int VAR_3, int VAR_4)
{
int VAR_5;
VAR_1 &= TARGET_PAGE_MASK;
VAR_5 = PAGE_READ | PAGE_WRITE;
return tlb_set_page(VAR_0, VAR_1, VAR_1, VAR_5, VAR_3, VAR_4);
}
| [
"int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{",
"int VAR_5;",
"VAR_1 &= TARGET_PAGE_MASK;",
"VAR_5 = PAGE_READ | PAGE_WRITE;",
"return tlb_set_page(VAR_0, VAR_1, VAR_1, VAR_5, VAR_3, VAR_4);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
24,879 | void helper_movl_crN_T0(int reg)
{
env->cr[reg] = T0;
switch(reg) {
case 0:
cpu_x86_update_cr0(env);
break;
case 3:
cpu_x86_update_cr3(env);
break;
}
}
| false | qemu | 1ac157da77c863b62b1d2f467626a440d57cf17d | void helper_movl_crN_T0(int reg)
{
env->cr[reg] = T0;
switch(reg) {
case 0:
cpu_x86_update_cr0(env);
break;
case 3:
cpu_x86_update_cr3(env);
break;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0)
{
env->cr[VAR_0] = T0;
switch(VAR_0) {
case 0:
cpu_x86_update_cr0(env);
break;
case 3:
cpu_x86_update_cr3(env);
break;
}
}
| [
"void FUNC_0(int VAR_0)\n{",
"env->cr[VAR_0] = T0;",
"switch(VAR_0) {",
"case 0:\ncpu_x86_update_cr0(env);",
"break;",
"case 3:\ncpu_x86_update_cr3(env);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
]
] |
24,882 | static bool pmsav7_needed(void *opaque)
{
ARMCPU *cpu = opaque;
CPUARMState *env = &cpu->env;
return arm_feature(env, ARM_FEATURE_PMSA) &&
arm_feature(env, ARM_FEATURE_V7);
}
| false | qemu | 0e1a46bbd2d6c39614b87f4e88ea305acce8a35f | static bool pmsav7_needed(void *opaque)
{
ARMCPU *cpu = opaque;
CPUARMState *env = &cpu->env;
return arm_feature(env, ARM_FEATURE_PMSA) &&
arm_feature(env, ARM_FEATURE_V7);
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(void *opaque)
{
ARMCPU *cpu = opaque;
CPUARMState *env = &cpu->env;
return arm_feature(env, ARM_FEATURE_PMSA) &&
arm_feature(env, ARM_FEATURE_V7);
}
| [
"static bool FUNC_0(void *opaque)\n{",
"ARMCPU *cpu = opaque;",
"CPUARMState *env = &cpu->env;",
"return arm_feature(env, ARM_FEATURE_PMSA) &&\narm_feature(env, ARM_FEATURE_V7);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
]
] |
24,883 | int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx,
target_ulong address, int rw, int access_type)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int i, ret, zsel, zpr;
ret = -1;
raddr = -1;
for (i = 0; i < env->nb_tlb; i++) {
tlb = &env->tlb[i].tlbe;
if (ppcemb_tlb_check(env, tlb, &raddr, address,
env->spr[SPR_40x_PID], 0, i) < 0)
continue;
zsel = (tlb->attr >> 4) & 0xF;
zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n",
__func__, i, zsel, zpr, rw, tlb->attr);
}
#endif
if (access_type == ACCESS_CODE) {
/* Check execute enable bit */
switch (zpr) {
case 0x2:
if (msr_pr)
goto check_exec_perm;
goto exec_granted;
case 0x0:
if (msr_pr) {
ctx->prot = 0;
ret = -3;
break;
}
/* No break here */
case 0x1:
check_exec_perm:
/* Check from TLB entry */
if (!(tlb->prot & PAGE_EXEC)) {
ret = -3;
} else {
if (tlb->prot & PAGE_WRITE) {
ctx->prot = PAGE_READ | PAGE_WRITE;
} else {
ctx->prot = PAGE_READ;
}
ret = 0;
}
break;
case 0x3:
exec_granted:
/* All accesses granted */
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
break;
}
} else {
switch (zpr) {
case 0x2:
if (msr_pr)
goto check_rw_perm;
goto rw_granted;
case 0x0:
if (msr_pr) {
ctx->prot = 0;
ret = -2;
break;
}
/* No break here */
case 0x1:
check_rw_perm:
/* Check from TLB entry */
/* Check write protection bit */
if (tlb->prot & PAGE_WRITE) {
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
} else {
ctx->prot = PAGE_READ;
if (rw)
ret = -2;
else
ret = 0;
}
break;
case 0x3:
rw_granted:
/* All accesses granted */
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
break;
}
}
if (ret >= 0) {
ctx->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, address, ctx->raddr, ctx->prot,
ret);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, address, raddr, ctx->prot,
ret);
}
#endif
return ret;
}
| false | qemu | b227a8e9aa5f27d29f77ba90d5eb9d0662a1175e | int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx,
target_ulong address, int rw, int access_type)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int i, ret, zsel, zpr;
ret = -1;
raddr = -1;
for (i = 0; i < env->nb_tlb; i++) {
tlb = &env->tlb[i].tlbe;
if (ppcemb_tlb_check(env, tlb, &raddr, address,
env->spr[SPR_40x_PID], 0, i) < 0)
continue;
zsel = (tlb->attr >> 4) & 0xF;
zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n",
__func__, i, zsel, zpr, rw, tlb->attr);
}
#endif
if (access_type == ACCESS_CODE) {
switch (zpr) {
case 0x2:
if (msr_pr)
goto check_exec_perm;
goto exec_granted;
case 0x0:
if (msr_pr) {
ctx->prot = 0;
ret = -3;
break;
}
case 0x1:
check_exec_perm:
if (!(tlb->prot & PAGE_EXEC)) {
ret = -3;
} else {
if (tlb->prot & PAGE_WRITE) {
ctx->prot = PAGE_READ | PAGE_WRITE;
} else {
ctx->prot = PAGE_READ;
}
ret = 0;
}
break;
case 0x3:
exec_granted:
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
break;
}
} else {
switch (zpr) {
case 0x2:
if (msr_pr)
goto check_rw_perm;
goto rw_granted;
case 0x0:
if (msr_pr) {
ctx->prot = 0;
ret = -2;
break;
}
case 0x1:
check_rw_perm:
if (tlb->prot & PAGE_WRITE) {
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
} else {
ctx->prot = PAGE_READ;
if (rw)
ret = -2;
else
ret = 0;
}
break;
case 0x3:
rw_granted:
ctx->prot = PAGE_READ | PAGE_WRITE;
ret = 0;
break;
}
}
if (ret >= 0) {
ctx->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, address, ctx->raddr, ctx->prot,
ret);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, address, raddr, ctx->prot,
ret);
}
#endif
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int VAR_5, VAR_6, VAR_7, VAR_8;
VAR_6 = -1;
raddr = -1;
for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) {
tlb = &VAR_0->tlb[VAR_5].tlbe;
if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,
VAR_0->spr[SPR_40x_PID], 0, VAR_5) < 0)
continue;
VAR_7 = (tlb->attr >> 4) & 0xF;
VAR_8 = (VAR_0->spr[SPR_40x_ZPR] >> (28 - (2 * VAR_7))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d VAR_7 %d VAR_8 %d VAR_3 %d attr %08x\n",
__func__, VAR_5, VAR_7, VAR_8, VAR_3, tlb->attr);
}
#endif
if (VAR_4 == ACCESS_CODE) {
switch (VAR_8) {
case 0x2:
if (msr_pr)
goto check_exec_perm;
goto exec_granted;
case 0x0:
if (msr_pr) {
VAR_1->prot = 0;
VAR_6 = -3;
break;
}
case 0x1:
check_exec_perm:
if (!(tlb->prot & PAGE_EXEC)) {
VAR_6 = -3;
} else {
if (tlb->prot & PAGE_WRITE) {
VAR_1->prot = PAGE_READ | PAGE_WRITE;
} else {
VAR_1->prot = PAGE_READ;
}
VAR_6 = 0;
}
break;
case 0x3:
exec_granted:
VAR_1->prot = PAGE_READ | PAGE_WRITE;
VAR_6 = 0;
break;
}
} else {
switch (VAR_8) {
case 0x2:
if (msr_pr)
goto check_rw_perm;
goto rw_granted;
case 0x0:
if (msr_pr) {
VAR_1->prot = 0;
VAR_6 = -2;
break;
}
case 0x1:
check_rw_perm:
if (tlb->prot & PAGE_WRITE) {
VAR_1->prot = PAGE_READ | PAGE_WRITE;
VAR_6 = 0;
} else {
VAR_1->prot = PAGE_READ;
if (VAR_3)
VAR_6 = -2;
else
VAR_6 = 0;
}
break;
case 0x3:
rw_granted:
VAR_1->prot = PAGE_READ | PAGE_WRITE;
VAR_6 = 0;
break;
}
}
if (VAR_6 >= 0) {
VAR_1->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, VAR_2, VAR_1->raddr, VAR_1->prot,
VAR_6);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, VAR_2, raddr, VAR_1->prot,
VAR_6);
}
#endif
return VAR_6;
}
| [
"int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4)\n{",
"ppcemb_tlb_t *tlb;",
"target_phys_addr_t raddr;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"VAR_6 = -1;",
"raddr = -1;",
"for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) {",
"tlb = &VAR_0->tlb[VAR_5].tlbe;",
"if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,\nVAR_0->spr[SPR_40x_PID], 0, VAR_5) < 0)\ncontinue;",
"VAR_7 = (tlb->attr >> 4) & 0xF;",
"VAR_8 = (VAR_0->spr[SPR_40x_ZPR] >> (28 - (2 * VAR_7))) & 0x3;",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: TLB %d VAR_7 %d VAR_8 %d VAR_3 %d attr %08x\\n\",\n__func__, VAR_5, VAR_7, VAR_8, VAR_3, tlb->attr);",
"}",
"#endif\nif (VAR_4 == ACCESS_CODE) {",
"switch (VAR_8) {",
"case 0x2:\nif (msr_pr)\ngoto check_exec_perm;",
"goto exec_granted;",
"case 0x0:\nif (msr_pr) {",
"VAR_1->prot = 0;",
"VAR_6 = -3;",
"break;",
"}",
"case 0x1:\ncheck_exec_perm:\nif (!(tlb->prot & PAGE_EXEC)) {",
"VAR_6 = -3;",
"} else {",
"if (tlb->prot & PAGE_WRITE) {",
"VAR_1->prot = PAGE_READ | PAGE_WRITE;",
"} else {",
"VAR_1->prot = PAGE_READ;",
"}",
"VAR_6 = 0;",
"}",
"break;",
"case 0x3:\nexec_granted:\nVAR_1->prot = PAGE_READ | PAGE_WRITE;",
"VAR_6 = 0;",
"break;",
"}",
"} else {",
"switch (VAR_8) {",
"case 0x2:\nif (msr_pr)\ngoto check_rw_perm;",
"goto rw_granted;",
"case 0x0:\nif (msr_pr) {",
"VAR_1->prot = 0;",
"VAR_6 = -2;",
"break;",
"}",
"case 0x1:\ncheck_rw_perm:\nif (tlb->prot & PAGE_WRITE) {",
"VAR_1->prot = PAGE_READ | PAGE_WRITE;",
"VAR_6 = 0;",
"} else {",
"VAR_1->prot = PAGE_READ;",
"if (VAR_3)\nVAR_6 = -2;",
"else\nVAR_6 = 0;",
"}",
"break;",
"case 0x3:\nrw_granted:\nVAR_1->prot = PAGE_READ | PAGE_WRITE;",
"VAR_6 = 0;",
"break;",
"}",
"}",
"if (VAR_6 >= 0) {",
"VAR_1->raddr = raddr;",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: access granted \" ADDRX \" => \" REGX\n\" %d %d\\n\", __func__, VAR_2, VAR_1->raddr, VAR_1->prot,\nVAR_6);",
"}",
"#endif\nreturn 0;",
"}",
"}",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: access refused \" ADDRX \" => \" REGX\n\" %d %d\\n\", __func__, VAR_2, raddr, VAR_1->prot,\nVAR_6);",
"}",
"#endif\nreturn VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141,
143,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163,
165
],
[
167
],
[
169
],
[
171,
173,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195,
197,
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211,
213
],
[
215,
217,
219
],
[
221
],
[
223,
227
],
[
229
]
] |
24,884 | static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)
{
struct dirent *entry;
again:
entry = readdir(fs->dir.stream);
if (!entry) {
return NULL;
}
if (ctx->export_flags & V9FS_SM_MAPPED) {
entry->d_type = DT_UNKNOWN;
} else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
if (local_is_mapped_file_metadata(ctx, entry->d_name)) {
/* skip the meta data directory */
goto again;
}
entry->d_type = DT_UNKNOWN;
}
return entry;
}
| false | qemu | 81ffbf5ab1458e357a761f1272105a55829b351e | static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)
{
struct dirent *entry;
again:
entry = readdir(fs->dir.stream);
if (!entry) {
return NULL;
}
if (ctx->export_flags & V9FS_SM_MAPPED) {
entry->d_type = DT_UNKNOWN;
} else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
if (local_is_mapped_file_metadata(ctx, entry->d_name)) {
goto again;
}
entry->d_type = DT_UNKNOWN;
}
return entry;
}
| {
"code": [],
"line_no": []
} | static struct dirent *FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1)
{
struct dirent *VAR_2;
again:
VAR_2 = readdir(VAR_1->dir.stream);
if (!VAR_2) {
return NULL;
}
if (VAR_0->export_flags & V9FS_SM_MAPPED) {
VAR_2->d_type = DT_UNKNOWN;
} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {
if (local_is_mapped_file_metadata(VAR_0, VAR_2->d_name)) {
goto again;
}
VAR_2->d_type = DT_UNKNOWN;
}
return VAR_2;
}
| [
"static struct dirent *FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1)\n{",
"struct dirent *VAR_2;",
"again:\nVAR_2 = readdir(VAR_1->dir.stream);",
"if (!VAR_2) {",
"return NULL;",
"}",
"if (VAR_0->export_flags & V9FS_SM_MAPPED) {",
"VAR_2->d_type = DT_UNKNOWN;",
"} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {",
"if (local_is_mapped_file_metadata(VAR_0, VAR_2->d_name)) {",
"goto again;",
"}",
"VAR_2->d_type = DT_UNKNOWN;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
24,886 | static void tricore_cpu_class_init(ObjectClass *c, void *data)
{
TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(c);
CPUClass *cc = CPU_CLASS(c);
DeviceClass *dc = DEVICE_CLASS(c);
mcc->parent_realize = dc->realize;
dc->realize = tricore_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = tricore_cpu_reset;
cc->class_by_name = tricore_cpu_class_by_name;
cc->has_work = tricore_cpu_has_work;
cc->dump_state = tricore_cpu_dump_state;
cc->set_pc = tricore_cpu_set_pc;
cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
} | true | qemu | b190f477e29c7cd03a8fee49c96d27f160e3f5b0 | static void tricore_cpu_class_init(ObjectClass *c, void *data)
{
TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(c);
CPUClass *cc = CPU_CLASS(c);
DeviceClass *dc = DEVICE_CLASS(c);
mcc->parent_realize = dc->realize;
dc->realize = tricore_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = tricore_cpu_reset;
cc->class_by_name = tricore_cpu_class_by_name;
cc->has_work = tricore_cpu_has_work;
cc->dump_state = tricore_cpu_dump_state;
cc->set_pc = tricore_cpu_set_pc;
cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(VAR_0);
CPUClass *cc = CPU_CLASS(VAR_0);
DeviceClass *dc = DEVICE_CLASS(VAR_0);
mcc->parent_realize = dc->realize;
dc->realize = tricore_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = tricore_cpu_reset;
cc->class_by_name = tricore_cpu_class_by_name;
cc->has_work = tricore_cpu_has_work;
cc->dump_state = tricore_cpu_dump_state;
cc->set_pc = tricore_cpu_set_pc;
cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(VAR_0);",
"CPUClass *cc = CPU_CLASS(VAR_0);",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"mcc->parent_realize = dc->realize;",
"dc->realize = tricore_cpu_realizefn;",
"mcc->parent_reset = cc->reset;",
"cc->reset = tricore_cpu_reset;",
"cc->class_by_name = tricore_cpu_class_by_name;",
"cc->has_work = tricore_cpu_has_work;",
"cc->dump_state = tricore_cpu_dump_state;",
"cc->set_pc = tricore_cpu_set_pc;",
"cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
36
]
] |
24,887 | static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
struct sockaddr_storage my_addr;
int len;
int reuse_specified = 0;
int i, include = 0, num_sources = 0;
char *sources[32];
h->is_streamed = 1;
h->max_packet_size = 1472;
is_output = !(flags & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
s->reuse_socket = 1;
reuse_specified = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) {
char *endptr = NULL;
s->overrun_nonfatal = strtol(buf, &endptr, 10);
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
"'circular_buffer_size' option was set but it is not supported "
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
if (av_find_info_tag(buf, sizeof(buf), "sources", p))
include = 1;
if (include || av_find_info_tag(buf, sizeof(buf), "block", p)) {
char *source_start;
source_start = buf;
while (1) {
char *next = strchr(source_start, ',');
if (next)
*next = '\0';
sources[num_sources] = av_strdup(source_start);
if (!sources[num_sources])
goto fail;
source_start = next + 1;
num_sources++;
if (num_sources >= FF_ARRAY_ELEMS(sources) || !next)
break;
}
}
}
/* fill the dest addr */
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
/* XXX: fix av_url_split */
if (hostname[0] == '\0' || hostname[0] == '?') {
/* only accepts null hostname if input */
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
/* Follow the requested reuse option, unless it's multicast in which
* case enable reuse unless explicitly disabled.
*/
if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
/* If multicast, try binding the multicast address first, to avoid
* receiving UDP packets from other sources aimed at the same UDP
* port. This fails on windows. This makes sending to the same address
* using sendto() fail, so only do it if we're opened in read-only mode. */
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
/* bind to the local address if not multicast or if the multicast
* bind failed */
/* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
log_net_error(h, AV_LOG_ERROR, "bind failed");
goto fail;
}
len = sizeof(my_addr);
getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
/* output */
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (h->flags & AVIO_FLAG_READ) {
/* input */
if (num_sources == 0 || !include) {
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
if (num_sources) {
if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 0) < 0)
goto fail;
}
} else if (include && num_sources) {
if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 1) < 0)
goto fail;
} else {
av_log(NULL, AV_LOG_ERROR, "invalid udp settings: inclusive multicast but no sources given\n");
goto fail;
}
}
}
if (is_output) {
/* limit the tx buf size to limit latency */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
goto fail;
}
} else {
/* set udp recv buffer size to the largest possible udp packet size to
* avoid losing data on OSes that set this too low by default. */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)");
}
/* make the socket non-blocking */
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
log_net_error(h, AV_LOG_ERROR, "connect");
goto fail;
}
}
for (i = 0; i < num_sources; i++)
av_freep(&sources[i]);
s->udp_fd = udp_fd;
#if HAVE_PTHREAD_CANCEL
if (!is_output && s->circular_buffer_size) {
int ret;
/* start the task going */
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREAD_CANCEL
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
av_fifo_free(s->fifo);
for (i = 0; i < num_sources; i++)
av_freep(&sources[i]);
return AVERROR(EIO);
} | true | FFmpeg | a8d8e868c6154f63a9229f913434aaa21833e488 | static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
struct sockaddr_storage my_addr;
int len;
int reuse_specified = 0;
int i, include = 0, num_sources = 0;
char *sources[32];
h->is_streamed = 1;
h->max_packet_size = 1472;
is_output = !(flags & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
if (buf == endptr)
s->reuse_socket = 1;
reuse_specified = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) {
char *endptr = NULL;
s->overrun_nonfatal = strtol(buf, &endptr, 10);
if (buf == endptr)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
"'circular_buffer_size' option was set but it is not supported "
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
if (av_find_info_tag(buf, sizeof(buf), "sources", p))
include = 1;
if (include || av_find_info_tag(buf, sizeof(buf), "block", p)) {
char *source_start;
source_start = buf;
while (1) {
char *next = strchr(source_start, ',');
if (next)
*next = '\0';
sources[num_sources] = av_strdup(source_start);
if (!sources[num_sources])
goto fail;
source_start = next + 1;
num_sources++;
if (num_sources >= FF_ARRAY_ELEMS(sources) || !next)
break;
}
}
}
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
if (hostname[0] == '\0' || hostname[0] == '?') {
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
log_net_error(h, AV_LOG_ERROR, "bind failed");
goto fail;
}
len = sizeof(my_addr);
getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (h->flags & AVIO_FLAG_READ) {
if (num_sources == 0 || !include) {
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
if (num_sources) {
if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 0) < 0)
goto fail;
}
} else if (include && num_sources) {
if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 1) < 0)
goto fail;
} else {
av_log(NULL, AV_LOG_ERROR, "invalid udp settings: inclusive multicast but no sources given\n");
goto fail;
}
}
}
if (is_output) {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
goto fail;
}
} else {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)");
}
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
log_net_error(h, AV_LOG_ERROR, "connect");
goto fail;
}
}
for (i = 0; i < num_sources; i++)
av_freep(&sources[i]);
s->udp_fd = udp_fd;
#if HAVE_PTHREAD_CANCEL
if (!is_output && s->circular_buffer_size) {
int ret;
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREAD_CANCEL
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
av_fifo_free(s->fifo);
for (i = 0; i < num_sources; i++)
av_freep(&sources[i]);
return AVERROR(EIO);
} | {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)
{
char VAR_3[1024], VAR_4[1024] = "";
int VAR_5, VAR_6 = -1, VAR_7, VAR_8 = -1;
UDPContext *s = VAR_0->priv_data;
int VAR_9;
const char *VAR_10;
char VAR_11[256];
struct sockaddr_storage VAR_12;
int VAR_13;
int VAR_14 = 0;
int VAR_15, VAR_16 = 0, VAR_17 = 0;
char *VAR_18[32];
VAR_0->is_streamed = 1;
VAR_0->max_packet_size = 1472;
VAR_9 = !(VAR_2 & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = VAR_9 ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
VAR_10 = strchr(VAR_1, '?');
if (VAR_10) {
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "reuse", VAR_10)) {
char *VAR_20 = NULL;
s->reuse_socket = strtol(VAR_11, &VAR_20, 10);
if (VAR_11 == VAR_20)
s->reuse_socket = 1;
VAR_14 = 1;
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "overrun_nonfatal", VAR_10)) {
char *VAR_20 = NULL;
s->overrun_nonfatal = strtol(VAR_11, &VAR_20, 10);
if (VAR_11 == VAR_20)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "ttl", VAR_10)) {
s->ttl = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "localport", VAR_10)) {
s->local_port = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "pkt_size", VAR_10)) {
VAR_0->max_packet_size = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "buffer_size", VAR_10)) {
s->buffer_size = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "connect", VAR_10)) {
s->is_connected = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "fifo_size", VAR_10)) {
s->circular_buffer_size = strtol(VAR_11, NULL, 10)*188;
"'circular_buffer_size' option was set but it is not supported "
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "VAR_4", VAR_10)) {
av_strlcpy(VAR_4, VAR_11, sizeof(VAR_4));
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "VAR_18", VAR_10))
VAR_16 = 1;
if (VAR_16 || av_find_info_tag(VAR_11, sizeof(VAR_11), "block", VAR_10)) {
char *VAR_20;
VAR_20 = VAR_11;
while (1) {
char *VAR_21 = strchr(VAR_20, ',');
if (VAR_21)
*VAR_21 = '\0';
VAR_18[VAR_17] = av_strdup(VAR_20);
if (!VAR_18[VAR_17])
goto fail;
VAR_20 = VAR_21 + 1;
VAR_17++;
if (VAR_17 >= FF_ARRAY_ELEMS(VAR_18) || !VAR_21)
break;
}
}
}
av_url_split(NULL, 0, NULL, 0, VAR_3, sizeof(VAR_3), &VAR_5, NULL, 0, VAR_1);
if (VAR_3[0] == '\0' || VAR_3[0] == '?') {
if (!(VAR_2 & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(VAR_0, VAR_1) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (VAR_0->VAR_2 & AVIO_FLAG_READ))
s->local_port = VAR_5;
VAR_6 = udp_socket_create(s, &VAR_12, &VAR_13, VAR_4);
if (VAR_6 < 0)
goto fail;
if (s->reuse_socket || (s->is_multicast && !VAR_14)) {
s->reuse_socket = 1;
if (setsockopt (VAR_6, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
if (s->is_multicast && !(VAR_0->VAR_2 & AVIO_FLAG_WRITE)) {
VAR_8 = bind(VAR_6,(struct sockaddr *)&s->dest_addr, VAR_13);
}
if (VAR_8 < 0 && bind(VAR_6,(struct sockaddr *)&VAR_12, VAR_13) < 0) {
log_net_error(VAR_0, AV_LOG_ERROR, "bind failed");
goto fail;
}
VAR_13 = sizeof(VAR_12);
getsockname(VAR_6, (struct sockaddr *)&VAR_12, &VAR_13);
s->local_port = udp_port(&VAR_12, VAR_13);
if (s->is_multicast) {
if (VAR_0->VAR_2 & AVIO_FLAG_WRITE) {
if (udp_set_multicast_ttl(VAR_6, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (VAR_0->VAR_2 & AVIO_FLAG_READ) {
if (VAR_17 == 0 || !VAR_16) {
if (udp_join_multicast_group(VAR_6, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
if (VAR_17) {
if (udp_set_multicast_sources(VAR_6, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, VAR_18, VAR_17, 0) < 0)
goto fail;
}
} else if (VAR_16 && VAR_17) {
if (udp_set_multicast_sources(VAR_6, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, VAR_18, VAR_17, 1) < 0)
goto fail;
} else {
av_log(NULL, AV_LOG_ERROR, "invalid udp settings: inclusive multicast but no VAR_18 given\n");
goto fail;
}
}
}
if (VAR_9) {
VAR_7 = s->buffer_size;
if (setsockopt(VAR_6, SOL_SOCKET, SO_SNDBUF, &VAR_7, sizeof(VAR_7)) < 0) {
log_net_error(VAR_0, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
goto fail;
}
} else {
VAR_7 = s->buffer_size;
if (setsockopt(VAR_6, SOL_SOCKET, SO_RCVBUF, &VAR_7, sizeof(VAR_7)) < 0) {
log_net_error(VAR_0, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)");
}
ff_socket_nonblock(VAR_6, 1);
}
if (s->is_connected) {
if (connect(VAR_6, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
log_net_error(VAR_0, AV_LOG_ERROR, "connect");
goto fail;
}
}
for (VAR_15 = 0; VAR_15 < VAR_17; VAR_15++)
av_freep(&VAR_18[VAR_15]);
s->VAR_6 = VAR_6;
#if HAVE_PTHREAD_CANCEL
if (!VAR_9 && s->circular_buffer_size) {
int ret;
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, VAR_0);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREAD_CANCEL
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (VAR_6 >= 0)
closesocket(VAR_6);
av_fifo_free(s->fifo);
for (VAR_15 = 0; VAR_15 < VAR_17; VAR_15++)
av_freep(&VAR_18[VAR_15]);
return AVERROR(EIO);
} | [
"static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)\n{",
"char VAR_3[1024], VAR_4[1024] = \"\";",
"int VAR_5, VAR_6 = -1, VAR_7, VAR_8 = -1;",
"UDPContext *s = VAR_0->priv_data;",
"int VAR_9;",
"const char *VAR_10;",
"char VAR_11[256];",
"struct sockaddr_storage VAR_12;",
"int VAR_13;",
"int VAR_14 = 0;",
"int VAR_15, VAR_16 = 0, VAR_17 = 0;",
"char *VAR_18[32];",
"VAR_0->is_streamed = 1;",
"VAR_0->max_packet_size = 1472;",
"VAR_9 = !(VAR_2 & AVIO_FLAG_READ);",
"s->ttl = 16;",
"s->buffer_size = VAR_9 ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;",
"s->circular_buffer_size = 7*188*4096;",
"VAR_10 = strchr(VAR_1, '?');",
"if (VAR_10) {",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"reuse\", VAR_10)) {",
"char *VAR_20 = NULL;",
"s->reuse_socket = strtol(VAR_11, &VAR_20, 10);",
"if (VAR_11 == VAR_20)\ns->reuse_socket = 1;",
"VAR_14 = 1;",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"overrun_nonfatal\", VAR_10)) {",
"char *VAR_20 = NULL;",
"s->overrun_nonfatal = strtol(VAR_11, &VAR_20, 10);",
"if (VAR_11 == VAR_20)\ns->overrun_nonfatal = 1;",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"ttl\", VAR_10)) {",
"s->ttl = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"localport\", VAR_10)) {",
"s->local_port = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"pkt_size\", VAR_10)) {",
"VAR_0->max_packet_size = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"buffer_size\", VAR_10)) {",
"s->buffer_size = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"connect\", VAR_10)) {",
"s->is_connected = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"fifo_size\", VAR_10)) {",
"s->circular_buffer_size = strtol(VAR_11, NULL, 10)*188;",
"\"'circular_buffer_size' option was set but it is not supported \"\n}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"VAR_4\", VAR_10)) {",
"av_strlcpy(VAR_4, VAR_11, sizeof(VAR_4));",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"VAR_18\", VAR_10))\nVAR_16 = 1;",
"if (VAR_16 || av_find_info_tag(VAR_11, sizeof(VAR_11), \"block\", VAR_10)) {",
"char *VAR_20;",
"VAR_20 = VAR_11;",
"while (1) {",
"char *VAR_21 = strchr(VAR_20, ',');",
"if (VAR_21)\n*VAR_21 = '\\0';",
"VAR_18[VAR_17] = av_strdup(VAR_20);",
"if (!VAR_18[VAR_17])\ngoto fail;",
"VAR_20 = VAR_21 + 1;",
"VAR_17++;",
"if (VAR_17 >= FF_ARRAY_ELEMS(VAR_18) || !VAR_21)\nbreak;",
"}",
"}",
"}",
"av_url_split(NULL, 0, NULL, 0, VAR_3, sizeof(VAR_3), &VAR_5, NULL, 0, VAR_1);",
"if (VAR_3[0] == '\\0' || VAR_3[0] == '?') {",
"if (!(VAR_2 & AVIO_FLAG_READ))\ngoto fail;",
"} else {",
"if (ff_udp_set_remote_url(VAR_0, VAR_1) < 0)\ngoto fail;",
"}",
"if ((s->is_multicast || !s->local_port) && (VAR_0->VAR_2 & AVIO_FLAG_READ))\ns->local_port = VAR_5;",
"VAR_6 = udp_socket_create(s, &VAR_12, &VAR_13, VAR_4);",
"if (VAR_6 < 0)\ngoto fail;",
"if (s->reuse_socket || (s->is_multicast && !VAR_14)) {",
"s->reuse_socket = 1;",
"if (setsockopt (VAR_6, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)\ngoto fail;",
"}",
"if (s->is_multicast && !(VAR_0->VAR_2 & AVIO_FLAG_WRITE)) {",
"VAR_8 = bind(VAR_6,(struct sockaddr *)&s->dest_addr, VAR_13);",
"}",
"if (VAR_8 < 0 && bind(VAR_6,(struct sockaddr *)&VAR_12, VAR_13) < 0) {",
"log_net_error(VAR_0, AV_LOG_ERROR, \"bind failed\");",
"goto fail;",
"}",
"VAR_13 = sizeof(VAR_12);",
"getsockname(VAR_6, (struct sockaddr *)&VAR_12, &VAR_13);",
"s->local_port = udp_port(&VAR_12, VAR_13);",
"if (s->is_multicast) {",
"if (VAR_0->VAR_2 & AVIO_FLAG_WRITE) {",
"if (udp_set_multicast_ttl(VAR_6, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)\ngoto fail;",
"}",
"if (VAR_0->VAR_2 & AVIO_FLAG_READ) {",
"if (VAR_17 == 0 || !VAR_16) {",
"if (udp_join_multicast_group(VAR_6, (struct sockaddr *)&s->dest_addr) < 0)\ngoto fail;",
"if (VAR_17) {",
"if (udp_set_multicast_sources(VAR_6, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, VAR_18, VAR_17, 0) < 0)\ngoto fail;",
"}",
"} else if (VAR_16 && VAR_17) {",
"if (udp_set_multicast_sources(VAR_6, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, VAR_18, VAR_17, 1) < 0)\ngoto fail;",
"} else {",
"av_log(NULL, AV_LOG_ERROR, \"invalid udp settings: inclusive multicast but no VAR_18 given\\n\");",
"goto fail;",
"}",
"}",
"}",
"if (VAR_9) {",
"VAR_7 = s->buffer_size;",
"if (setsockopt(VAR_6, SOL_SOCKET, SO_SNDBUF, &VAR_7, sizeof(VAR_7)) < 0) {",
"log_net_error(VAR_0, AV_LOG_ERROR, \"setsockopt(SO_SNDBUF)\");",
"goto fail;",
"}",
"} else {",
"VAR_7 = s->buffer_size;",
"if (setsockopt(VAR_6, SOL_SOCKET, SO_RCVBUF, &VAR_7, sizeof(VAR_7)) < 0) {",
"log_net_error(VAR_0, AV_LOG_WARNING, \"setsockopt(SO_RECVBUF)\");",
"}",
"ff_socket_nonblock(VAR_6, 1);",
"}",
"if (s->is_connected) {",
"if (connect(VAR_6, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {",
"log_net_error(VAR_0, AV_LOG_ERROR, \"connect\");",
"goto fail;",
"}",
"}",
"for (VAR_15 = 0; VAR_15 < VAR_17; VAR_15++)",
"av_freep(&VAR_18[VAR_15]);",
"s->VAR_6 = VAR_6;",
"#if HAVE_PTHREAD_CANCEL\nif (!VAR_9 && s->circular_buffer_size) {",
"int ret;",
"s->fifo = av_fifo_alloc(s->circular_buffer_size);",
"ret = pthread_mutex_init(&s->mutex, NULL);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_mutex_init failed : %s\\n\", strerror(ret));",
"goto fail;",
"}",
"ret = pthread_cond_init(&s->cond, NULL);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_cond_init failed : %s\\n\", strerror(ret));",
"goto cond_fail;",
"}",
"ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, VAR_0);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_create failed : %s\\n\", strerror(ret));",
"goto thread_fail;",
"}",
"s->thread_started = 1;",
"}",
"#endif\nreturn 0;",
"#if HAVE_PTHREAD_CANCEL\nthread_fail:\npthread_cond_destroy(&s->cond);",
"cond_fail:\npthread_mutex_destroy(&s->mutex);",
"#endif\nfail:\nif (VAR_6 >= 0)\nclosesocket(VAR_6);",
"av_fifo_free(s->fifo);",
"for (VAR_15 = 0; VAR_15 < VAR_17; VAR_15++)",
"av_freep(&VAR_18[VAR_15]);",
"return AVERROR(EIO);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123,
126
],
[
128
],
[
130
],
[
132
],
[
134,
136
],
[
138
],
[
140
],
[
144
],
[
146
],
[
148
],
[
150,
152
],
[
154
],
[
156,
158
],
[
160
],
[
162
],
[
164,
166
],
[
168
],
[
170
],
[
172
],
[
178
],
[
184
],
[
188,
190
],
[
192
],
[
194,
196
],
[
198
],
[
202,
204
],
[
206
],
[
208,
210
],
[
220
],
[
222
],
[
224,
226
],
[
228
],
[
240
],
[
242
],
[
244
],
[
252
],
[
254
],
[
256
],
[
258
],
[
262
],
[
264
],
[
266
],
[
270
],
[
272
],
[
276,
278
],
[
280
],
[
282
],
[
286
],
[
288,
290
],
[
294
],
[
296,
298
],
[
300
],
[
302
],
[
304,
306
],
[
308
],
[
310
],
[
312
],
[
314
],
[
316
],
[
318
],
[
322
],
[
326
],
[
328
],
[
330
],
[
332
],
[
334
],
[
336
],
[
342
],
[
344
],
[
346
],
[
348
],
[
352
],
[
354
],
[
356
],
[
358
],
[
360
],
[
362
],
[
364
],
[
366
],
[
370
],
[
372
],
[
376
],
[
380,
382
],
[
384
],
[
390
],
[
392
],
[
394
],
[
396
],
[
398
],
[
400
],
[
402
],
[
404
],
[
406
],
[
408
],
[
410
],
[
412
],
[
414
],
[
416
],
[
418
],
[
420
],
[
422
],
[
424
],
[
426,
430
],
[
432,
434,
436
],
[
438,
440
],
[
442,
444,
446,
448
],
[
450
],
[
452
],
[
454
],
[
456
],
[
458
]
] |
24,888 | static int vc1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size, n_slices = 0, i;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
uint8_t *buf2 = NULL;
const uint8_t *buf_start = buf;
int mb_height, n_slices1;
struct {
uint8_t *buf;
GetBitContext gb;
int mby_start;
} *slices = NULL, *tmp;
/* no supplementary picture */
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
/* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) {
*pict = s->next_picture_ptr->f;
s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
else
avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
}
//for advanced profile we may need to parse and unescape data
if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
int buf_size2 = 0;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */
const uint8_t *start, *end, *next;
int size;
next = buf;
for (start = buf, end = buf + buf_size; next < end; start = next) {
next = find_next_marker(start + 4, end);
size = next - start - 4;
if (size <= 0) continue;
switch (AV_RB32(start)) {
case VC1_CODE_FRAME:
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break;
case VC1_CODE_FIELD: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
/* assuming that the field marker is at the exact middle,
hope it's correct */
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1; // index of the last slice of the first field
n_slices++;
break;
}
case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&s->gb, buf2, buf_size2 * 8);
ff_vc1_decode_entry_point(avctx, v, &s->gb);
break;
case VC1_CODE_SLICE: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = get_bits(&slices[n_slices].gb, 9);
n_slices++;
break;
}
}
}
} else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) { /* WVC1 interlaced stores both fields divided by marker */
const uint8_t *divider;
int buf_size3;
divider = find_next_marker(buf, buf + buf_size);
if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) {
av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
goto err;
} else { // found field marker, unescape second field
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1;
n_slices++;
}
buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
} else {
buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
init_get_bits(&s->gb, buf, buf_size*8);
if (v->res_sprite) {
v->new_sprite = !get_bits1(&s->gb);
v->two_sprites = get_bits1(&s->gb);
/* res_sprite means a Windows Media Image stream, AV_CODEC_ID_*IMAGE means
we're using the sprite compositor. These are intentionally kept separate
so you can get the raw sprites by using the wmv3 decoder for WMVP or
the vc1 one for WVP2 */
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
if (v->new_sprite) {
// switch AVCodecContext parameters to those of the sprites
avctx->width = avctx->coded_width = v->sprite_width;
avctx->height = avctx->coded_height = v->sprite_height;
} else {
goto image;
}
}
}
if (s->context_initialized &&
(s->width != avctx->coded_width ||
s->height != avctx->coded_height)) {
ff_vc1_decode_end(avctx);
}
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
return -1;
s->low_delay = !avctx->has_b_frames || v->res_sprite;
if (v->profile == PROFILE_ADVANCED) {
s->h_edge_pos = avctx->coded_width;
s->v_edge_pos = avctx->coded_height;
}
}
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anything in there. */
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
goto err;
s->current_picture_ptr = &s->picture[i];
}
// do parse frame header
v->pic_header_flag = 0;
if (v->profile < PROFILE_ADVANCED) {
if (ff_vc1_parse_frame_header(v, &s->gb) == -1) {
goto err;
}
} else {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) == -1) {
goto err;
}
}
if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE)
&& s->pict_type != AV_PICTURE_TYPE_I) {
av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n");
goto err;
}
// process pulldown flags
s->current_picture_ptr->f.repeat_pict = 0;
// Pulldown flags are only valid when 'broadcast' has been set.
// So ticks_per_frame will be 2
if (v->rff) {
// repeat field
s->current_picture_ptr->f.repeat_pict = 1;
} else if (v->rptfrm) {
// repeat frames
s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
}
// for skipping the frame
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) {
goto err;
}
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL) {
goto end;
}
if (s->next_p_frame_damaged) {
if (s->pict_type == AV_PICTURE_TYPE_B)
goto end;
else
s->next_p_frame_damaged = 0;
}
if (ff_MPV_frame_start(s, avctx) < 0) {
goto err;
}
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER)
&&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
else if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
goto err;
if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
goto err;
if (avctx->hwaccel->end_frame(avctx) < 0)
goto err;
} else {
ff_er_frame_start(s);
v->bits = buf_size * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
uint8_t *tmp[2];
s->current_picture.f.linesize[0] <<= 1;
s->current_picture.f.linesize[1] <<= 1;
s->current_picture.f.linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
tmp[0] = v->mv_f_last[0];
tmp[1] = v->mv_f_last[1];
v->mv_f_last[0] = v->mv_f_next[0];
v->mv_f_last[1] = v->mv_f_next[1];
v->mv_f_next[0] = v->mv_f[0];
v->mv_f_next[1] = v->mv_f[1];
v->mv_f[0] = tmp[0];
v->mv_f[1] = tmp[1];
}
mb_height = s->mb_height >> v->field_mode;
for (i = 0; i <= n_slices; i++) {
if (i > 0 && slices[i - 1].mby_start >= mb_height) {
if (v->field_mode <= 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond "
"picture boundary (%d >= %d)\n", i,
slices[i - 1].mby_start, mb_height);
continue;
}
v->second_field = 1;
v->blocks_off = s->mb_width * s->mb_height << 1;
v->mb_off = s->mb_stride * s->mb_height >> 1;
} else {
v->second_field = 0;
v->blocks_off = 0;
v->mb_off = 0;
}
if (i) {
v->pic_header_flag = 0;
if (v->field_mode && i == n_slices1 + 2) {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n");
continue;
}
} else if (get_bits1(&s->gb)) {
v->pic_header_flag = 1;
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n");
continue;
}
}
}
s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
if (!v->field_mode || v->second_field)
s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
else
s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
ff_vc1_decode_blocks(v);
if (i != n_slices)
s->gb = slices[i].gb;
}
if (v->field_mode) {
v->second_field = 0;
if (s->pict_type == AV_PICTURE_TYPE_B) {
memcpy(v->mv_f_base, v->mv_f_next_base,
2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
}
s->current_picture.f.linesize[0] >>= 1;
s->current_picture.f.linesize[1] >>= 1;
s->current_picture.f.linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
}
av_dlog(s->avctx, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), s->gb.size_in_bits);
// if (get_bits_count(&s->gb) > buf_size * 8)
// return -1;
ff_er_frame_end(s);
}
ff_MPV_frame_end(s);
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
image:
avctx->width = avctx->coded_width = v->output_width;
avctx->height = avctx->coded_height = v->output_height;
if (avctx->skip_frame >= AVDISCARD_NONREF)
goto end;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
if (vc1_decode_sprites(v, &s->gb))
goto err;
#endif
*pict = v->sprite_output_frame;
*data_size = sizeof(AVFrame);
} else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
}
end:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return buf_size;
err:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return -1;
}
| true | FFmpeg | 6f8ef5320f4d435803482ed322f3de45e6ea125c | static int vc1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size, n_slices = 0, i;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
uint8_t *buf2 = NULL;
const uint8_t *buf_start = buf;
int mb_height, n_slices1;
struct {
uint8_t *buf;
GetBitContext gb;
int mby_start;
} *slices = NULL, *tmp;
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
if (s->low_delay == 0 && s->next_picture_ptr) {
*pict = s->next_picture_ptr->f;
s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
else
avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
}
if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
int buf_size2 = 0;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (IS_MARKER(AV_RB32(buf))) {
const uint8_t *start, *end, *next;
int size;
next = buf;
for (start = buf, end = buf + buf_size; next < end; start = next) {
next = find_next_marker(start + 4, end);
size = next - start - 4;
if (size <= 0) continue;
switch (AV_RB32(start)) {
case VC1_CODE_FRAME:
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break;
case VC1_CODE_FIELD: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1;
n_slices++;
break;
}
case VC1_CODE_ENTRYPOINT:
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&s->gb, buf2, buf_size2 * 8);
ff_vc1_decode_entry_point(avctx, v, &s->gb);
break;
case VC1_CODE_SLICE: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = get_bits(&slices[n_slices].gb, 9);
n_slices++;
break;
}
}
}
} else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) {
const uint8_t *divider;
int buf_size3;
divider = find_next_marker(buf, buf + buf_size);
if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) {
av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
goto err;
} else {
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1;
n_slices++;
}
buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
} else {
buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
init_get_bits(&s->gb, buf, buf_size*8);
if (v->res_sprite) {
v->new_sprite = !get_bits1(&s->gb);
v->two_sprites = get_bits1(&s->gb);
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
if (v->new_sprite) {
avctx->width = avctx->coded_width = v->sprite_width;
avctx->height = avctx->coded_height = v->sprite_height;
} else {
goto image;
}
}
}
if (s->context_initialized &&
(s->width != avctx->coded_width ||
s->height != avctx->coded_height)) {
ff_vc1_decode_end(avctx);
}
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
return -1;
s->low_delay = !avctx->has_b_frames || v->res_sprite;
if (v->profile == PROFILE_ADVANCED) {
s->h_edge_pos = avctx->coded_width;
s->v_edge_pos = avctx->coded_height;
}
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
goto err;
s->current_picture_ptr = &s->picture[i];
}
v->pic_header_flag = 0;
if (v->profile < PROFILE_ADVANCED) {
if (ff_vc1_parse_frame_header(v, &s->gb) == -1) {
goto err;
}
} else {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) == -1) {
goto err;
}
}
if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE)
&& s->pict_type != AV_PICTURE_TYPE_I) {
av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n");
goto err;
}
s->current_picture_ptr->f.repeat_pict = 0;
if (v->rff) {
s->current_picture_ptr->f.repeat_pict = 1;
} else if (v->rptfrm) {
s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) {
goto err;
}
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL) {
goto end;
}
if (s->next_p_frame_damaged) {
if (s->pict_type == AV_PICTURE_TYPE_B)
goto end;
else
s->next_p_frame_damaged = 0;
}
if (ff_MPV_frame_start(s, avctx) < 0) {
goto err;
}
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER)
&&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
else if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
goto err;
if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
goto err;
if (avctx->hwaccel->end_frame(avctx) < 0)
goto err;
} else {
ff_er_frame_start(s);
v->bits = buf_size * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
uint8_t *tmp[2];
s->current_picture.f.linesize[0] <<= 1;
s->current_picture.f.linesize[1] <<= 1;
s->current_picture.f.linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
tmp[0] = v->mv_f_last[0];
tmp[1] = v->mv_f_last[1];
v->mv_f_last[0] = v->mv_f_next[0];
v->mv_f_last[1] = v->mv_f_next[1];
v->mv_f_next[0] = v->mv_f[0];
v->mv_f_next[1] = v->mv_f[1];
v->mv_f[0] = tmp[0];
v->mv_f[1] = tmp[1];
}
mb_height = s->mb_height >> v->field_mode;
for (i = 0; i <= n_slices; i++) {
if (i > 0 && slices[i - 1].mby_start >= mb_height) {
if (v->field_mode <= 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond "
"picture boundary (%d >= %d)\n", i,
slices[i - 1].mby_start, mb_height);
continue;
}
v->second_field = 1;
v->blocks_off = s->mb_width * s->mb_height << 1;
v->mb_off = s->mb_stride * s->mb_height >> 1;
} else {
v->second_field = 0;
v->blocks_off = 0;
v->mb_off = 0;
}
if (i) {
v->pic_header_flag = 0;
if (v->field_mode && i == n_slices1 + 2) {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n");
continue;
}
} else if (get_bits1(&s->gb)) {
v->pic_header_flag = 1;
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n");
continue;
}
}
}
s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
if (!v->field_mode || v->second_field)
s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
else
s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
ff_vc1_decode_blocks(v);
if (i != n_slices)
s->gb = slices[i].gb;
}
if (v->field_mode) {
v->second_field = 0;
if (s->pict_type == AV_PICTURE_TYPE_B) {
memcpy(v->mv_f_base, v->mv_f_next_base,
2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
}
s->current_picture.f.linesize[0] >>= 1;
s->current_picture.f.linesize[1] >>= 1;
s->current_picture.f.linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
}
av_dlog(s->avctx, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_frame_end(s);
}
ff_MPV_frame_end(s);
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
image:
avctx->width = avctx->coded_width = v->output_width;
avctx->height = avctx->coded_height = v->output_height;
if (avctx->skip_frame >= AVDISCARD_NONREF)
goto end;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
if (vc1_decode_sprites(v, &s->gb))
goto err;
#endif
*pict = v->sprite_output_frame;
*data_size = sizeof(AVFrame);
} else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
}
end:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return buf_size;
err:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return -1;
}
| {
"code": [
" return -1;"
],
"line_no": [
319
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->VAR_15, VAR_6 = 0, VAR_18;
VC1Context *v = VAR_0->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = VAR_1;
uint8_t *buf2 = NULL;
const uint8_t *VAR_8 = VAR_4;
int VAR_9, VAR_10;
struct {
uint8_t *VAR_4;
GetBitContext gb;
int mby_start;
} *VAR_11 = NULL, *VAR_12;
if (VAR_5 == 0 || (VAR_5 == 4 && AV_RB32(VAR_4) == VC1_CODE_ENDOFSEQ)) {
if (s->low_delay == 0 && s->next_picture_ptr) {
*pict = s->next_picture_ptr->f;
s->next_picture_ptr = NULL;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
if (s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
if (v->profile < PROFILE_ADVANCED)
VAR_0->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
else
VAR_0->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
}
if (VAR_0->codec_id == AV_CODEC_ID_VC1 || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {
int VAR_13 = 0;
buf2 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);
if (IS_MARKER(AV_RB32(VAR_4))) {
const uint8_t *VAR_14, *end, *next;
int VAR_15;
next = VAR_4;
for (VAR_14 = VAR_4, end = VAR_4 + VAR_5; next < end; VAR_14 = next) {
next = find_next_marker(VAR_14 + 4, end);
VAR_15 = next - VAR_14 - 4;
if (VAR_15 <= 0) continue;
switch (AV_RB32(VAR_14)) {
case VC1_CODE_FRAME:
if (VAR_0->hwaccel ||
s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
VAR_8 = VAR_14;
VAR_13 = vc1_unescape_buffer(VAR_14 + 4, VAR_15, buf2);
break;
case VC1_CODE_FIELD: {
int VAR_17;
VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));
if (!VAR_12)
goto err;
VAR_11 = VAR_12;
VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_11[VAR_6].VAR_4)
goto err;
VAR_17 = vc1_unescape_buffer(VAR_14 + 4, VAR_15,
VAR_11[VAR_6].VAR_4);
init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,
VAR_17 << 3);
VAR_11[VAR_6].mby_start = s->VAR_9 >> 1;
VAR_10 = VAR_6 - 1;
VAR_6++;
break;
}
case VC1_CODE_ENTRYPOINT:
VAR_13 = vc1_unescape_buffer(VAR_14 + 4, VAR_15, buf2);
init_get_bits(&s->gb, buf2, VAR_13 * 8);
ff_vc1_decode_entry_point(VAR_0, v, &s->gb);
break;
case VC1_CODE_SLICE: {
int VAR_17;
VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));
if (!VAR_12)
goto err;
VAR_11 = VAR_12;
VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_11[VAR_6].VAR_4)
goto err;
VAR_17 = vc1_unescape_buffer(VAR_14 + 4, VAR_15,
VAR_11[VAR_6].VAR_4);
init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,
VAR_17 << 3);
VAR_11[VAR_6].mby_start = get_bits(&VAR_11[VAR_6].gb, 9);
VAR_6++;
break;
}
}
}
} else if (v->interlace && ((VAR_4[0] & 0xC0) == 0xC0)) {
const uint8_t *VAR_16;
int VAR_17;
VAR_16 = find_next_marker(VAR_4, VAR_4 + VAR_5);
if ((VAR_16 == (VAR_4 + VAR_5)) || AV_RB32(VAR_16) != VC1_CODE_FIELD) {
av_log(VAR_0, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
goto err;
} else {
VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));
if (!VAR_12)
goto err;
VAR_11 = VAR_12;
VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_11[VAR_6].VAR_4)
goto err;
VAR_17 = vc1_unescape_buffer(VAR_16 + 4, VAR_4 + VAR_5 - VAR_16 - 4, VAR_11[VAR_6].VAR_4);
init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,
VAR_17 << 3);
VAR_11[VAR_6].mby_start = s->VAR_9 >> 1;
VAR_10 = VAR_6 - 1;
VAR_6++;
}
VAR_13 = vc1_unescape_buffer(VAR_4, VAR_16 - VAR_4, buf2);
} else {
VAR_13 = vc1_unescape_buffer(VAR_4, VAR_5, buf2);
}
init_get_bits(&s->gb, buf2, VAR_13*8);
} else
init_get_bits(&s->gb, VAR_4, VAR_5*8);
if (v->res_sprite) {
v->new_sprite = !get_bits1(&s->gb);
v->two_sprites = get_bits1(&s->gb);
if (VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {
if (v->new_sprite) {
VAR_0->width = VAR_0->coded_width = v->sprite_width;
VAR_0->height = VAR_0->coded_height = v->sprite_height;
} else {
goto image;
}
}
}
if (s->context_initialized &&
(s->width != VAR_0->coded_width ||
s->height != VAR_0->coded_height)) {
ff_vc1_decode_end(VAR_0);
}
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(VAR_0) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
return -1;
s->low_delay = !VAR_0->has_b_frames || v->res_sprite;
if (v->profile == PROFILE_ADVANCED) {
s->h_edge_pos = VAR_0->coded_width;
s->v_edge_pos = VAR_0->coded_height;
}
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.VAR_1[0]) {
int VAR_18 = ff_find_unused_picture(s, 0);
if (VAR_18 < 0)
goto err;
s->current_picture_ptr = &s->picture[VAR_18];
}
v->pic_header_flag = 0;
if (v->profile < PROFILE_ADVANCED) {
if (ff_vc1_parse_frame_header(v, &s->gb) == -1) {
goto err;
}
} else {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) == -1) {
goto err;
}
}
if ((VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE)
&& s->pict_type != AV_PICTURE_TYPE_I) {
av_log(v->s.VAR_0, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n");
goto err;
}
s->current_picture_ptr->f.repeat_pict = 0;
if (v->rff) {
s->current_picture_ptr->f.repeat_pict = 1;
} else if (v->rptfrm) {
s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) {
goto err;
}
if ((VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
VAR_0->skip_frame >= AVDISCARD_ALL) {
goto end;
}
if (s->next_p_frame_damaged) {
if (s->pict_type == AV_PICTURE_TYPE_B)
goto end;
else
s->next_p_frame_damaged = 0;
}
if (ff_MPV_frame_start(s, VAR_0) < 0) {
goto err;
}
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER)
&&s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, VAR_8, (VAR_4 + VAR_5) - VAR_8);
else if (VAR_0->hwaccel) {
if (VAR_0->hwaccel->start_frame(VAR_0, VAR_4, VAR_5) < 0)
goto err;
if (VAR_0->hwaccel->decode_slice(VAR_0, VAR_8, (VAR_4 + VAR_5) - VAR_8) < 0)
goto err;
if (VAR_0->hwaccel->end_frame(VAR_0) < 0)
goto err;
} else {
ff_er_frame_start(s);
v->bits = VAR_5 * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
uint8_t *VAR_12[2];
s->current_picture.f.linesize[0] <<= 1;
s->current_picture.f.linesize[1] <<= 1;
s->current_picture.f.linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
VAR_12[0] = v->mv_f_last[0];
VAR_12[1] = v->mv_f_last[1];
v->mv_f_last[0] = v->mv_f_next[0];
v->mv_f_last[1] = v->mv_f_next[1];
v->mv_f_next[0] = v->mv_f[0];
v->mv_f_next[1] = v->mv_f[1];
v->mv_f[0] = VAR_12[0];
v->mv_f[1] = VAR_12[1];
}
VAR_9 = s->VAR_9 >> v->field_mode;
for (VAR_18 = 0; VAR_18 <= VAR_6; VAR_18++) {
if (VAR_18 > 0 && VAR_11[VAR_18 - 1].mby_start >= VAR_9) {
if (v->field_mode <= 0) {
av_log(v->s.VAR_0, AV_LOG_ERROR, "Slice %d starts beyond "
"picture boundary (%d >= %d)\n", VAR_18,
VAR_11[VAR_18 - 1].mby_start, VAR_9);
continue;
}
v->second_field = 1;
v->blocks_off = s->mb_width * s->VAR_9 << 1;
v->mb_off = s->mb_stride * s->VAR_9 >> 1;
} else {
v->second_field = 0;
v->blocks_off = 0;
v->mb_off = 0;
}
if (VAR_18) {
v->pic_header_flag = 0;
if (v->field_mode && VAR_18 == VAR_10 + 2) {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.VAR_0, AV_LOG_ERROR, "Field header damaged\n");
continue;
}
} else if (get_bits1(&s->gb)) {
v->pic_header_flag = 1;
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.VAR_0, AV_LOG_ERROR, "Slice header damaged\n");
continue;
}
}
}
s->start_mb_y = (VAR_18 == 0) ? 0 : FFMAX(0, VAR_11[VAR_18-1].mby_start % VAR_9);
if (!v->field_mode || v->second_field)
s->end_mb_y = (VAR_18 == VAR_6 ) ? VAR_9 : FFMIN(VAR_9, VAR_11[VAR_18].mby_start % VAR_9);
else
s->end_mb_y = (VAR_18 <= VAR_10 + 1) ? VAR_9 : FFMIN(VAR_9, VAR_11[VAR_18].mby_start % VAR_9);
ff_vc1_decode_blocks(v);
if (VAR_18 != VAR_6)
s->gb = VAR_11[VAR_18].gb;
}
if (v->field_mode) {
v->second_field = 0;
if (s->pict_type == AV_PICTURE_TYPE_B) {
memcpy(v->mv_f_base, v->mv_f_next_base,
2 * (s->b8_stride * (s->VAR_9 * 2 + 1) + s->mb_stride * (s->VAR_9 + 1) * 2));
}
s->current_picture.f.linesize[0] >>= 1;
s->current_picture.f.linesize[1] >>= 1;
s->current_picture.f.linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
}
av_dlog(s->VAR_0, "Consumed %VAR_18/%VAR_18 bits\n",
get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_frame_end(s);
}
ff_MPV_frame_end(s);
if (VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {
image:
VAR_0->width = VAR_0->coded_width = v->output_width;
VAR_0->height = VAR_0->coded_height = v->output_height;
if (VAR_0->skip_frame >= AVDISCARD_NONREF)
goto end;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
if (vc1_decode_sprites(v, &s->gb))
goto err;
#endif
*pict = v->sprite_output_frame;
*VAR_2 = sizeof(AVFrame);
} else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if (s->last_picture_ptr || s->low_delay) {
*VAR_2 = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
}
end:
av_free(buf2);
for (VAR_18 = 0; VAR_18 < VAR_6; VAR_18++)
av_free(VAR_11[VAR_18].VAR_4);
av_free(VAR_11);
return VAR_5;
err:
av_free(buf2);
for (VAR_18 = 0; VAR_18 < VAR_6; VAR_18++)
av_free(VAR_11[VAR_18].VAR_4);
av_free(VAR_11);
return -1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->VAR_15, VAR_6 = 0, VAR_18;",
"VC1Context *v = VAR_0->priv_data;",
"MpegEncContext *s = &v->s;",
"AVFrame *pict = VAR_1;",
"uint8_t *buf2 = NULL;",
"const uint8_t *VAR_8 = VAR_4;",
"int VAR_9, VAR_10;",
"struct {",
"uint8_t *VAR_4;",
"GetBitContext gb;",
"int mby_start;",
"} *VAR_11 = NULL, *VAR_12;",
"if (VAR_5 == 0 || (VAR_5 == 4 && AV_RB32(VAR_4) == VC1_CODE_ENDOFSEQ)) {",
"if (s->low_delay == 0 && s->next_picture_ptr) {",
"*pict = s->next_picture_ptr->f;",
"s->next_picture_ptr = NULL;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"if (s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {",
"if (v->profile < PROFILE_ADVANCED)\nVAR_0->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;",
"else\nVAR_0->pix_fmt = AV_PIX_FMT_VDPAU_VC1;",
"}",
"if (VAR_0->codec_id == AV_CODEC_ID_VC1 || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {",
"int VAR_13 = 0;",
"buf2 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (IS_MARKER(AV_RB32(VAR_4))) {",
"const uint8_t *VAR_14, *end, *next;",
"int VAR_15;",
"next = VAR_4;",
"for (VAR_14 = VAR_4, end = VAR_4 + VAR_5; next < end; VAR_14 = next) {",
"next = find_next_marker(VAR_14 + 4, end);",
"VAR_15 = next - VAR_14 - 4;",
"if (VAR_15 <= 0) continue;",
"switch (AV_RB32(VAR_14)) {",
"case VC1_CODE_FRAME:\nif (VAR_0->hwaccel ||\ns->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)\nVAR_8 = VAR_14;",
"VAR_13 = vc1_unescape_buffer(VAR_14 + 4, VAR_15, buf2);",
"break;",
"case VC1_CODE_FIELD: {",
"int VAR_17;",
"VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));",
"if (!VAR_12)\ngoto err;",
"VAR_11 = VAR_12;",
"VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_11[VAR_6].VAR_4)\ngoto err;",
"VAR_17 = vc1_unescape_buffer(VAR_14 + 4, VAR_15,\nVAR_11[VAR_6].VAR_4);",
"init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,\nVAR_17 << 3);",
"VAR_11[VAR_6].mby_start = s->VAR_9 >> 1;",
"VAR_10 = VAR_6 - 1;",
"VAR_6++;",
"break;",
"}",
"case VC1_CODE_ENTRYPOINT:\nVAR_13 = vc1_unescape_buffer(VAR_14 + 4, VAR_15, buf2);",
"init_get_bits(&s->gb, buf2, VAR_13 * 8);",
"ff_vc1_decode_entry_point(VAR_0, v, &s->gb);",
"break;",
"case VC1_CODE_SLICE: {",
"int VAR_17;",
"VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));",
"if (!VAR_12)\ngoto err;",
"VAR_11 = VAR_12;",
"VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_11[VAR_6].VAR_4)\ngoto err;",
"VAR_17 = vc1_unescape_buffer(VAR_14 + 4, VAR_15,\nVAR_11[VAR_6].VAR_4);",
"init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,\nVAR_17 << 3);",
"VAR_11[VAR_6].mby_start = get_bits(&VAR_11[VAR_6].gb, 9);",
"VAR_6++;",
"break;",
"}",
"}",
"}",
"} else if (v->interlace && ((VAR_4[0] & 0xC0) == 0xC0)) {",
"const uint8_t *VAR_16;",
"int VAR_17;",
"VAR_16 = find_next_marker(VAR_4, VAR_4 + VAR_5);",
"if ((VAR_16 == (VAR_4 + VAR_5)) || AV_RB32(VAR_16) != VC1_CODE_FIELD) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error in WVC1 interlaced frame\\n\");",
"goto err;",
"} else {",
"VAR_12 = av_realloc(VAR_11, sizeof(*VAR_11) * (VAR_6+1));",
"if (!VAR_12)\ngoto err;",
"VAR_11 = VAR_12;",
"VAR_11[VAR_6].VAR_4 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_11[VAR_6].VAR_4)\ngoto err;",
"VAR_17 = vc1_unescape_buffer(VAR_16 + 4, VAR_4 + VAR_5 - VAR_16 - 4, VAR_11[VAR_6].VAR_4);",
"init_get_bits(&VAR_11[VAR_6].gb, VAR_11[VAR_6].VAR_4,\nVAR_17 << 3);",
"VAR_11[VAR_6].mby_start = s->VAR_9 >> 1;",
"VAR_10 = VAR_6 - 1;",
"VAR_6++;",
"}",
"VAR_13 = vc1_unescape_buffer(VAR_4, VAR_16 - VAR_4, buf2);",
"} else {",
"VAR_13 = vc1_unescape_buffer(VAR_4, VAR_5, buf2);",
"}",
"init_get_bits(&s->gb, buf2, VAR_13*8);",
"} else",
"init_get_bits(&s->gb, VAR_4, VAR_5*8);",
"if (v->res_sprite) {",
"v->new_sprite = !get_bits1(&s->gb);",
"v->two_sprites = get_bits1(&s->gb);",
"if (VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {",
"if (v->new_sprite) {",
"VAR_0->width = VAR_0->coded_width = v->sprite_width;",
"VAR_0->height = VAR_0->coded_height = v->sprite_height;",
"} else {",
"goto image;",
"}",
"}",
"}",
"if (s->context_initialized &&\n(s->width != VAR_0->coded_width ||\ns->height != VAR_0->coded_height)) {",
"ff_vc1_decode_end(VAR_0);",
"}",
"if (!s->context_initialized) {",
"if (ff_msmpeg4_decode_init(VAR_0) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)\nreturn -1;",
"s->low_delay = !VAR_0->has_b_frames || v->res_sprite;",
"if (v->profile == PROFILE_ADVANCED) {",
"s->h_edge_pos = VAR_0->coded_width;",
"s->v_edge_pos = VAR_0->coded_height;",
"}",
"}",
"if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.VAR_1[0]) {",
"int VAR_18 = ff_find_unused_picture(s, 0);",
"if (VAR_18 < 0)\ngoto err;",
"s->current_picture_ptr = &s->picture[VAR_18];",
"}",
"v->pic_header_flag = 0;",
"if (v->profile < PROFILE_ADVANCED) {",
"if (ff_vc1_parse_frame_header(v, &s->gb) == -1) {",
"goto err;",
"}",
"} else {",
"if (ff_vc1_parse_frame_header_adv(v, &s->gb) == -1) {",
"goto err;",
"}",
"}",
"if ((VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE)\n&& s->pict_type != AV_PICTURE_TYPE_I) {",
"av_log(v->s.VAR_0, AV_LOG_ERROR, \"Sprite decoder: expected I-frame\\n\");",
"goto err;",
"}",
"s->current_picture_ptr->f.repeat_pict = 0;",
"if (v->rff) {",
"s->current_picture_ptr->f.repeat_pict = 1;",
"} else if (v->rptfrm) {",
"s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;",
"}",
"s->current_picture.f.pict_type = s->pict_type;",
"s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
"if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) {",
"goto err;",
"}",
"if ((VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||\n(VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||\nVAR_0->skip_frame >= AVDISCARD_ALL) {",
"goto end;",
"}",
"if (s->next_p_frame_damaged) {",
"if (s->pict_type == AV_PICTURE_TYPE_B)\ngoto end;",
"else\ns->next_p_frame_damaged = 0;",
"}",
"if (ff_MPV_frame_start(s, VAR_0) < 0) {",
"goto err;",
"}",
"s->me.qpel_put = s->dsp.put_qpel_pixels_tab;",
"s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;",
"if ((CONFIG_VC1_VDPAU_DECODER)\n&&s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)\nff_vdpau_vc1_decode_picture(s, VAR_8, (VAR_4 + VAR_5) - VAR_8);",
"else if (VAR_0->hwaccel) {",
"if (VAR_0->hwaccel->start_frame(VAR_0, VAR_4, VAR_5) < 0)\ngoto err;",
"if (VAR_0->hwaccel->decode_slice(VAR_0, VAR_8, (VAR_4 + VAR_5) - VAR_8) < 0)\ngoto err;",
"if (VAR_0->hwaccel->end_frame(VAR_0) < 0)\ngoto err;",
"} else {",
"ff_er_frame_start(s);",
"v->bits = VAR_5 * 8;",
"v->end_mb_x = s->mb_width;",
"if (v->field_mode) {",
"uint8_t *VAR_12[2];",
"s->current_picture.f.linesize[0] <<= 1;",
"s->current_picture.f.linesize[1] <<= 1;",
"s->current_picture.f.linesize[2] <<= 1;",
"s->linesize <<= 1;",
"s->uvlinesize <<= 1;",
"VAR_12[0] = v->mv_f_last[0];",
"VAR_12[1] = v->mv_f_last[1];",
"v->mv_f_last[0] = v->mv_f_next[0];",
"v->mv_f_last[1] = v->mv_f_next[1];",
"v->mv_f_next[0] = v->mv_f[0];",
"v->mv_f_next[1] = v->mv_f[1];",
"v->mv_f[0] = VAR_12[0];",
"v->mv_f[1] = VAR_12[1];",
"}",
"VAR_9 = s->VAR_9 >> v->field_mode;",
"for (VAR_18 = 0; VAR_18 <= VAR_6; VAR_18++) {",
"if (VAR_18 > 0 && VAR_11[VAR_18 - 1].mby_start >= VAR_9) {",
"if (v->field_mode <= 0) {",
"av_log(v->s.VAR_0, AV_LOG_ERROR, \"Slice %d starts beyond \"\n\"picture boundary (%d >= %d)\\n\", VAR_18,\nVAR_11[VAR_18 - 1].mby_start, VAR_9);",
"continue;",
"}",
"v->second_field = 1;",
"v->blocks_off = s->mb_width * s->VAR_9 << 1;",
"v->mb_off = s->mb_stride * s->VAR_9 >> 1;",
"} else {",
"v->second_field = 0;",
"v->blocks_off = 0;",
"v->mb_off = 0;",
"}",
"if (VAR_18) {",
"v->pic_header_flag = 0;",
"if (v->field_mode && VAR_18 == VAR_10 + 2) {",
"if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {",
"av_log(v->s.VAR_0, AV_LOG_ERROR, \"Field header damaged\\n\");",
"continue;",
"}",
"} else if (get_bits1(&s->gb)) {",
"v->pic_header_flag = 1;",
"if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {",
"av_log(v->s.VAR_0, AV_LOG_ERROR, \"Slice header damaged\\n\");",
"continue;",
"}",
"}",
"}",
"s->start_mb_y = (VAR_18 == 0) ? 0 : FFMAX(0, VAR_11[VAR_18-1].mby_start % VAR_9);",
"if (!v->field_mode || v->second_field)\ns->end_mb_y = (VAR_18 == VAR_6 ) ? VAR_9 : FFMIN(VAR_9, VAR_11[VAR_18].mby_start % VAR_9);",
"else\ns->end_mb_y = (VAR_18 <= VAR_10 + 1) ? VAR_9 : FFMIN(VAR_9, VAR_11[VAR_18].mby_start % VAR_9);",
"ff_vc1_decode_blocks(v);",
"if (VAR_18 != VAR_6)\ns->gb = VAR_11[VAR_18].gb;",
"}",
"if (v->field_mode) {",
"v->second_field = 0;",
"if (s->pict_type == AV_PICTURE_TYPE_B) {",
"memcpy(v->mv_f_base, v->mv_f_next_base,\n2 * (s->b8_stride * (s->VAR_9 * 2 + 1) + s->mb_stride * (s->VAR_9 + 1) * 2));",
"}",
"s->current_picture.f.linesize[0] >>= 1;",
"s->current_picture.f.linesize[1] >>= 1;",
"s->current_picture.f.linesize[2] >>= 1;",
"s->linesize >>= 1;",
"s->uvlinesize >>= 1;",
"}",
"av_dlog(s->VAR_0, \"Consumed %VAR_18/%VAR_18 bits\\n\",\nget_bits_count(&s->gb), s->gb.size_in_bits);",
"ff_er_frame_end(s);",
"}",
"ff_MPV_frame_end(s);",
"if (VAR_0->codec_id == AV_CODEC_ID_WMV3IMAGE || VAR_0->codec_id == AV_CODEC_ID_VC1IMAGE) {",
"image:\nVAR_0->width = VAR_0->coded_width = v->output_width;",
"VAR_0->height = VAR_0->coded_height = v->output_height;",
"if (VAR_0->skip_frame >= AVDISCARD_NONREF)\ngoto end;",
"#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER\nif (vc1_decode_sprites(v, &s->gb))\ngoto err;",
"#endif\n*pict = v->sprite_output_frame;",
"*VAR_2 = sizeof(AVFrame);",
"} else {",
"if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {",
"*pict = s->current_picture_ptr->f;",
"} else if (s->last_picture_ptr != NULL) {",
"*pict = s->last_picture_ptr->f;",
"}",
"if (s->last_picture_ptr || s->low_delay) {",
"*VAR_2 = sizeof(AVFrame);",
"ff_print_debug_info(s, pict);",
"}",
"}",
"end:\nav_free(buf2);",
"for (VAR_18 = 0; VAR_18 < VAR_6; VAR_18++)",
"av_free(VAR_11[VAR_18].VAR_4);",
"av_free(VAR_11);",
"return VAR_5;",
"err:\nav_free(buf2);",
"for (VAR_18 = 0; VAR_18 < VAR_6; VAR_18++)",
"av_free(VAR_11[VAR_18].VAR_4);",
"av_free(VAR_11);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
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
],
[
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
],
[
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
],
[
269
],
[
271
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303,
305,
307
],
[
309
],
[
311
],
[
315
],
[
317,
319
],
[
323
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
381,
383
],
[
385
],
[
387
],
[
389
],
[
395
],
[
401
],
[
405
],
[
407
],
[
411
],
[
413
],
[
419
],
[
421
],
[
427
],
[
429
],
[
431
],
[
433,
435,
437
],
[
439
],
[
441
],
[
445
],
[
447,
449
],
[
451,
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
467
],
[
469
],
[
473,
475,
477
],
[
479
],
[
481,
483
],
[
485,
487
],
[
489,
491
],
[
493
],
[
495
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543,
545,
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601,
603
],
[
605,
607
],
[
609
],
[
611,
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623,
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641,
643
],
[
649
],
[
651
],
[
655
],
[
659
],
[
661,
663
],
[
665
],
[
667,
669
],
[
671,
673,
675
],
[
677,
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
707,
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
721,
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
]
] |
24,889 | int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int ret;
AVFrame *pict = data;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
/* no supplementary picture */
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr= NULL;
*got_frame = 1;
}
return 0;
}
if(s->flags&CODEC_FLAG_TRUNCATED){
int next;
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else{
av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
return AVERROR(EINVAL);
}
if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
return buf_size;
}
retry:
if(s->divx_packed && s->bitstream_buffer_size){
int i;
for(i=0; i<buf_size-3; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1){
if(buf[i+3]==0xB0){
av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
s->bitstream_buffer_size=0;
}
break;
}
}
}
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
}else
init_get_bits(&s->gb, buf, buf_size*8);
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if ((ret = ff_MPV_common_init(s)) < 0) //we need the idct permutaton for reading a custom matrix
return ret;
}
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i= ff_find_unused_picture(s, 0);
if (i < 0)
return i;
s->current_picture_ptr= &s->picture[i];
}
/* let's go :-) */
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
ret= ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
ret = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
if(s->avctx->extradata_size && s->picture_number==0){
GetBitContext gb;
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
ret = ff_mpeg4_decode_picture_header(s, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
ret = ff_flv_decode_picture_header(s);
} else {
ret = ff_h263_decode_picture_header(s);
}
if (ret < 0 || ret==FRAME_SKIPPED) {
if ( s->width != avctx->coded_width
|| s->height != avctx->coded_height) {
av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
s->width = avctx->coded_width;
s->height= avctx->coded_height;
}
}
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
/* skip if the header was thrashed */
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return ret;
}
avctx->has_b_frames= !s->low_delay;
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->xvid_build= 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
s->xvid_build= 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400; //divx 4
}
if(s->xvid_build>=0 && s->divx_version>=0){
s->divx_version=
s->divx_build= -1;
}
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
if(s->xvid_build<=3U)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build<=1U)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
if(s->xvid_build<=12U)
s->workaround_bugs|= FF_BUG_EDGE;
if(s->xvid_build<=32U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if(s->lavc_build<4653U)
s->workaround_bugs|= FF_BUG_STD_QPEL;
if(s->lavc_build<4655U)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->lavc_build<=4712U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
if(s->divx_version<500U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
/* very ugly XVID padding bug detection FIXME/XXX solve this differently
* Let us hope this at least works.
*/
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
s->workaround_bugs|= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U) //FIXME not sure about the version num but a 4609 file seems ok
s->workaround_bugs|= FF_BUG_NO_PADDING;
#endif
}
if(s->workaround_bugs& FF_BUG_STD_QPEL){
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if(avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "p" : "");
#if HAVE_MMX
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX;
ff_dct_common_init(s);
goto retry;
}
#endif
/* After H263 & mpeg4 header decode we have the height, width,*/
/* and other parameters. So then we could init the picture */
/* FIXME: By the way H263 decoder is evolving it should have */
/* an H263EncContext */
if (s->width != avctx->coded_width ||
s->height != avctx->coded_height ||
s->context_reinit) {
/* H.263 could change picture size any time */
s->context_reinit = 0;
avcodec_set_dimensions(avctx, s->width, s->height);
if ((ret = ff_MPV_common_frame_size_change(s)))
return ret;
}
if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
s->gob_index = ff_h263_get_gob_height(s);
// for skipping the frame
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if(s->next_p_frame_damaged){
if(s->pict_type==AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, buf_size);
else
s->next_p_frame_damaged=0;
}
if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}else{
s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}
if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
return ret;
if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
return ret;
}
ff_mpeg_er_frame_start(s);
//the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type
//which is not available before ff_MPV_frame_start()
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto frame_end;
}
/* decode each macroblock */
s->mb_x=0;
s->mb_y=0;
ret = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
break;
}else{
int prev_x=s->mb_x, prev_y=s->mb_y;
if(ff_h263_resync(s)<0)
break;
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
s->er.error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
}
av_assert1(s->bitstream_buffer_size==0);
frame_end:
ff_er_frame_end(&s->er);
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
return ret;
}
ff_MPV_frame_end(s);
/* divx 5.01+ bitstream reorder stuff */
/* Since this clobbers the input buffer and hwaccel codecs still need the
* data during hwaccel->end_frame we should not do this any earlier */
if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){
int current_pos= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);
int startcode_found=0;
if(buf_size - current_pos > 7){
int i;
for(i=current_pos; i<buf_size-4; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
startcode_found=!(buf[i+4]&0x40);
break;
}
}
}
if(startcode_found){
av_fast_malloc(
&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
s->bitstream_buffer_size= buf_size - current_pos;
}
}
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
av_assert1(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
}
if(s->last_picture_ptr || s->low_delay){
if ( pict->format == AV_PIX_FMT_YUV420P
&& (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
int x, y, p;
av_frame_make_writable(pict);
for (p=0; p<3; p++) {
int w = FF_CEIL_RSHIFT(pict-> width, !!p);
int h = FF_CEIL_RSHIFT(pict->height, !!p);
int linesize = pict->linesize[p];
for (y=0; y<(h>>1); y++)
for (x=0; x<w; x++)
FFSWAP(int,
pict->data[p][x + y*linesize],
pict->data[p][x + (h-1-y)*linesize]);
}
}
*got_frame = 1;
}
return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
}
| true | FFmpeg | d47e14b53a3908e5bad82e22129bbd175b49e89b | int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int ret;
AVFrame *pict = data;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr= NULL;
*got_frame = 1;
}
return 0;
}
if(s->flags&CODEC_FLAG_TRUNCATED){
int next;
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else{
av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
return AVERROR(EINVAL);
}
if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
return buf_size;
}
retry:
if(s->divx_packed && s->bitstream_buffer_size){
int i;
for(i=0; i<buf_size-3; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1){
if(buf[i+3]==0xB0){
av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
s->bitstream_buffer_size=0;
}
break;
}
}
}
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
}else
init_get_bits(&s->gb, buf, buf_size*8);
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i= ff_find_unused_picture(s, 0);
if (i < 0)
return i;
s->current_picture_ptr= &s->picture[i];
}
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
ret= ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
ret = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
if(s->avctx->extradata_size && s->picture_number==0){
GetBitContext gb;
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
ret = ff_mpeg4_decode_picture_header(s, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
ret = ff_flv_decode_picture_header(s);
} else {
ret = ff_h263_decode_picture_header(s);
}
if (ret < 0 || ret==FRAME_SKIPPED) {
if ( s->width != avctx->coded_width
|| s->height != avctx->coded_height) {
av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
s->width = avctx->coded_width;
s->height= avctx->coded_height;
}
}
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return ret;
}
avctx->has_b_frames= !s->low_delay;
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->xvid_build= 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay)
s->xvid_build= 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400;
}
if(s->xvid_build>=0 && s->divx_version>=0){
s->divx_version=
s->divx_build= -1;
}
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
if(s->xvid_build<=3U)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build<=1U)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
if(s->xvid_build<=12U)
s->workaround_bugs|= FF_BUG_EDGE;
if(s->xvid_build<=32U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if(s->lavc_build<4653U)
s->workaround_bugs|= FF_BUG_STD_QPEL;
if(s->lavc_build<4655U)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->lavc_build<=4712U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
if(s->divx_version<500U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
s->workaround_bugs|= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U)
s->workaround_bugs|= FF_BUG_NO_PADDING;
#endif
}
if(s->workaround_bugs& FF_BUG_STD_QPEL){
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if(avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "p" : "");
#if HAVE_MMX
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX;
ff_dct_common_init(s);
goto retry;
}
#endif
if (s->width != avctx->coded_width ||
s->height != avctx->coded_height ||
s->context_reinit) {
s->context_reinit = 0;
avcodec_set_dimensions(avctx, s->width, s->height);
if ((ret = ff_MPV_common_frame_size_change(s)))
return ret;
}
if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
s->gob_index = ff_h263_get_gob_height(s);
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if(s->next_p_frame_damaged){
if(s->pict_type==AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, buf_size);
else
s->next_p_frame_damaged=0;
}
if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}else{
s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}
if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
return ret;
if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
return ret;
}
ff_mpeg_er_frame_start(s);
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto frame_end;
}
s->mb_x=0;
s->mb_y=0;
ret = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
break;
}else{
int prev_x=s->mb_x, prev_y=s->mb_y;
if(ff_h263_resync(s)<0)
break;
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
s->er.error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
}
av_assert1(s->bitstream_buffer_size==0);
frame_end:
ff_er_frame_end(&s->er);
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
return ret;
}
ff_MPV_frame_end(s);
if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){
int current_pos= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);
int startcode_found=0;
if(buf_size - current_pos > 7){
int i;
for(i=current_pos; i<buf_size-4; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
startcode_found=!(buf[i+4]&0x40);
break;
}
}
}
if(startcode_found){
av_fast_malloc(
&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
s->bitstream_buffer_size= buf_size - current_pos;
}
}
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
av_assert1(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
}
if(s->last_picture_ptr || s->low_delay){
if ( pict->format == AV_PIX_FMT_YUV420P
&& (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
int x, y, p;
av_frame_make_writable(pict);
for (p=0; p<3; p++) {
int w = FF_CEIL_RSHIFT(pict-> width, !!p);
int h = FF_CEIL_RSHIFT(pict->height, !!p);
int linesize = pict->linesize[p];
for (y=0; y<(h>>1); y++)
for (x=0; x<w; x++)
FFSWAP(int,
pict->data[p][x + y*linesize],
pict->data[p][x + (h-1-y)*linesize]);
}
}
*got_frame = 1;
}
return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
}
| {
"code": [
" init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);",
" init_get_bits(&s->gb, buf, buf_size*8);",
" init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);",
" ret = ff_mpeg4_decode_picture_header(s, &gb);"
],
"line_no": [
123,
127,
179,
181
]
} | int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
MpegEncContext *s = VAR_0->priv_data;
int VAR_6;
AVFrame *pict = VAR_1;
s->flags= VAR_0->flags;
s->flags2= VAR_0->flags2;
if (VAR_5 == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
if ((VAR_6 = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
return VAR_6;
s->next_picture_ptr= NULL;
*VAR_2 = 1;
}
return 0;
}
if(s->flags&CODEC_FLAG_TRUNCATED){
int VAR_7;
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
VAR_7= ff_mpeg4_find_frame_end(&s->parse_context, VAR_4, VAR_5);
}else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){
VAR_7= ff_h263_find_frame_end(&s->parse_context, VAR_4, VAR_5);
}else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){
VAR_7= ff_h263_find_frame_end(&s->parse_context, VAR_4, VAR_5);
}else{
av_log(s->VAR_0, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
return AVERROR(EINVAL);
}
if( ff_combine_frame(&s->parse_context, VAR_7, (const uint8_t **)&VAR_4, &VAR_5) < 0 )
return VAR_5;
}
retry:
if(s->divx_packed && s->bitstream_buffer_size){
int VAR_13;
for(VAR_13=0; VAR_13<VAR_5-3; VAR_13++){
if(VAR_4[VAR_13]==0 && VAR_4[VAR_13+1]==0 && VAR_4[VAR_13+2]==1){
if(VAR_4[VAR_13+3]==0xB0){
av_log(s->VAR_0, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
s->bitstream_buffer_size=0;
}
break;
}
}
}
if(s->bitstream_buffer_size && (s->divx_packed || VAR_5<20)){
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
}else
init_get_bits(&s->gb, VAR_4, VAR_5*8);
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if ((VAR_6 = ff_MPV_common_init(s)) < 0)
return VAR_6;
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.VAR_1[0]) {
int VAR_13= ff_find_unused_picture(s, 0);
if (VAR_13 < 0)
return VAR_13;
s->current_picture_ptr= &s->picture[VAR_13];
}
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
VAR_6= ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
VAR_6 = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
if(s->VAR_0->extradata_size && s->picture_number==0){
GetBitContext gb;
init_get_bits(&gb, s->VAR_0->extradata, s->VAR_0->extradata_size*8);
VAR_6 = ff_mpeg4_decode_picture_header(s, &gb);
}
VAR_6 = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
VAR_6 = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
VAR_6 = ff_flv_decode_picture_header(s);
} else {
VAR_6 = ff_h263_decode_picture_header(s);
}
if (VAR_6 < 0 || VAR_6==FRAME_SKIPPED) {
if ( s->width != VAR_0->coded_width
|| s->height != VAR_0->coded_height) {
av_log(s->VAR_0, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
s->width = VAR_0->coded_width;
s->height= VAR_0->coded_height;
}
}
if(VAR_6==FRAME_SKIPPED) return get_consumed_bytes(s, VAR_5);
if (VAR_6 < 0){
av_log(s->VAR_0, AV_LOG_ERROR, "header damaged\n");
return VAR_6;
}
VAR_0->has_b_frames= !s->low_delay;
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->xvid_build= 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay)
s->xvid_build= 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400;
}
if(s->xvid_build>=0 && s->divx_version>=0){
s->divx_version=
s->divx_build= -1;
}
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
if(s->xvid_build<=3U)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build<=1U)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
if(s->xvid_build<=12U)
s->workaround_bugs|= FF_BUG_EDGE;
if(s->xvid_build<=32U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if(s->lavc_build<4653U)
s->workaround_bugs|= FF_BUG_STD_QPEL;
if(s->lavc_build<4655U)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->lavc_build<=4712U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
if(s->divx_version<500U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
s->workaround_bugs|= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U)
s->workaround_bugs|= FF_BUG_NO_PADDING;
#endif
}
if(s->workaround_bugs& FF_BUG_STD_QPEL){
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if(VAR_0->debug & FF_DEBUG_BUGS)
av_log(s->VAR_0, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "VAR_15" : "");
#if HAVE_MMX
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && VAR_0->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
VAR_0->idct_algo= FF_IDCT_XVIDMMX;
ff_dct_common_init(s);
goto retry;
}
#endif
if (s->width != VAR_0->coded_width ||
s->height != VAR_0->coded_height ||
s->context_reinit) {
s->context_reinit = 0;
avcodec_set_dimensions(VAR_0, s->width, s->height);
if ((VAR_6 = ff_MPV_common_frame_size_change(s)))
return VAR_6;
}
if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
s->gob_index = ff_h263_get_gob_height(s);
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, VAR_5);
if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| VAR_0->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, VAR_5);
if(s->next_p_frame_damaged){
if(s->pict_type==AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, VAR_5);
else
s->next_p_frame_damaged=0;
}
if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}else{
s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}
if ((VAR_6 = ff_MPV_frame_start(s, VAR_0)) < 0)
return VAR_6;
if (!s->divx_packed && !VAR_0->hwaccel)
ff_thread_finish_setup(VAR_0);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->VAR_0->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (VAR_0->hwaccel) {
if ((VAR_6 = VAR_0->hwaccel->start_frame(VAR_0, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
return VAR_6;
}
ff_mpeg_er_frame_start(s);
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
VAR_6 = ff_wmv2_decode_secondary_picture_header(s);
if(VAR_6<0) return VAR_6;
if(VAR_6==1) goto frame_end;
}
s->mb_x=0;
s->mb_y=0;
VAR_6 = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
break;
}else{
int VAR_9=s->mb_x, VAR_10=s->mb_y;
if(ff_h263_resync(s)<0)
break;
if (VAR_10 * s->mb_width + VAR_9 < s->mb_y * s->mb_width + s->mb_x)
s->er.error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) VAR_6 = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, VAR_5) < 0){
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
}
av_assert1(s->bitstream_buffer_size==0);
frame_end:
ff_er_frame_end(&s->er);
if (VAR_0->hwaccel) {
if ((VAR_6 = VAR_0->hwaccel->end_frame(VAR_0)) < 0)
return VAR_6;
}
ff_MPV_frame_end(s);
if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){
int VAR_11= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);
int VAR_12=0;
if(VAR_5 - VAR_11 > 7){
int VAR_13;
for(VAR_13=VAR_11; VAR_13<VAR_5-4; VAR_13++){
if(VAR_4[VAR_13]==0 && VAR_4[VAR_13+1]==0 && VAR_4[VAR_13+2]==1 && VAR_4[VAR_13+3]==0xB6){
VAR_12=!(VAR_4[VAR_13+4]&0x40);
break;
}
}
}
if(VAR_12){
av_fast_malloc(
&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
VAR_5 - VAR_11 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, VAR_4 + VAR_11, VAR_5 - VAR_11);
s->bitstream_buffer_size= VAR_5 - VAR_11;
}
}
if (!s->divx_packed && VAR_0->hwaccel)
ff_thread_finish_setup(VAR_0);
av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
av_assert1(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((VAR_6 = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
return VAR_6;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
if ((VAR_6 = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
return VAR_6;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
}
if(s->last_picture_ptr || s->low_delay){
if ( pict->format == AV_PIX_FMT_YUV420P
&& (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
int VAR_13, VAR_14, VAR_15;
av_frame_make_writable(pict);
for (VAR_15=0; VAR_15<3; VAR_15++) {
int VAR_16 = FF_CEIL_RSHIFT(pict-> width, !!VAR_15);
int VAR_17 = FF_CEIL_RSHIFT(pict->height, !!VAR_15);
int VAR_18 = pict->VAR_18[VAR_15];
for (VAR_14=0; VAR_14<(VAR_17>>1); VAR_14++)
for (VAR_13=0; VAR_13<VAR_16; VAR_13++)
FFSWAP(int,
pict->VAR_1[VAR_15][VAR_13 + VAR_14*VAR_18],
pict->VAR_1[VAR_15][VAR_13 + (VAR_17-1-VAR_14)*VAR_18]);
}
}
*VAR_2 = 1;
}
return (VAR_6 && (VAR_0->err_recognition & AV_EF_EXPLODE))?VAR_6:get_consumed_bytes(s, VAR_5);
}
| [
"int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_6;",
"AVFrame *pict = VAR_1;",
"s->flags= VAR_0->flags;",
"s->flags2= VAR_0->flags2;",
"if (VAR_5 == 0) {",
"if (s->low_delay==0 && s->next_picture_ptr) {",
"if ((VAR_6 = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)\nreturn VAR_6;",
"s->next_picture_ptr= NULL;",
"*VAR_2 = 1;",
"}",
"return 0;",
"}",
"if(s->flags&CODEC_FLAG_TRUNCATED){",
"int VAR_7;",
"if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){",
"VAR_7= ff_mpeg4_find_frame_end(&s->parse_context, VAR_4, VAR_5);",
"}else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){",
"VAR_7= ff_h263_find_frame_end(&s->parse_context, VAR_4, VAR_5);",
"}else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){",
"VAR_7= ff_h263_find_frame_end(&s->parse_context, VAR_4, VAR_5);",
"}else{",
"av_log(s->VAR_0, AV_LOG_ERROR, \"this codec does not support truncated bitstreams\\n\");",
"return AVERROR(EINVAL);",
"}",
"if( ff_combine_frame(&s->parse_context, VAR_7, (const uint8_t **)&VAR_4, &VAR_5) < 0 )\nreturn VAR_5;",
"}",
"retry:\nif(s->divx_packed && s->bitstream_buffer_size){",
"int VAR_13;",
"for(VAR_13=0; VAR_13<VAR_5-3; VAR_13++){",
"if(VAR_4[VAR_13]==0 && VAR_4[VAR_13+1]==0 && VAR_4[VAR_13+2]==1){",
"if(VAR_4[VAR_13+3]==0xB0){",
"av_log(s->VAR_0, AV_LOG_WARNING, \"Discarding excessive bitstream in packed xvid\\n\");",
"s->bitstream_buffer_size=0;",
"}",
"break;",
"}",
"}",
"}",
"if(s->bitstream_buffer_size && (s->divx_packed || VAR_5<20)){",
"init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);",
"}else",
"init_get_bits(&s->gb, VAR_4, VAR_5*8);",
"s->bitstream_buffer_size=0;",
"if (!s->context_initialized) {",
"if ((VAR_6 = ff_MPV_common_init(s)) < 0)\nreturn VAR_6;",
"}",
"if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.VAR_1[0]) {",
"int VAR_13= ff_find_unused_picture(s, 0);",
"if (VAR_13 < 0)\nreturn VAR_13;",
"s->current_picture_ptr= &s->picture[VAR_13];",
"}",
"if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {",
"VAR_6= ff_wmv2_decode_picture_header(s);",
"} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {",
"VAR_6 = ff_msmpeg4_decode_picture_header(s);",
"} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {",
"if(s->VAR_0->extradata_size && s->picture_number==0){",
"GetBitContext gb;",
"init_get_bits(&gb, s->VAR_0->extradata, s->VAR_0->extradata_size*8);",
"VAR_6 = ff_mpeg4_decode_picture_header(s, &gb);",
"}",
"VAR_6 = ff_mpeg4_decode_picture_header(s, &s->gb);",
"} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {",
"VAR_6 = ff_intel_h263_decode_picture_header(s);",
"} else if (CONFIG_FLV_DECODER && s->h263_flv) {",
"VAR_6 = ff_flv_decode_picture_header(s);",
"} else {",
"VAR_6 = ff_h263_decode_picture_header(s);",
"}",
"if (VAR_6 < 0 || VAR_6==FRAME_SKIPPED) {",
"if ( s->width != VAR_0->coded_width\n|| s->height != VAR_0->coded_height) {",
"av_log(s->VAR_0, AV_LOG_WARNING, \"Reverting picture dimensions change due to header decoding failure\\n\");",
"s->width = VAR_0->coded_width;",
"s->height= VAR_0->coded_height;",
"}",
"}",
"if(VAR_6==FRAME_SKIPPED) return get_consumed_bytes(s, VAR_5);",
"if (VAR_6 < 0){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"header damaged\\n\");",
"return VAR_6;",
"}",
"VAR_0->has_b_frames= !s->low_delay;",
"if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){",
"if(s->stream_codec_tag == AV_RL32(\"XVID\") ||\ns->codec_tag == AV_RL32(\"XVID\") || s->codec_tag == AV_RL32(\"XVIX\") ||\ns->codec_tag == AV_RL32(\"RMP4\") || s->codec_tag == AV_RL32(\"ZMP4\") ||\ns->codec_tag == AV_RL32(\"SIPP\")\n)\ns->xvid_build= 0;",
"#if 0\nif(s->codec_tag == AV_RL32(\"DIVX\") && s->vo_type==0 && s->vol_control_parameters==1\n&& s->padding_bug_score > 0 && s->low_delay)\ns->xvid_build= 0;",
"#endif\n}",
"if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){",
"if(s->codec_tag == AV_RL32(\"DIVX\") && s->vo_type==0 && s->vol_control_parameters==0)\ns->divx_version= 400;",
"}",
"if(s->xvid_build>=0 && s->divx_version>=0){",
"s->divx_version=\ns->divx_build= -1;",
"}",
"if(s->workaround_bugs&FF_BUG_AUTODETECT){",
"if(s->codec_tag == AV_RL32(\"XVIX\"))\ns->workaround_bugs|= FF_BUG_XVID_ILACE;",
"if(s->codec_tag == AV_RL32(\"UMP4\")){",
"s->workaround_bugs|= FF_BUG_UMP4;",
"}",
"if(s->divx_version>=500 && s->divx_build<1814){",
"s->workaround_bugs|= FF_BUG_QPEL_CHROMA;",
"}",
"if(s->divx_version>502 && s->divx_build<1814){",
"s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;",
"}",
"if(s->xvid_build<=3U)\ns->padding_bug_score= 256*256*256*64;",
"if(s->xvid_build<=1U)\ns->workaround_bugs|= FF_BUG_QPEL_CHROMA;",
"if(s->xvid_build<=12U)\ns->workaround_bugs|= FF_BUG_EDGE;",
"if(s->xvid_build<=32U)\ns->workaround_bugs|= FF_BUG_DC_CLIP;",
"#define SET_QPEL_FUNC(postfix1, postfix2) \\\ns->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\\",
"s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\\",
"s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;",
"if(s->lavc_build<4653U)\ns->workaround_bugs|= FF_BUG_STD_QPEL;",
"if(s->lavc_build<4655U)\ns->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;",
"if(s->lavc_build<4670U){",
"s->workaround_bugs|= FF_BUG_EDGE;",
"}",
"if(s->lavc_build<=4712U)\ns->workaround_bugs|= FF_BUG_DC_CLIP;",
"if(s->divx_version>=0)\ns->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;",
"if(s->divx_version==501 && s->divx_build==20020416)\ns->padding_bug_score= 256*256*256*64;",
"if(s->divx_version<500U){",
"s->workaround_bugs|= FF_BUG_EDGE;",
"}",
"if(s->divx_version>=0)\ns->workaround_bugs|= FF_BUG_HPEL_CHROMA;",
"#if 0\nif(s->divx_version==500)\ns->padding_bug_score= 256*256*256*64;",
"if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1\n&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)\ns->workaround_bugs|= FF_BUG_NO_PADDING;",
"if(s->lavc_build<4609U)\ns->workaround_bugs|= FF_BUG_NO_PADDING;",
"#endif\n}",
"if(s->workaround_bugs& FF_BUG_STD_QPEL){",
"SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)\n}",
"if(VAR_0->debug & FF_DEBUG_BUGS)\nav_log(s->VAR_0, AV_LOG_DEBUG, \"bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\\n\",\ns->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,\ns->divx_packed ? \"VAR_15\" : \"\");",
"#if HAVE_MMX\nif (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && VAR_0->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {",
"VAR_0->idct_algo= FF_IDCT_XVIDMMX;",
"ff_dct_common_init(s);",
"goto retry;",
"}",
"#endif\nif (s->width != VAR_0->coded_width ||\ns->height != VAR_0->coded_height ||\ns->context_reinit) {",
"s->context_reinit = 0;",
"avcodec_set_dimensions(VAR_0, s->width, s->height);",
"if ((VAR_6 = ff_MPV_common_frame_size_change(s)))\nreturn VAR_6;",
"}",
"if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))\ns->gob_index = ff_h263_get_gob_height(s);",
"s->current_picture.f.pict_type = s->pict_type;",
"s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
"if (s->last_picture_ptr == NULL &&\n(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))\nreturn get_consumed_bytes(s, VAR_5);",
"if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)\n|| (VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)\n|| VAR_0->skip_frame >= AVDISCARD_ALL)\nreturn get_consumed_bytes(s, VAR_5);",
"if(s->next_p_frame_damaged){",
"if(s->pict_type==AV_PICTURE_TYPE_B)\nreturn get_consumed_bytes(s, VAR_5);",
"else\ns->next_p_frame_damaged=0;",
"}",
"if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){",
"s->me.qpel_put= s->dsp.put_qpel_pixels_tab;",
"s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;",
"}else{",
"s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;",
"s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;",
"}",
"if ((VAR_6 = ff_MPV_frame_start(s, VAR_0)) < 0)\nreturn VAR_6;",
"if (!s->divx_packed && !VAR_0->hwaccel)\nff_thread_finish_setup(VAR_0);",
"if (CONFIG_MPEG4_VDPAU_DECODER && (s->VAR_0->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {",
"ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);",
"goto frame_end;",
"}",
"if (VAR_0->hwaccel) {",
"if ((VAR_6 = VAR_0->hwaccel->start_frame(VAR_0, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)\nreturn VAR_6;",
"}",
"ff_mpeg_er_frame_start(s);",
"if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){",
"VAR_6 = ff_wmv2_decode_secondary_picture_header(s);",
"if(VAR_6<0) return VAR_6;",
"if(VAR_6==1) goto frame_end;",
"}",
"s->mb_x=0;",
"s->mb_y=0;",
"VAR_6 = decode_slice(s);",
"while(s->mb_y<s->mb_height){",
"if(s->msmpeg4_version){",
"if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)\nbreak;",
"}else{",
"int VAR_9=s->mb_x, VAR_10=s->mb_y;",
"if(ff_h263_resync(s)<0)\nbreak;",
"if (VAR_10 * s->mb_width + VAR_9 < s->mb_y * s->mb_width + s->mb_x)\ns->er.error_occurred = 1;",
"}",
"if(s->msmpeg4_version<4 && s->h263_pred)\nff_mpeg4_clean_buffers(s);",
"if (decode_slice(s) < 0) VAR_6 = AVERROR_INVALIDDATA;",
"}",
"if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)\nif(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, VAR_5) < 0){",
"s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;",
"}",
"av_assert1(s->bitstream_buffer_size==0);",
"frame_end:\nff_er_frame_end(&s->er);",
"if (VAR_0->hwaccel) {",
"if ((VAR_6 = VAR_0->hwaccel->end_frame(VAR_0)) < 0)\nreturn VAR_6;",
"}",
"ff_MPV_frame_end(s);",
"if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){",
"int VAR_11= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);",
"int VAR_12=0;",
"if(VAR_5 - VAR_11 > 7){",
"int VAR_13;",
"for(VAR_13=VAR_11; VAR_13<VAR_5-4; VAR_13++){",
"if(VAR_4[VAR_13]==0 && VAR_4[VAR_13+1]==0 && VAR_4[VAR_13+2]==1 && VAR_4[VAR_13+3]==0xB6){",
"VAR_12=!(VAR_4[VAR_13+4]&0x40);",
"break;",
"}",
"}",
"}",
"if(VAR_12){",
"av_fast_malloc(\n&s->bitstream_buffer,\n&s->allocated_bitstream_buffer_size,\nVAR_5 - VAR_11 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!s->bitstream_buffer)\nreturn AVERROR(ENOMEM);",
"memcpy(s->bitstream_buffer, VAR_4 + VAR_11, VAR_5 - VAR_11);",
"s->bitstream_buffer_size= VAR_5 - VAR_11;",
"}",
"}",
"if (!s->divx_packed && VAR_0->hwaccel)\nff_thread_finish_setup(VAR_0);",
"av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);",
"av_assert1(s->current_picture.f.pict_type == s->pict_type);",
"if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {",
"if ((VAR_6 = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)\nreturn VAR_6;",
"ff_print_debug_info(s, s->current_picture_ptr, pict);",
"ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);",
"} else if (s->last_picture_ptr != NULL) {",
"if ((VAR_6 = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)\nreturn VAR_6;",
"ff_print_debug_info(s, s->last_picture_ptr, pict);",
"ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);",
"}",
"if(s->last_picture_ptr || s->low_delay){",
"if ( pict->format == AV_PIX_FMT_YUV420P\n&& (s->codec_tag == AV_RL32(\"GEOV\") || s->codec_tag == AV_RL32(\"GEOX\"))) {",
"int VAR_13, VAR_14, VAR_15;",
"av_frame_make_writable(pict);",
"for (VAR_15=0; VAR_15<3; VAR_15++) {",
"int VAR_16 = FF_CEIL_RSHIFT(pict-> width, !!VAR_15);",
"int VAR_17 = FF_CEIL_RSHIFT(pict->height, !!VAR_15);",
"int VAR_18 = pict->VAR_18[VAR_15];",
"for (VAR_14=0; VAR_14<(VAR_17>>1); VAR_14++)",
"for (VAR_13=0; VAR_13<VAR_16; VAR_13++)",
"FFSWAP(int,\npict->VAR_1[VAR_15][VAR_13 + VAR_14*VAR_18],\npict->VAR_1[VAR_15][VAR_13 + (VAR_17-1-VAR_14)*VAR_18]);",
"}",
"}",
"*VAR_2 = 1;",
"}",
"return (VAR_6 && (VAR_0->err_recognition & AV_EF_EXPLODE))?VAR_6:get_consumed_bytes(s, VAR_5);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
239
],
[
241,
243,
245,
247,
249,
251
],
[
253,
255,
257,
259
],
[
261,
263
],
[
267
],
[
269,
271
],
[
273
],
[
277
],
[
279,
281
],
[
283
],
[
287
],
[
289,
291
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
315
],
[
319,
321
],
[
325,
327
],
[
331,
333
],
[
337,
339
],
[
343,
345
],
[
347
],
[
349
],
[
353,
355
],
[
359,
361
],
[
365
],
[
367
],
[
369
],
[
373,
375
],
[
379,
381
],
[
383,
385
],
[
389
],
[
391
],
[
393
],
[
397,
399
],
[
401,
403,
405
],
[
415,
417,
419
],
[
423,
425
],
[
427,
429
],
[
433
],
[
435,
437,
439,
441,
443,
445,
449,
451,
453,
455,
457,
459,
461
],
[
465,
467,
469,
471
],
[
475,
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487,
501,
503,
505
],
[
509
],
[
513
],
[
517,
519
],
[
521
],
[
525,
527
],
[
533
],
[
535
],
[
541,
543,
545
],
[
547,
549,
551,
553
],
[
557
],
[
559,
561
],
[
563,
565
],
[
567
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
587,
589
],
[
593,
595
],
[
599
],
[
601
],
[
603
],
[
605
],
[
609
],
[
611,
613
],
[
615
],
[
619
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
641
],
[
643
],
[
647
],
[
649
],
[
651
],
[
653,
655
],
[
657
],
[
659
],
[
661,
663
],
[
665,
667
],
[
669
],
[
673,
675
],
[
679
],
[
681
],
[
685,
687
],
[
689
],
[
691
],
[
695
],
[
697,
699
],
[
703
],
[
705,
707
],
[
709
],
[
713
],
[
723
],
[
725
],
[
727
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
747
],
[
751
],
[
753,
755,
757,
759
],
[
761,
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
775,
777
],
[
781
],
[
783
],
[
785
],
[
787,
789
],
[
791
],
[
793
],
[
795
],
[
797,
799
],
[
801
],
[
803
],
[
805
],
[
809
],
[
811,
813
],
[
815
],
[
817
],
[
819
],
[
821
],
[
823
],
[
825
],
[
827
],
[
829
],
[
831,
833,
835
],
[
837
],
[
839
],
[
841
],
[
843
],
[
847
],
[
849
]
] |
24,890 | void avcodec_free_context(AVCodecContext **pavctx)
{
AVCodecContext *avctx = *pavctx;
if (!avctx)
return;
avcodec_close(avctx);
av_freep(&avctx->extradata);
av_freep(&avctx->subtitle_header);
av_freep(pavctx);
} | true | FFmpeg | 345cfd04d093d9fdec81ea3531e73b1f5c1b6a6c | void avcodec_free_context(AVCodecContext **pavctx)
{
AVCodecContext *avctx = *pavctx;
if (!avctx)
return;
avcodec_close(avctx);
av_freep(&avctx->extradata);
av_freep(&avctx->subtitle_header);
av_freep(pavctx);
} | {
"code": [],
"line_no": []
} | void FUNC_0(AVCodecContext **VAR_0)
{
AVCodecContext *avctx = *VAR_0;
if (!avctx)
return;
avcodec_close(avctx);
av_freep(&avctx->extradata);
av_freep(&avctx->subtitle_header);
av_freep(VAR_0);
} | [
"void FUNC_0(AVCodecContext **VAR_0)\n{",
"AVCodecContext *avctx = *VAR_0;",
"if (!avctx)\nreturn;",
"avcodec_close(avctx);",
"av_freep(&avctx->extradata);",
"av_freep(&avctx->subtitle_header);",
"av_freep(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
19
],
[
21
],
[
28
],
[
30
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.