id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
listlengths
1
2.8k
label
listlengths
1
2.8k
line_no
listlengths
1
2.8k
11,575
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties) { int compno; if (s->buf_end - s->buf < 1) return AVERROR(EINVAL); compno = bytestream_get_byte(&s->buf); properties[compno] |= HAD_QCC; return get_qcx(s, n - 1, q + compno); }
false
FFmpeg
0b42631641d998e509cde6fa344edc6ab5cb4ac8
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties) { int compno; if (s->buf_end - s->buf < 1) return AVERROR(EINVAL); compno = bytestream_get_byte(&s->buf); properties[compno] |= HAD_QCC; return get_qcx(s, n - 1, q + compno); }
{ "code": [], "line_no": [] }
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1, Jpeg2000QuantStyle *VAR_2, uint8_t *VAR_3) { int VAR_4; if (VAR_0->buf_end - VAR_0->buf < 1) return AVERROR(EINVAL); VAR_4 = bytestream_get_byte(&VAR_0->buf); VAR_3[VAR_4] |= HAD_QCC; return get_qcx(VAR_0, VAR_1 - 1, VAR_2 + VAR_4); }
[ "static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1, Jpeg2000QuantStyle *VAR_2,\nuint8_t *VAR_3)\n{", "int VAR_4;", "if (VAR_0->buf_end - VAR_0->buf < 1)\nreturn AVERROR(EINVAL);", "VAR_4 = bytestream_get_byte(&VAR_0->buf);", "VAR_3[VAR_4] |= HAD_QCC;", "return get_qcx(VAR_0, VAR_1 - 1, VAR_2 + VAR_4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
11,576
static int mkv_write_tracks(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *dyn_cp, *pb = s->pb; ebml_master tracks; int i, ret, default_stream_exists = 0; ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (ret < 0) return ret; ret = start_ebml_master_crc32(pb, &dyn_cp, &tracks, MATROSKA_ID_TRACKS, 0); if (ret < 0) return ret; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT; } for (i = 0; i < s->nb_streams; i++) { ret = mkv_write_track(s, mkv, i, dyn_cp, default_stream_exists); if (ret < 0) return ret; } end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks); return 0; }
false
FFmpeg
eabbc64728c2fdb74f565aededec2ab023d20699
static int mkv_write_tracks(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *dyn_cp, *pb = s->pb; ebml_master tracks; int i, ret, default_stream_exists = 0; ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (ret < 0) return ret; ret = start_ebml_master_crc32(pb, &dyn_cp, &tracks, MATROSKA_ID_TRACKS, 0); if (ret < 0) return ret; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT; } for (i = 0; i < s->nb_streams; i++) { ret = mkv_write_track(s, mkv, i, dyn_cp, default_stream_exists); if (ret < 0) return ret; } end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { MatroskaMuxContext *mkv = VAR_0->priv_data; AVIOContext *dyn_cp, *pb = VAR_0->pb; ebml_master tracks; int VAR_1, VAR_2, VAR_3 = 0; VAR_2 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (VAR_2 < 0) return VAR_2; VAR_2 = start_ebml_master_crc32(pb, &dyn_cp, &tracks, MATROSKA_ID_TRACKS, 0); if (VAR_2 < 0) return VAR_2; for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) { AVStream *st = VAR_0->streams[VAR_1]; VAR_3 |= st->disposition & AV_DISPOSITION_DEFAULT; } for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) { VAR_2 = mkv_write_track(VAR_0, mkv, VAR_1, dyn_cp, VAR_3); if (VAR_2 < 0) return VAR_2; } end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "MatroskaMuxContext *mkv = VAR_0->priv_data;", "AVIOContext *dyn_cp, *pb = VAR_0->pb;", "ebml_master tracks;", "int VAR_1, VAR_2, VAR_3 = 0;", "VAR_2 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb));", "if (VAR_2 < 0)\nreturn VAR_2;", "VAR_2 = start_ebml_master_crc32(pb, &dyn_cp, &tracks, MATROSKA_ID_TRACKS, 0);", "if (VAR_2 < 0)\nreturn VAR_2;", "for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {", "AVStream *st = VAR_0->streams[VAR_1];", "VAR_3 |= st->disposition & AV_DISPOSITION_DEFAULT;", "}", "for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {", "VAR_2 = mkv_write_track(VAR_0, mkv, VAR_1, dyn_cp, VAR_3);", "if (VAR_2 < 0)\nreturn VAR_2;", "}", "end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
11,577
static void v9fs_stat(void *opaque) { int32_t fid; V9fsStat v9stat; ssize_t err = 0; size_t offset = 7; struct stat stbuf; V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "d", &fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } err = v9fs_co_lstat(pdu, &fidp->path, &stbuf); if (err < 0) { goto out; } err = stat_to_v9stat(pdu, &fidp->path, &stbuf, &v9stat); if (err < 0) { goto out; } offset += pdu_marshal(pdu, offset, "wS", 0, &v9stat); err = offset; v9fs_stat_free(&v9stat); out: put_fid(pdu, fidp); out_nofid: trace_v9fs_stat_return(pdu->tag, pdu->id, v9stat.mode, v9stat.atime, v9stat.mtime, v9stat.length); complete_pdu(s, pdu, err); }
true
qemu
c572f23a3e7180dbeab5e86583e43ea2afed6271
static void v9fs_stat(void *opaque) { int32_t fid; V9fsStat v9stat; ssize_t err = 0; size_t offset = 7; struct stat stbuf; V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "d", &fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } err = v9fs_co_lstat(pdu, &fidp->path, &stbuf); if (err < 0) { goto out; } err = stat_to_v9stat(pdu, &fidp->path, &stbuf, &v9stat); if (err < 0) { goto out; } offset += pdu_marshal(pdu, offset, "wS", 0, &v9stat); err = offset; v9fs_stat_free(&v9stat); out: put_fid(pdu, fidp); out_nofid: trace_v9fs_stat_return(pdu->tag, pdu->id, v9stat.mode, v9stat.atime, v9stat.mtime, v9stat.length); complete_pdu(s, pdu, err); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { int32_t fid; V9fsStat v9stat; ssize_t err = 0; size_t offset = 7; struct stat VAR_1; V9fsFidState *fidp; V9fsPDU *pdu = VAR_0; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "d", &fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } err = v9fs_co_lstat(pdu, &fidp->path, &VAR_1); if (err < 0) { goto out; } err = stat_to_v9stat(pdu, &fidp->path, &VAR_1, &v9stat); if (err < 0) { goto out; } offset += pdu_marshal(pdu, offset, "wS", 0, &v9stat); err = offset; v9fs_stat_free(&v9stat); out: put_fid(pdu, fidp); out_nofid: trace_v9fs_stat_return(pdu->tag, pdu->id, v9stat.mode, v9stat.atime, v9stat.mtime, v9stat.length); complete_pdu(s, pdu, err); }
[ "static void FUNC_0(void *VAR_0)\n{", "int32_t fid;", "V9fsStat v9stat;", "ssize_t err = 0;", "size_t offset = 7;", "struct stat VAR_1;", "V9fsFidState *fidp;", "V9fsPDU *pdu = VAR_0;", "V9fsState *s = pdu->s;", "pdu_unmarshal(pdu, offset, \"d\", &fid);", "fidp = get_fid(pdu, fid);", "if (fidp == NULL) {", "err = -ENOENT;", "goto out_nofid;", "}", "err = v9fs_co_lstat(pdu, &fidp->path, &VAR_1);", "if (err < 0) {", "goto out;", "}", "err = stat_to_v9stat(pdu, &fidp->path, &VAR_1, &v9stat);", "if (err < 0) {", "goto out;", "}", "offset += pdu_marshal(pdu, offset, \"wS\", 0, &v9stat);", "err = offset;", "v9fs_stat_free(&v9stat);", "out:\nput_fid(pdu, fidp);", "out_nofid:\ntrace_v9fs_stat_return(pdu->tag, pdu->id, v9stat.mode,\nv9stat.atime, v9stat.mtime, v9stat.length);", "complete_pdu(s, pdu, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 28 ], [ 30 ], [ 32 ], [ 34 ], [ 36 ], [ 38 ], [ 40 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 50 ], [ 52 ], [ 54 ], [ 56 ], [ 58 ], [ 60, 62 ], [ 64, 66, 68 ], [ 72 ], [ 74 ] ]
11,578
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){ int i, mb_x, mb_y; uint8_t* data[MAX_COMPONENTS]; int linesize[MAX_COMPONENTS]; for(i=0; i < nb_components; i++) { int c = s->comp_index[i]; data[c] = s->picture.data[c]; linesize[c]=s->linesize[c]; s->coefs_finished[c] |= 1; if(s->flipped) { //picture should be flipped upside-down for this codec assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); linesize[c] *= -1; } } for(mb_y = 0; mb_y < s->mb_height; mb_y++) { for(mb_x = 0; mb_x < s->mb_width; mb_x++) { if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; for(i=0;i<nb_components;i++) { uint8_t *ptr; int n, h, v, x, y, c, j; n = s->nb_blocks[i]; c = s->comp_index[i]; h = s->h_scount[i]; v = s->v_scount[i]; x = 0; y = 0; for(j=0;j<n;j++) { ptr = data[c] + (((linesize[c] * (v * mb_y + y) * 8) + (h * mb_x + x) * 8) >> s->avctx->lowres); if(s->interlaced && s->bottom_field) ptr += linesize[c] >> 1; if(!s->progressive) { s->dsp.clear_block(s->block); if(decode_block(s, s->block, i, s->dc_index[i], s->ac_index[i], s->quant_matrixes[ s->quant_index[c] ]) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } s->dsp.idct_put(ptr, linesize[c], s->block); } else { int block_idx = s->block_stride[c] * (v * mb_y + y) + (h * mb_x + x); DCTELEM *block = s->blocks[c][block_idx]; if(Ah) block[0] += get_bits1(&s->gb) * s->quant_matrixes[ s->quant_index[c] ][0] << Al; else if(decode_dc_progressive(s, block, i, s->dc_index[i], s->quant_matrixes[ s->quant_index[c] ], Al) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } } // av_log(s->avctx, AV_LOG_DEBUG, "mb: %d %d processed\n", mb_y, mb_x); //av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8); if (++x == h) { x = 0; y++; } } } if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); /* skip RSTn */ for (i=0; i<nb_components; i++) /* reset dc */ s->last_dc[i] = 1024; } } } return 0; }
true
FFmpeg
b711aaa2d8035b8a14bbdf0315cf2cea48dee890
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){ int i, mb_x, mb_y; uint8_t* data[MAX_COMPONENTS]; int linesize[MAX_COMPONENTS]; for(i=0; i < nb_components; i++) { int c = s->comp_index[i]; data[c] = s->picture.data[c]; linesize[c]=s->linesize[c]; s->coefs_finished[c] |= 1; if(s->flipped) { assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); linesize[c] *= -1; } } for(mb_y = 0; mb_y < s->mb_height; mb_y++) { for(mb_x = 0; mb_x < s->mb_width; mb_x++) { if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; for(i=0;i<nb_components;i++) { uint8_t *ptr; int n, h, v, x, y, c, j; n = s->nb_blocks[i]; c = s->comp_index[i]; h = s->h_scount[i]; v = s->v_scount[i]; x = 0; y = 0; for(j=0;j<n;j++) { ptr = data[c] + (((linesize[c] * (v * mb_y + y) * 8) + (h * mb_x + x) * 8) >> s->avctx->lowres); if(s->interlaced && s->bottom_field) ptr += linesize[c] >> 1; if(!s->progressive) { s->dsp.clear_block(s->block); if(decode_block(s, s->block, i, s->dc_index[i], s->ac_index[i], s->quant_matrixes[ s->quant_index[c] ]) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } s->dsp.idct_put(ptr, linesize[c], s->block); } else { int block_idx = s->block_stride[c] * (v * mb_y + y) + (h * mb_x + x); DCTELEM *block = s->blocks[c][block_idx]; if(Ah) block[0] += get_bits1(&s->gb) * s->quant_matrixes[ s->quant_index[c] ][0] << Al; else if(decode_dc_progressive(s, block, i, s->dc_index[i], s->quant_matrixes[ s->quant_index[c] ], Al) < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return -1; } } if (++x == h) { x = 0; y++; } } } if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); for (i=0; i<nb_components; i++) s->last_dc[i] = 1024; } } } return 0; }
{ "code": [ " assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE));" ], "line_no": [ 25 ] }
static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){ int VAR_4, VAR_5, VAR_6; uint8_t* data[MAX_COMPONENTS]; int VAR_7[MAX_COMPONENTS]; for(VAR_4=0; VAR_4 < VAR_1; VAR_4++) { int VAR_8 = VAR_0->comp_index[VAR_4]; data[VAR_8] = VAR_0->picture.data[VAR_8]; VAR_7[VAR_8]=VAR_0->VAR_7[VAR_8]; VAR_0->coefs_finished[VAR_8] |= 1; if(VAR_0->flipped) { assert(!(VAR_0->avctx->flags & CODEC_FLAG_EMU_EDGE)); data[VAR_8] += (VAR_7[VAR_8] * (VAR_0->v_scount[VAR_4] * (8 * VAR_0->mb_height -((VAR_0->height/VAR_0->v_max)&7)) - 1 )); VAR_7[VAR_8] *= -1; } } for(VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) { for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) { if (VAR_0->restart_interval && !VAR_0->restart_count) VAR_0->restart_count = VAR_0->restart_interval; for(VAR_4=0;VAR_4<VAR_1;VAR_4++) { uint8_t *ptr; int n, h, v, x, y, VAR_8, j; n = VAR_0->nb_blocks[VAR_4]; VAR_8 = VAR_0->comp_index[VAR_4]; h = VAR_0->h_scount[VAR_4]; v = VAR_0->v_scount[VAR_4]; x = 0; y = 0; for(j=0;j<n;j++) { ptr = data[VAR_8] + (((VAR_7[VAR_8] * (v * VAR_6 + y) * 8) + (h * VAR_5 + x) * 8) >> VAR_0->avctx->lowres); if(VAR_0->interlaced && VAR_0->bottom_field) ptr += VAR_7[VAR_8] >> 1; if(!VAR_0->progressive) { VAR_0->dsp.clear_block(VAR_0->block); if(decode_block(VAR_0, VAR_0->block, VAR_4, VAR_0->dc_index[VAR_4], VAR_0->ac_index[VAR_4], VAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ]) < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", VAR_6, VAR_5); return -1; } VAR_0->dsp.idct_put(ptr, VAR_7[VAR_8], VAR_0->block); } else { int block_idx = VAR_0->block_stride[VAR_8] * (v * VAR_6 + y) + (h * VAR_5 + x); DCTELEM *block = VAR_0->blocks[VAR_8][block_idx]; if(VAR_2) block[0] += get_bits1(&VAR_0->gb) * VAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ][0] << VAR_3; else if(decode_dc_progressive(VAR_0, block, VAR_4, VAR_0->dc_index[VAR_4], VAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ], VAR_3) < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", VAR_6, VAR_5); return -1; } } if (++x == h) { x = 0; y++; } } } if (VAR_0->restart_interval && !--VAR_0->restart_count) { align_get_bits(&VAR_0->gb); skip_bits(&VAR_0->gb, 16); for (VAR_4=0; VAR_4<VAR_1; VAR_4++) VAR_0->last_dc[VAR_4] = 1024; } } } return 0; }
[ "static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){", "int VAR_4, VAR_5, VAR_6;", "uint8_t* data[MAX_COMPONENTS];", "int VAR_7[MAX_COMPONENTS];", "for(VAR_4=0; VAR_4 < VAR_1; VAR_4++) {", "int VAR_8 = VAR_0->comp_index[VAR_4];", "data[VAR_8] = VAR_0->picture.data[VAR_8];", "VAR_7[VAR_8]=VAR_0->VAR_7[VAR_8];", "VAR_0->coefs_finished[VAR_8] |= 1;", "if(VAR_0->flipped) {", "assert(!(VAR_0->avctx->flags & CODEC_FLAG_EMU_EDGE));", "data[VAR_8] += (VAR_7[VAR_8] * (VAR_0->v_scount[VAR_4] * (8 * VAR_0->mb_height -((VAR_0->height/VAR_0->v_max)&7)) - 1 ));", "VAR_7[VAR_8] *= -1;", "}", "}", "for(VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) {", "for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {", "if (VAR_0->restart_interval && !VAR_0->restart_count)\nVAR_0->restart_count = VAR_0->restart_interval;", "for(VAR_4=0;VAR_4<VAR_1;VAR_4++) {", "uint8_t *ptr;", "int n, h, v, x, y, VAR_8, j;", "n = VAR_0->nb_blocks[VAR_4];", "VAR_8 = VAR_0->comp_index[VAR_4];", "h = VAR_0->h_scount[VAR_4];", "v = VAR_0->v_scount[VAR_4];", "x = 0;", "y = 0;", "for(j=0;j<n;j++) {", "ptr = data[VAR_8] +\n(((VAR_7[VAR_8] * (v * VAR_6 + y) * 8) +\n(h * VAR_5 + x) * 8) >> VAR_0->avctx->lowres);", "if(VAR_0->interlaced && VAR_0->bottom_field)\nptr += VAR_7[VAR_8] >> 1;", "if(!VAR_0->progressive) {", "VAR_0->dsp.clear_block(VAR_0->block);", "if(decode_block(VAR_0, VAR_0->block, VAR_4,\nVAR_0->dc_index[VAR_4], VAR_0->ac_index[VAR_4],\nVAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ]) < 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"error y=%d x=%d\\n\", VAR_6, VAR_5);", "return -1;", "}", "VAR_0->dsp.idct_put(ptr, VAR_7[VAR_8], VAR_0->block);", "} else {", "int block_idx = VAR_0->block_stride[VAR_8] * (v * VAR_6 + y) + (h * VAR_5 + x);", "DCTELEM *block = VAR_0->blocks[VAR_8][block_idx];", "if(VAR_2)\nblock[0] += get_bits1(&VAR_0->gb) * VAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ][0] << VAR_3;", "else if(decode_dc_progressive(VAR_0, block, VAR_4, VAR_0->dc_index[VAR_4], VAR_0->quant_matrixes[ VAR_0->quant_index[VAR_8] ], VAR_3) < 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"error y=%d x=%d\\n\", VAR_6, VAR_5);", "return -1;", "}", "}", "if (++x == h) {", "x = 0;", "y++;", "}", "}", "}", "if (VAR_0->restart_interval && !--VAR_0->restart_count) {", "align_get_bits(&VAR_0->gb);", "skip_bits(&VAR_0->gb, 16);", "for (VAR_4=0; VAR_4<VAR_1; VAR_4++)", "VAR_0->last_dc[VAR_4] = 1024;", "}", "}", "}", "return 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 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 69, 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81, 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ] ]
11,579
static double eval_expr(Parser *p, AVExpr *e) { switch (e->type) { case e_value: return e->value; case e_const: return e->value * p->const_values[e->a.const_index]; case e_func0: return e->value * e->a.func0(eval_expr(p, e->param[0])); case e_func1: return e->value * e->a.func1(p->opaque, eval_expr(p, e->param[0])); case e_func2: return e->value * e->a.func2(p->opaque, eval_expr(p, e->param[0]), eval_expr(p, e->param[1])); case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0]))); case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); } case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)]; case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0])); case e_floor: return e->value * floor(eval_expr(p, e->param[0])); case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); case e_if: return e->value * ( eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_random:{ int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; r= r*1664525+1013904223; p->var[idx]= r; return e->value * (r * (1.0/UINT64_MAX)); } case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) d=eval_expr(p, e->param[1]); return d; } case e_taylor: { double t = 1, d = 0, v; double x = eval_expr(p, e->param[1]); int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, VARS-1) : 0; int i; double var0 = p->var[id]; for(i=0; i<1000; i++) { double ld = d; p->var[id] = i; v = eval_expr(p, e->param[0]); d += t*v; if(ld==d && v) break; t *= x / (i+1); } p->var[id] = var0; return d; } case e_root: { int i; double low = -1, high = -1, v, low_v = -DBL_MAX, high_v = DBL_MAX; double var0 = p->var[0]; double x_max = eval_expr(p, e->param[1]); for(i=-1; i<1024; i++) { if(i<255) { p->var[0] = av_reverse[i&255]*x_max/255; } else { p->var[0] = x_max*pow(0.9, i-255); if (i&1) p->var[0] *= -1; if (i&2) p->var[0] += low; else p->var[0] += high; } v = eval_expr(p, e->param[0]); if (v<=0 && v>low_v) { low = p->var[0]; low_v = v; } if (v>=0 && v<high_v) { high = p->var[0]; high_v = v; } if (low>=0 && high>=0){ while (1) { p->var[0] = (low+high)*0.5; if (low == p->var[0] || high == p->var[0]) break; v = eval_expr(p, e->param[0]); if (v<=0) low = p->var[0]; if (v>=0) high= p->var[0]; if (isnan(v)) { low = high = v; break; } } break; } } p->var[0] = var0; return -low_v<high_v ? low : high; } default: { double d = eval_expr(p, e->param[0]); double d2 = eval_expr(p, e->param[1]); switch (e->type) { case e_mod: return e->value * (d - floor(d/d2)*d2); case e_gcd: return e->value * av_gcd(d,d2); case e_max: return e->value * (d > d2 ? d : d2); case e_min: return e->value * (d < d2 ? d : d2); case e_eq: return e->value * (d == d2 ? 1.0 : 0.0); case e_gt: return e->value * (d > d2 ? 1.0 : 0.0); case e_gte: return e->value * (d >= d2 ? 1.0 : 0.0); case e_pow: return e->value * pow(d, d2); case e_mul: return e->value * (d * d2); case e_div: return e->value * (d / d2); case e_add: return e->value * (d + d2); case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); case e_hypot:return e->value * (sqrt(d*d + d2*d2)); } } } return NAN; }
false
FFmpeg
d2101bffa0f2221586e3e7eacfecf47d5c29f2c4
static double eval_expr(Parser *p, AVExpr *e) { switch (e->type) { case e_value: return e->value; case e_const: return e->value * p->const_values[e->a.const_index]; case e_func0: return e->value * e->a.func0(eval_expr(p, e->param[0])); case e_func1: return e->value * e->a.func1(p->opaque, eval_expr(p, e->param[0])); case e_func2: return e->value * e->a.func2(p->opaque, eval_expr(p, e->param[0]), eval_expr(p, e->param[1])); case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0]))); case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); } case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)]; case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0])); case e_floor: return e->value * floor(eval_expr(p, e->param[0])); case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); case e_if: return e->value * ( eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_random:{ int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; r= r*1664525+1013904223; p->var[idx]= r; return e->value * (r * (1.0/UINT64_MAX)); } case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) d=eval_expr(p, e->param[1]); return d; } case e_taylor: { double t = 1, d = 0, v; double x = eval_expr(p, e->param[1]); int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, VARS-1) : 0; int i; double var0 = p->var[id]; for(i=0; i<1000; i++) { double ld = d; p->var[id] = i; v = eval_expr(p, e->param[0]); d += t*v; if(ld==d && v) break; t *= x / (i+1); } p->var[id] = var0; return d; } case e_root: { int i; double low = -1, high = -1, v, low_v = -DBL_MAX, high_v = DBL_MAX; double var0 = p->var[0]; double x_max = eval_expr(p, e->param[1]); for(i=-1; i<1024; i++) { if(i<255) { p->var[0] = av_reverse[i&255]*x_max/255; } else { p->var[0] = x_max*pow(0.9, i-255); if (i&1) p->var[0] *= -1; if (i&2) p->var[0] += low; else p->var[0] += high; } v = eval_expr(p, e->param[0]); if (v<=0 && v>low_v) { low = p->var[0]; low_v = v; } if (v>=0 && v<high_v) { high = p->var[0]; high_v = v; } if (low>=0 && high>=0){ while (1) { p->var[0] = (low+high)*0.5; if (low == p->var[0] || high == p->var[0]) break; v = eval_expr(p, e->param[0]); if (v<=0) low = p->var[0]; if (v>=0) high= p->var[0]; if (isnan(v)) { low = high = v; break; } } break; } } p->var[0] = var0; return -low_v<high_v ? low : high; } default: { double d = eval_expr(p, e->param[0]); double d2 = eval_expr(p, e->param[1]); switch (e->type) { case e_mod: return e->value * (d - floor(d/d2)*d2); case e_gcd: return e->value * av_gcd(d,d2); case e_max: return e->value * (d > d2 ? d : d2); case e_min: return e->value * (d < d2 ? d : d2); case e_eq: return e->value * (d == d2 ? 1.0 : 0.0); case e_gt: return e->value * (d > d2 ? 1.0 : 0.0); case e_gte: return e->value * (d >= d2 ? 1.0 : 0.0); case e_pow: return e->value * pow(d, d2); case e_mul: return e->value * (d * d2); case e_div: return e->value * (d / d2); case e_add: return e->value * (d + d2); case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); case e_hypot:return e->value * (sqrt(d*d + d2*d2)); } } } return NAN; }
{ "code": [], "line_no": [] }
static double FUNC_0(Parser *VAR_0, AVExpr *VAR_1) { switch (VAR_1->type) { case e_value: return VAR_1->value; case e_const: return VAR_1->value * VAR_0->const_values[VAR_1->a.const_index]; case e_func0: return VAR_1->value * VAR_1->a.func0(FUNC_0(VAR_0, VAR_1->param[0])); case e_func1: return VAR_1->value * VAR_1->a.func1(VAR_0->opaque, FUNC_0(VAR_0, VAR_1->param[0])); case e_func2: return VAR_1->value * VAR_1->a.func2(VAR_0->opaque, FUNC_0(VAR_0, VAR_1->param[0]), FUNC_0(VAR_0, VAR_1->param[1])); case e_squish: return 1/(1+exp(4*FUNC_0(VAR_0, VAR_1->param[0]))); case e_gauss: { double VAR_16 = FUNC_0(VAR_0, VAR_1->param[0]); return exp(-VAR_16*VAR_16/2)/sqrt(2*M_PI); } case e_ld: return VAR_1->value * VAR_0->var[av_clip(FUNC_0(VAR_0, VAR_1->param[0]), 0, VARS-1)]; case e_isnan: return VAR_1->value * !!isnan(FUNC_0(VAR_0, VAR_1->param[0])); case e_floor: return VAR_1->value * floor(FUNC_0(VAR_0, VAR_1->param[0])); case e_ceil : return VAR_1->value * ceil (FUNC_0(VAR_0, VAR_1->param[0])); case e_trunc: return VAR_1->value * trunc(FUNC_0(VAR_0, VAR_1->param[0])); case e_sqrt: return VAR_1->value * sqrt (FUNC_0(VAR_0, VAR_1->param[0])); case e_not: return VAR_1->value * (FUNC_0(VAR_0, VAR_1->param[0]) == 0); case e_if: return VAR_1->value * ( FUNC_0(VAR_0, VAR_1->param[0]) ? FUNC_0(VAR_0, VAR_1->param[1]) : 0); case e_ifnot: return VAR_1->value * (!FUNC_0(VAR_0, VAR_1->param[0]) ? FUNC_0(VAR_0, VAR_1->param[1]) : 0); case e_random:{ int VAR_3= av_clip(FUNC_0(VAR_0, VAR_1->param[0]), 0, VARS-1); uint64_t r= isnan(VAR_0->var[VAR_3]) ? 0 : VAR_0->var[VAR_3]; r= r*1664525+1013904223; VAR_0->var[VAR_3]= r; return VAR_1->value * (r * (1.0/UINT64_MAX)); } case e_while: { double VAR_16 = NAN; while (FUNC_0(VAR_0, VAR_1->param[0])) VAR_16=FUNC_0(VAR_0, VAR_1->param[1]); return VAR_16; } case e_taylor: { double VAR_4 = 1, VAR_16 = 0, VAR_13; double VAR_6 = FUNC_0(VAR_0, VAR_1->param[1]); int VAR_7 = VAR_1->param[2] ? av_clip(FUNC_0(VAR_0, VAR_1->param[2]), 0, VARS-1) : 0; int VAR_11; double VAR_15 = VAR_0->var[VAR_7]; for(VAR_11=0; VAR_11<1000; VAR_11++) { double VAR_10 = VAR_16; VAR_0->var[VAR_7] = VAR_11; VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]); VAR_16 += VAR_4*VAR_13; if(VAR_10==VAR_16 && VAR_13) break; VAR_4 *= VAR_6 / (VAR_11+1); } VAR_0->var[VAR_7] = VAR_15; return VAR_16; } case e_root: { int VAR_11; double VAR_11 = -1, VAR_12 = -1, VAR_13, VAR_13 = -DBL_MAX, VAR_14 = DBL_MAX; double VAR_15 = VAR_0->var[0]; double VAR_15 = FUNC_0(VAR_0, VAR_1->param[1]); for(VAR_11=-1; VAR_11<1024; VAR_11++) { if(VAR_11<255) { VAR_0->var[0] = av_reverse[VAR_11&255]*VAR_15/255; } else { VAR_0->var[0] = VAR_15*pow(0.9, VAR_11-255); if (VAR_11&1) VAR_0->var[0] *= -1; if (VAR_11&2) VAR_0->var[0] += VAR_11; else VAR_0->var[0] += VAR_12; } VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]); if (VAR_13<=0 && VAR_13>VAR_13) { VAR_11 = VAR_0->var[0]; VAR_13 = VAR_13; } if (VAR_13>=0 && VAR_13<VAR_14) { VAR_12 = VAR_0->var[0]; VAR_14 = VAR_13; } if (VAR_11>=0 && VAR_12>=0){ while (1) { VAR_0->var[0] = (VAR_11+VAR_12)*0.5; if (VAR_11 == VAR_0->var[0] || VAR_12 == VAR_0->var[0]) break; VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]); if (VAR_13<=0) VAR_11 = VAR_0->var[0]; if (VAR_13>=0) VAR_12= VAR_0->var[0]; if (isnan(VAR_13)) { VAR_11 = VAR_12 = VAR_13; break; } } break; } } VAR_0->var[0] = VAR_15; return -VAR_13<VAR_14 ? VAR_11 : VAR_12; } default: { double VAR_16 = FUNC_0(VAR_0, VAR_1->param[0]); double VAR_16 = FUNC_0(VAR_0, VAR_1->param[1]); switch (VAR_1->type) { case e_mod: return VAR_1->value * (VAR_16 - floor(VAR_16/VAR_16)*VAR_16); case e_gcd: return VAR_1->value * av_gcd(VAR_16,VAR_16); case e_max: return VAR_1->value * (VAR_16 > VAR_16 ? VAR_16 : VAR_16); case e_min: return VAR_1->value * (VAR_16 < VAR_16 ? VAR_16 : VAR_16); case e_eq: return VAR_1->value * (VAR_16 == VAR_16 ? 1.0 : 0.0); case e_gt: return VAR_1->value * (VAR_16 > VAR_16 ? 1.0 : 0.0); case e_gte: return VAR_1->value * (VAR_16 >= VAR_16 ? 1.0 : 0.0); case e_pow: return VAR_1->value * pow(VAR_16, VAR_16); case e_mul: return VAR_1->value * (VAR_16 * VAR_16); case e_div: return VAR_1->value * (VAR_16 / VAR_16); case e_add: return VAR_1->value * (VAR_16 + VAR_16); case e_last:return VAR_1->value * VAR_16; case e_st : return VAR_1->value * (VAR_0->var[av_clip(VAR_16, 0, VARS-1)]= VAR_16); case e_hypot:return VAR_1->value * (sqrt(VAR_16*VAR_16 + VAR_16*VAR_16)); } } } return NAN; }
[ "static double FUNC_0(Parser *VAR_0, AVExpr *VAR_1)\n{", "switch (VAR_1->type) {", "case e_value: return VAR_1->value;", "case e_const: return VAR_1->value * VAR_0->const_values[VAR_1->a.const_index];", "case e_func0: return VAR_1->value * VAR_1->a.func0(FUNC_0(VAR_0, VAR_1->param[0]));", "case e_func1: return VAR_1->value * VAR_1->a.func1(VAR_0->opaque, FUNC_0(VAR_0, VAR_1->param[0]));", "case e_func2: return VAR_1->value * VAR_1->a.func2(VAR_0->opaque, FUNC_0(VAR_0, VAR_1->param[0]), FUNC_0(VAR_0, VAR_1->param[1]));", "case e_squish: return 1/(1+exp(4*FUNC_0(VAR_0, VAR_1->param[0])));", "case e_gauss: { double VAR_16 = FUNC_0(VAR_0, VAR_1->param[0]); return exp(-VAR_16*VAR_16/2)/sqrt(2*M_PI); }", "case e_ld: return VAR_1->value * VAR_0->var[av_clip(FUNC_0(VAR_0, VAR_1->param[0]), 0, VARS-1)];", "case e_isnan: return VAR_1->value * !!isnan(FUNC_0(VAR_0, VAR_1->param[0]));", "case e_floor: return VAR_1->value * floor(FUNC_0(VAR_0, VAR_1->param[0]));", "case e_ceil : return VAR_1->value * ceil (FUNC_0(VAR_0, VAR_1->param[0]));", "case e_trunc: return VAR_1->value * trunc(FUNC_0(VAR_0, VAR_1->param[0]));", "case e_sqrt: return VAR_1->value * sqrt (FUNC_0(VAR_0, VAR_1->param[0]));", "case e_not: return VAR_1->value * (FUNC_0(VAR_0, VAR_1->param[0]) == 0);", "case e_if: return VAR_1->value * ( FUNC_0(VAR_0, VAR_1->param[0]) ? FUNC_0(VAR_0, VAR_1->param[1]) : 0);", "case e_ifnot: return VAR_1->value * (!FUNC_0(VAR_0, VAR_1->param[0]) ? FUNC_0(VAR_0, VAR_1->param[1]) : 0);", "case e_random:{", "int VAR_3= av_clip(FUNC_0(VAR_0, VAR_1->param[0]), 0, VARS-1);", "uint64_t r= isnan(VAR_0->var[VAR_3]) ? 0 : VAR_0->var[VAR_3];", "r= r*1664525+1013904223;", "VAR_0->var[VAR_3]= r;", "return VAR_1->value * (r * (1.0/UINT64_MAX));", "}", "case e_while: {", "double VAR_16 = NAN;", "while (FUNC_0(VAR_0, VAR_1->param[0]))\nVAR_16=FUNC_0(VAR_0, VAR_1->param[1]);", "return VAR_16;", "}", "case e_taylor: {", "double VAR_4 = 1, VAR_16 = 0, VAR_13;", "double VAR_6 = FUNC_0(VAR_0, VAR_1->param[1]);", "int VAR_7 = VAR_1->param[2] ? av_clip(FUNC_0(VAR_0, VAR_1->param[2]), 0, VARS-1) : 0;", "int VAR_11;", "double VAR_15 = VAR_0->var[VAR_7];", "for(VAR_11=0; VAR_11<1000; VAR_11++) {", "double VAR_10 = VAR_16;", "VAR_0->var[VAR_7] = VAR_11;", "VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]);", "VAR_16 += VAR_4*VAR_13;", "if(VAR_10==VAR_16 && VAR_13)\nbreak;", "VAR_4 *= VAR_6 / (VAR_11+1);", "}", "VAR_0->var[VAR_7] = VAR_15;", "return VAR_16;", "}", "case e_root: {", "int VAR_11;", "double VAR_11 = -1, VAR_12 = -1, VAR_13, VAR_13 = -DBL_MAX, VAR_14 = DBL_MAX;", "double VAR_15 = VAR_0->var[0];", "double VAR_15 = FUNC_0(VAR_0, VAR_1->param[1]);", "for(VAR_11=-1; VAR_11<1024; VAR_11++) {", "if(VAR_11<255) {", "VAR_0->var[0] = av_reverse[VAR_11&255]*VAR_15/255;", "} else {", "VAR_0->var[0] = VAR_15*pow(0.9, VAR_11-255);", "if (VAR_11&1) VAR_0->var[0] *= -1;", "if (VAR_11&2) VAR_0->var[0] += VAR_11;", "else VAR_0->var[0] += VAR_12;", "}", "VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]);", "if (VAR_13<=0 && VAR_13>VAR_13) {", "VAR_11 = VAR_0->var[0];", "VAR_13 = VAR_13;", "}", "if (VAR_13>=0 && VAR_13<VAR_14) {", "VAR_12 = VAR_0->var[0];", "VAR_14 = VAR_13;", "}", "if (VAR_11>=0 && VAR_12>=0){", "while (1) {", "VAR_0->var[0] = (VAR_11+VAR_12)*0.5;", "if (VAR_11 == VAR_0->var[0] || VAR_12 == VAR_0->var[0])\nbreak;", "VAR_13 = FUNC_0(VAR_0, VAR_1->param[0]);", "if (VAR_13<=0) VAR_11 = VAR_0->var[0];", "if (VAR_13>=0) VAR_12= VAR_0->var[0];", "if (isnan(VAR_13)) {", "VAR_11 = VAR_12 = VAR_13;", "break;", "}", "}", "break;", "}", "}", "VAR_0->var[0] = VAR_15;", "return -VAR_13<VAR_14 ? VAR_11 : VAR_12;", "}", "default: {", "double VAR_16 = FUNC_0(VAR_0, VAR_1->param[0]);", "double VAR_16 = FUNC_0(VAR_0, VAR_1->param[1]);", "switch (VAR_1->type) {", "case e_mod: return VAR_1->value * (VAR_16 - floor(VAR_16/VAR_16)*VAR_16);", "case e_gcd: return VAR_1->value * av_gcd(VAR_16,VAR_16);", "case e_max: return VAR_1->value * (VAR_16 > VAR_16 ? VAR_16 : VAR_16);", "case e_min: return VAR_1->value * (VAR_16 < VAR_16 ? VAR_16 : VAR_16);", "case e_eq: return VAR_1->value * (VAR_16 == VAR_16 ? 1.0 : 0.0);", "case e_gt: return VAR_1->value * (VAR_16 > VAR_16 ? 1.0 : 0.0);", "case e_gte: return VAR_1->value * (VAR_16 >= VAR_16 ? 1.0 : 0.0);", "case e_pow: return VAR_1->value * pow(VAR_16, VAR_16);", "case e_mul: return VAR_1->value * (VAR_16 * VAR_16);", "case e_div: return VAR_1->value * (VAR_16 / VAR_16);", "case e_add: return VAR_1->value * (VAR_16 + VAR_16);", "case e_last:return VAR_1->value * VAR_16;", "case e_st : return VAR_1->value * (VAR_0->var[av_clip(VAR_16, 0, VARS-1)]= VAR_16);", "case e_hypot:return VAR_1->value * (sqrt(VAR_16*VAR_16 + VAR_16*VAR_16));", "}", "}", "}", "return NAN;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ] ]
11,580
static int deband_16_coupling_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { DebandContext *s = ctx->priv; ThreadData *td = arg; AVFrame *in = td->in; AVFrame *out = td->out; const int start = (s->planeheight[0] * jobnr ) / nb_jobs; const int end = (s->planeheight[0] * (jobnr+1)) / nb_jobs; int x, y, p, z; for (y = start; y < end; y++) { const int pos = y * s->planewidth[0]; for (x = 0; x < s->planewidth[p]; x++) { const int x_pos = s->x_pos[pos + x]; const int y_pos = s->y_pos[pos + x]; int avg[4], cmp[4] = { 0 }, src[4]; for (p = 0; p < s->nb_components; p++) { const uint16_t *src_ptr = (const uint16_t *)in->data[p]; const int src_linesize = in->linesize[p] / 2; const int thr = s->thr[p]; const int w = s->planewidth[p] - 1; const int h = s->planeheight[p] - 1; const int ref0 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int ref3 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int src0 = src_ptr[y * src_linesize + x]; src[p] = src0; avg[p] = get_avg(ref0, ref1, ref2, ref3); if (s->blur) { cmp[p] = FFABS(src0 - avg[p]) < thr; } else { cmp[p] = (FFABS(src0 - ref0) < thr) && (FFABS(src0 - ref1) < thr) && (FFABS(src0 - ref2) < thr) && (FFABS(src0 - ref3) < thr); } } for (z = 0; z < s->nb_components; z++) if (!cmp[z]) break; if (z == s->nb_components) { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = avg[p]; } } else { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = src[p]; } } } } return 0; }
true
FFmpeg
9b26bf7e2a3904d0e4b80f8d771223d3045013db
static int deband_16_coupling_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { DebandContext *s = ctx->priv; ThreadData *td = arg; AVFrame *in = td->in; AVFrame *out = td->out; const int start = (s->planeheight[0] * jobnr ) / nb_jobs; const int end = (s->planeheight[0] * (jobnr+1)) / nb_jobs; int x, y, p, z; for (y = start; y < end; y++) { const int pos = y * s->planewidth[0]; for (x = 0; x < s->planewidth[p]; x++) { const int x_pos = s->x_pos[pos + x]; const int y_pos = s->y_pos[pos + x]; int avg[4], cmp[4] = { 0 }, src[4]; for (p = 0; p < s->nb_components; p++) { const uint16_t *src_ptr = (const uint16_t *)in->data[p]; const int src_linesize = in->linesize[p] / 2; const int thr = s->thr[p]; const int w = s->planewidth[p] - 1; const int h = s->planeheight[p] - 1; const int ref0 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int ref3 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; const int src0 = src_ptr[y * src_linesize + x]; src[p] = src0; avg[p] = get_avg(ref0, ref1, ref2, ref3); if (s->blur) { cmp[p] = FFABS(src0 - avg[p]) < thr; } else { cmp[p] = (FFABS(src0 - ref0) < thr) && (FFABS(src0 - ref1) < thr) && (FFABS(src0 - ref2) < thr) && (FFABS(src0 - ref3) < thr); } } for (z = 0; z < s->nb_components; z++) if (!cmp[z]) break; if (z == s->nb_components) { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = avg[p]; } } else { for (p = 0; p < s->nb_components; p++) { const int dst_linesize = out->linesize[p] / 2; uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x; dst[0] = src[p]; } } } } return 0; }
{ "code": [ " for (x = 0; x < s->planewidth[p]; x++) {", " for (x = 0; x < s->planewidth[p]; x++) {" ], "line_no": [ 27, 27 ] }
static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3) { DebandContext *s = VAR_0->priv; ThreadData *td = VAR_1; AVFrame *in = td->in; AVFrame *out = td->out; const int VAR_4 = (s->planeheight[0] * VAR_2 ) / VAR_3; const int VAR_5 = (s->planeheight[0] * (VAR_2+1)) / VAR_3; int VAR_6, VAR_7, VAR_8, VAR_9; for (VAR_7 = VAR_4; VAR_7 < VAR_5; VAR_7++) { const int VAR_10 = VAR_7 * s->planewidth[0]; for (VAR_6 = 0; VAR_6 < s->planewidth[VAR_8]; VAR_6++) { const int x_pos = s->x_pos[VAR_10 + VAR_6]; const int y_pos = s->y_pos[VAR_10 + VAR_6]; int avg[4], cmp[4] = { 0 }, src[4]; for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const uint16_t *src_ptr = (const uint16_t *)in->data[VAR_8]; const int src_linesize = in->linesize[VAR_8] / 2; const int thr = s->thr[VAR_8]; const int w = s->planewidth[VAR_8] - 1; const int h = s->planeheight[VAR_8] - 1; const int ref0 = src_ptr[av_clip(VAR_7 + y_pos, 0, h) * src_linesize + av_clip(VAR_6 + x_pos, 0, w)]; const int ref1 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + x_pos, 0, w)]; const int ref2 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)]; const int ref3 = src_ptr[av_clip(VAR_7 + y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)]; const int src0 = src_ptr[VAR_7 * src_linesize + VAR_6]; src[VAR_8] = src0; avg[VAR_8] = get_avg(ref0, ref1, ref2, ref3); if (s->blur) { cmp[VAR_8] = FFABS(src0 - avg[VAR_8]) < thr; } else { cmp[VAR_8] = (FFABS(src0 - ref0) < thr) && (FFABS(src0 - ref1) < thr) && (FFABS(src0 - ref2) < thr) && (FFABS(src0 - ref3) < thr); } } for (VAR_9 = 0; VAR_9 < s->nb_components; VAR_9++) if (!cmp[VAR_9]) break; if (VAR_9 == s->nb_components) { for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const int dst_linesize = out->linesize[VAR_8] / 2; uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6; dst[0] = avg[VAR_8]; } } else { for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const int dst_linesize = out->linesize[VAR_8] / 2; uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6; dst[0] = src[VAR_8]; } } } } return 0; }
[ "static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)\n{", "DebandContext *s = VAR_0->priv;", "ThreadData *td = VAR_1;", "AVFrame *in = td->in;", "AVFrame *out = td->out;", "const int VAR_4 = (s->planeheight[0] * VAR_2 ) / VAR_3;", "const int VAR_5 = (s->planeheight[0] * (VAR_2+1)) / VAR_3;", "int VAR_6, VAR_7, VAR_8, VAR_9;", "for (VAR_7 = VAR_4; VAR_7 < VAR_5; VAR_7++) {", "const int VAR_10 = VAR_7 * s->planewidth[0];", "for (VAR_6 = 0; VAR_6 < s->planewidth[VAR_8]; VAR_6++) {", "const int x_pos = s->x_pos[VAR_10 + VAR_6];", "const int y_pos = s->y_pos[VAR_10 + VAR_6];", "int avg[4], cmp[4] = { 0 }, src[4];", "for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {", "const uint16_t *src_ptr = (const uint16_t *)in->data[VAR_8];", "const int src_linesize = in->linesize[VAR_8] / 2;", "const int thr = s->thr[VAR_8];", "const int w = s->planewidth[VAR_8] - 1;", "const int h = s->planeheight[VAR_8] - 1;", "const int ref0 = src_ptr[av_clip(VAR_7 + y_pos, 0, h) * src_linesize + av_clip(VAR_6 + x_pos, 0, w)];", "const int ref1 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + x_pos, 0, w)];", "const int ref2 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)];", "const int ref3 = src_ptr[av_clip(VAR_7 + y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)];", "const int src0 = src_ptr[VAR_7 * src_linesize + VAR_6];", "src[VAR_8] = src0;", "avg[VAR_8] = get_avg(ref0, ref1, ref2, ref3);", "if (s->blur) {", "cmp[VAR_8] = FFABS(src0 - avg[VAR_8]) < thr;", "} else {", "cmp[VAR_8] = (FFABS(src0 - ref0) < thr) &&\n(FFABS(src0 - ref1) < thr) &&\n(FFABS(src0 - ref2) < thr) &&\n(FFABS(src0 - ref3) < thr);", "}", "}", "for (VAR_9 = 0; VAR_9 < s->nb_components; VAR_9++)", "if (!cmp[VAR_9])\nbreak;", "if (VAR_9 == s->nb_components) {", "for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {", "const int dst_linesize = out->linesize[VAR_8] / 2;", "uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6;", "dst[0] = avg[VAR_8];", "}", "} else {", "for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {", "const int dst_linesize = out->linesize[VAR_8] / 2;", "uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6;", "dst[0] = src[VAR_8];", "}", "}", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75, 77, 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ] ]
11,581
static int tiff_decode_tag(TiffContext *s) { unsigned tag, type, count, off, value = 0; int i, j, k, pos, start; int ret; uint32_t *pal; double *dp; tag = tget_short(&s->gb, s->le); type = tget_short(&s->gb, s->le); count = tget_long(&s->gb, s->le); off = tget_long(&s->gb, s->le); start = bytestream2_tell(&s->gb); if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) { av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n", type); return 0; } if (count == 1) { switch (type) { case TIFF_BYTE: case TIFF_SHORT: bytestream2_seek(&s->gb, -4, SEEK_CUR); value = tget(&s->gb, type, s->le); break; case TIFF_LONG: value = off; break; case TIFF_STRING: if (count <= 4) { bytestream2_seek(&s->gb, -4, SEEK_CUR); break; } default: value = UINT_MAX; bytestream2_seek(&s->gb, off, SEEK_SET); } } else { if (count <= 4 && type_sizes[type] * count <= 4) { bytestream2_seek(&s->gb, -4, SEEK_CUR); } else { bytestream2_seek(&s->gb, off, SEEK_SET); } } switch (tag) { case TIFF_WIDTH: s->width = value; break; case TIFF_HEIGHT: s->height = value; break; case TIFF_BPP: s->bppcount = count; if (count > 4) { av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); return AVERROR_INVALIDDATA; } if (count == 1) s->bpp = value; else { switch (type) { case TIFF_BYTE: s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) + ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF); break; case TIFF_SHORT: case TIFF_LONG: s->bpp = 0; if (bytestream2_get_bytes_left(&s->gb) < type_sizes[type] * count) return AVERROR_INVALIDDATA; for (i = 0; i < count; i++) s->bpp += tget(&s->gb, type, s->le); break; default: s->bpp = -1; } } break; case TIFF_SAMPLES_PER_PIXEL: if (count != 1) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel requires a single value, many provided\n"); return AVERROR_INVALIDDATA; } if (value > 4U) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel %d is too large\n", value); return AVERROR_INVALIDDATA; } if (s->bppcount == 1) s->bpp *= value; s->bppcount = value; break; case TIFF_COMPR: s->compr = value; s->predictor = 0; switch (s->compr) { case TIFF_RAW: case TIFF_PACKBITS: case TIFF_LZW: case TIFF_CCITT_RLE: break; case TIFF_G3: case TIFF_G4: s->fax_opts = 0; break; case TIFF_DEFLATE: case TIFF_ADOBE_DEFLATE: #if CONFIG_ZLIB break; #else av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); return AVERROR(ENOSYS); #endif case TIFF_JPEG: case TIFF_NEWJPEG: av_log(s->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n"); return AVERROR_PATCHWELCOME; default: av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr); return AVERROR_INVALIDDATA; } break; case TIFF_ROWSPERSTRIP: if (type == TIFF_LONG && value == UINT_MAX) value = s->height; if (value < 1) { av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n"); return AVERROR_INVALIDDATA; } s->rps = value; break; case TIFF_STRIP_OFFS: if (count == 1) { s->strippos = 0; s->stripoff = value; } else s->strippos = off; s->strips = count; if (s->strips == 1) s->rps = s->height; s->sot = type; if (s->strippos > bytestream2_size(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_STRIP_SIZE: if (count == 1) { s->stripsizesoff = 0; s->stripsize = value; s->strips = 1; } else { s->stripsizesoff = off; } s->strips = count; s->sstype = type; if (s->stripsizesoff > bytestream2_size(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_TILE_BYTE_COUNTS: case TIFF_TILE_LENGTH: case TIFF_TILE_OFFSETS: case TIFF_TILE_WIDTH: av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n"); return AVERROR_PATCHWELCOME; break; case TIFF_PREDICTOR: s->predictor = value; break; case TIFF_INVERT: switch (value) { case 0: s->invert = 1; break; case 1: s->invert = 0; break; case 2: case 3: break; default: av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", value); return AVERROR_INVALIDDATA; } break; case TIFF_FILL_ORDER: if (value < 1 || value > 2) { av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value); value = 1; } s->fill_order = value - 1; break; case TIFF_PAL: pal = (uint32_t *) s->palette; off = type_sizes[type]; if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3) return AVERROR_INVALIDDATA; off = (type_sizes[type] - 1) << 3; for (k = 2; k >= 0; k--) { for (i = 0; i < count / 3; i++) { if (k == 2) pal[i] = 0xFFU << 24; j = (tget(&s->gb, type, s->le) >> off) << (k * 8); pal[i] |= j; } } s->palette_is_set = 1; break; case TIFF_PLANAR: if (value == 2) { av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); return AVERROR_PATCHWELCOME; } break; case TIFF_T4OPTIONS: if (s->compr == TIFF_G3) s->fax_opts = value; break; case TIFF_T6OPTIONS: if (s->compr == TIFF_G4) s->fax_opts = value; break; #define ADD_METADATA(count, name, sep)\ if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\ av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ return ret;\ } case TIFF_MODEL_PIXEL_SCALE: ADD_METADATA(count, "ModelPixelScaleTag", NULL); break; case TIFF_MODEL_TRANSFORMATION: ADD_METADATA(count, "ModelTransformationTag", NULL); break; case TIFF_MODEL_TIEPOINT: ADD_METADATA(count, "ModelTiepointTag", NULL); break; case TIFF_GEO_KEY_DIRECTORY: ADD_METADATA(1, "GeoTIFF_Version", NULL); ADD_METADATA(2, "GeoTIFF_Key_Revision", "."); s->geotag_count = tget_short(&s->gb, s->le); if (s->geotag_count > count / 4 - 1) { s->geotag_count = count / 4 - 1; av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n"); } if (bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4) { s->geotag_count = 0; return -1; } s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count); if (!s->geotags) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); s->geotag_count = 0; return AVERROR(ENOMEM); } for (i = 0; i < s->geotag_count; i++) { s->geotags[i].key = tget_short(&s->gb, s->le); s->geotags[i].type = tget_short(&s->gb, s->le); s->geotags[i].count = tget_short(&s->gb, s->le); if (!s->geotags[i].type) s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&s->gb, s->le)); else s->geotags[i].offset = tget_short(&s->gb, s->le); } break; case TIFF_GEO_DOUBLE_PARAMS: if (count >= INT_MAX / sizeof(int64_t)) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t)) return AVERROR_INVALIDDATA; dp = av_malloc(count * sizeof(double)); if (!dp) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } for (i = 0; i < count; i++) dp[i] = tget_double(&s->gb, s->le); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", "); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); av_freep(&dp); return AVERROR(ENOMEM); } s->geotags[i].val = ap; } } } av_freep(&dp); break; case TIFF_GEO_ASCII_PARAMS: pos = bytestream2_tell(&s->gb); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap; bytestream2_seek(&s->gb, pos + s->geotags[i].offset, SEEK_SET); if (bytestream2_get_bytes_left(&s->gb) < s->geotags[i].count) return AVERROR_INVALIDDATA; ap = av_malloc(s->geotags[i].count); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } bytestream2_get_bufferu(&s->gb, ap, s->geotags[i].count); ap[s->geotags[i].count - 1] = '\0'; //replace the "|" delimiter with a 0 byte s->geotags[i].val = ap; } } } break; case TIFF_ARTIST: ADD_METADATA(count, "artist", NULL); break; case TIFF_COPYRIGHT: ADD_METADATA(count, "copyright", NULL); break; case TIFF_DATE: ADD_METADATA(count, "date", NULL); break; case TIFF_DOCUMENT_NAME: ADD_METADATA(count, "document_name", NULL); break; case TIFF_HOST_COMPUTER: ADD_METADATA(count, "computer", NULL); break; case TIFF_IMAGE_DESCRIPTION: ADD_METADATA(count, "description", NULL); break; case TIFF_MAKE: ADD_METADATA(count, "make", NULL); break; case TIFF_MODEL: ADD_METADATA(count, "model", NULL); break; case TIFF_PAGE_NAME: ADD_METADATA(count, "page_name", NULL); break; case TIFF_PAGE_NUMBER: ADD_METADATA(count, "page_number", " / "); break; case TIFF_SOFTWARE_NAME: ADD_METADATA(count, "software", NULL); break; default: av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n", tag, tag); } bytestream2_seek(&s->gb, start, SEEK_SET); return 0; }
true
FFmpeg
edcc51fb8e15b704955d742559215697598927bb
static int tiff_decode_tag(TiffContext *s) { unsigned tag, type, count, off, value = 0; int i, j, k, pos, start; int ret; uint32_t *pal; double *dp; tag = tget_short(&s->gb, s->le); type = tget_short(&s->gb, s->le); count = tget_long(&s->gb, s->le); off = tget_long(&s->gb, s->le); start = bytestream2_tell(&s->gb); if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) { av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n", type); return 0; } if (count == 1) { switch (type) { case TIFF_BYTE: case TIFF_SHORT: bytestream2_seek(&s->gb, -4, SEEK_CUR); value = tget(&s->gb, type, s->le); break; case TIFF_LONG: value = off; break; case TIFF_STRING: if (count <= 4) { bytestream2_seek(&s->gb, -4, SEEK_CUR); break; } default: value = UINT_MAX; bytestream2_seek(&s->gb, off, SEEK_SET); } } else { if (count <= 4 && type_sizes[type] * count <= 4) { bytestream2_seek(&s->gb, -4, SEEK_CUR); } else { bytestream2_seek(&s->gb, off, SEEK_SET); } } switch (tag) { case TIFF_WIDTH: s->width = value; break; case TIFF_HEIGHT: s->height = value; break; case TIFF_BPP: s->bppcount = count; if (count > 4) { av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); return AVERROR_INVALIDDATA; } if (count == 1) s->bpp = value; else { switch (type) { case TIFF_BYTE: s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) + ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF); break; case TIFF_SHORT: case TIFF_LONG: s->bpp = 0; if (bytestream2_get_bytes_left(&s->gb) < type_sizes[type] * count) return AVERROR_INVALIDDATA; for (i = 0; i < count; i++) s->bpp += tget(&s->gb, type, s->le); break; default: s->bpp = -1; } } break; case TIFF_SAMPLES_PER_PIXEL: if (count != 1) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel requires a single value, many provided\n"); return AVERROR_INVALIDDATA; } if (value > 4U) { av_log(s->avctx, AV_LOG_ERROR, "Samples per pixel %d is too large\n", value); return AVERROR_INVALIDDATA; } if (s->bppcount == 1) s->bpp *= value; s->bppcount = value; break; case TIFF_COMPR: s->compr = value; s->predictor = 0; switch (s->compr) { case TIFF_RAW: case TIFF_PACKBITS: case TIFF_LZW: case TIFF_CCITT_RLE: break; case TIFF_G3: case TIFF_G4: s->fax_opts = 0; break; case TIFF_DEFLATE: case TIFF_ADOBE_DEFLATE: #if CONFIG_ZLIB break; #else av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); return AVERROR(ENOSYS); #endif case TIFF_JPEG: case TIFF_NEWJPEG: av_log(s->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n"); return AVERROR_PATCHWELCOME; default: av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr); return AVERROR_INVALIDDATA; } break; case TIFF_ROWSPERSTRIP: if (type == TIFF_LONG && value == UINT_MAX) value = s->height; if (value < 1) { av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n"); return AVERROR_INVALIDDATA; } s->rps = value; break; case TIFF_STRIP_OFFS: if (count == 1) { s->strippos = 0; s->stripoff = value; } else s->strippos = off; s->strips = count; if (s->strips == 1) s->rps = s->height; s->sot = type; if (s->strippos > bytestream2_size(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_STRIP_SIZE: if (count == 1) { s->stripsizesoff = 0; s->stripsize = value; s->strips = 1; } else { s->stripsizesoff = off; } s->strips = count; s->sstype = type; if (s->stripsizesoff > bytestream2_size(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_TILE_BYTE_COUNTS: case TIFF_TILE_LENGTH: case TIFF_TILE_OFFSETS: case TIFF_TILE_WIDTH: av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n"); return AVERROR_PATCHWELCOME; break; case TIFF_PREDICTOR: s->predictor = value; break; case TIFF_INVERT: switch (value) { case 0: s->invert = 1; break; case 1: s->invert = 0; break; case 2: case 3: break; default: av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", value); return AVERROR_INVALIDDATA; } break; case TIFF_FILL_ORDER: if (value < 1 || value > 2) { av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value); value = 1; } s->fill_order = value - 1; break; case TIFF_PAL: pal = (uint32_t *) s->palette; off = type_sizes[type]; if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3) return AVERROR_INVALIDDATA; off = (type_sizes[type] - 1) << 3; for (k = 2; k >= 0; k--) { for (i = 0; i < count / 3; i++) { if (k == 2) pal[i] = 0xFFU << 24; j = (tget(&s->gb, type, s->le) >> off) << (k * 8); pal[i] |= j; } } s->palette_is_set = 1; break; case TIFF_PLANAR: if (value == 2) { av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); return AVERROR_PATCHWELCOME; } break; case TIFF_T4OPTIONS: if (s->compr == TIFF_G3) s->fax_opts = value; break; case TIFF_T6OPTIONS: if (s->compr == TIFF_G4) s->fax_opts = value; break; #define ADD_METADATA(count, name, sep)\ if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\ av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ return ret;\ } case TIFF_MODEL_PIXEL_SCALE: ADD_METADATA(count, "ModelPixelScaleTag", NULL); break; case TIFF_MODEL_TRANSFORMATION: ADD_METADATA(count, "ModelTransformationTag", NULL); break; case TIFF_MODEL_TIEPOINT: ADD_METADATA(count, "ModelTiepointTag", NULL); break; case TIFF_GEO_KEY_DIRECTORY: ADD_METADATA(1, "GeoTIFF_Version", NULL); ADD_METADATA(2, "GeoTIFF_Key_Revision", "."); s->geotag_count = tget_short(&s->gb, s->le); if (s->geotag_count > count / 4 - 1) { s->geotag_count = count / 4 - 1; av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n"); } if (bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4) { s->geotag_count = 0; return -1; } s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count); if (!s->geotags) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); s->geotag_count = 0; return AVERROR(ENOMEM); } for (i = 0; i < s->geotag_count; i++) { s->geotags[i].key = tget_short(&s->gb, s->le); s->geotags[i].type = tget_short(&s->gb, s->le); s->geotags[i].count = tget_short(&s->gb, s->le); if (!s->geotags[i].type) s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&s->gb, s->le)); else s->geotags[i].offset = tget_short(&s->gb, s->le); } break; case TIFF_GEO_DOUBLE_PARAMS: if (count >= INT_MAX / sizeof(int64_t)) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t)) return AVERROR_INVALIDDATA; dp = av_malloc(count * sizeof(double)); if (!dp) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } for (i = 0; i < count; i++) dp[i] = tget_double(&s->gb, s->le); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", "); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); av_freep(&dp); return AVERROR(ENOMEM); } s->geotags[i].val = ap; } } } av_freep(&dp); break; case TIFF_GEO_ASCII_PARAMS: pos = bytestream2_tell(&s->gb); for (i = 0; i < s->geotag_count; i++) { if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) { if (s->geotags[i].count == 0 || s->geotags[i].offset + s->geotags[i].count > count) { av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key); } else { char *ap; bytestream2_seek(&s->gb, pos + s->geotags[i].offset, SEEK_SET); if (bytestream2_get_bytes_left(&s->gb) < s->geotags[i].count) return AVERROR_INVALIDDATA; ap = av_malloc(s->geotags[i].count); if (!ap) { av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } bytestream2_get_bufferu(&s->gb, ap, s->geotags[i].count); ap[s->geotags[i].count - 1] = '\0'; s->geotags[i].val = ap; } } } break; case TIFF_ARTIST: ADD_METADATA(count, "artist", NULL); break; case TIFF_COPYRIGHT: ADD_METADATA(count, "copyright", NULL); break; case TIFF_DATE: ADD_METADATA(count, "date", NULL); break; case TIFF_DOCUMENT_NAME: ADD_METADATA(count, "document_name", NULL); break; case TIFF_HOST_COMPUTER: ADD_METADATA(count, "computer", NULL); break; case TIFF_IMAGE_DESCRIPTION: ADD_METADATA(count, "description", NULL); break; case TIFF_MAKE: ADD_METADATA(count, "make", NULL); break; case TIFF_MODEL: ADD_METADATA(count, "model", NULL); break; case TIFF_PAGE_NAME: ADD_METADATA(count, "page_name", NULL); break; case TIFF_PAGE_NUMBER: ADD_METADATA(count, "page_number", " / "); break; case TIFF_SOFTWARE_NAME: ADD_METADATA(count, "software", NULL); break; default: av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n", tag, tag); } bytestream2_seek(&s->gb, start, SEEK_SET); return 0; }
{ "code": [ "static int tiff_decode_tag(TiffContext *s)", " if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\\" ], "line_no": [ 1, 477 ] }
static int FUNC_0(TiffContext *VAR_0) { unsigned VAR_1, VAR_2, VAR_3, VAR_4, VAR_5 = 0; int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int VAR_11; uint32_t *pal; double *VAR_12; VAR_1 = tget_short(&VAR_0->gb, VAR_0->le); VAR_2 = tget_short(&VAR_0->gb, VAR_0->le); VAR_3 = tget_long(&VAR_0->gb, VAR_0->le); VAR_4 = tget_long(&VAR_0->gb, VAR_0->le); VAR_10 = bytestream2_tell(&VAR_0->gb); if (VAR_2 == 0 || VAR_2 >= FF_ARRAY_ELEMS(type_sizes)) { av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown tiff VAR_2 (%u) encountered\n", VAR_2); return 0; } if (VAR_3 == 1) { switch (VAR_2) { case TIFF_BYTE: case TIFF_SHORT: bytestream2_seek(&VAR_0->gb, -4, SEEK_CUR); VAR_5 = tget(&VAR_0->gb, VAR_2, VAR_0->le); break; case TIFF_LONG: VAR_5 = VAR_4; break; case TIFF_STRING: if (VAR_3 <= 4) { bytestream2_seek(&VAR_0->gb, -4, SEEK_CUR); break; } default: VAR_5 = UINT_MAX; bytestream2_seek(&VAR_0->gb, VAR_4, SEEK_SET); } } else { if (VAR_3 <= 4 && type_sizes[VAR_2] * VAR_3 <= 4) { bytestream2_seek(&VAR_0->gb, -4, SEEK_CUR); } else { bytestream2_seek(&VAR_0->gb, VAR_4, SEEK_SET); } } switch (VAR_1) { case TIFF_WIDTH: VAR_0->width = VAR_5; break; case TIFF_HEIGHT: VAR_0->height = VAR_5; break; case TIFF_BPP: VAR_0->bppcount = VAR_3; if (VAR_3 > 4) { av_log(VAR_0->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", VAR_0->bpp, VAR_3); return AVERROR_INVALIDDATA; } if (VAR_3 == 1) VAR_0->bpp = VAR_5; else { switch (VAR_2) { case TIFF_BYTE: VAR_0->bpp = (VAR_4 & 0xFF) + ((VAR_4 >> 8) & 0xFF) + ((VAR_4 >> 16) & 0xFF) + ((VAR_4 >> 24) & 0xFF); break; case TIFF_SHORT: case TIFF_LONG: VAR_0->bpp = 0; if (bytestream2_get_bytes_left(&VAR_0->gb) < type_sizes[VAR_2] * VAR_3) return AVERROR_INVALIDDATA; for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) VAR_0->bpp += tget(&VAR_0->gb, VAR_2, VAR_0->le); break; default: VAR_0->bpp = -1; } } break; case TIFF_SAMPLES_PER_PIXEL: if (VAR_3 != 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Samples per pixel requires a single VAR_5, many provided\n"); return AVERROR_INVALIDDATA; } if (VAR_5 > 4U) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Samples per pixel %d is too large\n", VAR_5); return AVERROR_INVALIDDATA; } if (VAR_0->bppcount == 1) VAR_0->bpp *= VAR_5; VAR_0->bppcount = VAR_5; break; case TIFF_COMPR: VAR_0->compr = VAR_5; VAR_0->predictor = 0; switch (VAR_0->compr) { case TIFF_RAW: case TIFF_PACKBITS: case TIFF_LZW: case TIFF_CCITT_RLE: break; case TIFF_G3: case TIFF_G4: VAR_0->fax_opts = 0; break; case TIFF_DEFLATE: case TIFF_ADOBE_DEFLATE: #if CONFIG_ZLIB break; #else av_log(VAR_0->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); return AVERROR(ENOSYS); #endif case TIFF_JPEG: case TIFF_NEWJPEG: av_log(VAR_0->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n"); return AVERROR_PATCHWELCOME; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown compression method %VAR_6\n", VAR_0->compr); return AVERROR_INVALIDDATA; } break; case TIFF_ROWSPERSTRIP: if (VAR_2 == TIFF_LONG && VAR_5 == UINT_MAX) VAR_5 = VAR_0->height; if (VAR_5 < 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect VAR_5 of rows per strip\n"); return AVERROR_INVALIDDATA; } VAR_0->rps = VAR_5; break; case TIFF_STRIP_OFFS: if (VAR_3 == 1) { VAR_0->strippos = 0; VAR_0->stripoff = VAR_5; } else VAR_0->strippos = VAR_4; VAR_0->strips = VAR_3; if (VAR_0->strips == 1) VAR_0->rps = VAR_0->height; VAR_0->sot = VAR_2; if (VAR_0->strippos > bytestream2_size(&VAR_0->gb)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_STRIP_SIZE: if (VAR_3 == 1) { VAR_0->stripsizesoff = 0; VAR_0->stripsize = VAR_5; VAR_0->strips = 1; } else { VAR_0->stripsizesoff = VAR_4; } VAR_0->strips = VAR_3; VAR_0->sstype = VAR_2; if (VAR_0->stripsizesoff > bytestream2_size(&VAR_0->gb)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); return AVERROR_INVALIDDATA; } break; case TIFF_TILE_BYTE_COUNTS: case TIFF_TILE_LENGTH: case TIFF_TILE_OFFSETS: case TIFF_TILE_WIDTH: av_log(VAR_0->avctx, AV_LOG_ERROR, "Tiled images are not supported\n"); return AVERROR_PATCHWELCOME; break; case TIFF_PREDICTOR: VAR_0->predictor = VAR_5; break; case TIFF_INVERT: switch (VAR_5) { case 0: VAR_0->invert = 1; break; case 1: VAR_0->invert = 0; break; case 2: case 3: break; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", VAR_5); return AVERROR_INVALIDDATA; } break; case TIFF_FILL_ORDER: if (VAR_5 < 1 || VAR_5 > 2) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown FillOrder VAR_5 %d, trying default one\n", VAR_5); VAR_5 = 1; } VAR_0->fill_order = VAR_5 - 1; break; case TIFF_PAL: pal = (uint32_t *) VAR_0->palette; VAR_4 = type_sizes[VAR_2]; if (VAR_3 / 3 > 256 || bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3 / 3 * VAR_4 * 3) return AVERROR_INVALIDDATA; VAR_4 = (type_sizes[VAR_2] - 1) << 3; for (VAR_8 = 2; VAR_8 >= 0; VAR_8--) { for (VAR_6 = 0; VAR_6 < VAR_3 / 3; VAR_6++) { if (VAR_8 == 2) pal[VAR_6] = 0xFFU << 24; VAR_7 = (tget(&VAR_0->gb, VAR_2, VAR_0->le) >> VAR_4) << (VAR_8 * 8); pal[VAR_6] |= VAR_7; } } VAR_0->palette_is_set = 1; break; case TIFF_PLANAR: if (VAR_5 == 2) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); return AVERROR_PATCHWELCOME; } break; case TIFF_T4OPTIONS: if (VAR_0->compr == TIFF_G3) VAR_0->fax_opts = VAR_5; break; case TIFF_T6OPTIONS: if (VAR_0->compr == TIFF_G4) VAR_0->fax_opts = VAR_5; break; #define ADD_METADATA(VAR_3, name, sep)\ if ((VAR_11 = add_metadata(VAR_3, VAR_2, name, sep, VAR_0)) < 0) {\ av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ return VAR_11;\ } case TIFF_MODEL_PIXEL_SCALE: ADD_METADATA(VAR_3, "ModelPixelScaleTag", NULL); break; case TIFF_MODEL_TRANSFORMATION: ADD_METADATA(VAR_3, "ModelTransformationTag", NULL); break; case TIFF_MODEL_TIEPOINT: ADD_METADATA(VAR_3, "ModelTiepointTag", NULL); break; case TIFF_GEO_KEY_DIRECTORY: ADD_METADATA(1, "GeoTIFF_Version", NULL); ADD_METADATA(2, "GeoTIFF_Key_Revision", "."); VAR_0->geotag_count = tget_short(&VAR_0->gb, VAR_0->le); if (VAR_0->geotag_count > VAR_3 / 4 - 1) { VAR_0->geotag_count = VAR_3 / 4 - 1; av_log(VAR_0->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n"); } if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_0->geotag_count * sizeof(int16_t) * 4) { VAR_0->geotag_count = 0; return -1; } VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count); if (!VAR_0->geotags) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); VAR_0->geotag_count = 0; return AVERROR(ENOMEM); } for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) { VAR_0->geotags[VAR_6].key = tget_short(&VAR_0->gb, VAR_0->le); VAR_0->geotags[VAR_6].VAR_2 = tget_short(&VAR_0->gb, VAR_0->le); VAR_0->geotags[VAR_6].VAR_3 = tget_short(&VAR_0->gb, VAR_0->le); if (!VAR_0->geotags[VAR_6].VAR_2) VAR_0->geotags[VAR_6].val = get_geokey_val(VAR_0->geotags[VAR_6].key, tget_short(&VAR_0->gb, VAR_0->le)); else VAR_0->geotags[VAR_6].offset = tget_short(&VAR_0->gb, VAR_0->le); } break; case TIFF_GEO_DOUBLE_PARAMS: if (VAR_3 >= INT_MAX / sizeof(int64_t)) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3 * sizeof(int64_t)) return AVERROR_INVALIDDATA; VAR_12 = av_malloc(VAR_3 * sizeof(double)); if (!VAR_12) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) VAR_12[VAR_6] = tget_double(&VAR_0->gb, VAR_0->le); for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) { if (VAR_0->geotags[VAR_6].VAR_2 == TIFF_GEO_DOUBLE_PARAMS) { if (VAR_0->geotags[VAR_6].VAR_3 == 0 || VAR_0->geotags[VAR_6].offset + VAR_0->geotags[VAR_6].VAR_3 > VAR_3) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_6].key); } else { char *ap = doubles2str(&VAR_12[VAR_0->geotags[VAR_6].offset], VAR_0->geotags[VAR_6].VAR_3, ", "); if (!ap) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); av_freep(&VAR_12); return AVERROR(ENOMEM); } VAR_0->geotags[VAR_6].val = ap; } } } av_freep(&VAR_12); break; case TIFF_GEO_ASCII_PARAMS: VAR_9 = bytestream2_tell(&VAR_0->gb); for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) { if (VAR_0->geotags[VAR_6].VAR_2 == TIFF_GEO_ASCII_PARAMS) { if (VAR_0->geotags[VAR_6].VAR_3 == 0 || VAR_0->geotags[VAR_6].offset + VAR_0->geotags[VAR_6].VAR_3 > VAR_3) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_6].key); } else { char *ap; bytestream2_seek(&VAR_0->gb, VAR_9 + VAR_0->geotags[VAR_6].offset, SEEK_SET); if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_0->geotags[VAR_6].VAR_3) return AVERROR_INVALIDDATA; ap = av_malloc(VAR_0->geotags[VAR_6].VAR_3); if (!ap) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } bytestream2_get_bufferu(&VAR_0->gb, ap, VAR_0->geotags[VAR_6].VAR_3); ap[VAR_0->geotags[VAR_6].VAR_3 - 1] = '\0'; VAR_0->geotags[VAR_6].val = ap; } } } break; case TIFF_ARTIST: ADD_METADATA(VAR_3, "artist", NULL); break; case TIFF_COPYRIGHT: ADD_METADATA(VAR_3, "copyright", NULL); break; case TIFF_DATE: ADD_METADATA(VAR_3, "date", NULL); break; case TIFF_DOCUMENT_NAME: ADD_METADATA(VAR_3, "document_name", NULL); break; case TIFF_HOST_COMPUTER: ADD_METADATA(VAR_3, "computer", NULL); break; case TIFF_IMAGE_DESCRIPTION: ADD_METADATA(VAR_3, "description", NULL); break; case TIFF_MAKE: ADD_METADATA(VAR_3, "make", NULL); break; case TIFF_MODEL: ADD_METADATA(VAR_3, "model", NULL); break; case TIFF_PAGE_NAME: ADD_METADATA(VAR_3, "page_name", NULL); break; case TIFF_PAGE_NUMBER: ADD_METADATA(VAR_3, "page_number", " / "); break; case TIFF_SOFTWARE_NAME: ADD_METADATA(VAR_3, "software", NULL); break; default: av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown or unsupported VAR_1 %d/0X%0X\n", VAR_1, VAR_1); } bytestream2_seek(&VAR_0->gb, VAR_10, SEEK_SET); return 0; }
[ "static int FUNC_0(TiffContext *VAR_0)\n{", "unsigned VAR_1, VAR_2, VAR_3, VAR_4, VAR_5 = 0;", "int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;", "int VAR_11;", "uint32_t *pal;", "double *VAR_12;", "VAR_1 = tget_short(&VAR_0->gb, VAR_0->le);", "VAR_2 = tget_short(&VAR_0->gb, VAR_0->le);", "VAR_3 = tget_long(&VAR_0->gb, VAR_0->le);", "VAR_4 = tget_long(&VAR_0->gb, VAR_0->le);", "VAR_10 = bytestream2_tell(&VAR_0->gb);", "if (VAR_2 == 0 || VAR_2 >= FF_ARRAY_ELEMS(type_sizes)) {", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Unknown tiff VAR_2 (%u) encountered\\n\",\nVAR_2);", "return 0;", "}", "if (VAR_3 == 1) {", "switch (VAR_2) {", "case TIFF_BYTE:\ncase TIFF_SHORT:\nbytestream2_seek(&VAR_0->gb, -4, SEEK_CUR);", "VAR_5 = tget(&VAR_0->gb, VAR_2, VAR_0->le);", "break;", "case TIFF_LONG:\nVAR_5 = VAR_4;", "break;", "case TIFF_STRING:\nif (VAR_3 <= 4) {", "bytestream2_seek(&VAR_0->gb, -4, SEEK_CUR);", "break;", "}", "default:\nVAR_5 = UINT_MAX;", "bytestream2_seek(&VAR_0->gb, VAR_4, SEEK_SET);", "}", "} else {", "if (VAR_3 <= 4 && type_sizes[VAR_2] * VAR_3 <= 4) {", "bytestream2_seek(&VAR_0->gb, -4, SEEK_CUR);", "} else {", "bytestream2_seek(&VAR_0->gb, VAR_4, SEEK_SET);", "}", "}", "switch (VAR_1) {", "case TIFF_WIDTH:\nVAR_0->width = VAR_5;", "break;", "case TIFF_HEIGHT:\nVAR_0->height = VAR_5;", "break;", "case TIFF_BPP:\nVAR_0->bppcount = VAR_3;", "if (VAR_3 > 4) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"This format is not supported (bpp=%d, %d components)\\n\",\nVAR_0->bpp, VAR_3);", "return AVERROR_INVALIDDATA;", "}", "if (VAR_3 == 1)\nVAR_0->bpp = VAR_5;", "else {", "switch (VAR_2) {", "case TIFF_BYTE:\nVAR_0->bpp = (VAR_4 & 0xFF) + ((VAR_4 >> 8) & 0xFF) +\n((VAR_4 >> 16) & 0xFF) + ((VAR_4 >> 24) & 0xFF);", "break;", "case TIFF_SHORT:\ncase TIFF_LONG:\nVAR_0->bpp = 0;", "if (bytestream2_get_bytes_left(&VAR_0->gb) < type_sizes[VAR_2] * VAR_3)\nreturn AVERROR_INVALIDDATA;", "for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++)", "VAR_0->bpp += tget(&VAR_0->gb, VAR_2, VAR_0->le);", "break;", "default:\nVAR_0->bpp = -1;", "}", "}", "break;", "case TIFF_SAMPLES_PER_PIXEL:\nif (VAR_3 != 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Samples per pixel requires a single VAR_5, many provided\\n\");", "return AVERROR_INVALIDDATA;", "}", "if (VAR_5 > 4U) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Samples per pixel %d is too large\\n\", VAR_5);", "return AVERROR_INVALIDDATA;", "}", "if (VAR_0->bppcount == 1)\nVAR_0->bpp *= VAR_5;", "VAR_0->bppcount = VAR_5;", "break;", "case TIFF_COMPR:\nVAR_0->compr = VAR_5;", "VAR_0->predictor = 0;", "switch (VAR_0->compr) {", "case TIFF_RAW:\ncase TIFF_PACKBITS:\ncase TIFF_LZW:\ncase TIFF_CCITT_RLE:\nbreak;", "case TIFF_G3:\ncase TIFF_G4:\nVAR_0->fax_opts = 0;", "break;", "case TIFF_DEFLATE:\ncase TIFF_ADOBE_DEFLATE:\n#if CONFIG_ZLIB\nbreak;", "#else\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Deflate: ZLib not compiled in\\n\");", "return AVERROR(ENOSYS);", "#endif\ncase TIFF_JPEG:\ncase TIFF_NEWJPEG:\nav_log(VAR_0->avctx, AV_LOG_ERROR,\n\"JPEG compression is not supported\\n\");", "return AVERROR_PATCHWELCOME;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown compression method %VAR_6\\n\",\nVAR_0->compr);", "return AVERROR_INVALIDDATA;", "}", "break;", "case TIFF_ROWSPERSTRIP:\nif (VAR_2 == TIFF_LONG && VAR_5 == UINT_MAX)\nVAR_5 = VAR_0->height;", "if (VAR_5 < 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Incorrect VAR_5 of rows per strip\\n\");", "return AVERROR_INVALIDDATA;", "}", "VAR_0->rps = VAR_5;", "break;", "case TIFF_STRIP_OFFS:\nif (VAR_3 == 1) {", "VAR_0->strippos = 0;", "VAR_0->stripoff = VAR_5;", "} else", "VAR_0->strippos = VAR_4;", "VAR_0->strips = VAR_3;", "if (VAR_0->strips == 1)\nVAR_0->rps = VAR_0->height;", "VAR_0->sot = VAR_2;", "if (VAR_0->strippos > bytestream2_size(&VAR_0->gb)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");", "return AVERROR_INVALIDDATA;", "}", "break;", "case TIFF_STRIP_SIZE:\nif (VAR_3 == 1) {", "VAR_0->stripsizesoff = 0;", "VAR_0->stripsize = VAR_5;", "VAR_0->strips = 1;", "} else {", "VAR_0->stripsizesoff = VAR_4;", "}", "VAR_0->strips = VAR_3;", "VAR_0->sstype = VAR_2;", "if (VAR_0->stripsizesoff > bytestream2_size(&VAR_0->gb)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");", "return AVERROR_INVALIDDATA;", "}", "break;", "case TIFF_TILE_BYTE_COUNTS:\ncase TIFF_TILE_LENGTH:\ncase TIFF_TILE_OFFSETS:\ncase TIFF_TILE_WIDTH:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Tiled images are not supported\\n\");", "return AVERROR_PATCHWELCOME;", "break;", "case TIFF_PREDICTOR:\nVAR_0->predictor = VAR_5;", "break;", "case TIFF_INVERT:\nswitch (VAR_5) {", "case 0:\nVAR_0->invert = 1;", "break;", "case 1:\nVAR_0->invert = 0;", "break;", "case 2:\ncase 3:\nbreak;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Color mode %d is not supported\\n\",\nVAR_5);", "return AVERROR_INVALIDDATA;", "}", "break;", "case TIFF_FILL_ORDER:\nif (VAR_5 < 1 || VAR_5 > 2) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Unknown FillOrder VAR_5 %d, trying default one\\n\", VAR_5);", "VAR_5 = 1;", "}", "VAR_0->fill_order = VAR_5 - 1;", "break;", "case TIFF_PAL:\npal = (uint32_t *) VAR_0->palette;", "VAR_4 = type_sizes[VAR_2];", "if (VAR_3 / 3 > 256 || bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3 / 3 * VAR_4 * 3)\nreturn AVERROR_INVALIDDATA;", "VAR_4 = (type_sizes[VAR_2] - 1) << 3;", "for (VAR_8 = 2; VAR_8 >= 0; VAR_8--) {", "for (VAR_6 = 0; VAR_6 < VAR_3 / 3; VAR_6++) {", "if (VAR_8 == 2)\npal[VAR_6] = 0xFFU << 24;", "VAR_7 = (tget(&VAR_0->gb, VAR_2, VAR_0->le) >> VAR_4) << (VAR_8 * 8);", "pal[VAR_6] |= VAR_7;", "}", "}", "VAR_0->palette_is_set = 1;", "break;", "case TIFF_PLANAR:\nif (VAR_5 == 2) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Planar format is not supported\\n\");", "return AVERROR_PATCHWELCOME;", "}", "break;", "case TIFF_T4OPTIONS:\nif (VAR_0->compr == TIFF_G3)\nVAR_0->fax_opts = VAR_5;", "break;", "case TIFF_T6OPTIONS:\nif (VAR_0->compr == TIFF_G4)\nVAR_0->fax_opts = VAR_5;", "break;", "#define ADD_METADATA(VAR_3, name, sep)\\\nif ((VAR_11 = add_metadata(VAR_3, VAR_2, name, sep, VAR_0)) < 0) {\\", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");\\", "return VAR_11;\\", "}", "case TIFF_MODEL_PIXEL_SCALE:\nADD_METADATA(VAR_3, \"ModelPixelScaleTag\", NULL);", "break;", "case TIFF_MODEL_TRANSFORMATION:\nADD_METADATA(VAR_3, \"ModelTransformationTag\", NULL);", "break;", "case TIFF_MODEL_TIEPOINT:\nADD_METADATA(VAR_3, \"ModelTiepointTag\", NULL);", "break;", "case TIFF_GEO_KEY_DIRECTORY:\nADD_METADATA(1, \"GeoTIFF_Version\", NULL);", "ADD_METADATA(2, \"GeoTIFF_Key_Revision\", \".\");", "VAR_0->geotag_count = tget_short(&VAR_0->gb, VAR_0->le);", "if (VAR_0->geotag_count > VAR_3 / 4 - 1) {", "VAR_0->geotag_count = VAR_3 / 4 - 1;", "av_log(VAR_0->avctx, AV_LOG_WARNING, \"GeoTIFF key directory buffer shorter than specified\\n\");", "}", "if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_0->geotag_count * sizeof(int16_t) * 4) {", "VAR_0->geotag_count = 0;", "return -1;", "}", "VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count);", "if (!VAR_0->geotags) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");", "VAR_0->geotag_count = 0;", "return AVERROR(ENOMEM);", "}", "for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) {", "VAR_0->geotags[VAR_6].key = tget_short(&VAR_0->gb, VAR_0->le);", "VAR_0->geotags[VAR_6].VAR_2 = tget_short(&VAR_0->gb, VAR_0->le);", "VAR_0->geotags[VAR_6].VAR_3 = tget_short(&VAR_0->gb, VAR_0->le);", "if (!VAR_0->geotags[VAR_6].VAR_2)\nVAR_0->geotags[VAR_6].val = get_geokey_val(VAR_0->geotags[VAR_6].key, tget_short(&VAR_0->gb, VAR_0->le));", "else\nVAR_0->geotags[VAR_6].offset = tget_short(&VAR_0->gb, VAR_0->le);", "}", "break;", "case TIFF_GEO_DOUBLE_PARAMS:\nif (VAR_3 >= INT_MAX / sizeof(int64_t))\nreturn AVERROR_INVALIDDATA;", "if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3 * sizeof(int64_t))\nreturn AVERROR_INVALIDDATA;", "VAR_12 = av_malloc(VAR_3 * sizeof(double));", "if (!VAR_12) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");", "return AVERROR(ENOMEM);", "}", "for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++)", "VAR_12[VAR_6] = tget_double(&VAR_0->gb, VAR_0->le);", "for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) {", "if (VAR_0->geotags[VAR_6].VAR_2 == TIFF_GEO_DOUBLE_PARAMS) {", "if (VAR_0->geotags[VAR_6].VAR_3 == 0\n|| VAR_0->geotags[VAR_6].offset + VAR_0->geotags[VAR_6].VAR_3 > VAR_3) {", "av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid GeoTIFF key %d\\n\", VAR_0->geotags[VAR_6].key);", "} else {", "char *ap = doubles2str(&VAR_12[VAR_0->geotags[VAR_6].offset], VAR_0->geotags[VAR_6].VAR_3, \", \");", "if (!ap) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");", "av_freep(&VAR_12);", "return AVERROR(ENOMEM);", "}", "VAR_0->geotags[VAR_6].val = ap;", "}", "}", "}", "av_freep(&VAR_12);", "break;", "case TIFF_GEO_ASCII_PARAMS:\nVAR_9 = bytestream2_tell(&VAR_0->gb);", "for (VAR_6 = 0; VAR_6 < VAR_0->geotag_count; VAR_6++) {", "if (VAR_0->geotags[VAR_6].VAR_2 == TIFF_GEO_ASCII_PARAMS) {", "if (VAR_0->geotags[VAR_6].VAR_3 == 0\n|| VAR_0->geotags[VAR_6].offset + VAR_0->geotags[VAR_6].VAR_3 > VAR_3) {", "av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid GeoTIFF key %d\\n\", VAR_0->geotags[VAR_6].key);", "} else {", "char *ap;", "bytestream2_seek(&VAR_0->gb, VAR_9 + VAR_0->geotags[VAR_6].offset, SEEK_SET);", "if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_0->geotags[VAR_6].VAR_3)\nreturn AVERROR_INVALIDDATA;", "ap = av_malloc(VAR_0->geotags[VAR_6].VAR_3);", "if (!ap) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");", "return AVERROR(ENOMEM);", "}", "bytestream2_get_bufferu(&VAR_0->gb, ap, VAR_0->geotags[VAR_6].VAR_3);", "ap[VAR_0->geotags[VAR_6].VAR_3 - 1] = '\\0';", "VAR_0->geotags[VAR_6].val = ap;", "}", "}", "}", "break;", "case TIFF_ARTIST:\nADD_METADATA(VAR_3, \"artist\", NULL);", "break;", "case TIFF_COPYRIGHT:\nADD_METADATA(VAR_3, \"copyright\", NULL);", "break;", "case TIFF_DATE:\nADD_METADATA(VAR_3, \"date\", NULL);", "break;", "case TIFF_DOCUMENT_NAME:\nADD_METADATA(VAR_3, \"document_name\", NULL);", "break;", "case TIFF_HOST_COMPUTER:\nADD_METADATA(VAR_3, \"computer\", NULL);", "break;", "case TIFF_IMAGE_DESCRIPTION:\nADD_METADATA(VAR_3, \"description\", NULL);", "break;", "case TIFF_MAKE:\nADD_METADATA(VAR_3, \"make\", NULL);", "break;", "case TIFF_MODEL:\nADD_METADATA(VAR_3, \"model\", NULL);", "break;", "case TIFF_PAGE_NAME:\nADD_METADATA(VAR_3, \"page_name\", NULL);", "break;", "case TIFF_PAGE_NUMBER:\nADD_METADATA(VAR_3, \"page_number\", \" / \");", "break;", "case TIFF_SOFTWARE_NAME:\nADD_METADATA(VAR_3, \"software\", NULL);", "break;", "default:\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"Unknown or unsupported VAR_1 %d/0X%0X\\n\",\nVAR_1, VAR_1);", "}", "bytestream2_seek(&VAR_0->gb, VAR_10, SEEK_SET);", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 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 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115, 117, 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133, 135, 137 ], [ 139 ], [ 141, 143, 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167, 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 205, 207, 209, 211, 213 ], [ 215, 217, 219 ], [ 221 ], [ 223, 225, 227, 229 ], [ 231, 233 ], [ 235 ], [ 237, 239, 241, 243, 245 ], [ 247 ], [ 249, 251, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261, 263, 265 ], [ 267 ], [ 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281, 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295, 297 ], [ 299 ], [ 301 ], [ 303, 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313, 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335, 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345, 347, 349, 351, 353 ], [ 355 ], [ 357 ], [ 359, 361 ], [ 363 ], [ 365, 367 ], [ 369, 371 ], [ 373 ], [ 375, 377 ], [ 379 ], [ 381, 383, 385 ], [ 387, 389, 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399, 401 ], [ 403, 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415, 417 ], [ 419 ], [ 421, 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431, 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447, 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459, 461, 463 ], [ 465 ], [ 467, 469, 471 ], [ 473 ], [ 475, 477 ], [ 479 ], [ 481 ], [ 483 ], [ 485, 487 ], [ 489 ], [ 491, 493 ], [ 495 ], [ 497, 499 ], [ 501 ], [ 503, 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541 ], [ 543 ], [ 545 ], [ 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 ], [ 641 ], [ 643, 645 ], [ 647 ], [ 649 ], [ 651 ], [ 653 ], [ 655 ], [ 657 ], [ 659 ], [ 661 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 671, 673 ], [ 675 ], [ 677, 679 ], [ 681 ], [ 683, 685 ], [ 687 ], [ 689, 691 ], [ 693 ], [ 695, 697 ], [ 699 ], [ 701, 703 ], [ 705 ], [ 707, 709 ], [ 711 ], [ 713, 715 ], [ 717 ], [ 719, 721 ], [ 723 ], [ 725, 727 ], [ 729 ], [ 731, 733 ], [ 735 ], [ 737, 739, 741 ], [ 743 ], [ 745 ], [ 747 ], [ 749 ] ]
11,582
static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int x, y; pixel *src = (pixel *)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); const int8_t *filter = ff_hevc_epel_filters[my - 1]; pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); int shift = 14 + 1 - BIT_DEPTH; int log2Wd = denom + shift - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
true
FFmpeg
7d88586e4728e97349f98e07ff782bb168ab96c3
static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int x, y; pixel *src = (pixel *)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); const int8_t *filter = ff_hevc_epel_filters[my - 1]; pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); int shift = 14 + 1 - BIT_DEPTH; int log2Wd = denom + shift - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
{ "code": [ " ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));" ], "line_no": [ 39 ] }
static void FUNC_0(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int VAR_0, VAR_1; pixel *src = (pixel *)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); const int8_t *VAR_2 = ff_hevc_epel_filters[my - 1]; pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); int VAR_3 = 14 + 1 - BIT_DEPTH; int VAR_4 = denom + VAR_3 - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (VAR_1 = 0; VAR_1 < height; VAR_1++) { for (VAR_0 = 0; VAR_0 < width; VAR_0++) dst[VAR_0] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[VAR_0] * wx0 + ((ox0 + ox1 + 1) << VAR_4)) >> (VAR_4 + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
[ "static void FUNC_0(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,\nint16_t *src2,\nint height, int denom, int wx0, int wx1,\nint ox0, int ox1, intptr_t mx, intptr_t my, int width)\n{", "int VAR_0, VAR_1;", "pixel *src = (pixel *)_src;", "ptrdiff_t srcstride = _srcstride / sizeof(pixel);", "const int8_t *VAR_2 = ff_hevc_epel_filters[my - 1];", "pixel *dst = (pixel *)_dst;", "ptrdiff_t dststride = _dststride / sizeof(pixel);", "int VAR_3 = 14 + 1 - BIT_DEPTH;", "int VAR_4 = denom + VAR_3 - 1;", "ox0 = ox0 * (1 << (BIT_DEPTH - 8));", "ox1 = ox1 * (1 << (BIT_DEPTH - 8));", "for (VAR_1 = 0; VAR_1 < height; VAR_1++) {", "for (VAR_0 = 0; VAR_0 < width; VAR_0++)", "dst[VAR_0] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[VAR_0] * wx0 +\n((ox0 + ox1 + 1) << VAR_4)) >> (VAR_4 + 1));", "src += srcstride;", "dst += dststride;", "src2 += MAX_PB_SIZE;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
11,583
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; BlockIOLimit io_limits; int snapshot = 0; bool copy_on_read; int ret; translation = BIOS_ATA_TRANSLATION_AUTO; media = MEDIA_DISK; /* extract parameters */ bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", buf); return NULL; } } else { type = default_to_scsi ? IF_SCSI : IF_IDE; pstrcpy(devname, sizeof(devname), if_name[type]); } max_devs = if_max_devs[type]; if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("CHS can't be set with media=%s", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { /* this is the default */ } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } /* disk I/O throttling */ io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "bps", 0); io_limits.bps[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "bps_rd", 0); io_limits.bps[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "bps_wr", 0); io_limits.iops[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "iops", 0); io_limits.iops[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "iops_rd", 0); io_limits.iops[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "iops_wr", 0); if (!do_check_io_limits(&io_limits)) { error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) " "cannot be used at the same time"); return NULL; } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } /* compute bus and unit according index */ if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } /* if user doesn't specify a unit_id, * try to find the first free */ if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } /* check unit id */ if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } /* * catch multiple definitions */ if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); return NULL; } /* init */ dinfo = g_malloc0(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = g_strdup(buf); } else { /* no id supplied -> create one */ dinfo->id = g_malloc0(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; dinfo->refcount = 1; if (serial) { pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial); } QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); /* disk I/O throttling */ bdrv_set_io_limits(dinfo->bdrv, &io_limits); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: /* add virtio block device */ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(opts, "driver", "virtio-blk-s390"); } else { qemu_opt_set(opts, "driver", "virtio-blk-pci"); } qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; default: abort(); } if (!file || !*file) { return dinfo; } if (snapshot) { /* always use cache=unsafe with snapshot */ bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (copy_on_read) { bdrv_flags |= BDRV_O_COPY_ON_READ; } if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INCOMING; } if (media == MEDIA_CDROM) { /* CDROM is fine for any interface, don't check. */ ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE && type != IF_PFLASH) { error_report("readonly not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); g_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); g_free(dinfo); return NULL; }
true
qemu
8be7e7e4c72c048b90e3482557954a24bba43ba7
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; BlockIOLimit io_limits; int snapshot = 0; bool copy_on_read; int ret; translation = BIOS_ATA_TRANSLATION_AUTO; media = MEDIA_DISK; bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", buf); return NULL; } } else { type = default_to_scsi ? IF_SCSI : IF_IDE; pstrcpy(devname, sizeof(devname), if_name[type]); } max_devs = if_max_devs[type]; if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("CHS can't be set with media=%s", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "bps", 0); io_limits.bps[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "bps_rd", 0); io_limits.bps[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "bps_wr", 0); io_limits.iops[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "iops", 0); io_limits.iops[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "iops_rd", 0); io_limits.iops[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "iops_wr", 0); if (!do_check_io_limits(&io_limits)) { error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) " "cannot be used at the same time"); return NULL; } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); return NULL; } dinfo = g_malloc0(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = g_strdup(buf); } else { dinfo->id = g_malloc0(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; dinfo->refcount = 1; if (serial) { pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial); } QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); bdrv_set_io_limits(dinfo->bdrv, &io_limits); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(opts, "driver", "virtio-blk-s390"); } else { qemu_opt_set(opts, "driver", "virtio-blk-pci"); } qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; default: abort(); } if (!file || !*file) { return dinfo; } if (snapshot) { bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (copy_on_read) { bdrv_flags |= BDRV_O_COPY_ON_READ; } if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INCOMING; } if (media == MEDIA_CDROM) { ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE && type != IF_PFLASH) { error_report("readonly not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); g_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); g_free(dinfo); return NULL; }
{ "code": [ " opts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);" ], "line_no": [ 591 ] }
DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi) { const char *VAR_0; const char *VAR_1 = NULL; char VAR_2[128]; const char *VAR_3; const char *VAR_4 = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } VAR_5; int VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11; BlockDriver *drv = NULL; int VAR_12; int VAR_13; int VAR_14 = 0; int VAR_15 = 0; int VAR_16, VAR_17; const char *VAR_18; DriveInfo *dinfo; BlockIOLimit io_limits; int VAR_19 = 0; bool copy_on_read; int VAR_20; VAR_11 = BIOS_ATA_TRANSLATION_AUTO; VAR_5 = MEDIA_DISK; VAR_6 = qemu_opt_get_number(opts, "bus", 0); VAR_7 = qemu_opt_get_number(opts, "unit", -1); VAR_13 = qemu_opt_get_number(opts, "VAR_13", -1); VAR_8 = qemu_opt_get_number(opts, "VAR_8", 0); VAR_9 = qemu_opt_get_number(opts, "VAR_9", 0); VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0); VAR_19 = qemu_opt_get_bool(opts, "VAR_19", 0); VAR_14 = qemu_opt_get_bool(opts, "readonly", 0); copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); VAR_1 = qemu_opt_get(opts, "VAR_1"); VAR_3 = qemu_opt_get(opts, "VAR_3"); if ((VAR_0 = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(VAR_2, sizeof(VAR_2), VAR_0); for (type = 0; type < IF_COUNT && strcmp(VAR_0, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", VAR_0); return NULL; } } else { type = default_to_scsi ? IF_SCSI : IF_IDE; pstrcpy(VAR_2, sizeof(VAR_2), if_name[type]); } VAR_12 = if_max_devs[type]; if (VAR_8 || VAR_9 || VAR_10) { if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) { error_report("invalid physical VAR_8 number"); return NULL; } if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) { error_report("invalid physical VAR_9 number"); return NULL; } if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) { error_report("invalid physical VAR_10 number"); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "trans")) != NULL) { if (!VAR_8) { error_report("'%s' trans must be used with VAR_8, VAR_9 and VAR_10", VAR_0); return NULL; } if (!strcmp(VAR_0, "none")) VAR_11 = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(VAR_0, "lba")) VAR_11 = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(VAR_0, "auto")) VAR_11 = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid VAR_11 type", VAR_0); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "VAR_5")) != NULL) { if (!strcmp(VAR_0, "disk")) { VAR_5 = MEDIA_DISK; } else if (!strcmp(VAR_0, "cdrom")) { if (VAR_8 || VAR_10 || VAR_9) { error_report("CHS can't be set with VAR_5=%s", VAR_0); return NULL; } VAR_5 = MEDIA_CDROM; } else { error_report("'%s' invalid VAR_5", VAR_0); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "cache")) != NULL) { if (bdrv_parse_cache_flags(VAR_0, &VAR_15) != 0) { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((VAR_0 = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(VAR_0, "native")) { VAR_15 |= BDRV_O_NATIVE_AIO; } else if (!strcmp(VAR_0, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((VAR_0 = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(VAR_0, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(VAR_0); if (!drv) { error_report("'%s' invalid format", VAR_0); return NULL; } } io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "bps", 0); io_limits.bps[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "bps_rd", 0); io_limits.bps[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "bps_wr", 0); io_limits.iops[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "iops", 0); io_limits.iops[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "iops_rd", 0); io_limits.iops[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "iops_wr", 0); if (!do_check_io_limits(&io_limits)) { error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) " "cannot be used at the same time"); return NULL; } VAR_17 = BLOCK_ERR_STOP_ENOSPC; if ((VAR_0 = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } VAR_17 = parse_block_error_action(VAR_0, 0); if (VAR_17 < 0) { return NULL; } } VAR_16 = BLOCK_ERR_REPORT; if ((VAR_0 = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } VAR_16 = parse_block_error_action(VAR_0, 1); if (VAR_16 < 0) { return NULL; } } if ((VAR_18 = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (VAR_13 != -1) { if (VAR_6 != 0 || VAR_7 != -1) { error_report("VAR_13 cannot be used with bus and unit"); return NULL; } VAR_6 = drive_index_to_bus_id(type, VAR_13); VAR_7 = drive_index_to_unit_id(type, VAR_13); } if (VAR_7 == -1) { VAR_7 = 0; while (drive_get(type, VAR_6, VAR_7) != NULL) { VAR_7++; if (VAR_12 && VAR_7 >= VAR_12) { VAR_7 -= VAR_12; VAR_6++; } } } if (VAR_12 && VAR_7 >= VAR_12) { error_report("unit %d too big (max is %d)", VAR_7, VAR_12 - 1); return NULL; } if (drive_get(type, VAR_6, VAR_7) != NULL) { error_report("drive with bus=%d, unit=%d (VAR_13=%d) exists", VAR_6, VAR_7, VAR_13); return NULL; } dinfo = g_malloc0(sizeof(*dinfo)); if ((VAR_0 = qemu_opts_id(opts)) != NULL) { dinfo->id = g_strdup(VAR_0); } else { dinfo->id = g_malloc0(32); if (type == IF_IDE || type == IF_SCSI) VAR_4 = (VAR_5 == MEDIA_CDROM) ? "-cd" : "-hd"; if (VAR_12) snprintf(dinfo->id, 32, "%s%i%s%i", VAR_2, VAR_6, VAR_4, VAR_7); else snprintf(dinfo->id, 32, "%s%s%i", VAR_2, VAR_4, VAR_7); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->VAR_18 = VAR_18; dinfo->type = type; dinfo->bus = VAR_6; dinfo->unit = VAR_7; dinfo->opts = opts; dinfo->refcount = 1; if (VAR_3) { pstrcpy(dinfo->VAR_3, sizeof(dinfo->VAR_3), VAR_3); } QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17); bdrv_set_io_limits(dinfo->bdrv, &io_limits); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(VAR_5) { case MEDIA_DISK: if (VAR_8 != 0) { bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10); bdrv_set_translation_hint(dinfo->bdrv, VAR_11); } break; case MEDIA_CDROM: dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(opts, "driver", "virtio-blk-s390"); } else { qemu_opt_set(opts, "driver", "virtio-blk-pci"); } qemu_opt_set(opts, "drive", dinfo->id); if (VAR_18) qemu_opt_set(opts, "addr", VAR_18); break; default: abort(); } if (!VAR_1 || !*VAR_1) { return dinfo; } if (VAR_19) { VAR_15 &= ~BDRV_O_CACHE_MASK; VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (copy_on_read) { VAR_15 |= BDRV_O_COPY_ON_READ; } if (runstate_check(RUN_STATE_INMIGRATE)) { VAR_15 |= BDRV_O_INCOMING; } if (VAR_5 == MEDIA_CDROM) { VAR_14 = 1; } else if (VAR_14 == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE && type != IF_PFLASH) { error_report("readonly not supported by this bus type"); goto err; } } VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR; VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv); if (VAR_20 < 0) { error_report("could not open disk image %s: %s", VAR_1, strerror(-VAR_20)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); g_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); g_free(dinfo); return NULL; }
[ "DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi)\n{", "const char *VAR_0;", "const char *VAR_1 = NULL;", "char VAR_2[128];", "const char *VAR_3;", "const char *VAR_4 = \"\";", "BlockInterfaceType type;", "enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;", "int VAR_6, VAR_7;", "int VAR_8, VAR_9, VAR_10, VAR_11;", "BlockDriver *drv = NULL;", "int VAR_12;", "int VAR_13;", "int VAR_14 = 0;", "int VAR_15 = 0;", "int VAR_16, VAR_17;", "const char *VAR_18;", "DriveInfo *dinfo;", "BlockIOLimit io_limits;", "int VAR_19 = 0;", "bool copy_on_read;", "int VAR_20;", "VAR_11 = BIOS_ATA_TRANSLATION_AUTO;", "VAR_5 = MEDIA_DISK;", "VAR_6 = qemu_opt_get_number(opts, \"bus\", 0);", "VAR_7 = qemu_opt_get_number(opts, \"unit\", -1);", "VAR_13 = qemu_opt_get_number(opts, \"VAR_13\", -1);", "VAR_8 = qemu_opt_get_number(opts, \"VAR_8\", 0);", "VAR_9 = qemu_opt_get_number(opts, \"VAR_9\", 0);", "VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);", "VAR_19 = qemu_opt_get_bool(opts, \"VAR_19\", 0);", "VAR_14 = qemu_opt_get_bool(opts, \"readonly\", 0);", "copy_on_read = qemu_opt_get_bool(opts, \"copy-on-read\", false);", "VAR_1 = qemu_opt_get(opts, \"VAR_1\");", "VAR_3 = qemu_opt_get(opts, \"VAR_3\");", "if ((VAR_0 = qemu_opt_get(opts, \"if\")) != NULL) {", "pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);", "for (type = 0; type < IF_COUNT && strcmp(VAR_0, if_name[type]); type++)", ";", "if (type == IF_COUNT) {", "error_report(\"unsupported bus type '%s'\", VAR_0);", "return NULL;", "}", "} else {", "type = default_to_scsi ? IF_SCSI : IF_IDE;", "pstrcpy(VAR_2, sizeof(VAR_2), if_name[type]);", "}", "VAR_12 = if_max_devs[type];", "if (VAR_8 || VAR_9 || VAR_10) {", "if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {", "error_report(\"invalid physical VAR_8 number\");", "return NULL;", "}", "if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {", "error_report(\"invalid physical VAR_9 number\");", "return NULL;", "}", "if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {", "error_report(\"invalid physical VAR_10 number\");", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"trans\")) != NULL) {", "if (!VAR_8) {", "error_report(\"'%s' trans must be used with VAR_8, VAR_9 and VAR_10\",\nVAR_0);", "return NULL;", "}", "if (!strcmp(VAR_0, \"none\"))\nVAR_11 = BIOS_ATA_TRANSLATION_NONE;", "else if (!strcmp(VAR_0, \"lba\"))\nVAR_11 = BIOS_ATA_TRANSLATION_LBA;", "else if (!strcmp(VAR_0, \"auto\"))\nVAR_11 = BIOS_ATA_TRANSLATION_AUTO;", "else {", "error_report(\"'%s' invalid VAR_11 type\", VAR_0);", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"VAR_5\")) != NULL) {", "if (!strcmp(VAR_0, \"disk\")) {", "VAR_5 = MEDIA_DISK;", "} else if (!strcmp(VAR_0, \"cdrom\")) {", "if (VAR_8 || VAR_10 || VAR_9) {", "error_report(\"CHS can't be set with VAR_5=%s\", VAR_0);", "return NULL;", "}", "VAR_5 = MEDIA_CDROM;", "} else {", "error_report(\"'%s' invalid VAR_5\", VAR_0);", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"cache\")) != NULL) {", "if (bdrv_parse_cache_flags(VAR_0, &VAR_15) != 0) {", "error_report(\"invalid cache option\");", "return NULL;", "}", "}", "#ifdef CONFIG_LINUX_AIO\nif ((VAR_0 = qemu_opt_get(opts, \"aio\")) != NULL) {", "if (!strcmp(VAR_0, \"native\")) {", "VAR_15 |= BDRV_O_NATIVE_AIO;", "} else if (!strcmp(VAR_0, \"threads\")) {", "} else {", "error_report(\"invalid aio option\");", "return NULL;", "}", "}", "#endif\nif ((VAR_0 = qemu_opt_get(opts, \"format\")) != NULL) {", "if (strcmp(VAR_0, \"?\") == 0) {", "error_printf(\"Supported formats:\");", "bdrv_iterate_format(bdrv_format_print, NULL);", "error_printf(\"\\n\");", "return NULL;", "}", "drv = bdrv_find_whitelisted_format(VAR_0);", "if (!drv) {", "error_report(\"'%s' invalid format\", VAR_0);", "return NULL;", "}", "}", "io_limits.bps[BLOCK_IO_LIMIT_TOTAL] =\nqemu_opt_get_number(opts, \"bps\", 0);", "io_limits.bps[BLOCK_IO_LIMIT_READ] =\nqemu_opt_get_number(opts, \"bps_rd\", 0);", "io_limits.bps[BLOCK_IO_LIMIT_WRITE] =\nqemu_opt_get_number(opts, \"bps_wr\", 0);", "io_limits.iops[BLOCK_IO_LIMIT_TOTAL] =\nqemu_opt_get_number(opts, \"iops\", 0);", "io_limits.iops[BLOCK_IO_LIMIT_READ] =\nqemu_opt_get_number(opts, \"iops_rd\", 0);", "io_limits.iops[BLOCK_IO_LIMIT_WRITE] =\nqemu_opt_get_number(opts, \"iops_wr\", 0);", "if (!do_check_io_limits(&io_limits)) {", "error_report(\"bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) \"\n\"cannot be used at the same time\");", "return NULL;", "}", "VAR_17 = BLOCK_ERR_STOP_ENOSPC;", "if ((VAR_0 = qemu_opt_get(opts, \"werror\")) != NULL) {", "if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {", "error_report(\"werror is not supported by this bus type\");", "return NULL;", "}", "VAR_17 = parse_block_error_action(VAR_0, 0);", "if (VAR_17 < 0) {", "return NULL;", "}", "}", "VAR_16 = BLOCK_ERR_REPORT;", "if ((VAR_0 = qemu_opt_get(opts, \"rerror\")) != NULL) {", "if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {", "error_report(\"rerror is not supported by this bus type\");", "return NULL;", "}", "VAR_16 = parse_block_error_action(VAR_0, 1);", "if (VAR_16 < 0) {", "return NULL;", "}", "}", "if ((VAR_18 = qemu_opt_get(opts, \"addr\")) != NULL) {", "if (type != IF_VIRTIO) {", "error_report(\"addr is not supported by this bus type\");", "return NULL;", "}", "}", "if (VAR_13 != -1) {", "if (VAR_6 != 0 || VAR_7 != -1) {", "error_report(\"VAR_13 cannot be used with bus and unit\");", "return NULL;", "}", "VAR_6 = drive_index_to_bus_id(type, VAR_13);", "VAR_7 = drive_index_to_unit_id(type, VAR_13);", "}", "if (VAR_7 == -1) {", "VAR_7 = 0;", "while (drive_get(type, VAR_6, VAR_7) != NULL) {", "VAR_7++;", "if (VAR_12 && VAR_7 >= VAR_12) {", "VAR_7 -= VAR_12;", "VAR_6++;", "}", "}", "}", "if (VAR_12 && VAR_7 >= VAR_12) {", "error_report(\"unit %d too big (max is %d)\",\nVAR_7, VAR_12 - 1);", "return NULL;", "}", "if (drive_get(type, VAR_6, VAR_7) != NULL) {", "error_report(\"drive with bus=%d, unit=%d (VAR_13=%d) exists\",\nVAR_6, VAR_7, VAR_13);", "return NULL;", "}", "dinfo = g_malloc0(sizeof(*dinfo));", "if ((VAR_0 = qemu_opts_id(opts)) != NULL) {", "dinfo->id = g_strdup(VAR_0);", "} else {", "dinfo->id = g_malloc0(32);", "if (type == IF_IDE || type == IF_SCSI)\nVAR_4 = (VAR_5 == MEDIA_CDROM) ? \"-cd\" : \"-hd\";", "if (VAR_12)\nsnprintf(dinfo->id, 32, \"%s%i%s%i\",\nVAR_2, VAR_6, VAR_4, VAR_7);", "else\nsnprintf(dinfo->id, 32, \"%s%s%i\",\nVAR_2, VAR_4, VAR_7);", "}", "dinfo->bdrv = bdrv_new(dinfo->id);", "dinfo->VAR_18 = VAR_18;", "dinfo->type = type;", "dinfo->bus = VAR_6;", "dinfo->unit = VAR_7;", "dinfo->opts = opts;", "dinfo->refcount = 1;", "if (VAR_3) {", "pstrcpy(dinfo->VAR_3, sizeof(dinfo->VAR_3), VAR_3);", "}", "QTAILQ_INSERT_TAIL(&drives, dinfo, next);", "bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17);", "bdrv_set_io_limits(dinfo->bdrv, &io_limits);", "switch(type) {", "case IF_IDE:\ncase IF_SCSI:\ncase IF_XEN:\ncase IF_NONE:\nswitch(VAR_5) {", "case MEDIA_DISK:\nif (VAR_8 != 0) {", "bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);", "bdrv_set_translation_hint(dinfo->bdrv, VAR_11);", "}", "break;", "case MEDIA_CDROM:\ndinfo->media_cd = 1;", "break;", "}", "break;", "case IF_SD:\ncase IF_FLOPPY:\ncase IF_PFLASH:\ncase IF_MTD:\nbreak;", "case IF_VIRTIO:\nopts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);", "if (arch_type == QEMU_ARCH_S390X) {", "qemu_opt_set(opts, \"driver\", \"virtio-blk-s390\");", "} else {", "qemu_opt_set(opts, \"driver\", \"virtio-blk-pci\");", "}", "qemu_opt_set(opts, \"drive\", dinfo->id);", "if (VAR_18)\nqemu_opt_set(opts, \"addr\", VAR_18);", "break;", "default:\nabort();", "}", "if (!VAR_1 || !*VAR_1) {", "return dinfo;", "}", "if (VAR_19) {", "VAR_15 &= ~BDRV_O_CACHE_MASK;", "VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);", "}", "if (copy_on_read) {", "VAR_15 |= BDRV_O_COPY_ON_READ;", "}", "if (runstate_check(RUN_STATE_INMIGRATE)) {", "VAR_15 |= BDRV_O_INCOMING;", "}", "if (VAR_5 == MEDIA_CDROM) {", "VAR_14 = 1;", "} else if (VAR_14 == 1) {", "if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY &&\ntype != IF_NONE && type != IF_PFLASH) {", "error_report(\"readonly not supported by this bus type\");", "goto err;", "}", "}", "VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;", "VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv);", "if (VAR_20 < 0) {", "error_report(\"could not open disk image %s: %s\",\nVAR_1, strerror(-VAR_20));", "goto err;", "}", "if (bdrv_key_required(dinfo->bdrv))\nautostart = 0;", "return dinfo;", "err:\nbdrv_delete(dinfo->bdrv);", "g_free(dinfo->id);", "QTAILQ_REMOVE(&drives, dinfo, next);", "g_free(dinfo);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 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 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 283, 285 ], [ 287, 289 ], [ 291, 293 ], [ 295, 297 ], [ 299, 301 ], [ 303, 305 ], [ 309 ], [ 311, 313 ], [ 315 ], [ 317 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 443 ], [ 445, 447 ], [ 449 ], [ 451 ], [ 463 ], [ 465, 467 ], [ 469 ], [ 471 ], [ 479 ], [ 481 ], [ 483 ], [ 485 ], [ 489 ], [ 491, 493 ], [ 495, 497, 499 ], [ 501, 503, 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529 ], [ 533 ], [ 539 ], [ 543 ], [ 545, 547, 549, 551, 553 ], [ 555, 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567, 569 ], [ 571 ], [ 573 ], [ 575 ], [ 577, 579, 581, 583, 585 ], [ 587, 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605, 607 ], [ 609 ], [ 611, 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 627 ], [ 629 ], [ 631 ], [ 635 ], [ 637 ], [ 639 ], [ 643 ], [ 645 ], [ 647 ], [ 651 ], [ 655 ], [ 657 ], [ 659, 661 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 673 ], [ 677 ], [ 679 ], [ 681, 683 ], [ 685 ], [ 687 ], [ 691, 693 ], [ 695 ], [ 699, 701 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711 ] ]
11,584
bool vhost_net_query(VHostNetState *net, VirtIODevice *dev) { return false; }
true
qemu
1e7398a140f7a6bd9f5a438e7ad0f1ef50990e25
bool vhost_net_query(VHostNetState *net, VirtIODevice *dev) { return false; }
{ "code": [ "bool vhost_net_query(VHostNetState *net, VirtIODevice *dev)", "bool vhost_net_query(VHostNetState *net, VirtIODevice *dev)", " return false;" ], "line_no": [ 1, 1, 5 ] }
bool FUNC_0(VHostNetState *net, VirtIODevice *dev) { return false; }
[ "bool FUNC_0(VHostNetState *net, VirtIODevice *dev)\n{", "return false;", "}" ]
[ 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,585
static int init_input(AVFormatContext *s, const char *filename) { int ret; AVProbeData pd = {filename, NULL, 0}; if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); else if (s->iformat->flags & AVFMT_NOFILE) av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); } if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) || (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0)))) if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0) return ret; if (s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); }
true
FFmpeg
bb99ae3ae924c942a634bec7711ec7ee11c38eb9
static int init_input(AVFormatContext *s, const char *filename) { int ret; AVProbeData pd = {filename, NULL, 0}; if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); else if (s->iformat->flags & AVFMT_NOFILE) av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); } if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) || (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0)))) if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0) return ret; if (s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1) { int VAR_2; AVProbeData pd = {VAR_1, NULL, 0}; if (VAR_0->pb) { VAR_0->flags |= AVFMT_FLAG_CUSTOM_IO; if (!VAR_0->iformat) return av_probe_input_buffer(VAR_0->pb, &VAR_0->iformat, VAR_1, VAR_0, 0, 0); else if (VAR_0->iformat->flags & AVFMT_NOFILE) av_log(VAR_0, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); } if ( (VAR_0->iformat && VAR_0->iformat->flags & AVFMT_NOFILE) || (!VAR_0->iformat && (VAR_0->iformat = av_probe_input_format(&pd, 0)))) if ((VAR_2 = avio_open(&VAR_0->pb, VAR_1, AVIO_FLAG_READ)) < 0) return VAR_2; if (VAR_0->iformat) return av_probe_input_buffer(VAR_0->pb, &VAR_0->iformat, VAR_1, VAR_0, 0, 0); }
[ "static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1)\n{", "int VAR_2;", "AVProbeData pd = {VAR_1, NULL, 0};", "if (VAR_0->pb) {", "VAR_0->flags |= AVFMT_FLAG_CUSTOM_IO;", "if (!VAR_0->iformat)\nreturn av_probe_input_buffer(VAR_0->pb, &VAR_0->iformat, VAR_1, VAR_0, 0, 0);", "else if (VAR_0->iformat->flags & AVFMT_NOFILE)\nav_log(VAR_0, AV_LOG_WARNING, \"Custom AVIOContext makes no sense and \"\n\"will be ignored with AVFMT_NOFILE format.\\n\");", "}", "if ( (VAR_0->iformat && VAR_0->iformat->flags & AVFMT_NOFILE) ||\n(!VAR_0->iformat && (VAR_0->iformat = av_probe_input_format(&pd, 0))))\nif ((VAR_2 = avio_open(&VAR_0->pb, VAR_1, AVIO_FLAG_READ)) < 0)\nreturn VAR_2;", "if (VAR_0->iformat)\nreturn av_probe_input_buffer(VAR_0->pb, &VAR_0->iformat, VAR_1, VAR_0, 0, 0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7, 8 ], [ 9, 10, 11 ], [ 12 ], [ 13, 14, 15, 16 ], [ 17, 18 ], [ 19 ] ]
11,586
void *etraxfs_eth_init(NICInfo *nd, CPUState *env, qemu_irq *irq, target_phys_addr_t base, int phyaddr) { struct etraxfs_dma_client *dma = NULL; struct fs_eth *eth = NULL; qemu_check_nic_model(nd, "fseth"); dma = qemu_mallocz(sizeof *dma * 2); eth = qemu_mallocz(sizeof *eth); dma[0].client.push = eth_tx_push; dma[0].client.opaque = eth; dma[1].client.opaque = eth; dma[1].client.pull = NULL; eth->env = env; eth->irq = irq; eth->dma_out = dma; eth->dma_in = dma + 1; /* Connect the phy. */ eth->phyaddr = phyaddr & 0x1f; tdk_init(&eth->phy); mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr); eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth); cpu_register_physical_memory (base, 0x5c, eth->ethregs); eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, eth); eth->vc->opaque = eth; eth->vc->link_status_changed = eth_set_link; return dma; }
true
qemu
b946a1533209f61a93e34898aebb5b43154b99c3
void *etraxfs_eth_init(NICInfo *nd, CPUState *env, qemu_irq *irq, target_phys_addr_t base, int phyaddr) { struct etraxfs_dma_client *dma = NULL; struct fs_eth *eth = NULL; qemu_check_nic_model(nd, "fseth"); dma = qemu_mallocz(sizeof *dma * 2); eth = qemu_mallocz(sizeof *eth); dma[0].client.push = eth_tx_push; dma[0].client.opaque = eth; dma[1].client.opaque = eth; dma[1].client.pull = NULL; eth->env = env; eth->irq = irq; eth->dma_out = dma; eth->dma_in = dma + 1; eth->phyaddr = phyaddr & 0x1f; tdk_init(&eth->phy); mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr); eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth); cpu_register_physical_memory (base, 0x5c, eth->ethregs); eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, eth); eth->vc->opaque = eth; eth->vc->link_status_changed = eth_set_link; return dma; }
{ "code": [ "\t\t\t\t eth_receive, eth_can_receive, eth);" ], "line_no": [ 63 ] }
void *FUNC_0(NICInfo *VAR_0, CPUState *VAR_1, qemu_irq *VAR_2, target_phys_addr_t VAR_3, int VAR_4) { struct etraxfs_dma_client *VAR_5 = NULL; struct fs_eth *VAR_6 = NULL; qemu_check_nic_model(VAR_0, "fseth"); VAR_5 = qemu_mallocz(sizeof *VAR_5 * 2); VAR_6 = qemu_mallocz(sizeof *VAR_6); VAR_5[0].client.push = eth_tx_push; VAR_5[0].client.opaque = VAR_6; VAR_5[1].client.opaque = VAR_6; VAR_5[1].client.pull = NULL; VAR_6->VAR_1 = VAR_1; VAR_6->VAR_2 = VAR_2; VAR_6->dma_out = VAR_5; VAR_6->dma_in = VAR_5 + 1; VAR_6->VAR_4 = VAR_4 & 0x1f; tdk_init(&VAR_6->phy); mdio_attach(&VAR_6->mdio_bus, &VAR_6->phy, VAR_6->VAR_4); VAR_6->ethregs = cpu_register_io_memory(0, eth_read, eth_write, VAR_6); cpu_register_physical_memory (VAR_3, 0x5c, VAR_6->ethregs); VAR_6->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name, eth_receive, eth_can_receive, VAR_6); VAR_6->vc->opaque = VAR_6; VAR_6->vc->link_status_changed = eth_set_link; return VAR_5; }
[ "void *FUNC_0(NICInfo *VAR_0, CPUState *VAR_1,\nqemu_irq *VAR_2, target_phys_addr_t VAR_3, int VAR_4)\n{", "struct etraxfs_dma_client *VAR_5 = NULL;", "struct fs_eth *VAR_6 = NULL;", "qemu_check_nic_model(VAR_0, \"fseth\");", "VAR_5 = qemu_mallocz(sizeof *VAR_5 * 2);", "VAR_6 = qemu_mallocz(sizeof *VAR_6);", "VAR_5[0].client.push = eth_tx_push;", "VAR_5[0].client.opaque = VAR_6;", "VAR_5[1].client.opaque = VAR_6;", "VAR_5[1].client.pull = NULL;", "VAR_6->VAR_1 = VAR_1;", "VAR_6->VAR_2 = VAR_2;", "VAR_6->dma_out = VAR_5;", "VAR_6->dma_in = VAR_5 + 1;", "VAR_6->VAR_4 = VAR_4 & 0x1f;", "tdk_init(&VAR_6->phy);", "mdio_attach(&VAR_6->mdio_bus, &VAR_6->phy, VAR_6->VAR_4);", "VAR_6->ethregs = cpu_register_io_memory(0, eth_read, eth_write, VAR_6);", "cpu_register_physical_memory (VAR_3, 0x5c, VAR_6->ethregs);", "VAR_6->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name,\neth_receive, eth_can_receive, VAR_6);", "VAR_6->vc->opaque = VAR_6;", "VAR_6->vc->link_status_changed = eth_set_link;", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ] ]
11,587
static int gif_read_extension(GifState *s) { ByteIOContext *f = s->f; int ext_code, ext_len, i, gce_flags, gce_transparent_index; /* extension */ ext_code = get_byte(f); ext_len = get_byte(f); #ifdef DEBUG printf("gif: ext_code=0x%x len=%d\n", ext_code, ext_len); #endif switch(ext_code) { case 0xf9: if (ext_len != 4) goto discard_ext; s->transparent_color_index = -1; gce_flags = get_byte(f); s->gce_delay = get_le16(f); gce_transparent_index = get_byte(f); if (gce_flags & 0x01) s->transparent_color_index = gce_transparent_index; else s->transparent_color_index = -1; s->gce_disposal = (gce_flags >> 2) & 0x7; #ifdef DEBUG printf("gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n", gce_flags, s->gce_delay, s->transparent_color_index, s->gce_disposal); #endif ext_len = get_byte(f); break; } /* NOTE: many extension blocks can come after */ discard_ext: while (ext_len != 0) { for (i = 0; i < ext_len; i++) get_byte(f); ext_len = get_byte(f); #ifdef DEBUG printf("gif: ext_len1=%d\n", ext_len); #endif } return 0; }
true
FFmpeg
0b54f3c0878a3acaa9142e4f24942e762d97e350
static int gif_read_extension(GifState *s) { ByteIOContext *f = s->f; int ext_code, ext_len, i, gce_flags, gce_transparent_index; ext_code = get_byte(f); ext_len = get_byte(f); #ifdef DEBUG printf("gif: ext_code=0x%x len=%d\n", ext_code, ext_len); #endif switch(ext_code) { case 0xf9: if (ext_len != 4) goto discard_ext; s->transparent_color_index = -1; gce_flags = get_byte(f); s->gce_delay = get_le16(f); gce_transparent_index = get_byte(f); if (gce_flags & 0x01) s->transparent_color_index = gce_transparent_index; else s->transparent_color_index = -1; s->gce_disposal = (gce_flags >> 2) & 0x7; #ifdef DEBUG printf("gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n", gce_flags, s->gce_delay, s->transparent_color_index, s->gce_disposal); #endif ext_len = get_byte(f); break; } discard_ext: while (ext_len != 0) { for (i = 0; i < ext_len; i++) get_byte(f); ext_len = get_byte(f); #ifdef DEBUG printf("gif: ext_len1=%d\n", ext_len); #endif } return 0; }
{ "code": [ " return 0;", " ByteIOContext *f = s->f;", "#ifdef DEBUG", "#endif", " return 0;", "static int gif_read_extension(GifState *s)", " ByteIOContext *f = s->f;", " int ext_code, ext_len, i, gce_flags, gce_transparent_index;", " ext_code = get_byte(f);", " ext_len = get_byte(f);", "#ifdef DEBUG", " printf(\"gif: ext_code=0x%x len=%d\\n\", ext_code, ext_len);", "#endif", " switch(ext_code) {", " case 0xf9:", " if (ext_len != 4)", " goto discard_ext;", " s->transparent_color_index = -1;", " gce_flags = get_byte(f);", " s->gce_delay = get_le16(f);", " gce_transparent_index = get_byte(f);", " if (gce_flags & 0x01)", " s->transparent_color_index = gce_transparent_index;", " s->transparent_color_index = -1;", " s->gce_disposal = (gce_flags >> 2) & 0x7;", "#ifdef DEBUG", " printf(\"gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\\n\",", " gce_flags, s->gce_delay,", " s->transparent_color_index, s->gce_disposal);", "#endif", " ext_len = get_byte(f);", " break;", " discard_ext:", " while (ext_len != 0) {", " for (i = 0; i < ext_len; i++)", " get_byte(f);", " ext_len = get_byte(f);", "#ifdef DEBUG", " printf(\"gif: ext_len1=%d\\n\", ext_len);", "#endif", " return 0;", " ByteIOContext *f = s->f;", "#ifdef DEBUG", "#endif", " return 0;", " ByteIOContext *f = s->f;", "#ifdef DEBUG", "#endif", " return 0;", " return 0;", " return 0;" ], "line_no": [ 87, 5, 17, 21, 87, 1, 5, 7, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 45, 47, 17, 51, 53, 55, 21, 59, 61, 69, 71, 73, 75, 59, 17, 81, 21, 87, 5, 17, 21, 87, 5, 17, 21, 87, 87, 87 ] }
static int FUNC_0(GifState *VAR_0) { ByteIOContext *f = VAR_0->f; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5; VAR_1 = get_byte(f); VAR_2 = get_byte(f); #ifdef DEBUG printf("gif: VAR_1=0x%x len=%d\n", VAR_1, VAR_2); #endif switch(VAR_1) { case 0xf9: if (VAR_2 != 4) goto discard_ext; VAR_0->transparent_color_index = -1; VAR_4 = get_byte(f); VAR_0->gce_delay = get_le16(f); VAR_5 = get_byte(f); if (VAR_4 & 0x01) VAR_0->transparent_color_index = VAR_5; else VAR_0->transparent_color_index = -1; VAR_0->gce_disposal = (VAR_4 >> 2) & 0x7; #ifdef DEBUG printf("gif: VAR_4=%x delay=%d tcolor=%d disposal=%d\n", VAR_4, VAR_0->gce_delay, VAR_0->transparent_color_index, VAR_0->gce_disposal); #endif VAR_2 = get_byte(f); break; } discard_ext: while (VAR_2 != 0) { for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) get_byte(f); VAR_2 = get_byte(f); #ifdef DEBUG printf("gif: ext_len1=%d\n", VAR_2); #endif } return 0; }
[ "static int FUNC_0(GifState *VAR_0)\n{", "ByteIOContext *f = VAR_0->f;", "int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;", "VAR_1 = get_byte(f);", "VAR_2 = get_byte(f);", "#ifdef DEBUG\nprintf(\"gif: VAR_1=0x%x len=%d\\n\", VAR_1, VAR_2);", "#endif\nswitch(VAR_1) {", "case 0xf9:\nif (VAR_2 != 4)\ngoto discard_ext;", "VAR_0->transparent_color_index = -1;", "VAR_4 = get_byte(f);", "VAR_0->gce_delay = get_le16(f);", "VAR_5 = get_byte(f);", "if (VAR_4 & 0x01)\nVAR_0->transparent_color_index = VAR_5;", "else\nVAR_0->transparent_color_index = -1;", "VAR_0->gce_disposal = (VAR_4 >> 2) & 0x7;", "#ifdef DEBUG\nprintf(\"gif: VAR_4=%x delay=%d tcolor=%d disposal=%d\\n\",\nVAR_4, VAR_0->gce_delay,\nVAR_0->transparent_color_index, VAR_0->gce_disposal);", "#endif\nVAR_2 = get_byte(f);", "break;", "}", "discard_ext:\nwhile (VAR_2 != 0) {", "for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++)", "get_byte(f);", "VAR_2 = get_byte(f);", "#ifdef DEBUG\nprintf(\"gif: ext_len1=%d\\n\", VAR_2);", "#endif\n}", "return 0;", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 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 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83, 85 ], [ 87 ], [ 89 ] ]
11,588
altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW) { register int i; vector unsigned int altivec_vectorShiftInt19 = vec_add(vec_splat_u32(10),vec_splat_u32(9)); if ((unsigned long)dest % 16) { /* badly aligned store, we force store alignement */ /* and will handle load misalignement on val w/ vec_perm */ vector unsigned char perm1; vector signed int v1; for (i = 0 ; (i < dstW) && (((unsigned long)dest + i) % 16) ; i++) { int t = val[i] >> 19; dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); } perm1 = vec_lvsl(i << 2, val); v1 = vec_ld(i << 2, val); for ( ; i < (dstW - 15); i+=16) { int offset = i << 2; vector signed int v2 = vec_ld(offset + 16, val); vector signed int v3 = vec_ld(offset + 32, val); vector signed int v4 = vec_ld(offset + 48, val); vector signed int v5 = vec_ld(offset + 64, val); vector signed int v12 = vec_perm(v1,v2,perm1); vector signed int v23 = vec_perm(v2,v3,perm1); vector signed int v34 = vec_perm(v3,v4,perm1); vector signed int v45 = vec_perm(v4,v5,perm1); vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19); vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(vA, vB); vector unsigned short vs2 = vec_packsu(vC, vD); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, i, dest); v1 = v5; } } else { // dest is properly aligned, great for (i = 0; i < (dstW - 15); i+=16) { int offset = i << 2; vector signed int v1 = vec_ld(offset, val); vector signed int v2 = vec_ld(offset + 16, val); vector signed int v3 = vec_ld(offset + 32, val); vector signed int v4 = vec_ld(offset + 48, val); vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19); vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19); vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19); vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(v5, v6); vector unsigned short vs2 = vec_packsu(v7, v8); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, i, dest); } } for ( ; i < dstW ; i++) { int t = val[i] >> 19; dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); } }
true
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW) { register int i; vector unsigned int altivec_vectorShiftInt19 = vec_add(vec_splat_u32(10),vec_splat_u32(9)); if ((unsigned long)dest % 16) { vector unsigned char perm1; vector signed int v1; for (i = 0 ; (i < dstW) && (((unsigned long)dest + i) % 16) ; i++) { int t = val[i] >> 19; dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); } perm1 = vec_lvsl(i << 2, val); v1 = vec_ld(i << 2, val); for ( ; i < (dstW - 15); i+=16) { int offset = i << 2; vector signed int v2 = vec_ld(offset + 16, val); vector signed int v3 = vec_ld(offset + 32, val); vector signed int v4 = vec_ld(offset + 48, val); vector signed int v5 = vec_ld(offset + 64, val); vector signed int v12 = vec_perm(v1,v2,perm1); vector signed int v23 = vec_perm(v2,v3,perm1); vector signed int v34 = vec_perm(v3,v4,perm1); vector signed int v45 = vec_perm(v4,v5,perm1); vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19); vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(vA, vB); vector unsigned short vs2 = vec_packsu(vC, vD); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, i, dest); v1 = v5; } } else { for (i = 0; i < (dstW - 15); i+=16) { int offset = i << 2; vector signed int v1 = vec_ld(offset, val); vector signed int v2 = vec_ld(offset + 16, val); vector signed int v3 = vec_ld(offset + 32, val); vector signed int v4 = vec_ld(offset + 48, val); vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19); vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19); vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19); vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(v5, v6); vector unsigned short vs2 = vec_packsu(v7, v8); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, i, dest); } } for ( ; i < dstW ; i++) { int t = val[i] >> 19; dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); } }
{ "code": [ " register int i;", " vector unsigned int altivec_vectorShiftInt19 =", " vec_add(vec_splat_u32(10),vec_splat_u32(9));", " if ((unsigned long)dest % 16) {", " vector unsigned char perm1;", " vector signed int v1;", " for (i = 0 ; (i < dstW) &&", "\t (((unsigned long)dest + i) % 16) ; i++) {", " int t = val[i] >> 19;", " dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);", " perm1 = vec_lvsl(i << 2, val);", " v1 = vec_ld(i << 2, val);", " for ( ; i < (dstW - 15); i+=16) {", " int offset = i << 2;", " vector signed int v2 = vec_ld(offset + 16, val);", " vector signed int v3 = vec_ld(offset + 32, val);", " vector signed int v4 = vec_ld(offset + 48, val);", " vector signed int v5 = vec_ld(offset + 64, val);", " vector signed int v12 = vec_perm(v1,v2,perm1);", " vector signed int v23 = vec_perm(v2,v3,perm1);", " vector signed int v34 = vec_perm(v3,v4,perm1);", " vector signed int v45 = vec_perm(v4,v5,perm1);", " vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19);", " vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19);", " vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19);", " vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19);", " vector unsigned short vs1 = vec_packsu(vA, vB);", " vector unsigned short vs2 = vec_packsu(vC, vD);", " vector unsigned char vf = vec_packsu(vs1, vs2);", " vec_st(vf, i, dest);", " v1 = v5;", " for (i = 0; i < (dstW - 15); i+=16) {", " int offset = i << 2;", " vector signed int v1 = vec_ld(offset, val);", " vector signed int v2 = vec_ld(offset + 16, val);", " vector signed int v3 = vec_ld(offset + 32, val);", " vector signed int v4 = vec_ld(offset + 48, val);", " vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19);", " vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19);", " vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19);", " vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19);", " vector unsigned short vs1 = vec_packsu(v5, v6);", " vector unsigned short vs2 = vec_packsu(v7, v8);", " vector unsigned char vf = vec_packsu(vs1, vs2);", " vec_st(vf, i, dest);", " for ( ; i < dstW ; i++) {", " int t = val[i] >> 19;", " dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);", " register int i;" ], "line_no": [ 3, 5, 7, 9, 15, 17, 19, 21, 23, 25, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 55, 57, 59, 61, 63, 65, 67, 69, 71, 77, 35, 81, 37, 39, 41, 89, 91, 93, 95, 97, 99, 67, 69, 109, 111, 113, 3 ] }
FUNC_0(int *VAR_0, uint8_t* VAR_1, int VAR_2) { register int VAR_3; vector unsigned int altivec_vectorShiftInt19 = vec_add(vec_splat_u32(10),vec_splat_u32(9)); if ((unsigned long)VAR_1 % 16) { vector unsigned char perm1; vector signed int v1; for (VAR_3 = 0 ; (VAR_3 < VAR_2) && (((unsigned long)VAR_1 + VAR_3) % 16) ; VAR_3++) { int VAR_5 = VAR_0[VAR_3] >> 19; VAR_1[VAR_3] = (VAR_5 < 0) ? 0 : ((VAR_5 > 255) ? 255 : VAR_5); } perm1 = vec_lvsl(VAR_3 << 2, VAR_0); v1 = vec_ld(VAR_3 << 2, VAR_0); for ( ; VAR_3 < (VAR_2 - 15); VAR_3+=16) { int VAR_5 = VAR_3 << 2; vector signed int v2 = vec_ld(VAR_5 + 16, VAR_0); vector signed int v3 = vec_ld(VAR_5 + 32, VAR_0); vector signed int v4 = vec_ld(VAR_5 + 48, VAR_0); vector signed int v5 = vec_ld(VAR_5 + 64, VAR_0); vector signed int v12 = vec_perm(v1,v2,perm1); vector signed int v23 = vec_perm(v2,v3,perm1); vector signed int v34 = vec_perm(v3,v4,perm1); vector signed int v45 = vec_perm(v4,v5,perm1); vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19); vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(vA, vB); vector unsigned short vs2 = vec_packsu(vC, vD); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, VAR_3, VAR_1); v1 = v5; } } else { for (VAR_3 = 0; VAR_3 < (VAR_2 - 15); VAR_3+=16) { int VAR_5 = VAR_3 << 2; vector signed int v1 = vec_ld(VAR_5, VAR_0); vector signed int v2 = vec_ld(VAR_5 + 16, VAR_0); vector signed int v3 = vec_ld(VAR_5 + 32, VAR_0); vector signed int v4 = vec_ld(VAR_5 + 48, VAR_0); vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19); vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19); vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19); vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19); vector unsigned short vs1 = vec_packsu(v5, v6); vector unsigned short vs2 = vec_packsu(v7, v8); vector unsigned char vf = vec_packsu(vs1, vs2); vec_st(vf, VAR_3, VAR_1); } } for ( ; VAR_3 < VAR_2 ; VAR_3++) { int VAR_5 = VAR_0[VAR_3] >> 19; VAR_1[VAR_3] = (VAR_5 < 0) ? 0 : ((VAR_5 > 255) ? 255 : VAR_5); } }
[ "FUNC_0(int *VAR_0, uint8_t* VAR_1, int VAR_2) {", "register int VAR_3;", "vector unsigned int altivec_vectorShiftInt19 =\nvec_add(vec_splat_u32(10),vec_splat_u32(9));", "if ((unsigned long)VAR_1 % 16) {", "vector unsigned char perm1;", "vector signed int v1;", "for (VAR_3 = 0 ; (VAR_3 < VAR_2) &&", "(((unsigned long)VAR_1 + VAR_3) % 16) ; VAR_3++) {", "int VAR_5 = VAR_0[VAR_3] >> 19;", "VAR_1[VAR_3] = (VAR_5 < 0) ? 0 : ((VAR_5 > 255) ? 255 : VAR_5);", "}", "perm1 = vec_lvsl(VAR_3 << 2, VAR_0);", "v1 = vec_ld(VAR_3 << 2, VAR_0);", "for ( ; VAR_3 < (VAR_2 - 15); VAR_3+=16) {", "int VAR_5 = VAR_3 << 2;", "vector signed int v2 = vec_ld(VAR_5 + 16, VAR_0);", "vector signed int v3 = vec_ld(VAR_5 + 32, VAR_0);", "vector signed int v4 = vec_ld(VAR_5 + 48, VAR_0);", "vector signed int v5 = vec_ld(VAR_5 + 64, VAR_0);", "vector signed int v12 = vec_perm(v1,v2,perm1);", "vector signed int v23 = vec_perm(v2,v3,perm1);", "vector signed int v34 = vec_perm(v3,v4,perm1);", "vector signed int v45 = vec_perm(v4,v5,perm1);", "vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19);", "vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19);", "vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19);", "vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19);", "vector unsigned short vs1 = vec_packsu(vA, vB);", "vector unsigned short vs2 = vec_packsu(vC, vD);", "vector unsigned char vf = vec_packsu(vs1, vs2);", "vec_st(vf, VAR_3, VAR_1);", "v1 = v5;", "}", "} else {", "for (VAR_3 = 0; VAR_3 < (VAR_2 - 15); VAR_3+=16) {", "int VAR_5 = VAR_3 << 2;", "vector signed int v1 = vec_ld(VAR_5, VAR_0);", "vector signed int v2 = vec_ld(VAR_5 + 16, VAR_0);", "vector signed int v3 = vec_ld(VAR_5 + 32, VAR_0);", "vector signed int v4 = vec_ld(VAR_5 + 48, VAR_0);", "vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19);", "vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19);", "vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19);", "vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19);", "vector unsigned short vs1 = vec_packsu(v5, v6);", "vector unsigned short vs2 = vec_packsu(v7, v8);", "vector unsigned char vf = vec_packsu(vs1, vs2);", "vec_st(vf, VAR_3, VAR_1);", "}", "}", "for ( ; VAR_3 < VAR_2 ; VAR_3++) {", "int VAR_5 = VAR_0[VAR_3] >> 19;", "VAR_1[VAR_3] = (VAR_5 < 0) ? 0 : ((VAR_5 > 255) ? 255 : VAR_5);", "}", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5, 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ] ]
11,589
static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev); /* * virtio pci bar layout used by default. * subclasses can re-arrange things if needed. * * region 0 -- virtio legacy io bar * region 1 -- msi-x bar * region 4+5 -- virtio modern memory (64bit) bar * */ proxy->legacy_io_bar = 0; proxy->msix_bar = 1; proxy->modern_io_bar = 2; proxy->modern_mem_bar = 4; proxy->common.offset = 0x0; proxy->common.size = 0x1000; proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; proxy->isr.offset = 0x1000; proxy->isr.size = 0x1000; proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; proxy->device.offset = 0x2000; proxy->device.size = 0x1000; proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; proxy->notify.offset = 0x3000; proxy->notify.size = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX; proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; proxy->notify_pio.offset = 0x0; proxy->notify_pio.size = 0x4; proxy->notify_pio.type = VIRTIO_PCI_CAP_NOTIFY_CFG; /* subclasses can enforce modern, so do this unconditionally */ memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); memory_region_init_alias(&proxy->modern_cfg, OBJECT(proxy), "virtio-pci-cfg", &proxy->modern_bar, 0, memory_region_size(&proxy->modern_bar)); address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as"); if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN) && pci_bus_is_express(pci_dev->bus) && !pci_bus_is_root(pci_dev->bus)) { int pos; pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; pos = pcie_endpoint_cap_init(pci_dev, 0); assert(pos > 0); pos = pci_add_capability(pci_dev, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF); assert(pos > 0); /* * Indicates that this function complies with revision 1.2 of the * PCI Power Management Interface Specification. */ pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3); } virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy); if (k->realize) { k->realize(proxy, errp); } }
true
qemu
0560b0e97df3da43651158c799c6d889f27529c3
static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev); proxy->legacy_io_bar = 0; proxy->msix_bar = 1; proxy->modern_io_bar = 2; proxy->modern_mem_bar = 4; proxy->common.offset = 0x0; proxy->common.size = 0x1000; proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; proxy->isr.offset = 0x1000; proxy->isr.size = 0x1000; proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; proxy->device.offset = 0x2000; proxy->device.size = 0x1000; proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; proxy->notify.offset = 0x3000; proxy->notify.size = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX; proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; proxy->notify_pio.offset = 0x0; proxy->notify_pio.size = 0x4; proxy->notify_pio.type = VIRTIO_PCI_CAP_NOTIFY_CFG; memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); memory_region_init_alias(&proxy->modern_cfg, OBJECT(proxy), "virtio-pci-cfg", &proxy->modern_bar, 0, memory_region_size(&proxy->modern_bar)); address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as"); if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN) && pci_bus_is_express(pci_dev->bus) && !pci_bus_is_root(pci_dev->bus)) { int pos; pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; pos = pcie_endpoint_cap_init(pci_dev, 0); assert(pos > 0); pos = pci_add_capability(pci_dev, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF); assert(pos > 0); pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3); } virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy); if (k->realize) { k->realize(proxy, errp); } }
{ "code": [ " if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE)", " && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)", " && pci_bus_is_express(pci_dev->bus)", " && !pci_bus_is_root(pci_dev->bus)) {", " pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;" ], "line_no": [ 109, 111, 113, 115, 121 ] }
static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0); VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(VAR_0); proxy->legacy_io_bar = 0; proxy->msix_bar = 1; proxy->modern_io_bar = 2; proxy->modern_mem_bar = 4; proxy->common.offset = 0x0; proxy->common.size = 0x1000; proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; proxy->isr.offset = 0x1000; proxy->isr.size = 0x1000; proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; proxy->device.offset = 0x2000; proxy->device.size = 0x1000; proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; proxy->notify.offset = 0x3000; proxy->notify.size = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX; proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; proxy->notify_pio.offset = 0x0; proxy->notify_pio.size = 0x4; proxy->notify_pio.type = VIRTIO_PCI_CAP_NOTIFY_CFG; memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); memory_region_init_alias(&proxy->modern_cfg, OBJECT(proxy), "virtio-pci-cfg", &proxy->modern_bar, 0, memory_region_size(&proxy->modern_bar)); address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as"); if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN) && pci_bus_is_express(VAR_0->bus) && !pci_bus_is_root(VAR_0->bus)) { int VAR_2; VAR_0->cap_present |= QEMU_PCI_CAP_EXPRESS; VAR_2 = pcie_endpoint_cap_init(VAR_0, 0); assert(VAR_2 > 0); VAR_2 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF); assert(VAR_2 > 0); pci_set_word(VAR_0->config + VAR_2 + PCI_PM_PMC, 0x3); } virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy); if (k->realize) { k->realize(proxy, VAR_1); } }
[ "static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);", "VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(VAR_0);", "proxy->legacy_io_bar = 0;", "proxy->msix_bar = 1;", "proxy->modern_io_bar = 2;", "proxy->modern_mem_bar = 4;", "proxy->common.offset = 0x0;", "proxy->common.size = 0x1000;", "proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG;", "proxy->isr.offset = 0x1000;", "proxy->isr.size = 0x1000;", "proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG;", "proxy->device.offset = 0x2000;", "proxy->device.size = 0x1000;", "proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG;", "proxy->notify.offset = 0x3000;", "proxy->notify.size =\nQEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX;", "proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG;", "proxy->notify_pio.offset = 0x0;", "proxy->notify_pio.size = 0x4;", "proxy->notify_pio.type = VIRTIO_PCI_CAP_NOTIFY_CFG;", "memory_region_init(&proxy->modern_bar, OBJECT(proxy), \"virtio-pci\",\n2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *\nVIRTIO_QUEUE_MAX);", "memory_region_init_alias(&proxy->modern_cfg,\nOBJECT(proxy),\n\"virtio-pci-cfg\",\n&proxy->modern_bar,\n0,\nmemory_region_size(&proxy->modern_bar));", "address_space_init(&proxy->modern_as, &proxy->modern_cfg, \"virtio-pci-cfg-as\");", "if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE)\n&& !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)\n&& pci_bus_is_express(VAR_0->bus)\n&& !pci_bus_is_root(VAR_0->bus)) {", "int VAR_2;", "VAR_0->cap_present |= QEMU_PCI_CAP_EXPRESS;", "VAR_2 = pcie_endpoint_cap_init(VAR_0, 0);", "assert(VAR_2 > 0);", "VAR_2 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF);", "assert(VAR_2 > 0);", "pci_set_word(VAR_0->config + VAR_2 + PCI_PM_PMC, 0x3);", "}", "virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy);", "if (k->realize) {", "k->realize(proxy, VAR_1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 83, 85, 87 ], [ 91, 93, 95, 97, 99, 101 ], [ 105 ], [ 109, 111, 113, 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ] ]
11,590
static HTTPContext *find_rtp_session_with_url(const char *url, const char *session_id) { HTTPContext *rtp_c; char path1[1024]; const char *path; char buf[1024]; int s; rtp_c = find_rtp_session(session_id); if (!rtp_c) return NULL; /* find which url is asked */ url_split(NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; if(!strcmp(path, rtp_c->stream->filename)) return rtp_c; for(s=0; s<rtp_c->stream->nb_streams; ++s) { snprintf(buf, sizeof(buf), "%s/streamid=%d", rtp_c->stream->filename, s); if(!strncmp(path, buf, sizeof(buf))) { // XXX: Should we reply with RTSP_STATUS_ONLY_AGGREGATE if nb_streams>1? return rtp_c; } } return NULL; }
false
FFmpeg
6ba5cbc699e77cae66bb719354fa142114b64eab
static HTTPContext *find_rtp_session_with_url(const char *url, const char *session_id) { HTTPContext *rtp_c; char path1[1024]; const char *path; char buf[1024]; int s; rtp_c = find_rtp_session(session_id); if (!rtp_c) return NULL; url_split(NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; if(!strcmp(path, rtp_c->stream->filename)) return rtp_c; for(s=0; s<rtp_c->stream->nb_streams; ++s) { snprintf(buf, sizeof(buf), "%s/streamid=%d", rtp_c->stream->filename, s); if(!strncmp(path, buf, sizeof(buf))) { return rtp_c; } } return NULL; }
{ "code": [], "line_no": [] }
static HTTPContext *FUNC_0(const char *url, const char *session_id) { HTTPContext *rtp_c; char VAR_0[1024]; const char *VAR_1; char VAR_2[1024]; int VAR_3; rtp_c = find_rtp_session(session_id); if (!rtp_c) return NULL; url_split(NULL, 0, NULL, 0, NULL, VAR_0, sizeof(VAR_0), url); VAR_1 = VAR_0; if (*VAR_1 == '/') VAR_1++; if(!strcmp(VAR_1, rtp_c->stream->filename)) return rtp_c; for(VAR_3=0; VAR_3<rtp_c->stream->nb_streams; ++VAR_3) { snprintf(VAR_2, sizeof(VAR_2), "%VAR_3/streamid=%d", rtp_c->stream->filename, VAR_3); if(!strncmp(VAR_1, VAR_2, sizeof(VAR_2))) { return rtp_c; } } return NULL; }
[ "static HTTPContext *FUNC_0(const char *url,\nconst char *session_id)\n{", "HTTPContext *rtp_c;", "char VAR_0[1024];", "const char *VAR_1;", "char VAR_2[1024];", "int VAR_3;", "rtp_c = find_rtp_session(session_id);", "if (!rtp_c)\nreturn NULL;", "url_split(NULL, 0, NULL, 0, NULL, VAR_0, sizeof(VAR_0), url);", "VAR_1 = VAR_0;", "if (*VAR_1 == '/')\nVAR_1++;", "if(!strcmp(VAR_1, rtp_c->stream->filename)) return rtp_c;", "for(VAR_3=0; VAR_3<rtp_c->stream->nb_streams; ++VAR_3) {", "snprintf(VAR_2, sizeof(VAR_2), \"%VAR_3/streamid=%d\",\nrtp_c->stream->filename, VAR_3);", "if(!strncmp(VAR_1, VAR_2, sizeof(VAR_2))) {", "return rtp_c;", "}", "}", "return NULL;", "}" ]
[ 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 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
11,591
static void write_header(FFV1Context *f) { uint8_t state[CONTEXT_SIZE]; int i, j; RangeCoder *const c = &f->slice_context[0]->c; memset(state, 128, sizeof(state)); if (f->version < 2) { put_symbol(c, state, f->version, 0); put_symbol(c, state, f->ac, 0); if (f->ac > 1) { for (i = 1; i < 256; i++) put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1); } put_symbol(c, state, f->colorspace, 0); // YUV cs type if (f->version > 0) put_symbol(c, state, f->bits_per_raw_sample, 0); put_rac(c, state, f->chroma_planes); put_symbol(c, state, f->chroma_h_shift, 0); put_symbol(c, state, f->chroma_v_shift, 0); put_rac(c, state, f->transparency); write_quant_tables(c, f->quant_table); } else if (f->version < 3) { put_symbol(c, state, f->slice_count, 0); for (i = 0; i < f->slice_count; i++) { FFV1Context *fs = f->slice_context[i]; put_symbol(c, state, (fs->slice_x + 1) * f->num_h_slices / f->width, 0); put_symbol(c, state, (fs->slice_y + 1) * f->num_v_slices / f->height, 0); put_symbol(c, state, (fs->slice_width + 1) * f->num_h_slices / f->width - 1, 0); put_symbol(c, state, (fs->slice_height + 1) * f->num_v_slices / f->height - 1, 0); for (j = 0; j < f->plane_count; j++) { put_symbol(c, state, f->plane[j].quant_table_index, 0); av_assert0(f->plane[j].quant_table_index == f->avctx->context_model); } } } }
false
FFmpeg
4bb1070c154e49d35805fbcdac9c9e92f702ef96
static void write_header(FFV1Context *f) { uint8_t state[CONTEXT_SIZE]; int i, j; RangeCoder *const c = &f->slice_context[0]->c; memset(state, 128, sizeof(state)); if (f->version < 2) { put_symbol(c, state, f->version, 0); put_symbol(c, state, f->ac, 0); if (f->ac > 1) { for (i = 1; i < 256; i++) put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1); } put_symbol(c, state, f->colorspace, 0); if (f->version > 0) put_symbol(c, state, f->bits_per_raw_sample, 0); put_rac(c, state, f->chroma_planes); put_symbol(c, state, f->chroma_h_shift, 0); put_symbol(c, state, f->chroma_v_shift, 0); put_rac(c, state, f->transparency); write_quant_tables(c, f->quant_table); } else if (f->version < 3) { put_symbol(c, state, f->slice_count, 0); for (i = 0; i < f->slice_count; i++) { FFV1Context *fs = f->slice_context[i]; put_symbol(c, state, (fs->slice_x + 1) * f->num_h_slices / f->width, 0); put_symbol(c, state, (fs->slice_y + 1) * f->num_v_slices / f->height, 0); put_symbol(c, state, (fs->slice_width + 1) * f->num_h_slices / f->width - 1, 0); put_symbol(c, state, (fs->slice_height + 1) * f->num_v_slices / f->height - 1, 0); for (j = 0; j < f->plane_count; j++) { put_symbol(c, state, f->plane[j].quant_table_index, 0); av_assert0(f->plane[j].quant_table_index == f->avctx->context_model); } } } }
{ "code": [], "line_no": [] }
static void FUNC_0(FFV1Context *VAR_0) { uint8_t state[CONTEXT_SIZE]; int VAR_1, VAR_2; RangeCoder *const c = &VAR_0->slice_context[0]->c; memset(state, 128, sizeof(state)); if (VAR_0->version < 2) { put_symbol(c, state, VAR_0->version, 0); put_symbol(c, state, VAR_0->ac, 0); if (VAR_0->ac > 1) { for (VAR_1 = 1; VAR_1 < 256; VAR_1++) put_symbol(c, state, VAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1); } put_symbol(c, state, VAR_0->colorspace, 0); if (VAR_0->version > 0) put_symbol(c, state, VAR_0->bits_per_raw_sample, 0); put_rac(c, state, VAR_0->chroma_planes); put_symbol(c, state, VAR_0->chroma_h_shift, 0); put_symbol(c, state, VAR_0->chroma_v_shift, 0); put_rac(c, state, VAR_0->transparency); write_quant_tables(c, VAR_0->quant_table); } else if (VAR_0->version < 3) { put_symbol(c, state, VAR_0->slice_count, 0); for (VAR_1 = 0; VAR_1 < VAR_0->slice_count; VAR_1++) { FFV1Context *fs = VAR_0->slice_context[VAR_1]; put_symbol(c, state, (fs->slice_x + 1) * VAR_0->num_h_slices / VAR_0->width, 0); put_symbol(c, state, (fs->slice_y + 1) * VAR_0->num_v_slices / VAR_0->height, 0); put_symbol(c, state, (fs->slice_width + 1) * VAR_0->num_h_slices / VAR_0->width - 1, 0); put_symbol(c, state, (fs->slice_height + 1) * VAR_0->num_v_slices / VAR_0->height - 1, 0); for (VAR_2 = 0; VAR_2 < VAR_0->plane_count; VAR_2++) { put_symbol(c, state, VAR_0->plane[VAR_2].quant_table_index, 0); av_assert0(VAR_0->plane[VAR_2].quant_table_index == VAR_0->avctx->context_model); } } } }
[ "static void FUNC_0(FFV1Context *VAR_0)\n{", "uint8_t state[CONTEXT_SIZE];", "int VAR_1, VAR_2;", "RangeCoder *const c = &VAR_0->slice_context[0]->c;", "memset(state, 128, sizeof(state));", "if (VAR_0->version < 2) {", "put_symbol(c, state, VAR_0->version, 0);", "put_symbol(c, state, VAR_0->ac, 0);", "if (VAR_0->ac > 1) {", "for (VAR_1 = 1; VAR_1 < 256; VAR_1++)", "put_symbol(c, state,\nVAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1);", "}", "put_symbol(c, state, VAR_0->colorspace, 0);", "if (VAR_0->version > 0)\nput_symbol(c, state, VAR_0->bits_per_raw_sample, 0);", "put_rac(c, state, VAR_0->chroma_planes);", "put_symbol(c, state, VAR_0->chroma_h_shift, 0);", "put_symbol(c, state, VAR_0->chroma_v_shift, 0);", "put_rac(c, state, VAR_0->transparency);", "write_quant_tables(c, VAR_0->quant_table);", "} else if (VAR_0->version < 3) {", "put_symbol(c, state, VAR_0->slice_count, 0);", "for (VAR_1 = 0; VAR_1 < VAR_0->slice_count; VAR_1++) {", "FFV1Context *fs = VAR_0->slice_context[VAR_1];", "put_symbol(c, state,\n(fs->slice_x + 1) * VAR_0->num_h_slices / VAR_0->width, 0);", "put_symbol(c, state,\n(fs->slice_y + 1) * VAR_0->num_v_slices / VAR_0->height, 0);", "put_symbol(c, state,\n(fs->slice_width + 1) * VAR_0->num_h_slices / VAR_0->width - 1,\n0);", "put_symbol(c, state,\n(fs->slice_height + 1) * VAR_0->num_v_slices / VAR_0->height - 1,\n0);", "for (VAR_2 = 0; VAR_2 < VAR_0->plane_count; VAR_2++) {", "put_symbol(c, state, VAR_0->plane[VAR_2].quant_table_index, 0);", "av_assert0(VAR_0->plane[VAR_2].quant_table_index == VAR_0->avctx->context_model);", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63, 65 ], [ 67, 69, 71 ], [ 73, 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ] ]
11,593
static void __attribute__((constructor)) init_main_loop(void) { init_clocks(); init_timer_alarm(); qemu_clock_enable(vm_clock, false); }
false
qemu
d34e8f6e9d3a396c3327aa9807c83f9e1f4a7bd7
static void __attribute__((constructor)) init_main_loop(void) { init_clocks(); init_timer_alarm(); qemu_clock_enable(vm_clock, false); }
{ "code": [], "line_no": [] }
static void __attribute__((constructor)) FUNC_0(void) { init_clocks(); init_timer_alarm(); qemu_clock_enable(vm_clock, false); }
[ "static void __attribute__((constructor)) FUNC_0(void)\n{", "init_clocks();", "init_timer_alarm();", "qemu_clock_enable(vm_clock, false);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
11,594
static unsigned tget_long(const uint8_t **p, int le) { unsigned v = le ? AV_RL32(*p) : AV_RB32(*p); *p += 4; return v; }
false
FFmpeg
1ec83d9a9e472f485897ac92bad9631d551a8c5b
static unsigned tget_long(const uint8_t **p, int le) { unsigned v = le ? AV_RL32(*p) : AV_RB32(*p); *p += 4; return v; }
{ "code": [], "line_no": [] }
static unsigned FUNC_0(const uint8_t **VAR_0, int VAR_1) { unsigned VAR_2 = VAR_1 ? AV_RL32(*VAR_0) : AV_RB32(*VAR_0); *VAR_0 += 4; return VAR_2; }
[ "static unsigned FUNC_0(const uint8_t **VAR_0, int VAR_1)\n{", "unsigned VAR_2 = VAR_1 ? AV_RL32(*VAR_0) : AV_RB32(*VAR_0);", "*VAR_0 += 4;", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
11,596
tcp_input(struct mbuf *m, int iphlen, struct socket *inso) { struct ip save_ip, *ip; register struct tcpiphdr *ti; caddr_t optp = NULL; int optlen = 0; int len, tlen, off; register struct tcpcb *tp = NULL; register int tiflags; struct socket *so = NULL; int todrop, acked, ourfinisacked, needoutput = 0; int iss = 0; u_long tiwin; int ret; struct ex_list *ex_ptr; Slirp *slirp; DEBUG_CALL("tcp_input"); DEBUG_ARGS((dfd, " m = %8lx iphlen = %2d inso = %lx\n", (long )m, iphlen, (long )inso )); /* * If called with m == 0, then we're continuing the connect */ if (m == NULL) { so = inso; slirp = so->slirp; /* Re-set a few variables */ tp = sototcpcb(so); m = so->so_m; so->so_m = NULL; ti = so->so_ti; tiwin = ti->ti_win; tiflags = ti->ti_flags; goto cont_conn; } slirp = m->slirp; /* * Get IP and TCP header together in first mbuf. * Note: IP leaves IP header in first mbuf. */ ti = mtod(m, struct tcpiphdr *); if (iphlen > sizeof(struct ip )) { ip_stripoptions(m, (struct mbuf *)0); iphlen=sizeof(struct ip ); } /* XXX Check if too short */ /* * Save a copy of the IP header in case we want restore it * for sending an ICMP error message in response. */ ip=mtod(m, struct ip *); save_ip = *ip; save_ip.ip_len+= iphlen; /* * Checksum extended TCP header and data. */ tlen = ((struct ip *)ti)->ip_len; tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL; memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); ti->ti_x1 = 0; ti->ti_len = htons((uint16_t)tlen); len = sizeof(struct ip ) + tlen; if(cksum(m, len)) { goto drop; } /* * Check that TCP offset makes sense, * pull out TCP options and adjust length. XXX */ off = ti->ti_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { goto drop; } tlen -= off; ti->ti_len = tlen; if (off > sizeof (struct tcphdr)) { optlen = off - sizeof (struct tcphdr); optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr); } tiflags = ti->ti_flags; /* * Convert TCP protocol specific fields to host format. */ NTOHL(ti->ti_seq); NTOHL(ti->ti_ack); NTOHS(ti->ti_win); NTOHS(ti->ti_urp); /* * Drop TCP, IP headers and TCP options. */ m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); if (slirp->restricted) { for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_fport == ti->ti_dport && ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) { break; } } if (!ex_ptr) goto drop; } /* * Locate pcb for segment. */ findso: so = slirp->tcp_last_so; if (so->so_fport != ti->ti_dport || so->so_lport != ti->ti_sport || so->so_laddr.s_addr != ti->ti_src.s_addr || so->so_faddr.s_addr != ti->ti_dst.s_addr) { so = solookup(&slirp->tcb, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); if (so) slirp->tcp_last_so = so; } /* * If the state is CLOSED (i.e., TCB does not exist) then * all data in the incoming segment is discarded. * If the TCB exists but is in CLOSED state, it is embryonic, * but should either do a listen or a connect soon. * * state == CLOSED means we've done socreate() but haven't * attached it to a protocol yet... * * XXX If a TCB does not exist, and the TH_SYN flag is * the only flag set, then create a session, mark it * as if it was LISTENING, and continue... */ if (so == NULL) { if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN) goto dropwithreset; if ((so = socreate(slirp)) == NULL) goto dropwithreset; if (tcp_attach(so) < 0) { free(so); /* Not sofree (if it failed, it's not insqued) */ goto dropwithreset; } sbreserve(&so->so_snd, TCP_SNDSPACE); sbreserve(&so->so_rcv, TCP_RCVSPACE); so->so_laddr = ti->ti_src; so->so_lport = ti->ti_sport; so->so_faddr = ti->ti_dst; so->so_fport = ti->ti_dport; if ((so->so_iptos = tcp_tos(so)) == 0) so->so_iptos = ((struct ip *)ti)->ip_tos; tp = sototcpcb(so); tp->t_state = TCPS_LISTEN; } /* * If this is a still-connecting socket, this probably * a retransmit of the SYN. Whether it's a retransmit SYN * or something else, we nuke it. */ if (so->so_state & SS_ISFCONNECTING) goto drop; tp = sototcpcb(so); /* XXX Should never fail */ if (tp == NULL) goto dropwithreset; if (tp->t_state == TCPS_CLOSED) goto drop; tiwin = ti->ti_win; /* * Segment received on connection. * Reset idle time and keep-alive timer. */ tp->t_idle = 0; if (SO_OPTIONS) tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; else tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE; /* * Process options if not in LISTEN state, * else do it below (after getting remote address). */ if (optp && tp->t_state != TCPS_LISTEN) tcp_dooptions(tp, (u_char *)optp, optlen, ti); /* * Header prediction: check for the two common cases * of a uni-directional data xfer. If the packet has * no control flags, is in-sequence, the window didn't * change and we're not retransmitting, it's a * candidate. If the length is zero and the ack moved * forward, we're the sender side of the xfer. Just * free the data acked & wake any higher level process * that was blocked waiting for space. If the length * is non-zero and the ack didn't move, we're the * receiver side. If we're getting packets in-order * (the reassembly queue is empty), add the data to * the socket buffer and note that we need a delayed ack. * * XXX Some of these tests are not needed * eg: the tiwin == tp->snd_wnd prevents many more * predictions.. with no *real* advantage.. */ if (tp->t_state == TCPS_ESTABLISHED && (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK && ti->ti_seq == tp->rcv_nxt && tiwin && tiwin == tp->snd_wnd && tp->snd_nxt == tp->snd_max) { if (ti->ti_len == 0) { if (SEQ_GT(ti->ti_ack, tp->snd_una) && SEQ_LEQ(ti->ti_ack, tp->snd_max) && tp->snd_cwnd >= tp->snd_wnd) { /* * this is a pure ack for outstanding data. */ if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; sbdrop(&so->so_snd, acked); tp->snd_una = ti->ti_ack; m_free(m); /* * If all outstanding data are acked, stop * retransmit timer, otherwise restart timer * using current (possibly backed-off) value. * If process is waiting for space, * wakeup/selwakeup/signal. If data * are ready to send, let tcp_output * decide between more output or persist. */ if (tp->snd_una == tp->snd_max) tp->t_timer[TCPT_REXMT] = 0; else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; /* * This is called because sowwakeup might have * put data into so_snd. Since we don't so sowwakeup, * we don't need this.. XXX??? */ if (so->so_snd.sb_cc) (void) tcp_output(tp); return; } } else if (ti->ti_ack == tp->snd_una && tcpfrag_list_empty(tp) && ti->ti_len <= sbspace(&so->so_rcv)) { /* * this is a pure, in-sequence data packet * with nothing on the reassembly queue and * we have enough buffer space to take it. */ tp->rcv_nxt += ti->ti_len; /* * Add data to socket buffer. */ if (so->so_emu) { if (tcp_emu(so,m)) sbappend(so, m); } else sbappend(so, m); /* * If this is a short packet, then ACK now - with Nagel * congestion avoidance sender won't send more until * he gets an ACK. * * It is better to not delay acks at all to maximize * TCP throughput. See RFC 2581. */ tp->t_flags |= TF_ACKNOW; tcp_output(tp); return; } } /* header prediction */ /* * Calculate amount of space in receive window, * and then do TCP input processing. * Receive window is amount of space in rcv queue, * but not less than advertised window. */ { int win; win = sbspace(&so->so_rcv); if (win < 0) win = 0; tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt)); } switch (tp->t_state) { /* * If the state is LISTEN then ignore segment if it contains an RST. * If the segment contains an ACK then it is bad and send a RST. * If it does not contain a SYN then it is not interesting; drop it. * Don't bother responding if the destination was a broadcast. * Otherwise initialize tp->rcv_nxt, and tp->irs, select an initial * tp->iss, and send a segment: * <SEQ=ISS><ACK=RCV_NXT><CTL=SYN,ACK> * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss. * Fill in remote peer address fields if not previously specified. * Enter SYN_RECEIVED state, and process any other fields of this * segment in this state. */ case TCPS_LISTEN: { if (tiflags & TH_RST) goto drop; if (tiflags & TH_ACK) goto dropwithreset; if ((tiflags & TH_SYN) == 0) goto drop; /* * This has way too many gotos... * But a bit of spaghetti code never hurt anybody :) */ /* * If this is destined for the control address, then flag to * tcp_ctl once connected, otherwise connect */ if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == slirp->vnetwork_addr.s_addr) { if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr && so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) { /* May be an add exec */ for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if(ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { so->so_state |= SS_CTL; break; } } if (so->so_state & SS_CTL) { goto cont_input; } } /* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */ } if (so->so_emu & EMU_NOCONNECT) { so->so_emu &= ~EMU_NOCONNECT; goto cont_input; } if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { u_char code=ICMP_UNREACH_NET; DEBUG_MISC((dfd, " tcp fconnect errno = %d-%s\n", errno,strerror(errno))); if(errno == ECONNREFUSED) { /* ACK the SYN, send RST to refuse the connection */ tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0, TH_RST|TH_ACK); } else { if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; HTONL(ti->ti_seq); /* restore tcp header */ HTONL(ti->ti_ack); HTONS(ti->ti_win); HTONS(ti->ti_urp); m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); *ip=save_ip; icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno)); } tcp_close(tp); m_free(m); } else { /* * Haven't connected yet, save the current mbuf * and ti, and return * XXX Some OS's don't tell us whether the connect() * succeeded or not. So we must time it out. */ so->so_m = m; so->so_ti = ti; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; tp->t_state = TCPS_SYN_RECEIVED; tcp_template(tp); } return; cont_conn: /* m==NULL * Check if the connect succeeded */ if (so->so_state & SS_NOFDREF) { tp = tcp_close(tp); goto dropwithreset; } cont_input: tcp_template(tp); if (optp) tcp_dooptions(tp, (u_char *)optp, optlen, ti); if (iss) tp->iss = iss; else tp->iss = slirp->tcp_iss; slirp->tcp_iss += TCP_ISSINCR/2; tp->irs = ti->ti_seq; tcp_sendseqinit(tp); tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; tp->t_state = TCPS_SYN_RECEIVED; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; goto trimthenstep6; } /* case TCPS_LISTEN */ /* * If the state is SYN_SENT: * if seg contains an ACK, but not for our SYN, drop the input. * if seg contains a RST, then drop the connection. * if seg does not contain SYN, then drop it. * Otherwise this is an acceptable SYN segment * initialize tp->rcv_nxt and tp->irs * if seg contains ack then advance tp->snd_una * if SYN has been acked change to ESTABLISHED else SYN_RCVD state * arrange for segment to be acked (eventually) * continue processing rest of data/controls, beginning with URG */ case TCPS_SYN_SENT: if ((tiflags & TH_ACK) && (SEQ_LEQ(ti->ti_ack, tp->iss) || SEQ_GT(ti->ti_ack, tp->snd_max))) goto dropwithreset; if (tiflags & TH_RST) { if (tiflags & TH_ACK) { tcp_drop(tp, 0); /* XXX Check t_softerror! */ } goto drop; } if ((tiflags & TH_SYN) == 0) goto drop; if (tiflags & TH_ACK) { tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; } tp->t_timer[TCPT_REXMT] = 0; tp->irs = ti->ti_seq; tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { soisfconnected(so); tp->t_state = TCPS_ESTABLISHED; (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); /* * if we didn't have to retransmit the SYN, * use its rtt as our initial srtt & rtt var. */ if (tp->t_rtt) tcp_xmit_timer(tp, tp->t_rtt); } else tp->t_state = TCPS_SYN_RECEIVED; trimthenstep6: /* * Advance ti->ti_seq to correspond to first data byte. * If data, trim to stay within window, * dropping FIN if necessary. */ ti->ti_seq++; if (ti->ti_len > tp->rcv_wnd) { todrop = ti->ti_len - tp->rcv_wnd; m_adj(m, -todrop); ti->ti_len = tp->rcv_wnd; tiflags &= ~TH_FIN; } tp->snd_wl1 = ti->ti_seq - 1; tp->rcv_up = ti->ti_seq; goto step6; } /* switch tp->t_state */ /* * States other than LISTEN or SYN_SENT. * Check that at least some bytes of segment are within * receive window. If segment begins before rcv_nxt, * drop leading data (and SYN); if nothing left, just ack. */ todrop = tp->rcv_nxt - ti->ti_seq; if (todrop > 0) { if (tiflags & TH_SYN) { tiflags &= ~TH_SYN; ti->ti_seq++; if (ti->ti_urp > 1) ti->ti_urp--; else tiflags &= ~TH_URG; todrop--; } /* * Following if statement from Stevens, vol. 2, p. 960. */ if (todrop > ti->ti_len || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) { /* * Any valid FIN must be to the left of the window. * At this point the FIN must be a duplicate or out * of sequence; drop it. */ tiflags &= ~TH_FIN; /* * Send an ACK to resynchronize and drop any data. * But keep on processing for RST or ACK. */ tp->t_flags |= TF_ACKNOW; todrop = ti->ti_len; } m_adj(m, todrop); ti->ti_seq += todrop; ti->ti_len -= todrop; if (ti->ti_urp > todrop) ti->ti_urp -= todrop; else { tiflags &= ~TH_URG; ti->ti_urp = 0; } } /* * If new data are received on a connection after the * user processes are gone, then RST the other end. */ if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { tp = tcp_close(tp); goto dropwithreset; } /* * If segment ends after window, drop trailing data * (and PUSH and FIN); if nothing left, just ACK. */ todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); if (todrop > 0) { if (todrop >= ti->ti_len) { /* * If a new connection request is received * while in TIME_WAIT, drop the old connection * and start over if the sequence numbers * are above the previous ones. */ if (tiflags & TH_SYN && tp->t_state == TCPS_TIME_WAIT && SEQ_GT(ti->ti_seq, tp->rcv_nxt)) { iss = tp->rcv_nxt + TCP_ISSINCR; tp = tcp_close(tp); goto findso; } /* * If window is closed can only take segments at * window edge, and have to drop data and PUSH from * incoming segments. Continue processing, but * remember to ack. Otherwise, drop segment * and ack. */ if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; } else { goto dropafterack; } } m_adj(m, -todrop); ti->ti_len -= todrop; tiflags &= ~(TH_PUSH|TH_FIN); } /* * If the RST bit is set examine the state: * SYN_RECEIVED STATE: * If passive open, return to LISTEN state. * If active open, inform user that connection was refused. * ESTABLISHED, FIN_WAIT_1, FIN_WAIT2, CLOSE_WAIT STATES: * Inform user that connection was reset, and close tcb. * CLOSING, LAST_ACK, TIME_WAIT STATES * Close the tcb. */ if (tiflags&TH_RST) switch (tp->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: tp->t_state = TCPS_CLOSED; tcp_close(tp); goto drop; case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: tcp_close(tp); goto drop; } /* * If a SYN is in the window, then this is an * error and we send an RST and drop the connection. */ if (tiflags & TH_SYN) { tp = tcp_drop(tp,0); goto dropwithreset; } /* * If the ACK bit is off we drop the segment and return. */ if ((tiflags & TH_ACK) == 0) goto drop; /* * Ack processing. */ switch (tp->t_state) { /* * In SYN_RECEIVED state if the ack ACKs our SYN then enter * ESTABLISHED state and continue processing, otherwise * send an RST. una<=ack<=max */ case TCPS_SYN_RECEIVED: if (SEQ_GT(tp->snd_una, ti->ti_ack) || SEQ_GT(ti->ti_ack, tp->snd_max)) goto dropwithreset; tp->t_state = TCPS_ESTABLISHED; /* * The sent SYN is ack'ed with our sequence number +1 * The first data byte already in the buffer will get * lost if no correction is made. This is only needed for * SS_CTL since the buffer is empty otherwise. * tp->snd_una++; or: */ tp->snd_una=ti->ti_ack; if (so->so_state & SS_CTL) { /* So tcp_ctl reports the right state */ ret = tcp_ctl(so); if (ret == 1) { soisfconnected(so); so->so_state &= ~SS_CTL; /* success XXX */ } else if (ret == 2) { so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; /* CTL_CMD */ } else { needoutput = 1; tp->t_state = TCPS_FIN_WAIT_1; } } else { soisfconnected(so); } (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); tp->snd_wl1 = ti->ti_seq - 1; /* Avoid ack processing; snd_una==ti_ack => dup ack */ goto synrx_to_est; /* fall into ... */ /* * In ESTABLISHED state: drop duplicate ACKs; ACK out of range * ACKs. If the ack is in the range * tp->snd_una < ti->ti_ack <= tp->snd_max * then advance tp->snd_una to ti->ti_ack and drop * data from the retransmission queue. If this ACK reflects * more up to date window information we update our window information. */ case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { DEBUG_MISC((dfd, " dup ack m = %lx so = %lx\n", (long )m, (long )so)); /* * If we have outstanding data (other than * a window probe), this is a completely * duplicate ack (ie, window info didn't * change), the ack is the biggest we've * seen and we've seen exactly our rexmt * threshold of them, assume a packet * has been dropped and retransmit it. * Kludge snd_nxt & the congestion * window so we send only this one * packet. * * We know we're losing at the current * window size so do congestion avoidance * (set ssthresh to half the current window * and pull our congestion window back to * the new ssthresh). * * Dup acks mean that packets have left the * network (they're now cached at the receiver) * so bump cwnd by the amount in the receiver * to keep a constant cwnd packets in the * network. */ if (tp->t_timer[TCPT_REXMT] == 0 || ti->ti_ack != tp->snd_una) tp->t_dupacks = 0; else if (++tp->t_dupacks == TCPREXMTTHRESH) { tcp_seq onxt = tp->snd_nxt; u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; if (win < 2) win = 2; tp->snd_ssthresh = win * tp->t_maxseg; tp->t_timer[TCPT_REXMT] = 0; tp->t_rtt = 0; tp->snd_nxt = ti->ti_ack; tp->snd_cwnd = tp->t_maxseg; (void) tcp_output(tp); tp->snd_cwnd = tp->snd_ssthresh + tp->t_maxseg * tp->t_dupacks; if (SEQ_GT(onxt, tp->snd_nxt)) tp->snd_nxt = onxt; goto drop; } else if (tp->t_dupacks > TCPREXMTTHRESH) { tp->snd_cwnd += tp->t_maxseg; (void) tcp_output(tp); goto drop; } } else tp->t_dupacks = 0; break; } synrx_to_est: /* * If the congestion window was inflated to account * for the other side's cached packets, retract it. */ if (tp->t_dupacks > TCPREXMTTHRESH && tp->snd_cwnd > tp->snd_ssthresh) tp->snd_cwnd = tp->snd_ssthresh; tp->t_dupacks = 0; if (SEQ_GT(ti->ti_ack, tp->snd_max)) { goto dropafterack; } acked = ti->ti_ack - tp->snd_una; /* * If transmit timer is running and timed sequence * number was acked, update smoothed round trip time. * Since we now have an rtt measurement, cancel the * timer backoff (cf., Phil Karn's retransmit alg.). * Recompute the initial retransmit timer. */ if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp,tp->t_rtt); /* * If all outstanding data is acked, stop retransmit * timer and remember to restart (more output or persist). * If there is more data to be acked, restart retransmit * timer, using current (possibly backed-off) value. */ if (ti->ti_ack == tp->snd_max) { tp->t_timer[TCPT_REXMT] = 0; needoutput = 1; } else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; /* * When new data is acked, open the congestion window. * If the window gives us less than ssthresh packets * in flight, open exponentially (maxseg per packet). * Otherwise open linearly: maxseg per window * (maxseg^2 / cwnd per packet). */ { register u_int cw = tp->snd_cwnd; register u_int incr = tp->t_maxseg; if (cw > tp->snd_ssthresh) incr = incr * incr / cw; tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale); } if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; sbdrop(&so->so_snd, (int )so->so_snd.sb_cc); ourfinisacked = 1; } else { sbdrop(&so->so_snd, acked); tp->snd_wnd -= acked; ourfinisacked = 0; } tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; switch (tp->t_state) { /* * In FIN_WAIT_1 STATE in addition to the processing * for the ESTABLISHED state if our FIN is now acknowledged * then enter FIN_WAIT_2. */ case TCPS_FIN_WAIT_1: if (ourfinisacked) { /* * If we can't receive any more * data, then closing user can proceed. * Starting the timer is contrary to the * specification, but if we don't get a FIN * we'll hang forever. */ if (so->so_state & SS_FCANTRCVMORE) { tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE; } tp->t_state = TCPS_FIN_WAIT_2; } break; /* * In CLOSING STATE in addition to the processing for * the ESTABLISHED state if the ACK acknowledges our FIN * then enter the TIME-WAIT state, otherwise ignore * the segment. */ case TCPS_CLOSING: if (ourfinisacked) { tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; } break; /* * In LAST_ACK, we may still be waiting for data to drain * and/or to be acked, as well as for the ack of our FIN. * If our FIN is now acknowledged, delete the TCB, * enter the closed state and return. */ case TCPS_LAST_ACK: if (ourfinisacked) { tcp_close(tp); goto drop; } break; /* * In TIME_WAIT state the only thing that should arrive * is a retransmission of the remote FIN. Acknowledge * it and restart the finack timer. */ case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; goto dropafterack; } } /* switch(tp->t_state) */ step6: /* * Update window information. * Don't look at window if no ACK: TAC's send garbage on first SYN. */ if ((tiflags & TH_ACK) && (SEQ_LT(tp->snd_wl1, ti->ti_seq) || (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) || (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) { tp->snd_wnd = tiwin; tp->snd_wl1 = ti->ti_seq; tp->snd_wl2 = ti->ti_ack; if (tp->snd_wnd > tp->max_sndwnd) tp->max_sndwnd = tp->snd_wnd; needoutput = 1; } /* * Process segments with URG. */ if ((tiflags & TH_URG) && ti->ti_urp && TCPS_HAVERCVDFIN(tp->t_state) == 0) { /* * This is a kludge, but if we receive and accept * random urgent pointers, we'll crash in * soreceive. It's hard to imagine someone * actually wanting to send this much urgent data. */ if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) { ti->ti_urp = 0; tiflags &= ~TH_URG; goto dodata; } /* * If this segment advances the known urgent pointer, * then mark the data stream. This should not happen * in CLOSE_WAIT, CLOSING, LAST_ACK or TIME_WAIT STATES since * a FIN has been received from the remote side. * In these states we ignore the URG. * * According to RFC961 (Assigned Protocols), * the urgent pointer points to the last octet * of urgent data. We continue, however, * to consider it to indicate the first octet * of data past the urgent section as the original * spec states (in one of two places). */ if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) { tp->rcv_up = ti->ti_seq + ti->ti_urp; so->so_urgc = so->so_rcv.sb_cc + (tp->rcv_up - tp->rcv_nxt); /* -1; */ tp->rcv_up = ti->ti_seq + ti->ti_urp; } } else /* * If no out of band data is expected, * pull receive urgent pointer along * with the receive window. */ if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) tp->rcv_up = tp->rcv_nxt; dodata: /* * If this is a small packet, then ACK now - with Nagel * congestion avoidance sender won't send more until * he gets an ACK. */ if (ti->ti_len && (unsigned)ti->ti_len <= 5 && ((struct tcpiphdr_2 *)ti)->first_char == (char)27) { tp->t_flags |= TF_ACKNOW; } /* * Process the segment text, merging it into the TCP sequencing queue, * and arranging for acknowledgment of receipt if necessary. * This process logically involves adjusting tp->rcv_wnd as data * is presented to the user (this happens in tcp_usrreq.c, * case PRU_RCVD). If a FIN has already been received on this * connection then we just ignore the text. */ if ((ti->ti_len || (tiflags&TH_FIN)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { TCP_REASS(tp, ti, m, so, tiflags); } else { m_free(m); tiflags &= ~TH_FIN; } /* * If FIN is received ACK the FIN and let the user know * that the connection is closing. */ if (tiflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { /* * If we receive a FIN we can't send more data, * set it SS_FDRAIN * Shutdown the socket if there is no rx data in the * buffer. * soread() is called on completion of shutdown() and * will got to TCPS_LAST_ACK, and use tcp_output() * to send the FIN. */ sofwdrain(so); tp->t_flags |= TF_ACKNOW; tp->rcv_nxt++; } switch (tp->t_state) { /* * In SYN_RECEIVED and ESTABLISHED STATES * enter the CLOSE_WAIT state. */ case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: if(so->so_emu == EMU_CTL) /* no shutdown on socket */ tp->t_state = TCPS_LAST_ACK; else tp->t_state = TCPS_CLOSE_WAIT; break; /* * If still in FIN_WAIT_1 STATE FIN has not been acked so * enter the CLOSING state. */ case TCPS_FIN_WAIT_1: tp->t_state = TCPS_CLOSING; break; /* * In FIN_WAIT_2 state enter the TIME_WAIT state, * starting the time-wait timer, turning off the other * standard timers. */ case TCPS_FIN_WAIT_2: tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; /* * In TIME_WAIT state restart the 2 MSL time_wait timer. */ case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; } } /* * Return any desired output. */ if (needoutput || (tp->t_flags & TF_ACKNOW)) { (void) tcp_output(tp); } return; dropafterack: /* * Generate an ACK dropping incoming segment if it occupies * sequence space, where the ACK reflects our state. */ if (tiflags & TH_RST) goto drop; m_free(m); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); return; dropwithreset: /* reuses m if m!=NULL, m_free() unnecessary */ if (tiflags & TH_ACK) tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST); else { if (tiflags & TH_SYN) ti->ti_len++; tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0, TH_RST|TH_ACK); } return; drop: /* * Drop space held by incoming segment and return. */ m_free(m); }
false
qemu
b5a87d26e848945eb891f4d7e4a7f2be514e08d5
tcp_input(struct mbuf *m, int iphlen, struct socket *inso) { struct ip save_ip, *ip; register struct tcpiphdr *ti; caddr_t optp = NULL; int optlen = 0; int len, tlen, off; register struct tcpcb *tp = NULL; register int tiflags; struct socket *so = NULL; int todrop, acked, ourfinisacked, needoutput = 0; int iss = 0; u_long tiwin; int ret; struct ex_list *ex_ptr; Slirp *slirp; DEBUG_CALL("tcp_input"); DEBUG_ARGS((dfd, " m = %8lx iphlen = %2d inso = %lx\n", (long )m, iphlen, (long )inso )); if (m == NULL) { so = inso; slirp = so->slirp; tp = sototcpcb(so); m = so->so_m; so->so_m = NULL; ti = so->so_ti; tiwin = ti->ti_win; tiflags = ti->ti_flags; goto cont_conn; } slirp = m->slirp; ti = mtod(m, struct tcpiphdr *); if (iphlen > sizeof(struct ip )) { ip_stripoptions(m, (struct mbuf *)0); iphlen=sizeof(struct ip ); } ip=mtod(m, struct ip *); save_ip = *ip; save_ip.ip_len+= iphlen; tlen = ((struct ip *)ti)->ip_len; tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL; memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); ti->ti_x1 = 0; ti->ti_len = htons((uint16_t)tlen); len = sizeof(struct ip ) + tlen; if(cksum(m, len)) { goto drop; } off = ti->ti_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { goto drop; } tlen -= off; ti->ti_len = tlen; if (off > sizeof (struct tcphdr)) { optlen = off - sizeof (struct tcphdr); optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr); } tiflags = ti->ti_flags; NTOHL(ti->ti_seq); NTOHL(ti->ti_ack); NTOHS(ti->ti_win); NTOHS(ti->ti_urp); m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); if (slirp->restricted) { for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_fport == ti->ti_dport && ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) { break; } } if (!ex_ptr) goto drop; } findso: so = slirp->tcp_last_so; if (so->so_fport != ti->ti_dport || so->so_lport != ti->ti_sport || so->so_laddr.s_addr != ti->ti_src.s_addr || so->so_faddr.s_addr != ti->ti_dst.s_addr) { so = solookup(&slirp->tcb, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); if (so) slirp->tcp_last_so = so; } if (so == NULL) { if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN) goto dropwithreset; if ((so = socreate(slirp)) == NULL) goto dropwithreset; if (tcp_attach(so) < 0) { free(so); goto dropwithreset; } sbreserve(&so->so_snd, TCP_SNDSPACE); sbreserve(&so->so_rcv, TCP_RCVSPACE); so->so_laddr = ti->ti_src; so->so_lport = ti->ti_sport; so->so_faddr = ti->ti_dst; so->so_fport = ti->ti_dport; if ((so->so_iptos = tcp_tos(so)) == 0) so->so_iptos = ((struct ip *)ti)->ip_tos; tp = sototcpcb(so); tp->t_state = TCPS_LISTEN; } if (so->so_state & SS_ISFCONNECTING) goto drop; tp = sototcpcb(so); if (tp == NULL) goto dropwithreset; if (tp->t_state == TCPS_CLOSED) goto drop; tiwin = ti->ti_win; tp->t_idle = 0; if (SO_OPTIONS) tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; else tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE; if (optp && tp->t_state != TCPS_LISTEN) tcp_dooptions(tp, (u_char *)optp, optlen, ti); if (tp->t_state == TCPS_ESTABLISHED && (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK && ti->ti_seq == tp->rcv_nxt && tiwin && tiwin == tp->snd_wnd && tp->snd_nxt == tp->snd_max) { if (ti->ti_len == 0) { if (SEQ_GT(ti->ti_ack, tp->snd_una) && SEQ_LEQ(ti->ti_ack, tp->snd_max) && tp->snd_cwnd >= tp->snd_wnd) { if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; sbdrop(&so->so_snd, acked); tp->snd_una = ti->ti_ack; m_free(m); if (tp->snd_una == tp->snd_max) tp->t_timer[TCPT_REXMT] = 0; else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; if (so->so_snd.sb_cc) (void) tcp_output(tp); return; } } else if (ti->ti_ack == tp->snd_una && tcpfrag_list_empty(tp) && ti->ti_len <= sbspace(&so->so_rcv)) { tp->rcv_nxt += ti->ti_len; if (so->so_emu) { if (tcp_emu(so,m)) sbappend(so, m); } else sbappend(so, m); tp->t_flags |= TF_ACKNOW; tcp_output(tp); return; } } { int win; win = sbspace(&so->so_rcv); if (win < 0) win = 0; tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt)); } switch (tp->t_state) { case TCPS_LISTEN: { if (tiflags & TH_RST) goto drop; if (tiflags & TH_ACK) goto dropwithreset; if ((tiflags & TH_SYN) == 0) goto drop; if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == slirp->vnetwork_addr.s_addr) { if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr && so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) { for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if(ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { so->so_state |= SS_CTL; break; } } if (so->so_state & SS_CTL) { goto cont_input; } } } if (so->so_emu & EMU_NOCONNECT) { so->so_emu &= ~EMU_NOCONNECT; goto cont_input; } if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { u_char code=ICMP_UNREACH_NET; DEBUG_MISC((dfd, " tcp fconnect errno = %d-%s\n", errno,strerror(errno))); if(errno == ECONNREFUSED) { tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0, TH_RST|TH_ACK); } else { if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; HTONL(ti->ti_seq); HTONL(ti->ti_ack); HTONS(ti->ti_win); HTONS(ti->ti_urp); m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); *ip=save_ip; icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno)); } tcp_close(tp); m_free(m); } else { so->so_m = m; so->so_ti = ti; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; tp->t_state = TCPS_SYN_RECEIVED; tcp_template(tp); } return; cont_conn: if (so->so_state & SS_NOFDREF) { tp = tcp_close(tp); goto dropwithreset; } cont_input: tcp_template(tp); if (optp) tcp_dooptions(tp, (u_char *)optp, optlen, ti); if (iss) tp->iss = iss; else tp->iss = slirp->tcp_iss; slirp->tcp_iss += TCP_ISSINCR/2; tp->irs = ti->ti_seq; tcp_sendseqinit(tp); tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; tp->t_state = TCPS_SYN_RECEIVED; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; goto trimthenstep6; } case TCPS_SYN_SENT: if ((tiflags & TH_ACK) && (SEQ_LEQ(ti->ti_ack, tp->iss) || SEQ_GT(ti->ti_ack, tp->snd_max))) goto dropwithreset; if (tiflags & TH_RST) { if (tiflags & TH_ACK) { tcp_drop(tp, 0); } goto drop; } if ((tiflags & TH_SYN) == 0) goto drop; if (tiflags & TH_ACK) { tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; } tp->t_timer[TCPT_REXMT] = 0; tp->irs = ti->ti_seq; tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { soisfconnected(so); tp->t_state = TCPS_ESTABLISHED; (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); if (tp->t_rtt) tcp_xmit_timer(tp, tp->t_rtt); } else tp->t_state = TCPS_SYN_RECEIVED; trimthenstep6: ti->ti_seq++; if (ti->ti_len > tp->rcv_wnd) { todrop = ti->ti_len - tp->rcv_wnd; m_adj(m, -todrop); ti->ti_len = tp->rcv_wnd; tiflags &= ~TH_FIN; } tp->snd_wl1 = ti->ti_seq - 1; tp->rcv_up = ti->ti_seq; goto step6; } todrop = tp->rcv_nxt - ti->ti_seq; if (todrop > 0) { if (tiflags & TH_SYN) { tiflags &= ~TH_SYN; ti->ti_seq++; if (ti->ti_urp > 1) ti->ti_urp--; else tiflags &= ~TH_URG; todrop--; } if (todrop > ti->ti_len || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) { tiflags &= ~TH_FIN; tp->t_flags |= TF_ACKNOW; todrop = ti->ti_len; } m_adj(m, todrop); ti->ti_seq += todrop; ti->ti_len -= todrop; if (ti->ti_urp > todrop) ti->ti_urp -= todrop; else { tiflags &= ~TH_URG; ti->ti_urp = 0; } } if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { tp = tcp_close(tp); goto dropwithreset; } todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); if (todrop > 0) { if (todrop >= ti->ti_len) { if (tiflags & TH_SYN && tp->t_state == TCPS_TIME_WAIT && SEQ_GT(ti->ti_seq, tp->rcv_nxt)) { iss = tp->rcv_nxt + TCP_ISSINCR; tp = tcp_close(tp); goto findso; } if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; } else { goto dropafterack; } } m_adj(m, -todrop); ti->ti_len -= todrop; tiflags &= ~(TH_PUSH|TH_FIN); } if (tiflags&TH_RST) switch (tp->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: tp->t_state = TCPS_CLOSED; tcp_close(tp); goto drop; case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: tcp_close(tp); goto drop; } if (tiflags & TH_SYN) { tp = tcp_drop(tp,0); goto dropwithreset; } if ((tiflags & TH_ACK) == 0) goto drop; switch (tp->t_state) { case TCPS_SYN_RECEIVED: if (SEQ_GT(tp->snd_una, ti->ti_ack) || SEQ_GT(ti->ti_ack, tp->snd_max)) goto dropwithreset; tp->t_state = TCPS_ESTABLISHED; tp->snd_una=ti->ti_ack; if (so->so_state & SS_CTL) { ret = tcp_ctl(so); if (ret == 1) { soisfconnected(so); so->so_state &= ~SS_CTL; } else if (ret == 2) { so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } else { needoutput = 1; tp->t_state = TCPS_FIN_WAIT_1; } } else { soisfconnected(so); } (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); tp->snd_wl1 = ti->ti_seq - 1; goto synrx_to_est; case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { DEBUG_MISC((dfd, " dup ack m = %lx so = %lx\n", (long )m, (long )so)); if (tp->t_timer[TCPT_REXMT] == 0 || ti->ti_ack != tp->snd_una) tp->t_dupacks = 0; else if (++tp->t_dupacks == TCPREXMTTHRESH) { tcp_seq onxt = tp->snd_nxt; u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; if (win < 2) win = 2; tp->snd_ssthresh = win * tp->t_maxseg; tp->t_timer[TCPT_REXMT] = 0; tp->t_rtt = 0; tp->snd_nxt = ti->ti_ack; tp->snd_cwnd = tp->t_maxseg; (void) tcp_output(tp); tp->snd_cwnd = tp->snd_ssthresh + tp->t_maxseg * tp->t_dupacks; if (SEQ_GT(onxt, tp->snd_nxt)) tp->snd_nxt = onxt; goto drop; } else if (tp->t_dupacks > TCPREXMTTHRESH) { tp->snd_cwnd += tp->t_maxseg; (void) tcp_output(tp); goto drop; } } else tp->t_dupacks = 0; break; } synrx_to_est: if (tp->t_dupacks > TCPREXMTTHRESH && tp->snd_cwnd > tp->snd_ssthresh) tp->snd_cwnd = tp->snd_ssthresh; tp->t_dupacks = 0; if (SEQ_GT(ti->ti_ack, tp->snd_max)) { goto dropafterack; } acked = ti->ti_ack - tp->snd_una; if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp,tp->t_rtt); if (ti->ti_ack == tp->snd_max) { tp->t_timer[TCPT_REXMT] = 0; needoutput = 1; } else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; { register u_int cw = tp->snd_cwnd; register u_int incr = tp->t_maxseg; if (cw > tp->snd_ssthresh) incr = incr * incr / cw; tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale); } if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; sbdrop(&so->so_snd, (int )so->so_snd.sb_cc); ourfinisacked = 1; } else { sbdrop(&so->so_snd, acked); tp->snd_wnd -= acked; ourfinisacked = 0; } tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; switch (tp->t_state) { case TCPS_FIN_WAIT_1: if (ourfinisacked) { if (so->so_state & SS_FCANTRCVMORE) { tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE; } tp->t_state = TCPS_FIN_WAIT_2; } break; case TCPS_CLOSING: if (ourfinisacked) { tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; } break; case TCPS_LAST_ACK: if (ourfinisacked) { tcp_close(tp); goto drop; } break; case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; goto dropafterack; } } step6: if ((tiflags & TH_ACK) && (SEQ_LT(tp->snd_wl1, ti->ti_seq) || (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) || (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) { tp->snd_wnd = tiwin; tp->snd_wl1 = ti->ti_seq; tp->snd_wl2 = ti->ti_ack; if (tp->snd_wnd > tp->max_sndwnd) tp->max_sndwnd = tp->snd_wnd; needoutput = 1; } if ((tiflags & TH_URG) && ti->ti_urp && TCPS_HAVERCVDFIN(tp->t_state) == 0) { if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) { ti->ti_urp = 0; tiflags &= ~TH_URG; goto dodata; } if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) { tp->rcv_up = ti->ti_seq + ti->ti_urp; so->so_urgc = so->so_rcv.sb_cc + (tp->rcv_up - tp->rcv_nxt); tp->rcv_up = ti->ti_seq + ti->ti_urp; } } else if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) tp->rcv_up = tp->rcv_nxt; dodata: if (ti->ti_len && (unsigned)ti->ti_len <= 5 && ((struct tcpiphdr_2 *)ti)->first_char == (char)27) { tp->t_flags |= TF_ACKNOW; } if ((ti->ti_len || (tiflags&TH_FIN)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { TCP_REASS(tp, ti, m, so, tiflags); } else { m_free(m); tiflags &= ~TH_FIN; } if (tiflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { sofwdrain(so); tp->t_flags |= TF_ACKNOW; tp->rcv_nxt++; } switch (tp->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: if(so->so_emu == EMU_CTL) tp->t_state = TCPS_LAST_ACK; else tp->t_state = TCPS_CLOSE_WAIT; break; case TCPS_FIN_WAIT_1: tp->t_state = TCPS_CLOSING; break; case TCPS_FIN_WAIT_2: tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; } } if (needoutput || (tp->t_flags & TF_ACKNOW)) { (void) tcp_output(tp); } return; dropafterack: if (tiflags & TH_RST) goto drop; m_free(m); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); return; dropwithreset: if (tiflags & TH_ACK) tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST); else { if (tiflags & TH_SYN) ti->ti_len++; tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0, TH_RST|TH_ACK); } return; drop: m_free(m); }
{ "code": [], "line_no": [] }
FUNC_0(struct mbuf *VAR_0, int VAR_1, struct socket *VAR_2) { struct VAR_4 VAR_3, *VAR_4; register struct tcpiphdr *VAR_5; caddr_t optp = NULL; int VAR_6 = 0; int VAR_7, VAR_8, VAR_9; register struct tcpcb *VAR_10 = NULL; register int VAR_11; struct socket *VAR_12 = NULL; int VAR_13, VAR_14, VAR_15, VAR_16 = 0; int VAR_17 = 0; u_long tiwin; int VAR_18; struct ex_list *VAR_19; Slirp *slirp; DEBUG_CALL("FUNC_0"); DEBUG_ARGS((dfd, " VAR_0 = %8lx VAR_1 = %2d VAR_2 = %lx\n", (long )VAR_0, VAR_1, (long )VAR_2 )); if (VAR_0 == NULL) { VAR_12 = VAR_2; slirp = VAR_12->slirp; VAR_10 = sototcpcb(VAR_12); VAR_0 = VAR_12->so_m; VAR_12->so_m = NULL; VAR_5 = VAR_12->so_ti; tiwin = VAR_5->ti_win; VAR_11 = VAR_5->ti_flags; goto cont_conn; } slirp = VAR_0->slirp; VAR_5 = mtod(VAR_0, struct tcpiphdr *); if (VAR_1 > sizeof(struct VAR_4 )) { ip_stripoptions(VAR_0, (struct mbuf *)0); VAR_1=sizeof(struct VAR_4 ); } VAR_4=mtod(VAR_0, struct VAR_4 *); VAR_3 = *VAR_4; VAR_3.ip_len+= VAR_1; VAR_8 = ((struct VAR_4 *)VAR_5)->ip_len; tcpiphdr2qlink(VAR_5)->next = tcpiphdr2qlink(VAR_5)->prev = NULL; memset(&VAR_5->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); VAR_5->ti_x1 = 0; VAR_5->ti_len = htons((uint16_t)VAR_8); VAR_7 = sizeof(struct VAR_4 ) + VAR_8; if(cksum(VAR_0, VAR_7)) { goto drop; } VAR_9 = VAR_5->ti_off << 2; if (VAR_9 < sizeof (struct tcphdr) || VAR_9 > VAR_8) { goto drop; } VAR_8 -= VAR_9; VAR_5->ti_len = VAR_8; if (VAR_9 > sizeof (struct tcphdr)) { VAR_6 = VAR_9 - sizeof (struct tcphdr); optp = mtod(VAR_0, caddr_t) + sizeof (struct tcpiphdr); } VAR_11 = VAR_5->ti_flags; NTOHL(VAR_5->ti_seq); NTOHL(VAR_5->ti_ack); NTOHS(VAR_5->ti_win); NTOHS(VAR_5->ti_urp); VAR_0->m_data += sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr); VAR_0->m_len -= sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr); if (slirp->restricted) { for (VAR_19 = slirp->exec_list; VAR_19; VAR_19 = VAR_19->ex_next) { if (VAR_19->ex_fport == VAR_5->ti_dport && VAR_5->ti_dst.s_addr == VAR_19->ex_addr.s_addr) { break; } } if (!VAR_19) goto drop; } findso: VAR_12 = slirp->tcp_last_so; if (VAR_12->so_fport != VAR_5->ti_dport || VAR_12->so_lport != VAR_5->ti_sport || VAR_12->so_laddr.s_addr != VAR_5->ti_src.s_addr || VAR_12->so_faddr.s_addr != VAR_5->ti_dst.s_addr) { VAR_12 = solookup(&slirp->tcb, VAR_5->ti_src, VAR_5->ti_sport, VAR_5->ti_dst, VAR_5->ti_dport); if (VAR_12) slirp->tcp_last_so = VAR_12; } if (VAR_12 == NULL) { if ((VAR_11 & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN) goto dropwithreset; if ((VAR_12 = socreate(slirp)) == NULL) goto dropwithreset; if (tcp_attach(VAR_12) < 0) { free(VAR_12); goto dropwithreset; } sbreserve(&VAR_12->so_snd, TCP_SNDSPACE); sbreserve(&VAR_12->so_rcv, TCP_RCVSPACE); VAR_12->so_laddr = VAR_5->ti_src; VAR_12->so_lport = VAR_5->ti_sport; VAR_12->so_faddr = VAR_5->ti_dst; VAR_12->so_fport = VAR_5->ti_dport; if ((VAR_12->so_iptos = tcp_tos(VAR_12)) == 0) VAR_12->so_iptos = ((struct VAR_4 *)VAR_5)->ip_tos; VAR_10 = sototcpcb(VAR_12); VAR_10->t_state = TCPS_LISTEN; } if (VAR_12->so_state & SS_ISFCONNECTING) goto drop; VAR_10 = sototcpcb(VAR_12); if (VAR_10 == NULL) goto dropwithreset; if (VAR_10->t_state == TCPS_CLOSED) goto drop; tiwin = VAR_5->ti_win; VAR_10->t_idle = 0; if (SO_OPTIONS) VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; else VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE; if (optp && VAR_10->t_state != TCPS_LISTEN) tcp_dooptions(VAR_10, (u_char *)optp, VAR_6, VAR_5); if (VAR_10->t_state == TCPS_ESTABLISHED && (VAR_11 & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK && VAR_5->ti_seq == VAR_10->rcv_nxt && tiwin && tiwin == VAR_10->snd_wnd && VAR_10->snd_nxt == VAR_10->snd_max) { if (VAR_5->ti_len == 0) { if (SEQ_GT(VAR_5->ti_ack, VAR_10->snd_una) && SEQ_LEQ(VAR_5->ti_ack, VAR_10->snd_max) && VAR_10->snd_cwnd >= VAR_10->snd_wnd) { if (VAR_10->t_rtt && SEQ_GT(VAR_5->ti_ack, VAR_10->t_rtseq)) tcp_xmit_timer(VAR_10, VAR_10->t_rtt); VAR_14 = VAR_5->ti_ack - VAR_10->snd_una; sbdrop(&VAR_12->so_snd, VAR_14); VAR_10->snd_una = VAR_5->ti_ack; m_free(VAR_0); if (VAR_10->snd_una == VAR_10->snd_max) VAR_10->t_timer[TCPT_REXMT] = 0; else if (VAR_10->t_timer[TCPT_PERSIST] == 0) VAR_10->t_timer[TCPT_REXMT] = VAR_10->t_rxtcur; if (VAR_12->so_snd.sb_cc) (void) tcp_output(VAR_10); return; } } else if (VAR_5->ti_ack == VAR_10->snd_una && tcpfrag_list_empty(VAR_10) && VAR_5->ti_len <= sbspace(&VAR_12->so_rcv)) { VAR_10->rcv_nxt += VAR_5->ti_len; if (VAR_12->so_emu) { if (tcp_emu(VAR_12,VAR_0)) sbappend(VAR_12, VAR_0); } else sbappend(VAR_12, VAR_0); VAR_10->t_flags |= TF_ACKNOW; tcp_output(VAR_10); return; } } { int VAR_20; VAR_20 = sbspace(&VAR_12->so_rcv); if (VAR_20 < 0) VAR_20 = 0; VAR_10->rcv_wnd = max(VAR_20, (int)(VAR_10->rcv_adv - VAR_10->rcv_nxt)); } switch (VAR_10->t_state) { case TCPS_LISTEN: { if (VAR_11 & TH_RST) goto drop; if (VAR_11 & TH_ACK) goto dropwithreset; if ((VAR_11 & TH_SYN) == 0) goto drop; if ((VAR_12->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == slirp->vnetwork_addr.s_addr) { if (VAR_12->so_faddr.s_addr != slirp->vhost_addr.s_addr && VAR_12->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) { for (VAR_19 = slirp->exec_list; VAR_19; VAR_19 = VAR_19->ex_next) { if(VAR_19->ex_fport == VAR_12->so_fport && VAR_12->so_faddr.s_addr == VAR_19->ex_addr.s_addr) { VAR_12->so_state |= SS_CTL; break; } } if (VAR_12->so_state & SS_CTL) { goto cont_input; } } } if (VAR_12->so_emu & EMU_NOCONNECT) { VAR_12->so_emu &= ~EMU_NOCONNECT; goto cont_input; } if((tcp_fconnect(VAR_12) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { u_char code=ICMP_UNREACH_NET; DEBUG_MISC((dfd, " tcp fconnect errno = %d-%s\n", errno,strerror(errno))); if(errno == ECONNREFUSED) { tcp_respond(VAR_10, VAR_5, VAR_0, VAR_5->ti_seq+1, (tcp_seq)0, TH_RST|TH_ACK); } else { if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; HTONL(VAR_5->ti_seq); HTONL(VAR_5->ti_ack); HTONS(VAR_5->ti_win); HTONS(VAR_5->ti_urp); VAR_0->m_data -= sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr); VAR_0->m_len += sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr); *VAR_4=VAR_3; icmp_error(VAR_0, ICMP_UNREACH,code, 0,strerror(errno)); } tcp_close(VAR_10); m_free(VAR_0); } else { VAR_12->so_m = VAR_0; VAR_12->so_ti = VAR_5; VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; VAR_10->t_state = TCPS_SYN_RECEIVED; tcp_template(VAR_10); } return; cont_conn: if (VAR_12->so_state & SS_NOFDREF) { VAR_10 = tcp_close(VAR_10); goto dropwithreset; } cont_input: tcp_template(VAR_10); if (optp) tcp_dooptions(VAR_10, (u_char *)optp, VAR_6, VAR_5); if (VAR_17) VAR_10->VAR_17 = VAR_17; else VAR_10->VAR_17 = slirp->tcp_iss; slirp->tcp_iss += TCP_ISSINCR/2; VAR_10->irs = VAR_5->ti_seq; tcp_sendseqinit(VAR_10); tcp_rcvseqinit(VAR_10); VAR_10->t_flags |= TF_ACKNOW; VAR_10->t_state = TCPS_SYN_RECEIVED; VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; goto trimthenstep6; } case TCPS_SYN_SENT: if ((VAR_11 & TH_ACK) && (SEQ_LEQ(VAR_5->ti_ack, VAR_10->VAR_17) || SEQ_GT(VAR_5->ti_ack, VAR_10->snd_max))) goto dropwithreset; if (VAR_11 & TH_RST) { if (VAR_11 & TH_ACK) { tcp_drop(VAR_10, 0); } goto drop; } if ((VAR_11 & TH_SYN) == 0) goto drop; if (VAR_11 & TH_ACK) { VAR_10->snd_una = VAR_5->ti_ack; if (SEQ_LT(VAR_10->snd_nxt, VAR_10->snd_una)) VAR_10->snd_nxt = VAR_10->snd_una; } VAR_10->t_timer[TCPT_REXMT] = 0; VAR_10->irs = VAR_5->ti_seq; tcp_rcvseqinit(VAR_10); VAR_10->t_flags |= TF_ACKNOW; if (VAR_11 & TH_ACK && SEQ_GT(VAR_10->snd_una, VAR_10->VAR_17)) { soisfconnected(VAR_12); VAR_10->t_state = TCPS_ESTABLISHED; (void) tcp_reass(VAR_10, (struct tcpiphdr *)0, (struct mbuf *)0); if (VAR_10->t_rtt) tcp_xmit_timer(VAR_10, VAR_10->t_rtt); } else VAR_10->t_state = TCPS_SYN_RECEIVED; trimthenstep6: VAR_5->ti_seq++; if (VAR_5->ti_len > VAR_10->rcv_wnd) { VAR_13 = VAR_5->ti_len - VAR_10->rcv_wnd; m_adj(VAR_0, -VAR_13); VAR_5->ti_len = VAR_10->rcv_wnd; VAR_11 &= ~TH_FIN; } VAR_10->snd_wl1 = VAR_5->ti_seq - 1; VAR_10->rcv_up = VAR_5->ti_seq; goto step6; } VAR_13 = VAR_10->rcv_nxt - VAR_5->ti_seq; if (VAR_13 > 0) { if (VAR_11 & TH_SYN) { VAR_11 &= ~TH_SYN; VAR_5->ti_seq++; if (VAR_5->ti_urp > 1) VAR_5->ti_urp--; else VAR_11 &= ~TH_URG; VAR_13--; } if (VAR_13 > VAR_5->ti_len || (VAR_13 == VAR_5->ti_len && (VAR_11 & TH_FIN) == 0)) { VAR_11 &= ~TH_FIN; VAR_10->t_flags |= TF_ACKNOW; VAR_13 = VAR_5->ti_len; } m_adj(VAR_0, VAR_13); VAR_5->ti_seq += VAR_13; VAR_5->ti_len -= VAR_13; if (VAR_5->ti_urp > VAR_13) VAR_5->ti_urp -= VAR_13; else { VAR_11 &= ~TH_URG; VAR_5->ti_urp = 0; } } if ((VAR_12->so_state & SS_NOFDREF) && VAR_10->t_state > TCPS_CLOSE_WAIT && VAR_5->ti_len) { VAR_10 = tcp_close(VAR_10); goto dropwithreset; } VAR_13 = (VAR_5->ti_seq+VAR_5->ti_len) - (VAR_10->rcv_nxt+VAR_10->rcv_wnd); if (VAR_13 > 0) { if (VAR_13 >= VAR_5->ti_len) { if (VAR_11 & TH_SYN && VAR_10->t_state == TCPS_TIME_WAIT && SEQ_GT(VAR_5->ti_seq, VAR_10->rcv_nxt)) { VAR_17 = VAR_10->rcv_nxt + TCP_ISSINCR; VAR_10 = tcp_close(VAR_10); goto findso; } if (VAR_10->rcv_wnd == 0 && VAR_5->ti_seq == VAR_10->rcv_nxt) { VAR_10->t_flags |= TF_ACKNOW; } else { goto dropafterack; } } m_adj(VAR_0, -VAR_13); VAR_5->ti_len -= VAR_13; VAR_11 &= ~(TH_PUSH|TH_FIN); } if (VAR_11&TH_RST) switch (VAR_10->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: VAR_10->t_state = TCPS_CLOSED; tcp_close(VAR_10); goto drop; case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: tcp_close(VAR_10); goto drop; } if (VAR_11 & TH_SYN) { VAR_10 = tcp_drop(VAR_10,0); goto dropwithreset; } if ((VAR_11 & TH_ACK) == 0) goto drop; switch (VAR_10->t_state) { case TCPS_SYN_RECEIVED: if (SEQ_GT(VAR_10->snd_una, VAR_5->ti_ack) || SEQ_GT(VAR_5->ti_ack, VAR_10->snd_max)) goto dropwithreset; VAR_10->t_state = TCPS_ESTABLISHED; VAR_10->snd_una=VAR_5->ti_ack; if (VAR_12->so_state & SS_CTL) { VAR_18 = tcp_ctl(VAR_12); if (VAR_18 == 1) { soisfconnected(VAR_12); VAR_12->so_state &= ~SS_CTL; } else if (VAR_18 == 2) { VAR_12->so_state &= SS_PERSISTENT_MASK; VAR_12->so_state |= SS_NOFDREF; } else { VAR_16 = 1; VAR_10->t_state = TCPS_FIN_WAIT_1; } } else { soisfconnected(VAR_12); } (void) tcp_reass(VAR_10, (struct tcpiphdr *)0, (struct mbuf *)0); VAR_10->snd_wl1 = VAR_5->ti_seq - 1; goto synrx_to_est; case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: if (SEQ_LEQ(VAR_5->ti_ack, VAR_10->snd_una)) { if (VAR_5->ti_len == 0 && tiwin == VAR_10->snd_wnd) { DEBUG_MISC((dfd, " dup ack VAR_0 = %lx VAR_12 = %lx\n", (long )VAR_0, (long )VAR_12)); if (VAR_10->t_timer[TCPT_REXMT] == 0 || VAR_5->ti_ack != VAR_10->snd_una) VAR_10->t_dupacks = 0; else if (++VAR_10->t_dupacks == TCPREXMTTHRESH) { tcp_seq onxt = VAR_10->snd_nxt; u_int VAR_20 = min(VAR_10->snd_wnd, VAR_10->snd_cwnd) / 2 / VAR_10->t_maxseg; if (VAR_20 < 2) VAR_20 = 2; VAR_10->snd_ssthresh = VAR_20 * VAR_10->t_maxseg; VAR_10->t_timer[TCPT_REXMT] = 0; VAR_10->t_rtt = 0; VAR_10->snd_nxt = VAR_5->ti_ack; VAR_10->snd_cwnd = VAR_10->t_maxseg; (void) tcp_output(VAR_10); VAR_10->snd_cwnd = VAR_10->snd_ssthresh + VAR_10->t_maxseg * VAR_10->t_dupacks; if (SEQ_GT(onxt, VAR_10->snd_nxt)) VAR_10->snd_nxt = onxt; goto drop; } else if (VAR_10->t_dupacks > TCPREXMTTHRESH) { VAR_10->snd_cwnd += VAR_10->t_maxseg; (void) tcp_output(VAR_10); goto drop; } } else VAR_10->t_dupacks = 0; break; } synrx_to_est: if (VAR_10->t_dupacks > TCPREXMTTHRESH && VAR_10->snd_cwnd > VAR_10->snd_ssthresh) VAR_10->snd_cwnd = VAR_10->snd_ssthresh; VAR_10->t_dupacks = 0; if (SEQ_GT(VAR_5->ti_ack, VAR_10->snd_max)) { goto dropafterack; } VAR_14 = VAR_5->ti_ack - VAR_10->snd_una; if (VAR_10->t_rtt && SEQ_GT(VAR_5->ti_ack, VAR_10->t_rtseq)) tcp_xmit_timer(VAR_10,VAR_10->t_rtt); if (VAR_5->ti_ack == VAR_10->snd_max) { VAR_10->t_timer[TCPT_REXMT] = 0; VAR_16 = 1; } else if (VAR_10->t_timer[TCPT_PERSIST] == 0) VAR_10->t_timer[TCPT_REXMT] = VAR_10->t_rxtcur; { register u_int VAR_21 = VAR_10->snd_cwnd; register u_int VAR_22 = VAR_10->t_maxseg; if (VAR_21 > VAR_10->snd_ssthresh) VAR_22 = VAR_22 * VAR_22 / VAR_21; VAR_10->snd_cwnd = min(VAR_21 + VAR_22, TCP_MAXWIN<<VAR_10->snd_scale); } if (VAR_14 > VAR_12->so_snd.sb_cc) { VAR_10->snd_wnd -= VAR_12->so_snd.sb_cc; sbdrop(&VAR_12->so_snd, (int )VAR_12->so_snd.sb_cc); VAR_15 = 1; } else { sbdrop(&VAR_12->so_snd, VAR_14); VAR_10->snd_wnd -= VAR_14; VAR_15 = 0; } VAR_10->snd_una = VAR_5->ti_ack; if (SEQ_LT(VAR_10->snd_nxt, VAR_10->snd_una)) VAR_10->snd_nxt = VAR_10->snd_una; switch (VAR_10->t_state) { case TCPS_FIN_WAIT_1: if (VAR_15) { if (VAR_12->so_state & SS_FCANTRCVMORE) { VAR_10->t_timer[TCPT_2MSL] = TCP_MAXIDLE; } VAR_10->t_state = TCPS_FIN_WAIT_2; } break; case TCPS_CLOSING: if (VAR_15) { VAR_10->t_state = TCPS_TIME_WAIT; tcp_canceltimers(VAR_10); VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; } break; case TCPS_LAST_ACK: if (VAR_15) { tcp_close(VAR_10); goto drop; } break; case TCPS_TIME_WAIT: VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; goto dropafterack; } } step6: if ((VAR_11 & TH_ACK) && (SEQ_LT(VAR_10->snd_wl1, VAR_5->ti_seq) || (VAR_10->snd_wl1 == VAR_5->ti_seq && (SEQ_LT(VAR_10->snd_wl2, VAR_5->ti_ack) || (VAR_10->snd_wl2 == VAR_5->ti_ack && tiwin > VAR_10->snd_wnd))))) { VAR_10->snd_wnd = tiwin; VAR_10->snd_wl1 = VAR_5->ti_seq; VAR_10->snd_wl2 = VAR_5->ti_ack; if (VAR_10->snd_wnd > VAR_10->max_sndwnd) VAR_10->max_sndwnd = VAR_10->snd_wnd; VAR_16 = 1; } if ((VAR_11 & TH_URG) && VAR_5->ti_urp && TCPS_HAVERCVDFIN(VAR_10->t_state) == 0) { if (VAR_5->ti_urp + VAR_12->so_rcv.sb_cc > VAR_12->so_rcv.sb_datalen) { VAR_5->ti_urp = 0; VAR_11 &= ~TH_URG; goto dodata; } if (SEQ_GT(VAR_5->ti_seq+VAR_5->ti_urp, VAR_10->rcv_up)) { VAR_10->rcv_up = VAR_5->ti_seq + VAR_5->ti_urp; VAR_12->so_urgc = VAR_12->so_rcv.sb_cc + (VAR_10->rcv_up - VAR_10->rcv_nxt); VAR_10->rcv_up = VAR_5->ti_seq + VAR_5->ti_urp; } } else if (SEQ_GT(VAR_10->rcv_nxt, VAR_10->rcv_up)) VAR_10->rcv_up = VAR_10->rcv_nxt; dodata: if (VAR_5->ti_len && (unsigned)VAR_5->ti_len <= 5 && ((struct tcpiphdr_2 *)VAR_5)->first_char == (char)27) { VAR_10->t_flags |= TF_ACKNOW; } if ((VAR_5->ti_len || (VAR_11&TH_FIN)) && TCPS_HAVERCVDFIN(VAR_10->t_state) == 0) { TCP_REASS(VAR_10, VAR_5, VAR_0, VAR_12, VAR_11); } else { m_free(VAR_0); VAR_11 &= ~TH_FIN; } if (VAR_11 & TH_FIN) { if (TCPS_HAVERCVDFIN(VAR_10->t_state) == 0) { sofwdrain(VAR_12); VAR_10->t_flags |= TF_ACKNOW; VAR_10->rcv_nxt++; } switch (VAR_10->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: if(VAR_12->so_emu == EMU_CTL) VAR_10->t_state = TCPS_LAST_ACK; else VAR_10->t_state = TCPS_CLOSE_WAIT; break; case TCPS_FIN_WAIT_1: VAR_10->t_state = TCPS_CLOSING; break; case TCPS_FIN_WAIT_2: VAR_10->t_state = TCPS_TIME_WAIT; tcp_canceltimers(VAR_10); VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; case TCPS_TIME_WAIT: VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; } } if (VAR_16 || (VAR_10->t_flags & TF_ACKNOW)) { (void) tcp_output(VAR_10); } return; dropafterack: if (VAR_11 & TH_RST) goto drop; m_free(VAR_0); VAR_10->t_flags |= TF_ACKNOW; (void) tcp_output(VAR_10); return; dropwithreset: if (VAR_11 & TH_ACK) tcp_respond(VAR_10, VAR_5, VAR_0, (tcp_seq)0, VAR_5->ti_ack, TH_RST); else { if (VAR_11 & TH_SYN) VAR_5->ti_len++; tcp_respond(VAR_10, VAR_5, VAR_0, VAR_5->ti_seq+VAR_5->ti_len, (tcp_seq)0, TH_RST|TH_ACK); } return; drop: m_free(VAR_0); }
[ "FUNC_0(struct mbuf *VAR_0, int VAR_1, struct socket *VAR_2)\n{", "struct VAR_4 VAR_3, *VAR_4;", "register struct tcpiphdr *VAR_5;", "caddr_t optp = NULL;", "int VAR_6 = 0;", "int VAR_7, VAR_8, VAR_9;", "register struct tcpcb *VAR_10 = NULL;", "register int VAR_11;", "struct socket *VAR_12 = NULL;", "int VAR_13, VAR_14, VAR_15, VAR_16 = 0;", "int VAR_17 = 0;", "u_long tiwin;", "int VAR_18;", "struct ex_list *VAR_19;", "Slirp *slirp;", "DEBUG_CALL(\"FUNC_0\");", "DEBUG_ARGS((dfd, \" VAR_0 = %8lx VAR_1 = %2d VAR_2 = %lx\\n\",\n(long )VAR_0, VAR_1, (long )VAR_2 ));", "if (VAR_0 == NULL) {", "VAR_12 = VAR_2;", "slirp = VAR_12->slirp;", "VAR_10 = sototcpcb(VAR_12);", "VAR_0 = VAR_12->so_m;", "VAR_12->so_m = NULL;", "VAR_5 = VAR_12->so_ti;", "tiwin = VAR_5->ti_win;", "VAR_11 = VAR_5->ti_flags;", "goto cont_conn;", "}", "slirp = VAR_0->slirp;", "VAR_5 = mtod(VAR_0, struct tcpiphdr *);", "if (VAR_1 > sizeof(struct VAR_4 )) {", "ip_stripoptions(VAR_0, (struct mbuf *)0);", "VAR_1=sizeof(struct VAR_4 );", "}", "VAR_4=mtod(VAR_0, struct VAR_4 *);", "VAR_3 = *VAR_4;", "VAR_3.ip_len+= VAR_1;", "VAR_8 = ((struct VAR_4 *)VAR_5)->ip_len;", "tcpiphdr2qlink(VAR_5)->next = tcpiphdr2qlink(VAR_5)->prev = NULL;", "memset(&VAR_5->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));", "VAR_5->ti_x1 = 0;", "VAR_5->ti_len = htons((uint16_t)VAR_8);", "VAR_7 = sizeof(struct VAR_4 ) + VAR_8;", "if(cksum(VAR_0, VAR_7)) {", "goto drop;", "}", "VAR_9 = VAR_5->ti_off << 2;", "if (VAR_9 < sizeof (struct tcphdr) || VAR_9 > VAR_8) {", "goto drop;", "}", "VAR_8 -= VAR_9;", "VAR_5->ti_len = VAR_8;", "if (VAR_9 > sizeof (struct tcphdr)) {", "VAR_6 = VAR_9 - sizeof (struct tcphdr);", "optp = mtod(VAR_0, caddr_t) + sizeof (struct tcpiphdr);", "}", "VAR_11 = VAR_5->ti_flags;", "NTOHL(VAR_5->ti_seq);", "NTOHL(VAR_5->ti_ack);", "NTOHS(VAR_5->ti_win);", "NTOHS(VAR_5->ti_urp);", "VAR_0->m_data += sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr);", "VAR_0->m_len -= sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr);", "if (slirp->restricted) {", "for (VAR_19 = slirp->exec_list; VAR_19; VAR_19 = VAR_19->ex_next) {", "if (VAR_19->ex_fport == VAR_5->ti_dport &&\nVAR_5->ti_dst.s_addr == VAR_19->ex_addr.s_addr) {", "break;", "}", "}", "if (!VAR_19)\ngoto drop;", "}", "findso:\nVAR_12 = slirp->tcp_last_so;", "if (VAR_12->so_fport != VAR_5->ti_dport ||\nVAR_12->so_lport != VAR_5->ti_sport ||\nVAR_12->so_laddr.s_addr != VAR_5->ti_src.s_addr ||\nVAR_12->so_faddr.s_addr != VAR_5->ti_dst.s_addr) {", "VAR_12 = solookup(&slirp->tcb, VAR_5->ti_src, VAR_5->ti_sport,\nVAR_5->ti_dst, VAR_5->ti_dport);", "if (VAR_12)\nslirp->tcp_last_so = VAR_12;", "}", "if (VAR_12 == NULL) {", "if ((VAR_11 & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)\ngoto dropwithreset;", "if ((VAR_12 = socreate(slirp)) == NULL)\ngoto dropwithreset;", "if (tcp_attach(VAR_12) < 0) {", "free(VAR_12);", "goto dropwithreset;", "}", "sbreserve(&VAR_12->so_snd, TCP_SNDSPACE);", "sbreserve(&VAR_12->so_rcv, TCP_RCVSPACE);", "VAR_12->so_laddr = VAR_5->ti_src;", "VAR_12->so_lport = VAR_5->ti_sport;", "VAR_12->so_faddr = VAR_5->ti_dst;", "VAR_12->so_fport = VAR_5->ti_dport;", "if ((VAR_12->so_iptos = tcp_tos(VAR_12)) == 0)\nVAR_12->so_iptos = ((struct VAR_4 *)VAR_5)->ip_tos;", "VAR_10 = sototcpcb(VAR_12);", "VAR_10->t_state = TCPS_LISTEN;", "}", "if (VAR_12->so_state & SS_ISFCONNECTING)\ngoto drop;", "VAR_10 = sototcpcb(VAR_12);", "if (VAR_10 == NULL)\ngoto dropwithreset;", "if (VAR_10->t_state == TCPS_CLOSED)\ngoto drop;", "tiwin = VAR_5->ti_win;", "VAR_10->t_idle = 0;", "if (SO_OPTIONS)\nVAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;", "else\nVAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;", "if (optp && VAR_10->t_state != TCPS_LISTEN)\ntcp_dooptions(VAR_10, (u_char *)optp, VAR_6, VAR_5);", "if (VAR_10->t_state == TCPS_ESTABLISHED &&\n(VAR_11 & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&\nVAR_5->ti_seq == VAR_10->rcv_nxt &&\ntiwin && tiwin == VAR_10->snd_wnd &&\nVAR_10->snd_nxt == VAR_10->snd_max) {", "if (VAR_5->ti_len == 0) {", "if (SEQ_GT(VAR_5->ti_ack, VAR_10->snd_una) &&\nSEQ_LEQ(VAR_5->ti_ack, VAR_10->snd_max) &&\nVAR_10->snd_cwnd >= VAR_10->snd_wnd) {", "if (VAR_10->t_rtt &&\nSEQ_GT(VAR_5->ti_ack, VAR_10->t_rtseq))\ntcp_xmit_timer(VAR_10, VAR_10->t_rtt);", "VAR_14 = VAR_5->ti_ack - VAR_10->snd_una;", "sbdrop(&VAR_12->so_snd, VAR_14);", "VAR_10->snd_una = VAR_5->ti_ack;", "m_free(VAR_0);", "if (VAR_10->snd_una == VAR_10->snd_max)\nVAR_10->t_timer[TCPT_REXMT] = 0;", "else if (VAR_10->t_timer[TCPT_PERSIST] == 0)\nVAR_10->t_timer[TCPT_REXMT] = VAR_10->t_rxtcur;", "if (VAR_12->so_snd.sb_cc)\n(void) tcp_output(VAR_10);", "return;", "}", "} else if (VAR_5->ti_ack == VAR_10->snd_una &&", "tcpfrag_list_empty(VAR_10) &&\nVAR_5->ti_len <= sbspace(&VAR_12->so_rcv)) {", "VAR_10->rcv_nxt += VAR_5->ti_len;", "if (VAR_12->so_emu) {", "if (tcp_emu(VAR_12,VAR_0)) sbappend(VAR_12, VAR_0);", "} else", "sbappend(VAR_12, VAR_0);", "VAR_10->t_flags |= TF_ACKNOW;", "tcp_output(VAR_10);", "return;", "}", "}", "{ int VAR_20;", "VAR_20 = sbspace(&VAR_12->so_rcv);", "if (VAR_20 < 0)\nVAR_20 = 0;", "VAR_10->rcv_wnd = max(VAR_20, (int)(VAR_10->rcv_adv - VAR_10->rcv_nxt));", "}", "switch (VAR_10->t_state) {", "case TCPS_LISTEN: {", "if (VAR_11 & TH_RST)\ngoto drop;", "if (VAR_11 & TH_ACK)\ngoto dropwithreset;", "if ((VAR_11 & TH_SYN) == 0)\ngoto drop;", "if ((VAR_12->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==\nslirp->vnetwork_addr.s_addr) {", "if (VAR_12->so_faddr.s_addr != slirp->vhost_addr.s_addr &&\nVAR_12->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) {", "for (VAR_19 = slirp->exec_list; VAR_19;", "VAR_19 = VAR_19->ex_next) {", "if(VAR_19->ex_fport == VAR_12->so_fport &&\nVAR_12->so_faddr.s_addr == VAR_19->ex_addr.s_addr) {", "VAR_12->so_state |= SS_CTL;", "break;", "}", "}", "if (VAR_12->so_state & SS_CTL) {", "goto cont_input;", "}", "}", "}", "if (VAR_12->so_emu & EMU_NOCONNECT) {", "VAR_12->so_emu &= ~EMU_NOCONNECT;", "goto cont_input;", "}", "if((tcp_fconnect(VAR_12) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {", "u_char code=ICMP_UNREACH_NET;", "DEBUG_MISC((dfd, \" tcp fconnect errno = %d-%s\\n\",\nerrno,strerror(errno)));", "if(errno == ECONNREFUSED) {", "tcp_respond(VAR_10, VAR_5, VAR_0, VAR_5->ti_seq+1, (tcp_seq)0,\nTH_RST|TH_ACK);", "} else {", "if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;", "HTONL(VAR_5->ti_seq);", "HTONL(VAR_5->ti_ack);", "HTONS(VAR_5->ti_win);", "HTONS(VAR_5->ti_urp);", "VAR_0->m_data -= sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr);", "VAR_0->m_len += sizeof(struct tcpiphdr)+VAR_9-sizeof(struct tcphdr);", "*VAR_4=VAR_3;", "icmp_error(VAR_0, ICMP_UNREACH,code, 0,strerror(errno));", "}", "tcp_close(VAR_10);", "m_free(VAR_0);", "} else {", "VAR_12->so_m = VAR_0;", "VAR_12->so_ti = VAR_5;", "VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;", "VAR_10->t_state = TCPS_SYN_RECEIVED;", "tcp_template(VAR_10);", "}", "return;", "cont_conn:\nif (VAR_12->so_state & SS_NOFDREF) {", "VAR_10 = tcp_close(VAR_10);", "goto dropwithreset;", "}", "cont_input:\ntcp_template(VAR_10);", "if (optp)\ntcp_dooptions(VAR_10, (u_char *)optp, VAR_6, VAR_5);", "if (VAR_17)\nVAR_10->VAR_17 = VAR_17;", "else\nVAR_10->VAR_17 = slirp->tcp_iss;", "slirp->tcp_iss += TCP_ISSINCR/2;", "VAR_10->irs = VAR_5->ti_seq;", "tcp_sendseqinit(VAR_10);", "tcp_rcvseqinit(VAR_10);", "VAR_10->t_flags |= TF_ACKNOW;", "VAR_10->t_state = TCPS_SYN_RECEIVED;", "VAR_10->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;", "goto trimthenstep6;", "}", "case TCPS_SYN_SENT:\nif ((VAR_11 & TH_ACK) &&\n(SEQ_LEQ(VAR_5->ti_ack, VAR_10->VAR_17) ||\nSEQ_GT(VAR_5->ti_ack, VAR_10->snd_max)))\ngoto dropwithreset;", "if (VAR_11 & TH_RST) {", "if (VAR_11 & TH_ACK) {", "tcp_drop(VAR_10, 0);", "}", "goto drop;", "}", "if ((VAR_11 & TH_SYN) == 0)\ngoto drop;", "if (VAR_11 & TH_ACK) {", "VAR_10->snd_una = VAR_5->ti_ack;", "if (SEQ_LT(VAR_10->snd_nxt, VAR_10->snd_una))\nVAR_10->snd_nxt = VAR_10->snd_una;", "}", "VAR_10->t_timer[TCPT_REXMT] = 0;", "VAR_10->irs = VAR_5->ti_seq;", "tcp_rcvseqinit(VAR_10);", "VAR_10->t_flags |= TF_ACKNOW;", "if (VAR_11 & TH_ACK && SEQ_GT(VAR_10->snd_una, VAR_10->VAR_17)) {", "soisfconnected(VAR_12);", "VAR_10->t_state = TCPS_ESTABLISHED;", "(void) tcp_reass(VAR_10, (struct tcpiphdr *)0,\n(struct mbuf *)0);", "if (VAR_10->t_rtt)\ntcp_xmit_timer(VAR_10, VAR_10->t_rtt);", "} else", "VAR_10->t_state = TCPS_SYN_RECEIVED;", "trimthenstep6:\nVAR_5->ti_seq++;", "if (VAR_5->ti_len > VAR_10->rcv_wnd) {", "VAR_13 = VAR_5->ti_len - VAR_10->rcv_wnd;", "m_adj(VAR_0, -VAR_13);", "VAR_5->ti_len = VAR_10->rcv_wnd;", "VAR_11 &= ~TH_FIN;", "}", "VAR_10->snd_wl1 = VAR_5->ti_seq - 1;", "VAR_10->rcv_up = VAR_5->ti_seq;", "goto step6;", "}", "VAR_13 = VAR_10->rcv_nxt - VAR_5->ti_seq;", "if (VAR_13 > 0) {", "if (VAR_11 & TH_SYN) {", "VAR_11 &= ~TH_SYN;", "VAR_5->ti_seq++;", "if (VAR_5->ti_urp > 1)\nVAR_5->ti_urp--;", "else\nVAR_11 &= ~TH_URG;", "VAR_13--;", "}", "if (VAR_13 > VAR_5->ti_len\n|| (VAR_13 == VAR_5->ti_len && (VAR_11 & TH_FIN) == 0)) {", "VAR_11 &= ~TH_FIN;", "VAR_10->t_flags |= TF_ACKNOW;", "VAR_13 = VAR_5->ti_len;", "}", "m_adj(VAR_0, VAR_13);", "VAR_5->ti_seq += VAR_13;", "VAR_5->ti_len -= VAR_13;", "if (VAR_5->ti_urp > VAR_13)\nVAR_5->ti_urp -= VAR_13;", "else {", "VAR_11 &= ~TH_URG;", "VAR_5->ti_urp = 0;", "}", "}", "if ((VAR_12->so_state & SS_NOFDREF) &&\nVAR_10->t_state > TCPS_CLOSE_WAIT && VAR_5->ti_len) {", "VAR_10 = tcp_close(VAR_10);", "goto dropwithreset;", "}", "VAR_13 = (VAR_5->ti_seq+VAR_5->ti_len) - (VAR_10->rcv_nxt+VAR_10->rcv_wnd);", "if (VAR_13 > 0) {", "if (VAR_13 >= VAR_5->ti_len) {", "if (VAR_11 & TH_SYN &&\nVAR_10->t_state == TCPS_TIME_WAIT &&\nSEQ_GT(VAR_5->ti_seq, VAR_10->rcv_nxt)) {", "VAR_17 = VAR_10->rcv_nxt + TCP_ISSINCR;", "VAR_10 = tcp_close(VAR_10);", "goto findso;", "}", "if (VAR_10->rcv_wnd == 0 && VAR_5->ti_seq == VAR_10->rcv_nxt) {", "VAR_10->t_flags |= TF_ACKNOW;", "} else {", "goto dropafterack;", "}", "}", "m_adj(VAR_0, -VAR_13);", "VAR_5->ti_len -= VAR_13;", "VAR_11 &= ~(TH_PUSH|TH_FIN);", "}", "if (VAR_11&TH_RST) switch (VAR_10->t_state) {", "case TCPS_SYN_RECEIVED:\ncase TCPS_ESTABLISHED:\ncase TCPS_FIN_WAIT_1:\ncase TCPS_FIN_WAIT_2:\ncase TCPS_CLOSE_WAIT:\nVAR_10->t_state = TCPS_CLOSED;", "tcp_close(VAR_10);", "goto drop;", "case TCPS_CLOSING:\ncase TCPS_LAST_ACK:\ncase TCPS_TIME_WAIT:\ntcp_close(VAR_10);", "goto drop;", "}", "if (VAR_11 & TH_SYN) {", "VAR_10 = tcp_drop(VAR_10,0);", "goto dropwithreset;", "}", "if ((VAR_11 & TH_ACK) == 0) goto drop;", "switch (VAR_10->t_state) {", "case TCPS_SYN_RECEIVED:\nif (SEQ_GT(VAR_10->snd_una, VAR_5->ti_ack) ||\nSEQ_GT(VAR_5->ti_ack, VAR_10->snd_max))\ngoto dropwithreset;", "VAR_10->t_state = TCPS_ESTABLISHED;", "VAR_10->snd_una=VAR_5->ti_ack;", "if (VAR_12->so_state & SS_CTL) {", "VAR_18 = tcp_ctl(VAR_12);", "if (VAR_18 == 1) {", "soisfconnected(VAR_12);", "VAR_12->so_state &= ~SS_CTL;", "} else if (VAR_18 == 2) {", "VAR_12->so_state &= SS_PERSISTENT_MASK;", "VAR_12->so_state |= SS_NOFDREF;", "} else {", "VAR_16 = 1;", "VAR_10->t_state = TCPS_FIN_WAIT_1;", "}", "} else {", "soisfconnected(VAR_12);", "}", "(void) tcp_reass(VAR_10, (struct tcpiphdr *)0, (struct mbuf *)0);", "VAR_10->snd_wl1 = VAR_5->ti_seq - 1;", "goto synrx_to_est;", "case TCPS_ESTABLISHED:\ncase TCPS_FIN_WAIT_1:\ncase TCPS_FIN_WAIT_2:\ncase TCPS_CLOSE_WAIT:\ncase TCPS_CLOSING:\ncase TCPS_LAST_ACK:\ncase TCPS_TIME_WAIT:\nif (SEQ_LEQ(VAR_5->ti_ack, VAR_10->snd_una)) {", "if (VAR_5->ti_len == 0 && tiwin == VAR_10->snd_wnd) {", "DEBUG_MISC((dfd, \" dup ack VAR_0 = %lx VAR_12 = %lx\\n\",\n(long )VAR_0, (long )VAR_12));", "if (VAR_10->t_timer[TCPT_REXMT] == 0 ||\nVAR_5->ti_ack != VAR_10->snd_una)\nVAR_10->t_dupacks = 0;", "else if (++VAR_10->t_dupacks == TCPREXMTTHRESH) {", "tcp_seq onxt = VAR_10->snd_nxt;", "u_int VAR_20 =\nmin(VAR_10->snd_wnd, VAR_10->snd_cwnd) / 2 /\nVAR_10->t_maxseg;", "if (VAR_20 < 2)\nVAR_20 = 2;", "VAR_10->snd_ssthresh = VAR_20 * VAR_10->t_maxseg;", "VAR_10->t_timer[TCPT_REXMT] = 0;", "VAR_10->t_rtt = 0;", "VAR_10->snd_nxt = VAR_5->ti_ack;", "VAR_10->snd_cwnd = VAR_10->t_maxseg;", "(void) tcp_output(VAR_10);", "VAR_10->snd_cwnd = VAR_10->snd_ssthresh +\nVAR_10->t_maxseg * VAR_10->t_dupacks;", "if (SEQ_GT(onxt, VAR_10->snd_nxt))\nVAR_10->snd_nxt = onxt;", "goto drop;", "} else if (VAR_10->t_dupacks > TCPREXMTTHRESH) {", "VAR_10->snd_cwnd += VAR_10->t_maxseg;", "(void) tcp_output(VAR_10);", "goto drop;", "}", "} else", "VAR_10->t_dupacks = 0;", "break;", "}", "synrx_to_est:\nif (VAR_10->t_dupacks > TCPREXMTTHRESH &&\nVAR_10->snd_cwnd > VAR_10->snd_ssthresh)\nVAR_10->snd_cwnd = VAR_10->snd_ssthresh;", "VAR_10->t_dupacks = 0;", "if (SEQ_GT(VAR_5->ti_ack, VAR_10->snd_max)) {", "goto dropafterack;", "}", "VAR_14 = VAR_5->ti_ack - VAR_10->snd_una;", "if (VAR_10->t_rtt && SEQ_GT(VAR_5->ti_ack, VAR_10->t_rtseq))\ntcp_xmit_timer(VAR_10,VAR_10->t_rtt);", "if (VAR_5->ti_ack == VAR_10->snd_max) {", "VAR_10->t_timer[TCPT_REXMT] = 0;", "VAR_16 = 1;", "} else if (VAR_10->t_timer[TCPT_PERSIST] == 0)", "VAR_10->t_timer[TCPT_REXMT] = VAR_10->t_rxtcur;", "{", "register u_int VAR_21 = VAR_10->snd_cwnd;", "register u_int VAR_22 = VAR_10->t_maxseg;", "if (VAR_21 > VAR_10->snd_ssthresh)\nVAR_22 = VAR_22 * VAR_22 / VAR_21;", "VAR_10->snd_cwnd = min(VAR_21 + VAR_22, TCP_MAXWIN<<VAR_10->snd_scale);", "}", "if (VAR_14 > VAR_12->so_snd.sb_cc) {", "VAR_10->snd_wnd -= VAR_12->so_snd.sb_cc;", "sbdrop(&VAR_12->so_snd, (int )VAR_12->so_snd.sb_cc);", "VAR_15 = 1;", "} else {", "sbdrop(&VAR_12->so_snd, VAR_14);", "VAR_10->snd_wnd -= VAR_14;", "VAR_15 = 0;", "}", "VAR_10->snd_una = VAR_5->ti_ack;", "if (SEQ_LT(VAR_10->snd_nxt, VAR_10->snd_una))\nVAR_10->snd_nxt = VAR_10->snd_una;", "switch (VAR_10->t_state) {", "case TCPS_FIN_WAIT_1:\nif (VAR_15) {", "if (VAR_12->so_state & SS_FCANTRCVMORE) {", "VAR_10->t_timer[TCPT_2MSL] = TCP_MAXIDLE;", "}", "VAR_10->t_state = TCPS_FIN_WAIT_2;", "}", "break;", "case TCPS_CLOSING:\nif (VAR_15) {", "VAR_10->t_state = TCPS_TIME_WAIT;", "tcp_canceltimers(VAR_10);", "VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;", "}", "break;", "case TCPS_LAST_ACK:\nif (VAR_15) {", "tcp_close(VAR_10);", "goto drop;", "}", "break;", "case TCPS_TIME_WAIT:\nVAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;", "goto dropafterack;", "}", "}", "step6:\nif ((VAR_11 & TH_ACK) &&\n(SEQ_LT(VAR_10->snd_wl1, VAR_5->ti_seq) ||\n(VAR_10->snd_wl1 == VAR_5->ti_seq && (SEQ_LT(VAR_10->snd_wl2, VAR_5->ti_ack) ||\n(VAR_10->snd_wl2 == VAR_5->ti_ack && tiwin > VAR_10->snd_wnd))))) {", "VAR_10->snd_wnd = tiwin;", "VAR_10->snd_wl1 = VAR_5->ti_seq;", "VAR_10->snd_wl2 = VAR_5->ti_ack;", "if (VAR_10->snd_wnd > VAR_10->max_sndwnd)\nVAR_10->max_sndwnd = VAR_10->snd_wnd;", "VAR_16 = 1;", "}", "if ((VAR_11 & TH_URG) && VAR_5->ti_urp &&\nTCPS_HAVERCVDFIN(VAR_10->t_state) == 0) {", "if (VAR_5->ti_urp + VAR_12->so_rcv.sb_cc > VAR_12->so_rcv.sb_datalen) {", "VAR_5->ti_urp = 0;", "VAR_11 &= ~TH_URG;", "goto dodata;", "}", "if (SEQ_GT(VAR_5->ti_seq+VAR_5->ti_urp, VAR_10->rcv_up)) {", "VAR_10->rcv_up = VAR_5->ti_seq + VAR_5->ti_urp;", "VAR_12->so_urgc = VAR_12->so_rcv.sb_cc +\n(VAR_10->rcv_up - VAR_10->rcv_nxt);", "VAR_10->rcv_up = VAR_5->ti_seq + VAR_5->ti_urp;", "}", "} else", "if (SEQ_GT(VAR_10->rcv_nxt, VAR_10->rcv_up))\nVAR_10->rcv_up = VAR_10->rcv_nxt;", "dodata:\nif (VAR_5->ti_len && (unsigned)VAR_5->ti_len <= 5 &&\n((struct tcpiphdr_2 *)VAR_5)->first_char == (char)27) {", "VAR_10->t_flags |= TF_ACKNOW;", "}", "if ((VAR_5->ti_len || (VAR_11&TH_FIN)) &&\nTCPS_HAVERCVDFIN(VAR_10->t_state) == 0) {", "TCP_REASS(VAR_10, VAR_5, VAR_0, VAR_12, VAR_11);", "} else {", "m_free(VAR_0);", "VAR_11 &= ~TH_FIN;", "}", "if (VAR_11 & TH_FIN) {", "if (TCPS_HAVERCVDFIN(VAR_10->t_state) == 0) {", "sofwdrain(VAR_12);", "VAR_10->t_flags |= TF_ACKNOW;", "VAR_10->rcv_nxt++;", "}", "switch (VAR_10->t_state) {", "case TCPS_SYN_RECEIVED:\ncase TCPS_ESTABLISHED:\nif(VAR_12->so_emu == EMU_CTL)\nVAR_10->t_state = TCPS_LAST_ACK;", "else\nVAR_10->t_state = TCPS_CLOSE_WAIT;", "break;", "case TCPS_FIN_WAIT_1:\nVAR_10->t_state = TCPS_CLOSING;", "break;", "case TCPS_FIN_WAIT_2:\nVAR_10->t_state = TCPS_TIME_WAIT;", "tcp_canceltimers(VAR_10);", "VAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;", "break;", "case TCPS_TIME_WAIT:\nVAR_10->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;", "break;", "}", "}", "if (VAR_16 || (VAR_10->t_flags & TF_ACKNOW)) {", "(void) tcp_output(VAR_10);", "}", "return;", "dropafterack:\nif (VAR_11 & TH_RST)\ngoto drop;", "m_free(VAR_0);", "VAR_10->t_flags |= TF_ACKNOW;", "(void) tcp_output(VAR_10);", "return;", "dropwithreset:\nif (VAR_11 & TH_ACK)\ntcp_respond(VAR_10, VAR_5, VAR_0, (tcp_seq)0, VAR_5->ti_ack, TH_RST);", "else {", "if (VAR_11 & TH_SYN) VAR_5->ti_len++;", "tcp_respond(VAR_10, VAR_5, VAR_0, VAR_5->ti_seq+VAR_5->ti_len, (tcp_seq)0,\nTH_RST|TH_ACK);", "}", "return;", "drop:\nm_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 37, 39 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 113 ], [ 115 ], [ 117 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 233, 235 ], [ 237, 239, 241, 243 ], [ 245, 247 ], [ 249, 251 ], [ 253 ], [ 283 ], [ 285, 287 ], [ 291, 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 321, 323 ], [ 327 ], [ 329 ], [ 331 ], [ 345, 347 ], [ 351 ], [ 357, 359 ], [ 361, 363 ], [ 367 ], [ 379 ], [ 381, 383 ], [ 385, 387 ], [ 399, 401 ], [ 441, 443, 445, 447, 449 ], [ 451 ], [ 453, 455, 457 ], [ 465, 467, 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 499, 501 ], [ 503, 505 ], [ 519, 521 ], [ 525 ], [ 527 ], [ 529 ], [ 531, 533 ], [ 545 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587 ], [ 601 ], [ 603 ], [ 605, 607 ], [ 609 ], [ 611 ], [ 615 ], [ 645 ], [ 649, 651 ], [ 653, 655 ], [ 657, 659 ], [ 681, 683 ], [ 685, 687 ], [ 691 ], [ 693 ], [ 695, 697 ], [ 699 ], [ 701 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711 ], [ 713 ], [ 717 ], [ 721 ], [ 723 ], [ 725 ], [ 727 ], [ 731 ], [ 733 ], [ 735, 737 ], [ 739 ], [ 743, 745 ], [ 747 ], [ 749 ], [ 751 ], [ 753 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 765 ], [ 767 ], [ 769 ], [ 771 ], [ 773 ], [ 787 ], [ 789 ], [ 791 ], [ 793 ], [ 795 ], [ 797 ], [ 799 ], [ 803, 811 ], [ 813 ], [ 815 ], [ 817 ], [ 819, 821 ], [ 825, 827 ], [ 831, 833 ], [ 835, 837 ], [ 839 ], [ 841 ], [ 843 ], [ 845 ], [ 847 ], [ 849 ], [ 851 ], [ 853 ], [ 855 ], [ 883, 885, 887, 889, 891 ], [ 895 ], [ 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 909, 911 ], [ 913 ], [ 915 ], [ 917, 919 ], [ 921 ], [ 925 ], [ 927 ], [ 929 ], [ 931 ], [ 933 ], [ 935 ], [ 937 ], [ 941, 943 ], [ 953, 955 ], [ 957 ], [ 959 ], [ 963, 975 ], [ 977 ], [ 979 ], [ 981 ], [ 983 ], [ 985 ], [ 987 ], [ 989 ], [ 991 ], [ 993 ], [ 995 ], [ 1009 ], [ 1011 ], [ 1013 ], [ 1015 ], [ 1017 ], [ 1019, 1021 ], [ 1023, 1025 ], [ 1027 ], [ 1029 ], [ 1037, 1039 ], [ 1051 ], [ 1063 ], [ 1065 ], [ 1067 ], [ 1069 ], [ 1071 ], [ 1073 ], [ 1075, 1077 ], [ 1079 ], [ 1081 ], [ 1083 ], [ 1085 ], [ 1087 ], [ 1097, 1099 ], [ 1101 ], [ 1103 ], [ 1105 ], [ 1117 ], [ 1119 ], [ 1121 ], [ 1135, 1137, 1139 ], [ 1141 ], [ 1143 ], [ 1145 ], [ 1147 ], [ 1163 ], [ 1165 ], [ 1167 ], [ 1169 ], [ 1171 ], [ 1173 ], [ 1175 ], [ 1177 ], [ 1179 ], [ 1181 ], [ 1205 ], [ 1209, 1211, 1213, 1215, 1217, 1219 ], [ 1221 ], [ 1223 ], [ 1227, 1229, 1231, 1233 ], [ 1235 ], [ 1237 ], [ 1249 ], [ 1251 ], [ 1253 ], [ 1255 ], [ 1265 ], [ 1275 ], [ 1287, 1291, 1293, 1295 ], [ 1297 ], [ 1313 ], [ 1315 ], [ 1319 ], [ 1321 ], [ 1323 ], [ 1325 ], [ 1327 ], [ 1329 ], [ 1331 ], [ 1333 ], [ 1335 ], [ 1337 ], [ 1339 ], [ 1341 ], [ 1343 ], [ 1345 ], [ 1349 ], [ 1351 ], [ 1355 ], [ 1377, 1379, 1381, 1383, 1385, 1387, 1389, 1393 ], [ 1395 ], [ 1397, 1399 ], [ 1449, 1451, 1453 ], [ 1455 ], [ 1457 ], [ 1459, 1461, 1463 ], [ 1467, 1469 ], [ 1471 ], [ 1473 ], [ 1475 ], [ 1477 ], [ 1479 ], [ 1481 ], [ 1483, 1485 ], [ 1487, 1489 ], [ 1491 ], [ 1493 ], [ 1495 ], [ 1497 ], [ 1499 ], [ 1501 ], [ 1503 ], [ 1505 ], [ 1507 ], [ 1509 ], [ 1511, 1521, 1523, 1525 ], [ 1527 ], [ 1529 ], [ 1531 ], [ 1533 ], [ 1535 ], [ 1553, 1555 ], [ 1571 ], [ 1573 ], [ 1575 ], [ 1577 ], [ 1579 ], [ 1595 ], [ 1597 ], [ 1599 ], [ 1603, 1605 ], [ 1607 ], [ 1609 ], [ 1611 ], [ 1613 ], [ 1615 ], [ 1617 ], [ 1619 ], [ 1621 ], [ 1623 ], [ 1625 ], [ 1627 ], [ 1629 ], [ 1631, 1633 ], [ 1637 ], [ 1651, 1653 ], [ 1669 ], [ 1671 ], [ 1673 ], [ 1675 ], [ 1677 ], [ 1679 ], [ 1695, 1697 ], [ 1699 ], [ 1701 ], [ 1703 ], [ 1705 ], [ 1707 ], [ 1723, 1725 ], [ 1727 ], [ 1729 ], [ 1731 ], [ 1733 ], [ 1747, 1749 ], [ 1751 ], [ 1753 ], [ 1755 ], [ 1759, 1769, 1771, 1773, 1775 ], [ 1777 ], [ 1779 ], [ 1781 ], [ 1783, 1785 ], [ 1787 ], [ 1789 ], [ 1799, 1801 ], [ 1815 ], [ 1817 ], [ 1819 ], [ 1821 ], [ 1823 ], [ 1853 ], [ 1855 ], [ 1857, 1859 ], [ 1861 ], [ 1865 ], [ 1867 ], [ 1879, 1881 ], [ 1883, 1897, 1899 ], [ 1901 ], [ 1903 ], [ 1923, 1925 ], [ 1927 ], [ 1929 ], [ 1931 ], [ 1933 ], [ 1935 ], [ 1947 ], [ 1949 ], [ 1969 ], [ 1973 ], [ 1975 ], [ 1977 ], [ 1979 ], [ 1991, 1993, 1995, 1997 ], [ 1999, 2001 ], [ 2003 ], [ 2015, 2017 ], [ 2019 ], [ 2033, 2035 ], [ 2037 ], [ 2039 ], [ 2041 ], [ 2051, 2053 ], [ 2055 ], [ 2057 ], [ 2059 ], [ 2069 ], [ 2071 ], [ 2073 ], [ 2075 ], [ 2079, 2089, 2091 ], [ 2093 ], [ 2095 ], [ 2097 ], [ 2099 ], [ 2103, 2107, 2109 ], [ 2111 ], [ 2113 ], [ 2115, 2117 ], [ 2119 ], [ 2123 ], [ 2127, 2135 ], [ 2137 ] ]
11,598
static bool cmd_identify(IDEState *s, uint8_t cmd) { if (s->bs && s->drive_kind != IDE_CD) { if (s->drive_kind != IDE_CFATA) { ide_identify(s); } else { ide_cfata_identify(s); } s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop); ide_set_irq(s->bus); return false; } else { if (s->drive_kind == IDE_CD) { ide_set_signature(s); } ide_abort_command(s); } return true; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static bool cmd_identify(IDEState *s, uint8_t cmd) { if (s->bs && s->drive_kind != IDE_CD) { if (s->drive_kind != IDE_CFATA) { ide_identify(s); } else { ide_cfata_identify(s); } s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop); ide_set_irq(s->bus); return false; } else { if (s->drive_kind == IDE_CD) { ide_set_signature(s); } ide_abort_command(s); } return true; }
{ "code": [], "line_no": [] }
static bool FUNC_0(IDEState *s, uint8_t cmd) { if (s->bs && s->drive_kind != IDE_CD) { if (s->drive_kind != IDE_CFATA) { ide_identify(s); } else { ide_cfata_identify(s); } s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop); ide_set_irq(s->bus); return false; } else { if (s->drive_kind == IDE_CD) { ide_set_signature(s); } ide_abort_command(s); } return true; }
[ "static bool FUNC_0(IDEState *s, uint8_t cmd)\n{", "if (s->bs && s->drive_kind != IDE_CD) {", "if (s->drive_kind != IDE_CFATA) {", "ide_identify(s);", "} else {", "ide_cfata_identify(s);", "}", "s->status = READY_STAT | SEEK_STAT;", "ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);", "ide_set_irq(s->bus);", "return false;", "} else {", "if (s->drive_kind == IDE_CD) {", "ide_set_signature(s);", "}", "ide_abort_command(s);", "}", "return true;", "}" ]
[ 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 ], [ 39 ], [ 41 ] ]
11,599
static coroutine_fn int dmg_co_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { int ret; BDRVDMGState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = dmg_read(bs, sector_num, buf, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; }
false
qemu
3edf1e73d568c646202e9faa6224df4fee1bd0e6
static coroutine_fn int dmg_co_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { int ret; BDRVDMGState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = dmg_read(bs, sector_num, buf, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; }
{ "code": [], "line_no": [] }
static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { int VAR_0; BDRVDMGState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); VAR_0 = dmg_read(bs, sector_num, buf, nb_sectors); qemu_co_mutex_unlock(&s->lock); return VAR_0; }
[ "static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num,\nuint8_t *buf, int nb_sectors)\n{", "int VAR_0;", "BDRVDMGState *s = bs->opaque;", "qemu_co_mutex_lock(&s->lock);", "VAR_0 = dmg_read(bs, sector_num, buf, nb_sectors);", "qemu_co_mutex_unlock(&s->lock);", "return VAR_0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
11,600
static void cmd_read_cdvd_capacity(IDEState *s, uint8_t* buf) { uint64_t total_sectors = s->nb_sectors >> 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } /* NOTE: it is really the number of sectors minus 1 */ cpu_to_ube32(buf, total_sectors - 1); cpu_to_ube32(buf + 4, 2048); ide_atapi_cmd_reply(s, 8, 8); }
false
qemu
7a2c4b82340d621bff462672b29c88d2020d68c1
static void cmd_read_cdvd_capacity(IDEState *s, uint8_t* buf) { uint64_t total_sectors = s->nb_sectors >> 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } cpu_to_ube32(buf, total_sectors - 1); cpu_to_ube32(buf + 4, 2048); ide_atapi_cmd_reply(s, 8, 8); }
{ "code": [], "line_no": [] }
static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1) { uint64_t total_sectors = VAR_0->nb_sectors >> 2; if (total_sectors == 0) { ide_atapi_cmd_error(VAR_0, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } cpu_to_ube32(VAR_1, total_sectors - 1); cpu_to_ube32(VAR_1 + 4, 2048); ide_atapi_cmd_reply(VAR_0, 8, 8); }
[ "static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1)\n{", "uint64_t total_sectors = VAR_0->nb_sectors >> 2;", "if (total_sectors == 0) {", "ide_atapi_cmd_error(VAR_0, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);", "return;", "}", "cpu_to_ube32(VAR_1, total_sectors - 1);", "cpu_to_ube32(VAR_1 + 4, 2048);", "ide_atapi_cmd_reply(VAR_0, 8, 8);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
11,601
int64 float32_to_int64_round_to_zero( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; bits64 aSig64; int64 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0xBE; if ( 0 <= shiftCount ) { if ( a != 0xDF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { return LIT64( 0x7FFFFFFFFFFFFFFF ); } } return (sbits64) LIT64( 0x8000000000000000 ); } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig64 = aSig | 0x00800000; aSig64 <<= 40; z = aSig64>>( - shiftCount ); if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
false
qemu
f090c9d4ad5812fb92843d6470a1111c15190c4c
int64 float32_to_int64_round_to_zero( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; bits64 aSig64; int64 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0xBE; if ( 0 <= shiftCount ) { if ( a != 0xDF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { return LIT64( 0x7FFFFFFFFFFFFFFF ); } } return (sbits64) LIT64( 0x8000000000000000 ); } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig64 = aSig | 0x00800000; aSig64 <<= 40; z = aSig64>>( - shiftCount ); if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
{ "code": [], "line_no": [] }
int64 FUNC_0( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; bits64 aSig64; int64 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0xBE; if ( 0 <= shiftCount ) { if ( a != 0xDF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { return LIT64( 0x7FFFFFFFFFFFFFFF ); } } return (sbits64) LIT64( 0x8000000000000000 ); } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig64 = aSig | 0x00800000; aSig64 <<= 40; z = aSig64>>( - shiftCount ); if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
[ "int64 FUNC_0( float32 a STATUS_PARAM )\n{", "flag aSign;", "int16 aExp, shiftCount;", "bits32 aSig;", "bits64 aSig64;", "int64 z;", "aSig = extractFloat32Frac( a );", "aExp = extractFloat32Exp( a );", "aSign = extractFloat32Sign( a );", "shiftCount = aExp - 0xBE;", "if ( 0 <= shiftCount ) {", "if ( a != 0xDF000000 ) {", "float_raise( float_flag_invalid STATUS_VAR);", "if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) {", "return LIT64( 0x7FFFFFFFFFFFFFFF );", "}", "}", "return (sbits64) LIT64( 0x8000000000000000 );", "}", "else if ( aExp <= 0x7E ) {", "if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;", "return 0;", "}", "aSig64 = aSig | 0x00800000;", "aSig64 <<= 40;", "z = aSig64>>( - shiftCount );", "if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) {", "STATUS(float_exception_flags) |= float_flag_inexact;", "}", "if ( aSign ) z = - z;", "return z;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ] ]
11,602
putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse) { if (cse && cse < n) n = cse + 1; if (sloc < n-1) cpu_to_be16wu((uint16_t *)(data + sloc), do_cksum(data + css, data + n)); }
false
qemu
c6a6a5e3bb7120e1eb33eca6364a290229c1e72e
putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse) { if (cse && cse < n) n = cse + 1; if (sloc < n-1) cpu_to_be16wu((uint16_t *)(data + sloc), do_cksum(data + css, data + n)); }
{ "code": [], "line_no": [] }
FUNC_0(uint8_t *VAR_0, uint32_t VAR_1, uint32_t VAR_2, uint32_t VAR_3, uint32_t VAR_4) { if (VAR_4 && VAR_4 < VAR_1) VAR_1 = VAR_4 + 1; if (VAR_2 < VAR_1-1) cpu_to_be16wu((uint16_t *)(VAR_0 + VAR_2), do_cksum(VAR_0 + VAR_3, VAR_0 + VAR_1)); }
[ "FUNC_0(uint8_t *VAR_0, uint32_t VAR_1, uint32_t VAR_2, uint32_t VAR_3, uint32_t VAR_4)\n{", "if (VAR_4 && VAR_4 < VAR_1)\nVAR_1 = VAR_4 + 1;", "if (VAR_2 < VAR_1-1)\ncpu_to_be16wu((uint16_t *)(VAR_0 + VAR_2),\ndo_cksum(VAR_0 + VAR_3, VAR_0 + VAR_1));", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11, 13 ], [ 15 ] ]
11,603
uint32_t HELPER(lcxbr)(CPUS390XState *env, uint32_t f1, uint32_t f2) { CPU_QuadU x1, x2; x2.ll.upper = env->fregs[f2].ll; x2.ll.lower = env->fregs[f2 + 2].ll; x1.q = float128_chs(x2.q); env->fregs[f1].ll = x1.ll.upper; env->fregs[f1 + 2].ll = x1.ll.lower; return set_cc_nz_f128(x1.q); }
false
qemu
5d7fd045cafeac1831c1999cb9e1251b7906c6b2
uint32_t HELPER(lcxbr)(CPUS390XState *env, uint32_t f1, uint32_t f2) { CPU_QuadU x1, x2; x2.ll.upper = env->fregs[f2].ll; x2.ll.lower = env->fregs[f2 + 2].ll; x1.q = float128_chs(x2.q); env->fregs[f1].ll = x1.ll.upper; env->fregs[f1 + 2].ll = x1.ll.lower; return set_cc_nz_f128(x1.q); }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(lcxbr)(CPUS390XState *env, uint32_t f1, uint32_t f2) { CPU_QuadU x1, x2; x2.ll.upper = env->fregs[f2].ll; x2.ll.lower = env->fregs[f2 + 2].ll; x1.q = float128_chs(x2.q); env->fregs[f1].ll = x1.ll.upper; env->fregs[f1 + 2].ll = x1.ll.lower; return set_cc_nz_f128(x1.q); }
[ "uint32_t FUNC_0(lcxbr)(CPUS390XState *env, uint32_t f1, uint32_t f2)\n{", "CPU_QuadU x1, x2;", "x2.ll.upper = env->fregs[f2].ll;", "x2.ll.lower = env->fregs[f2 + 2].ll;", "x1.q = float128_chs(x2.q);", "env->fregs[f1].ll = x1.ll.upper;", "env->fregs[f1 + 2].ll = x1.ll.lower;", "return set_cc_nz_f128(x1.q);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
11,604
static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); pcms->nvdimm = value; }
false
qemu
5fe79386ba3cdc86fd808dde301bfc5bb7e9bded
static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); pcms->nvdimm = value; }
{ "code": [], "line_no": [] }
static void FUNC_0(Object *VAR_0, bool VAR_1, Error **VAR_2) { PCMachineState *pcms = PC_MACHINE(VAR_0); pcms->nvdimm = VAR_1; }
[ "static void FUNC_0(Object *VAR_0, bool VAR_1, Error **VAR_2)\n{", "PCMachineState *pcms = PC_MACHINE(VAR_0);", "pcms->nvdimm = VAR_1;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
11,605
static int dca_exss_parse_asset_header(DCAContext *s) { int header_pos = get_bits_count(&s->gb); int header_size; int channels; int embedded_stereo = 0; int embedded_6ch = 0; int drc_code_present; int extensions_mask; int i, j; if (get_bits_left(&s->gb) < 16) return -1; /* We will parse just enough to get to the extensions bitmask with which * we can set the profile value. */ header_size = get_bits(&s->gb, 9) + 1; skip_bits(&s->gb, 3); // asset index if (s->static_fields) { if (get_bits1(&s->gb)) skip_bits(&s->gb, 4); // asset type descriptor if (get_bits1(&s->gb)) skip_bits_long(&s->gb, 24); // language descriptor if (get_bits1(&s->gb)) { /* How can one fit 1024 bytes of text here if the maximum value * for the asset header size field above was 512 bytes? */ int text_length = get_bits(&s->gb, 10) + 1; if (get_bits_left(&s->gb) < text_length * 8) return -1; skip_bits_long(&s->gb, text_length * 8); // info text } skip_bits(&s->gb, 5); // bit resolution - 1 skip_bits(&s->gb, 4); // max sample rate code channels = get_bits(&s->gb, 8) + 1; if (get_bits1(&s->gb)) { // 1-to-1 channels to speakers int spkr_remap_sets; int spkr_mask_size = 16; int num_spkrs[7]; if (channels > 2) embedded_stereo = get_bits1(&s->gb); if (channels > 6) embedded_6ch = get_bits1(&s->gb); if (get_bits1(&s->gb)) { spkr_mask_size = (get_bits(&s->gb, 2) + 1) << 2; skip_bits(&s->gb, spkr_mask_size); // spkr activity mask } spkr_remap_sets = get_bits(&s->gb, 3); for (i = 0; i < spkr_remap_sets; i++) { /* std layout mask for each remap set */ num_spkrs[i] = dca_exss_mask2count(get_bits(&s->gb, spkr_mask_size)); } for (i = 0; i < spkr_remap_sets; i++) { int num_dec_ch_remaps = get_bits(&s->gb, 5) + 1; if (get_bits_left(&s->gb) < 0) return -1; for (j = 0; j < num_spkrs[i]; j++) { int remap_dec_ch_mask = get_bits_long(&s->gb, num_dec_ch_remaps); int num_dec_ch = av_popcount(remap_dec_ch_mask); skip_bits_long(&s->gb, num_dec_ch * 5); // remap codes } } } else { skip_bits(&s->gb, 3); // representation type } } drc_code_present = get_bits1(&s->gb); if (drc_code_present) get_bits(&s->gb, 8); // drc code if (get_bits1(&s->gb)) skip_bits(&s->gb, 5); // dialog normalization code if (drc_code_present && embedded_stereo) get_bits(&s->gb, 8); // drc stereo code if (s->mix_metadata && get_bits1(&s->gb)) { skip_bits(&s->gb, 1); // external mix skip_bits(&s->gb, 6); // post mix gain code if (get_bits(&s->gb, 2) != 3) // mixer drc code skip_bits(&s->gb, 3); // drc limit else skip_bits(&s->gb, 8); // custom drc code if (get_bits1(&s->gb)) // channel specific scaling for (i = 0; i < s->num_mix_configs; i++) skip_bits_long(&s->gb, s->mix_config_num_ch[i] * 6); // scale codes else skip_bits_long(&s->gb, s->num_mix_configs * 6); // scale codes for (i = 0; i < s->num_mix_configs; i++) { if (get_bits_left(&s->gb) < 0) return -1; dca_exss_skip_mix_coeffs(&s->gb, channels, s->mix_config_num_ch[i]); if (embedded_6ch) dca_exss_skip_mix_coeffs(&s->gb, 6, s->mix_config_num_ch[i]); if (embedded_stereo) dca_exss_skip_mix_coeffs(&s->gb, 2, s->mix_config_num_ch[i]); } } switch (get_bits(&s->gb, 2)) { case 0: extensions_mask = get_bits(&s->gb, 12); break; case 1: extensions_mask = DCA_EXT_EXSS_XLL; break; case 2: extensions_mask = DCA_EXT_EXSS_LBR; break; case 3: extensions_mask = 0; /* aux coding */ break; } /* not parsed further, we were only interested in the extensions mask */ if (get_bits_left(&s->gb) < 0) return -1; if (get_bits_count(&s->gb) - header_pos > header_size * 8) { av_log(s->avctx, AV_LOG_WARNING, "Asset header size mismatch.\n"); return -1; } skip_bits_long(&s->gb, header_pos + header_size * 8 - get_bits_count(&s->gb)); if (extensions_mask & DCA_EXT_EXSS_XLL) s->profile = FF_PROFILE_DTS_HD_MA; else if (extensions_mask & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 | DCA_EXT_EXSS_XXCH)) s->profile = FF_PROFILE_DTS_HD_HRA; if (!(extensions_mask & DCA_EXT_CORE)) av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask) av_log(s->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n", extensions_mask & DCA_CORE_EXTS, s->core_ext_mask); return 0; }
false
FFmpeg
d5d2d6c3b8cff61eb26c18bbd977881cf6d5524a
static int dca_exss_parse_asset_header(DCAContext *s) { int header_pos = get_bits_count(&s->gb); int header_size; int channels; int embedded_stereo = 0; int embedded_6ch = 0; int drc_code_present; int extensions_mask; int i, j; if (get_bits_left(&s->gb) < 16) return -1; header_size = get_bits(&s->gb, 9) + 1; skip_bits(&s->gb, 3); if (s->static_fields) { if (get_bits1(&s->gb)) skip_bits(&s->gb, 4); if (get_bits1(&s->gb)) skip_bits_long(&s->gb, 24); if (get_bits1(&s->gb)) { int text_length = get_bits(&s->gb, 10) + 1; if (get_bits_left(&s->gb) < text_length * 8) return -1; skip_bits_long(&s->gb, text_length * 8); } skip_bits(&s->gb, 5); skip_bits(&s->gb, 4); channels = get_bits(&s->gb, 8) + 1; if (get_bits1(&s->gb)) { int spkr_remap_sets; int spkr_mask_size = 16; int num_spkrs[7]; if (channels > 2) embedded_stereo = get_bits1(&s->gb); if (channels > 6) embedded_6ch = get_bits1(&s->gb); if (get_bits1(&s->gb)) { spkr_mask_size = (get_bits(&s->gb, 2) + 1) << 2; skip_bits(&s->gb, spkr_mask_size); } spkr_remap_sets = get_bits(&s->gb, 3); for (i = 0; i < spkr_remap_sets; i++) { num_spkrs[i] = dca_exss_mask2count(get_bits(&s->gb, spkr_mask_size)); } for (i = 0; i < spkr_remap_sets; i++) { int num_dec_ch_remaps = get_bits(&s->gb, 5) + 1; if (get_bits_left(&s->gb) < 0) return -1; for (j = 0; j < num_spkrs[i]; j++) { int remap_dec_ch_mask = get_bits_long(&s->gb, num_dec_ch_remaps); int num_dec_ch = av_popcount(remap_dec_ch_mask); skip_bits_long(&s->gb, num_dec_ch * 5); } } } else { skip_bits(&s->gb, 3); } } drc_code_present = get_bits1(&s->gb); if (drc_code_present) get_bits(&s->gb, 8); if (get_bits1(&s->gb)) skip_bits(&s->gb, 5); if (drc_code_present && embedded_stereo) get_bits(&s->gb, 8); if (s->mix_metadata && get_bits1(&s->gb)) { skip_bits(&s->gb, 1); skip_bits(&s->gb, 6); if (get_bits(&s->gb, 2) != 3) skip_bits(&s->gb, 3); else skip_bits(&s->gb, 8); if (get_bits1(&s->gb)) for (i = 0; i < s->num_mix_configs; i++) skip_bits_long(&s->gb, s->mix_config_num_ch[i] * 6); else skip_bits_long(&s->gb, s->num_mix_configs * 6); for (i = 0; i < s->num_mix_configs; i++) { if (get_bits_left(&s->gb) < 0) return -1; dca_exss_skip_mix_coeffs(&s->gb, channels, s->mix_config_num_ch[i]); if (embedded_6ch) dca_exss_skip_mix_coeffs(&s->gb, 6, s->mix_config_num_ch[i]); if (embedded_stereo) dca_exss_skip_mix_coeffs(&s->gb, 2, s->mix_config_num_ch[i]); } } switch (get_bits(&s->gb, 2)) { case 0: extensions_mask = get_bits(&s->gb, 12); break; case 1: extensions_mask = DCA_EXT_EXSS_XLL; break; case 2: extensions_mask = DCA_EXT_EXSS_LBR; break; case 3: extensions_mask = 0; break; } if (get_bits_left(&s->gb) < 0) return -1; if (get_bits_count(&s->gb) - header_pos > header_size * 8) { av_log(s->avctx, AV_LOG_WARNING, "Asset header size mismatch.\n"); return -1; } skip_bits_long(&s->gb, header_pos + header_size * 8 - get_bits_count(&s->gb)); if (extensions_mask & DCA_EXT_EXSS_XLL) s->profile = FF_PROFILE_DTS_HD_MA; else if (extensions_mask & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 | DCA_EXT_EXSS_XXCH)) s->profile = FF_PROFILE_DTS_HD_HRA; if (!(extensions_mask & DCA_EXT_CORE)) av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask) av_log(s->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n", extensions_mask & DCA_CORE_EXTS, s->core_ext_mask); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(DCAContext *VAR_0) { int VAR_1 = get_bits_count(&VAR_0->gb); int VAR_2; int VAR_3; int VAR_4 = 0; int VAR_5 = 0; int VAR_6; int VAR_7; int VAR_8, VAR_9; if (get_bits_left(&VAR_0->gb) < 16) return -1; VAR_2 = get_bits(&VAR_0->gb, 9) + 1; skip_bits(&VAR_0->gb, 3); if (VAR_0->static_fields) { if (get_bits1(&VAR_0->gb)) skip_bits(&VAR_0->gb, 4); if (get_bits1(&VAR_0->gb)) skip_bits_long(&VAR_0->gb, 24); if (get_bits1(&VAR_0->gb)) { int VAR_10 = get_bits(&VAR_0->gb, 10) + 1; if (get_bits_left(&VAR_0->gb) < VAR_10 * 8) return -1; skip_bits_long(&VAR_0->gb, VAR_10 * 8); } skip_bits(&VAR_0->gb, 5); skip_bits(&VAR_0->gb, 4); VAR_3 = get_bits(&VAR_0->gb, 8) + 1; if (get_bits1(&VAR_0->gb)) { int VAR_11; int VAR_12 = 16; int VAR_13[7]; if (VAR_3 > 2) VAR_4 = get_bits1(&VAR_0->gb); if (VAR_3 > 6) VAR_5 = get_bits1(&VAR_0->gb); if (get_bits1(&VAR_0->gb)) { VAR_12 = (get_bits(&VAR_0->gb, 2) + 1) << 2; skip_bits(&VAR_0->gb, VAR_12); } VAR_11 = get_bits(&VAR_0->gb, 3); for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) { VAR_13[VAR_8] = dca_exss_mask2count(get_bits(&VAR_0->gb, VAR_12)); } for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) { int VAR_14 = get_bits(&VAR_0->gb, 5) + 1; if (get_bits_left(&VAR_0->gb) < 0) return -1; for (VAR_9 = 0; VAR_9 < VAR_13[VAR_8]; VAR_9++) { int VAR_15 = get_bits_long(&VAR_0->gb, VAR_14); int VAR_16 = av_popcount(VAR_15); skip_bits_long(&VAR_0->gb, VAR_16 * 5); } } } else { skip_bits(&VAR_0->gb, 3); } } VAR_6 = get_bits1(&VAR_0->gb); if (VAR_6) get_bits(&VAR_0->gb, 8); if (get_bits1(&VAR_0->gb)) skip_bits(&VAR_0->gb, 5); if (VAR_6 && VAR_4) get_bits(&VAR_0->gb, 8); if (VAR_0->mix_metadata && get_bits1(&VAR_0->gb)) { skip_bits(&VAR_0->gb, 1); skip_bits(&VAR_0->gb, 6); if (get_bits(&VAR_0->gb, 2) != 3) skip_bits(&VAR_0->gb, 3); else skip_bits(&VAR_0->gb, 8); if (get_bits1(&VAR_0->gb)) for (VAR_8 = 0; VAR_8 < VAR_0->num_mix_configs; VAR_8++) skip_bits_long(&VAR_0->gb, VAR_0->mix_config_num_ch[VAR_8] * 6); else skip_bits_long(&VAR_0->gb, VAR_0->num_mix_configs * 6); for (VAR_8 = 0; VAR_8 < VAR_0->num_mix_configs; VAR_8++) { if (get_bits_left(&VAR_0->gb) < 0) return -1; dca_exss_skip_mix_coeffs(&VAR_0->gb, VAR_3, VAR_0->mix_config_num_ch[VAR_8]); if (VAR_5) dca_exss_skip_mix_coeffs(&VAR_0->gb, 6, VAR_0->mix_config_num_ch[VAR_8]); if (VAR_4) dca_exss_skip_mix_coeffs(&VAR_0->gb, 2, VAR_0->mix_config_num_ch[VAR_8]); } } switch (get_bits(&VAR_0->gb, 2)) { case 0: VAR_7 = get_bits(&VAR_0->gb, 12); break; case 1: VAR_7 = DCA_EXT_EXSS_XLL; break; case 2: VAR_7 = DCA_EXT_EXSS_LBR; break; case 3: VAR_7 = 0; break; } if (get_bits_left(&VAR_0->gb) < 0) return -1; if (get_bits_count(&VAR_0->gb) - VAR_1 > VAR_2 * 8) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Asset header size mismatch.\n"); return -1; } skip_bits_long(&VAR_0->gb, VAR_1 + VAR_2 * 8 - get_bits_count(&VAR_0->gb)); if (VAR_7 & DCA_EXT_EXSS_XLL) VAR_0->profile = FF_PROFILE_DTS_HD_MA; else if (VAR_7 & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 | DCA_EXT_EXSS_XXCH)) VAR_0->profile = FF_PROFILE_DTS_HD_HRA; if (!(VAR_7 & DCA_EXT_CORE)) av_log(VAR_0->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); if ((VAR_7 & DCA_CORE_EXTS) != VAR_0->core_ext_mask) av_log(VAR_0->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n", VAR_7 & DCA_CORE_EXTS, VAR_0->core_ext_mask); return 0; }
[ "static int FUNC_0(DCAContext *VAR_0)\n{", "int VAR_1 = get_bits_count(&VAR_0->gb);", "int VAR_2;", "int VAR_3;", "int VAR_4 = 0;", "int VAR_5 = 0;", "int VAR_6;", "int VAR_7;", "int VAR_8, VAR_9;", "if (get_bits_left(&VAR_0->gb) < 16)\nreturn -1;", "VAR_2 = get_bits(&VAR_0->gb, 9) + 1;", "skip_bits(&VAR_0->gb, 3);", "if (VAR_0->static_fields) {", "if (get_bits1(&VAR_0->gb))\nskip_bits(&VAR_0->gb, 4);", "if (get_bits1(&VAR_0->gb))\nskip_bits_long(&VAR_0->gb, 24);", "if (get_bits1(&VAR_0->gb)) {", "int VAR_10 = get_bits(&VAR_0->gb, 10) + 1;", "if (get_bits_left(&VAR_0->gb) < VAR_10 * 8)\nreturn -1;", "skip_bits_long(&VAR_0->gb, VAR_10 * 8);", "}", "skip_bits(&VAR_0->gb, 5);", "skip_bits(&VAR_0->gb, 4);", "VAR_3 = get_bits(&VAR_0->gb, 8) + 1;", "if (get_bits1(&VAR_0->gb)) {", "int VAR_11;", "int VAR_12 = 16;", "int VAR_13[7];", "if (VAR_3 > 2)\nVAR_4 = get_bits1(&VAR_0->gb);", "if (VAR_3 > 6)\nVAR_5 = get_bits1(&VAR_0->gb);", "if (get_bits1(&VAR_0->gb)) {", "VAR_12 = (get_bits(&VAR_0->gb, 2) + 1) << 2;", "skip_bits(&VAR_0->gb, VAR_12);", "}", "VAR_11 = get_bits(&VAR_0->gb, 3);", "for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {", "VAR_13[VAR_8] = dca_exss_mask2count(get_bits(&VAR_0->gb, VAR_12));", "}", "for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {", "int VAR_14 = get_bits(&VAR_0->gb, 5) + 1;", "if (get_bits_left(&VAR_0->gb) < 0)\nreturn -1;", "for (VAR_9 = 0; VAR_9 < VAR_13[VAR_8]; VAR_9++) {", "int VAR_15 = get_bits_long(&VAR_0->gb, VAR_14);", "int VAR_16 = av_popcount(VAR_15);", "skip_bits_long(&VAR_0->gb, VAR_16 * 5);", "}", "}", "} else {", "skip_bits(&VAR_0->gb, 3);", "}", "}", "VAR_6 = get_bits1(&VAR_0->gb);", "if (VAR_6)\nget_bits(&VAR_0->gb, 8);", "if (get_bits1(&VAR_0->gb))\nskip_bits(&VAR_0->gb, 5);", "if (VAR_6 && VAR_4)\nget_bits(&VAR_0->gb, 8);", "if (VAR_0->mix_metadata && get_bits1(&VAR_0->gb)) {", "skip_bits(&VAR_0->gb, 1);", "skip_bits(&VAR_0->gb, 6);", "if (get_bits(&VAR_0->gb, 2) != 3)\nskip_bits(&VAR_0->gb, 3);", "else\nskip_bits(&VAR_0->gb, 8);", "if (get_bits1(&VAR_0->gb))\nfor (VAR_8 = 0; VAR_8 < VAR_0->num_mix_configs; VAR_8++)", "skip_bits_long(&VAR_0->gb, VAR_0->mix_config_num_ch[VAR_8] * 6);", "else\nskip_bits_long(&VAR_0->gb, VAR_0->num_mix_configs * 6);", "for (VAR_8 = 0; VAR_8 < VAR_0->num_mix_configs; VAR_8++) {", "if (get_bits_left(&VAR_0->gb) < 0)\nreturn -1;", "dca_exss_skip_mix_coeffs(&VAR_0->gb, VAR_3, VAR_0->mix_config_num_ch[VAR_8]);", "if (VAR_5)\ndca_exss_skip_mix_coeffs(&VAR_0->gb, 6, VAR_0->mix_config_num_ch[VAR_8]);", "if (VAR_4)\ndca_exss_skip_mix_coeffs(&VAR_0->gb, 2, VAR_0->mix_config_num_ch[VAR_8]);", "}", "}", "switch (get_bits(&VAR_0->gb, 2)) {", "case 0:\nVAR_7 = get_bits(&VAR_0->gb, 12);", "break;", "case 1:\nVAR_7 = DCA_EXT_EXSS_XLL;", "break;", "case 2:\nVAR_7 = DCA_EXT_EXSS_LBR;", "break;", "case 3:\nVAR_7 = 0;", "break;", "}", "if (get_bits_left(&VAR_0->gb) < 0)\nreturn -1;", "if (get_bits_count(&VAR_0->gb) - VAR_1 > VAR_2 * 8) {", "av_log(VAR_0->avctx, AV_LOG_WARNING, \"Asset header size mismatch.\\n\");", "return -1;", "}", "skip_bits_long(&VAR_0->gb, VAR_1 + VAR_2 * 8 - get_bits_count(&VAR_0->gb));", "if (VAR_7 & DCA_EXT_EXSS_XLL)\nVAR_0->profile = FF_PROFILE_DTS_HD_MA;", "else if (VAR_7 & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 |\nDCA_EXT_EXSS_XXCH))\nVAR_0->profile = FF_PROFILE_DTS_HD_HRA;", "if (!(VAR_7 & DCA_EXT_CORE))\nav_log(VAR_0->avctx, AV_LOG_WARNING, \"DTS core detection mismatch.\\n\");", "if ((VAR_7 & DCA_CORE_EXTS) != VAR_0->core_ext_mask)\nav_log(VAR_0->avctx, AV_LOG_WARNING,\n\"DTS extensions detection mismatch (%d, %d)\\n\",\nVAR_7 & DCA_CORE_EXTS, VAR_0->core_ext_mask);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 47, 49 ], [ 53 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89, 91 ], [ 93, 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 113 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157, 159 ], [ 163, 165 ], [ 169, 171 ], [ 175 ], [ 177 ], [ 179 ], [ 183, 185 ], [ 187, 189 ], [ 193, 195 ], [ 197 ], [ 199, 201 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213, 215 ], [ 217, 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229, 231 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 247, 249 ], [ 251 ], [ 253 ], [ 261, 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279, 281 ], [ 283, 285, 287 ], [ 291, 293 ], [ 295, 297, 299, 301 ], [ 305 ], [ 307 ] ]
11,606
static int uhci_broadcast_packet(UHCIState *s, USBPacket *p) { UHCIPort *port; USBDevice *dev; int i, ret; #ifdef DEBUG_PACKET { const char *pidstr; switch(p->pid) { case USB_TOKEN_SETUP: pidstr = "SETUP"; break; case USB_TOKEN_IN: pidstr = "IN"; break; case USB_TOKEN_OUT: pidstr = "OUT"; break; default: pidstr = "?"; break; } printf("frame %d: pid=%s addr=0x%02x ep=%d len=%d\n", s->frnum, pidstr, p->devaddr, p->devep, p->len); if (p->pid != USB_TOKEN_IN) { printf(" data_out="); for(i = 0; i < p->len; i++) { printf(" %02x", p->data[i]); } printf("\n"); } } #endif for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; dev = port->port.dev; if (dev && (port->ctrl & UHCI_PORT_EN)) { ret = dev->handle_packet(dev, p); if (ret != USB_RET_NODEV) { #ifdef DEBUG_PACKET if (ret == USB_RET_ASYNC) { printf("usb-uhci: Async packet\n"); } else { printf(" ret=%d ", ret); if (p->pid == USB_TOKEN_IN && ret > 0) { printf("data_in="); for(i = 0; i < ret; i++) { printf(" %02x", p->data[i]); } } printf("\n"); } #endif return ret; } } } return USB_RET_NODEV; }
false
qemu
54f254f973a1b2ed0f3571390f4de060adfe23e8
static int uhci_broadcast_packet(UHCIState *s, USBPacket *p) { UHCIPort *port; USBDevice *dev; int i, ret; #ifdef DEBUG_PACKET { const char *pidstr; switch(p->pid) { case USB_TOKEN_SETUP: pidstr = "SETUP"; break; case USB_TOKEN_IN: pidstr = "IN"; break; case USB_TOKEN_OUT: pidstr = "OUT"; break; default: pidstr = "?"; break; } printf("frame %d: pid=%s addr=0x%02x ep=%d len=%d\n", s->frnum, pidstr, p->devaddr, p->devep, p->len); if (p->pid != USB_TOKEN_IN) { printf(" data_out="); for(i = 0; i < p->len; i++) { printf(" %02x", p->data[i]); } printf("\n"); } } #endif for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; dev = port->port.dev; if (dev && (port->ctrl & UHCI_PORT_EN)) { ret = dev->handle_packet(dev, p); if (ret != USB_RET_NODEV) { #ifdef DEBUG_PACKET if (ret == USB_RET_ASYNC) { printf("usb-uhci: Async packet\n"); } else { printf(" ret=%d ", ret); if (p->pid == USB_TOKEN_IN && ret > 0) { printf("data_in="); for(i = 0; i < ret; i++) { printf(" %02x", p->data[i]); } } printf("\n"); } #endif return ret; } } } return USB_RET_NODEV; }
{ "code": [], "line_no": [] }
static int FUNC_0(UHCIState *VAR_0, USBPacket *VAR_1) { UHCIPort *port; USBDevice *dev; int VAR_2, VAR_3; #ifdef DEBUG_PACKET { const char *pidstr; switch(VAR_1->pid) { case USB_TOKEN_SETUP: pidstr = "SETUP"; break; case USB_TOKEN_IN: pidstr = "IN"; break; case USB_TOKEN_OUT: pidstr = "OUT"; break; default: pidstr = "?"; break; } printf("frame %d: pid=%VAR_0 addr=0x%02x ep=%d len=%d\n", VAR_0->frnum, pidstr, VAR_1->devaddr, VAR_1->devep, VAR_1->len); if (VAR_1->pid != USB_TOKEN_IN) { printf(" data_out="); for(VAR_2 = 0; VAR_2 < VAR_1->len; VAR_2++) { printf(" %02x", VAR_1->data[VAR_2]); } printf("\n"); } } #endif for(VAR_2 = 0; VAR_2 < NB_PORTS; VAR_2++) { port = &VAR_0->ports[VAR_2]; dev = port->port.dev; if (dev && (port->ctrl & UHCI_PORT_EN)) { VAR_3 = dev->handle_packet(dev, VAR_1); if (VAR_3 != USB_RET_NODEV) { #ifdef DEBUG_PACKET if (VAR_3 == USB_RET_ASYNC) { printf("usb-uhci: Async packet\n"); } else { printf(" VAR_3=%d ", VAR_3); if (VAR_1->pid == USB_TOKEN_IN && VAR_3 > 0) { printf("data_in="); for(VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) { printf(" %02x", VAR_1->data[VAR_2]); } } printf("\n"); } #endif return VAR_3; } } } return USB_RET_NODEV; }
[ "static int FUNC_0(UHCIState *VAR_0, USBPacket *VAR_1)\n{", "UHCIPort *port;", "USBDevice *dev;", "int VAR_2, VAR_3;", "#ifdef DEBUG_PACKET\n{", "const char *pidstr;", "switch(VAR_1->pid) {", "case USB_TOKEN_SETUP: pidstr = \"SETUP\"; break;", "case USB_TOKEN_IN: pidstr = \"IN\"; break;", "case USB_TOKEN_OUT: pidstr = \"OUT\"; break;", "default: pidstr = \"?\"; break;", "}", "printf(\"frame %d: pid=%VAR_0 addr=0x%02x ep=%d len=%d\\n\",\nVAR_0->frnum, pidstr, VAR_1->devaddr, VAR_1->devep, VAR_1->len);", "if (VAR_1->pid != USB_TOKEN_IN) {", "printf(\" data_out=\");", "for(VAR_2 = 0; VAR_2 < VAR_1->len; VAR_2++) {", "printf(\" %02x\", VAR_1->data[VAR_2]);", "}", "printf(\"\\n\");", "}", "}", "#endif\nfor(VAR_2 = 0; VAR_2 < NB_PORTS; VAR_2++) {", "port = &VAR_0->ports[VAR_2];", "dev = port->port.dev;", "if (dev && (port->ctrl & UHCI_PORT_EN)) {", "VAR_3 = dev->handle_packet(dev, VAR_1);", "if (VAR_3 != USB_RET_NODEV) {", "#ifdef DEBUG_PACKET\nif (VAR_3 == USB_RET_ASYNC) {", "printf(\"usb-uhci: Async packet\\n\");", "} else {", "printf(\" VAR_3=%d \", VAR_3);", "if (VAR_1->pid == USB_TOKEN_IN && VAR_3 > 0) {", "printf(\"data_in=\");", "for(VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {", "printf(\" %02x\", VAR_1->data[VAR_2]);", "}", "}", "printf(\"\\n\");", "}", "#endif\nreturn VAR_3;", "}", "}", "}", "return USB_RET_NODEV;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
11,607
static inline PageDesc *page_find_alloc(target_ulong index) { PageDesc **lp, *p; lp = page_l1_map(index); if (!lp) return NULL; p = *lp; if (!p) { /* allocate if not found */ #if defined(CONFIG_USER_ONLY) unsigned long addr; size_t len = sizeof(PageDesc) * L2_SIZE; /* Don't use qemu_malloc because it may recurse. */ p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); *lp = p; addr = h2g(p); if (addr == (target_ulong)addr) { page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + len), PAGE_RESERVED); } #else p = qemu_mallocz(sizeof(PageDesc) * L2_SIZE); *lp = p; #endif } return p + (index & (L2_SIZE - 1)); }
false
qemu
fb1c2cd7d9a9955a98eb7c874a74122f1e964811
static inline PageDesc *page_find_alloc(target_ulong index) { PageDesc **lp, *p; lp = page_l1_map(index); if (!lp) return NULL; p = *lp; if (!p) { #if defined(CONFIG_USER_ONLY) unsigned long addr; size_t len = sizeof(PageDesc) * L2_SIZE; p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); *lp = p; addr = h2g(p); if (addr == (target_ulong)addr) { page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + len), PAGE_RESERVED); } #else p = qemu_mallocz(sizeof(PageDesc) * L2_SIZE); *lp = p; #endif } return p + (index & (L2_SIZE - 1)); }
{ "code": [], "line_no": [] }
static inline PageDesc *FUNC_0(target_ulong index) { PageDesc **lp, *p; lp = page_l1_map(index); if (!lp) return NULL; p = *lp; if (!p) { #if defined(CONFIG_USER_ONLY) unsigned long addr; size_t len = sizeof(PageDesc) * L2_SIZE; p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); *lp = p; addr = h2g(p); if (addr == (target_ulong)addr) { page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + len), PAGE_RESERVED); } #else p = qemu_mallocz(sizeof(PageDesc) * L2_SIZE); *lp = p; #endif } return p + (index & (L2_SIZE - 1)); }
[ "static inline PageDesc *FUNC_0(target_ulong index)\n{", "PageDesc **lp, *p;", "lp = page_l1_map(index);", "if (!lp)\nreturn NULL;", "p = *lp;", "if (!p) {", "#if defined(CONFIG_USER_ONLY)\nunsigned long addr;", "size_t len = sizeof(PageDesc) * L2_SIZE;", "p = mmap(0, len, PROT_READ | PROT_WRITE,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);", "*lp = p;", "addr = h2g(p);", "if (addr == (target_ulong)addr) {", "page_set_flags(addr & TARGET_PAGE_MASK,\nTARGET_PAGE_ALIGN(addr + len),\nPAGE_RESERVED);", "}", "#else\np = qemu_mallocz(sizeof(PageDesc) * L2_SIZE);", "*lp = p;", "#endif\n}", "return p + (index & (L2_SIZE - 1));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ] ]
11,609
static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) { DeviceState *dev = DEVICE(cpu); APICCommonState *apic; const char *apic_type = "apic"; if (kvm_irqchip_in_kernel()) { apic_type = "kvm-apic"; } else if (xen_enabled()) { apic_type = "xen-apic"; } cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type); if (cpu->apic_state == NULL) { error_setg(errp, "APIC device '%s' could not be created", apic_type); return; } object_property_add_child(OBJECT(cpu), "apic", OBJECT(cpu->apic_state), NULL); qdev_prop_set_uint8(cpu->apic_state, "id", cpu->apic_id); /* TODO: convert to link<> */ apic = APIC_COMMON(cpu->apic_state); apic->cpu = cpu; apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; }
false
qemu
46232aaacb66733d3e16dcbd0d26c32ec388801d
static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) { DeviceState *dev = DEVICE(cpu); APICCommonState *apic; const char *apic_type = "apic"; if (kvm_irqchip_in_kernel()) { apic_type = "kvm-apic"; } else if (xen_enabled()) { apic_type = "xen-apic"; } cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type); if (cpu->apic_state == NULL) { error_setg(errp, "APIC device '%s' could not be created", apic_type); return; } object_property_add_child(OBJECT(cpu), "apic", OBJECT(cpu->apic_state), NULL); qdev_prop_set_uint8(cpu->apic_state, "id", cpu->apic_id); apic = APIC_COMMON(cpu->apic_state); apic->cpu = cpu; apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; }
{ "code": [], "line_no": [] }
static void FUNC_0(X86CPU *VAR_0, Error **VAR_1) { DeviceState *dev = DEVICE(VAR_0); APICCommonState *apic; const char *VAR_2 = "apic"; if (kvm_irqchip_in_kernel()) { VAR_2 = "kvm-apic"; } else if (xen_enabled()) { VAR_2 = "xen-apic"; } VAR_0->apic_state = qdev_try_create(qdev_get_parent_bus(dev), VAR_2); if (VAR_0->apic_state == NULL) { error_setg(VAR_1, "APIC device '%s' could not be created", VAR_2); return; } object_property_add_child(OBJECT(VAR_0), "apic", OBJECT(VAR_0->apic_state), NULL); qdev_prop_set_uint8(VAR_0->apic_state, "id", VAR_0->apic_id); apic = APIC_COMMON(VAR_0->apic_state); apic->VAR_0 = VAR_0; apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; }
[ "static void FUNC_0(X86CPU *VAR_0, Error **VAR_1)\n{", "DeviceState *dev = DEVICE(VAR_0);", "APICCommonState *apic;", "const char *VAR_2 = \"apic\";", "if (kvm_irqchip_in_kernel()) {", "VAR_2 = \"kvm-apic\";", "} else if (xen_enabled()) {", "VAR_2 = \"xen-apic\";", "}", "VAR_0->apic_state = qdev_try_create(qdev_get_parent_bus(dev), VAR_2);", "if (VAR_0->apic_state == NULL) {", "error_setg(VAR_1, \"APIC device '%s' could not be created\", VAR_2);", "return;", "}", "object_property_add_child(OBJECT(VAR_0), \"apic\",\nOBJECT(VAR_0->apic_state), NULL);", "qdev_prop_set_uint8(VAR_0->apic_state, \"id\", VAR_0->apic_id);", "apic = APIC_COMMON(VAR_0->apic_state);", "apic->VAR_0 = VAR_0;", "apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
11,610
int select_watchdog_action(const char *p) { int action; char *qapi_value; qapi_value = g_ascii_strdown(p, -1); action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, NULL); g_free(qapi_value); if (action < 0) return -1; watchdog_action = action; return 0; }
false
qemu
f0df84c6c46cb632dac2d9fae5fdbe6001527c3b
int select_watchdog_action(const char *p) { int action; char *qapi_value; qapi_value = g_ascii_strdown(p, -1); action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, NULL); g_free(qapi_value); if (action < 0) return -1; watchdog_action = action; return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(const char *VAR_0) { int VAR_1; char *VAR_2; VAR_2 = g_ascii_strdown(VAR_0, -1); VAR_1 = qapi_enum_parse(&WatchdogAction_lookup, VAR_2, -1, NULL); g_free(VAR_2); if (VAR_1 < 0) return -1; watchdog_action = VAR_1; return 0; }
[ "int FUNC_0(const char *VAR_0)\n{", "int VAR_1;", "char *VAR_2;", "VAR_2 = g_ascii_strdown(VAR_0, -1);", "VAR_1 = qapi_enum_parse(&WatchdogAction_lookup, VAR_2, -1, NULL);", "g_free(VAR_2);", "if (VAR_1 < 0)\nreturn -1;", "watchdog_action = VAR_1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ] ]
11,614
static void pty_chr_read(void *opaque) { CharDriverState *chr = opaque; PtyCharDriver *s = chr->opaque; int size, len; uint8_t buf[1024]; len = sizeof(buf); if (len > s->read_bytes) len = s->read_bytes; if (len == 0) return; size = read(s->fd, buf, len); if ((size == -1 && errno == EIO) || (size == 0)) { pty_chr_state(chr, 0); return; } if (size > 0) { pty_chr_state(chr, 1); qemu_chr_read(chr, buf, size); } }
false
qemu
9bd7854e1e5d6f4cfe4558090bbd9493c12bf846
static void pty_chr_read(void *opaque) { CharDriverState *chr = opaque; PtyCharDriver *s = chr->opaque; int size, len; uint8_t buf[1024]; len = sizeof(buf); if (len > s->read_bytes) len = s->read_bytes; if (len == 0) return; size = read(s->fd, buf, len); if ((size == -1 && errno == EIO) || (size == 0)) { pty_chr_state(chr, 0); return; } if (size > 0) { pty_chr_state(chr, 1); qemu_chr_read(chr, buf, size); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { CharDriverState *chr = VAR_0; PtyCharDriver *s = chr->VAR_0; int VAR_1, VAR_2; uint8_t buf[1024]; VAR_2 = sizeof(buf); if (VAR_2 > s->read_bytes) VAR_2 = s->read_bytes; if (VAR_2 == 0) return; VAR_1 = read(s->fd, buf, VAR_2); if ((VAR_1 == -1 && errno == EIO) || (VAR_1 == 0)) { pty_chr_state(chr, 0); return; } if (VAR_1 > 0) { pty_chr_state(chr, 1); qemu_chr_read(chr, buf, VAR_1); } }
[ "static void FUNC_0(void *VAR_0)\n{", "CharDriverState *chr = VAR_0;", "PtyCharDriver *s = chr->VAR_0;", "int VAR_1, VAR_2;", "uint8_t buf[1024];", "VAR_2 = sizeof(buf);", "if (VAR_2 > s->read_bytes)\nVAR_2 = s->read_bytes;", "if (VAR_2 == 0)\nreturn;", "VAR_1 = read(s->fd, buf, VAR_2);", "if ((VAR_1 == -1 && errno == EIO) ||\n(VAR_1 == 0)) {", "pty_chr_state(chr, 0);", "return;", "}", "if (VAR_1 > 0) {", "pty_chr_state(chr, 1);", "qemu_chr_read(chr, buf, VAR_1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ] ]
11,615
static void test_visitor_out_struct(TestOutputVisitorData *data, const void *unused) { TestStruct test_struct = { .integer = 42, .boolean = false, .string = (char *) "foo"}; TestStruct *p = &test_struct; QObject *obj; QDict *qdict; visit_type_TestStruct(data->ov, NULL, &p, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QDICT); qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false); g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo"); }
false
qemu
ca6b6e1e68ac44b2e8895da10dd1c80dc03d08b7
static void test_visitor_out_struct(TestOutputVisitorData *data, const void *unused) { TestStruct test_struct = { .integer = 42, .boolean = false, .string = (char *) "foo"}; TestStruct *p = &test_struct; QObject *obj; QDict *qdict; visit_type_TestStruct(data->ov, NULL, &p, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QDICT); qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false); g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo"); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestOutputVisitorData *VAR_0, const void *VAR_1) { TestStruct test_struct = { .integer = 42, .boolean = false, .string = (char *) "foo"}; TestStruct *p = &test_struct; QObject *obj; QDict *qdict; visit_type_TestStruct(VAR_0->ov, NULL, &p, &error_abort); obj = visitor_get(VAR_0); g_assert(qobject_type(obj) == QTYPE_QDICT); qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false); g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo"); }
[ "static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "TestStruct test_struct = { .integer = 42,", ".boolean = false,\n.string = (char *) \"foo\"};", "TestStruct *p = &test_struct;", "QObject *obj;", "QDict *qdict;", "visit_type_TestStruct(VAR_0->ov, NULL, &p, &error_abort);", "obj = visitor_get(VAR_0);", "g_assert(qobject_type(obj) == QTYPE_QDICT);", "qdict = qobject_to_qdict(obj);", "g_assert_cmpint(qdict_size(qdict), ==, 3);", "g_assert_cmpint(qdict_get_int(qdict, \"integer\"), ==, 42);", "g_assert_cmpint(qdict_get_bool(qdict, \"boolean\"), ==, false);", "g_assert_cmpstr(qdict_get_str(qdict, \"string\"), ==, \"foo\");", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
11,617
static inline int check_ap(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot, int access_type) { int prot_ro; bool is_user = regime_is_user(env, mmu_idx); if (domain_prot == 3) { return PAGE_READ | PAGE_WRITE; } if (access_type == 1) { prot_ro = 0; } else { prot_ro = PAGE_READ; } switch (ap) { case 0: if (arm_feature(env, ARM_FEATURE_V7)) { return 0; } if (access_type == 1) { return 0; } switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { case SCTLR_S: return is_user ? 0 : PAGE_READ; case SCTLR_R: return PAGE_READ; default: return 0; } case 1: return is_user ? 0 : PAGE_READ | PAGE_WRITE; case 2: if (is_user) { return prot_ro; } else { return PAGE_READ | PAGE_WRITE; } case 3: return PAGE_READ | PAGE_WRITE; case 4: /* Reserved. */ return 0; case 5: return is_user ? 0 : prot_ro; case 6: return prot_ro; case 7: if (!arm_feature(env, ARM_FEATURE_V6K)) { return 0; } return prot_ro; default: abort(); } }
false
qemu
0fbf5238203041f734c51b49778223686f14366b
static inline int check_ap(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot, int access_type) { int prot_ro; bool is_user = regime_is_user(env, mmu_idx); if (domain_prot == 3) { return PAGE_READ | PAGE_WRITE; } if (access_type == 1) { prot_ro = 0; } else { prot_ro = PAGE_READ; } switch (ap) { case 0: if (arm_feature(env, ARM_FEATURE_V7)) { return 0; } if (access_type == 1) { return 0; } switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { case SCTLR_S: return is_user ? 0 : PAGE_READ; case SCTLR_R: return PAGE_READ; default: return 0; } case 1: return is_user ? 0 : PAGE_READ | PAGE_WRITE; case 2: if (is_user) { return prot_ro; } else { return PAGE_READ | PAGE_WRITE; } case 3: return PAGE_READ | PAGE_WRITE; case 4: return 0; case 5: return is_user ? 0 : prot_ro; case 6: return prot_ro; case 7: if (!arm_feature(env, ARM_FEATURE_V6K)) { return 0; } return prot_ro; default: abort(); } }
{ "code": [], "line_no": [] }
static inline int FUNC_0(CPUARMState *VAR_0, ARMMMUIdx VAR_1, int VAR_2, int VAR_3, int VAR_4) { int VAR_5; bool is_user = regime_is_user(VAR_0, VAR_1); if (VAR_3 == 3) { return PAGE_READ | PAGE_WRITE; } if (VAR_4 == 1) { VAR_5 = 0; } else { VAR_5 = PAGE_READ; } switch (VAR_2) { case 0: if (arm_feature(VAR_0, ARM_FEATURE_V7)) { return 0; } if (VAR_4 == 1) { return 0; } switch (regime_sctlr(VAR_0, VAR_1) & (SCTLR_S | SCTLR_R)) { case SCTLR_S: return is_user ? 0 : PAGE_READ; case SCTLR_R: return PAGE_READ; default: return 0; } case 1: return is_user ? 0 : PAGE_READ | PAGE_WRITE; case 2: if (is_user) { return VAR_5; } else { return PAGE_READ | PAGE_WRITE; } case 3: return PAGE_READ | PAGE_WRITE; case 4: return 0; case 5: return is_user ? 0 : VAR_5; case 6: return VAR_5; case 7: if (!arm_feature(VAR_0, ARM_FEATURE_V6K)) { return 0; } return VAR_5; default: abort(); } }
[ "static inline int FUNC_0(CPUARMState *VAR_0, ARMMMUIdx VAR_1,\nint VAR_2, int VAR_3,\nint VAR_4)\n{", "int VAR_5;", "bool is_user = regime_is_user(VAR_0, VAR_1);", "if (VAR_3 == 3) {", "return PAGE_READ | PAGE_WRITE;", "}", "if (VAR_4 == 1) {", "VAR_5 = 0;", "} else {", "VAR_5 = PAGE_READ;", "}", "switch (VAR_2) {", "case 0:\nif (arm_feature(VAR_0, ARM_FEATURE_V7)) {", "return 0;", "}", "if (VAR_4 == 1) {", "return 0;", "}", "switch (regime_sctlr(VAR_0, VAR_1) & (SCTLR_S | SCTLR_R)) {", "case SCTLR_S:\nreturn is_user ? 0 : PAGE_READ;", "case SCTLR_R:\nreturn PAGE_READ;", "default:\nreturn 0;", "}", "case 1:\nreturn is_user ? 0 : PAGE_READ | PAGE_WRITE;", "case 2:\nif (is_user) {", "return VAR_5;", "} else {", "return PAGE_READ | PAGE_WRITE;", "}", "case 3:\nreturn PAGE_READ | PAGE_WRITE;", "case 4:\nreturn 0;", "case 5:\nreturn is_user ? 0 : VAR_5;", "case 6:\nreturn VAR_5;", "case 7:\nif (!arm_feature(VAR_0, ARM_FEATURE_V6K)) {", "return 0;", "}", "return VAR_5;", "default:\nabort();", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57, 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87, 89 ], [ 91, 93 ], [ 95, 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ] ]
11,618
static int posix_aio_flush(void *opaque) { PosixAioState *s = opaque; return !!s->first_aio; }
false
qemu
9ef91a677110ec200d7b2904fc4bcae5a77329ad
static int posix_aio_flush(void *opaque) { PosixAioState *s = opaque; return !!s->first_aio; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0) { PosixAioState *s = VAR_0; return !!s->first_aio; }
[ "static int FUNC_0(void *VAR_0)\n{", "PosixAioState *s = VAR_0;", "return !!s->first_aio;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,619
static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d, hwaddr addr, bool resolve_subpage) { MemoryRegionSection *section; subpage_t *subpage; section = phys_page_find(d->phys_map, addr, d->map.nodes, d->map.sections); if (resolve_subpage && section->mr->subpage) { subpage = container_of(section->mr, subpage_t, iomem); section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; } return section; }
false
qemu
729633c2bc30496073431584eb6e304776b4ebd4
static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d, hwaddr addr, bool resolve_subpage) { MemoryRegionSection *section; subpage_t *subpage; section = phys_page_find(d->phys_map, addr, d->map.nodes, d->map.sections); if (resolve_subpage && section->mr->subpage) { subpage = container_of(section->mr, subpage_t, iomem); section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; } return section; }
{ "code": [], "line_no": [] }
static MemoryRegionSection *FUNC_0(AddressSpaceDispatch *d, hwaddr addr, bool resolve_subpage) { MemoryRegionSection *section; subpage_t *subpage; section = phys_page_find(d->phys_map, addr, d->map.nodes, d->map.sections); if (resolve_subpage && section->mr->subpage) { subpage = container_of(section->mr, subpage_t, iomem); section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; } return section; }
[ "static MemoryRegionSection *FUNC_0(AddressSpaceDispatch *d,\nhwaddr addr,\nbool resolve_subpage)\n{", "MemoryRegionSection *section;", "subpage_t *subpage;", "section = phys_page_find(d->phys_map, addr, d->map.nodes, d->map.sections);", "if (resolve_subpage && section->mr->subpage) {", "subpage = container_of(section->mr, subpage_t, iomem);", "section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];", "}", "return section;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
11,620
static void finish_read_pci_config(sPAPREnvironment *spapr, uint64_t buid, uint32_t addr, uint32_t size, target_ulong rets) { PCIDevice *pci_dev; uint32_t val; if ((size != 1) && (size != 2) && (size != 4)) { /* access must be 1, 2 or 4 bytes */ rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } pci_dev = find_dev(spapr, buid, addr); addr = rtas_pci_cfgaddr(addr); if (!pci_dev || (addr % size) || (addr >= pci_config_size(pci_dev))) { /* Access must be to a valid device, within bounds and * naturally aligned */ rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } val = pci_host_config_read_common(pci_dev, addr, pci_config_size(pci_dev), size); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, val); }
false
qemu
46c5874e9cd752ed8ded31af03472edd8fc3efc1
static void finish_read_pci_config(sPAPREnvironment *spapr, uint64_t buid, uint32_t addr, uint32_t size, target_ulong rets) { PCIDevice *pci_dev; uint32_t val; if ((size != 1) && (size != 2) && (size != 4)) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } pci_dev = find_dev(spapr, buid, addr); addr = rtas_pci_cfgaddr(addr); if (!pci_dev || (addr % size) || (addr >= pci_config_size(pci_dev))) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } val = pci_host_config_read_common(pci_dev, addr, pci_config_size(pci_dev), size); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, val); }
{ "code": [], "line_no": [] }
static void FUNC_0(sPAPREnvironment *VAR_0, uint64_t VAR_1, uint32_t VAR_2, uint32_t VAR_3, target_ulong VAR_4) { PCIDevice *pci_dev; uint32_t val; if ((VAR_3 != 1) && (VAR_3 != 2) && (VAR_3 != 4)) { rtas_st(VAR_4, 0, RTAS_OUT_HW_ERROR); return; } pci_dev = find_dev(VAR_0, VAR_1, VAR_2); VAR_2 = rtas_pci_cfgaddr(VAR_2); if (!pci_dev || (VAR_2 % VAR_3) || (VAR_2 >= pci_config_size(pci_dev))) { rtas_st(VAR_4, 0, RTAS_OUT_HW_ERROR); return; } val = pci_host_config_read_common(pci_dev, VAR_2, pci_config_size(pci_dev), VAR_3); rtas_st(VAR_4, 0, RTAS_OUT_SUCCESS); rtas_st(VAR_4, 1, val); }
[ "static void FUNC_0(sPAPREnvironment *VAR_0, uint64_t VAR_1,\nuint32_t VAR_2, uint32_t VAR_3,\ntarget_ulong VAR_4)\n{", "PCIDevice *pci_dev;", "uint32_t val;", "if ((VAR_3 != 1) && (VAR_3 != 2) && (VAR_3 != 4)) {", "rtas_st(VAR_4, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "pci_dev = find_dev(VAR_0, VAR_1, VAR_2);", "VAR_2 = rtas_pci_cfgaddr(VAR_2);", "if (!pci_dev || (VAR_2 % VAR_3) || (VAR_2 >= pci_config_size(pci_dev))) {", "rtas_st(VAR_4, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "val = pci_host_config_read_common(pci_dev, VAR_2,\npci_config_size(pci_dev), VAR_3);", "rtas_st(VAR_4, 0, RTAS_OUT_SUCCESS);", "rtas_st(VAR_4, 1, val);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57 ] ]
11,621
static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, long width, long height, long src1Stride, long src2Stride, long dstStride) { long h; for (h=0; h < height; h++) { long w; #if COMPILE_TEMPLATE_MMX #if COMPILE_TEMPLATE_SSE2 __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movdqa (%1, %%"REG_a"), %%xmm0 \n\t" "movdqa (%1, %%"REG_a"), %%xmm1 \n\t" "movdqa (%2, %%"REG_a"), %%xmm2 \n\t" "punpcklbw %%xmm2, %%xmm0 \n\t" "punpckhbw %%xmm2, %%xmm1 \n\t" "movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t" "movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a"" ); #else __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 8(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq (%2, %%"REG_a"), %%mm4 \n\t" "movq 8(%2, %%"REG_a"), %%mm5 \n\t" "punpcklbw %%mm4, %%mm0 \n\t" "punpckhbw %%mm4, %%mm1 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm3 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a ); #endif for (w= (width&(~15)); w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #else for (w=0; w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #endif dest += dstStride; src1 += src1Stride; src2 += src2Stride; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
false
FFmpeg
d1adad3cca407f493c3637e20ecd4f7124e69212
static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, long width, long height, long src1Stride, long src2Stride, long dstStride) { long h; for (h=0; h < height; h++) { long w; #if COMPILE_TEMPLATE_MMX #if COMPILE_TEMPLATE_SSE2 __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movdqa (%1, %%"REG_a"), %%xmm0 \n\t" "movdqa (%1, %%"REG_a"), %%xmm1 \n\t" "movdqa (%2, %%"REG_a"), %%xmm2 \n\t" "punpcklbw %%xmm2, %%xmm0 \n\t" "punpckhbw %%xmm2, %%xmm1 \n\t" "movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t" "movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a"" ); #else __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 8(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq (%2, %%"REG_a"), %%mm4 \n\t" "movq 8(%2, %%"REG_a"), %%mm5 \n\t" "punpcklbw %%mm4, %%mm0 \n\t" "punpckhbw %%mm4, %%mm1 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm3 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a ); #endif for (w= (width&(~15)); w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #else for (w=0; w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #endif dest += dstStride; src1 += src1Stride; src2 += src2Stride; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
{ "code": [], "line_no": [] }
static void FUNC_0(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, long width, long height, long src1Stride, long src2Stride, long dstStride) { long VAR_0; for (VAR_0=0; VAR_0 < height; VAR_0++) { long w; #if COMPILE_TEMPLATE_MMX #if COMPILE_TEMPLATE_SSE2 __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movdqa (%1, %%"REG_a"), %%xmm0 \n\t" "movdqa (%1, %%"REG_a"), %%xmm1 \n\t" "movdqa (%2, %%"REG_a"), %%xmm2 \n\t" "punpcklbw %%xmm2, %%xmm0 \n\t" "punpckhbw %%xmm2, %%xmm1 \n\t" "movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t" "movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a"" ); #else __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 8(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq (%2, %%"REG_a"), %%mm4 \n\t" "movq 8(%2, %%"REG_a"), %%mm5 \n\t" "punpcklbw %%mm4, %%mm0 \n\t" "punpckhbw %%mm4, %%mm1 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm3 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a ); #endif for (w= (width&(~15)); w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #else for (w=0; w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #endif dest += dstStride; src1 += src1Stride; src2 += src2Stride; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
[ "static void FUNC_0(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,\nlong width, long height, long src1Stride,\nlong src2Stride, long dstStride)\n{", "long VAR_0;", "for (VAR_0=0; VAR_0 < height; VAR_0++) {", "long w;", "#if COMPILE_TEMPLATE_MMX\n#if COMPILE_TEMPLATE_SSE2\n__asm__(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\") \\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\") \\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm0 \\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm1 \\n\\t\"\n\"movdqa (%2, %%\"REG_a\"), %%xmm2 \\n\\t\"\n\"punpcklbw %%xmm2, %%xmm0 \\n\\t\"\n\"punpckhbw %%xmm2, %%xmm1 \\n\\t\"\n\"movntdq %%xmm0, (%0, %%\"REG_a\", 2) \\n\\t\"\n\"movntdq %%xmm1, 16(%0, %%\"REG_a\", 2) \\n\\t\"\n\"add $16, %%\"REG_a\" \\n\\t\"\n\"cmp %3, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" ((x86_reg)width-15)\n: \"memory\", \"%\"REG_a\"\"\n);", "#else\n__asm__(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\") \\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\") \\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\"), %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq (%2, %%\"REG_a\"), %%mm4 \\n\\t\"\n\"movq 8(%2, %%\"REG_a\"), %%mm5 \\n\\t\"\n\"punpcklbw %%mm4, %%mm0 \\n\\t\"\n\"punpckhbw %%mm4, %%mm1 \\n\\t\"\n\"punpcklbw %%mm5, %%mm2 \\n\\t\"\n\"punpckhbw %%mm5, %%mm3 \\n\\t\"\nMOVNTQ\" %%mm0, (%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm1, 8(%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm2, 16(%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm3, 24(%0, %%\"REG_a\", 2) \\n\\t\"\n\"add $16, %%\"REG_a\" \\n\\t\"\n\"cmp %3, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" ((x86_reg)width-15)\n: \"memory\", \"%\"REG_a\n);", "#endif\nfor (w= (width&(~15)); w < width; w++) {", "dest[2*w+0] = src1[w];", "dest[2*w+1] = src2[w];", "}", "#else\nfor (w=0; w < width; w++) {", "dest[2*w+0] = src1[w];", "dest[2*w+1] = src2[w];", "}", "#endif\ndest += dstStride;", "src1 += src1Stride;", "src2 += src2Stride;", "}", "#if COMPILE_TEMPLATE_MMX\n__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57 ], [ 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141, 143, 145, 147, 149, 151 ], [ 153, 155 ] ]
11,622
static int spapr_nvram_init(VIOsPAPRDevice *dev) { sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev); if (nvram->drive) { nvram->size = bdrv_getlength(nvram->drive); } else { nvram->size = DEFAULT_NVRAM_SIZE; nvram->buf = g_malloc0(nvram->size); } if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) { fprintf(stderr, "spapr-nvram must be between %d and %d bytes in size\n", MIN_NVRAM_SIZE, MAX_NVRAM_SIZE); return -1; } spapr_rtas_register(RTAS_NVRAM_FETCH, "nvram-fetch", rtas_nvram_fetch); spapr_rtas_register(RTAS_NVRAM_STORE, "nvram-store", rtas_nvram_store); return 0; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static int spapr_nvram_init(VIOsPAPRDevice *dev) { sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev); if (nvram->drive) { nvram->size = bdrv_getlength(nvram->drive); } else { nvram->size = DEFAULT_NVRAM_SIZE; nvram->buf = g_malloc0(nvram->size); } if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) { fprintf(stderr, "spapr-nvram must be between %d and %d bytes in size\n", MIN_NVRAM_SIZE, MAX_NVRAM_SIZE); return -1; } spapr_rtas_register(RTAS_NVRAM_FETCH, "nvram-fetch", rtas_nvram_fetch); spapr_rtas_register(RTAS_NVRAM_STORE, "nvram-store", rtas_nvram_store); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(VIOsPAPRDevice *VAR_0) { sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(VAR_0); if (nvram->drive) { nvram->size = bdrv_getlength(nvram->drive); } else { nvram->size = DEFAULT_NVRAM_SIZE; nvram->buf = g_malloc0(nvram->size); } if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) { fprintf(stderr, "spapr-nvram must be between %d and %d bytes in size\n", MIN_NVRAM_SIZE, MAX_NVRAM_SIZE); return -1; } spapr_rtas_register(RTAS_NVRAM_FETCH, "nvram-fetch", rtas_nvram_fetch); spapr_rtas_register(RTAS_NVRAM_STORE, "nvram-store", rtas_nvram_store); return 0; }
[ "static int FUNC_0(VIOsPAPRDevice *VAR_0)\n{", "sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(VAR_0);", "if (nvram->drive) {", "nvram->size = bdrv_getlength(nvram->drive);", "} else {", "nvram->size = DEFAULT_NVRAM_SIZE;", "nvram->buf = g_malloc0(nvram->size);", "}", "if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) {", "fprintf(stderr, \"spapr-nvram must be between %d and %d bytes in size\\n\",\nMIN_NVRAM_SIZE, MAX_NVRAM_SIZE);", "return -1;", "}", "spapr_rtas_register(RTAS_NVRAM_FETCH, \"nvram-fetch\", rtas_nvram_fetch);", "spapr_rtas_register(RTAS_NVRAM_STORE, \"nvram-store\", rtas_nvram_store);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ] ]
11,623
static void test_io_channel_setup_async(SocketAddress *listen_addr, SocketAddress *connect_addr, QIOChannel **src, QIOChannel **dst) { QIOChannelSocket *lioc; struct TestIOChannelData data; data.loop = g_main_loop_new(g_main_context_default(), TRUE); lioc = qio_channel_socket_new(); qio_channel_socket_listen_async( lioc, listen_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) { SocketAddress *laddr = qio_channel_socket_get_local_address( lioc, &error_abort); g_free(connect_addr->u.inet.data->port); connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port); qapi_free_SocketAddress(laddr); } *src = QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_async( QIO_CHANNEL_SOCKET(*src), connect_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); g_assert(*dst); qio_channel_set_delay(*src, false); test_io_channel_set_socket_bufs(*src, *dst); object_unref(OBJECT(lioc)); g_main_loop_unref(data.loop); }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
static void test_io_channel_setup_async(SocketAddress *listen_addr, SocketAddress *connect_addr, QIOChannel **src, QIOChannel **dst) { QIOChannelSocket *lioc; struct TestIOChannelData data; data.loop = g_main_loop_new(g_main_context_default(), TRUE); lioc = qio_channel_socket_new(); qio_channel_socket_listen_async( lioc, listen_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) { SocketAddress *laddr = qio_channel_socket_get_local_address( lioc, &error_abort); g_free(connect_addr->u.inet.data->port); connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port); qapi_free_SocketAddress(laddr); } *src = QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_async( QIO_CHANNEL_SOCKET(*src), connect_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); g_assert(*dst); qio_channel_set_delay(*src, false); test_io_channel_set_socket_bufs(*src, *dst); object_unref(OBJECT(lioc)); g_main_loop_unref(data.loop); }
{ "code": [], "line_no": [] }
static void FUNC_0(SocketAddress *VAR_0, SocketAddress *VAR_1, QIOChannel **VAR_2, QIOChannel **VAR_3) { QIOChannelSocket *lioc; struct TestIOChannelData VAR_4; VAR_4.loop = g_main_loop_new(g_main_context_default(), TRUE); lioc = qio_channel_socket_new(); qio_channel_socket_listen_async( lioc, VAR_0, test_io_channel_complete, &VAR_4, NULL); g_main_loop_run(VAR_4.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!VAR_4.err); if (VAR_0->type == SOCKET_ADDRESS_KIND_INET) { SocketAddress *laddr = qio_channel_socket_get_local_address( lioc, &error_abort); g_free(VAR_1->u.inet.VAR_4->port); VAR_1->u.inet.VAR_4->port = g_strdup(laddr->u.inet.VAR_4->port); qapi_free_SocketAddress(laddr); } *VAR_2 = QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_async( QIO_CHANNEL_SOCKET(*VAR_2), VAR_1, test_io_channel_complete, &VAR_4, NULL); g_main_loop_run(VAR_4.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!VAR_4.err); qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); *VAR_3 = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); g_assert(*VAR_3); qio_channel_set_delay(*VAR_2, false); test_io_channel_set_socket_bufs(*VAR_2, *VAR_3); object_unref(OBJECT(lioc)); g_main_loop_unref(VAR_4.loop); }
[ "static void FUNC_0(SocketAddress *VAR_0,\nSocketAddress *VAR_1,\nQIOChannel **VAR_2,\nQIOChannel **VAR_3)\n{", "QIOChannelSocket *lioc;", "struct TestIOChannelData VAR_4;", "VAR_4.loop = g_main_loop_new(g_main_context_default(),\nTRUE);", "lioc = qio_channel_socket_new();", "qio_channel_socket_listen_async(\nlioc, VAR_0,\ntest_io_channel_complete, &VAR_4, NULL);", "g_main_loop_run(VAR_4.loop);", "g_main_context_iteration(g_main_context_default(), FALSE);", "g_assert(!VAR_4.err);", "if (VAR_0->type == SOCKET_ADDRESS_KIND_INET) {", "SocketAddress *laddr = qio_channel_socket_get_local_address(\nlioc, &error_abort);", "g_free(VAR_1->u.inet.VAR_4->port);", "VAR_1->u.inet.VAR_4->port = g_strdup(laddr->u.inet.VAR_4->port);", "qapi_free_SocketAddress(laddr);", "}", "*VAR_2 = QIO_CHANNEL(qio_channel_socket_new());", "qio_channel_socket_connect_async(\nQIO_CHANNEL_SOCKET(*VAR_2), VAR_1,\ntest_io_channel_complete, &VAR_4, NULL);", "g_main_loop_run(VAR_4.loop);", "g_main_context_iteration(g_main_context_default(), FALSE);", "g_assert(!VAR_4.err);", "qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);", "*VAR_3 = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));", "g_assert(*VAR_3);", "qio_channel_set_delay(*VAR_2, false);", "test_io_channel_set_socket_bufs(*VAR_2, *VAR_3);", "object_unref(OBJECT(lioc));", "g_main_loop_unref(VAR_4.loop);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25, 27, 29 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 67, 69, 71 ], [ 75 ], [ 77 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ] ]
11,625
iscsi_process_read(void *arg) { IscsiLun *iscsilun = arg; struct iscsi_context *iscsi = iscsilun->iscsi; aio_context_acquire(iscsilun->aio_context); iscsi_service(iscsi, POLLIN); iscsi_set_events(iscsilun); aio_context_release(iscsilun->aio_context); }
false
qemu
d045c466d9e62b4321fadf586d024d54ddfd8bd4
iscsi_process_read(void *arg) { IscsiLun *iscsilun = arg; struct iscsi_context *iscsi = iscsilun->iscsi; aio_context_acquire(iscsilun->aio_context); iscsi_service(iscsi, POLLIN); iscsi_set_events(iscsilun); aio_context_release(iscsilun->aio_context); }
{ "code": [], "line_no": [] }
FUNC_0(void *VAR_0) { IscsiLun *iscsilun = VAR_0; struct iscsi_context *VAR_1 = iscsilun->VAR_1; aio_context_acquire(iscsilun->aio_context); iscsi_service(VAR_1, POLLIN); iscsi_set_events(iscsilun); aio_context_release(iscsilun->aio_context); }
[ "FUNC_0(void *VAR_0)\n{", "IscsiLun *iscsilun = VAR_0;", "struct iscsi_context *VAR_1 = iscsilun->VAR_1;", "aio_context_acquire(iscsilun->aio_context);", "iscsi_service(VAR_1, POLLIN);", "iscsi_set_events(iscsilun);", "aio_context_release(iscsilun->aio_context);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
11,626
static int local_open2(FsContext *ctx, const char *path, int flags, mode_t mode) { return open(rpath(ctx, path), flags, mode); }
false
qemu
4750a96f6baf8949cc04a0c5b7167606544a4401
static int local_open2(FsContext *ctx, const char *path, int flags, mode_t mode) { return open(rpath(ctx, path), flags, mode); }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, const char *VAR_1, int VAR_2, mode_t VAR_3) { return open(rpath(VAR_0, VAR_1), VAR_2, VAR_3); }
[ "static int FUNC_0(FsContext *VAR_0, const char *VAR_1, int VAR_2, mode_t VAR_3)\n{", "return open(rpath(VAR_0, VAR_1), VAR_2, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,627
static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) { CPUState *env = opaque; if (version_id != CPU_COMMON_SAVE_VERSION) return -EINVAL; qemu_get_be32s(f, &env->halted); qemu_get_be32s(f, &env->interrupt_request); env->interrupt_request &= ~CPU_INTERRUPT_EXIT; tlb_flush(env, 1); return 0; }
false
qemu
3098dba01c7daab60762b6f6624ea88c0d6cb65a
static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) { CPUState *env = opaque; if (version_id != CPU_COMMON_SAVE_VERSION) return -EINVAL; qemu_get_be32s(f, &env->halted); qemu_get_be32s(f, &env->interrupt_request); env->interrupt_request &= ~CPU_INTERRUPT_EXIT; tlb_flush(env, 1); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2) { CPUState *env = VAR_1; if (VAR_2 != CPU_COMMON_SAVE_VERSION) return -EINVAL; qemu_get_be32s(VAR_0, &env->halted); qemu_get_be32s(VAR_0, &env->interrupt_request); env->interrupt_request &= ~CPU_INTERRUPT_EXIT; tlb_flush(env, 1); return 0; }
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)\n{", "CPUState *env = VAR_1;", "if (VAR_2 != CPU_COMMON_SAVE_VERSION)\nreturn -EINVAL;", "qemu_get_be32s(VAR_0, &env->halted);", "qemu_get_be32s(VAR_0, &env->interrupt_request);", "env->interrupt_request &= ~CPU_INTERRUPT_EXIT;", "tlb_flush(env, 1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ] ]
11,629
static void xhci_port_reset(XHCIPort *port) { trace_usb_xhci_port_reset(port->portnr); if (!xhci_port_have_device(port)) { return; } usb_device_reset(port->uport->dev); switch (port->uport->dev->speed) { case USB_SPEED_LOW: case USB_SPEED_FULL: case USB_SPEED_HIGH: set_field(&port->portsc, PLS_U0, PORTSC_PLS); trace_usb_xhci_port_link(port->portnr, PLS_U0); port->portsc |= PORTSC_PED; break; } port->portsc &= ~PORTSC_PR; xhci_port_notify(port, PORTSC_PRC); }
false
qemu
dad5b9ea0895c227bc9d48b7f0a6fa51eaaa8661
static void xhci_port_reset(XHCIPort *port) { trace_usb_xhci_port_reset(port->portnr); if (!xhci_port_have_device(port)) { return; } usb_device_reset(port->uport->dev); switch (port->uport->dev->speed) { case USB_SPEED_LOW: case USB_SPEED_FULL: case USB_SPEED_HIGH: set_field(&port->portsc, PLS_U0, PORTSC_PLS); trace_usb_xhci_port_link(port->portnr, PLS_U0); port->portsc |= PORTSC_PED; break; } port->portsc &= ~PORTSC_PR; xhci_port_notify(port, PORTSC_PRC); }
{ "code": [], "line_no": [] }
static void FUNC_0(XHCIPort *VAR_0) { trace_usb_xhci_port_reset(VAR_0->portnr); if (!xhci_port_have_device(VAR_0)) { return; } usb_device_reset(VAR_0->uport->dev); switch (VAR_0->uport->dev->speed) { case USB_SPEED_LOW: case USB_SPEED_FULL: case USB_SPEED_HIGH: set_field(&VAR_0->portsc, PLS_U0, PORTSC_PLS); trace_usb_xhci_port_link(VAR_0->portnr, PLS_U0); VAR_0->portsc |= PORTSC_PED; break; } VAR_0->portsc &= ~PORTSC_PR; xhci_port_notify(VAR_0, PORTSC_PRC); }
[ "static void FUNC_0(XHCIPort *VAR_0)\n{", "trace_usb_xhci_port_reset(VAR_0->portnr);", "if (!xhci_port_have_device(VAR_0)) {", "return;", "}", "usb_device_reset(VAR_0->uport->dev);", "switch (VAR_0->uport->dev->speed) {", "case USB_SPEED_LOW:\ncase USB_SPEED_FULL:\ncase USB_SPEED_HIGH:\nset_field(&VAR_0->portsc, PLS_U0, PORTSC_PLS);", "trace_usb_xhci_port_link(VAR_0->portnr, PLS_U0);", "VAR_0->portsc |= PORTSC_PED;", "break;", "}", "VAR_0->portsc &= ~PORTSC_PR;", "xhci_port_notify(VAR_0, PORTSC_PRC);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23, 25, 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ] ]
11,630
static int block_crypto_create_generic(QCryptoBlockFormat format, const char *filename, QemuOpts *opts, Error **errp) { int ret = -EINVAL; QCryptoBlockCreateOptions *create_opts = NULL; QCryptoBlock *crypto = NULL; struct BlockCryptoCreateData data = { .size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE), .opts = opts, .filename = filename, }; create_opts = block_crypto_create_opts_init(format, opts, errp); if (!create_opts) { return -1; } crypto = qcrypto_block_create(create_opts, block_crypto_init_func, block_crypto_write_func, &data, errp); if (!crypto) { ret = -EIO; goto cleanup; } ret = 0; cleanup: qcrypto_block_free(crypto); blk_unref(data.blk); qapi_free_QCryptoBlockCreateOptions(create_opts); return ret; }
false
qemu
306a06e5f766acaf26b71397a5692c65b65a61c7
static int block_crypto_create_generic(QCryptoBlockFormat format, const char *filename, QemuOpts *opts, Error **errp) { int ret = -EINVAL; QCryptoBlockCreateOptions *create_opts = NULL; QCryptoBlock *crypto = NULL; struct BlockCryptoCreateData data = { .size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE), .opts = opts, .filename = filename, }; create_opts = block_crypto_create_opts_init(format, opts, errp); if (!create_opts) { return -1; } crypto = qcrypto_block_create(create_opts, block_crypto_init_func, block_crypto_write_func, &data, errp); if (!crypto) { ret = -EIO; goto cleanup; } ret = 0; cleanup: qcrypto_block_free(crypto); blk_unref(data.blk); qapi_free_QCryptoBlockCreateOptions(create_opts); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(QCryptoBlockFormat VAR_0, const char *VAR_1, QemuOpts *VAR_2, Error **VAR_3) { int VAR_4 = -EINVAL; QCryptoBlockCreateOptions *create_opts = NULL; QCryptoBlock *crypto = NULL; struct BlockCryptoCreateData VAR_5 = { .size = ROUND_UP(qemu_opt_get_size_del(VAR_2, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE), .VAR_2 = VAR_2, .VAR_1 = VAR_1, }; create_opts = block_crypto_create_opts_init(VAR_0, VAR_2, VAR_3); if (!create_opts) { return -1; } crypto = qcrypto_block_create(create_opts, block_crypto_init_func, block_crypto_write_func, &VAR_5, VAR_3); if (!crypto) { VAR_4 = -EIO; goto cleanup; } VAR_4 = 0; cleanup: qcrypto_block_free(crypto); blk_unref(VAR_5.blk); qapi_free_QCryptoBlockCreateOptions(create_opts); return VAR_4; }
[ "static int FUNC_0(QCryptoBlockFormat VAR_0,\nconst char *VAR_1,\nQemuOpts *VAR_2,\nError **VAR_3)\n{", "int VAR_4 = -EINVAL;", "QCryptoBlockCreateOptions *create_opts = NULL;", "QCryptoBlock *crypto = NULL;", "struct BlockCryptoCreateData VAR_5 = {", ".size = ROUND_UP(qemu_opt_get_size_del(VAR_2, BLOCK_OPT_SIZE, 0),\nBDRV_SECTOR_SIZE),\n.VAR_2 = VAR_2,\n.VAR_1 = VAR_1,\n};", "create_opts = block_crypto_create_opts_init(VAR_0, VAR_2, VAR_3);", "if (!create_opts) {", "return -1;", "}", "crypto = qcrypto_block_create(create_opts,\nblock_crypto_init_func,\nblock_crypto_write_func,\n&VAR_5,\nVAR_3);", "if (!crypto) {", "VAR_4 = -EIO;", "goto cleanup;", "}", "VAR_4 = 0;", "cleanup:\nqcrypto_block_free(crypto);", "blk_unref(VAR_5.blk);", "qapi_free_QCryptoBlockCreateOptions(create_opts);", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21, 23, 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43, 45, 47, 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ] ]
11,632
static void vertical_filter(unsigned char *first_pixel, int stride, int *bounding_values) { int i; int filter_value; for (i = 0; i < 8; i++, first_pixel++) { filter_value = (first_pixel[-(2 * stride)] * 1) - (first_pixel[-(1 * stride)] * 3) + (first_pixel[ (0 )] * 3) - (first_pixel[ (1 * stride)] * 1); filter_value = bounding_values[(filter_value + 4) >> 3]; first_pixel[-(1 * stride)] = SATURATE_U8(first_pixel[-(1 * stride)] + filter_value); first_pixel[0] = SATURATE_U8(first_pixel[0] - filter_value); } }
false
FFmpeg
ee408eadbadbc629c9ef06f62ddf63643defe541
static void vertical_filter(unsigned char *first_pixel, int stride, int *bounding_values) { int i; int filter_value; for (i = 0; i < 8; i++, first_pixel++) { filter_value = (first_pixel[-(2 * stride)] * 1) - (first_pixel[-(1 * stride)] * 3) + (first_pixel[ (0 )] * 3) - (first_pixel[ (1 * stride)] * 1); filter_value = bounding_values[(filter_value + 4) >> 3]; first_pixel[-(1 * stride)] = SATURATE_U8(first_pixel[-(1 * stride)] + filter_value); first_pixel[0] = SATURATE_U8(first_pixel[0] - filter_value); } }
{ "code": [], "line_no": [] }
static void FUNC_0(unsigned char *VAR_0, int VAR_1, int *VAR_2) { int VAR_3; int VAR_4; for (VAR_3 = 0; VAR_3 < 8; VAR_3++, VAR_0++) { VAR_4 = (VAR_0[-(2 * VAR_1)] * 1) - (VAR_0[-(1 * VAR_1)] * 3) + (VAR_0[ (0 )] * 3) - (VAR_0[ (1 * VAR_1)] * 1); VAR_4 = VAR_2[(VAR_4 + 4) >> 3]; VAR_0[-(1 * VAR_1)] = SATURATE_U8(VAR_0[-(1 * VAR_1)] + VAR_4); VAR_0[0] = SATURATE_U8(VAR_0[0] - VAR_4); } }
[ "static void FUNC_0(unsigned char *VAR_0, int VAR_1,\nint *VAR_2)\n{", "int VAR_3;", "int VAR_4;", "for (VAR_3 = 0; VAR_3 < 8; VAR_3++, VAR_0++) {", "VAR_4 =\n(VAR_0[-(2 * VAR_1)] * 1) -\n(VAR_0[-(1 * VAR_1)] * 3) +\n(VAR_0[ (0 )] * 3) -\n(VAR_0[ (1 * VAR_1)] * 1);", "VAR_4 = VAR_2[(VAR_4 + 4) >> 3];", "VAR_0[-(1 * VAR_1)] = SATURATE_U8(VAR_0[-(1 * VAR_1)] + VAR_4);", "VAR_0[0] = SATURATE_U8(VAR_0[0] - VAR_4);", "}", "}" ]
[ 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 ] ]
11,633
POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER8"; dc->desc = "POWER8"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power8; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_TM; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_SHV) | (1ull << MSR_TM) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_07; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; pcc->sps = &POWER7_POWER8_sps; #endif pcc->excp_model = POWERPC_EXCP_POWER8; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX | POWERPC_FLAG_TM; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
false
qemu
8cd2ce7aaa3c3fadc561f40045d4d53ff72e94ef
POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER8"; dc->desc = "POWER8"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power8; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_TM; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_SHV) | (1ull << MSR_TM) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_07; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; pcc->sps = &POWER7_POWER8_sps; #endif pcc->excp_model = POWERPC_EXCP_POWER8; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX | POWERPC_FLAG_TM; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
{ "code": [], "line_no": [] }
FUNC_0(POWER8)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER8"; dc->desc = "POWER8"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power8; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_TM; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_SHV) | (1ull << MSR_TM) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_07; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; pcc->sps = &POWER7_POWER8_sps; #endif pcc->excp_model = POWERPC_EXCP_POWER8; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX | POWERPC_FLAG_TM; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
[ "FUNC_0(POWER8)(ObjectClass *oc, void *data)\n{", "DeviceClass *dc = DEVICE_CLASS(oc);", "PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);", "dc->fw_name = \"PowerPC,POWER8\";", "dc->desc = \"POWER8\";", "dc->props = powerpc_servercpu_properties;", "pcc->pvr_match = ppc_pvr_match_power8;", "pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;", "pcc->init_proc = init_proc_POWER8;", "pcc->check_pow = check_pow_nocheck;", "pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |\nPPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |\nPPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |\nPPC_FLOAT_FRSQRTES |\nPPC_FLOAT_STFIWX |\nPPC_FLOAT_EXT |\nPPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |\nPPC_MEM_SYNC | PPC_MEM_EIEIO |\nPPC_MEM_TLBIE | PPC_MEM_TLBSYNC |\nPPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |\nPPC_SEGMENT_64B | PPC_SLBI |\nPPC_POPCNTB | PPC_POPCNTWD;", "pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |\nPPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |\nPPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |\nPPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |\nPPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |\nPPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |\nPPC2_TM;", "pcc->msr_mask = (1ull << MSR_SF) |\n(1ull << MSR_SHV) |\n(1ull << MSR_TM) |\n(1ull << MSR_VR) |\n(1ull << MSR_VSX) |\n(1ull << MSR_EE) |\n(1ull << MSR_PR) |\n(1ull << MSR_FP) |\n(1ull << MSR_ME) |\n(1ull << MSR_FE0) |\n(1ull << MSR_SE) |\n(1ull << MSR_DE) |\n(1ull << MSR_FE1) |\n(1ull << MSR_IR) |\n(1ull << MSR_DR) |\n(1ull << MSR_PMM) |\n(1ull << MSR_RI) |\n(1ull << MSR_LE);", "pcc->mmu_model = POWERPC_MMU_2_07;", "#if defined(CONFIG_SOFTMMU)\npcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;", "pcc->sps = &POWER7_POWER8_sps;", "#endif\npcc->excp_model = POWERPC_EXCP_POWER8;", "pcc->bus_model = PPC_FLAGS_INPUT_POWER7;", "pcc->bfd_mach = bfd_mach_ppc64;", "pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |\nPOWERPC_FLAG_BE | POWERPC_FLAG_PMM |\nPOWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |\nPOWERPC_FLAG_VSX | POWERPC_FLAG_TM;", "pcc->l1_dcache_size = 0x8000;", "pcc->l1_icache_size = 0x8000;", "pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47 ], [ 49, 51, 53, 55, 57, 59, 61 ], [ 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115, 117, 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ] ]
11,634
void qemu_aio_set_fd_handler(int fd, IOHandler *io_read, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque) { aio_set_fd_handler(qemu_aio_context, fd, io_read, io_write, io_flush, opaque); qemu_set_fd_handler2(fd, NULL, io_read, io_write, opaque); }
false
qemu
82cbbdc6a0958b49c77639a60906e30d02e6bb7b
void qemu_aio_set_fd_handler(int fd, IOHandler *io_read, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque) { aio_set_fd_handler(qemu_aio_context, fd, io_read, io_write, io_flush, opaque); qemu_set_fd_handler2(fd, NULL, io_read, io_write, opaque); }
{ "code": [], "line_no": [] }
void FUNC_0(int VAR_0, IOHandler *VAR_1, IOHandler *VAR_2, AioFlushHandler *VAR_3, void *VAR_4) { aio_set_fd_handler(qemu_aio_context, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); qemu_set_fd_handler2(VAR_0, NULL, VAR_1, VAR_2, VAR_4); }
[ "void FUNC_0(int VAR_0,\nIOHandler *VAR_1,\nIOHandler *VAR_2,\nAioFlushHandler *VAR_3,\nvoid *VAR_4)\n{", "aio_set_fd_handler(qemu_aio_context, VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4);", "qemu_set_fd_handler2(VAR_0, NULL, VAR_1, VAR_2, VAR_4);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13, 15 ], [ 19 ], [ 21 ] ]
11,636
static void apb_pci_config_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { APBState *s = opaque; val = qemu_bswap_len(val, size); APB_DPRINTF("%s: addr " TARGET_FMT_lx " val %" PRIx64 "\n", __func__, addr, val); pci_data_write(s->bus, addr, val, size); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void apb_pci_config_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { APBState *s = opaque; val = qemu_bswap_len(val, size); APB_DPRINTF("%s: addr " TARGET_FMT_lx " val %" PRIx64 "\n", __func__, addr, val); pci_data_write(s->bus, addr, val, size); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { APBState *s = VAR_0; VAR_2 = qemu_bswap_len(VAR_2, VAR_3); APB_DPRINTF("%s: VAR_1 " TARGET_FMT_lx " VAR_2 %" PRIx64 "\n", __func__, VAR_1, VAR_2); pci_data_write(s->bus, VAR_1, VAR_2, VAR_3); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "APBState *s = VAR_0;", "VAR_2 = qemu_bswap_len(VAR_2, VAR_3);", "APB_DPRINTF(\"%s: VAR_1 \" TARGET_FMT_lx \" VAR_2 %\" PRIx64 \"\\n\", __func__, VAR_1, VAR_2);", "pci_data_write(s->bus, VAR_1, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
11,637
static inline bool extended_addresses_enabled(CPUARMState *env) { return arm_el_is_aa64(env, 1) || ((arm_feature(env, ARM_FEATURE_LPAE) && (env->cp15.c2_control & (1U << 31)))); }
false
qemu
e389be1673052b538534643165111725a79e5afd
static inline bool extended_addresses_enabled(CPUARMState *env) { return arm_el_is_aa64(env, 1) || ((arm_feature(env, ARM_FEATURE_LPAE) && (env->cp15.c2_control & (1U << 31)))); }
{ "code": [], "line_no": [] }
static inline bool FUNC_0(CPUARMState *env) { return arm_el_is_aa64(env, 1) || ((arm_feature(env, ARM_FEATURE_LPAE) && (env->cp15.c2_control & (1U << 31)))); }
[ "static inline bool FUNC_0(CPUARMState *env)\n{", "return arm_el_is_aa64(env, 1)\n|| ((arm_feature(env, ARM_FEATURE_LPAE)\n&& (env->cp15.c2_control & (1U << 31))));", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7, 9 ], [ 11 ] ]
11,638
void qmp_block_job_pause(const char *device, Error **errp) { BlockJob *job = find_block_job(device); if (!job) { error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device); return; } trace_qmp_block_job_pause(job); block_job_pause(job); }
false
qemu
3d948cdf3760b52238038626a7ffa7d30913060b
void qmp_block_job_pause(const char *device, Error **errp) { BlockJob *job = find_block_job(device); if (!job) { error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device); return; } trace_qmp_block_job_pause(job); block_job_pause(job); }
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0, Error **VAR_1) { BlockJob *job = find_block_job(VAR_0); if (!job) { error_set(VAR_1, QERR_BLOCK_JOB_NOT_ACTIVE, VAR_0); return; } trace_qmp_block_job_pause(job); block_job_pause(job); }
[ "void FUNC_0(const char *VAR_0, Error **VAR_1)\n{", "BlockJob *job = find_block_job(VAR_0);", "if (!job) {", "error_set(VAR_1, QERR_BLOCK_JOB_NOT_ACTIVE, VAR_0);", "return;", "}", "trace_qmp_block_job_pause(job);", "block_job_pause(job);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ] ]
11,639
void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { struct socket *so, *so_next; int ret; global_readfds = readfds; global_writefds = writefds; global_xfds = xfds; /* Update time */ updtime(); /* * See if anything has timed out */ if (link_up) { if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { tcp_fasttimo(); time_fasttimo = 0; } if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) { ip_slowtimo(); tcp_slowtimo(); last_slowtimo = curtime; } } /* * Check sockets */ if (link_up) { /* * Check TCP sockets */ for (so = tcb.so_next; so != &tcb; so = so_next) { so_next = so->so_next; /* * FD_ISSET is meaningless on these sockets * (and they can crash the program) */ if (so->so_state & SS_NOFDREF || so->s == -1) continue; /* * Check for URG data * This will soread as well, so no need to * test for readfds below if this succeeds */ if (FD_ISSET(so->s, xfds)) sorecvoob(so); /* * Check sockets for reading */ else if (FD_ISSET(so->s, readfds)) { /* * Check for incoming connections */ if (so->so_state & SS_FACCEPTCONN) { tcp_connect(so); continue; } /* else */ ret = soread(so); /* Output it if we read something */ if (ret > 0) tcp_output(sototcpcb(so)); } /* * Check sockets for writing */ if (FD_ISSET(so->s, writefds)) { /* * Check for non-blocking, still-connecting sockets */ if (so->so_state & SS_ISFCONNECTING) { /* Connected */ so->so_state &= ~SS_ISFCONNECTING; ret = send(so->s, (const void *) &ret, 0, 0); if (ret < 0) { /* XXXXX Must fix, zero bytes is a NOP */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; /* else failed */ so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } /* else so->so_state &= ~SS_ISFCONNECTING; */ /* * Continue tcp_input */ tcp_input((struct mbuf *)NULL, sizeof(struct ip), so); /* continue; */ } else ret = sowrite(so); /* * XXXXX If we wrote something (a lot), there * could be a need for a window update. * In the worst case, the remote will send * a window probe to get things going again */ } /* * Probe a still-connecting, non-blocking socket * to check if it's still alive */ #ifdef PROBE_CONN if (so->so_state & SS_ISFCONNECTING) { ret = recv(so->s, (char *)&ret, 0,0); if (ret < 0) { /* XXX */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; /* Still connecting, continue */ /* else failed */ so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; /* tcp_input will take care of it */ } else { ret = send(so->s, &ret, 0,0); if (ret < 0) { /* XXX */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; /* else failed */ so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } else so->so_state &= ~SS_ISFCONNECTING; } tcp_input((struct mbuf *)NULL, sizeof(struct ip),so); } /* SS_ISFCONNECTING */ #endif } /* * Now UDP sockets. * Incoming packets are sent straight away, they're not buffered. * Incoming UDP data isn't buffered either. */ for (so = udb.so_next; so != &udb; so = so_next) { so_next = so->so_next; if (so->s != -1 && FD_ISSET(so->s, readfds)) { sorecvfrom(so); } } } /* * See if we can start outputting */ if (if_queued && link_up) if_start(); /* clear global file descriptor sets. * these reside on the stack in vl.c * so they're unusable if we're not in * slirp_select_fill or slirp_select_poll. */ global_readfds = NULL; global_writefds = NULL; global_xfds = NULL; }
false
qemu
d918f23efaf486293b96418fe5deaff8a5583304
void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { struct socket *so, *so_next; int ret; global_readfds = readfds; global_writefds = writefds; global_xfds = xfds; updtime(); if (link_up) { if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { tcp_fasttimo(); time_fasttimo = 0; } if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) { ip_slowtimo(); tcp_slowtimo(); last_slowtimo = curtime; } } if (link_up) { for (so = tcb.so_next; so != &tcb; so = so_next) { so_next = so->so_next; if (so->so_state & SS_NOFDREF || so->s == -1) continue; if (FD_ISSET(so->s, xfds)) sorecvoob(so); else if (FD_ISSET(so->s, readfds)) { if (so->so_state & SS_FACCEPTCONN) { tcp_connect(so); continue; } ret = soread(so); if (ret > 0) tcp_output(sototcpcb(so)); } if (FD_ISSET(so->s, writefds)) { if (so->so_state & SS_ISFCONNECTING) { so->so_state &= ~SS_ISFCONNECTING; ret = send(so->s, (const void *) &ret, 0, 0); if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } tcp_input((struct mbuf *)NULL, sizeof(struct ip), so); } else ret = sowrite(so); } #ifdef PROBE_CONN if (so->so_state & SS_ISFCONNECTING) { ret = recv(so->s, (char *)&ret, 0,0); if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } else { ret = send(so->s, &ret, 0,0); if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } else so->so_state &= ~SS_ISFCONNECTING; } tcp_input((struct mbuf *)NULL, sizeof(struct ip),so); } #endif } for (so = udb.so_next; so != &udb; so = so_next) { so_next = so->so_next; if (so->s != -1 && FD_ISSET(so->s, readfds)) { sorecvfrom(so); } } } if (if_queued && link_up) if_start(); global_readfds = NULL; global_writefds = NULL; global_xfds = NULL; }
{ "code": [], "line_no": [] }
void FUNC_0(fd_set *VAR_0, fd_set *VAR_1, fd_set *VAR_2) { struct socket *VAR_3, *VAR_4; int VAR_5; global_readfds = VAR_0; global_writefds = VAR_1; global_xfds = VAR_2; updtime(); if (link_up) { if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { tcp_fasttimo(); time_fasttimo = 0; } if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) { ip_slowtimo(); tcp_slowtimo(); last_slowtimo = curtime; } } if (link_up) { for (VAR_3 = tcb.VAR_4; VAR_3 != &tcb; VAR_3 = VAR_4) { VAR_4 = VAR_3->VAR_4; if (VAR_3->so_state & SS_NOFDREF || VAR_3->s == -1) continue; if (FD_ISSET(VAR_3->s, VAR_2)) sorecvoob(VAR_3); else if (FD_ISSET(VAR_3->s, VAR_0)) { if (VAR_3->so_state & SS_FACCEPTCONN) { tcp_connect(VAR_3); continue; } VAR_5 = soread(VAR_3); if (VAR_5 > 0) tcp_output(sototcpcb(VAR_3)); } if (FD_ISSET(VAR_3->s, VAR_1)) { if (VAR_3->so_state & SS_ISFCONNECTING) { VAR_3->so_state &= ~SS_ISFCONNECTING; VAR_5 = send(VAR_3->s, (const void *) &VAR_5, 0, 0); if (VAR_5 < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; VAR_3->so_state &= SS_PERSISTENT_MASK; VAR_3->so_state |= SS_NOFDREF; } tcp_input((struct mbuf *)NULL, sizeof(struct ip), VAR_3); } else VAR_5 = sowrite(VAR_3); } #ifdef PROBE_CONN if (VAR_3->so_state & SS_ISFCONNECTING) { VAR_5 = recv(VAR_3->s, (char *)&VAR_5, 0,0); if (VAR_5 < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; VAR_3->so_state &= SS_PERSISTENT_MASK; VAR_3->so_state |= SS_NOFDREF; } else { VAR_5 = send(VAR_3->s, &VAR_5, 0,0); if (VAR_5 < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) continue; VAR_3->so_state &= SS_PERSISTENT_MASK; VAR_3->so_state |= SS_NOFDREF; } else VAR_3->so_state &= ~SS_ISFCONNECTING; } tcp_input((struct mbuf *)NULL, sizeof(struct ip),VAR_3); } #endif } for (VAR_3 = udb.VAR_4; VAR_3 != &udb; VAR_3 = VAR_4) { VAR_4 = VAR_3->VAR_4; if (VAR_3->s != -1 && FD_ISSET(VAR_3->s, VAR_0)) { sorecvfrom(VAR_3); } } } if (if_queued && link_up) if_start(); global_readfds = NULL; global_writefds = NULL; global_xfds = NULL; }
[ "void FUNC_0(fd_set *VAR_0, fd_set *VAR_1, fd_set *VAR_2)\n{", "struct socket *VAR_3, *VAR_4;", "int VAR_5;", "global_readfds = VAR_0;", "global_writefds = VAR_1;", "global_xfds = VAR_2;", "updtime();", "if (link_up) {", "if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {", "tcp_fasttimo();", "time_fasttimo = 0;", "}", "if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {", "ip_slowtimo();", "tcp_slowtimo();", "last_slowtimo = curtime;", "}", "}", "if (link_up) {", "for (VAR_3 = tcb.VAR_4; VAR_3 != &tcb; VAR_3 = VAR_4) {", "VAR_4 = VAR_3->VAR_4;", "if (VAR_3->so_state & SS_NOFDREF || VAR_3->s == -1)\ncontinue;", "if (FD_ISSET(VAR_3->s, VAR_2))\nsorecvoob(VAR_3);", "else if (FD_ISSET(VAR_3->s, VAR_0)) {", "if (VAR_3->so_state & SS_FACCEPTCONN) {", "tcp_connect(VAR_3);", "continue;", "}", "VAR_5 = soread(VAR_3);", "if (VAR_5 > 0)\ntcp_output(sototcpcb(VAR_3));", "}", "if (FD_ISSET(VAR_3->s, VAR_1)) {", "if (VAR_3->so_state & SS_ISFCONNECTING) {", "VAR_3->so_state &= ~SS_ISFCONNECTING;", "VAR_5 = send(VAR_3->s, (const void *) &VAR_5, 0, 0);", "if (VAR_5 < 0) {", "if (errno == EAGAIN || errno == EWOULDBLOCK ||\nerrno == EINPROGRESS || errno == ENOTCONN)\ncontinue;", "VAR_3->so_state &= SS_PERSISTENT_MASK;", "VAR_3->so_state |= SS_NOFDREF;", "}", "tcp_input((struct mbuf *)NULL, sizeof(struct ip), VAR_3);", "} else", "VAR_5 = sowrite(VAR_3);", "}", "#ifdef PROBE_CONN\nif (VAR_3->so_state & SS_ISFCONNECTING) {", "VAR_5 = recv(VAR_3->s, (char *)&VAR_5, 0,0);", "if (VAR_5 < 0) {", "if (errno == EAGAIN || errno == EWOULDBLOCK ||\nerrno == EINPROGRESS || errno == ENOTCONN)\ncontinue;", "VAR_3->so_state &= SS_PERSISTENT_MASK;", "VAR_3->so_state |= SS_NOFDREF;", "} else {", "VAR_5 = send(VAR_3->s, &VAR_5, 0,0);", "if (VAR_5 < 0) {", "if (errno == EAGAIN || errno == EWOULDBLOCK ||\nerrno == EINPROGRESS || errno == ENOTCONN)\ncontinue;", "VAR_3->so_state &= SS_PERSISTENT_MASK;", "VAR_3->so_state |= SS_NOFDREF;", "} else", "VAR_3->so_state &= ~SS_ISFCONNECTING;", "}", "tcp_input((struct mbuf *)NULL, sizeof(struct ip),VAR_3);", "}", "#endif\n}", "for (VAR_3 = udb.VAR_4; VAR_3 != &udb; VAR_3 = VAR_4) {", "VAR_4 = VAR_3->VAR_4;", "if (VAR_3->s != -1 && FD_ISSET(VAR_3->s, VAR_0)) {", "sorecvfrom(VAR_3);", "}", "}", "}", "if (if_queued && link_up)\nif_start();", "global_readfds = NULL;", "global_writefds = NULL;", "global_xfds = NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 61 ], [ 69 ], [ 71 ], [ 83, 85 ], [ 99, 101 ], [ 109 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 131, 133 ], [ 135 ], [ 145 ], [ 153 ], [ 157 ], [ 161 ], [ 163 ], [ 167, 169, 171 ], [ 177 ], [ 179 ], [ 181 ], [ 193 ], [ 197 ], [ 199 ], [ 213 ], [ 225, 227 ], [ 229 ], [ 233 ], [ 237, 239, 241 ], [ 247 ], [ 249 ], [ 255 ], [ 257 ], [ 259 ], [ 263, 265, 267 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 303 ], [ 305 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 327, 329 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ] ]
11,640
static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, int rw, int tlb_error) { CPUState *cs = CPU(mips_env_get_cpu(env)); int exception = 0, error_code = 0; switch (tlb_error) { default: case TLBRET_BADADDR: /* Reference to kernel address from user mode or supervisor mode */ /* Reference to supervisor address from user mode */ if (rw == MMU_DATA_STORE) { exception = EXCP_AdES; } else { exception = EXCP_AdEL; } break; case TLBRET_NOMATCH: /* No TLB match for a mapped address */ if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } error_code = 1; break; case TLBRET_INVALID: /* TLB match with no valid bit */ if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } break; case TLBRET_DIRTY: /* TLB match but 'D' bit is cleared */ exception = EXCP_LTLBL; break; case TLBRET_XI: /* Execute-Inhibit Exception */ if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBXI; } else { exception = EXCP_TLBL; } break; case TLBRET_RI: /* Read-Inhibit Exception */ if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBRI; } else { exception = EXCP_TLBL; } break; } /* Raise exception */ env->CP0_BadVAddr = address; env->CP0_Context = (env->CP0_Context & ~0x007fffff) | ((address >> 9) & 0x007ffff0); env->CP0_EntryHi = (env->CP0_EntryHi & 0xFF) | (address & (TARGET_PAGE_MASK << 1)); #if defined(TARGET_MIPS64) env->CP0_EntryHi &= env->SEGMask; env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) | ((address & 0xC00000000000ULL) >> (55 - env->SEGBITS)) | ((address & ((1ULL << env->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9); #endif cs->exception_index = exception; env->error_code = error_code; }
false
qemu
aea14095ea91f792ee43ee52fe6032cd8cdd7190
static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, int rw, int tlb_error) { CPUState *cs = CPU(mips_env_get_cpu(env)); int exception = 0, error_code = 0; switch (tlb_error) { default: case TLBRET_BADADDR: if (rw == MMU_DATA_STORE) { exception = EXCP_AdES; } else { exception = EXCP_AdEL; } break; case TLBRET_NOMATCH: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } error_code = 1; break; case TLBRET_INVALID: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } break; case TLBRET_DIRTY: exception = EXCP_LTLBL; break; case TLBRET_XI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBXI; } else { exception = EXCP_TLBL; } break; case TLBRET_RI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBRI; } else { exception = EXCP_TLBL; } break; } env->CP0_BadVAddr = address; env->CP0_Context = (env->CP0_Context & ~0x007fffff) | ((address >> 9) & 0x007ffff0); env->CP0_EntryHi = (env->CP0_EntryHi & 0xFF) | (address & (TARGET_PAGE_MASK << 1)); #if defined(TARGET_MIPS64) env->CP0_EntryHi &= env->SEGMask; env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) | ((address & 0xC00000000000ULL) >> (55 - env->SEGBITS)) | ((address & ((1ULL << env->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9); #endif cs->exception_index = exception; env->error_code = error_code; }
{ "code": [], "line_no": [] }
static void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3) { CPUState *cs = CPU(mips_env_get_cpu(VAR_0)); int VAR_4 = 0, VAR_5 = 0; switch (VAR_3) { default: case TLBRET_BADADDR: if (VAR_2 == MMU_DATA_STORE) { VAR_4 = EXCP_AdES; } else { VAR_4 = EXCP_AdEL; } break; case TLBRET_NOMATCH: if (VAR_2 == MMU_DATA_STORE) { VAR_4 = EXCP_TLBS; } else { VAR_4 = EXCP_TLBL; } VAR_5 = 1; break; case TLBRET_INVALID: if (VAR_2 == MMU_DATA_STORE) { VAR_4 = EXCP_TLBS; } else { VAR_4 = EXCP_TLBL; } break; case TLBRET_DIRTY: VAR_4 = EXCP_LTLBL; break; case TLBRET_XI: if (VAR_0->CP0_PageGrain & (1 << CP0PG_IEC)) { VAR_4 = EXCP_TLBXI; } else { VAR_4 = EXCP_TLBL; } break; case TLBRET_RI: if (VAR_0->CP0_PageGrain & (1 << CP0PG_IEC)) { VAR_4 = EXCP_TLBRI; } else { VAR_4 = EXCP_TLBL; } break; } VAR_0->CP0_BadVAddr = VAR_1; VAR_0->CP0_Context = (VAR_0->CP0_Context & ~0x007fffff) | ((VAR_1 >> 9) & 0x007ffff0); VAR_0->CP0_EntryHi = (VAR_0->CP0_EntryHi & 0xFF) | (VAR_1 & (TARGET_PAGE_MASK << 1)); #if defined(TARGET_MIPS64) VAR_0->CP0_EntryHi &= VAR_0->SEGMask; VAR_0->CP0_XContext = (VAR_0->CP0_XContext & ((~0ULL) << (VAR_0->SEGBITS - 7))) | ((VAR_1 & 0xC00000000000ULL) >> (55 - VAR_0->SEGBITS)) | ((VAR_1 & ((1ULL << VAR_0->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9); #endif cs->exception_index = VAR_4; VAR_0->VAR_5 = VAR_5; }
[ "static void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1,\nint VAR_2, int VAR_3)\n{", "CPUState *cs = CPU(mips_env_get_cpu(VAR_0));", "int VAR_4 = 0, VAR_5 = 0;", "switch (VAR_3) {", "default:\ncase TLBRET_BADADDR:\nif (VAR_2 == MMU_DATA_STORE) {", "VAR_4 = EXCP_AdES;", "} else {", "VAR_4 = EXCP_AdEL;", "}", "break;", "case TLBRET_NOMATCH:\nif (VAR_2 == MMU_DATA_STORE) {", "VAR_4 = EXCP_TLBS;", "} else {", "VAR_4 = EXCP_TLBL;", "}", "VAR_5 = 1;", "break;", "case TLBRET_INVALID:\nif (VAR_2 == MMU_DATA_STORE) {", "VAR_4 = EXCP_TLBS;", "} else {", "VAR_4 = EXCP_TLBL;", "}", "break;", "case TLBRET_DIRTY:\nVAR_4 = EXCP_LTLBL;", "break;", "case TLBRET_XI:\nif (VAR_0->CP0_PageGrain & (1 << CP0PG_IEC)) {", "VAR_4 = EXCP_TLBXI;", "} else {", "VAR_4 = EXCP_TLBL;", "}", "break;", "case TLBRET_RI:\nif (VAR_0->CP0_PageGrain & (1 << CP0PG_IEC)) {", "VAR_4 = EXCP_TLBRI;", "} else {", "VAR_4 = EXCP_TLBL;", "}", "break;", "}", "VAR_0->CP0_BadVAddr = VAR_1;", "VAR_0->CP0_Context = (VAR_0->CP0_Context & ~0x007fffff) |\n((VAR_1 >> 9) & 0x007ffff0);", "VAR_0->CP0_EntryHi =\n(VAR_0->CP0_EntryHi & 0xFF) | (VAR_1 & (TARGET_PAGE_MASK << 1));", "#if defined(TARGET_MIPS64)\nVAR_0->CP0_EntryHi &= VAR_0->SEGMask;", "VAR_0->CP0_XContext = (VAR_0->CP0_XContext & ((~0ULL) << (VAR_0->SEGBITS - 7))) |\n((VAR_1 & 0xC00000000000ULL) >> (55 - VAR_0->SEGBITS)) |\n((VAR_1 & ((1ULL << VAR_0->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9);", "#endif\ncs->exception_index = VAR_4;", "VAR_0->VAR_5 = 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 73 ], [ 75 ], [ 77, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115, 117 ], [ 119, 121 ], [ 123, 125 ], [ 127, 129, 131 ], [ 133, 135 ], [ 137 ], [ 139 ] ]
11,643
void ff_put_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_4w_msa(src - 2, stride, dst, stride, 4); }
false
FFmpeg
6796a1dd8c14843b77925cb83a3ef88706ae1dd0
void ff_put_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_4w_msa(src - 2, stride, dst, stride, 4); }
{ "code": [], "line_no": [] }
void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1, ptrdiff_t VAR_2) { avc_luma_hz_4w_msa(VAR_1 - 2, VAR_2, VAR_0, VAR_2, 4); }
[ "void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{", "avc_luma_hz_4w_msa(VAR_1 - 2, VAR_2, VAR_0, VAR_2, 4);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
11,644
static int roq_encode_video(RoqContext *enc) { RoqTempdata *tempData = enc->tmpData; int i, ret; memset(tempData, 0, sizeof(*tempData)); ret = create_cel_evals(enc, tempData); if (ret < 0) return ret; ret = generate_new_codebooks(enc, tempData); if (ret < 0) return ret; if (enc->framesSinceKeyframe >= 1) { motion_search(enc, 8); motion_search(enc, 4); } retry_encode: for (i=0; i<enc->width*enc->height/64; i++) gather_data_for_cel(tempData->cel_evals + i, enc, tempData); /* Quake 3 can't handle chunks bigger than 65535 bytes */ if (tempData->mainChunkSize/8 > 65535) { av_log(enc->avctx, AV_LOG_ERROR, "Warning, generated a frame too big (%d > 65535), " "try using a smaller qscale value.\n", tempData->mainChunkSize/8); enc->lambda *= 1.5; tempData->mainChunkSize = 0; memset(tempData->used_option, 0, sizeof(tempData->used_option)); memset(tempData->codebooks.usedCB4, 0, sizeof(tempData->codebooks.usedCB4)); memset(tempData->codebooks.usedCB2, 0, sizeof(tempData->codebooks.usedCB2)); goto retry_encode; } remap_codebooks(enc, tempData); write_codebooks(enc, tempData); reconstruct_and_encode_image(enc, tempData, enc->width, enc->height, enc->width*enc->height/64); enc->avctx->coded_frame = enc->current_frame; /* Rotate frame history */ FFSWAP(AVFrame *, enc->current_frame, enc->last_frame); FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4); FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8); av_free(tempData->cel_evals); av_free(tempData->closest_cb2); enc->framesSinceKeyframe++; return 0; }
false
FFmpeg
95e2317ed85502dd8d96bcd9b12084dbfb8f9e8e
static int roq_encode_video(RoqContext *enc) { RoqTempdata *tempData = enc->tmpData; int i, ret; memset(tempData, 0, sizeof(*tempData)); ret = create_cel_evals(enc, tempData); if (ret < 0) return ret; ret = generate_new_codebooks(enc, tempData); if (ret < 0) return ret; if (enc->framesSinceKeyframe >= 1) { motion_search(enc, 8); motion_search(enc, 4); } retry_encode: for (i=0; i<enc->width*enc->height/64; i++) gather_data_for_cel(tempData->cel_evals + i, enc, tempData); if (tempData->mainChunkSize/8 > 65535) { av_log(enc->avctx, AV_LOG_ERROR, "Warning, generated a frame too big (%d > 65535), " "try using a smaller qscale value.\n", tempData->mainChunkSize/8); enc->lambda *= 1.5; tempData->mainChunkSize = 0; memset(tempData->used_option, 0, sizeof(tempData->used_option)); memset(tempData->codebooks.usedCB4, 0, sizeof(tempData->codebooks.usedCB4)); memset(tempData->codebooks.usedCB2, 0, sizeof(tempData->codebooks.usedCB2)); goto retry_encode; } remap_codebooks(enc, tempData); write_codebooks(enc, tempData); reconstruct_and_encode_image(enc, tempData, enc->width, enc->height, enc->width*enc->height/64); enc->avctx->coded_frame = enc->current_frame; FFSWAP(AVFrame *, enc->current_frame, enc->last_frame); FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4); FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8); av_free(tempData->cel_evals); av_free(tempData->closest_cb2); enc->framesSinceKeyframe++; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(RoqContext *VAR_0) { RoqTempdata *tempData = VAR_0->tmpData; int VAR_1, VAR_2; memset(tempData, 0, sizeof(*tempData)); VAR_2 = create_cel_evals(VAR_0, tempData); if (VAR_2 < 0) return VAR_2; VAR_2 = generate_new_codebooks(VAR_0, tempData); if (VAR_2 < 0) return VAR_2; if (VAR_0->framesSinceKeyframe >= 1) { motion_search(VAR_0, 8); motion_search(VAR_0, 4); } retry_encode: for (VAR_1=0; VAR_1<VAR_0->width*VAR_0->height/64; VAR_1++) gather_data_for_cel(tempData->cel_evals + VAR_1, VAR_0, tempData); if (tempData->mainChunkSize/8 > 65535) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Warning, generated a frame too big (%d > 65535), " "try using a smaller qscale value.\n", tempData->mainChunkSize/8); VAR_0->lambda *= 1.5; tempData->mainChunkSize = 0; memset(tempData->used_option, 0, sizeof(tempData->used_option)); memset(tempData->codebooks.usedCB4, 0, sizeof(tempData->codebooks.usedCB4)); memset(tempData->codebooks.usedCB2, 0, sizeof(tempData->codebooks.usedCB2)); goto retry_encode; } remap_codebooks(VAR_0, tempData); write_codebooks(VAR_0, tempData); reconstruct_and_encode_image(VAR_0, tempData, VAR_0->width, VAR_0->height, VAR_0->width*VAR_0->height/64); VAR_0->avctx->coded_frame = VAR_0->current_frame; FFSWAP(AVFrame *, VAR_0->current_frame, VAR_0->last_frame); FFSWAP(motion_vect *, VAR_0->last_motion4, VAR_0->this_motion4); FFSWAP(motion_vect *, VAR_0->last_motion8, VAR_0->this_motion8); av_free(tempData->cel_evals); av_free(tempData->closest_cb2); VAR_0->framesSinceKeyframe++; return 0; }
[ "static int FUNC_0(RoqContext *VAR_0)\n{", "RoqTempdata *tempData = VAR_0->tmpData;", "int VAR_1, VAR_2;", "memset(tempData, 0, sizeof(*tempData));", "VAR_2 = create_cel_evals(VAR_0, tempData);", "if (VAR_2 < 0)\nreturn VAR_2;", "VAR_2 = generate_new_codebooks(VAR_0, tempData);", "if (VAR_2 < 0)\nreturn VAR_2;", "if (VAR_0->framesSinceKeyframe >= 1) {", "motion_search(VAR_0, 8);", "motion_search(VAR_0, 4);", "}", "retry_encode:\nfor (VAR_1=0; VAR_1<VAR_0->width*VAR_0->height/64; VAR_1++)", "gather_data_for_cel(tempData->cel_evals + VAR_1, VAR_0, tempData);", "if (tempData->mainChunkSize/8 > 65535) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Warning, generated a frame too big (%d > 65535), \"\n\"try using a smaller qscale value.\\n\",\ntempData->mainChunkSize/8);", "VAR_0->lambda *= 1.5;", "tempData->mainChunkSize = 0;", "memset(tempData->used_option, 0, sizeof(tempData->used_option));", "memset(tempData->codebooks.usedCB4, 0,\nsizeof(tempData->codebooks.usedCB4));", "memset(tempData->codebooks.usedCB2, 0,\nsizeof(tempData->codebooks.usedCB2));", "goto retry_encode;", "}", "remap_codebooks(VAR_0, tempData);", "write_codebooks(VAR_0, tempData);", "reconstruct_and_encode_image(VAR_0, tempData, VAR_0->width, VAR_0->height,\nVAR_0->width*VAR_0->height/64);", "VAR_0->avctx->coded_frame = VAR_0->current_frame;", "FFSWAP(AVFrame *, VAR_0->current_frame, VAR_0->last_frame);", "FFSWAP(motion_vect *, VAR_0->last_motion4, VAR_0->this_motion4);", "FFSWAP(motion_vect *, VAR_0->last_motion8, VAR_0->this_motion8);", "av_free(tempData->cel_evals);", "av_free(tempData->closest_cb2);", "VAR_0->framesSinceKeyframe++;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 51 ], [ 53, 55, 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 83 ], [ 87 ], [ 91, 93 ], [ 97 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 117 ], [ 121 ], [ 123 ] ]
11,645
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { TAKDemuxContext *tc = s->priv_data; int ret; if (tc->mlast_frame) { AVIOContext *pb = s->pb; int64_t size, left; left = tc->data_end - avio_tell(s->pb); size = FFMIN(left, 1024); if (size <= 0) return AVERROR_EOF; ret = av_get_packet(pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; } else { ret = ff_raw_read_partial_packet(s, pkt); } return ret; }
false
FFmpeg
4977e467a50a690a46af5988d568eaab2e5933c7
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { TAKDemuxContext *tc = s->priv_data; int ret; if (tc->mlast_frame) { AVIOContext *pb = s->pb; int64_t size, left; left = tc->data_end - avio_tell(s->pb); size = FFMIN(left, 1024); if (size <= 0) return AVERROR_EOF; ret = av_get_packet(pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; } else { ret = ff_raw_read_partial_packet(s, pkt); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { TAKDemuxContext *tc = VAR_0->priv_data; int VAR_2; if (tc->mlast_frame) { AVIOContext *pb = VAR_0->pb; int64_t size, left; left = tc->data_end - avio_tell(VAR_0->pb); size = FFMIN(left, 1024); if (size <= 0) return AVERROR_EOF; VAR_2 = av_get_packet(pb, VAR_1, size); if (VAR_2 < 0) return VAR_2; VAR_1->stream_index = 0; } else { VAR_2 = ff_raw_read_partial_packet(VAR_0, VAR_1); } return VAR_2; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "TAKDemuxContext *tc = VAR_0->priv_data;", "int VAR_2;", "if (tc->mlast_frame) {", "AVIOContext *pb = VAR_0->pb;", "int64_t size, left;", "left = tc->data_end - avio_tell(VAR_0->pb);", "size = FFMIN(left, 1024);", "if (size <= 0)\nreturn AVERROR_EOF;", "VAR_2 = av_get_packet(pb, VAR_1, size);", "if (VAR_2 < 0)\nreturn VAR_2;", "VAR_1->stream_index = 0;", "} else {", "VAR_2 = ff_raw_read_partial_packet(VAR_0, VAR_1);", "}", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ] ]
11,647
uint64_t helper_mullv (uint64_t op1, uint64_t op2) { int64_t res = (int64_t)op1 * (int64_t)op2; if (unlikely((int32_t)res != res)) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return (int64_t)((int32_t)res); }
true
qemu
2958620f67dcfd11476e62b4ca704dae0b978ea3
uint64_t helper_mullv (uint64_t op1, uint64_t op2) { int64_t res = (int64_t)op1 * (int64_t)op2; if (unlikely((int32_t)res != res)) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return (int64_t)((int32_t)res); }
{ "code": [ " arith_excp(env, GETPC(), EXC_M_IOV, 0);", " arith_excp(env, GETPC(), EXC_M_IOV, 0);", " arith_excp(env, GETPC(), EXC_M_IOV, 0);", " arith_excp(env, GETPC(), EXC_M_IOV, 0);", "uint64_t helper_mullv (uint64_t op1, uint64_t op2)", " int64_t res = (int64_t)op1 * (int64_t)op2;", " if (unlikely((int32_t)res != res)) {", " arith_excp(env, GETPC(), EXC_M_IOV, 0);", " return (int64_t)((int32_t)res);", " arith_excp(env, GETPC(), EXC_M_IOV, 0);" ], "line_no": [ 11, 11, 11, 11, 1, 5, 9, 11, 15, 11 ] }
uint64_t FUNC_0 (uint64_t op1, uint64_t op2) { int64_t res = (int64_t)op1 * (int64_t)op2; if (unlikely((int32_t)res != res)) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return (int64_t)((int32_t)res); }
[ "uint64_t FUNC_0 (uint64_t op1, uint64_t op2)\n{", "int64_t res = (int64_t)op1 * (int64_t)op2;", "if (unlikely((int32_t)res != res)) {", "arith_excp(env, GETPC(), EXC_M_IOV, 0);", "}", "return (int64_t)((int32_t)res);", "}" ]
[ 1, 1, 1, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
11,648
uint32_t hpet_in_legacy_mode(void) { if (hpet_statep) return hpet_statep->config & HPET_CFG_LEGACY; else return 0; }
true
qemu
27bb0b2d6f80f058bdb6fcc8fcdfa69b0c8a6d71
uint32_t hpet_in_legacy_mode(void) { if (hpet_statep) return hpet_statep->config & HPET_CFG_LEGACY; else return 0; }
{ "code": [ " if (hpet_statep)", " return hpet_statep->config & HPET_CFG_LEGACY;" ], "line_no": [ 5, 7 ] }
uint32_t FUNC_0(void) { if (hpet_statep) return hpet_statep->config & HPET_CFG_LEGACY; else return 0; }
[ "uint32_t FUNC_0(void)\n{", "if (hpet_statep)\nreturn hpet_statep->config & HPET_CFG_LEGACY;", "else\nreturn 0;", "}" ]
[ 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11 ], [ 13 ] ]
11,649
make_setup_request (AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge) { RTSPState *rt = s->priv_data; int j, i, err; RTSPStream *rtsp_st; RTSPHeader reply1, *reply = &reply1; char cmd[2048]; const char *trans_pref; if (rt->server_type == RTSP_SERVER_REAL) trans_pref = "x-pn-tng"; else trans_pref = "RTP/AVP"; /* for each stream, make the setup request */ /* XXX: we assume the same server is used for the control of each RTSP stream */ for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) { char transport[2048]; rtsp_st = rt->rtsp_streams[i]; /* RTP/UDP */ if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) { char buf[256]; /* first try in specified port range */ if (RTSP_RTP_PORT_MIN != 0) { while(j <= RTSP_RTP_PORT_MAX) { snprintf(buf, sizeof(buf), "rtp://%s?localport=%d", host, j); j += 2; /* we will use two port by rtp stream (rtp and rtcp) */ if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) { goto rtp_opened; } } } /* then try on any port ** if (url_open(&rtsp_st->rtp_handle, "rtp://", URL_RDONLY) < 0) { ** err = AVERROR_INVALIDDATA; ** goto fail; ** } */ rtp_opened: port = rtp_get_local_port(rtsp_st->rtp_handle); snprintf(transport, sizeof(transport) - 1, "%s/UDP;unicast;client_port=%d", trans_pref, port); if (rt->server_type == RTSP_SERVER_RTP) av_strlcatf(transport, sizeof(transport), "-%d", port + 1); } /* RTP/TCP */ else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) { snprintf(transport, sizeof(transport) - 1, "%s/TCP", trans_pref); } else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) { snprintf(transport, sizeof(transport) - 1, "%s/UDP;multicast", trans_pref); } if (rt->server_type == RTSP_SERVER_REAL) av_strlcat(transport, ";mode=play", sizeof(transport)); snprintf(cmd, sizeof(cmd), "SETUP %s RTSP/1.0\r\n" "Transport: %s\r\n", rtsp_st->control_url, transport); if (i == 0 && rt->server_type == RTSP_SERVER_REAL) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, real_challenge); av_strlcatf(cmd, sizeof(cmd), "If-Match: %s\r\n" "RealChallenge2: %s, sd=%s\r\n", rt->session_id, real_res, real_csum); } rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) { err = 1; goto fail; } else if (reply->status_code != RTSP_STATUS_OK || reply->nb_transports != 1) { err = AVERROR_INVALIDDATA; goto fail; } /* XXX: same protocol for all streams is required */ if (i > 0) { if (reply->transports[0].lower_transport != rt->lower_transport) { err = AVERROR_INVALIDDATA; goto fail; } } else { rt->lower_transport = reply->transports[0].lower_transport; } /* close RTP connection if not choosen */ if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP && (lower_transport == RTSP_LOWER_TRANSPORT_UDP)) { url_close(rtsp_st->rtp_handle); rtsp_st->rtp_handle = NULL; } switch(reply->transports[0].lower_transport) { case RTSP_LOWER_TRANSPORT_TCP: rtsp_st->interleaved_min = reply->transports[0].interleaved_min; rtsp_st->interleaved_max = reply->transports[0].interleaved_max; break; case RTSP_LOWER_TRANSPORT_UDP: { char url[1024]; /* XXX: also use address if specified */ snprintf(url, sizeof(url), "rtp://%s:%d", host, reply->transports[0].server_port_min); if (rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { char url[1024]; struct in_addr in; in.s_addr = htonl(reply->transports[0].destination); snprintf(url, sizeof(url), "rtp://%s:%d?ttl=%d", inet_ntoa(in), reply->transports[0].port_min, reply->transports[0].ttl); if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; } if ((err = rtsp_open_transport_ctx(s, rtsp_st))) goto fail; } if (rt->server_type == RTSP_SERVER_REAL) rt->need_subscription = 1; return 0; fail: for (i=0; i<rt->nb_rtsp_streams; i++) { if (rt->rtsp_streams[i]->rtp_handle) { url_close(rt->rtsp_streams[i]->rtp_handle); rt->rtsp_streams[i]->rtp_handle = NULL; } } return err; }
true
FFmpeg
eee2cbff77d957e19c8e7d4407a27a5f42fef5f6
make_setup_request (AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge) { RTSPState *rt = s->priv_data; int j, i, err; RTSPStream *rtsp_st; RTSPHeader reply1, *reply = &reply1; char cmd[2048]; const char *trans_pref; if (rt->server_type == RTSP_SERVER_REAL) trans_pref = "x-pn-tng"; else trans_pref = "RTP/AVP"; for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) { char transport[2048]; rtsp_st = rt->rtsp_streams[i]; if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) { char buf[256]; if (RTSP_RTP_PORT_MIN != 0) { while(j <= RTSP_RTP_PORT_MAX) { snprintf(buf, sizeof(buf), "rtp: j += 2; if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) { goto rtp_opened; } } } rtp_opened: port = rtp_get_local_port(rtsp_st->rtp_handle); snprintf(transport, sizeof(transport) - 1, "%s/UDP;unicast;client_port=%d", trans_pref, port); if (rt->server_type == RTSP_SERVER_RTP) av_strlcatf(transport, sizeof(transport), "-%d", port + 1); } else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) { snprintf(transport, sizeof(transport) - 1, "%s/TCP", trans_pref); } else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) { snprintf(transport, sizeof(transport) - 1, "%s/UDP;multicast", trans_pref); } if (rt->server_type == RTSP_SERVER_REAL) av_strlcat(transport, ";mode=play", sizeof(transport)); snprintf(cmd, sizeof(cmd), "SETUP %s RTSP/1.0\r\n" "Transport: %s\r\n", rtsp_st->control_url, transport); if (i == 0 && rt->server_type == RTSP_SERVER_REAL) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, real_challenge); av_strlcatf(cmd, sizeof(cmd), "If-Match: %s\r\n" "RealChallenge2: %s, sd=%s\r\n", rt->session_id, real_res, real_csum); } rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code == 461 && i == 0) { err = 1; goto fail; } else if (reply->status_code != RTSP_STATUS_OK || reply->nb_transports != 1) { err = AVERROR_INVALIDDATA; goto fail; } if (i > 0) { if (reply->transports[0].lower_transport != rt->lower_transport) { err = AVERROR_INVALIDDATA; goto fail; } } else { rt->lower_transport = reply->transports[0].lower_transport; } if (reply->transports[0].lower_transport != RTSP_LOWER_TRANSPORT_UDP && (lower_transport == RTSP_LOWER_TRANSPORT_UDP)) { url_close(rtsp_st->rtp_handle); rtsp_st->rtp_handle = NULL; } switch(reply->transports[0].lower_transport) { case RTSP_LOWER_TRANSPORT_TCP: rtsp_st->interleaved_min = reply->transports[0].interleaved_min; rtsp_st->interleaved_max = reply->transports[0].interleaved_max; break; case RTSP_LOWER_TRANSPORT_UDP: { char url[1024]; snprintf(url, sizeof(url), "rtp: host, reply->transports[0].server_port_min); if (rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { char url[1024]; struct in_addr in; in.s_addr = htonl(reply->transports[0].destination); snprintf(url, sizeof(url), "rtp: inet_ntoa(in), reply->transports[0].port_min, reply->transports[0].ttl); if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { err = AVERROR_INVALIDDATA; goto fail; } } break; } if ((err = rtsp_open_transport_ctx(s, rtsp_st))) goto fail; } if (rt->server_type == RTSP_SERVER_REAL) rt->need_subscription = 1; return 0; fail: for (i=0; i<rt->nb_rtsp_streams; i++) { if (rt->rtsp_streams[i]->rtp_handle) { url_close(rt->rtsp_streams[i]->rtp_handle); rt->rtsp_streams[i]->rtp_handle = NULL; } } return err; }
{ "code": [ " \"%s/UDP;unicast;client_port=%d\",", " trans_pref, port);" ], "line_no": [ 99, 101 ] }
FUNC_0 (AVFormatContext *VAR_0, const char *VAR_1, int VAR_2, int VAR_3, const char *VAR_4) { RTSPState *rt = VAR_0->priv_data; int VAR_5, VAR_6, VAR_7; RTSPStream *rtsp_st; RTSPHeader reply1, *reply = &reply1; char VAR_8[2048]; const char *VAR_9; if (rt->server_type == RTSP_SERVER_REAL) VAR_9 = "x-pn-tng"; else VAR_9 = "RTP/AVP"; for(VAR_5 = RTSP_RTP_PORT_MIN, VAR_6 = 0; VAR_6 < rt->nb_rtsp_streams; ++VAR_6) { char transport[2048]; rtsp_st = rt->rtsp_streams[VAR_6]; if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP) { char buf[256]; if (RTSP_RTP_PORT_MIN != 0) { while(VAR_5 <= RTSP_RTP_PORT_MAX) { snprintf(buf, sizeof(buf), "rtp: VAR_5 += 2; if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) { goto rtp_opened; } } } rtp_opened: VAR_2 = rtp_get_local_port(rtsp_st->rtp_handle); snprintf(transport, sizeof(transport) - 1, "%VAR_0/UDP;unicast;client_port=%d", VAR_9, VAR_2); if (rt->server_type == RTSP_SERVER_RTP) av_strlcatf(transport, sizeof(transport), "-%d", VAR_2 + 1); } else if (VAR_3 == RTSP_LOWER_TRANSPORT_TCP) { snprintf(transport, sizeof(transport) - 1, "%VAR_0/TCP", VAR_9); } else if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) { snprintf(transport, sizeof(transport) - 1, "%VAR_0/UDP;multicast", VAR_9); } if (rt->server_type == RTSP_SERVER_REAL) av_strlcat(transport, ";mode=play", sizeof(transport)); snprintf(VAR_8, sizeof(VAR_8), "SETUP %VAR_0 RTSP/1.0\r\n" "Transport: %VAR_0\r\n", rtsp_st->control_url, transport); if (VAR_6 == 0 && rt->server_type == RTSP_SERVER_REAL) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, VAR_4); av_strlcatf(VAR_8, sizeof(VAR_8), "If-Match: %VAR_0\r\n" "RealChallenge2: %VAR_0, sd=%VAR_0\r\n", rt->session_id, real_res, real_csum); } rtsp_send_cmd(VAR_0, VAR_8, reply, NULL); if (reply->status_code == 461 && VAR_6 == 0) { VAR_7 = 1; goto fail; } else if (reply->status_code != RTSP_STATUS_OK || reply->nb_transports != 1) { VAR_7 = AVERROR_INVALIDDATA; goto fail; } if (VAR_6 > 0) { if (reply->transports[0].VAR_3 != rt->VAR_3) { VAR_7 = AVERROR_INVALIDDATA; goto fail; } } else { rt->VAR_3 = reply->transports[0].VAR_3; } if (reply->transports[0].VAR_3 != RTSP_LOWER_TRANSPORT_UDP && (VAR_3 == RTSP_LOWER_TRANSPORT_UDP)) { url_close(rtsp_st->rtp_handle); rtsp_st->rtp_handle = NULL; } switch(reply->transports[0].VAR_3) { case RTSP_LOWER_TRANSPORT_TCP: rtsp_st->interleaved_min = reply->transports[0].interleaved_min; rtsp_st->interleaved_max = reply->transports[0].interleaved_max; break; case RTSP_LOWER_TRANSPORT_UDP: { char url[1024]; snprintf(url, sizeof(url), "rtp: VAR_1, reply->transports[0].server_port_min); if (rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { VAR_7 = AVERROR_INVALIDDATA; goto fail; } } break; case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { char url[1024]; struct in_addr in; in.s_addr = htonl(reply->transports[0].destination); snprintf(url, sizeof(url), "rtp: inet_ntoa(in), reply->transports[0].port_min, reply->transports[0].ttl); if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { VAR_7 = AVERROR_INVALIDDATA; goto fail; } } break; } if ((VAR_7 = rtsp_open_transport_ctx(VAR_0, rtsp_st))) goto fail; } if (rt->server_type == RTSP_SERVER_REAL) rt->need_subscription = 1; return 0; fail: for (VAR_6=0; VAR_6<rt->nb_rtsp_streams; VAR_6++) { if (rt->rtsp_streams[VAR_6]->rtp_handle) { url_close(rt->rtsp_streams[VAR_6]->rtp_handle); rt->rtsp_streams[VAR_6]->rtp_handle = NULL; } } return VAR_7; }
[ "FUNC_0 (AVFormatContext *VAR_0, const char *VAR_1, int VAR_2,\nint VAR_3, const char *VAR_4)\n{", "RTSPState *rt = VAR_0->priv_data;", "int VAR_5, VAR_6, VAR_7;", "RTSPStream *rtsp_st;", "RTSPHeader reply1, *reply = &reply1;", "char VAR_8[2048];", "const char *VAR_9;", "if (rt->server_type == RTSP_SERVER_REAL)\nVAR_9 = \"x-pn-tng\";", "else\nVAR_9 = \"RTP/AVP\";", "for(VAR_5 = RTSP_RTP_PORT_MIN, VAR_6 = 0; VAR_6 < rt->nb_rtsp_streams; ++VAR_6) {", "char transport[2048];", "rtsp_st = rt->rtsp_streams[VAR_6];", "if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP) {", "char buf[256];", "if (RTSP_RTP_PORT_MIN != 0) {", "while(VAR_5 <= RTSP_RTP_PORT_MAX) {", "snprintf(buf, sizeof(buf), \"rtp:\nVAR_5 += 2;", "if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) {", "goto rtp_opened;", "}", "}", "}", "rtp_opened:\nVAR_2 = rtp_get_local_port(rtsp_st->rtp_handle);", "snprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/UDP;unicast;client_port=%d\",", "VAR_9, VAR_2);", "if (rt->server_type == RTSP_SERVER_RTP)\nav_strlcatf(transport, sizeof(transport), \"-%d\", VAR_2 + 1);", "}", "else if (VAR_3 == RTSP_LOWER_TRANSPORT_TCP) {", "snprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/TCP\", VAR_9);", "}", "else if (VAR_3 == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {", "snprintf(transport, sizeof(transport) - 1,\n\"%VAR_0/UDP;multicast\", VAR_9);", "}", "if (rt->server_type == RTSP_SERVER_REAL)\nav_strlcat(transport, \";mode=play\", sizeof(transport));", "snprintf(VAR_8, sizeof(VAR_8),\n\"SETUP %VAR_0 RTSP/1.0\\r\\n\"\n\"Transport: %VAR_0\\r\\n\",\nrtsp_st->control_url, transport);", "if (VAR_6 == 0 && rt->server_type == RTSP_SERVER_REAL) {", "char real_res[41], real_csum[9];", "ff_rdt_calc_response_and_checksum(real_res, real_csum,\nVAR_4);", "av_strlcatf(VAR_8, sizeof(VAR_8),\n\"If-Match: %VAR_0\\r\\n\"\n\"RealChallenge2: %VAR_0, sd=%VAR_0\\r\\n\",\nrt->session_id, real_res, real_csum);", "}", "rtsp_send_cmd(VAR_0, VAR_8, reply, NULL);", "if (reply->status_code == 461 && VAR_6 == 0) {", "VAR_7 = 1;", "goto fail;", "} else if (reply->status_code != RTSP_STATUS_OK ||", "reply->nb_transports != 1) {", "VAR_7 = AVERROR_INVALIDDATA;", "goto fail;", "}", "if (VAR_6 > 0) {", "if (reply->transports[0].VAR_3 != rt->VAR_3) {", "VAR_7 = AVERROR_INVALIDDATA;", "goto fail;", "}", "} else {", "rt->VAR_3 = reply->transports[0].VAR_3;", "}", "if (reply->transports[0].VAR_3 != RTSP_LOWER_TRANSPORT_UDP &&\n(VAR_3 == RTSP_LOWER_TRANSPORT_UDP)) {", "url_close(rtsp_st->rtp_handle);", "rtsp_st->rtp_handle = NULL;", "}", "switch(reply->transports[0].VAR_3) {", "case RTSP_LOWER_TRANSPORT_TCP:\nrtsp_st->interleaved_min = reply->transports[0].interleaved_min;", "rtsp_st->interleaved_max = reply->transports[0].interleaved_max;", "break;", "case RTSP_LOWER_TRANSPORT_UDP:\n{", "char url[1024];", "snprintf(url, sizeof(url), \"rtp:\nVAR_1, reply->transports[0].server_port_min);", "if (rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {", "VAR_7 = AVERROR_INVALIDDATA;", "goto fail;", "}", "}", "break;", "case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:\n{", "char url[1024];", "struct in_addr in;", "in.s_addr = htonl(reply->transports[0].destination);", "snprintf(url, sizeof(url), \"rtp:\ninet_ntoa(in),\nreply->transports[0].port_min,\nreply->transports[0].ttl);", "if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {", "VAR_7 = AVERROR_INVALIDDATA;", "goto fail;", "}", "}", "break;", "}", "if ((VAR_7 = rtsp_open_transport_ctx(VAR_0, rtsp_st)))\ngoto fail;", "}", "if (rt->server_type == RTSP_SERVER_REAL)\nrt->need_subscription = 1;", "return 0;", "fail:\nfor (VAR_6=0; VAR_6<rt->nb_rtsp_streams; VAR_6++) {", "if (rt->rtsp_streams[VAR_6]->rtp_handle) {", "url_close(rt->rtsp_streams[VAR_6]->rtp_handle);", "rt->rtsp_streams[VAR_6]->rtp_handle = NULL;", "}", "}", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25, 27 ], [ 39 ], [ 41 ], [ 45 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 93, 95 ], [ 97, 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131, 133 ], [ 135, 137, 139, 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151, 153, 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 203, 205 ], [ 207 ], [ 209 ], [ 211 ], [ 215 ], [ 217, 219 ], [ 221 ], [ 223 ], [ 227, 229 ], [ 231 ], [ 237, 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 263 ], [ 265, 267, 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 289, 291 ], [ 293 ], [ 297, 299 ], [ 303 ], [ 307, 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ] ]
11,650
static int ipvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IpvideoContext *s = avctx->priv_data; AVFrame *frame = data; int ret; int send_buffer; int frame_format; int video_data_size; if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { av_frame_unref(s->last_frame); av_frame_unref(s->second_last_frame); if (buf_size < 8) return AVERROR_INVALIDDATA; frame_format = AV_RL8(buf); send_buffer = AV_RL8(buf + 1); video_data_size = AV_RL16(buf + 2); s->decoding_map_size = AV_RL16(buf + 4); s->skip_map_size = AV_RL16(buf + 6); switch(frame_format) { case 0x06: if (s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Decoding map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(avctx, AV_LOG_ERROR, "Video format 0x06 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; /* Decoding map for 0x06 frame format is at the top of pixeldata */ s->decoding_map_size = ((s->avctx->width / 8) * (s->avctx->height / 8)) * 2; s->decoding_map = buf + 8 + 14; /* 14 bits of op data */ video_data_size -= s->decoding_map_size + 14; if (video_data_size <= 0) return AVERROR_INVALIDDATA; if (buf_size < 8 + s->decoding_map_size + 14 + video_data_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8 + s->decoding_map_size + 14, video_data_size); break; case 0x10: if (! s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x10\n"); return AVERROR_INVALIDDATA; if (! s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty skip map for format 0x10\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(avctx, AV_LOG_ERROR, "Video format 0x10 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; if (buf_size < 8 + video_data_size + s->decoding_map_size + s->skip_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8, video_data_size); s->decoding_map = buf + 8 + video_data_size; s->skip_map = buf + 8 + video_data_size + s->decoding_map_size; break; case 0x11: if (! s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x11\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x11\n"); return AVERROR_INVALIDDATA; if (buf_size < 8 + video_data_size + s->decoding_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8, video_data_size); s->decoding_map = buf + 8 + video_data_size; break; default: av_log(avctx, AV_LOG_ERROR, "Frame type 0x%02X unsupported\n", frame_format); /* ensure we can't overread the packet */ if (buf_size < 8 + s->decoding_map_size + video_data_size + s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Invalid IP packet size\n"); return AVERROR_INVALIDDATA; if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) if (!s->is_16bpp) { int size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); if (pal && size == AVPALETTE_SIZE) { frame->palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } else if (pal) { av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); switch(frame_format) { case 0x06: ipvideo_decode_format_06_opcodes(s, frame); break; case 0x10: ipvideo_decode_format_10_opcodes(s, frame); break; case 0x11: ipvideo_decode_format_11_opcodes(s, frame); break; *got_frame = send_buffer; /* shuffle frames */ av_frame_unref(s->second_last_frame); FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); if ((ret = av_frame_ref(s->last_frame, frame)) < 0) /* report that the buffer was completely consumed */ return buf_size;
true
FFmpeg
f1baafac7129c3bb8d4abaaa899988c7a51ca5cd
static int ipvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IpvideoContext *s = avctx->priv_data; AVFrame *frame = data; int ret; int send_buffer; int frame_format; int video_data_size; if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { av_frame_unref(s->last_frame); av_frame_unref(s->second_last_frame); if (buf_size < 8) return AVERROR_INVALIDDATA; frame_format = AV_RL8(buf); send_buffer = AV_RL8(buf + 1); video_data_size = AV_RL16(buf + 2); s->decoding_map_size = AV_RL16(buf + 4); s->skip_map_size = AV_RL16(buf + 6); switch(frame_format) { case 0x06: if (s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Decoding map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(avctx, AV_LOG_ERROR, "Video format 0x06 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; s->decoding_map_size = ((s->avctx->width / 8) * (s->avctx->height / 8)) * 2; s->decoding_map = buf + 8 + 14; video_data_size -= s->decoding_map_size + 14; if (video_data_size <= 0) return AVERROR_INVALIDDATA; if (buf_size < 8 + s->decoding_map_size + 14 + video_data_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8 + s->decoding_map_size + 14, video_data_size); break; case 0x10: if (! s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x10\n"); return AVERROR_INVALIDDATA; if (! s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty skip map for format 0x10\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(avctx, AV_LOG_ERROR, "Video format 0x10 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; if (buf_size < 8 + video_data_size + s->decoding_map_size + s->skip_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8, video_data_size); s->decoding_map = buf + 8 + video_data_size; s->skip_map = buf + 8 + video_data_size + s->decoding_map_size; break; case 0x11: if (! s->decoding_map_size) { av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x11\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x11\n"); return AVERROR_INVALIDDATA; if (buf_size < 8 + video_data_size + s->decoding_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, buf + 8, video_data_size); s->decoding_map = buf + 8 + video_data_size; break; default: av_log(avctx, AV_LOG_ERROR, "Frame type 0x%02X unsupported\n", frame_format); if (buf_size < 8 + s->decoding_map_size + video_data_size + s->skip_map_size) { av_log(avctx, AV_LOG_ERROR, "Invalid IP packet size\n"); return AVERROR_INVALIDDATA; if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) if (!s->is_16bpp) { int size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); if (pal && size == AVPALETTE_SIZE) { frame->palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } else if (pal) { av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); switch(frame_format) { case 0x06: ipvideo_decode_format_06_opcodes(s, frame); break; case 0x10: ipvideo_decode_format_10_opcodes(s, frame); break; case 0x11: ipvideo_decode_format_11_opcodes(s, frame); break; *got_frame = send_buffer; av_frame_unref(s->second_last_frame); FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); if ((ret = av_frame_ref(s->last_frame, frame)) < 0) return buf_size;
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->VAR_10; IpvideoContext *s = VAR_0->priv_data; AVFrame *frame = VAR_1; int VAR_6; int VAR_7; int VAR_8; int VAR_9; if (av_packet_get_side_data(VAR_3, AV_PKT_DATA_PARAM_CHANGE, NULL)) { av_frame_unref(s->last_frame); av_frame_unref(s->second_last_frame); if (VAR_5 < 8) return AVERROR_INVALIDDATA; VAR_8 = AV_RL8(VAR_4); VAR_7 = AV_RL8(VAR_4 + 1); VAR_9 = AV_RL16(VAR_4 + 2); s->decoding_map_size = AV_RL16(VAR_4 + 4); s->skip_map_size = AV_RL16(VAR_4 + 6); switch(VAR_8) { case 0x06: if (s->decoding_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Decoding map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Skip map for format 0x06\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(VAR_0, AV_LOG_ERROR, "Video format 0x06 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; s->decoding_map_size = ((s->VAR_0->width / 8) * (s->VAR_0->height / 8)) * 2; s->decoding_map = VAR_4 + 8 + 14; VAR_9 -= s->decoding_map_size + 14; if (VAR_9 <= 0) return AVERROR_INVALIDDATA; if (VAR_5 < 8 + s->decoding_map_size + 14 + VAR_9) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, VAR_4 + 8 + s->decoding_map_size + 14, VAR_9); break; case 0x10: if (! s->decoding_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Empty decoding map for format 0x10\n"); return AVERROR_INVALIDDATA; if (! s->skip_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Empty skip map for format 0x10\n"); return AVERROR_INVALIDDATA; if (s->is_16bpp) { av_log(VAR_0, AV_LOG_ERROR, "Video format 0x10 does not support 16bpp movies\n"); return AVERROR_INVALIDDATA; if (VAR_5 < 8 + VAR_9 + s->decoding_map_size + s->skip_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, VAR_4 + 8, VAR_9); s->decoding_map = VAR_4 + 8 + VAR_9; s->skip_map = VAR_4 + 8 + VAR_9 + s->decoding_map_size; break; case 0x11: if (! s->decoding_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Empty decoding map for format 0x11\n"); return AVERROR_INVALIDDATA; if (s->skip_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Skip map for format 0x11\n"); return AVERROR_INVALIDDATA; if (VAR_5 < 8 + VAR_9 + s->decoding_map_size) return AVERROR_INVALIDDATA; bytestream2_init(&s->stream_ptr, VAR_4 + 8, VAR_9); s->decoding_map = VAR_4 + 8 + VAR_9; break; default: av_log(VAR_0, AV_LOG_ERROR, "Frame type 0x%02X unsupported\n", VAR_8); if (VAR_5 < 8 + s->decoding_map_size + VAR_9 + s->skip_map_size) { av_log(VAR_0, AV_LOG_ERROR, "Invalid IP packet VAR_10\n"); return AVERROR_INVALIDDATA; if ((VAR_6 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0) if (!s->is_16bpp) { int VAR_10; const uint8_t *VAR_11 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_10); if (VAR_11 && VAR_10 == AVPALETTE_SIZE) { frame->palette_has_changed = 1; memcpy(s->VAR_11, VAR_11, AVPALETTE_SIZE); } else if (VAR_11) { av_log(VAR_0, AV_LOG_ERROR, "Palette VAR_10 %d is wrong\n", VAR_10); switch(VAR_8) { case 0x06: ipvideo_decode_format_06_opcodes(s, frame); break; case 0x10: ipvideo_decode_format_10_opcodes(s, frame); break; case 0x11: ipvideo_decode_format_11_opcodes(s, frame); break; *VAR_2 = VAR_7; av_frame_unref(s->second_last_frame); FFSWAP(AVFrame*, s->second_last_frame, s->last_frame); if ((VAR_6 = av_frame_ref(s->last_frame, frame)) < 0) return VAR_5;
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->VAR_10;", "IpvideoContext *s = VAR_0->priv_data;", "AVFrame *frame = VAR_1;", "int VAR_6;", "int VAR_7;", "int VAR_8;", "int VAR_9;", "if (av_packet_get_side_data(VAR_3, AV_PKT_DATA_PARAM_CHANGE, NULL)) {", "av_frame_unref(s->last_frame);", "av_frame_unref(s->second_last_frame);", "if (VAR_5 < 8)\nreturn AVERROR_INVALIDDATA;", "VAR_8 = AV_RL8(VAR_4);", "VAR_7 = AV_RL8(VAR_4 + 1);", "VAR_9 = AV_RL16(VAR_4 + 2);", "s->decoding_map_size = AV_RL16(VAR_4 + 4);", "s->skip_map_size = AV_RL16(VAR_4 + 6);", "switch(VAR_8) {", "case 0x06:\nif (s->decoding_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Decoding map for format 0x06\\n\");", "return AVERROR_INVALIDDATA;", "if (s->skip_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Skip map for format 0x06\\n\");", "return AVERROR_INVALIDDATA;", "if (s->is_16bpp) {", "av_log(VAR_0, AV_LOG_ERROR, \"Video format 0x06 does not support 16bpp movies\\n\");", "return AVERROR_INVALIDDATA;", "s->decoding_map_size = ((s->VAR_0->width / 8) * (s->VAR_0->height / 8)) * 2;", "s->decoding_map = VAR_4 + 8 + 14;", "VAR_9 -= s->decoding_map_size + 14;", "if (VAR_9 <= 0)\nreturn AVERROR_INVALIDDATA;", "if (VAR_5 < 8 + s->decoding_map_size + 14 + VAR_9)\nreturn AVERROR_INVALIDDATA;", "bytestream2_init(&s->stream_ptr, VAR_4 + 8 + s->decoding_map_size + 14, VAR_9);", "break;", "case 0x10:\nif (! s->decoding_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Empty decoding map for format 0x10\\n\");", "return AVERROR_INVALIDDATA;", "if (! s->skip_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Empty skip map for format 0x10\\n\");", "return AVERROR_INVALIDDATA;", "if (s->is_16bpp) {", "av_log(VAR_0, AV_LOG_ERROR, \"Video format 0x10 does not support 16bpp movies\\n\");", "return AVERROR_INVALIDDATA;", "if (VAR_5 < 8 + VAR_9 + s->decoding_map_size + s->skip_map_size)\nreturn AVERROR_INVALIDDATA;", "bytestream2_init(&s->stream_ptr, VAR_4 + 8, VAR_9);", "s->decoding_map = VAR_4 + 8 + VAR_9;", "s->skip_map = VAR_4 + 8 + VAR_9 + s->decoding_map_size;", "break;", "case 0x11:\nif (! s->decoding_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Empty decoding map for format 0x11\\n\");", "return AVERROR_INVALIDDATA;", "if (s->skip_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Skip map for format 0x11\\n\");", "return AVERROR_INVALIDDATA;", "if (VAR_5 < 8 + VAR_9 + s->decoding_map_size)\nreturn AVERROR_INVALIDDATA;", "bytestream2_init(&s->stream_ptr, VAR_4 + 8, VAR_9);", "s->decoding_map = VAR_4 + 8 + VAR_9;", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"Frame type 0x%02X unsupported\\n\", VAR_8);", "if (VAR_5 < 8 + s->decoding_map_size + VAR_9 + s->skip_map_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid IP packet VAR_10\\n\");", "return AVERROR_INVALIDDATA;", "if ((VAR_6 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)\nif (!s->is_16bpp) {", "int VAR_10;", "const uint8_t *VAR_11 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_10);", "if (VAR_11 && VAR_10 == AVPALETTE_SIZE) {", "frame->palette_has_changed = 1;", "memcpy(s->VAR_11, VAR_11, AVPALETTE_SIZE);", "} else if (VAR_11) {", "av_log(VAR_0, AV_LOG_ERROR, \"Palette VAR_10 %d is wrong\\n\", VAR_10);", "switch(VAR_8) {", "case 0x06:\nipvideo_decode_format_06_opcodes(s, frame);", "break;", "case 0x10:\nipvideo_decode_format_10_opcodes(s, frame);", "break;", "case 0x11:\nipvideo_decode_format_11_opcodes(s, frame);", "break;", "*VAR_2 = VAR_7;", "av_frame_unref(s->second_last_frame);", "FFSWAP(AVFrame*, s->second_last_frame, s->last_frame);", "if ((VAR_6 = av_frame_ref(s->last_frame, frame)) < 0)\nreturn VAR_5;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16, 17 ], [ 18 ], [ 19 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24, 25 ], [ 26 ], [ 27 ], [ 28 ], [ 29 ], [ 30 ], [ 31 ], [ 32 ], [ 33 ], [ 35 ], [ 36 ], [ 37 ], [ 38, 39 ], [ 40, 41 ], [ 42 ], [ 43 ], [ 44, 45 ], [ 46 ], [ 47 ], [ 48 ], [ 49 ], [ 50 ], [ 51 ], [ 52 ], [ 53 ], [ 54, 55 ], [ 56 ], [ 57 ], [ 58 ], [ 59 ], [ 60, 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66 ], [ 67, 68 ], [ 69 ], [ 70 ], [ 71 ], [ 72, 73 ], [ 75 ], [ 76 ], [ 77 ], [ 78, 79 ], [ 80 ], [ 81 ], [ 82 ], [ 83 ], [ 84 ], [ 85 ], [ 86 ], [ 87 ], [ 88, 89 ], [ 90 ], [ 91, 92 ], [ 93 ], [ 94, 95 ], [ 96 ], [ 97 ], [ 99 ], [ 100 ], [ 101, 103 ] ]
11,651
static int qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(buffer, hdrs, nhdrs, errp); if (!nhdrs) { return -1; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); return -1; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); return -1; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); return -1; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); return -1; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); return -1; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); return -1; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); return -1; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); return -1; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); return -1; } if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) { error_setg(errp, "No connection upgrade requested '%s'", connection); return -1; } if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); return -1; } return qio_channel_websock_handshake_send_response(ioc, key, errp); }
true
qemu
f69a8bde29354493ff8aea64cc9cb3b531d16337
static int qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(buffer, hdrs, nhdrs, errp); if (!nhdrs) { return -1; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); return -1; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); return -1; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); return -1; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); return -1; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); return -1; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); return -1; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); return -1; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); return -1; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); return -1; } if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) { error_setg(errp, "No connection upgrade requested '%s'", connection); return -1; } if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); return -1; } return qio_channel_websock_handshake_send_response(ioc, key, errp); }
{ "code": [ " return -1;", "static int qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,", " char *buffer,", " Error **errp)", " nhdrs = qio_channel_websock_extract_headers(buffer, hdrs, nhdrs, errp);", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return qio_channel_websock_handshake_send_response(ioc, key, errp);", " return -1;" ], "line_no": [ 23, 1, 3, 5, 19, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 169, 23 ] }
static int FUNC_0(QIOChannelWebsock *VAR_0, char *VAR_1, Error **VAR_2) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *VAR_3 = NULL, *VAR_4 = NULL, *VAR_5 = NULL, *VAR_6 = NULL, *VAR_7 = NULL, *VAR_8 = NULL; nhdrs = qio_channel_websock_extract_headers(VAR_1, hdrs, nhdrs, VAR_2); if (!nhdrs) { return -1; } VAR_3 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!VAR_3) { error_setg(VAR_2, "Missing websocket protocol header data"); return -1; } VAR_4 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!VAR_4) { error_setg(VAR_2, "Missing websocket VAR_4 header data"); return -1; } VAR_5 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!VAR_5) { error_setg(VAR_2, "Missing websocket VAR_5 header data"); return -1; } VAR_6 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!VAR_6) { error_setg(VAR_2, "Missing websocket VAR_6 header data"); return -1; } VAR_7 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!VAR_7) { error_setg(VAR_2, "Missing websocket VAR_7 header data"); return -1; } VAR_8 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!VAR_8) { error_setg(VAR_2, "Missing websocket VAR_8 header data"); return -1; } if (!g_strrstr(VAR_3, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(VAR_2, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, VAR_3); return -1; } if (!g_str_equal(VAR_4, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(VAR_2, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, VAR_4); return -1; } if (strlen(VAR_5) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(VAR_2, "Key length '%zu' was not as expected '%d'", strlen(VAR_5), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); return -1; } if (!g_strrstr(VAR_7, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) { error_setg(VAR_2, "No VAR_7 VAR_8 requested '%s'", VAR_7); return -1; } if (!g_str_equal(VAR_8, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) { error_setg(VAR_2, "Incorrect VAR_8 method '%s'", VAR_8); return -1; } return qio_channel_websock_handshake_send_response(VAR_0, VAR_5, VAR_2); }
[ "static int FUNC_0(QIOChannelWebsock *VAR_0,\nchar *VAR_1,\nError **VAR_2)\n{", "QIOChannelWebsockHTTPHeader hdrs[32];", "size_t nhdrs = G_N_ELEMENTS(hdrs);", "const char *VAR_3 = NULL, *VAR_4 = NULL, *VAR_5 = NULL,\n*VAR_6 = NULL, *VAR_7 = NULL, *VAR_8 = NULL;", "nhdrs = qio_channel_websock_extract_headers(VAR_1, hdrs, nhdrs, VAR_2);", "if (!nhdrs) {", "return -1;", "}", "VAR_3 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL);", "if (!VAR_3) {", "error_setg(VAR_2, \"Missing websocket protocol header data\");", "return -1;", "}", "VAR_4 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION);", "if (!VAR_4) {", "error_setg(VAR_2, \"Missing websocket VAR_4 header data\");", "return -1;", "}", "VAR_5 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY);", "if (!VAR_5) {", "error_setg(VAR_2, \"Missing websocket VAR_5 header data\");", "return -1;", "}", "VAR_6 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST);", "if (!VAR_6) {", "error_setg(VAR_2, \"Missing websocket VAR_6 header data\");", "return -1;", "}", "VAR_7 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION);", "if (!VAR_7) {", "error_setg(VAR_2, \"Missing websocket VAR_7 header data\");", "return -1;", "}", "VAR_8 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE);", "if (!VAR_8) {", "error_setg(VAR_2, \"Missing websocket VAR_8 header data\");", "return -1;", "}", "if (!g_strrstr(VAR_3, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) {", "error_setg(VAR_2, \"No '%s' protocol is supported by client '%s'\",\nQIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, VAR_3);", "return -1;", "}", "if (!g_str_equal(VAR_4, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) {", "error_setg(VAR_2, \"Version '%s' is not supported by client '%s'\",\nQIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, VAR_4);", "return -1;", "}", "if (strlen(VAR_5) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) {", "error_setg(VAR_2, \"Key length '%zu' was not as expected '%d'\",\nstrlen(VAR_5), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN);", "return -1;", "}", "if (!g_strrstr(VAR_7, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) {", "error_setg(VAR_2, \"No VAR_7 VAR_8 requested '%s'\", VAR_7);", "return -1;", "}", "if (!g_str_equal(VAR_8, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) {", "error_setg(VAR_2, \"Incorrect VAR_8 method '%s'\", VAR_8);", "return -1;", "}", "return qio_channel_websock_handshake_send_response(VAR_0, VAR_5, VAR_2);", "}" ]
[ 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ] ]
11,652
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { AVFrame frame; int ret, got_frame = 0; if (avctx->get_buffer != avcodec_default_get_buffer) { av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with" "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n"); av_log(avctx, AV_LOG_ERROR, "Please port your application to " "avcodec_decode_audio4()\n"); avctx->get_buffer = avcodec_default_get_buffer; } ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); if (ret >= 0 && got_frame) { int ch, plane_size; int planar = av_sample_fmt_is_planar(avctx->sample_fmt); int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, frame.nb_samples, avctx->sample_fmt, 1); if (*frame_size_ptr < data_size) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " "the current frame (%d < %d)\n", *frame_size_ptr, data_size); return AVERROR(EINVAL); } memcpy(samples, frame.extended_data[0], plane_size); if (planar && avctx->channels > 1) { uint8_t *out = ((uint8_t *)samples) + plane_size; for (ch = 1; ch < avctx->channels; ch++) { memcpy(out, frame.extended_data[ch], plane_size); out += plane_size; } } *frame_size_ptr = data_size; } else { *frame_size_ptr = 0; } return ret; }
false
FFmpeg
6d1270a0f9ededd37ed14bde52b8ee69b99e8a7f
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { AVFrame frame; int ret, got_frame = 0; if (avctx->get_buffer != avcodec_default_get_buffer) { av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with" "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n"); av_log(avctx, AV_LOG_ERROR, "Please port your application to " "avcodec_decode_audio4()\n"); avctx->get_buffer = avcodec_default_get_buffer; } ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); if (ret >= 0 && got_frame) { int ch, plane_size; int planar = av_sample_fmt_is_planar(avctx->sample_fmt); int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, frame.nb_samples, avctx->sample_fmt, 1); if (*frame_size_ptr < data_size) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " "the current frame (%d < %d)\n", *frame_size_ptr, data_size); return AVERROR(EINVAL); } memcpy(samples, frame.extended_data[0], plane_size); if (planar && avctx->channels > 1) { uint8_t *out = ((uint8_t *)samples) + plane_size; for (ch = 1; ch < avctx->channels; ch++) { memcpy(out, frame.extended_data[ch], plane_size); out += plane_size; } } *frame_size_ptr = data_size; } else { *frame_size_ptr = 0; } return ret; }
{ "code": [], "line_no": [] }
int VAR_0 avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { AVFrame frame; int ret, got_frame = 0; if (avctx->get_buffer != avcodec_default_get_buffer) { av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with" "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n"); av_log(avctx, AV_LOG_ERROR, "Please port your application to " "avcodec_decode_audio4()\n"); avctx->get_buffer = avcodec_default_get_buffer; } ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); if (ret >= 0 && got_frame) { int ch, plane_size; int planar = av_sample_fmt_is_planar(avctx->sample_fmt); int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, frame.nb_samples, avctx->sample_fmt, 1); if (*frame_size_ptr < data_size) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " "the current frame (%d < %d)\n", *frame_size_ptr, data_size); return AVERROR(EINVAL); } memcpy(samples, frame.extended_data[0], plane_size); if (planar && avctx->channels > 1) { uint8_t *out = ((uint8_t *)samples) + plane_size; for (ch = 1; ch < avctx->channels; ch++) { memcpy(out, frame.extended_data[ch], plane_size); out += plane_size; } } *frame_size_ptr = data_size; } else { *frame_size_ptr = 0; } return ret; }
[ "int VAR_0 avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,\nint *frame_size_ptr,\nAVPacket *avpkt)\n{", "AVFrame frame;", "int ret, got_frame = 0;", "if (avctx->get_buffer != avcodec_default_get_buffer) {", "av_log(avctx, AV_LOG_ERROR, \"Custom get_buffer() for use with\"\n\"avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\\n\");", "av_log(avctx, AV_LOG_ERROR, \"Please port your application to \"\n\"avcodec_decode_audio4()\\n\");", "avctx->get_buffer = avcodec_default_get_buffer;", "}", "ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);", "if (ret >= 0 && got_frame) {", "int ch, plane_size;", "int planar = av_sample_fmt_is_planar(avctx->sample_fmt);", "int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels,\nframe.nb_samples,\navctx->sample_fmt, 1);", "if (*frame_size_ptr < data_size) {", "av_log(avctx, AV_LOG_ERROR, \"output buffer size is too small for \"\n\"the current frame (%d < %d)\\n\", *frame_size_ptr, data_size);", "return AVERROR(EINVAL);", "}", "memcpy(samples, frame.extended_data[0], plane_size);", "if (planar && avctx->channels > 1) {", "uint8_t *out = ((uint8_t *)samples) + plane_size;", "for (ch = 1; ch < avctx->channels; ch++) {", "memcpy(out, frame.extended_data[ch], plane_size);", "out += plane_size;", "}", "}", "*frame_size_ptr = data_size;", "} else {", "*frame_size_ptr = 0;", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43, 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ] ]
11,653
void ff_put_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_16w_msa(src - (stride * 2), stride, dst, stride, 16); }
false
FFmpeg
662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a
void ff_put_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_16w_msa(src - (stride * 2), stride, dst, stride, 16); }
{ "code": [], "line_no": [] }
void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1, ptrdiff_t VAR_2) { avc_luma_vt_16w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 16); }
[ "void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{", "avc_luma_vt_16w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 16);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
11,654
int img_convert(AVPicture *dst, int dst_pix_fmt, AVPicture *src, int src_pix_fmt, int src_width, int src_height) { static int inited; int i, ret, dst_width, dst_height, int_pix_fmt; PixFmtInfo *src_pix, *dst_pix; ConvertEntry *ce; AVPicture tmp1, *tmp = &tmp1; if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB || dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB) return -1; if (src_width <= 0 || src_height <= 0) return 0; if (!inited) { inited = 1; img_convert_init(); } dst_width = src_width; dst_height = src_height; dst_pix = &pix_fmt_info[dst_pix_fmt]; src_pix = &pix_fmt_info[src_pix_fmt]; if (src_pix_fmt == dst_pix_fmt) { /* XXX: incorrect */ /* same format: just copy */ for(i = 0; i < dst_pix->nb_components; i++) { int w, h; w = dst_width; h = dst_height; if (is_yuv_planar(dst_pix) && (i == 1 || i == 2)) { w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; } img_copy(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], w, h); } return 0; } ce = &convert_table[src_pix_fmt][dst_pix_fmt]; if (ce->convert) { /* specific convertion routine */ ce->convert(dst, src, dst_width, dst_height); return 0; } /* gray to YUV */ if (is_yuv_planar(dst_pix) && src_pix_fmt == PIX_FMT_GRAY8) { int w, h, y; uint8_t *d; if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_jpeg_to_ccir); } /* fill U and V with 128 */ w = dst_width; h = dst_height; w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; for(i = 1; i <= 2; i++) { d = dst->data[i]; for(y = 0; y< h; y++) { memset(d, 128, w); d += dst->linesize[i]; } } return 0; } /* YUV to gray */ if (is_yuv_planar(src_pix) && dst_pix_fmt == PIX_FMT_GRAY8) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_ccir_to_jpeg); } return 0; } /* YUV to YUV planar */ if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { int x_shift, y_shift, w, h; void (*resize_func)(uint8_t *dst, int dst_wrap, uint8_t *src, int src_wrap, int width, int height); /* compute chroma size of the smallest dimensions */ w = dst_width; h = dst_height; if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift) w >>= dst_pix->x_chroma_shift; else w >>= src_pix->x_chroma_shift; if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift) h >>= dst_pix->y_chroma_shift; else h >>= src_pix->y_chroma_shift; x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); if (x_shift == 0 && y_shift == 0) { resize_func = img_copy; } else if (x_shift == 0 && y_shift == 1) { resize_func = shrink2; } else if (x_shift == 1 && y_shift == 1) { resize_func = shrink22; } else if (x_shift == -1 && y_shift == -1) { resize_func = grow22; } else if (x_shift == -1 && y_shift == 1) { resize_func = conv411; } else { /* currently not handled */ return -1; } img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); for(i = 1;i <= 2; i++) resize_func(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); /* if yuv color space conversion is needed, we do it here on the destination image */ if (dst_pix->color_type != src_pix->color_type) { const uint8_t *y_table, *c_table; if (dst_pix->color_type == FF_COLOR_YUV) { y_table = y_jpeg_to_ccir; c_table = c_jpeg_to_ccir; } else { y_table = y_ccir_to_jpeg; c_table = c_ccir_to_jpeg; } img_apply_table(dst->data[0], dst->linesize[0], dst->data[0], dst->linesize[0], dst_width, dst_height, y_table); for(i = 1;i <= 2; i++) img_apply_table(dst->data[i], dst->linesize[i], dst->data[i], dst->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift, c_table); } return 0; } /* try to use an intermediate format */ if (src_pix_fmt == PIX_FMT_YUV422 || dst_pix_fmt == PIX_FMT_YUV422) { /* specific case: convert to YUV422P first */ int_pix_fmt = PIX_FMT_YUV422P; } else if ((src_pix->color_type == FF_COLOR_GRAY && src_pix_fmt != PIX_FMT_GRAY8) || (dst_pix->color_type == FF_COLOR_GRAY && dst_pix_fmt != PIX_FMT_GRAY8)) { /* gray8 is the normalized format */ int_pix_fmt = PIX_FMT_GRAY8; } else if ((is_yuv_planar(src_pix) && src_pix_fmt != PIX_FMT_YUV444P && src_pix_fmt != PIX_FMT_YUVJ444P)) { /* yuv444 is the normalized format */ if (src_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else if ((is_yuv_planar(dst_pix) && dst_pix_fmt != PIX_FMT_YUV444P && dst_pix_fmt != PIX_FMT_YUVJ444P)) { /* yuv444 is the normalized format */ if (dst_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else { /* the two formats are rgb or gray8 or yuv[j]444p */ if (src_pix->is_alpha && dst_pix->is_alpha) int_pix_fmt = PIX_FMT_RGBA32; else int_pix_fmt = PIX_FMT_RGB24; } if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0) return -1; ret = -1; if (img_convert(tmp, int_pix_fmt, src, src_pix_fmt, src_width, src_height) < 0) goto fail1; if (img_convert(dst, dst_pix_fmt, tmp, int_pix_fmt, dst_width, dst_height) < 0) goto fail1; ret = 0; fail1: avpicture_free(tmp); return ret; }
false
FFmpeg
7e7e59409294af9caa63808e56c5cc824c98b4fc
int img_convert(AVPicture *dst, int dst_pix_fmt, AVPicture *src, int src_pix_fmt, int src_width, int src_height) { static int inited; int i, ret, dst_width, dst_height, int_pix_fmt; PixFmtInfo *src_pix, *dst_pix; ConvertEntry *ce; AVPicture tmp1, *tmp = &tmp1; if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB || dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB) return -1; if (src_width <= 0 || src_height <= 0) return 0; if (!inited) { inited = 1; img_convert_init(); } dst_width = src_width; dst_height = src_height; dst_pix = &pix_fmt_info[dst_pix_fmt]; src_pix = &pix_fmt_info[src_pix_fmt]; if (src_pix_fmt == dst_pix_fmt) { for(i = 0; i < dst_pix->nb_components; i++) { int w, h; w = dst_width; h = dst_height; if (is_yuv_planar(dst_pix) && (i == 1 || i == 2)) { w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; } img_copy(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], w, h); } return 0; } ce = &convert_table[src_pix_fmt][dst_pix_fmt]; if (ce->convert) { ce->convert(dst, src, dst_width, dst_height); return 0; } if (is_yuv_planar(dst_pix) && src_pix_fmt == PIX_FMT_GRAY8) { int w, h, y; uint8_t *d; if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_jpeg_to_ccir); } w = dst_width; h = dst_height; w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; for(i = 1; i <= 2; i++) { d = dst->data[i]; for(y = 0; y< h; y++) { memset(d, 128, w); d += dst->linesize[i]; } } return 0; } if (is_yuv_planar(src_pix) && dst_pix_fmt == PIX_FMT_GRAY8) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_ccir_to_jpeg); } return 0; } if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { int x_shift, y_shift, w, h; void (*resize_func)(uint8_t *dst, int dst_wrap, uint8_t *src, int src_wrap, int width, int height); w = dst_width; h = dst_height; if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift) w >>= dst_pix->x_chroma_shift; else w >>= src_pix->x_chroma_shift; if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift) h >>= dst_pix->y_chroma_shift; else h >>= src_pix->y_chroma_shift; x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); if (x_shift == 0 && y_shift == 0) { resize_func = img_copy; } else if (x_shift == 0 && y_shift == 1) { resize_func = shrink2; } else if (x_shift == 1 && y_shift == 1) { resize_func = shrink22; } else if (x_shift == -1 && y_shift == -1) { resize_func = grow22; } else if (x_shift == -1 && y_shift == 1) { resize_func = conv411; } else { return -1; } img_copy(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); for(i = 1;i <= 2; i++) resize_func(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); if (dst_pix->color_type != src_pix->color_type) { const uint8_t *y_table, *c_table; if (dst_pix->color_type == FF_COLOR_YUV) { y_table = y_jpeg_to_ccir; c_table = c_jpeg_to_ccir; } else { y_table = y_ccir_to_jpeg; c_table = c_ccir_to_jpeg; } img_apply_table(dst->data[0], dst->linesize[0], dst->data[0], dst->linesize[0], dst_width, dst_height, y_table); for(i = 1;i <= 2; i++) img_apply_table(dst->data[i], dst->linesize[i], dst->data[i], dst->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift, c_table); } return 0; } if (src_pix_fmt == PIX_FMT_YUV422 || dst_pix_fmt == PIX_FMT_YUV422) { int_pix_fmt = PIX_FMT_YUV422P; } else if ((src_pix->color_type == FF_COLOR_GRAY && src_pix_fmt != PIX_FMT_GRAY8) || (dst_pix->color_type == FF_COLOR_GRAY && dst_pix_fmt != PIX_FMT_GRAY8)) { int_pix_fmt = PIX_FMT_GRAY8; } else if ((is_yuv_planar(src_pix) && src_pix_fmt != PIX_FMT_YUV444P && src_pix_fmt != PIX_FMT_YUVJ444P)) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else if ((is_yuv_planar(dst_pix) && dst_pix_fmt != PIX_FMT_YUV444P && dst_pix_fmt != PIX_FMT_YUVJ444P)) { if (dst_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else { if (src_pix->is_alpha && dst_pix->is_alpha) int_pix_fmt = PIX_FMT_RGBA32; else int_pix_fmt = PIX_FMT_RGB24; } if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0) return -1; ret = -1; if (img_convert(tmp, int_pix_fmt, src, src_pix_fmt, src_width, src_height) < 0) goto fail1; if (img_convert(dst, dst_pix_fmt, tmp, int_pix_fmt, dst_width, dst_height) < 0) goto fail1; ret = 0; fail1: avpicture_free(tmp); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(AVPicture *VAR_18, int VAR_1, AVPicture *VAR_19, int VAR_3, int VAR_4, int VAR_5) { static int VAR_6; int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; PixFmtInfo *src_pix, *dst_pix; ConvertEntry *ce; AVPicture tmp1, *tmp = &tmp1; if (VAR_3 < 0 || VAR_3 >= PIX_FMT_NB || VAR_1 < 0 || VAR_1 >= PIX_FMT_NB) return -1; if (VAR_4 <= 0 || VAR_5 <= 0) return 0; if (!VAR_6) { VAR_6 = 1; img_convert_init(); } VAR_9 = VAR_4; VAR_10 = VAR_5; dst_pix = &pix_fmt_info[VAR_1]; src_pix = &pix_fmt_info[VAR_3]; if (VAR_3 == VAR_1) { for(VAR_7 = 0; VAR_7 < dst_pix->nb_components; VAR_7++) { int VAR_17, VAR_17; VAR_17 = VAR_9; VAR_17 = VAR_10; if (is_yuv_planar(dst_pix) && (VAR_7 == 1 || VAR_7 == 2)) { VAR_17 >>= dst_pix->x_chroma_shift; VAR_17 >>= dst_pix->y_chroma_shift; } img_copy(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7], VAR_19->data[VAR_7], VAR_19->linesize[VAR_7], VAR_17, VAR_17); } return 0; } ce = &convert_table[VAR_3][VAR_1]; if (ce->convert) { ce->convert(VAR_18, VAR_19, VAR_9, VAR_10); return 0; } if (is_yuv_planar(dst_pix) && VAR_3 == PIX_FMT_GRAY8) { int VAR_17, VAR_17, VAR_14; uint8_t *d; if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(VAR_18->data[0], VAR_18->linesize[0], VAR_19->data[0], VAR_19->linesize[0], VAR_9, VAR_10); } else { img_apply_table(VAR_18->data[0], VAR_18->linesize[0], VAR_19->data[0], VAR_19->linesize[0], VAR_9, VAR_10, y_jpeg_to_ccir); } VAR_17 = VAR_9; VAR_17 = VAR_10; VAR_17 >>= dst_pix->x_chroma_shift; VAR_17 >>= dst_pix->y_chroma_shift; for(VAR_7 = 1; VAR_7 <= 2; VAR_7++) { d = VAR_18->data[VAR_7]; for(VAR_14 = 0; VAR_14< VAR_17; VAR_14++) { memset(d, 128, VAR_17); d += VAR_18->linesize[VAR_7]; } } return 0; } if (is_yuv_planar(src_pix) && VAR_1 == PIX_FMT_GRAY8) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) { img_copy(VAR_18->data[0], VAR_18->linesize[0], VAR_19->data[0], VAR_19->linesize[0], VAR_9, VAR_10); } else { img_apply_table(VAR_18->data[0], VAR_18->linesize[0], VAR_19->data[0], VAR_19->linesize[0], VAR_9, VAR_10, y_ccir_to_jpeg); } return 0; } if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { int VAR_15, VAR_16, VAR_17, VAR_17; void (*VAR_17)(uint8_t *VAR_18, int VAR_18, uint8_t *VAR_19, int VAR_19, int VAR_20, int VAR_21); VAR_17 = VAR_9; VAR_17 = VAR_10; if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift) VAR_17 >>= dst_pix->x_chroma_shift; else VAR_17 >>= src_pix->x_chroma_shift; if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift) VAR_17 >>= dst_pix->y_chroma_shift; else VAR_17 >>= src_pix->y_chroma_shift; VAR_15 = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); VAR_16 = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); if (VAR_15 == 0 && VAR_16 == 0) { VAR_17 = img_copy; } else if (VAR_15 == 0 && VAR_16 == 1) { VAR_17 = shrink2; } else if (VAR_15 == 1 && VAR_16 == 1) { VAR_17 = shrink22; } else if (VAR_15 == -1 && VAR_16 == -1) { VAR_17 = grow22; } else if (VAR_15 == -1 && VAR_16 == 1) { VAR_17 = conv411; } else { return -1; } img_copy(VAR_18->data[0], VAR_18->linesize[0], VAR_19->data[0], VAR_19->linesize[0], VAR_9, VAR_10); for(VAR_7 = 1;VAR_7 <= 2; VAR_7++) VAR_17(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7], VAR_19->data[VAR_7], VAR_19->linesize[VAR_7], VAR_9>>dst_pix->x_chroma_shift, VAR_10>>dst_pix->y_chroma_shift); if (dst_pix->color_type != src_pix->color_type) { const uint8_t *VAR_22, *c_table; if (dst_pix->color_type == FF_COLOR_YUV) { VAR_22 = y_jpeg_to_ccir; c_table = c_jpeg_to_ccir; } else { VAR_22 = y_ccir_to_jpeg; c_table = c_ccir_to_jpeg; } img_apply_table(VAR_18->data[0], VAR_18->linesize[0], VAR_18->data[0], VAR_18->linesize[0], VAR_9, VAR_10, VAR_22); for(VAR_7 = 1;VAR_7 <= 2; VAR_7++) img_apply_table(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7], VAR_18->data[VAR_7], VAR_18->linesize[VAR_7], VAR_9>>dst_pix->x_chroma_shift, VAR_10>>dst_pix->y_chroma_shift, c_table); } return 0; } if (VAR_3 == PIX_FMT_YUV422 || VAR_1 == PIX_FMT_YUV422) { VAR_11 = PIX_FMT_YUV422P; } else if ((src_pix->color_type == FF_COLOR_GRAY && VAR_3 != PIX_FMT_GRAY8) || (dst_pix->color_type == FF_COLOR_GRAY && VAR_1 != PIX_FMT_GRAY8)) { VAR_11 = PIX_FMT_GRAY8; } else if ((is_yuv_planar(src_pix) && VAR_3 != PIX_FMT_YUV444P && VAR_3 != PIX_FMT_YUVJ444P)) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) VAR_11 = PIX_FMT_YUVJ444P; else VAR_11 = PIX_FMT_YUV444P; } else if ((is_yuv_planar(dst_pix) && VAR_1 != PIX_FMT_YUV444P && VAR_1 != PIX_FMT_YUVJ444P)) { if (dst_pix->color_type == FF_COLOR_YUV_JPEG) VAR_11 = PIX_FMT_YUVJ444P; else VAR_11 = PIX_FMT_YUV444P; } else { if (src_pix->is_alpha && dst_pix->is_alpha) VAR_11 = PIX_FMT_RGBA32; else VAR_11 = PIX_FMT_RGB24; } if (avpicture_alloc(tmp, VAR_11, VAR_9, VAR_10) < 0) return -1; VAR_8 = -1; if (FUNC_0(tmp, VAR_11, VAR_19, VAR_3, VAR_4, VAR_5) < 0) goto fail1; if (FUNC_0(VAR_18, VAR_1, tmp, VAR_11, VAR_9, VAR_10) < 0) goto fail1; VAR_8 = 0; fail1: avpicture_free(tmp); return VAR_8; }
[ "int FUNC_0(AVPicture *VAR_18, int VAR_1,\nAVPicture *VAR_19, int VAR_3,\nint VAR_4, int VAR_5)\n{", "static int VAR_6;", "int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;", "PixFmtInfo *src_pix, *dst_pix;", "ConvertEntry *ce;", "AVPicture tmp1, *tmp = &tmp1;", "if (VAR_3 < 0 || VAR_3 >= PIX_FMT_NB ||\nVAR_1 < 0 || VAR_1 >= PIX_FMT_NB)\nreturn -1;", "if (VAR_4 <= 0 || VAR_5 <= 0)\nreturn 0;", "if (!VAR_6) {", "VAR_6 = 1;", "img_convert_init();", "}", "VAR_9 = VAR_4;", "VAR_10 = VAR_5;", "dst_pix = &pix_fmt_info[VAR_1];", "src_pix = &pix_fmt_info[VAR_3];", "if (VAR_3 == VAR_1) {", "for(VAR_7 = 0; VAR_7 < dst_pix->nb_components; VAR_7++) {", "int VAR_17, VAR_17;", "VAR_17 = VAR_9;", "VAR_17 = VAR_10;", "if (is_yuv_planar(dst_pix) && (VAR_7 == 1 || VAR_7 == 2)) {", "VAR_17 >>= dst_pix->x_chroma_shift;", "VAR_17 >>= dst_pix->y_chroma_shift;", "}", "img_copy(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7],\nVAR_19->data[VAR_7], VAR_19->linesize[VAR_7],\nVAR_17, VAR_17);", "}", "return 0;", "}", "ce = &convert_table[VAR_3][VAR_1];", "if (ce->convert) {", "ce->convert(VAR_18, VAR_19, VAR_9, VAR_10);", "return 0;", "}", "if (is_yuv_planar(dst_pix) &&\nVAR_3 == PIX_FMT_GRAY8) {", "int VAR_17, VAR_17, VAR_14;", "uint8_t *d;", "if (dst_pix->color_type == FF_COLOR_YUV_JPEG) {", "img_copy(VAR_18->data[0], VAR_18->linesize[0],\nVAR_19->data[0], VAR_19->linesize[0],\nVAR_9, VAR_10);", "} else {", "img_apply_table(VAR_18->data[0], VAR_18->linesize[0],\nVAR_19->data[0], VAR_19->linesize[0],\nVAR_9, VAR_10,\ny_jpeg_to_ccir);", "}", "VAR_17 = VAR_9;", "VAR_17 = VAR_10;", "VAR_17 >>= dst_pix->x_chroma_shift;", "VAR_17 >>= dst_pix->y_chroma_shift;", "for(VAR_7 = 1; VAR_7 <= 2; VAR_7++) {", "d = VAR_18->data[VAR_7];", "for(VAR_14 = 0; VAR_14< VAR_17; VAR_14++) {", "memset(d, 128, VAR_17);", "d += VAR_18->linesize[VAR_7];", "}", "}", "return 0;", "}", "if (is_yuv_planar(src_pix) &&\nVAR_1 == PIX_FMT_GRAY8) {", "if (src_pix->color_type == FF_COLOR_YUV_JPEG) {", "img_copy(VAR_18->data[0], VAR_18->linesize[0],\nVAR_19->data[0], VAR_19->linesize[0],\nVAR_9, VAR_10);", "} else {", "img_apply_table(VAR_18->data[0], VAR_18->linesize[0],\nVAR_19->data[0], VAR_19->linesize[0],\nVAR_9, VAR_10,\ny_ccir_to_jpeg);", "}", "return 0;", "}", "if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) {", "int VAR_15, VAR_16, VAR_17, VAR_17;", "void (*VAR_17)(uint8_t *VAR_18, int VAR_18,\nuint8_t *VAR_19, int VAR_19,\nint VAR_20, int VAR_21);", "VAR_17 = VAR_9;", "VAR_17 = VAR_10;", "if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift)\nVAR_17 >>= dst_pix->x_chroma_shift;", "else\nVAR_17 >>= src_pix->x_chroma_shift;", "if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift)\nVAR_17 >>= dst_pix->y_chroma_shift;", "else\nVAR_17 >>= src_pix->y_chroma_shift;", "VAR_15 = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift);", "VAR_16 = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift);", "if (VAR_15 == 0 && VAR_16 == 0) {", "VAR_17 = img_copy;", "} else if (VAR_15 == 0 && VAR_16 == 1) {", "VAR_17 = shrink2;", "} else if (VAR_15 == 1 && VAR_16 == 1) {", "VAR_17 = shrink22;", "} else if (VAR_15 == -1 && VAR_16 == -1) {", "VAR_17 = grow22;", "} else if (VAR_15 == -1 && VAR_16 == 1) {", "VAR_17 = conv411;", "} else {", "return -1;", "}", "img_copy(VAR_18->data[0], VAR_18->linesize[0],\nVAR_19->data[0], VAR_19->linesize[0],\nVAR_9, VAR_10);", "for(VAR_7 = 1;VAR_7 <= 2; VAR_7++)", "VAR_17(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7],\nVAR_19->data[VAR_7], VAR_19->linesize[VAR_7],\nVAR_9>>dst_pix->x_chroma_shift, VAR_10>>dst_pix->y_chroma_shift);", "if (dst_pix->color_type != src_pix->color_type) {", "const uint8_t *VAR_22, *c_table;", "if (dst_pix->color_type == FF_COLOR_YUV) {", "VAR_22 = y_jpeg_to_ccir;", "c_table = c_jpeg_to_ccir;", "} else {", "VAR_22 = y_ccir_to_jpeg;", "c_table = c_ccir_to_jpeg;", "}", "img_apply_table(VAR_18->data[0], VAR_18->linesize[0],\nVAR_18->data[0], VAR_18->linesize[0],\nVAR_9, VAR_10,\nVAR_22);", "for(VAR_7 = 1;VAR_7 <= 2; VAR_7++)", "img_apply_table(VAR_18->data[VAR_7], VAR_18->linesize[VAR_7],\nVAR_18->data[VAR_7], VAR_18->linesize[VAR_7],\nVAR_9>>dst_pix->x_chroma_shift,\nVAR_10>>dst_pix->y_chroma_shift,\nc_table);", "}", "return 0;", "}", "if (VAR_3 == PIX_FMT_YUV422 ||\nVAR_1 == PIX_FMT_YUV422) {", "VAR_11 = PIX_FMT_YUV422P;", "} else if ((src_pix->color_type == FF_COLOR_GRAY &&", "VAR_3 != PIX_FMT_GRAY8) ||\n(dst_pix->color_type == FF_COLOR_GRAY &&\nVAR_1 != PIX_FMT_GRAY8)) {", "VAR_11 = PIX_FMT_GRAY8;", "} else if ((is_yuv_planar(src_pix) &&", "VAR_3 != PIX_FMT_YUV444P &&\nVAR_3 != PIX_FMT_YUVJ444P)) {", "if (src_pix->color_type == FF_COLOR_YUV_JPEG)\nVAR_11 = PIX_FMT_YUVJ444P;", "else\nVAR_11 = PIX_FMT_YUV444P;", "} else if ((is_yuv_planar(dst_pix) &&", "VAR_1 != PIX_FMT_YUV444P &&\nVAR_1 != PIX_FMT_YUVJ444P)) {", "if (dst_pix->color_type == FF_COLOR_YUV_JPEG)\nVAR_11 = PIX_FMT_YUVJ444P;", "else\nVAR_11 = PIX_FMT_YUV444P;", "} else {", "if (src_pix->is_alpha && dst_pix->is_alpha)\nVAR_11 = PIX_FMT_RGBA32;", "else\nVAR_11 = PIX_FMT_RGB24;", "}", "if (avpicture_alloc(tmp, VAR_11, VAR_9, VAR_10) < 0)\nreturn -1;", "VAR_8 = -1;", "if (FUNC_0(tmp, VAR_11,\nVAR_19, VAR_3, VAR_4, VAR_5) < 0)\ngoto fail1;", "if (FUNC_0(VAR_18, VAR_1,\ntmp, VAR_11, VAR_9, VAR_10) < 0)\ngoto fail1;", "VAR_8 = 0;", "fail1:\navpicture_free(tmp);", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23, 25 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117, 119, 121 ], [ 123 ], [ 125, 127, 129, 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 167, 169 ], [ 171 ], [ 173, 175, 177 ], [ 179 ], [ 181, 183, 185, 187 ], [ 189 ], [ 191 ], [ 193 ], [ 199 ], [ 201 ], [ 203, 205, 207 ], [ 213 ], [ 215 ], [ 217, 219 ], [ 221, 223 ], [ 225, 227 ], [ 229, 231 ], [ 235 ], [ 237 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 265 ], [ 267 ], [ 271, 273, 275 ], [ 279 ], [ 281, 283, 285 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309, 311, 313, 315 ], [ 319 ], [ 321, 323, 325, 327, 329 ], [ 331 ], [ 333 ], [ 335 ], [ 341, 343 ], [ 347 ], [ 349 ], [ 351, 353, 355 ], [ 359 ], [ 361 ], [ 363, 365 ], [ 369, 371 ], [ 373, 375 ], [ 377 ], [ 379, 381 ], [ 385, 387 ], [ 389, 391 ], [ 393 ], [ 397, 399 ], [ 401, 403 ], [ 405 ], [ 407, 409 ], [ 411 ], [ 413, 415, 417 ], [ 419, 421, 423 ], [ 425 ], [ 427, 429 ], [ 431 ], [ 433 ] ]
11,655
static void render_fragments(Vp3DecodeContext *s, int first_fragment, int fragment_width, int fragment_height, int plane /* 0 = Y, 1 = U, 2 = V */) { int x, y; int m, n; int i = first_fragment; int j; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *output_plane; unsigned char *last_plane; unsigned char *golden_plane; int stride; debug_vp3(" vp3: rendering final fragments for %s\n", (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane"); /* set up plane-specific parameters */ if (plane == 0) { dequantizer = s->intra_y_dequant; output_plane = s->current_frame.data[0]; last_plane = s->current_frame.data[0]; golden_plane = s->current_frame.data[0]; stride = -s->current_frame.linesize[0]; } else if (plane == 1) { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[1]; last_plane = s->current_frame.data[1]; golden_plane = s->current_frame.data[1]; stride = -s->current_frame.linesize[1]; } else { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[2]; last_plane = s->current_frame.data[2]; golden_plane = s->current_frame.data[2]; stride = -s->current_frame.linesize[2]; } /* for each fragment row... */ for (y = 0; y < fragment_height; y++) { /* for each fragment in a row... */ for (x = 0; x < fragment_width; x++, i++) { /* transform if this block was coded */ if (s->all_fragments[i].coding_method == MODE_INTRA) { /* dequantize the DCT coefficients */ for (j = 0; j < 64; j++) dequant_block[dequant_index[j]] = s->all_fragments[i].coeffs[j] * dequantizer[j]; dequant_block[0] += 1024; debug_idct("fragment %d:\n", i); debug_idct("dequantized block:\n"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %5d", dequant_block[m * 8 + n]); } debug_idct("\n"); } debug_idct("\n"); /* invert DCT and place in final output */ s->dsp.idct_put( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); /* debug_idct("idct block:\n"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %3d", pixels[m * 8 + n]); } debug_idct("\n"); } debug_idct("\n"); */ } else if (s->all_fragments[i].coding_method == MODE_COPY) { /* copy directly from the previous frame */ for (m = 0; m < 8; m++) memcpy( output_plane + s->all_fragments[i].first_pixel + stride * m, last_plane + s->all_fragments[i].first_pixel + stride * m, 8); } else { /* carry out the motion compensation */ } } } emms_c(); }
true
FFmpeg
61873c4a4436f2c516e14d6a00a2b856fa93f818
static void render_fragments(Vp3DecodeContext *s, int first_fragment, int fragment_width, int fragment_height, int plane ) { int x, y; int m, n; int i = first_fragment; int j; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *output_plane; unsigned char *last_plane; unsigned char *golden_plane; int stride; debug_vp3(" vp3: rendering final fragments for %s\n", (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane"); if (plane == 0) { dequantizer = s->intra_y_dequant; output_plane = s->current_frame.data[0]; last_plane = s->current_frame.data[0]; golden_plane = s->current_frame.data[0]; stride = -s->current_frame.linesize[0]; } else if (plane == 1) { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[1]; last_plane = s->current_frame.data[1]; golden_plane = s->current_frame.data[1]; stride = -s->current_frame.linesize[1]; } else { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[2]; last_plane = s->current_frame.data[2]; golden_plane = s->current_frame.data[2]; stride = -s->current_frame.linesize[2]; } for (y = 0; y < fragment_height; y++) { for (x = 0; x < fragment_width; x++, i++) { if (s->all_fragments[i].coding_method == MODE_INTRA) { for (j = 0; j < 64; j++) dequant_block[dequant_index[j]] = s->all_fragments[i].coeffs[j] * dequantizer[j]; dequant_block[0] += 1024; debug_idct("fragment %d:\n", i); debug_idct("dequantized block:\n"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %5d", dequant_block[m * 8 + n]); } debug_idct("\n"); } debug_idct("\n"); s->dsp.idct_put( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); } else if (s->all_fragments[i].coding_method == MODE_COPY) { for (m = 0; m < 8; m++) memcpy( output_plane + s->all_fragments[i].first_pixel + stride * m, last_plane + s->all_fragments[i].first_pixel + stride * m, 8); } else { } } } emms_c(); }
{ "code": [ " last_plane = s->current_frame.data[0];", " golden_plane = s->current_frame.data[0];", " last_plane = s->current_frame.data[1];", " golden_plane = s->current_frame.data[1];", " last_plane = s->current_frame.data[2];", " golden_plane = s->current_frame.data[2];" ], "line_no": [ 49, 51, 61, 63, 73, 75 ] }
static void FUNC_0(Vp3DecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4 ) { int VAR_5, VAR_6; int VAR_7, VAR_8; int VAR_9 = VAR_1; int VAR_10; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *VAR_11; unsigned char *VAR_12; unsigned char *VAR_13; int VAR_14; debug_vp3(" vp3: rendering final fragments for %VAR_0\VAR_8", (VAR_4 == 0) ? "Y VAR_4" : (VAR_4 == 1) ? "U VAR_4" : "V VAR_4"); if (VAR_4 == 0) { dequantizer = VAR_0->intra_y_dequant; VAR_11 = VAR_0->current_frame.data[0]; VAR_12 = VAR_0->current_frame.data[0]; VAR_13 = VAR_0->current_frame.data[0]; VAR_14 = -VAR_0->current_frame.linesize[0]; } else if (VAR_4 == 1) { dequantizer = VAR_0->intra_c_dequant; VAR_11 = VAR_0->current_frame.data[1]; VAR_12 = VAR_0->current_frame.data[1]; VAR_13 = VAR_0->current_frame.data[1]; VAR_14 = -VAR_0->current_frame.linesize[1]; } else { dequantizer = VAR_0->intra_c_dequant; VAR_11 = VAR_0->current_frame.data[2]; VAR_12 = VAR_0->current_frame.data[2]; VAR_13 = VAR_0->current_frame.data[2]; VAR_14 = -VAR_0->current_frame.linesize[2]; } for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) { for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++, VAR_9++) { if (VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA) { for (VAR_10 = 0; VAR_10 < 64; VAR_10++) dequant_block[dequant_index[VAR_10]] = VAR_0->all_fragments[VAR_9].coeffs[VAR_10] * dequantizer[VAR_10]; dequant_block[0] += 1024; debug_idct("fragment %d:\VAR_8", VAR_9); debug_idct("dequantized block:\VAR_8"); for (VAR_7 = 0; VAR_7 < 8; VAR_7++) { for (VAR_8 = 0; VAR_8 < 8; VAR_8++) { debug_idct(" %5d", dequant_block[VAR_7 * 8 + VAR_8]); } debug_idct("\VAR_8"); } debug_idct("\VAR_8"); VAR_0->dsp.idct_put( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_14, dequant_block); } else if (VAR_0->all_fragments[VAR_9].coding_method == MODE_COPY) { for (VAR_7 = 0; VAR_7 < 8; VAR_7++) memcpy( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel + VAR_14 * VAR_7, VAR_12 + VAR_0->all_fragments[VAR_9].first_pixel + VAR_14 * VAR_7, 8); } else { } } } emms_c(); }
[ "static void FUNC_0(Vp3DecodeContext *VAR_0,\nint VAR_1,\nint VAR_2,\nint VAR_3,\nint VAR_4 )\n{", "int VAR_5, VAR_6;", "int VAR_7, VAR_8;", "int VAR_9 = VAR_1;", "int VAR_10;", "int16_t *dequantizer;", "DCTELEM dequant_block[64];", "unsigned char *VAR_11;", "unsigned char *VAR_12;", "unsigned char *VAR_13;", "int VAR_14;", "debug_vp3(\" vp3: rendering final fragments for %VAR_0\\VAR_8\",\n(VAR_4 == 0) ? \"Y VAR_4\" : (VAR_4 == 1) ? \"U VAR_4\" : \"V VAR_4\");", "if (VAR_4 == 0) {", "dequantizer = VAR_0->intra_y_dequant;", "VAR_11 = VAR_0->current_frame.data[0];", "VAR_12 = VAR_0->current_frame.data[0];", "VAR_13 = VAR_0->current_frame.data[0];", "VAR_14 = -VAR_0->current_frame.linesize[0];", "} else if (VAR_4 == 1) {", "dequantizer = VAR_0->intra_c_dequant;", "VAR_11 = VAR_0->current_frame.data[1];", "VAR_12 = VAR_0->current_frame.data[1];", "VAR_13 = VAR_0->current_frame.data[1];", "VAR_14 = -VAR_0->current_frame.linesize[1];", "} else {", "dequantizer = VAR_0->intra_c_dequant;", "VAR_11 = VAR_0->current_frame.data[2];", "VAR_12 = VAR_0->current_frame.data[2];", "VAR_13 = VAR_0->current_frame.data[2];", "VAR_14 = -VAR_0->current_frame.linesize[2];", "}", "for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {", "for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++, VAR_9++) {", "if (VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA) {", "for (VAR_10 = 0; VAR_10 < 64; VAR_10++)", "dequant_block[dequant_index[VAR_10]] =\nVAR_0->all_fragments[VAR_9].coeffs[VAR_10] *\ndequantizer[VAR_10];", "dequant_block[0] += 1024;", "debug_idct(\"fragment %d:\\VAR_8\", VAR_9);", "debug_idct(\"dequantized block:\\VAR_8\");", "for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {", "for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {", "debug_idct(\" %5d\", dequant_block[VAR_7 * 8 + VAR_8]);", "}", "debug_idct(\"\\VAR_8\");", "}", "debug_idct(\"\\VAR_8\");", "VAR_0->dsp.idct_put(\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_14, dequant_block);", "} else if (VAR_0->all_fragments[VAR_9].coding_method == MODE_COPY) {", "for (VAR_7 = 0; VAR_7 < 8; VAR_7++)", "memcpy(\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel + VAR_14 * VAR_7,\nVAR_12 + VAR_0->all_fragments[VAR_9].first_pixel + VAR_14 * VAR_7,\n8);", "} else {", "}", "}", "}", "emms_c();", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 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 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 85 ], [ 91 ], [ 97 ], [ 101 ], [ 103, 105, 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135, 137, 139 ], [ 163 ], [ 169 ], [ 171, 173, 175, 177 ], [ 181 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 201 ] ]
11,656
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags) { BDRVRBDState *s = bs->opaque; char pool[RBD_MAX_POOL_NAME_SIZE]; char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; char conf[RBD_MAX_CONF_SIZE]; char clientname_buf[RBD_MAX_CONF_SIZE]; char *clientname; QemuOpts *opts; Error *local_err = NULL; const char *filename; int r; opts = qemu_opts_create_nofail(&runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); qemu_opts_del(opts); return -EINVAL; } filename = qemu_opt_get(opts, "filename"); qemu_opts_del(opts); if (qemu_rbd_parsename(filename, pool, sizeof(pool), snap_buf, sizeof(snap_buf), s->name, sizeof(s->name), conf, sizeof(conf)) < 0) { return -EINVAL; } clientname = qemu_rbd_parse_clientname(conf, clientname_buf); r = rados_create(&s->cluster, clientname); if (r < 0) { error_report("error initializing"); return r; } s->snap = NULL; if (snap_buf[0] != '\0') { s->snap = g_strdup(snap_buf); } /* * Fallback to more conservative semantics if setting cache * options fails. Ignore errors from setting rbd_cache because the * only possible error is that the option does not exist, and * librbd defaults to no caching. If write through caching cannot * be set up, fall back to no caching. */ if (flags & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(conf, "conf=") == NULL) { /* try default location, but ignore failure */ rados_conf_read_file(s->cluster, NULL); } if (conf[0] != '\0') { r = qemu_rbd_set_conf(s->cluster, conf); if (r < 0) { error_report("error setting config options"); goto failed_shutdown; } } r = rados_connect(s->cluster); if (r < 0) { error_report("error connecting"); goto failed_shutdown; } r = rados_ioctx_create(s->cluster, pool, &s->io_ctx); if (r < 0) { error_report("error opening pool %s", pool); goto failed_shutdown; } r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (r < 0) { error_report("error reading header from %s", s->name); goto failed_open; } bs->read_only = (s->snap != NULL); s->event_reader_pos = 0; r = qemu_pipe(s->fds); if (r < 0) { error_report("error opening eventfd"); goto failed; } fcntl(s->fds[0], F_SETFL, O_NONBLOCK); fcntl(s->fds[1], F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader, NULL, qemu_rbd_aio_flush_cb, s); return 0; failed: rbd_close(s->image); failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); return r; }
true
qemu
c3ca988d2b0ee94dc8d53eff4b1c2de4ac06a270
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags) { BDRVRBDState *s = bs->opaque; char pool[RBD_MAX_POOL_NAME_SIZE]; char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; char conf[RBD_MAX_CONF_SIZE]; char clientname_buf[RBD_MAX_CONF_SIZE]; char *clientname; QemuOpts *opts; Error *local_err = NULL; const char *filename; int r; opts = qemu_opts_create_nofail(&runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); qemu_opts_del(opts); return -EINVAL; } filename = qemu_opt_get(opts, "filename"); qemu_opts_del(opts); if (qemu_rbd_parsename(filename, pool, sizeof(pool), snap_buf, sizeof(snap_buf), s->name, sizeof(s->name), conf, sizeof(conf)) < 0) { return -EINVAL; } clientname = qemu_rbd_parse_clientname(conf, clientname_buf); r = rados_create(&s->cluster, clientname); if (r < 0) { error_report("error initializing"); return r; } s->snap = NULL; if (snap_buf[0] != '\0') { s->snap = g_strdup(snap_buf); } if (flags & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(conf, "conf=") == NULL) { rados_conf_read_file(s->cluster, NULL); } if (conf[0] != '\0') { r = qemu_rbd_set_conf(s->cluster, conf); if (r < 0) { error_report("error setting config options"); goto failed_shutdown; } } r = rados_connect(s->cluster); if (r < 0) { error_report("error connecting"); goto failed_shutdown; } r = rados_ioctx_create(s->cluster, pool, &s->io_ctx); if (r < 0) { error_report("error opening pool %s", pool); goto failed_shutdown; } r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (r < 0) { error_report("error reading header from %s", s->name); goto failed_open; } bs->read_only = (s->snap != NULL); s->event_reader_pos = 0; r = qemu_pipe(s->fds); if (r < 0) { error_report("error opening eventfd"); goto failed; } fcntl(s->fds[0], F_SETFL, O_NONBLOCK); fcntl(s->fds[1], F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader, NULL, qemu_rbd_aio_flush_cb, s); return 0; failed: rbd_close(s->image); failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); return r; }
{ "code": [ " qemu_opts_del(opts);", " return -EINVAL;", " return r;" ], "line_no": [ 47, 39, 73 ] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2) { BDRVRBDState *s = VAR_0->opaque; char VAR_3[RBD_MAX_POOL_NAME_SIZE]; char VAR_4[RBD_MAX_SNAP_NAME_SIZE]; char VAR_5[RBD_MAX_CONF_SIZE]; char VAR_6[RBD_MAX_CONF_SIZE]; char *VAR_7; QemuOpts *opts; Error *local_err = NULL; const char *VAR_8; int VAR_9; opts = qemu_opts_create_nofail(&runtime_opts); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); qemu_opts_del(opts); return -EINVAL; } VAR_8 = qemu_opt_get(opts, "VAR_8"); qemu_opts_del(opts); if (qemu_rbd_parsename(VAR_8, VAR_3, sizeof(VAR_3), VAR_4, sizeof(VAR_4), s->name, sizeof(s->name), VAR_5, sizeof(VAR_5)) < 0) { return -EINVAL; } VAR_7 = qemu_rbd_parse_clientname(VAR_5, VAR_6); VAR_9 = rados_create(&s->cluster, VAR_7); if (VAR_9 < 0) { error_report("error initializing"); return VAR_9; } s->snap = NULL; if (VAR_4[0] != '\0') { s->snap = g_strdup(VAR_4); } if (VAR_2 & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(VAR_5, "VAR_5=") == NULL) { rados_conf_read_file(s->cluster, NULL); } if (VAR_5[0] != '\0') { VAR_9 = qemu_rbd_set_conf(s->cluster, VAR_5); if (VAR_9 < 0) { error_report("error setting config VAR_1"); goto failed_shutdown; } } VAR_9 = rados_connect(s->cluster); if (VAR_9 < 0) { error_report("error connecting"); goto failed_shutdown; } VAR_9 = rados_ioctx_create(s->cluster, VAR_3, &s->io_ctx); if (VAR_9 < 0) { error_report("error opening VAR_3 %s", VAR_3); goto failed_shutdown; } VAR_9 = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (VAR_9 < 0) { error_report("error reading header from %s", s->name); goto failed_open; } VAR_0->read_only = (s->snap != NULL); s->event_reader_pos = 0; VAR_9 = qemu_pipe(s->fds); if (VAR_9 < 0) { error_report("error opening eventfd"); goto failed; } fcntl(s->fds[0], F_SETFL, O_NONBLOCK); fcntl(s->fds[1], F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader, NULL, qemu_rbd_aio_flush_cb, s); return 0; failed: rbd_close(s->image); failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); return VAR_9; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2)\n{", "BDRVRBDState *s = VAR_0->opaque;", "char VAR_3[RBD_MAX_POOL_NAME_SIZE];", "char VAR_4[RBD_MAX_SNAP_NAME_SIZE];", "char VAR_5[RBD_MAX_CONF_SIZE];", "char VAR_6[RBD_MAX_CONF_SIZE];", "char *VAR_7;", "QemuOpts *opts;", "Error *local_err = NULL;", "const char *VAR_8;", "int VAR_9;", "opts = qemu_opts_create_nofail(&runtime_opts);", "qemu_opts_absorb_qdict(opts, VAR_1, &local_err);", "if (error_is_set(&local_err)) {", "qerror_report_err(local_err);", "error_free(local_err);", "qemu_opts_del(opts);", "return -EINVAL;", "}", "VAR_8 = qemu_opt_get(opts, \"VAR_8\");", "qemu_opts_del(opts);", "if (qemu_rbd_parsename(VAR_8, VAR_3, sizeof(VAR_3),\nVAR_4, sizeof(VAR_4),\ns->name, sizeof(s->name),\nVAR_5, sizeof(VAR_5)) < 0) {", "return -EINVAL;", "}", "VAR_7 = qemu_rbd_parse_clientname(VAR_5, VAR_6);", "VAR_9 = rados_create(&s->cluster, VAR_7);", "if (VAR_9 < 0) {", "error_report(\"error initializing\");", "return VAR_9;", "}", "s->snap = NULL;", "if (VAR_4[0] != '\\0') {", "s->snap = g_strdup(VAR_4);", "}", "if (VAR_2 & BDRV_O_NOCACHE) {", "rados_conf_set(s->cluster, \"rbd_cache\", \"false\");", "} else {", "rados_conf_set(s->cluster, \"rbd_cache\", \"true\");", "}", "if (strstr(VAR_5, \"VAR_5=\") == NULL) {", "rados_conf_read_file(s->cluster, NULL);", "}", "if (VAR_5[0] != '\\0') {", "VAR_9 = qemu_rbd_set_conf(s->cluster, VAR_5);", "if (VAR_9 < 0) {", "error_report(\"error setting config VAR_1\");", "goto failed_shutdown;", "}", "}", "VAR_9 = rados_connect(s->cluster);", "if (VAR_9 < 0) {", "error_report(\"error connecting\");", "goto failed_shutdown;", "}", "VAR_9 = rados_ioctx_create(s->cluster, VAR_3, &s->io_ctx);", "if (VAR_9 < 0) {", "error_report(\"error opening VAR_3 %s\", VAR_3);", "goto failed_shutdown;", "}", "VAR_9 = rbd_open(s->io_ctx, s->name, &s->image, s->snap);", "if (VAR_9 < 0) {", "error_report(\"error reading header from %s\", s->name);", "goto failed_open;", "}", "VAR_0->read_only = (s->snap != NULL);", "s->event_reader_pos = 0;", "VAR_9 = qemu_pipe(s->fds);", "if (VAR_9 < 0) {", "error_report(\"error opening eventfd\");", "goto failed;", "}", "fcntl(s->fds[0], F_SETFL, O_NONBLOCK);", "fcntl(s->fds[1], F_SETFL, O_NONBLOCK);", "qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader,\nNULL, qemu_rbd_aio_flush_cb, s);", "return 0;", "failed:\nrbd_close(s->image);", "failed_open:\nrados_ioctx_destroy(s->io_ctx);", "failed_shutdown:\nrados_shutdown(s->cluster);", "g_free(s->snap);", "return VAR_9;", "}" ]
[ 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, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 51, 53, 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 205 ], [ 209, 211 ], [ 213, 215 ], [ 217, 219 ], [ 221 ], [ 223 ], [ 225 ] ]
11,658
static void vnc_client_read(VncState *vs) { ssize_t ret; #ifdef CONFIG_VNC_SASL if (vs->sasl.conn && vs->sasl.runSSF) ret = vnc_client_read_sasl(vs); else #endif /* CONFIG_VNC_SASL */ ret = vnc_client_read_plain(vs); if (!ret) { if (vs->disconnecting) { vnc_disconnect_finish(vs); } return; } while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->disconnecting) { vnc_disconnect_finish(vs); return; } if (!ret) { buffer_advance(&vs->input, len); } else { vs->read_handler_expect = ret; } } }
true
qemu
ea697449884d83b83fefbc9cd87bdde0c94b49d6
static void vnc_client_read(VncState *vs) { ssize_t ret; #ifdef CONFIG_VNC_SASL if (vs->sasl.conn && vs->sasl.runSSF) ret = vnc_client_read_sasl(vs); else #endif ret = vnc_client_read_plain(vs); if (!ret) { if (vs->disconnecting) { vnc_disconnect_finish(vs); } return; } while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->disconnecting) { vnc_disconnect_finish(vs); return; } if (!ret) { buffer_advance(&vs->input, len); } else { vs->read_handler_expect = ret; } } }
{ "code": [ "static void vnc_client_read(VncState *vs)" ], "line_no": [ 1 ] }
static void FUNC_0(VncState *VAR_0) { ssize_t VAR_1; #ifdef CONFIG_VNC_SASL if (VAR_0->sasl.conn && VAR_0->sasl.runSSF) VAR_1 = vnc_client_read_sasl(VAR_0); else #endif VAR_1 = vnc_client_read_plain(VAR_0); if (!VAR_1) { if (VAR_0->disconnecting) { vnc_disconnect_finish(VAR_0); } return; } while (VAR_0->read_handler && VAR_0->input.offset >= VAR_0->read_handler_expect) { size_t len = VAR_0->read_handler_expect; int VAR_1; VAR_1 = VAR_0->read_handler(VAR_0, VAR_0->input.buffer, len); if (VAR_0->disconnecting) { vnc_disconnect_finish(VAR_0); return; } if (!VAR_1) { buffer_advance(&VAR_0->input, len); } else { VAR_0->read_handler_expect = VAR_1; } } }
[ "static void FUNC_0(VncState *VAR_0)\n{", "ssize_t VAR_1;", "#ifdef CONFIG_VNC_SASL\nif (VAR_0->sasl.conn && VAR_0->sasl.runSSF)\nVAR_1 = vnc_client_read_sasl(VAR_0);", "else\n#endif\nVAR_1 = vnc_client_read_plain(VAR_0);", "if (!VAR_1) {", "if (VAR_0->disconnecting) {", "vnc_disconnect_finish(VAR_0);", "}", "return;", "}", "while (VAR_0->read_handler && VAR_0->input.offset >= VAR_0->read_handler_expect) {", "size_t len = VAR_0->read_handler_expect;", "int VAR_1;", "VAR_1 = VAR_0->read_handler(VAR_0, VAR_0->input.buffer, len);", "if (VAR_0->disconnecting) {", "vnc_disconnect_finish(VAR_0);", "return;", "}", "if (!VAR_1) {", "buffer_advance(&VAR_0->input, len);", "} else {", "VAR_0->read_handler_expect = VAR_1;", "}", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11, 13 ], [ 15, 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
11,659
static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; int64_t left; AVStream *st; WAVDemuxContext *wav = s->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && s->streams[0]->codec->codec_tag == 1) { enum AVCodecID codec; ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, &codec); if (ret > AVPROBE_SCORE_EXTENSION) { s->streams[0]->codec->codec_id = codec; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(s, pkt); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = s->streams[0]->cur_dts; video_dts = s->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q); video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q); /*We always return a video frame first to get the pixel format first*/ wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(s->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { ret = AVERROR_EOF; goto smv_out; } size = avio_rl24(s->pb); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) goto smv_out; pkt->pos -= 3; pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; pkt->stream_index = 1; smv_out: avio_seek(s->pb, old_pos, SEEK_SET); if (ret == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return ret; } } st = s->streams[0]; left = wav->data_end - avio_tell(s->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(s->pb, ff_w64_guid_data) - 24; else left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(s->pb) + left; } size = MAX_SIZE; if (st->codec->block_align > 1) { if (size < st->codec->block_align) size = st->codec->block_align; size = (size / st->codec->block_align) * st->codec->block_align; } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; return ret; }
true
FFmpeg
2a91038e13a00897fde89ad65a36012985687793
static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; int64_t left; AVStream *st; WAVDemuxContext *wav = s->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && s->streams[0]->codec->codec_tag == 1) { enum AVCodecID codec; ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, &codec); if (ret > AVPROBE_SCORE_EXTENSION) { s->streams[0]->codec->codec_id = codec; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(s, pkt); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = s->streams[0]->cur_dts; video_dts = s->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q); video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q); wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(s->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { ret = AVERROR_EOF; goto smv_out; } size = avio_rl24(s->pb); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) goto smv_out; pkt->pos -= 3; pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; pkt->stream_index = 1; smv_out: avio_seek(s->pb, old_pos, SEEK_SET); if (ret == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return ret; } } st = s->streams[0]; left = wav->data_end - avio_tell(s->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(s->pb, ff_w64_guid_data) - 24; else left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(s->pb) + left; } size = MAX_SIZE; if (st->codec->block_align > 1) { if (size < st->codec->block_align) size = st->codec->block_align; size = (size / st->codec->block_align) * st->codec->block_align; } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; return ret; }
{ "code": [ " audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q);", " video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q);", " wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0;" ], "line_no": [ 59, 61, 65 ] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { int VAR_2, VAR_3; int64_t left; AVStream *st; WAVDemuxContext *wav = VAR_0->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && VAR_0->streams[0]->VAR_4->codec_tag == 1) { enum AVCodecID VAR_4; VAR_2 = ff_spdif_probe(VAR_0->pb->buffer, VAR_0->pb->buf_end - VAR_0->pb->buffer, &VAR_4); if (VAR_2 > AVPROBE_SCORE_EXTENSION) { VAR_0->streams[0]->VAR_4->codec_id = VAR_4; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(VAR_0, VAR_1); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = VAR_0->streams[0]->cur_dts; video_dts = VAR_0->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { audio_dts = av_rescale_q(audio_dts, VAR_0->streams[0]->time_base, AV_TIME_BASE_Q); video_dts = av_rescale_q(video_dts, VAR_0->streams[1]->time_base, AV_TIME_BASE_Q); wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(VAR_0->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(VAR_0->pb, new_pos, SEEK_SET) < 0) { VAR_2 = AVERROR_EOF; goto smv_out; } VAR_3 = avio_rl24(VAR_0->pb); VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3); if (VAR_2 < 0) goto smv_out; VAR_1->pos -= 3; VAR_1->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; VAR_1->stream_index = 1; smv_out: avio_seek(VAR_0->pb, old_pos, SEEK_SET); if (VAR_2 == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return VAR_2; } } st = VAR_0->streams[0]; left = wav->data_end - avio_tell(VAR_0->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(VAR_0->pb, ff_w64_guid_data) - 24; else left = find_tag(VAR_0->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(VAR_0->pb) + left; } VAR_3 = MAX_SIZE; if (st->VAR_4->block_align > 1) { if (VAR_3 < st->VAR_4->block_align) VAR_3 = st->VAR_4->block_align; VAR_3 = (VAR_3 / st->VAR_4->block_align) * st->VAR_4->block_align; } VAR_3 = FFMIN(VAR_3, left); VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3); if (VAR_2 < 0) return VAR_2; VAR_1->stream_index = 0; return VAR_2; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "int VAR_2, VAR_3;", "int64_t left;", "AVStream *st;", "WAVDemuxContext *wav = VAR_0->priv_data;", "if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 &&\nVAR_0->streams[0]->VAR_4->codec_tag == 1) {", "enum AVCodecID VAR_4;", "VAR_2 = ff_spdif_probe(VAR_0->pb->buffer, VAR_0->pb->buf_end - VAR_0->pb->buffer,\n&VAR_4);", "if (VAR_2 > AVPROBE_SCORE_EXTENSION) {", "VAR_0->streams[0]->VAR_4->codec_id = VAR_4;", "wav->spdif = 1;", "} else {", "wav->spdif = -1;", "}", "}", "if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)\nreturn ff_spdif_read_packet(VAR_0, VAR_1);", "if (wav->smv_data_ofs > 0) {", "int64_t audio_dts, video_dts;", "smv_retry:\naudio_dts = VAR_0->streams[0]->cur_dts;", "video_dts = VAR_0->streams[1]->cur_dts;", "if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) {", "audio_dts = av_rescale_q(audio_dts, VAR_0->streams[0]->time_base, AV_TIME_BASE_Q);", "video_dts = av_rescale_q(video_dts, VAR_0->streams[1]->time_base, AV_TIME_BASE_Q);", "wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0;", "wav->smv_given_first = 1;", "}", "wav->smv_last_stream = !wav->smv_last_stream;", "wav->smv_last_stream |= wav->audio_eof;", "wav->smv_last_stream &= !wav->smv_eof;", "if (wav->smv_last_stream) {", "uint64_t old_pos = avio_tell(VAR_0->pb);", "uint64_t new_pos = wav->smv_data_ofs +\nwav->smv_block * wav->smv_block_size;", "if (avio_seek(VAR_0->pb, new_pos, SEEK_SET) < 0) {", "VAR_2 = AVERROR_EOF;", "goto smv_out;", "}", "VAR_3 = avio_rl24(VAR_0->pb);", "VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);", "if (VAR_2 < 0)\ngoto smv_out;", "VAR_1->pos -= 3;", "VAR_1->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt;", "wav->smv_cur_pt++;", "if (wav->smv_frames_per_jpeg > 0)\nwav->smv_cur_pt %= wav->smv_frames_per_jpeg;", "if (!wav->smv_cur_pt)\nwav->smv_block++;", "VAR_1->stream_index = 1;", "smv_out:\navio_seek(VAR_0->pb, old_pos, SEEK_SET);", "if (VAR_2 == AVERROR_EOF) {", "wav->smv_eof = 1;", "goto smv_retry;", "}", "return VAR_2;", "}", "}", "st = VAR_0->streams[0];", "left = wav->data_end - avio_tell(VAR_0->pb);", "if (wav->ignore_length)\nleft = INT_MAX;", "if (left <= 0) {", "if (CONFIG_W64_DEMUXER && wav->w64)\nleft = find_guid(VAR_0->pb, ff_w64_guid_data) - 24;", "else\nleft = find_tag(VAR_0->pb, MKTAG('d', 'a', 't', 'a'));", "if (left < 0) {", "wav->audio_eof = 1;", "if (wav->smv_data_ofs > 0 && !wav->smv_eof)\ngoto smv_retry;", "return AVERROR_EOF;", "}", "wav->data_end = avio_tell(VAR_0->pb) + left;", "}", "VAR_3 = MAX_SIZE;", "if (st->VAR_4->block_align > 1) {", "if (VAR_3 < st->VAR_4->block_align)\nVAR_3 = st->VAR_4->block_align;", "VAR_3 = (VAR_3 / st->VAR_4->block_align) * st->VAR_4->block_align;", "}", "VAR_3 = FFMIN(VAR_3, left);", "VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);", "if (VAR_2 < 0)\nreturn VAR_2;", "VAR_1->stream_index = 0;", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 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 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151, 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193, 195 ], [ 197 ], [ 201 ], [ 203 ] ]
11,660
static uint32_t hpet_time_after(uint64_t a, uint64_t b) { return ((int32_t)(b) - (int32_t)(a) < 0); }
true
qemu
d17008bc2914d62fd0af6a8f313604ae9f9a102c
static uint32_t hpet_time_after(uint64_t a, uint64_t b) { return ((int32_t)(b) - (int32_t)(a) < 0); }
{ "code": [ " return ((int32_t)(b) - (int32_t)(a) < 0);" ], "line_no": [ 5 ] }
static uint32_t FUNC_0(uint64_t a, uint64_t b) { return ((int32_t)(b) - (int32_t)(a) < 0); }
[ "static uint32_t FUNC_0(uint64_t a, uint64_t b)\n{", "return ((int32_t)(b) - (int32_t)(a) < 0);", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,661
static int xenfb_map_fb(struct XenFB *xenfb) { struct xenfb_page *page = xenfb->c.page; char *protocol = xenfb->c.xendev.protocol; int n_fbdirs; xen_pfn_t *pgmfns = NULL; xen_pfn_t *fbmfns = NULL; void *map, *pd; int mode, ret = -1; /* default to native */ pd = page->pd; mode = sizeof(unsigned long) * 8; if (!protocol) { /* * Undefined protocol, some guesswork needed. * * Old frontends which don't set the protocol use * one page directory only, thus pd[1] must be zero. * pd[1] of the 32bit struct layout and the lower * 32 bits of pd[0] of the 64bit struct layout have * the same location, so we can check that ... */ uint32_t *ptr32 = NULL; uint32_t *ptr64 = NULL; #if defined(__i386__) ptr32 = (void*)page->pd; ptr64 = ((void*)page->pd) + 4; #elif defined(__x86_64__) ptr32 = ((void*)page->pd) - 4; ptr64 = (void*)page->pd; #endif if (ptr32) { if (ptr32[1] == 0) { mode = 32; pd = ptr32; } else { mode = 64; pd = ptr64; } } #if defined(__x86_64__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { /* 64bit dom0, 32bit domU */ mode = 32; pd = ((void*)page->pd) - 4; #elif defined(__i386__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { /* 32bit dom0, 64bit domU */ mode = 64; pd = ((void*)page->pd) + 4; #endif } if (xenfb->pixels) { munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE); xenfb->pixels = NULL; } xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; n_fbdirs = xenfb->fbpages * mode / 8; n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; pgmfns = g_malloc0(sizeof(xen_pfn_t) * n_fbdirs); fbmfns = g_malloc0(sizeof(xen_pfn_t) * xenfb->fbpages); xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd); map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ, pgmfns, n_fbdirs); if (map == NULL) goto out; xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map); munmap(map, n_fbdirs * XC_PAGE_SIZE); xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ, fbmfns, xenfb->fbpages); if (xenfb->pixels == NULL) goto out; ret = 0; /* all is fine */ out: g_free(pgmfns); g_free(fbmfns); return ret; }
true
qemu
e0cb42ae4bc4438ba4ec0760df2d830b8759b255
static int xenfb_map_fb(struct XenFB *xenfb) { struct xenfb_page *page = xenfb->c.page; char *protocol = xenfb->c.xendev.protocol; int n_fbdirs; xen_pfn_t *pgmfns = NULL; xen_pfn_t *fbmfns = NULL; void *map, *pd; int mode, ret = -1; pd = page->pd; mode = sizeof(unsigned long) * 8; if (!protocol) { uint32_t *ptr32 = NULL; uint32_t *ptr64 = NULL; #if defined(__i386__) ptr32 = (void*)page->pd; ptr64 = ((void*)page->pd) + 4; #elif defined(__x86_64__) ptr32 = ((void*)page->pd) - 4; ptr64 = (void*)page->pd; #endif if (ptr32) { if (ptr32[1] == 0) { mode = 32; pd = ptr32; } else { mode = 64; pd = ptr64; } } #if defined(__x86_64__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { mode = 32; pd = ((void*)page->pd) - 4; #elif defined(__i386__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { mode = 64; pd = ((void*)page->pd) + 4; #endif } if (xenfb->pixels) { munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE); xenfb->pixels = NULL; } xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; n_fbdirs = xenfb->fbpages * mode / 8; n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; pgmfns = g_malloc0(sizeof(xen_pfn_t) * n_fbdirs); fbmfns = g_malloc0(sizeof(xen_pfn_t) * xenfb->fbpages); xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd); map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ, pgmfns, n_fbdirs); if (map == NULL) goto out; xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map); munmap(map, n_fbdirs * XC_PAGE_SIZE); xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ, fbmfns, xenfb->fbpages); if (xenfb->pixels == NULL) goto out; ret = 0; out: g_free(pgmfns); g_free(fbmfns); return ret; }
{ "code": [ " map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,", "\t\t\t PROT_READ, pgmfns, n_fbdirs);", " munmap(map, n_fbdirs * XC_PAGE_SIZE);", " xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,", " PROT_READ, fbmfns, xenfb->fbpages);" ], "line_no": [ 137, 139, 147, 151, 153 ] }
static int FUNC_0(struct XenFB *VAR_0) { struct xenfb_page *VAR_1 = VAR_0->c.VAR_1; char *VAR_2 = VAR_0->c.xendev.VAR_2; int VAR_3; xen_pfn_t *pgmfns = NULL; xen_pfn_t *fbmfns = NULL; void *VAR_4, *VAR_5; int VAR_6, VAR_7 = -1; VAR_5 = VAR_1->VAR_5; VAR_6 = sizeof(unsigned long) * 8; if (!VAR_2) { uint32_t *ptr32 = NULL; uint32_t *ptr64 = NULL; #if defined(__i386__) ptr32 = (void*)VAR_1->VAR_5; ptr64 = ((void*)VAR_1->VAR_5) + 4; #elif defined(__x86_64__) ptr32 = ((void*)VAR_1->VAR_5) - 4; ptr64 = (void*)VAR_1->VAR_5; #endif if (ptr32) { if (ptr32[1] == 0) { VAR_6 = 32; VAR_5 = ptr32; } else { VAR_6 = 64; VAR_5 = ptr64; } } #if defined(__x86_64__) } else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_32) == 0) { VAR_6 = 32; VAR_5 = ((void*)VAR_1->VAR_5) - 4; #elif defined(__i386__) } else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_64) == 0) { VAR_6 = 64; VAR_5 = ((void*)VAR_1->VAR_5) + 4; #endif } if (VAR_0->pixels) { munmap(VAR_0->pixels, VAR_0->fbpages * XC_PAGE_SIZE); VAR_0->pixels = NULL; } VAR_0->fbpages = (VAR_0->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; VAR_3 = VAR_0->fbpages * VAR_6 / 8; VAR_3 = (VAR_3 + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; pgmfns = g_malloc0(sizeof(xen_pfn_t) * VAR_3); fbmfns = g_malloc0(sizeof(xen_pfn_t) * VAR_0->fbpages); xenfb_copy_mfns(VAR_6, VAR_3, pgmfns, VAR_5); VAR_4 = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom, PROT_READ, pgmfns, VAR_3); if (VAR_4 == NULL) goto out; xenfb_copy_mfns(VAR_6, VAR_0->fbpages, fbmfns, VAR_4); munmap(VAR_4, VAR_3 * XC_PAGE_SIZE); VAR_0->pixels = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom, PROT_READ, fbmfns, VAR_0->fbpages); if (VAR_0->pixels == NULL) goto out; VAR_7 = 0; out: g_free(pgmfns); g_free(fbmfns); return VAR_7; }
[ "static int FUNC_0(struct XenFB *VAR_0)\n{", "struct xenfb_page *VAR_1 = VAR_0->c.VAR_1;", "char *VAR_2 = VAR_0->c.xendev.VAR_2;", "int VAR_3;", "xen_pfn_t *pgmfns = NULL;", "xen_pfn_t *fbmfns = NULL;", "void *VAR_4, *VAR_5;", "int VAR_6, VAR_7 = -1;", "VAR_5 = VAR_1->VAR_5;", "VAR_6 = sizeof(unsigned long) * 8;", "if (!VAR_2) {", "uint32_t *ptr32 = NULL;", "uint32_t *ptr64 = NULL;", "#if defined(__i386__)\nptr32 = (void*)VAR_1->VAR_5;", "ptr64 = ((void*)VAR_1->VAR_5) + 4;", "#elif defined(__x86_64__)\nptr32 = ((void*)VAR_1->VAR_5) - 4;", "ptr64 = (void*)VAR_1->VAR_5;", "#endif\nif (ptr32) {", "if (ptr32[1] == 0) {", "VAR_6 = 32;", "VAR_5 = ptr32;", "} else {", "VAR_6 = 64;", "VAR_5 = ptr64;", "}", "}", "#if defined(__x86_64__)\n} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_32) == 0) {", "VAR_6 = 32;", "VAR_5 = ((void*)VAR_1->VAR_5) - 4;", "#elif defined(__i386__)\n} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_64) == 0) {", "VAR_6 = 64;", "VAR_5 = ((void*)VAR_1->VAR_5) + 4;", "#endif\n}", "if (VAR_0->pixels) {", "munmap(VAR_0->pixels, VAR_0->fbpages * XC_PAGE_SIZE);", "VAR_0->pixels = NULL;", "}", "VAR_0->fbpages = (VAR_0->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;", "VAR_3 = VAR_0->fbpages * VAR_6 / 8;", "VAR_3 = (VAR_3 + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;", "pgmfns = g_malloc0(sizeof(xen_pfn_t) * VAR_3);", "fbmfns = g_malloc0(sizeof(xen_pfn_t) * VAR_0->fbpages);", "xenfb_copy_mfns(VAR_6, VAR_3, pgmfns, VAR_5);", "VAR_4 = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,\nPROT_READ, pgmfns, VAR_3);", "if (VAR_4 == NULL)\ngoto out;", "xenfb_copy_mfns(VAR_6, VAR_0->fbpages, fbmfns, VAR_4);", "munmap(VAR_4, VAR_3 * XC_PAGE_SIZE);", "VAR_0->pixels = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,\nPROT_READ, fbmfns, VAR_0->fbpages);", "if (VAR_0->pixels == NULL)\ngoto out;", "VAR_7 = 0;", "out:\ng_free(pgmfns);", "g_free(fbmfns);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 29 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 135 ], [ 137, 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 151, 153 ], [ 155, 157 ], [ 161 ], [ 165, 167 ], [ 169 ], [ 171 ], [ 173 ] ]
11,663
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts) { VideoPicture *vp; int dst_pix_fmt; AVPicture pict; static struct SwsContext *img_convert_ctx; /* wait until we have space to put a new picture */ SDL_LockMutex(is->pictq_mutex); while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); } SDL_UnlockMutex(is->pictq_mutex); if (is->videoq.abort_request) return -1; vp = &is->pictq[is->pictq_windex]; /* alloc or resize hardware picture buffer */ if (!vp->bmp || vp->width != is->video_st->codec->width || vp->height != is->video_st->codec->height) { SDL_Event event; vp->allocated = 0; /* the allocation must be done in the main thread to avoid locking problems */ event.type = FF_ALLOC_EVENT; event.user.data1 = is; SDL_PushEvent(&event); /* wait until the picture is allocated */ SDL_LockMutex(is->pictq_mutex); while (!vp->allocated && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); } SDL_UnlockMutex(is->pictq_mutex); if (is->videoq.abort_request) return -1; } /* if the frame is not skipped, then display it */ if (vp->bmp) { /* get a pointer on the bitmap */ SDL_LockYUVOverlay (vp->bmp); dst_pix_fmt = PIX_FMT_YUV420P; pict.data[0] = vp->bmp->pixels[0]; pict.data[1] = vp->bmp->pixels[2]; pict.data[2] = vp->bmp->pixels[1]; pict.linesize[0] = vp->bmp->pitches[0]; pict.linesize[1] = vp->bmp->pitches[2]; pict.linesize[2] = vp->bmp->pitches[1]; sws_flags = av_get_int(sws_opts, "sws_flags", NULL); img_convert_ctx = sws_getCachedContext(img_convert_ctx, is->video_st->codec->width, is->video_st->codec->height, is->video_st->codec->pix_fmt, is->video_st->codec->width, is->video_st->codec->height, dst_pix_fmt, sws_flags, NULL, NULL, NULL); if (img_convert_ctx == NULL) { fprintf(stderr, "Cannot initialize the conversion context\n"); exit(1); } sws_scale(img_convert_ctx, src_frame->data, src_frame->linesize, 0, is->video_st->codec->height, pict.data, pict.linesize); /* update the bitmap content */ SDL_UnlockYUVOverlay(vp->bmp); vp->pts = pts; /* now we can update the picture count */ if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) is->pictq_windex = 0; SDL_LockMutex(is->pictq_mutex); is->pictq_size++; SDL_UnlockMutex(is->pictq_mutex); } return 0; }
false
FFmpeg
fbf1b88589c7d3914ed396011121077412358b5d
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts) { VideoPicture *vp; int dst_pix_fmt; AVPicture pict; static struct SwsContext *img_convert_ctx; SDL_LockMutex(is->pictq_mutex); while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); } SDL_UnlockMutex(is->pictq_mutex); if (is->videoq.abort_request) return -1; vp = &is->pictq[is->pictq_windex]; if (!vp->bmp || vp->width != is->video_st->codec->width || vp->height != is->video_st->codec->height) { SDL_Event event; vp->allocated = 0; event.type = FF_ALLOC_EVENT; event.user.data1 = is; SDL_PushEvent(&event); SDL_LockMutex(is->pictq_mutex); while (!vp->allocated && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); } SDL_UnlockMutex(is->pictq_mutex); if (is->videoq.abort_request) return -1; } if (vp->bmp) { SDL_LockYUVOverlay (vp->bmp); dst_pix_fmt = PIX_FMT_YUV420P; pict.data[0] = vp->bmp->pixels[0]; pict.data[1] = vp->bmp->pixels[2]; pict.data[2] = vp->bmp->pixels[1]; pict.linesize[0] = vp->bmp->pitches[0]; pict.linesize[1] = vp->bmp->pitches[2]; pict.linesize[2] = vp->bmp->pitches[1]; sws_flags = av_get_int(sws_opts, "sws_flags", NULL); img_convert_ctx = sws_getCachedContext(img_convert_ctx, is->video_st->codec->width, is->video_st->codec->height, is->video_st->codec->pix_fmt, is->video_st->codec->width, is->video_st->codec->height, dst_pix_fmt, sws_flags, NULL, NULL, NULL); if (img_convert_ctx == NULL) { fprintf(stderr, "Cannot initialize the conversion context\n"); exit(1); } sws_scale(img_convert_ctx, src_frame->data, src_frame->linesize, 0, is->video_st->codec->height, pict.data, pict.linesize); SDL_UnlockYUVOverlay(vp->bmp); vp->pts = pts; if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) is->pictq_windex = 0; SDL_LockMutex(is->pictq_mutex); is->pictq_size++; SDL_UnlockMutex(is->pictq_mutex); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2) { VideoPicture *vp; int VAR_3; AVPicture pict; static struct SwsContext *VAR_4; SDL_LockMutex(VAR_0->pictq_mutex); while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !VAR_0->videoq.abort_request) { SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex); } SDL_UnlockMutex(VAR_0->pictq_mutex); if (VAR_0->videoq.abort_request) return -1; vp = &VAR_0->pictq[VAR_0->pictq_windex]; if (!vp->bmp || vp->width != VAR_0->video_st->codec->width || vp->height != VAR_0->video_st->codec->height) { SDL_Event event; vp->allocated = 0; event.type = FF_ALLOC_EVENT; event.user.data1 = VAR_0; SDL_PushEvent(&event); SDL_LockMutex(VAR_0->pictq_mutex); while (!vp->allocated && !VAR_0->videoq.abort_request) { SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex); } SDL_UnlockMutex(VAR_0->pictq_mutex); if (VAR_0->videoq.abort_request) return -1; } if (vp->bmp) { SDL_LockYUVOverlay (vp->bmp); VAR_3 = PIX_FMT_YUV420P; pict.data[0] = vp->bmp->pixels[0]; pict.data[1] = vp->bmp->pixels[2]; pict.data[2] = vp->bmp->pixels[1]; pict.linesize[0] = vp->bmp->pitches[0]; pict.linesize[1] = vp->bmp->pitches[2]; pict.linesize[2] = vp->bmp->pitches[1]; sws_flags = av_get_int(sws_opts, "sws_flags", NULL); VAR_4 = sws_getCachedContext(VAR_4, VAR_0->video_st->codec->width, VAR_0->video_st->codec->height, VAR_0->video_st->codec->pix_fmt, VAR_0->video_st->codec->width, VAR_0->video_st->codec->height, VAR_3, sws_flags, NULL, NULL, NULL); if (VAR_4 == NULL) { fprintf(stderr, "Cannot initialize the conversion context\n"); exit(1); } sws_scale(VAR_4, VAR_1->data, VAR_1->linesize, 0, VAR_0->video_st->codec->height, pict.data, pict.linesize); SDL_UnlockYUVOverlay(vp->bmp); vp->VAR_2 = VAR_2; if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) VAR_0->pictq_windex = 0; SDL_LockMutex(VAR_0->pictq_mutex); VAR_0->pictq_size++; SDL_UnlockMutex(VAR_0->pictq_mutex); } return 0; }
[ "static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2)\n{", "VideoPicture *vp;", "int VAR_3;", "AVPicture pict;", "static struct SwsContext *VAR_4;", "SDL_LockMutex(VAR_0->pictq_mutex);", "while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&\n!VAR_0->videoq.abort_request) {", "SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);", "}", "SDL_UnlockMutex(VAR_0->pictq_mutex);", "if (VAR_0->videoq.abort_request)\nreturn -1;", "vp = &VAR_0->pictq[VAR_0->pictq_windex];", "if (!vp->bmp ||\nvp->width != VAR_0->video_st->codec->width ||\nvp->height != VAR_0->video_st->codec->height) {", "SDL_Event event;", "vp->allocated = 0;", "event.type = FF_ALLOC_EVENT;", "event.user.data1 = VAR_0;", "SDL_PushEvent(&event);", "SDL_LockMutex(VAR_0->pictq_mutex);", "while (!vp->allocated && !VAR_0->videoq.abort_request) {", "SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);", "}", "SDL_UnlockMutex(VAR_0->pictq_mutex);", "if (VAR_0->videoq.abort_request)\nreturn -1;", "}", "if (vp->bmp) {", "SDL_LockYUVOverlay (vp->bmp);", "VAR_3 = PIX_FMT_YUV420P;", "pict.data[0] = vp->bmp->pixels[0];", "pict.data[1] = vp->bmp->pixels[2];", "pict.data[2] = vp->bmp->pixels[1];", "pict.linesize[0] = vp->bmp->pitches[0];", "pict.linesize[1] = vp->bmp->pitches[2];", "pict.linesize[2] = vp->bmp->pitches[1];", "sws_flags = av_get_int(sws_opts, \"sws_flags\", NULL);", "VAR_4 = sws_getCachedContext(VAR_4,\nVAR_0->video_st->codec->width, VAR_0->video_st->codec->height,\nVAR_0->video_st->codec->pix_fmt,\nVAR_0->video_st->codec->width, VAR_0->video_st->codec->height,\nVAR_3, sws_flags, NULL, NULL, NULL);", "if (VAR_4 == NULL) {", "fprintf(stderr, \"Cannot initialize the conversion context\\n\");", "exit(1);", "}", "sws_scale(VAR_4, VAR_1->data, VAR_1->linesize,\n0, VAR_0->video_st->codec->height, pict.data, pict.linesize);", "SDL_UnlockYUVOverlay(vp->bmp);", "vp->VAR_2 = VAR_2;", "if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)\nVAR_0->pictq_windex = 0;", "SDL_LockMutex(VAR_0->pictq_mutex);", "VAR_0->pictq_size++;", "SDL_UnlockMutex(VAR_0->pictq_mutex);", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 37 ], [ 43, 45, 47 ], [ 49 ], [ 53 ], [ 61 ], [ 63 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 93 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121, 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 143 ], [ 147 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ] ]
11,664
static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "wave"); if (track->enc->codec_id != AV_CODEC_ID_QDM2) { avio_wb32(pb, 12); /* size */ ffio_wfourcc(pb, "frma"); avio_wl32(pb, track->tag); } if (track->enc->codec_id == AV_CODEC_ID_AAC) { /* useless atom needed by mplayer, ipod, not needed by quicktime */ avio_wb32(pb, 12); /* size */ ffio_wfourcc(pb, "mp4a"); avio_wb32(pb, 0); mov_write_esds_tag(pb, track); } else if (mov_pcm_le_gt16(track->enc->codec_id)) { mov_write_enda_tag(pb); } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) { mov_write_amr_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_AC3) { mov_write_ac3_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ALAC || track->enc->codec_id == AV_CODEC_ID_QDM2) { mov_write_extradata_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { mov_write_ms_tag(pb, track); } avio_wb32(pb, 8); /* size */ avio_wb32(pb, 0); /* null tag */ return update_size(pb, pos); }
false
FFmpeg
60b433d905c582ed3656c120b3ffffd0119d5377
static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); avio_wb32(pb, 0); ffio_wfourcc(pb, "wave"); if (track->enc->codec_id != AV_CODEC_ID_QDM2) { avio_wb32(pb, 12); ffio_wfourcc(pb, "frma"); avio_wl32(pb, track->tag); } if (track->enc->codec_id == AV_CODEC_ID_AAC) { avio_wb32(pb, 12); ffio_wfourcc(pb, "mp4a"); avio_wb32(pb, 0); mov_write_esds_tag(pb, track); } else if (mov_pcm_le_gt16(track->enc->codec_id)) { mov_write_enda_tag(pb); } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) { mov_write_amr_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_AC3) { mov_write_ac3_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ALAC || track->enc->codec_id == AV_CODEC_ID_QDM2) { mov_write_extradata_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { mov_write_ms_tag(pb, track); } avio_wb32(pb, 8); avio_wb32(pb, 0); return update_size(pb, pos); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1) { int64_t pos = avio_tell(VAR_0); avio_wb32(VAR_0, 0); ffio_wfourcc(VAR_0, "wave"); if (VAR_1->enc->codec_id != AV_CODEC_ID_QDM2) { avio_wb32(VAR_0, 12); ffio_wfourcc(VAR_0, "frma"); avio_wl32(VAR_0, VAR_1->tag); } if (VAR_1->enc->codec_id == AV_CODEC_ID_AAC) { avio_wb32(VAR_0, 12); ffio_wfourcc(VAR_0, "mp4a"); avio_wb32(VAR_0, 0); mov_write_esds_tag(VAR_0, VAR_1); } else if (mov_pcm_le_gt16(VAR_1->enc->codec_id)) { mov_write_enda_tag(VAR_0); } else if (VAR_1->enc->codec_id == AV_CODEC_ID_AMR_NB) { mov_write_amr_tag(VAR_0, VAR_1); } else if (VAR_1->enc->codec_id == AV_CODEC_ID_AC3) { mov_write_ac3_tag(VAR_0, VAR_1); } else if (VAR_1->enc->codec_id == AV_CODEC_ID_ALAC || VAR_1->enc->codec_id == AV_CODEC_ID_QDM2) { mov_write_extradata_tag(VAR_0, VAR_1); } else if (VAR_1->enc->codec_id == AV_CODEC_ID_ADPCM_MS || VAR_1->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { mov_write_ms_tag(VAR_0, VAR_1); } avio_wb32(VAR_0, 8); avio_wb32(VAR_0, 0); return update_size(VAR_0, pos); }
[ "static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)\n{", "int64_t pos = avio_tell(VAR_0);", "avio_wb32(VAR_0, 0);", "ffio_wfourcc(VAR_0, \"wave\");", "if (VAR_1->enc->codec_id != AV_CODEC_ID_QDM2) {", "avio_wb32(VAR_0, 12);", "ffio_wfourcc(VAR_0, \"frma\");", "avio_wl32(VAR_0, VAR_1->tag);", "}", "if (VAR_1->enc->codec_id == AV_CODEC_ID_AAC) {", "avio_wb32(VAR_0, 12);", "ffio_wfourcc(VAR_0, \"mp4a\");", "avio_wb32(VAR_0, 0);", "mov_write_esds_tag(VAR_0, VAR_1);", "} else if (mov_pcm_le_gt16(VAR_1->enc->codec_id)) {", "mov_write_enda_tag(VAR_0);", "} else if (VAR_1->enc->codec_id == AV_CODEC_ID_AMR_NB) {", "mov_write_amr_tag(VAR_0, VAR_1);", "} else if (VAR_1->enc->codec_id == AV_CODEC_ID_AC3) {", "mov_write_ac3_tag(VAR_0, VAR_1);", "} else if (VAR_1->enc->codec_id == AV_CODEC_ID_ALAC ||", "VAR_1->enc->codec_id == AV_CODEC_ID_QDM2) {", "mov_write_extradata_tag(VAR_0, VAR_1);", "} else if (VAR_1->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||", "VAR_1->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {", "mov_write_ms_tag(VAR_0, VAR_1);", "}", "avio_wb32(VAR_0, 8);", "avio_wb32(VAR_0, 0);", "return update_size(VAR_0, pos);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ] ]
11,666
int av_read_frame(AVFormatContext *s, AVPacket *pkt) { const int genpts = s->flags & AVFMT_FLAG_GENPTS; int eof = 0; if (!genpts) return s->internal->packet_buffer ? read_from_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end, pkt) : read_frame_internal(s, pkt); for (;;) { int ret; AVPacketList *pktl = s->internal->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->pkt; if (next_pkt->dts != AV_NOPTS_VALUE) { int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->pkt.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0) && av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { // not B-frame next_pkt->pts = pktl->pkt.dts; } pktl = pktl->next; } pktl = s->internal->packet_buffer; } /* read packet from packet buffer, if there is data */ if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !eof)) return read_from_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end, pkt); } ret = read_frame_internal(s, pkt); if (ret < 0) { if (pktl && ret != AVERROR(EAGAIN)) { eof = 1; continue; } else return ret; } if (av_dup_packet(add_to_pktbuf(&s->internal->packet_buffer, pkt, &s->internal->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } }
false
FFmpeg
d584533cf38141172e20bae5436629ee17c8ce50
int av_read_frame(AVFormatContext *s, AVPacket *pkt) { const int genpts = s->flags & AVFMT_FLAG_GENPTS; int eof = 0; if (!genpts) return s->internal->packet_buffer ? read_from_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end, pkt) : read_frame_internal(s, pkt); for (;;) { int ret; AVPacketList *pktl = s->internal->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->pkt; if (next_pkt->dts != AV_NOPTS_VALUE) { int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->pkt.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0) && av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { next_pkt->pts = pktl->pkt.dts; } pktl = pktl->next; } pktl = s->internal->packet_buffer; } if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !eof)) return read_from_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end, pkt); } ret = read_frame_internal(s, pkt); if (ret < 0) { if (pktl && ret != AVERROR(EAGAIN)) { eof = 1; continue; } else return ret; } if (av_dup_packet(add_to_pktbuf(&s->internal->packet_buffer, pkt, &s->internal->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } }
{ "code": [], "line_no": [] }
int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { const int VAR_2 = VAR_0->flags & AVFMT_FLAG_GENPTS; int VAR_3 = 0; if (!VAR_2) return VAR_0->internal->packet_buffer ? read_from_packet_buffer(&VAR_0->internal->packet_buffer, &VAR_0->internal->packet_buffer_end, VAR_1) : read_frame_internal(VAR_0, VAR_1); for (;;) { int VAR_4; AVPacketList *pktl = VAR_0->internal->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->VAR_1; if (next_pkt->dts != AV_NOPTS_VALUE) { int VAR_5 = VAR_0->streams[next_pkt->stream_index]->pts_wrap_bits; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->VAR_1.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1)) < 0) && av_compare_mod(pktl->VAR_1.pts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1))) { next_pkt->pts = pktl->VAR_1.dts; } pktl = pktl->next; } pktl = VAR_0->internal->packet_buffer; } if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !VAR_3)) return read_from_packet_buffer(&VAR_0->internal->packet_buffer, &VAR_0->internal->packet_buffer_end, VAR_1); } VAR_4 = read_frame_internal(VAR_0, VAR_1); if (VAR_4 < 0) { if (pktl && VAR_4 != AVERROR(EAGAIN)) { VAR_3 = 1; continue; } else return VAR_4; } if (av_dup_packet(add_to_pktbuf(&VAR_0->internal->packet_buffer, VAR_1, &VAR_0->internal->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } }
[ "int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "const int VAR_2 = VAR_0->flags & AVFMT_FLAG_GENPTS;", "int VAR_3 = 0;", "if (!VAR_2)\nreturn VAR_0->internal->packet_buffer\n? read_from_packet_buffer(&VAR_0->internal->packet_buffer,\n&VAR_0->internal->packet_buffer_end, VAR_1)\n: read_frame_internal(VAR_0, VAR_1);", "for (;;) {", "int VAR_4;", "AVPacketList *pktl = VAR_0->internal->packet_buffer;", "if (pktl) {", "AVPacket *next_pkt = &pktl->VAR_1;", "if (next_pkt->dts != AV_NOPTS_VALUE) {", "int VAR_5 = VAR_0->streams[next_pkt->stream_index]->pts_wrap_bits;", "while (pktl && next_pkt->pts == AV_NOPTS_VALUE) {", "if (pktl->VAR_1.stream_index == next_pkt->stream_index &&\n(av_compare_mod(next_pkt->dts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1)) < 0) &&\nav_compare_mod(pktl->VAR_1.pts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1))) {", "next_pkt->pts = pktl->VAR_1.dts;", "}", "pktl = pktl->next;", "}", "pktl = VAR_0->internal->packet_buffer;", "}", "if (!(next_pkt->pts == AV_NOPTS_VALUE &&\nnext_pkt->dts != AV_NOPTS_VALUE && !VAR_3))\nreturn read_from_packet_buffer(&VAR_0->internal->packet_buffer,\n&VAR_0->internal->packet_buffer_end, VAR_1);", "}", "VAR_4 = read_frame_internal(VAR_0, VAR_1);", "if (VAR_4 < 0) {", "if (pktl && VAR_4 != AVERROR(EAGAIN)) {", "VAR_3 = 1;", "continue;", "} else", "return VAR_4;", "}", "if (av_dup_packet(add_to_pktbuf(&VAR_0->internal->packet_buffer, VAR_1,\n&VAR_0->internal->packet_buffer_end)) < 0)\nreturn AVERROR(ENOMEM);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13, 15, 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45, 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67, 69, 71, 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99, 101 ], [ 103 ], [ 105 ] ]
11,667
static int coroutine_fn nfs_co_flush(BlockDriverState *bs) { NFSClient *client = bs->opaque; NFSRPC task; nfs_co_init_task(client, &task); if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { return -ENOMEM; } while (!task.complete) { nfs_set_events(client); qemu_coroutine_yield(); } return task.ret; }
false
qemu
aa92d6c4609e174fc6884e4b7b87367fac33cbe9
static int coroutine_fn nfs_co_flush(BlockDriverState *bs) { NFSClient *client = bs->opaque; NFSRPC task; nfs_co_init_task(client, &task); if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { return -ENOMEM; } while (!task.complete) { nfs_set_events(client); qemu_coroutine_yield(); } return task.ret; }
{ "code": [], "line_no": [] }
static int VAR_0 nfs_co_flush(BlockDriverState *bs) { NFSClient *client = bs->opaque; NFSRPC task; nfs_co_init_task(client, &task); if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { return -ENOMEM; } while (!task.complete) { nfs_set_events(client); qemu_coroutine_yield(); } return task.ret; }
[ "static int VAR_0 nfs_co_flush(BlockDriverState *bs)\n{", "NFSClient *client = bs->opaque;", "NFSRPC task;", "nfs_co_init_task(client, &task);", "if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb,\n&task) != 0) {", "return -ENOMEM;", "}", "while (!task.complete) {", "nfs_set_events(client);", "qemu_coroutine_yield();", "}", "return task.ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ] ]
11,668
static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) { Error *local_err = NULL; int64_t bytes = 0; int64_t objsize; int obj_order = 0; const char *pool, *name, *conf, *clientname, *keypairs; const char *secretid; rados_t cluster; rados_ioctx_t io_ctx; QDict *options = NULL; QemuOpts *rbd_opts = NULL; int ret = 0; secretid = qemu_opt_get(opts, "password-secret"); /* Read out options */ bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0); if (objsize) { if ((objsize - 1) & objsize) { /* not a power of 2? */ error_setg(errp, "obj size needs to be power of 2"); ret = -EINVAL; goto exit; } if (objsize < 4096) { error_setg(errp, "obj size too small"); ret = -EINVAL; goto exit; } obj_order = ctz32(objsize); } options = qdict_new(); qemu_rbd_parse_filename(filename, options, &local_err); if (local_err) { ret = -EINVAL; error_propagate(errp, local_err); goto exit; } rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(rbd_opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto exit; } pool = qemu_opt_get(rbd_opts, "pool"); conf = qemu_opt_get(rbd_opts, "conf"); clientname = qemu_opt_get(rbd_opts, "user"); name = qemu_opt_get(rbd_opts, "image"); keypairs = qemu_opt_get(rbd_opts, "keyvalue-pairs"); ret = rados_create(&cluster, clientname); if (ret < 0) { error_setg_errno(errp, -ret, "error initializing"); goto exit; } /* try default location when conf=NULL, but ignore failure */ ret = rados_conf_read_file(cluster, conf); if (conf && ret < 0) { error_setg_errno(errp, -ret, "error reading conf file %s", conf); ret = -EIO; goto shutdown; } ret = qemu_rbd_set_keypairs(cluster, keypairs, errp); if (ret < 0) { ret = -EIO; goto shutdown; } if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) { ret = -EIO; goto shutdown; } ret = rados_connect(cluster); if (ret < 0) { error_setg_errno(errp, -ret, "error connecting"); goto shutdown; } ret = rados_ioctx_create(cluster, pool, &io_ctx); if (ret < 0) { error_setg_errno(errp, -ret, "error opening pool %s", pool); goto shutdown; } ret = rbd_create(io_ctx, name, bytes, &obj_order); if (ret < 0) { error_setg_errno(errp, -ret, "error rbd create"); } rados_ioctx_destroy(io_ctx); shutdown: rados_shutdown(cluster); exit: QDECREF(options); qemu_opts_del(rbd_opts); return ret; }
false
qemu
82f20e8547ce665e9bb23fdb55374840b846c143
static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) { Error *local_err = NULL; int64_t bytes = 0; int64_t objsize; int obj_order = 0; const char *pool, *name, *conf, *clientname, *keypairs; const char *secretid; rados_t cluster; rados_ioctx_t io_ctx; QDict *options = NULL; QemuOpts *rbd_opts = NULL; int ret = 0; secretid = qemu_opt_get(opts, "password-secret"); bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0); if (objsize) { if ((objsize - 1) & objsize) { error_setg(errp, "obj size needs to be power of 2"); ret = -EINVAL; goto exit; } if (objsize < 4096) { error_setg(errp, "obj size too small"); ret = -EINVAL; goto exit; } obj_order = ctz32(objsize); } options = qdict_new(); qemu_rbd_parse_filename(filename, options, &local_err); if (local_err) { ret = -EINVAL; error_propagate(errp, local_err); goto exit; } rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(rbd_opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto exit; } pool = qemu_opt_get(rbd_opts, "pool"); conf = qemu_opt_get(rbd_opts, "conf"); clientname = qemu_opt_get(rbd_opts, "user"); name = qemu_opt_get(rbd_opts, "image"); keypairs = qemu_opt_get(rbd_opts, "keyvalue-pairs"); ret = rados_create(&cluster, clientname); if (ret < 0) { error_setg_errno(errp, -ret, "error initializing"); goto exit; } ret = rados_conf_read_file(cluster, conf); if (conf && ret < 0) { error_setg_errno(errp, -ret, "error reading conf file %s", conf); ret = -EIO; goto shutdown; } ret = qemu_rbd_set_keypairs(cluster, keypairs, errp); if (ret < 0) { ret = -EIO; goto shutdown; } if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) { ret = -EIO; goto shutdown; } ret = rados_connect(cluster); if (ret < 0) { error_setg_errno(errp, -ret, "error connecting"); goto shutdown; } ret = rados_ioctx_create(cluster, pool, &io_ctx); if (ret < 0) { error_setg_errno(errp, -ret, "error opening pool %s", pool); goto shutdown; } ret = rbd_create(io_ctx, name, bytes, &obj_order); if (ret < 0) { error_setg_errno(errp, -ret, "error rbd create"); } rados_ioctx_destroy(io_ctx); shutdown: rados_shutdown(cluster); exit: QDECREF(options); qemu_opts_del(rbd_opts); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2) { Error *local_err = NULL; int64_t bytes = 0; int64_t objsize; int VAR_3 = 0; const char *VAR_4, *VAR_5, *VAR_6, *VAR_7, *VAR_8; const char *VAR_9; rados_t cluster; rados_ioctx_t io_ctx; QDict *options = NULL; QemuOpts *rbd_opts = NULL; int VAR_10 = 0; VAR_9 = qemu_opt_get(VAR_1, "password-secret"); bytes = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); objsize = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_CLUSTER_SIZE, 0); if (objsize) { if ((objsize - 1) & objsize) { error_setg(VAR_2, "obj size needs to be power of 2"); VAR_10 = -EINVAL; goto exit; } if (objsize < 4096) { error_setg(VAR_2, "obj size too small"); VAR_10 = -EINVAL; goto exit; } VAR_3 = ctz32(objsize); } options = qdict_new(); qemu_rbd_parse_filename(VAR_0, options, &local_err); if (local_err) { VAR_10 = -EINVAL; error_propagate(VAR_2, local_err); goto exit; } rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(rbd_opts, options, &local_err); if (local_err) { error_propagate(VAR_2, local_err); VAR_10 = -EINVAL; goto exit; } VAR_4 = qemu_opt_get(rbd_opts, "VAR_4"); VAR_6 = qemu_opt_get(rbd_opts, "VAR_6"); VAR_7 = qemu_opt_get(rbd_opts, "user"); VAR_5 = qemu_opt_get(rbd_opts, "image"); VAR_8 = qemu_opt_get(rbd_opts, "keyvalue-pairs"); VAR_10 = rados_create(&cluster, VAR_7); if (VAR_10 < 0) { error_setg_errno(VAR_2, -VAR_10, "error initializing"); goto exit; } VAR_10 = rados_conf_read_file(cluster, VAR_6); if (VAR_6 && VAR_10 < 0) { error_setg_errno(VAR_2, -VAR_10, "error reading VAR_6 file %s", VAR_6); VAR_10 = -EIO; goto shutdown; } VAR_10 = qemu_rbd_set_keypairs(cluster, VAR_8, VAR_2); if (VAR_10 < 0) { VAR_10 = -EIO; goto shutdown; } if (qemu_rbd_set_auth(cluster, VAR_9, VAR_2) < 0) { VAR_10 = -EIO; goto shutdown; } VAR_10 = rados_connect(cluster); if (VAR_10 < 0) { error_setg_errno(VAR_2, -VAR_10, "error connecting"); goto shutdown; } VAR_10 = rados_ioctx_create(cluster, VAR_4, &io_ctx); if (VAR_10 < 0) { error_setg_errno(VAR_2, -VAR_10, "error opening VAR_4 %s", VAR_4); goto shutdown; } VAR_10 = rbd_create(io_ctx, VAR_5, bytes, &VAR_3); if (VAR_10 < 0) { error_setg_errno(VAR_2, -VAR_10, "error rbd create"); } rados_ioctx_destroy(io_ctx); shutdown: rados_shutdown(cluster); exit: QDECREF(options); qemu_opts_del(rbd_opts); return VAR_10; }
[ "static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{", "Error *local_err = NULL;", "int64_t bytes = 0;", "int64_t objsize;", "int VAR_3 = 0;", "const char *VAR_4, *VAR_5, *VAR_6, *VAR_7, *VAR_8;", "const char *VAR_9;", "rados_t cluster;", "rados_ioctx_t io_ctx;", "QDict *options = NULL;", "QemuOpts *rbd_opts = NULL;", "int VAR_10 = 0;", "VAR_9 = qemu_opt_get(VAR_1, \"password-secret\");", "bytes = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0),\nBDRV_SECTOR_SIZE);", "objsize = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_CLUSTER_SIZE, 0);", "if (objsize) {", "if ((objsize - 1) & objsize) {", "error_setg(VAR_2, \"obj size needs to be power of 2\");", "VAR_10 = -EINVAL;", "goto exit;", "}", "if (objsize < 4096) {", "error_setg(VAR_2, \"obj size too small\");", "VAR_10 = -EINVAL;", "goto exit;", "}", "VAR_3 = ctz32(objsize);", "}", "options = qdict_new();", "qemu_rbd_parse_filename(VAR_0, options, &local_err);", "if (local_err) {", "VAR_10 = -EINVAL;", "error_propagate(VAR_2, local_err);", "goto exit;", "}", "rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);", "qemu_opts_absorb_qdict(rbd_opts, options, &local_err);", "if (local_err) {", "error_propagate(VAR_2, local_err);", "VAR_10 = -EINVAL;", "goto exit;", "}", "VAR_4 = qemu_opt_get(rbd_opts, \"VAR_4\");", "VAR_6 = qemu_opt_get(rbd_opts, \"VAR_6\");", "VAR_7 = qemu_opt_get(rbd_opts, \"user\");", "VAR_5 = qemu_opt_get(rbd_opts, \"image\");", "VAR_8 = qemu_opt_get(rbd_opts, \"keyvalue-pairs\");", "VAR_10 = rados_create(&cluster, VAR_7);", "if (VAR_10 < 0) {", "error_setg_errno(VAR_2, -VAR_10, \"error initializing\");", "goto exit;", "}", "VAR_10 = rados_conf_read_file(cluster, VAR_6);", "if (VAR_6 && VAR_10 < 0) {", "error_setg_errno(VAR_2, -VAR_10, \"error reading VAR_6 file %s\", VAR_6);", "VAR_10 = -EIO;", "goto shutdown;", "}", "VAR_10 = qemu_rbd_set_keypairs(cluster, VAR_8, VAR_2);", "if (VAR_10 < 0) {", "VAR_10 = -EIO;", "goto shutdown;", "}", "if (qemu_rbd_set_auth(cluster, VAR_9, VAR_2) < 0) {", "VAR_10 = -EIO;", "goto shutdown;", "}", "VAR_10 = rados_connect(cluster);", "if (VAR_10 < 0) {", "error_setg_errno(VAR_2, -VAR_10, \"error connecting\");", "goto shutdown;", "}", "VAR_10 = rados_ioctx_create(cluster, VAR_4, &io_ctx);", "if (VAR_10 < 0) {", "error_setg_errno(VAR_2, -VAR_10, \"error opening VAR_4 %s\", VAR_4);", "goto shutdown;", "}", "VAR_10 = rbd_create(io_ctx, VAR_5, bytes, &VAR_3);", "if (VAR_10 < 0) {", "error_setg_errno(VAR_2, -VAR_10, \"error rbd create\");", "}", "rados_ioctx_destroy(io_ctx);", "shutdown:\nrados_shutdown(cluster);", "exit:\nQDECREF(options);", "qemu_opts_del(rbd_opts);", "return VAR_10;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 201, 203 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ] ]
11,669
static void port92_init(ISADevice *dev, qemu_irq *a20_out) { Port92State *s = PORT92(dev); s->a20_out = a20_out; }
false
qemu
d812b3d68ddf0efe91a088ecc8b177865b0bab8d
static void port92_init(ISADevice *dev, qemu_irq *a20_out) { Port92State *s = PORT92(dev); s->a20_out = a20_out; }
{ "code": [], "line_no": [] }
static void FUNC_0(ISADevice *VAR_0, qemu_irq *VAR_1) { Port92State *s = PORT92(VAR_0); s->VAR_1 = VAR_1; }
[ "static void FUNC_0(ISADevice *VAR_0, qemu_irq *VAR_1)\n{", "Port92State *s = PORT92(VAR_0);", "s->VAR_1 = VAR_1;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
11,670
static TCGv gen_mulu_i64_i32(TCGv a, TCGv b) { TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64); TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_extu_i32_i64(tmp1, a); dead_tmp(a); tcg_gen_extu_i32_i64(tmp2, b); dead_tmp(b); tcg_gen_mul_i64(tmp1, tmp1, tmp2); return tmp1; }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static TCGv gen_mulu_i64_i32(TCGv a, TCGv b) { TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64); TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_extu_i32_i64(tmp1, a); dead_tmp(a); tcg_gen_extu_i32_i64(tmp2, b); dead_tmp(b); tcg_gen_mul_i64(tmp1, tmp1, tmp2); return tmp1; }
{ "code": [], "line_no": [] }
static TCGv FUNC_0(TCGv a, TCGv b) { TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64); TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_extu_i32_i64(tmp1, a); dead_tmp(a); tcg_gen_extu_i32_i64(tmp2, b); dead_tmp(b); tcg_gen_mul_i64(tmp1, tmp1, tmp2); return tmp1; }
[ "static TCGv FUNC_0(TCGv a, TCGv b)\n{", "TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64);", "TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64);", "tcg_gen_extu_i32_i64(tmp1, a);", "dead_tmp(a);", "tcg_gen_extu_i32_i64(tmp2, b);", "dead_tmp(b);", "tcg_gen_mul_i64(tmp1, tmp1, tmp2);", "return tmp1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
11,671
static void pxa2xx_rtc_piupdate(PXA2xxRTCState *s) { int64_t rt = qemu_get_clock(rt_clock); if (s->rtsr & (1 << 15)) s->last_swcr += rt - s->last_pi; s->last_pi = rt; }
false
qemu
7bd427d801e1e3293a634d3c83beadaa90ffb911
static void pxa2xx_rtc_piupdate(PXA2xxRTCState *s) { int64_t rt = qemu_get_clock(rt_clock); if (s->rtsr & (1 << 15)) s->last_swcr += rt - s->last_pi; s->last_pi = rt; }
{ "code": [], "line_no": [] }
static void FUNC_0(PXA2xxRTCState *VAR_0) { int64_t rt = qemu_get_clock(rt_clock); if (VAR_0->rtsr & (1 << 15)) VAR_0->last_swcr += rt - VAR_0->last_pi; VAR_0->last_pi = rt; }
[ "static void FUNC_0(PXA2xxRTCState *VAR_0)\n{", "int64_t rt = qemu_get_clock(rt_clock);", "if (VAR_0->rtsr & (1 << 15))\nVAR_0->last_swcr += rt - VAR_0->last_pi;", "VAR_0->last_pi = rt;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ] ]
11,672
int ioinst_handle_ssch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; ORB *orig_orb, orb; uint64_t addr; int ret = -ENODEV; int cc; hwaddr len = sizeof(*orig_orb); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("ssch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } orig_orb = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!orig_orb || len != sizeof(*orig_orb)) { program_interrupt(env, PGM_ADDRESSING, 2); cc = -EIO; goto out; } copy_orb_from_guest(&orb, orig_orb); if (!ioinst_orb_valid(&orb)) { program_interrupt(env, PGM_OPERAND, 2); cc = -EIO; goto out; } sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { ret = css_do_ssch(sch, &orb); } switch (ret) { case -ENODEV: cc = 3; break; case -EBUSY: cc = 2; break; case 0: cc = 0; break; default: cc = 1; break; } out: s390_cpu_physical_memory_unmap(env, orig_orb, len, 0); return cc; }
false
qemu
71ed827abd57dc7947ce3316118d0e601e70fac9
int ioinst_handle_ssch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; ORB *orig_orb, orb; uint64_t addr; int ret = -ENODEV; int cc; hwaddr len = sizeof(*orig_orb); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("ssch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } orig_orb = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!orig_orb || len != sizeof(*orig_orb)) { program_interrupt(env, PGM_ADDRESSING, 2); cc = -EIO; goto out; } copy_orb_from_guest(&orb, orig_orb); if (!ioinst_orb_valid(&orb)) { program_interrupt(env, PGM_OPERAND, 2); cc = -EIO; goto out; } sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { ret = css_do_ssch(sch, &orb); } switch (ret) { case -ENODEV: cc = 3; break; case -EBUSY: cc = 2; break; case 0: cc = 0; break; default: cc = 1; break; } out: s390_cpu_physical_memory_unmap(env, orig_orb, len, 0); return cc; }
{ "code": [], "line_no": [] }
int FUNC_0(CPUS390XState *VAR_0, uint64_t VAR_1, uint32_t VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6; SubchDev *sch; ORB *orig_orb, orb; uint64_t addr; int VAR_7 = -ENODEV; int VAR_8; hwaddr len = sizeof(*orig_orb); if (ioinst_disassemble_sch_ident(VAR_1, &VAR_6, &VAR_3, &VAR_4, &VAR_5)) { program_interrupt(VAR_0, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("ssch", VAR_3, VAR_4, VAR_5); addr = decode_basedisp_s(VAR_0, VAR_2); if (addr & 3) { program_interrupt(VAR_0, PGM_SPECIFICATION, 2); return -EIO; } orig_orb = s390_cpu_physical_memory_map(VAR_0, addr, &len, 0); if (!orig_orb || len != sizeof(*orig_orb)) { program_interrupt(VAR_0, PGM_ADDRESSING, 2); VAR_8 = -EIO; goto out; } copy_orb_from_guest(&orb, orig_orb); if (!ioinst_orb_valid(&orb)) { program_interrupt(VAR_0, PGM_OPERAND, 2); VAR_8 = -EIO; goto out; } sch = css_find_subch(VAR_6, VAR_3, VAR_4, VAR_5); if (sch && css_subch_visible(sch)) { VAR_7 = css_do_ssch(sch, &orb); } switch (VAR_7) { case -ENODEV: VAR_8 = 3; break; case -EBUSY: VAR_8 = 2; break; case 0: VAR_8 = 0; break; default: VAR_8 = 1; break; } out: s390_cpu_physical_memory_unmap(VAR_0, orig_orb, len, 0); return VAR_8; }
[ "int FUNC_0(CPUS390XState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6;", "SubchDev *sch;", "ORB *orig_orb, orb;", "uint64_t addr;", "int VAR_7 = -ENODEV;", "int VAR_8;", "hwaddr len = sizeof(*orig_orb);", "if (ioinst_disassemble_sch_ident(VAR_1, &VAR_6, &VAR_3, &VAR_4, &VAR_5)) {", "program_interrupt(VAR_0, PGM_OPERAND, 2);", "return -EIO;", "}", "trace_ioinst_sch_id(\"ssch\", VAR_3, VAR_4, VAR_5);", "addr = decode_basedisp_s(VAR_0, VAR_2);", "if (addr & 3) {", "program_interrupt(VAR_0, PGM_SPECIFICATION, 2);", "return -EIO;", "}", "orig_orb = s390_cpu_physical_memory_map(VAR_0, addr, &len, 0);", "if (!orig_orb || len != sizeof(*orig_orb)) {", "program_interrupt(VAR_0, PGM_ADDRESSING, 2);", "VAR_8 = -EIO;", "goto out;", "}", "copy_orb_from_guest(&orb, orig_orb);", "if (!ioinst_orb_valid(&orb)) {", "program_interrupt(VAR_0, PGM_OPERAND, 2);", "VAR_8 = -EIO;", "goto out;", "}", "sch = css_find_subch(VAR_6, VAR_3, VAR_4, VAR_5);", "if (sch && css_subch_visible(sch)) {", "VAR_7 = css_do_ssch(sch, &orb);", "}", "switch (VAR_7) {", "case -ENODEV:\nVAR_8 = 3;", "break;", "case -EBUSY:\nVAR_8 = 2;", "break;", "case 0:\nVAR_8 = 0;", "break;", "default:\nVAR_8 = 1;", "break;", "}", "out:\ns390_cpu_physical_memory_unmap(VAR_0, orig_orb, len, 0);", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 103, 105 ], [ 107 ], [ 109 ] ]
11,673
int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb) { CPUS390XState *env = &cpu->env; uint64_t addr; int lowcore; IOIntCode int_code; hwaddr len; int ret; uint8_t ar; trace_ioinst("tpi"); addr = decode_basedisp_s(env, ipb, &ar); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } lowcore = addr ? 0 : 1; len = lowcore ? 8 /* two words */ : 12 /* three words */; ret = css_do_tpi(&int_code, lowcore); if (ret == 1) { s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, ar, &int_code, len); } return ret; }
false
qemu
7e01376daea75e888c370aab521a7d4aeaf2ffd1
int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb) { CPUS390XState *env = &cpu->env; uint64_t addr; int lowcore; IOIntCode int_code; hwaddr len; int ret; uint8_t ar; trace_ioinst("tpi"); addr = decode_basedisp_s(env, ipb, &ar); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } lowcore = addr ? 0 : 1; len = lowcore ? 8 : 12 ; ret = css_do_tpi(&int_code, lowcore); if (ret == 1) { s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, ar, &int_code, len); } return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(S390CPU *VAR_0, uint32_t VAR_1) { CPUS390XState *env = &VAR_0->env; uint64_t addr; int VAR_2; IOIntCode int_code; hwaddr len; int VAR_3; uint8_t ar; trace_ioinst("tpi"); addr = decode_basedisp_s(env, VAR_1, &ar); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } VAR_2 = addr ? 0 : 1; len = VAR_2 ? 8 : 12 ; VAR_3 = css_do_tpi(&int_code, VAR_2); if (VAR_3 == 1) { s390_cpu_virt_mem_write(VAR_0, VAR_2 ? 184 : addr, ar, &int_code, len); } return VAR_3; }
[ "int FUNC_0(S390CPU *VAR_0, uint32_t VAR_1)\n{", "CPUS390XState *env = &VAR_0->env;", "uint64_t addr;", "int VAR_2;", "IOIntCode int_code;", "hwaddr len;", "int VAR_3;", "uint8_t ar;", "trace_ioinst(\"tpi\");", "addr = decode_basedisp_s(env, VAR_1, &ar);", "if (addr & 3) {", "program_interrupt(env, PGM_SPECIFICATION, 2);", "return -EIO;", "}", "VAR_2 = addr ? 0 : 1;", "len = VAR_2 ? 8 : 12 ;", "VAR_3 = css_do_tpi(&int_code, VAR_2);", "if (VAR_3 == 1) {", "s390_cpu_virt_mem_write(VAR_0, VAR_2 ? 184 : addr, ar, &int_code, len);", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
11,675
static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data) { exit(0); return 0; }
false
qemu
0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d
static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data) { exit(0); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2) { exit(0); return 0; }
[ "static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{", "exit(0);", "return 0;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,676
void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt) { switch (fs) { case 1: /* UFR Alias - Reset Status FR */ if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) { return; } if (env->CP0_Config5 & (1 << CP0C5_UFR)) { env->CP0_Status &= ~(1 << CP0St_FR); compute_hflags(env); } else { helper_raise_exception(env, EXCP_RI); } break; case 4: /* UNFR Alias - Set Status FR */ if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) { return; } if (env->CP0_Config5 & (1 << CP0C5_UFR)) { env->CP0_Status |= (1 << CP0St_FR); compute_hflags(env); } else { helper_raise_exception(env, EXCP_RI); } break; case 25: if (arg1 & 0xffffff00) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0x017fffff) | ((arg1 & 0xfe) << 24) | ((arg1 & 0x1) << 23); break; case 26: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfffc0f83) | (arg1 & 0x0003f07c); break; case 28: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfefff07c) | (arg1 & 0x00000f83) | ((arg1 & 0x4) << 22); break; case 31: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = arg1; break; default: return; } /* set rounding mode */ restore_rounding_mode(env); /* set flush-to-zero mode */ restore_flush_mode(env); set_float_exception_flags(0, &env->active_fpu.fp_status); if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31)) do_raise_exception(env, EXCP_FPE, GETPC()); }
false
qemu
ba801af429aaa68f6cc03842c8b6be81a6ede65a
void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt) { switch (fs) { case 1: if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) { return; } if (env->CP0_Config5 & (1 << CP0C5_UFR)) { env->CP0_Status &= ~(1 << CP0St_FR); compute_hflags(env); } else { helper_raise_exception(env, EXCP_RI); } break; case 4: if (!((env->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (rt == 0))) { return; } if (env->CP0_Config5 & (1 << CP0C5_UFR)) { env->CP0_Status |= (1 << CP0St_FR); compute_hflags(env); } else { helper_raise_exception(env, EXCP_RI); } break; case 25: if (arg1 & 0xffffff00) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0x017fffff) | ((arg1 & 0xfe) << 24) | ((arg1 & 0x1) << 23); break; case 26: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfffc0f83) | (arg1 & 0x0003f07c); break; case 28: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfefff07c) | (arg1 & 0x00000f83) | ((arg1 & 0x4) << 22); break; case 31: if (arg1 & 0x007c0000) return; env->active_fpu.fcr31 = arg1; break; default: return; } restore_rounding_mode(env); restore_flush_mode(env); set_float_exception_flags(0, &env->active_fpu.fp_status); if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31)) do_raise_exception(env, EXCP_FPE, GETPC()); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1, uint32_t VAR_2, uint32_t VAR_3) { switch (VAR_2) { case 1: if (!((VAR_0->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (VAR_3 == 0))) { return; } if (VAR_0->CP0_Config5 & (1 << CP0C5_UFR)) { VAR_0->CP0_Status &= ~(1 << CP0St_FR); compute_hflags(VAR_0); } else { helper_raise_exception(VAR_0, EXCP_RI); } break; case 4: if (!((VAR_0->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (VAR_3 == 0))) { return; } if (VAR_0->CP0_Config5 & (1 << CP0C5_UFR)) { VAR_0->CP0_Status |= (1 << CP0St_FR); compute_hflags(VAR_0); } else { helper_raise_exception(VAR_0, EXCP_RI); } break; case 25: if (VAR_1 & 0xffffff00) return; VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0x017fffff) | ((VAR_1 & 0xfe) << 24) | ((VAR_1 & 0x1) << 23); break; case 26: if (VAR_1 & 0x007c0000) return; VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0xfffc0f83) | (VAR_1 & 0x0003f07c); break; case 28: if (VAR_1 & 0x007c0000) return; VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0xfefff07c) | (VAR_1 & 0x00000f83) | ((VAR_1 & 0x4) << 22); break; case 31: if (VAR_1 & 0x007c0000) return; VAR_0->active_fpu.fcr31 = VAR_1; break; default: return; } restore_rounding_mode(VAR_0); restore_flush_mode(VAR_0); set_float_exception_flags(0, &VAR_0->active_fpu.fp_status); if ((GET_FP_ENABLE(VAR_0->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(VAR_0->active_fpu.fcr31)) do_raise_exception(VAR_0, EXCP_FPE, GETPC()); }
[ "void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1, uint32_t VAR_2, uint32_t VAR_3)\n{", "switch (VAR_2) {", "case 1:\nif (!((VAR_0->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (VAR_3 == 0))) {", "return;", "}", "if (VAR_0->CP0_Config5 & (1 << CP0C5_UFR)) {", "VAR_0->CP0_Status &= ~(1 << CP0St_FR);", "compute_hflags(VAR_0);", "} else {", "helper_raise_exception(VAR_0, EXCP_RI);", "}", "break;", "case 4:\nif (!((VAR_0->active_fpu.fcr0 & (1 << FCR0_UFRP)) && (VAR_3 == 0))) {", "return;", "}", "if (VAR_0->CP0_Config5 & (1 << CP0C5_UFR)) {", "VAR_0->CP0_Status |= (1 << CP0St_FR);", "compute_hflags(VAR_0);", "} else {", "helper_raise_exception(VAR_0, EXCP_RI);", "}", "break;", "case 25:\nif (VAR_1 & 0xffffff00)\nreturn;", "VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0x017fffff) | ((VAR_1 & 0xfe) << 24) |\n((VAR_1 & 0x1) << 23);", "break;", "case 26:\nif (VAR_1 & 0x007c0000)\nreturn;", "VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0xfffc0f83) | (VAR_1 & 0x0003f07c);", "break;", "case 28:\nif (VAR_1 & 0x007c0000)\nreturn;", "VAR_0->active_fpu.fcr31 = (VAR_0->active_fpu.fcr31 & 0xfefff07c) | (VAR_1 & 0x00000f83) |\n((VAR_1 & 0x4) << 22);", "break;", "case 31:\nif (VAR_1 & 0x007c0000)\nreturn;", "VAR_0->active_fpu.fcr31 = VAR_1;", "break;", "default:\nreturn;", "}", "restore_rounding_mode(VAR_0);", "restore_flush_mode(VAR_0);", "set_float_exception_flags(0, &VAR_0->active_fpu.fp_status);", "if ((GET_FP_ENABLE(VAR_0->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(VAR_0->active_fpu.fcr31))\ndo_raise_exception(VAR_0, EXCP_FPE, GETPC());", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57, 59 ], [ 61, 63 ], [ 65 ], [ 67, 69, 71 ], [ 73 ], [ 75 ], [ 77, 79, 81 ], [ 83, 85 ], [ 87 ], [ 89, 91, 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 107 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 119 ] ]
11,677
static void predictor_decode_stereo(APEContext *ctx, int count) { APEPredictor *p = &ctx->predictor; int32_t *decoded0 = ctx->decoded[0]; int32_t *decoded1 = ctx->decoded[1]; while (count--) { /* Predictor Y */ *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB); decoded0++; *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB); decoded1++; /* Combined */ p->buf++; /* Have we filled the history buffer? */ if (p->buf == p->historybuffer + HISTORY_SIZE) { memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(*p->historybuffer)); p->buf = p->historybuffer; } } }
false
FFmpeg
b164d66e35d349de414e2f0d7365a147aba8a620
static void predictor_decode_stereo(APEContext *ctx, int count) { APEPredictor *p = &ctx->predictor; int32_t *decoded0 = ctx->decoded[0]; int32_t *decoded1 = ctx->decoded[1]; while (count--) { *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB); decoded0++; *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB); decoded1++; p->buf++; if (p->buf == p->historybuffer + HISTORY_SIZE) { memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(*p->historybuffer)); p->buf = p->historybuffer; } } }
{ "code": [], "line_no": [] }
static void FUNC_0(APEContext *VAR_0, int VAR_1) { APEPredictor *p = &VAR_0->predictor; int32_t *decoded0 = VAR_0->decoded[0]; int32_t *decoded1 = VAR_0->decoded[1]; while (VAR_1--) { *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB); decoded0++; *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB); decoded1++; p->buf++; if (p->buf == p->historybuffer + HISTORY_SIZE) { memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(*p->historybuffer)); p->buf = p->historybuffer; } } }
[ "static void FUNC_0(APEContext *VAR_0, int VAR_1)\n{", "APEPredictor *p = &VAR_0->predictor;", "int32_t *decoded0 = VAR_0->decoded[0];", "int32_t *decoded1 = VAR_0->decoded[1];", "while (VAR_1--) {", "*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,\nYADAPTCOEFFSA, YADAPTCOEFFSB);", "decoded0++;", "*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,\nXADAPTCOEFFSA, XADAPTCOEFFSB);", "decoded1++;", "p->buf++;", "if (p->buf == p->historybuffer + HISTORY_SIZE) {", "memmove(p->historybuffer, p->buf,\nPREDICTOR_SIZE * sizeof(*p->historybuffer));", "p->buf = p->historybuffer;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17, 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 33 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
11,678
static bool rtas_event_log_contains(uint32_t event_mask, bool exception) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry = NULL; /* we only queue EPOW events atm. */ if ((event_mask & EVENT_MASK_EPOW) == 0) { return false; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { if (entry->exception != exception) { continue; } /* EPOW and hotplug events are surfaced in the same manner */ if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { return true; } } return false; }
false
qemu
ffbb1705a33df8e2fb12b24d96663d63b22eaf8b
static bool rtas_event_log_contains(uint32_t event_mask, bool exception) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry = NULL; if ((event_mask & EVENT_MASK_EPOW) == 0) { return false; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { if (entry->exception != exception) { continue; } if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { return true; } } return false; }
{ "code": [], "line_no": [] }
static bool FUNC_0(uint32_t event_mask, bool exception) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry = NULL; if ((event_mask & EVENT_MASK_EPOW) == 0) { return false; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { if (entry->exception != exception) { continue; } if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { return true; } } return false; }
[ "static bool FUNC_0(uint32_t event_mask, bool exception)\n{", "sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());", "sPAPREventLogEntry *entry = NULL;", "if ((event_mask & EVENT_MASK_EPOW) == 0) {", "return false;", "}", "QTAILQ_FOREACH(entry, &spapr->pending_events, next) {", "if (entry->exception != exception) {", "continue;", "}", "if (entry->log_type == RTAS_LOG_TYPE_EPOW ||\nentry->log_type == RTAS_LOG_TYPE_HOTPLUG) {", "return true;", "}", "}", "return false;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ] ]
11,679
void helper_ldq_raw(uint64_t t0, uint64_t t1) { ldq_raw(t1, t0); }
false
qemu
2374e73edafff0586cbfb67c333c5a7588f81fd5
void helper_ldq_raw(uint64_t t0, uint64_t t1) { ldq_raw(t1, t0); }
{ "code": [], "line_no": [] }
void FUNC_0(uint64_t VAR_0, uint64_t VAR_1) { ldq_raw(VAR_1, VAR_0); }
[ "void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)\n{", "ldq_raw(VAR_1, VAR_0);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,680
void qemu_bh_update_timeout(int *timeout) { QEMUBH *bh; for (bh = async_context->first_bh; bh; bh = bh->next) { if (!bh->deleted && bh->scheduled) { if (bh->idle) { /* idle bottom halves will be polled at least * every 10ms */ *timeout = MIN(10, *timeout); } else { /* non-idle bottom halves will be executed * immediately */ *timeout = 0; break; } } } }
false
qemu
384acbf46b70edf0d2c1648aa1a92a90bcf7057d
void qemu_bh_update_timeout(int *timeout) { QEMUBH *bh; for (bh = async_context->first_bh; bh; bh = bh->next) { if (!bh->deleted && bh->scheduled) { if (bh->idle) { *timeout = MIN(10, *timeout); } else { *timeout = 0; break; } } } }
{ "code": [], "line_no": [] }
void FUNC_0(int *VAR_0) { QEMUBH *bh; for (bh = async_context->first_bh; bh; bh = bh->next) { if (!bh->deleted && bh->scheduled) { if (bh->idle) { *VAR_0 = MIN(10, *VAR_0); } else { *VAR_0 = 0; break; } } } }
[ "void FUNC_0(int *VAR_0)\n{", "QEMUBH *bh;", "for (bh = async_context->first_bh; bh; bh = bh->next) {", "if (!bh->deleted && bh->scheduled) {", "if (bh->idle) {", "*VAR_0 = MIN(10, *VAR_0);", "} else {", "*VAR_0 = 0;", "break;", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ] ]
11,681
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq, int kvm_enabled) { PCIDevice *dev; PIIX4PMState *s; dev = pci_create(bus, devfn, "PIIX4_PM"); qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base); s = DO_UPCAST(PIIX4PMState, dev, dev); s->irq = sci_irq; acpi_pm1_cnt_init(&s->ar, cmos_s3); s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; qdev_init_nofail(&dev->qdev); return s->smb.smbus; }
false
qemu
da98c8eb4c35225049cad8cf767647eb39788b5d
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq, int kvm_enabled) { PCIDevice *dev; PIIX4PMState *s; dev = pci_create(bus, devfn, "PIIX4_PM"); qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base); s = DO_UPCAST(PIIX4PMState, dev, dev); s->irq = sci_irq; acpi_pm1_cnt_init(&s->ar, cmos_s3); s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; qdev_init_nofail(&dev->qdev); return s->smb.smbus; }
{ "code": [], "line_no": [] }
i2c_bus *FUNC_0(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq, int kvm_enabled) { PCIDevice *dev; PIIX4PMState *s; dev = pci_create(bus, devfn, "PIIX4_PM"); qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base); s = DO_UPCAST(PIIX4PMState, dev, dev); s->irq = sci_irq; acpi_pm1_cnt_init(&s->ar, cmos_s3); s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; qdev_init_nofail(&dev->qdev); return s->smb.smbus; }
[ "i2c_bus *FUNC_0(PCIBus *bus, int devfn, uint32_t smb_io_base,\nqemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,\nint kvm_enabled)\n{", "PCIDevice *dev;", "PIIX4PMState *s;", "dev = pci_create(bus, devfn, \"PIIX4_PM\");", "qdev_prop_set_uint32(&dev->qdev, \"smb_io_base\", smb_io_base);", "s = DO_UPCAST(PIIX4PMState, dev, dev);", "s->irq = sci_irq;", "acpi_pm1_cnt_init(&s->ar, cmos_s3);", "s->smi_irq = smi_irq;", "s->kvm_enabled = kvm_enabled;", "qdev_init_nofail(&dev->qdev);", "return s->smb.smbus;", "}" ]
[ 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 ], [ 33 ], [ 37 ], [ 39 ] ]
11,682
static int get_phys_addr_v6(CPUARMState *env, uint32_t address, int access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, target_ulong *page_size) { CPUState *cs = CPU(arm_env_get_cpu(env)); int code; uint32_t table; uint32_t desc; uint32_t xn; uint32_t pxn = 0; int type; int ap; int domain = 0; int domain_prot; hwaddr phys_addr; uint32_t dacr; /* Pagetable walk. */ /* Lookup l1 descriptor. */ if (!get_level1_table_address(env, mmu_idx, &table, address)) { /* Section translation fault if page walk is disabled by PD0 or PD1 */ code = 5; goto do_fault; } desc = ldl_phys(cs->as, table); type = (desc & 3); if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) { /* Section translation fault, or attempt to use the encoding * which is Reserved on implementations without PXN. */ code = 5; goto do_fault; } if ((type == 1) || !(desc & (1 << 18))) { /* Page or Section. */ domain = (desc >> 5) & 0x0f; } if (regime_el(env, mmu_idx) == 1) { dacr = env->cp15.dacr_ns; } else { dacr = env->cp15.dacr_s; } domain_prot = (dacr >> (domain * 2)) & 3; if (domain_prot == 0 || domain_prot == 2) { if (type != 1) { code = 9; /* Section domain fault. */ } else { code = 11; /* Page domain fault. */ } goto do_fault; } if (type != 1) { if (desc & (1 << 18)) { /* Supersection. */ phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); *page_size = 0x1000000; } else { /* Section. */ phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); *page_size = 0x100000; } ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); xn = desc & (1 << 4); pxn = desc & 1; code = 13; } else { if (arm_feature(env, ARM_FEATURE_PXN)) { pxn = (desc >> 2) & 1; } /* Lookup l2 entry. */ table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); desc = ldl_phys(cs->as, table); ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); switch (desc & 3) { case 0: /* Page translation fault. */ code = 7; goto do_fault; case 1: /* 64k page. */ phys_addr = (desc & 0xffff0000) | (address & 0xffff); xn = desc & (1 << 15); *page_size = 0x10000; break; case 2: case 3: /* 4k page. */ phys_addr = (desc & 0xfffff000) | (address & 0xfff); xn = desc & 1; *page_size = 0x1000; break; default: /* Never happens, but compiler isn't smart enough to tell. */ abort(); } code = 15; } if (domain_prot == 3) { *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { if (pxn && !regime_is_user(env, mmu_idx)) { xn = 1; } if (xn && access_type == 2) goto do_fault; /* The simplified model uses AP[0] as an access control bit. */ if ((regime_sctlr(env, mmu_idx) & SCTLR_AFE) && (ap & 1) == 0) { /* Access flag fault. */ code = (code == 15) ? 6 : 3; goto do_fault; } *prot = check_ap(env, mmu_idx, ap, domain_prot, access_type); if (!*prot) { /* Access permission fault. */ goto do_fault; } if (!xn) { *prot |= PAGE_EXEC; } } *phys_ptr = phys_addr; return 0; do_fault: return code | (domain << 4); }
false
qemu
0fbf5238203041f734c51b49778223686f14366b
static int get_phys_addr_v6(CPUARMState *env, uint32_t address, int access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, target_ulong *page_size) { CPUState *cs = CPU(arm_env_get_cpu(env)); int code; uint32_t table; uint32_t desc; uint32_t xn; uint32_t pxn = 0; int type; int ap; int domain = 0; int domain_prot; hwaddr phys_addr; uint32_t dacr; if (!get_level1_table_address(env, mmu_idx, &table, address)) { code = 5; goto do_fault; } desc = ldl_phys(cs->as, table); type = (desc & 3); if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) { code = 5; goto do_fault; } if ((type == 1) || !(desc & (1 << 18))) { domain = (desc >> 5) & 0x0f; } if (regime_el(env, mmu_idx) == 1) { dacr = env->cp15.dacr_ns; } else { dacr = env->cp15.dacr_s; } domain_prot = (dacr >> (domain * 2)) & 3; if (domain_prot == 0 || domain_prot == 2) { if (type != 1) { code = 9; } else { code = 11; } goto do_fault; } if (type != 1) { if (desc & (1 << 18)) { phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); *page_size = 0x1000000; } else { phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); *page_size = 0x100000; } ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); xn = desc & (1 << 4); pxn = desc & 1; code = 13; } else { if (arm_feature(env, ARM_FEATURE_PXN)) { pxn = (desc >> 2) & 1; } table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); desc = ldl_phys(cs->as, table); ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); switch (desc & 3) { case 0: code = 7; goto do_fault; case 1: phys_addr = (desc & 0xffff0000) | (address & 0xffff); xn = desc & (1 << 15); *page_size = 0x10000; break; case 2: case 3: phys_addr = (desc & 0xfffff000) | (address & 0xfff); xn = desc & 1; *page_size = 0x1000; break; default: abort(); } code = 15; } if (domain_prot == 3) { *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { if (pxn && !regime_is_user(env, mmu_idx)) { xn = 1; } if (xn && access_type == 2) goto do_fault; if ((regime_sctlr(env, mmu_idx) & SCTLR_AFE) && (ap & 1) == 0) { code = (code == 15) ? 6 : 3; goto do_fault; } *prot = check_ap(env, mmu_idx, ap, domain_prot, access_type); if (!*prot) { goto do_fault; } if (!xn) { *prot |= PAGE_EXEC; } } *phys_ptr = phys_addr; return 0; do_fault: return code | (domain << 4); }
{ "code": [], "line_no": [] }
static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1, int VAR_2, ARMMMUIdx VAR_3, hwaddr *VAR_4, int *VAR_5, target_ulong *VAR_6) { CPUState *cs = CPU(arm_env_get_cpu(VAR_0)); int VAR_7; uint32_t table; uint32_t desc; uint32_t xn; uint32_t pxn = 0; int VAR_8; int VAR_9; int VAR_10 = 0; int VAR_11; hwaddr phys_addr; uint32_t dacr; if (!get_level1_table_address(VAR_0, VAR_3, &table, VAR_1)) { VAR_7 = 5; goto do_fault; } desc = ldl_phys(cs->as, table); VAR_8 = (desc & 3); if (VAR_8 == 0 || (VAR_8 == 3 && !arm_feature(VAR_0, ARM_FEATURE_PXN))) { VAR_7 = 5; goto do_fault; } if ((VAR_8 == 1) || !(desc & (1 << 18))) { VAR_10 = (desc >> 5) & 0x0f; } if (regime_el(VAR_0, VAR_3) == 1) { dacr = VAR_0->cp15.dacr_ns; } else { dacr = VAR_0->cp15.dacr_s; } VAR_11 = (dacr >> (VAR_10 * 2)) & 3; if (VAR_11 == 0 || VAR_11 == 2) { if (VAR_8 != 1) { VAR_7 = 9; } else { VAR_7 = 11; } goto do_fault; } if (VAR_8 != 1) { if (desc & (1 << 18)) { phys_addr = (desc & 0xff000000) | (VAR_1 & 0x00ffffff); *VAR_6 = 0x1000000; } else { phys_addr = (desc & 0xfff00000) | (VAR_1 & 0x000fffff); *VAR_6 = 0x100000; } VAR_9 = ((desc >> 10) & 3) | ((desc >> 13) & 4); xn = desc & (1 << 4); pxn = desc & 1; VAR_7 = 13; } else { if (arm_feature(VAR_0, ARM_FEATURE_PXN)) { pxn = (desc >> 2) & 1; } table = (desc & 0xfffffc00) | ((VAR_1 >> 10) & 0x3fc); desc = ldl_phys(cs->as, table); VAR_9 = ((desc >> 4) & 3) | ((desc >> 7) & 4); switch (desc & 3) { case 0: VAR_7 = 7; goto do_fault; case 1: phys_addr = (desc & 0xffff0000) | (VAR_1 & 0xffff); xn = desc & (1 << 15); *VAR_6 = 0x10000; break; case 2: case 3: phys_addr = (desc & 0xfffff000) | (VAR_1 & 0xfff); xn = desc & 1; *VAR_6 = 0x1000; break; default: abort(); } VAR_7 = 15; } if (VAR_11 == 3) { *VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { if (pxn && !regime_is_user(VAR_0, VAR_3)) { xn = 1; } if (xn && VAR_2 == 2) goto do_fault; if ((regime_sctlr(VAR_0, VAR_3) & SCTLR_AFE) && (VAR_9 & 1) == 0) { VAR_7 = (VAR_7 == 15) ? 6 : 3; goto do_fault; } *VAR_5 = check_ap(VAR_0, VAR_3, VAR_9, VAR_11, VAR_2); if (!*VAR_5) { goto do_fault; } if (!xn) { *VAR_5 |= PAGE_EXEC; } } *VAR_4 = phys_addr; return 0; do_fault: return VAR_7 | (VAR_10 << 4); }
[ "static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1, int VAR_2,\nARMMMUIdx VAR_3, hwaddr *VAR_4,\nint *VAR_5, target_ulong *VAR_6)\n{", "CPUState *cs = CPU(arm_env_get_cpu(VAR_0));", "int VAR_7;", "uint32_t table;", "uint32_t desc;", "uint32_t xn;", "uint32_t pxn = 0;", "int VAR_8;", "int VAR_9;", "int VAR_10 = 0;", "int VAR_11;", "hwaddr phys_addr;", "uint32_t dacr;", "if (!get_level1_table_address(VAR_0, VAR_3, &table, VAR_1)) {", "VAR_7 = 5;", "goto do_fault;", "}", "desc = ldl_phys(cs->as, table);", "VAR_8 = (desc & 3);", "if (VAR_8 == 0 || (VAR_8 == 3 && !arm_feature(VAR_0, ARM_FEATURE_PXN))) {", "VAR_7 = 5;", "goto do_fault;", "}", "if ((VAR_8 == 1) || !(desc & (1 << 18))) {", "VAR_10 = (desc >> 5) & 0x0f;", "}", "if (regime_el(VAR_0, VAR_3) == 1) {", "dacr = VAR_0->cp15.dacr_ns;", "} else {", "dacr = VAR_0->cp15.dacr_s;", "}", "VAR_11 = (dacr >> (VAR_10 * 2)) & 3;", "if (VAR_11 == 0 || VAR_11 == 2) {", "if (VAR_8 != 1) {", "VAR_7 = 9;", "} else {", "VAR_7 = 11;", "}", "goto do_fault;", "}", "if (VAR_8 != 1) {", "if (desc & (1 << 18)) {", "phys_addr = (desc & 0xff000000) | (VAR_1 & 0x00ffffff);", "*VAR_6 = 0x1000000;", "} else {", "phys_addr = (desc & 0xfff00000) | (VAR_1 & 0x000fffff);", "*VAR_6 = 0x100000;", "}", "VAR_9 = ((desc >> 10) & 3) | ((desc >> 13) & 4);", "xn = desc & (1 << 4);", "pxn = desc & 1;", "VAR_7 = 13;", "} else {", "if (arm_feature(VAR_0, ARM_FEATURE_PXN)) {", "pxn = (desc >> 2) & 1;", "}", "table = (desc & 0xfffffc00) | ((VAR_1 >> 10) & 0x3fc);", "desc = ldl_phys(cs->as, table);", "VAR_9 = ((desc >> 4) & 3) | ((desc >> 7) & 4);", "switch (desc & 3) {", "case 0:\nVAR_7 = 7;", "goto do_fault;", "case 1:\nphys_addr = (desc & 0xffff0000) | (VAR_1 & 0xffff);", "xn = desc & (1 << 15);", "*VAR_6 = 0x10000;", "break;", "case 2: case 3:\nphys_addr = (desc & 0xfffff000) | (VAR_1 & 0xfff);", "xn = desc & 1;", "*VAR_6 = 0x1000;", "break;", "default:\nabort();", "}", "VAR_7 = 15;", "}", "if (VAR_11 == 3) {", "*VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;", "} else {", "if (pxn && !regime_is_user(VAR_0, VAR_3)) {", "xn = 1;", "}", "if (xn && VAR_2 == 2)\ngoto do_fault;", "if ((regime_sctlr(VAR_0, VAR_3) & SCTLR_AFE)\n&& (VAR_9 & 1) == 0) {", "VAR_7 = (VAR_7 == 15) ? 6 : 3;", "goto do_fault;", "}", "*VAR_5 = check_ap(VAR_0, VAR_3, VAR_9, VAR_11, VAR_2);", "if (!*VAR_5) {", "goto do_fault;", "}", "if (!xn) {", "*VAR_5 |= PAGE_EXEC;", "}", "}", "*VAR_4 = phys_addr;", "return 0;", "do_fault:\nreturn VAR_7 | (VAR_10 << 4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199, 201 ], [ 207, 209 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241, 243 ], [ 245 ] ]
11,684
static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) { uint8_t buf[1024]; VHDFooter *footer = (VHDFooter *) buf; char *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int disk_type; int ret = -EIO; bool nocow = false; /* Read out options */ total_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0); disk_type_param = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); if (disk_type_param) { if (!strcmp(disk_type_param, "dynamic")) { disk_type = VHD_DYNAMIC; } else if (!strcmp(disk_type_param, "fixed")) { disk_type = VHD_FIXED; } else { ret = -EINVAL; goto out; } } else { disk_type = VHD_DYNAMIC; } nocow = qemu_opt_get_bool_del(opts, BLOCK_OPT_NOCOW, false); /* Create the file */ fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { ret = -EIO; goto out; } if (nocow) { #ifdef __linux__ /* Set NOCOW flag to solve performance issue on fs like btrfs. * This is an optimisation. The FS_IOC_SETFLAGS ioctl return value will * be ignored since any failure of this operation should not block the * left work. */ int attr; if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; ioctl(fd, FS_IOC_SETFLAGS, &attr); } #endif } /* * Calculate matching total_size and geometry. Increase the number of * sectors requested until we get enough (or fail). This ensures that * qemu-img convert doesn't truncate images, but rather rounds up. */ total_sectors = total_size / BDRV_SECTOR_SIZE; for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { if (calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl)) { ret = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; /* Prepare the Hard Disk Footer */ memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); /* TODO Check if "qemu" creator_app is ok for VPC */ memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (disk_type == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); /* Version of Virtual PC 2007 */ footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (disk_type == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(disk_type); #if defined(CONFIG_UUID) uuid_generate(footer->uuid); #endif footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(fd, buf, total_sectors); } else { ret = create_fixed_disk(fd, buf, total_size); } fail: qemu_close(fd); out: g_free(disk_type_param); return ret; }
false
qemu
fef6070eff233400015cede968b0afe46c80bb0f
static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) { uint8_t buf[1024]; VHDFooter *footer = (VHDFooter *) buf; char *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int disk_type; int ret = -EIO; bool nocow = false; total_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0); disk_type_param = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); if (disk_type_param) { if (!strcmp(disk_type_param, "dynamic")) { disk_type = VHD_DYNAMIC; } else if (!strcmp(disk_type_param, "fixed")) { disk_type = VHD_FIXED; } else { ret = -EINVAL; goto out; } } else { disk_type = VHD_DYNAMIC; } nocow = qemu_opt_get_bool_del(opts, BLOCK_OPT_NOCOW, false); fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { ret = -EIO; goto out; } if (nocow) { #ifdef __linux__ int attr; if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; ioctl(fd, FS_IOC_SETFLAGS, &attr); } #endif } total_sectors = total_size / BDRV_SECTOR_SIZE; for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { if (calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl)) { ret = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (disk_type == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (disk_type == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(disk_type); #if defined(CONFIG_UUID) uuid_generate(footer->uuid); #endif footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(fd, buf, total_sectors); } else { ret = create_fixed_disk(fd, buf, total_size); } fail: qemu_close(fd); out: g_free(disk_type_param); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2) { uint8_t buf[1024]; VHDFooter *footer = (VHDFooter *) buf; char *VAR_3; int VAR_4, VAR_5; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int VAR_6; int VAR_7 = -EIO; bool nocow = false; total_size = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0); VAR_3 = qemu_opt_get_del(VAR_1, BLOCK_OPT_SUBFMT); if (VAR_3) { if (!strcmp(VAR_3, "dynamic")) { VAR_6 = VHD_DYNAMIC; } else if (!strcmp(VAR_3, "fixed")) { VAR_6 = VHD_FIXED; } else { VAR_7 = -EINVAL; goto out; } } else { VAR_6 = VHD_DYNAMIC; } nocow = qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_NOCOW, false); VAR_4 = qemu_open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (VAR_4 < 0) { VAR_7 = -EIO; goto out; } if (nocow) { #ifdef __linux__ int attr; if (ioctl(VAR_4, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; ioctl(VAR_4, FS_IOC_SETFLAGS, &attr); } #endif } total_sectors = total_size / BDRV_SECTOR_SIZE; for (VAR_5 = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; VAR_5++) { if (calculate_geometry(total_sectors + VAR_5, &cyls, &heads, &secs_per_cyl)) { VAR_7 = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (VAR_6 == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (VAR_6 == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(VAR_6); #if defined(CONFIG_UUID) uuid_generate(footer->uuid); #endif footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (VAR_6 == VHD_DYNAMIC) { VAR_7 = create_dynamic_disk(VAR_4, buf, total_sectors); } else { VAR_7 = create_fixed_disk(VAR_4, buf, total_size); } fail: qemu_close(VAR_4); out: g_free(VAR_3); return VAR_7; }
[ "static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{", "uint8_t buf[1024];", "VHDFooter *footer = (VHDFooter *) buf;", "char *VAR_3;", "int VAR_4, VAR_5;", "uint16_t cyls = 0;", "uint8_t heads = 0;", "uint8_t secs_per_cyl = 0;", "int64_t total_sectors;", "int64_t total_size;", "int VAR_6;", "int VAR_7 = -EIO;", "bool nocow = false;", "total_size = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0);", "VAR_3 = qemu_opt_get_del(VAR_1, BLOCK_OPT_SUBFMT);", "if (VAR_3) {", "if (!strcmp(VAR_3, \"dynamic\")) {", "VAR_6 = VHD_DYNAMIC;", "} else if (!strcmp(VAR_3, \"fixed\")) {", "VAR_6 = VHD_FIXED;", "} else {", "VAR_7 = -EINVAL;", "goto out;", "}", "} else {", "VAR_6 = VHD_DYNAMIC;", "}", "nocow = qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_NOCOW, false);", "VAR_4 = qemu_open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);", "if (VAR_4 < 0) {", "VAR_7 = -EIO;", "goto out;", "}", "if (nocow) {", "#ifdef __linux__\nint attr;", "if (ioctl(VAR_4, FS_IOC_GETFLAGS, &attr) == 0) {", "attr |= FS_NOCOW_FL;", "ioctl(VAR_4, FS_IOC_SETFLAGS, &attr);", "}", "#endif\n}", "total_sectors = total_size / BDRV_SECTOR_SIZE;", "for (VAR_5 = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; VAR_5++) {", "if (calculate_geometry(total_sectors + VAR_5, &cyls, &heads,\n&secs_per_cyl))\n{", "VAR_7 = -EFBIG;", "goto fail;", "}", "}", "total_sectors = (int64_t) cyls * heads * secs_per_cyl;", "memset(buf, 0, 1024);", "memcpy(footer->creator, \"conectix\", 8);", "memcpy(footer->creator_app, \"qemu\", 4);", "memcpy(footer->creator_os, \"Wi2k\", 4);", "footer->features = be32_to_cpu(0x02);", "footer->version = be32_to_cpu(0x00010000);", "if (VAR_6 == VHD_DYNAMIC) {", "footer->data_offset = be64_to_cpu(HEADER_SIZE);", "} else {", "footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL);", "}", "footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE);", "footer->major = be16_to_cpu(0x0005);", "footer->minor = be16_to_cpu(0x0003);", "if (VAR_6 == VHD_DYNAMIC) {", "footer->orig_size = be64_to_cpu(total_sectors * 512);", "footer->size = be64_to_cpu(total_sectors * 512);", "} else {", "footer->orig_size = be64_to_cpu(total_size);", "footer->size = be64_to_cpu(total_size);", "}", "footer->cyls = be16_to_cpu(cyls);", "footer->heads = heads;", "footer->secs_per_cyl = secs_per_cyl;", "footer->type = be32_to_cpu(VAR_6);", "#if defined(CONFIG_UUID)\nuuid_generate(footer->uuid);", "#endif\nfooter->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));", "if (VAR_6 == VHD_DYNAMIC) {", "VAR_7 = create_dynamic_disk(VAR_4, buf, total_sectors);", "} else {", "VAR_7 = create_fixed_disk(VAR_4, buf, total_size);", "}", "fail:\nqemu_close(VAR_4);", "out:\ng_free(VAR_3);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 119 ], [ 121 ], [ 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 145 ], [ 149 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 205 ], [ 209, 211 ], [ 213, 217 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 233, 235 ], [ 237, 239 ], [ 241 ], [ 243 ] ]
11,686
static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate) { int64_t now; int64_t ticks; int64_t bytes; int64_t samples; now = qemu_get_clock (vm_clock); ticks = now - rate->start_ticks; bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ()); samples = (bytes - rate->bytes_sent) >> info->shift; if (samples < 0 || samples > 65536) { fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples); rate_start (rate); samples = 0; } rate->bytes_sent += samples << info->shift; return samples; }
false
qemu
74475455442398a64355428b37422d14ccc293cb
static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate) { int64_t now; int64_t ticks; int64_t bytes; int64_t samples; now = qemu_get_clock (vm_clock); ticks = now - rate->start_ticks; bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ()); samples = (bytes - rate->bytes_sent) >> info->shift; if (samples < 0 || samples > 65536) { fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples); rate_start (rate); samples = 0; } rate->bytes_sent += samples << info->shift; return samples; }
{ "code": [], "line_no": [] }
static int FUNC_0 (struct audio_pcm_info *VAR_0, SpiceRateCtl *VAR_1) { int64_t now; int64_t ticks; int64_t bytes; int64_t samples; now = qemu_get_clock (vm_clock); ticks = now - VAR_1->start_ticks; bytes = muldiv64 (ticks, VAR_0->bytes_per_second, get_ticks_per_sec ()); samples = (bytes - VAR_1->bytes_sent) >> VAR_0->shift; if (samples < 0 || samples > 65536) { fprintf (stderr, "Resetting VAR_1 control (%" PRId64 " samples)\n", samples); rate_start (VAR_1); samples = 0; } VAR_1->bytes_sent += samples << VAR_0->shift; return samples; }
[ "static int FUNC_0 (struct audio_pcm_info *VAR_0, SpiceRateCtl *VAR_1)\n{", "int64_t now;", "int64_t ticks;", "int64_t bytes;", "int64_t samples;", "now = qemu_get_clock (vm_clock);", "ticks = now - VAR_1->start_ticks;", "bytes = muldiv64 (ticks, VAR_0->bytes_per_second, get_ticks_per_sec ());", "samples = (bytes - VAR_1->bytes_sent) >> VAR_0->shift;", "if (samples < 0 || samples > 65536) {", "fprintf (stderr, \"Resetting VAR_1 control (%\" PRId64 \" samples)\\n\", samples);", "rate_start (VAR_1);", "samples = 0;", "}", "VAR_1->bytes_sent += samples << VAR_0->shift;", "return samples;", "}" ]
[ 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 ] ]
11,689
static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestOutputVisitorData *VAR_0, const void *VAR_1) { test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_U8); }
[ "static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_U8);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
11,690
static int alsa_run_out (HWVoiceOut *hw) { ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw; int rpos, live, decr; int samples; uint8_t *dst; st_sample_t *src; snd_pcm_sframes_t avail; live = audio_pcm_hw_get_live_out (hw); if (!live) { return 0; } avail = alsa_get_avail (alsa->handle); if (avail < 0) { dolog ("Could not get number of available playback frames\n"); return 0; } decr = audio_MIN (live, avail); samples = decr; rpos = hw->rpos; while (samples) { int left_till_end_samples = hw->samples - rpos; int len = audio_MIN (samples, left_till_end_samples); snd_pcm_sframes_t written; src = hw->mix_buf + rpos; dst = advance (alsa->pcm_buf, rpos << hw->info.shift); hw->clip (dst, src, len); while (len) { written = snd_pcm_writei (alsa->handle, dst, len); if (written <= 0) { switch (written) { case 0: if (conf.verbose) { dolog ("Failed to write %d frames (wrote zero)\n", len); } goto exit; case -EPIPE: if (alsa_recover (alsa->handle)) { alsa_logerr (written, "Failed to write %d frames\n", len); goto exit; } if (conf.verbose) { dolog ("Recovering from playback xrun\n"); } continue; case -EAGAIN: goto exit; default: alsa_logerr (written, "Failed to write %d frames to %p\n", len, dst); goto exit; } } rpos = (rpos + written) % hw->samples; samples -= written; len -= written; dst = advance (dst, written << hw->info.shift); src += written; } } exit: hw->rpos = rpos; return decr; }
false
qemu
1ea879e5580f63414693655fcf0328559cdce138
static int alsa_run_out (HWVoiceOut *hw) { ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw; int rpos, live, decr; int samples; uint8_t *dst; st_sample_t *src; snd_pcm_sframes_t avail; live = audio_pcm_hw_get_live_out (hw); if (!live) { return 0; } avail = alsa_get_avail (alsa->handle); if (avail < 0) { dolog ("Could not get number of available playback frames\n"); return 0; } decr = audio_MIN (live, avail); samples = decr; rpos = hw->rpos; while (samples) { int left_till_end_samples = hw->samples - rpos; int len = audio_MIN (samples, left_till_end_samples); snd_pcm_sframes_t written; src = hw->mix_buf + rpos; dst = advance (alsa->pcm_buf, rpos << hw->info.shift); hw->clip (dst, src, len); while (len) { written = snd_pcm_writei (alsa->handle, dst, len); if (written <= 0) { switch (written) { case 0: if (conf.verbose) { dolog ("Failed to write %d frames (wrote zero)\n", len); } goto exit; case -EPIPE: if (alsa_recover (alsa->handle)) { alsa_logerr (written, "Failed to write %d frames\n", len); goto exit; } if (conf.verbose) { dolog ("Recovering from playback xrun\n"); } continue; case -EAGAIN: goto exit; default: alsa_logerr (written, "Failed to write %d frames to %p\n", len, dst); goto exit; } } rpos = (rpos + written) % hw->samples; samples -= written; len -= written; dst = advance (dst, written << hw->info.shift); src += written; } } exit: hw->rpos = rpos; return decr; }
{ "code": [], "line_no": [] }
static int FUNC_0 (HWVoiceOut *VAR_0) { ALSAVoiceOut *alsa = (ALSAVoiceOut *) VAR_0; int VAR_1, VAR_2, VAR_3; int VAR_4; uint8_t *dst; st_sample_t *src; snd_pcm_sframes_t avail; VAR_2 = audio_pcm_hw_get_live_out (VAR_0); if (!VAR_2) { return 0; } avail = alsa_get_avail (alsa->handle); if (avail < 0) { dolog ("Could not get number of available playback frames\n"); return 0; } VAR_3 = audio_MIN (VAR_2, avail); VAR_4 = VAR_3; VAR_1 = VAR_0->VAR_1; while (VAR_4) { int VAR_5 = VAR_0->VAR_4 - VAR_1; int VAR_6 = audio_MIN (VAR_4, VAR_5); snd_pcm_sframes_t written; src = VAR_0->mix_buf + VAR_1; dst = advance (alsa->pcm_buf, VAR_1 << VAR_0->info.shift); VAR_0->clip (dst, src, VAR_6); while (VAR_6) { written = snd_pcm_writei (alsa->handle, dst, VAR_6); if (written <= 0) { switch (written) { case 0: if (conf.verbose) { dolog ("Failed to write %d frames (wrote zero)\n", VAR_6); } goto exit; case -EPIPE: if (alsa_recover (alsa->handle)) { alsa_logerr (written, "Failed to write %d frames\n", VAR_6); goto exit; } if (conf.verbose) { dolog ("Recovering from playback xrun\n"); } continue; case -EAGAIN: goto exit; default: alsa_logerr (written, "Failed to write %d frames to %p\n", VAR_6, dst); goto exit; } } VAR_1 = (VAR_1 + written) % VAR_0->VAR_4; VAR_4 -= written; VAR_6 -= written; dst = advance (dst, written << VAR_0->info.shift); src += written; } } exit: VAR_0->VAR_1 = VAR_1; return VAR_3; }
[ "static int FUNC_0 (HWVoiceOut *VAR_0)\n{", "ALSAVoiceOut *alsa = (ALSAVoiceOut *) VAR_0;", "int VAR_1, VAR_2, VAR_3;", "int VAR_4;", "uint8_t *dst;", "st_sample_t *src;", "snd_pcm_sframes_t avail;", "VAR_2 = audio_pcm_hw_get_live_out (VAR_0);", "if (!VAR_2) {", "return 0;", "}", "avail = alsa_get_avail (alsa->handle);", "if (avail < 0) {", "dolog (\"Could not get number of available playback frames\\n\");", "return 0;", "}", "VAR_3 = audio_MIN (VAR_2, avail);", "VAR_4 = VAR_3;", "VAR_1 = VAR_0->VAR_1;", "while (VAR_4) {", "int VAR_5 = VAR_0->VAR_4 - VAR_1;", "int VAR_6 = audio_MIN (VAR_4, VAR_5);", "snd_pcm_sframes_t written;", "src = VAR_0->mix_buf + VAR_1;", "dst = advance (alsa->pcm_buf, VAR_1 << VAR_0->info.shift);", "VAR_0->clip (dst, src, VAR_6);", "while (VAR_6) {", "written = snd_pcm_writei (alsa->handle, dst, VAR_6);", "if (written <= 0) {", "switch (written) {", "case 0:\nif (conf.verbose) {", "dolog (\"Failed to write %d frames (wrote zero)\\n\", VAR_6);", "}", "goto exit;", "case -EPIPE:\nif (alsa_recover (alsa->handle)) {", "alsa_logerr (written, \"Failed to write %d frames\\n\",\nVAR_6);", "goto exit;", "}", "if (conf.verbose) {", "dolog (\"Recovering from playback xrun\\n\");", "}", "continue;", "case -EAGAIN:\ngoto exit;", "default:\nalsa_logerr (written, \"Failed to write %d frames to %p\\n\",\nVAR_6, dst);", "goto exit;", "}", "}", "VAR_1 = (VAR_1 + written) % VAR_0->VAR_4;", "VAR_4 -= written;", "VAR_6 -= written;", "dst = advance (dst, written << VAR_0->info.shift);", "src += written;", "}", "}", "exit:\nVAR_0->VAR_1 = VAR_1;", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89, 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 117, 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147, 149 ], [ 151 ], [ 153 ] ]
11,694
static int local_symlink(FsContext *ctx, const char *oldpath, const char *newpath) { return symlink(oldpath, rpath(ctx, newpath)); }
false
qemu
879c28133dfa54b780dffbb29e4dcfc6581f6281
static int local_symlink(FsContext *ctx, const char *oldpath, const char *newpath) { return symlink(oldpath, rpath(ctx, newpath)); }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, const char *VAR_1, const char *VAR_2) { return symlink(VAR_1, rpath(VAR_0, VAR_2)); }
[ "static int FUNC_0(FsContext *VAR_0, const char *VAR_1,\nconst char *VAR_2)\n{", "return symlink(VAR_1, rpath(VAR_0, VAR_2));", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
11,695
static void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUX86State *env) { abi_ulong frame_addr, addr; struct rt_sigframe *frame; int i, err = 0; frame_addr = get_sigframe(ka, env, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; __put_user(current_exec_domain_sig(sig), &frame->sig); addr = frame_addr + offsetof(struct rt_sigframe, info); __put_user(addr, &frame->pinfo); addr = frame_addr + offsetof(struct rt_sigframe, uc); __put_user(addr, &frame->puc); copy_siginfo_to_user(&frame->info, info); /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &frame->uc.tuc_stack.ss_flags); __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size); setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); for(i = 0; i < TARGET_NSIG_WORDS; i++) { if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) goto give_sigsegv; } /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { uint16_t val16; addr = frame_addr + offsetof(struct rt_sigframe, retcode); __put_user(addr, &frame->pretcode); /* This is movl $,%eax ; int $0x80 */ __put_user(0xb8, (char *)(frame->retcode+0)); __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); val16 = 0x80cd; __put_user(val16, (uint16_t *)(frame->retcode+5)); } if (err) goto give_sigsegv; /* Set up registers for signal handler */ env->regs[R_ESP] = frame_addr; env->eip = ka->_sa_handler; cpu_x86_load_seg(env, R_DS, __USER_DS); cpu_x86_load_seg(env, R_ES, __USER_DS); cpu_x86_load_seg(env, R_SS, __USER_DS); cpu_x86_load_seg(env, R_CS, __USER_CS); env->eflags &= ~TF_MASK; unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); if (sig == TARGET_SIGSEGV) ka->_sa_handler = TARGET_SIG_DFL; force_sig(TARGET_SIGSEGV /* , current */); }
true
qemu
0188fadb7fe460d8c4c743372b1f7b25773e183e
static void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUX86State *env) { abi_ulong frame_addr, addr; struct rt_sigframe *frame; int i, err = 0; frame_addr = get_sigframe(ka, env, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; __put_user(current_exec_domain_sig(sig), &frame->sig); addr = frame_addr + offsetof(struct rt_sigframe, info); __put_user(addr, &frame->pinfo); addr = frame_addr + offsetof(struct rt_sigframe, uc); __put_user(addr, &frame->puc); copy_siginfo_to_user(&frame->info, info); __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &frame->uc.tuc_stack.ss_flags); __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size); setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); for(i = 0; i < TARGET_NSIG_WORDS; i++) { if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) goto give_sigsegv; } if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { uint16_t val16; addr = frame_addr + offsetof(struct rt_sigframe, retcode); __put_user(addr, &frame->pretcode); __put_user(0xb8, (char *)(frame->retcode+0)); __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); val16 = 0x80cd; __put_user(val16, (uint16_t *)(frame->retcode+5)); } if (err) goto give_sigsegv; env->regs[R_ESP] = frame_addr; env->eip = ka->_sa_handler; cpu_x86_load_seg(env, R_DS, __USER_DS); cpu_x86_load_seg(env, R_ES, __USER_DS); cpu_x86_load_seg(env, R_SS, __USER_DS); cpu_x86_load_seg(env, R_CS, __USER_CS); env->eflags &= ~TF_MASK; unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); if (sig == TARGET_SIGSEGV) ka->_sa_handler = TARGET_SIG_DFL; force_sig(TARGET_SIGSEGV ); }
{ "code": [ "\tint i, err = 0;", " for(i = 0; i < TARGET_NSIG_WORDS; i++) {", " if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]))", " goto give_sigsegv;", "\tif (err)", "\t\tgoto give_sigsegv;", "\tunlock_user_struct(frame, frame_addr, 1);", " if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]))", "\tif (err)", "\tunlock_user_struct(frame, frame_addr, 1);" ], "line_no": [ 13, 63, 65, 67, 103, 23, 129, 65, 103, 129 ] }
static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1, target_siginfo_t *VAR_2, target_sigset_t *VAR_3, CPUX86State *VAR_4) { abi_ulong frame_addr, addr; struct rt_sigframe *VAR_5; int VAR_6, VAR_7 = 0; frame_addr = get_sigframe(VAR_1, VAR_4, sizeof(*VAR_5)); if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0)) goto give_sigsegv; __put_user(current_exec_domain_sig(VAR_0), &VAR_5->VAR_0); addr = frame_addr + offsetof(struct rt_sigframe, VAR_2); __put_user(addr, &VAR_5->pinfo); addr = frame_addr + offsetof(struct rt_sigframe, uc); __put_user(addr, &VAR_5->puc); copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2); __put_user(0, &VAR_5->uc.tuc_flags); __put_user(0, &VAR_5->uc.tuc_link); __put_user(target_sigaltstack_used.ss_sp, &VAR_5->uc.tuc_stack.ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(VAR_4)), &VAR_5->uc.tuc_stack.ss_flags); __put_user(target_sigaltstack_used.ss_size, &VAR_5->uc.tuc_stack.ss_size); setup_sigcontext(&VAR_5->uc.tuc_mcontext, &VAR_5->fpstate, VAR_4, VAR_3->VAR_0[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) { if (__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6])) goto give_sigsegv; } if (VAR_1->sa_flags & TARGET_SA_RESTORER) { __put_user(VAR_1->sa_restorer, &VAR_5->pretcode); } else { uint16_t val16; addr = frame_addr + offsetof(struct rt_sigframe, retcode); __put_user(addr, &VAR_5->pretcode); __put_user(0xb8, (char *)(VAR_5->retcode+0)); __put_user(TARGET_NR_rt_sigreturn, (int *)(VAR_5->retcode+1)); val16 = 0x80cd; __put_user(val16, (uint16_t *)(VAR_5->retcode+5)); } if (VAR_7) goto give_sigsegv; VAR_4->regs[R_ESP] = frame_addr; VAR_4->eip = VAR_1->_sa_handler; cpu_x86_load_seg(VAR_4, R_DS, __USER_DS); cpu_x86_load_seg(VAR_4, R_ES, __USER_DS); cpu_x86_load_seg(VAR_4, R_SS, __USER_DS); cpu_x86_load_seg(VAR_4, R_CS, __USER_CS); VAR_4->eflags &= ~TF_MASK; unlock_user_struct(VAR_5, frame_addr, 1); return; give_sigsegv: unlock_user_struct(VAR_5, frame_addr, 1); if (VAR_0 == TARGET_SIGSEGV) VAR_1->_sa_handler = TARGET_SIG_DFL; force_sig(TARGET_SIGSEGV ); }
[ "static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_siginfo_t *VAR_2,\ntarget_sigset_t *VAR_3, CPUX86State *VAR_4)\n{", "abi_ulong frame_addr, addr;", "struct rt_sigframe *VAR_5;", "int VAR_6, VAR_7 = 0;", "frame_addr = get_sigframe(VAR_1, VAR_4, sizeof(*VAR_5));", "if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0))\ngoto give_sigsegv;", "__put_user(current_exec_domain_sig(VAR_0), &VAR_5->VAR_0);", "addr = frame_addr + offsetof(struct rt_sigframe, VAR_2);", "__put_user(addr, &VAR_5->pinfo);", "addr = frame_addr + offsetof(struct rt_sigframe, uc);", "__put_user(addr, &VAR_5->puc);", "copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2);", "__put_user(0, &VAR_5->uc.tuc_flags);", "__put_user(0, &VAR_5->uc.tuc_link);", "__put_user(target_sigaltstack_used.ss_sp, &VAR_5->uc.tuc_stack.ss_sp);", "__put_user(sas_ss_flags(get_sp_from_cpustate(VAR_4)),\n&VAR_5->uc.tuc_stack.ss_flags);", "__put_user(target_sigaltstack_used.ss_size,\n&VAR_5->uc.tuc_stack.ss_size);", "setup_sigcontext(&VAR_5->uc.tuc_mcontext, &VAR_5->fpstate, VAR_4,\nVAR_3->VAR_0[0], frame_addr + offsetof(struct rt_sigframe, fpstate));", "for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {", "if (__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6]))\ngoto give_sigsegv;", "}", "if (VAR_1->sa_flags & TARGET_SA_RESTORER) {", "__put_user(VAR_1->sa_restorer, &VAR_5->pretcode);", "} else {", "uint16_t val16;", "addr = frame_addr + offsetof(struct rt_sigframe, retcode);", "__put_user(addr, &VAR_5->pretcode);", "__put_user(0xb8, (char *)(VAR_5->retcode+0));", "__put_user(TARGET_NR_rt_sigreturn, (int *)(VAR_5->retcode+1));", "val16 = 0x80cd;", "__put_user(val16, (uint16_t *)(VAR_5->retcode+5));", "}", "if (VAR_7)\ngoto give_sigsegv;", "VAR_4->regs[R_ESP] = frame_addr;", "VAR_4->eip = VAR_1->_sa_handler;", "cpu_x86_load_seg(VAR_4, R_DS, __USER_DS);", "cpu_x86_load_seg(VAR_4, R_ES, __USER_DS);", "cpu_x86_load_seg(VAR_4, R_SS, __USER_DS);", "cpu_x86_load_seg(VAR_4, R_CS, __USER_CS);", "VAR_4->eflags &= ~TF_MASK;", "unlock_user_struct(VAR_5, frame_addr, 1);", "return;", "give_sigsegv:\nunlock_user_struct(VAR_5, frame_addr, 1);", "if (VAR_0 == TARGET_SIGSEGV)\nVAR_1->_sa_handler = TARGET_SIG_DFL;", "force_sig(TARGET_SIGSEGV );", "}" ]
[ 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53, 55 ], [ 57, 59 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103, 105 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 133 ], [ 137, 139 ], [ 141, 143 ], [ 145 ], [ 147 ] ]
11,697
static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce) { FFPsyBand *band; int w, g, w2, i; float *PNS = &s->scoefs[0*128], *PNS34 = &s->scoefs[1*128]; float *NOR34 = &s->scoefs[3*128]; const float lambda = s->lambda; const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; const float thr_mult = NOISE_LAMBDA_REPLACE*(100.0f/lambda); const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/100.f); if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) return; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int noise_sfi; float dist1 = 0.0f, dist2 = 0.0f, noise_amp; float pns_energy = 0.0f, energy_ratio, dist_thresh; float sfb_energy = 0.0f, threshold = 0.0f, spread = 0.0f; const int start = sce->ics.swb_offset[w*16+g]; const float freq = start*freq_mult; const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f); if (freq < NOISE_LOW_LIMIT || avctx->cutoff && freq >= avctx->cutoff) continue; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; sfb_energy += band->energy; spread += band->spread; threshold += band->threshold; } /* Ramps down at ~8000Hz and loosens the dist threshold */ dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f); if (sce->zeroes[w*16+g] || spread < spread_threshold || sfb_energy > threshold*thr_mult*freq_boost) { sce->pns_ener[w*16+g] = sfb_energy; continue; } noise_sfi = av_clip(roundf(log2f(sfb_energy)*2), -100, 155); /* Quantize */ noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO]; /* Dequantize */ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { float band_energy, scale; const int start_c = sce->ics.swb_offset[(w+w2)*16+g]; band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; for (i = 0; i < sce->ics.swb_sizes[g]; i++) PNS[i] = s->random_state = lcg_random(s->random_state); band_energy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]); scale = noise_amp/sqrtf(band_energy); s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]); pns_energy += s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]); abs_pow34_v(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]); abs_pow34_v(PNS34, PNS, sce->ics.swb_sizes[g]); dist1 += quantize_band_cost(s, &sce->coeffs[start_c], NOR34, sce->ics.swb_sizes[g], sce->sf_idx[(w+w2)*16+g], sce->band_alt[(w+w2)*16+g], lambda/band->threshold, INFINITY, NULL, 0); dist2 += quantize_band_cost(s, PNS, PNS34, sce->ics.swb_sizes[g], noise_sfi, NOISE_BT, lambda/band->threshold, INFINITY, NULL, 0); } energy_ratio = sfb_energy/pns_energy; /* Compensates for quantization error */ sce->pns_ener[w*16+g] = energy_ratio*sfb_energy; if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) { sce->band_type[w*16+g] = NOISE_BT; sce->zeroes[w*16+g] = 0; if (sce->band_type[w*16+g-1] != NOISE_BT && /* Prevent holes */ sce->band_type[w*16+g-2] == NOISE_BT) { sce->band_type[w*16+g-1] = NOISE_BT; sce->zeroes[w*16+g-1] = 0; } } } } }
true
FFmpeg
9458a62decfcaa1313b1ba69276466de536d0768
static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce) { FFPsyBand *band; int w, g, w2, i; float *PNS = &s->scoefs[0*128], *PNS34 = &s->scoefs[1*128]; float *NOR34 = &s->scoefs[3*128]; const float lambda = s->lambda; const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; const float thr_mult = NOISE_LAMBDA_REPLACE*(100.0f/lambda); const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/100.f); if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) return; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int noise_sfi; float dist1 = 0.0f, dist2 = 0.0f, noise_amp; float pns_energy = 0.0f, energy_ratio, dist_thresh; float sfb_energy = 0.0f, threshold = 0.0f, spread = 0.0f; const int start = sce->ics.swb_offset[w*16+g]; const float freq = start*freq_mult; const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f); if (freq < NOISE_LOW_LIMIT || avctx->cutoff && freq >= avctx->cutoff) continue; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; sfb_energy += band->energy; spread += band->spread; threshold += band->threshold; } dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f); if (sce->zeroes[w*16+g] || spread < spread_threshold || sfb_energy > threshold*thr_mult*freq_boost) { sce->pns_ener[w*16+g] = sfb_energy; continue; } noise_sfi = av_clip(roundf(log2f(sfb_energy)*2), -100, 155); noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO]; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { float band_energy, scale; const int start_c = sce->ics.swb_offset[(w+w2)*16+g]; band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; for (i = 0; i < sce->ics.swb_sizes[g]; i++) PNS[i] = s->random_state = lcg_random(s->random_state); band_energy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]); scale = noise_amp/sqrtf(band_energy); s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]); pns_energy += s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]); abs_pow34_v(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]); abs_pow34_v(PNS34, PNS, sce->ics.swb_sizes[g]); dist1 += quantize_band_cost(s, &sce->coeffs[start_c], NOR34, sce->ics.swb_sizes[g], sce->sf_idx[(w+w2)*16+g], sce->band_alt[(w+w2)*16+g], lambda/band->threshold, INFINITY, NULL, 0); dist2 += quantize_band_cost(s, PNS, PNS34, sce->ics.swb_sizes[g], noise_sfi, NOISE_BT, lambda/band->threshold, INFINITY, NULL, 0); } energy_ratio = sfb_energy/pns_energy; sce->pns_ener[w*16+g] = energy_ratio*sfb_energy; if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) { sce->band_type[w*16+g] = NOISE_BT; sce->zeroes[w*16+g] = 0; if (sce->band_type[w*16+g-1] != NOISE_BT && sce->band_type[w*16+g-2] == NOISE_BT) { sce->band_type[w*16+g-1] = NOISE_BT; sce->zeroes[w*16+g-1] = 0; } } } } }
{ "code": [ " const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/100.f);", " if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE)", " float pns_energy = 0.0f, energy_ratio, dist_thresh;", " const float freq = start*freq_mult;", " dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f);", " if (sce->zeroes[w*16+g] || spread < spread_threshold ||", " sfb_energy > threshold*thr_mult*freq_boost) {", " float band_energy, scale;", " pns_energy += s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);", " dist2 += quantize_band_cost(s, PNS,", " PNS34,", " sce->ics.swb_sizes[g],", " noise_sfi,", " NOISE_BT,", " lambda/band->threshold, INFINITY, NULL, 0);", " sce->pns_ener[w*16+g] = energy_ratio*sfb_energy;", " if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) {", " sce->band_type[w*16+g-2] == NOISE_BT) {", " sce->band_type[w*16+g-1] = NOISE_BT;", " sce->zeroes[w*16+g-1] = 0;" ], "line_no": [ 19, 23, 37, 43, 67, 71, 73, 89, 105, 123, 125, 115, 129, 131, 121, 139, 141, 149, 151, 153 ] }
static void FUNC_0(AACEncContext *VAR_0, AVCodecContext *VAR_1, SingleChannelElement *VAR_2) { FFPsyBand *band; int VAR_3, VAR_4, VAR_5, VAR_6; float *VAR_7 = &VAR_0->scoefs[0*128], *VAR_8 = &VAR_0->scoefs[1*128]; float *VAR_9 = &VAR_0->scoefs[3*128]; const float VAR_10 = VAR_0->VAR_10; const float VAR_11 = VAR_1->sample_rate/(1024.0f/VAR_2->ics.num_windows)/2.0f; const float VAR_12 = NOISE_LAMBDA_REPLACE*(100.0f/VAR_10); const float VAR_13 = NOISE_SPREAD_THRESHOLD*(VAR_10/100.f); if (VAR_2->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) return; for (VAR_3 = 0; VAR_3 < VAR_2->ics.num_windows; VAR_3 += VAR_2->ics.group_len[VAR_3]) { for (VAR_4 = 0; VAR_4 < VAR_2->ics.num_swb; VAR_4++) { int noise_sfi; float dist1 = 0.0f, dist2 = 0.0f, noise_amp; float pns_energy = 0.0f, energy_ratio, dist_thresh; float sfb_energy = 0.0f, threshold = 0.0f, spread = 0.0f; const int start = VAR_2->ics.swb_offset[VAR_3*16+VAR_4]; const float freq = start*VAR_11; const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f); if (freq < NOISE_LOW_LIMIT || VAR_1->cutoff && freq >= VAR_1->cutoff) continue; for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_3]; VAR_5++) { band = &VAR_0->psy.ch[VAR_0->cur_channel].psy_bands[(VAR_3+VAR_5)*16+VAR_4]; sfb_energy += band->energy; spread += band->spread; threshold += band->threshold; } dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f); if (VAR_2->zeroes[VAR_3*16+VAR_4] || spread < VAR_13 || sfb_energy > threshold*VAR_12*freq_boost) { VAR_2->pns_ener[VAR_3*16+VAR_4] = sfb_energy; continue; } noise_sfi = av_clip(roundf(log2f(sfb_energy)*2), -100, 155); noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO]; for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_3]; VAR_5++) { float band_energy, scale; const int start_c = VAR_2->ics.swb_offset[(VAR_3+VAR_5)*16+VAR_4]; band = &VAR_0->psy.ch[VAR_0->cur_channel].psy_bands[(VAR_3+VAR_5)*16+VAR_4]; for (VAR_6 = 0; VAR_6 < VAR_2->ics.swb_sizes[VAR_4]; VAR_6++) VAR_7[VAR_6] = VAR_0->random_state = lcg_random(VAR_0->random_state); band_energy = VAR_0->fdsp->scalarproduct_float(VAR_7, VAR_7, VAR_2->ics.swb_sizes[VAR_4]); scale = noise_amp/sqrtf(band_energy); VAR_0->fdsp->vector_fmul_scalar(VAR_7, VAR_7, scale, VAR_2->ics.swb_sizes[VAR_4]); pns_energy += VAR_0->fdsp->scalarproduct_float(VAR_7, VAR_7, VAR_2->ics.swb_sizes[VAR_4]); abs_pow34_v(VAR_9, &VAR_2->coeffs[start_c], VAR_2->ics.swb_sizes[VAR_4]); abs_pow34_v(VAR_8, VAR_7, VAR_2->ics.swb_sizes[VAR_4]); dist1 += quantize_band_cost(VAR_0, &VAR_2->coeffs[start_c], VAR_9, VAR_2->ics.swb_sizes[VAR_4], VAR_2->sf_idx[(VAR_3+VAR_5)*16+VAR_4], VAR_2->band_alt[(VAR_3+VAR_5)*16+VAR_4], VAR_10/band->threshold, INFINITY, NULL, 0); dist2 += quantize_band_cost(VAR_0, VAR_7, VAR_8, VAR_2->ics.swb_sizes[VAR_4], noise_sfi, NOISE_BT, VAR_10/band->threshold, INFINITY, NULL, 0); } energy_ratio = sfb_energy/pns_energy; VAR_2->pns_ener[VAR_3*16+VAR_4] = energy_ratio*sfb_energy; if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) { VAR_2->band_type[VAR_3*16+VAR_4] = NOISE_BT; VAR_2->zeroes[VAR_3*16+VAR_4] = 0; if (VAR_2->band_type[VAR_3*16+VAR_4-1] != NOISE_BT && VAR_2->band_type[VAR_3*16+VAR_4-2] == NOISE_BT) { VAR_2->band_type[VAR_3*16+VAR_4-1] = NOISE_BT; VAR_2->zeroes[VAR_3*16+VAR_4-1] = 0; } } } } }
[ "static void FUNC_0(AACEncContext *VAR_0, AVCodecContext *VAR_1, SingleChannelElement *VAR_2)\n{", "FFPsyBand *band;", "int VAR_3, VAR_4, VAR_5, VAR_6;", "float *VAR_7 = &VAR_0->scoefs[0*128], *VAR_8 = &VAR_0->scoefs[1*128];", "float *VAR_9 = &VAR_0->scoefs[3*128];", "const float VAR_10 = VAR_0->VAR_10;", "const float VAR_11 = VAR_1->sample_rate/(1024.0f/VAR_2->ics.num_windows)/2.0f;", "const float VAR_12 = NOISE_LAMBDA_REPLACE*(100.0f/VAR_10);", "const float VAR_13 = NOISE_SPREAD_THRESHOLD*(VAR_10/100.f);", "if (VAR_2->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE)\nreturn;", "for (VAR_3 = 0; VAR_3 < VAR_2->ics.num_windows; VAR_3 += VAR_2->ics.group_len[VAR_3]) {", "for (VAR_4 = 0; VAR_4 < VAR_2->ics.num_swb; VAR_4++) {", "int noise_sfi;", "float dist1 = 0.0f, dist2 = 0.0f, noise_amp;", "float pns_energy = 0.0f, energy_ratio, dist_thresh;", "float sfb_energy = 0.0f, threshold = 0.0f, spread = 0.0f;", "const int start = VAR_2->ics.swb_offset[VAR_3*16+VAR_4];", "const float freq = start*VAR_11;", "const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);", "if (freq < NOISE_LOW_LIMIT || VAR_1->cutoff && freq >= VAR_1->cutoff)\ncontinue;", "for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_3]; VAR_5++) {", "band = &VAR_0->psy.ch[VAR_0->cur_channel].psy_bands[(VAR_3+VAR_5)*16+VAR_4];", "sfb_energy += band->energy;", "spread += band->spread;", "threshold += band->threshold;", "}", "dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f);", "if (VAR_2->zeroes[VAR_3*16+VAR_4] || spread < VAR_13 ||\nsfb_energy > threshold*VAR_12*freq_boost) {", "VAR_2->pns_ener[VAR_3*16+VAR_4] = sfb_energy;", "continue;", "}", "noise_sfi = av_clip(roundf(log2f(sfb_energy)*2), -100, 155);", "noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO];", "for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_3]; VAR_5++) {", "float band_energy, scale;", "const int start_c = VAR_2->ics.swb_offset[(VAR_3+VAR_5)*16+VAR_4];", "band = &VAR_0->psy.ch[VAR_0->cur_channel].psy_bands[(VAR_3+VAR_5)*16+VAR_4];", "for (VAR_6 = 0; VAR_6 < VAR_2->ics.swb_sizes[VAR_4]; VAR_6++)", "VAR_7[VAR_6] = VAR_0->random_state = lcg_random(VAR_0->random_state);", "band_energy = VAR_0->fdsp->scalarproduct_float(VAR_7, VAR_7, VAR_2->ics.swb_sizes[VAR_4]);", "scale = noise_amp/sqrtf(band_energy);", "VAR_0->fdsp->vector_fmul_scalar(VAR_7, VAR_7, scale, VAR_2->ics.swb_sizes[VAR_4]);", "pns_energy += VAR_0->fdsp->scalarproduct_float(VAR_7, VAR_7, VAR_2->ics.swb_sizes[VAR_4]);", "abs_pow34_v(VAR_9, &VAR_2->coeffs[start_c], VAR_2->ics.swb_sizes[VAR_4]);", "abs_pow34_v(VAR_8, VAR_7, VAR_2->ics.swb_sizes[VAR_4]);", "dist1 += quantize_band_cost(VAR_0, &VAR_2->coeffs[start_c],\nVAR_9,\nVAR_2->ics.swb_sizes[VAR_4],\nVAR_2->sf_idx[(VAR_3+VAR_5)*16+VAR_4],\nVAR_2->band_alt[(VAR_3+VAR_5)*16+VAR_4],\nVAR_10/band->threshold, INFINITY, NULL, 0);", "dist2 += quantize_band_cost(VAR_0, VAR_7,\nVAR_8,\nVAR_2->ics.swb_sizes[VAR_4],\nnoise_sfi,\nNOISE_BT,\nVAR_10/band->threshold, INFINITY, NULL, 0);", "}", "energy_ratio = sfb_energy/pns_energy;", "VAR_2->pns_ener[VAR_3*16+VAR_4] = energy_ratio*sfb_energy;", "if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) {", "VAR_2->band_type[VAR_3*16+VAR_4] = NOISE_BT;", "VAR_2->zeroes[VAR_3*16+VAR_4] = 0;", "if (VAR_2->band_type[VAR_3*16+VAR_4-1] != NOISE_BT &&\nVAR_2->band_type[VAR_3*16+VAR_4-2] == NOISE_BT) {", "VAR_2->band_type[VAR_3*16+VAR_4-1] = NOISE_BT;", "VAR_2->zeroes[VAR_3*16+VAR_4-1] = 0;", "}", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111, 113, 115, 117, 119, 121 ], [ 123, 125, 127, 129, 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ] ]
11,698
static inline void dv_decode_video_segment(DVVideoContext *s, const uint8_t *buf_ptr1, const uint16_t *mb_pos_ptr) { int quant, dc, dct_mode, class1, j; int mb_index, mb_x, mb_y, v, last_index; int y_stride, i; DCTELEM *block, *block1; int c_offset; uint8_t *y_ptr; const uint8_t *buf_ptr; PutBitContext pb, vs_pb; GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]); DECLARE_ALIGNED_8(uint8_t, mb_bit_buffer[80 + 4]); /* allow some slack */ DECLARE_ALIGNED_8(uint8_t, vs_bit_buffer[5 * 80 + 4]); /* allow some slack */ const int log2_blocksize= 3-s->avctx->lowres; int is_field_mode[5]; assert((((int)mb_bit_buffer)&7)==0); assert((((int)vs_bit_buffer)&7)==0); memset(sblock, 0, sizeof(sblock)); /* pass 1 : read DC and AC coefficients in blocks */ buf_ptr = buf_ptr1; block1 = &sblock[0][0]; mb1 = mb_data; init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); for(mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) { /* skip header */ quant = buf_ptr[3] & 0x0f; buf_ptr += 4; init_put_bits(&pb, mb_bit_buffer, 80); mb = mb1; block = block1; is_field_mode[mb_index] = 0; for(j = 0;j < s->sys->bpm; j++) { last_index = s->sys->block_sizes[j]; init_get_bits(&gb, buf_ptr, last_index); /* get the dc */ dc = get_sbits(&gb, 9); dct_mode = get_bits1(&gb); class1 = get_bits(&gb, 2); if (DV_PROFILE_IS_HD(s->sys)) { mb->idct_put = s->idct_put[0]; mb->scan_table = s->dv_zigzag[0]; mb->factor_table = s->dv100_idct_factor[((s->sys->height == 720)<<1)&(j < 4)][class1][quant]; is_field_mode[mb_index] |= !j && dct_mode; } else { mb->idct_put = s->idct_put[dct_mode && log2_blocksize==3]; mb->scan_table = s->dv_zigzag[dct_mode]; mb->factor_table = s->dv_idct_factor[class1 == 3][dct_mode] [quant + dv_quant_offset[class1]]; } dc = dc << 2; /* convert to unsigned because 128 is not added in the standard IDCT */ dc += 1024; block[0] = dc; buf_ptr += last_index >> 3; mb->pos = 0; mb->partial_bit_count = 0; #ifdef VLC_DEBUG printf("MB block: %d, %d ", mb_index, j); #endif dv_decode_ac(&gb, mb, block); /* write the remaining bits in a new buffer only if the block is finished */ if (mb->pos >= 64) bit_copy(&pb, &gb); block += 64; mb++; } /* pass 2 : we can do it just after */ #ifdef VLC_DEBUG printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); #endif block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); flush_put_bits(&pb); for(j = 0;j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { dv_decode_ac(&gb, mb, block); /* if still not finished, no need to parse other blocks */ if (mb->pos < 64) break; } } /* all blocks are finished, so the extra bytes can be used at the video segment level */ if (j >= s->sys->bpm) bit_copy(&vs_pb, &gb); } /* we need a pass other the whole video segment */ #ifdef VLC_DEBUG printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); #endif block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); flush_put_bits(&vs_pb); for(mb_index = 0; mb_index < 5; mb_index++) { for(j = 0;j < s->sys->bpm; j++) { if (mb->pos < 64) { #ifdef VLC_DEBUG printf("start %d:%d\n", mb_index, j); #endif dv_decode_ac(&gb, mb, block); } if (mb->pos >= 64 && mb->pos < 127) av_log(NULL, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos); block += 64; mb++; } } /* compute idct and place blocks */ block = &sblock[0][0]; mb = mb_data; for(mb_index = 0; mb_index < 5; mb_index++) { v = *mb_pos_ptr++; mb_x = v & 0xff; mb_y = v >> 8; /* We work with 720p frames split in half. The odd half-frame (chan==2,3) is displaced :-( */ if (s->sys->height == 720 && !(s->buf[1]&0x0C)) { mb_y -= (mb_y>17)?18:-72; /* shifting the Y coordinate down by 72/2 macroblocks */ } /* idct_put'ting luminance */ if ((s->sys->pix_fmt == PIX_FMT_YUV420P) || (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) || (s->sys->height >= 720 && mb_y != 134)) { y_stride = (s->picture.linesize[0]<<((!is_field_mode[mb_index])*log2_blocksize)) - (2<<log2_blocksize); } else { y_stride = 0; } y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize); for(j = 0; j < 2; j++, y_ptr += y_stride) { for (i=0; i<2; i++, block += 64, mb++, y_ptr += (1<<log2_blocksize)) if (s->sys->pix_fmt == PIX_FMT_YUV422P && s->sys->width == 720 && i) y_ptr -= (1<<log2_blocksize); else mb->idct_put(y_ptr, s->picture.linesize[0]<<is_field_mode[mb_index], block); } /* idct_put'ting chrominance */ c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] + (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<log2_blocksize); for(j=2; j; j--) { uint8_t *c_ptr = s->picture.data[j] + c_offset; if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) { uint64_t aligned_pixels[64/8]; uint8_t *pixels = (uint8_t*)aligned_pixels; uint8_t *c_ptr1, *ptr1; int x, y; mb->idct_put(pixels, 8, block); for(y = 0; y < (1<<log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) { ptr1= pixels + (1<<(log2_blocksize-1)); c_ptr1 = c_ptr + (s->picture.linesize[j]<<log2_blocksize); for(x=0; x < (1<<(log2_blocksize-1)); x++) { c_ptr[x]= pixels[x]; c_ptr1[x]= ptr1[x]; } } block += 64; mb++; } else { y_stride = (mb_y == 134) ? (1<<log2_blocksize) : s->picture.linesize[j]<<((!is_field_mode[mb_index])*log2_blocksize); for (i=0; i<(1<<(s->sys->bpm==8)); i++, block += 64, mb++, c_ptr += y_stride) mb->idct_put(c_ptr, s->picture.linesize[j]<<is_field_mode[mb_index], block); } } } }
true
FFmpeg
0843ddcb91cfd11eeeebbd62cfc4bcd340c1e87d
static inline void dv_decode_video_segment(DVVideoContext *s, const uint8_t *buf_ptr1, const uint16_t *mb_pos_ptr) { int quant, dc, dct_mode, class1, j; int mb_index, mb_x, mb_y, v, last_index; int y_stride, i; DCTELEM *block, *block1; int c_offset; uint8_t *y_ptr; const uint8_t *buf_ptr; PutBitContext pb, vs_pb; GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]); DECLARE_ALIGNED_8(uint8_t, mb_bit_buffer[80 + 4]); DECLARE_ALIGNED_8(uint8_t, vs_bit_buffer[5 * 80 + 4]); const int log2_blocksize= 3-s->avctx->lowres; int is_field_mode[5]; assert((((int)mb_bit_buffer)&7)==0); assert((((int)vs_bit_buffer)&7)==0); memset(sblock, 0, sizeof(sblock)); buf_ptr = buf_ptr1; block1 = &sblock[0][0]; mb1 = mb_data; init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); for(mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) { quant = buf_ptr[3] & 0x0f; buf_ptr += 4; init_put_bits(&pb, mb_bit_buffer, 80); mb = mb1; block = block1; is_field_mode[mb_index] = 0; for(j = 0;j < s->sys->bpm; j++) { last_index = s->sys->block_sizes[j]; init_get_bits(&gb, buf_ptr, last_index); dc = get_sbits(&gb, 9); dct_mode = get_bits1(&gb); class1 = get_bits(&gb, 2); if (DV_PROFILE_IS_HD(s->sys)) { mb->idct_put = s->idct_put[0]; mb->scan_table = s->dv_zigzag[0]; mb->factor_table = s->dv100_idct_factor[((s->sys->height == 720)<<1)&(j < 4)][class1][quant]; is_field_mode[mb_index] |= !j && dct_mode; } else { mb->idct_put = s->idct_put[dct_mode && log2_blocksize==3]; mb->scan_table = s->dv_zigzag[dct_mode]; mb->factor_table = s->dv_idct_factor[class1 == 3][dct_mode] [quant + dv_quant_offset[class1]]; } dc = dc << 2; dc += 1024; block[0] = dc; buf_ptr += last_index >> 3; mb->pos = 0; mb->partial_bit_count = 0; #ifdef VLC_DEBUG printf("MB block: %d, %d ", mb_index, j); #endif dv_decode_ac(&gb, mb, block); if (mb->pos >= 64) bit_copy(&pb, &gb); block += 64; mb++; } #ifdef VLC_DEBUG printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); #endif block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); flush_put_bits(&pb); for(j = 0;j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { dv_decode_ac(&gb, mb, block); if (mb->pos < 64) break; } } if (j >= s->sys->bpm) bit_copy(&vs_pb, &gb); } #ifdef VLC_DEBUG printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); #endif block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); flush_put_bits(&vs_pb); for(mb_index = 0; mb_index < 5; mb_index++) { for(j = 0;j < s->sys->bpm; j++) { if (mb->pos < 64) { #ifdef VLC_DEBUG printf("start %d:%d\n", mb_index, j); #endif dv_decode_ac(&gb, mb, block); } if (mb->pos >= 64 && mb->pos < 127) av_log(NULL, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos); block += 64; mb++; } } block = &sblock[0][0]; mb = mb_data; for(mb_index = 0; mb_index < 5; mb_index++) { v = *mb_pos_ptr++; mb_x = v & 0xff; mb_y = v >> 8; if (s->sys->height == 720 && !(s->buf[1]&0x0C)) { mb_y -= (mb_y>17)?18:-72; } if ((s->sys->pix_fmt == PIX_FMT_YUV420P) || (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) || (s->sys->height >= 720 && mb_y != 134)) { y_stride = (s->picture.linesize[0]<<((!is_field_mode[mb_index])*log2_blocksize)) - (2<<log2_blocksize); } else { y_stride = 0; } y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize); for(j = 0; j < 2; j++, y_ptr += y_stride) { for (i=0; i<2; i++, block += 64, mb++, y_ptr += (1<<log2_blocksize)) if (s->sys->pix_fmt == PIX_FMT_YUV422P && s->sys->width == 720 && i) y_ptr -= (1<<log2_blocksize); else mb->idct_put(y_ptr, s->picture.linesize[0]<<is_field_mode[mb_index], block); } c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] + (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<log2_blocksize); for(j=2; j; j--) { uint8_t *c_ptr = s->picture.data[j] + c_offset; if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) { uint64_t aligned_pixels[64/8]; uint8_t *pixels = (uint8_t*)aligned_pixels; uint8_t *c_ptr1, *ptr1; int x, y; mb->idct_put(pixels, 8, block); for(y = 0; y < (1<<log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) { ptr1= pixels + (1<<(log2_blocksize-1)); c_ptr1 = c_ptr + (s->picture.linesize[j]<<log2_blocksize); for(x=0; x < (1<<(log2_blocksize-1)); x++) { c_ptr[x]= pixels[x]; c_ptr1[x]= ptr1[x]; } } block += 64; mb++; } else { y_stride = (mb_y == 134) ? (1<<log2_blocksize) : s->picture.linesize[j]<<((!is_field_mode[mb_index])*log2_blocksize); for (i=0; i<(1<<(s->sys->bpm==8)); i++, block += 64, mb++, c_ptr += y_stride) mb->idct_put(c_ptr, s->picture.linesize[j]<<is_field_mode[mb_index], block); } } } }
{ "code": [ " mb->factor_table = s->dv100_idct_factor[((s->sys->height == 720)<<1)&(j < 4)][class1][quant];" ], "line_no": [ 99 ] }
static inline void FUNC_0(DVVideoContext *VAR_0, const uint8_t *VAR_1, const uint16_t *VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; int VAR_13, VAR_14; DCTELEM *block, *block1; int VAR_15; uint8_t *y_ptr; const uint8_t *VAR_16; PutBitContext pb, vs_pb; GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]); DECLARE_ALIGNED_8(uint8_t, mb_bit_buffer[80 + 4]); DECLARE_ALIGNED_8(uint8_t, vs_bit_buffer[5 * 80 + 4]); const int VAR_17= 3-VAR_0->avctx->lowres; int VAR_18[5]; assert((((int)mb_bit_buffer)&7)==0); assert((((int)vs_bit_buffer)&7)==0); memset(sblock, 0, sizeof(sblock)); VAR_16 = VAR_1; block1 = &sblock[0][0]; mb1 = mb_data; init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); for(VAR_8 = 0; VAR_8 < 5; VAR_8++, mb1 += VAR_0->sys->bpm, block1 += VAR_0->sys->bpm * 64) { VAR_3 = VAR_16[3] & 0x0f; VAR_16 += 4; init_put_bits(&pb, mb_bit_buffer, 80); mb = mb1; block = block1; VAR_18[VAR_8] = 0; for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++) { VAR_12 = VAR_0->sys->block_sizes[VAR_7]; init_get_bits(&gb, VAR_16, VAR_12); VAR_4 = get_sbits(&gb, 9); VAR_5 = get_bits1(&gb); VAR_6 = get_bits(&gb, 2); if (DV_PROFILE_IS_HD(VAR_0->sys)) { mb->idct_put = VAR_0->idct_put[0]; mb->scan_table = VAR_0->dv_zigzag[0]; mb->factor_table = VAR_0->dv100_idct_factor[((VAR_0->sys->height == 720)<<1)&(VAR_7 < 4)][VAR_6][VAR_3]; VAR_18[VAR_8] |= !VAR_7 && VAR_5; } else { mb->idct_put = VAR_0->idct_put[VAR_5 && VAR_17==3]; mb->scan_table = VAR_0->dv_zigzag[VAR_5]; mb->factor_table = VAR_0->dv_idct_factor[VAR_6 == 3][VAR_5] [VAR_3 + dv_quant_offset[VAR_6]]; } VAR_4 = VAR_4 << 2; VAR_4 += 1024; block[0] = VAR_4; VAR_16 += VAR_12 >> 3; mb->pos = 0; mb->partial_bit_count = 0; #ifdef VLC_DEBUG printf("MB block: %d, %d ", VAR_8, VAR_7); #endif dv_decode_ac(&gb, mb, block); if (mb->pos >= 64) bit_copy(&pb, &gb); block += 64; mb++; } #ifdef VLC_DEBUG printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), VAR_8); #endif block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); flush_put_bits(&pb); for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { dv_decode_ac(&gb, mb, block); if (mb->pos < 64) break; } } if (VAR_7 >= VAR_0->sys->bpm) bit_copy(&vs_pb, &gb); } #ifdef VLC_DEBUG printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); #endif block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); flush_put_bits(&vs_pb); for(VAR_8 = 0; VAR_8 < 5; VAR_8++) { for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++) { if (mb->pos < 64) { #ifdef VLC_DEBUG printf("start %d:%d\n", VAR_8, VAR_7); #endif dv_decode_ac(&gb, mb, block); } if (mb->pos >= 64 && mb->pos < 127) av_log(NULL, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos); block += 64; mb++; } } block = &sblock[0][0]; mb = mb_data; for(VAR_8 = 0; VAR_8 < 5; VAR_8++) { VAR_11 = *VAR_2++; VAR_9 = VAR_11 & 0xff; VAR_10 = VAR_11 >> 8; if (VAR_0->sys->height == 720 && !(VAR_0->buf[1]&0x0C)) { VAR_10 -= (VAR_10>17)?18:-72; } if ((VAR_0->sys->pix_fmt == PIX_FMT_YUV420P) || (VAR_0->sys->pix_fmt == PIX_FMT_YUV411P && VAR_9 >= (704 / 8)) || (VAR_0->sys->height >= 720 && VAR_10 != 134)) { VAR_13 = (VAR_0->picture.linesize[0]<<((!VAR_18[VAR_8])*VAR_17)) - (2<<VAR_17); } else { VAR_13 = 0; } y_ptr = VAR_0->picture.data[0] + ((VAR_10 * VAR_0->picture.linesize[0] + VAR_9)<<VAR_17); for(VAR_7 = 0; VAR_7 < 2; VAR_7++, y_ptr += VAR_13) { for (VAR_14=0; VAR_14<2; VAR_14++, block += 64, mb++, y_ptr += (1<<VAR_17)) if (VAR_0->sys->pix_fmt == PIX_FMT_YUV422P && VAR_0->sys->width == 720 && VAR_14) y_ptr -= (1<<VAR_17); else mb->idct_put(y_ptr, VAR_0->picture.linesize[0]<<VAR_18[VAR_8], block); } VAR_15 = (((VAR_10>>(VAR_0->sys->pix_fmt == PIX_FMT_YUV420P)) * VAR_0->picture.linesize[1] + (VAR_9>>((VAR_0->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<VAR_17); for(VAR_7=2; VAR_7; VAR_7--) { uint8_t *c_ptr = VAR_0->picture.data[VAR_7] + VAR_15; if (VAR_0->sys->pix_fmt == PIX_FMT_YUV411P && VAR_9 >= (704 / 8)) { uint64_t aligned_pixels[64/8]; uint8_t *pixels = (uint8_t*)aligned_pixels; uint8_t *c_ptr1, *ptr1; int VAR_19, VAR_20; mb->idct_put(pixels, 8, block); for(VAR_20 = 0; VAR_20 < (1<<VAR_17); VAR_20++, c_ptr += VAR_0->picture.linesize[VAR_7], pixels += 8) { ptr1= pixels + (1<<(VAR_17-1)); c_ptr1 = c_ptr + (VAR_0->picture.linesize[VAR_7]<<VAR_17); for(VAR_19=0; VAR_19 < (1<<(VAR_17-1)); VAR_19++) { c_ptr[VAR_19]= pixels[VAR_19]; c_ptr1[VAR_19]= ptr1[VAR_19]; } } block += 64; mb++; } else { VAR_13 = (VAR_10 == 134) ? (1<<VAR_17) : VAR_0->picture.linesize[VAR_7]<<((!VAR_18[VAR_8])*VAR_17); for (VAR_14=0; VAR_14<(1<<(VAR_0->sys->bpm==8)); VAR_14++, block += 64, mb++, c_ptr += VAR_13) mb->idct_put(c_ptr, VAR_0->picture.linesize[VAR_7]<<VAR_18[VAR_8], block); } } } }
[ "static inline void FUNC_0(DVVideoContext *VAR_0,\nconst uint8_t *VAR_1,\nconst uint16_t *VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;", "int VAR_13, VAR_14;", "DCTELEM *block, *block1;", "int VAR_15;", "uint8_t *y_ptr;", "const uint8_t *VAR_16;", "PutBitContext pb, vs_pb;", "GetBitContext gb;", "BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;", "DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]);", "DECLARE_ALIGNED_8(uint8_t, mb_bit_buffer[80 + 4]);", "DECLARE_ALIGNED_8(uint8_t, vs_bit_buffer[5 * 80 + 4]);", "const int VAR_17= 3-VAR_0->avctx->lowres;", "int VAR_18[5];", "assert((((int)mb_bit_buffer)&7)==0);", "assert((((int)vs_bit_buffer)&7)==0);", "memset(sblock, 0, sizeof(sblock));", "VAR_16 = VAR_1;", "block1 = &sblock[0][0];", "mb1 = mb_data;", "init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);", "for(VAR_8 = 0; VAR_8 < 5; VAR_8++, mb1 += VAR_0->sys->bpm, block1 += VAR_0->sys->bpm * 64) {", "VAR_3 = VAR_16[3] & 0x0f;", "VAR_16 += 4;", "init_put_bits(&pb, mb_bit_buffer, 80);", "mb = mb1;", "block = block1;", "VAR_18[VAR_8] = 0;", "for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++) {", "VAR_12 = VAR_0->sys->block_sizes[VAR_7];", "init_get_bits(&gb, VAR_16, VAR_12);", "VAR_4 = get_sbits(&gb, 9);", "VAR_5 = get_bits1(&gb);", "VAR_6 = get_bits(&gb, 2);", "if (DV_PROFILE_IS_HD(VAR_0->sys)) {", "mb->idct_put = VAR_0->idct_put[0];", "mb->scan_table = VAR_0->dv_zigzag[0];", "mb->factor_table = VAR_0->dv100_idct_factor[((VAR_0->sys->height == 720)<<1)&(VAR_7 < 4)][VAR_6][VAR_3];", "VAR_18[VAR_8] |= !VAR_7 && VAR_5;", "} else {", "mb->idct_put = VAR_0->idct_put[VAR_5 && VAR_17==3];", "mb->scan_table = VAR_0->dv_zigzag[VAR_5];", "mb->factor_table = VAR_0->dv_idct_factor[VAR_6 == 3][VAR_5]\n[VAR_3 + dv_quant_offset[VAR_6]];", "}", "VAR_4 = VAR_4 << 2;", "VAR_4 += 1024;", "block[0] = VAR_4;", "VAR_16 += VAR_12 >> 3;", "mb->pos = 0;", "mb->partial_bit_count = 0;", "#ifdef VLC_DEBUG\nprintf(\"MB block: %d, %d \", VAR_8, VAR_7);", "#endif\ndv_decode_ac(&gb, mb, block);", "if (mb->pos >= 64)\nbit_copy(&pb, &gb);", "block += 64;", "mb++;", "}", "#ifdef VLC_DEBUG\nprintf(\"***pass 2 size=%d MB#=%d\\n\", put_bits_count(&pb), VAR_8);", "#endif\nblock = block1;", "mb = mb1;", "init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));", "flush_put_bits(&pb);", "for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++, block += 64, mb++) {", "if (mb->pos < 64 && get_bits_left(&gb) > 0) {", "dv_decode_ac(&gb, mb, block);", "if (mb->pos < 64)\nbreak;", "}", "}", "if (VAR_7 >= VAR_0->sys->bpm)\nbit_copy(&vs_pb, &gb);", "}", "#ifdef VLC_DEBUG\nprintf(\"***pass 3 size=%d\\n\", put_bits_count(&vs_pb));", "#endif\nblock = &sblock[0][0];", "mb = mb_data;", "init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));", "flush_put_bits(&vs_pb);", "for(VAR_8 = 0; VAR_8 < 5; VAR_8++) {", "for(VAR_7 = 0;VAR_7 < VAR_0->sys->bpm; VAR_7++) {", "if (mb->pos < 64) {", "#ifdef VLC_DEBUG\nprintf(\"start %d:%d\\n\", VAR_8, VAR_7);", "#endif\ndv_decode_ac(&gb, mb, block);", "}", "if (mb->pos >= 64 && mb->pos < 127)\nav_log(NULL, AV_LOG_ERROR, \"AC EOB marker is absent pos=%d\\n\", mb->pos);", "block += 64;", "mb++;", "}", "}", "block = &sblock[0][0];", "mb = mb_data;", "for(VAR_8 = 0; VAR_8 < 5; VAR_8++) {", "VAR_11 = *VAR_2++;", "VAR_9 = VAR_11 & 0xff;", "VAR_10 = VAR_11 >> 8;", "if (VAR_0->sys->height == 720 && !(VAR_0->buf[1]&0x0C)) {", "VAR_10 -= (VAR_10>17)?18:-72;", "}", "if ((VAR_0->sys->pix_fmt == PIX_FMT_YUV420P) ||\n(VAR_0->sys->pix_fmt == PIX_FMT_YUV411P && VAR_9 >= (704 / 8)) ||\n(VAR_0->sys->height >= 720 && VAR_10 != 134)) {", "VAR_13 = (VAR_0->picture.linesize[0]<<((!VAR_18[VAR_8])*VAR_17)) - (2<<VAR_17);", "} else {", "VAR_13 = 0;", "}", "y_ptr = VAR_0->picture.data[0] + ((VAR_10 * VAR_0->picture.linesize[0] + VAR_9)<<VAR_17);", "for(VAR_7 = 0; VAR_7 < 2; VAR_7++, y_ptr += VAR_13) {", "for (VAR_14=0; VAR_14<2; VAR_14++, block += 64, mb++, y_ptr += (1<<VAR_17))", "if (VAR_0->sys->pix_fmt == PIX_FMT_YUV422P && VAR_0->sys->width == 720 && VAR_14)\ny_ptr -= (1<<VAR_17);", "else\nmb->idct_put(y_ptr, VAR_0->picture.linesize[0]<<VAR_18[VAR_8], block);", "}", "VAR_15 = (((VAR_10>>(VAR_0->sys->pix_fmt == PIX_FMT_YUV420P)) * VAR_0->picture.linesize[1] +\n(VAR_9>>((VAR_0->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<VAR_17);", "for(VAR_7=2; VAR_7; VAR_7--) {", "uint8_t *c_ptr = VAR_0->picture.data[VAR_7] + VAR_15;", "if (VAR_0->sys->pix_fmt == PIX_FMT_YUV411P && VAR_9 >= (704 / 8)) {", "uint64_t aligned_pixels[64/8];", "uint8_t *pixels = (uint8_t*)aligned_pixels;", "uint8_t *c_ptr1, *ptr1;", "int VAR_19, VAR_20;", "mb->idct_put(pixels, 8, block);", "for(VAR_20 = 0; VAR_20 < (1<<VAR_17); VAR_20++, c_ptr += VAR_0->picture.linesize[VAR_7], pixels += 8) {", "ptr1= pixels + (1<<(VAR_17-1));", "c_ptr1 = c_ptr + (VAR_0->picture.linesize[VAR_7]<<VAR_17);", "for(VAR_19=0; VAR_19 < (1<<(VAR_17-1)); VAR_19++) {", "c_ptr[VAR_19]= pixels[VAR_19];", "c_ptr1[VAR_19]= ptr1[VAR_19];", "}", "}", "block += 64; mb++;", "} else {", "VAR_13 = (VAR_10 == 134) ? (1<<VAR_17) :\nVAR_0->picture.linesize[VAR_7]<<((!VAR_18[VAR_8])*VAR_17);", "for (VAR_14=0; VAR_14<(1<<(VAR_0->sys->bpm==8)); VAR_14++, block += 64, mb++, c_ptr += VAR_13)", "mb->idct_put(c_ptr, VAR_0->picture.linesize[VAR_7]<<VAR_18[VAR_8], block);", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137, 139 ], [ 147, 149 ], [ 153 ], [ 155 ], [ 157 ], [ 163, 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 197, 199 ], [ 201 ], [ 207, 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231, 233 ], [ 235 ], [ 237, 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 277, 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297, 299 ], [ 301, 303 ], [ 305 ], [ 311, 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351, 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ] ]
11,699
static void set_sensor_evt_enable(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] > MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; switch ((cmd[3] >> 4) & 0x3) { case 0: /* Do not change */ break; case 1: /* Enable bits */ if (cmd_len > 4) { sens->assert_enable |= cmd[4]; } if (cmd_len > 5) { sens->assert_enable |= cmd[5] << 8; } if (cmd_len > 6) { sens->deassert_enable |= cmd[6]; } if (cmd_len > 7) { sens->deassert_enable |= cmd[7] << 8; } break; case 2: /* Disable bits */ if (cmd_len > 4) { sens->assert_enable &= ~cmd[4]; } if (cmd_len > 5) { sens->assert_enable &= ~(cmd[5] << 8); } if (cmd_len > 6) { sens->deassert_enable &= ~cmd[6]; } if (cmd_len > 7) { sens->deassert_enable &= ~(cmd[7] << 8); } break; case 3: rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } IPMI_SENSOR_SET_RET_STATUS(sens, cmd[3]); }
true
qemu
73d60fa5fae60c8e07e1f295d8c7fd5d04320160
static void set_sensor_evt_enable(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] > MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; switch ((cmd[3] >> 4) & 0x3) { case 0: break; case 1: if (cmd_len > 4) { sens->assert_enable |= cmd[4]; } if (cmd_len > 5) { sens->assert_enable |= cmd[5] << 8; } if (cmd_len > 6) { sens->deassert_enable |= cmd[6]; } if (cmd_len > 7) { sens->deassert_enable |= cmd[7] << 8; } break; case 2: if (cmd_len > 4) { sens->assert_enable &= ~cmd[4]; } if (cmd_len > 5) { sens->assert_enable &= ~(cmd[5] << 8); } if (cmd_len > 6) { sens->deassert_enable &= ~cmd[6]; } if (cmd_len > 7) { sens->deassert_enable &= ~(cmd[7] << 8); } break; case 3: rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } IPMI_SENSOR_SET_RET_STATUS(sens, cmd[3]); }
{ "code": [ " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||", " if ((cmd[2] > MAX_SENSORS) ||" ], "line_no": [ 17, 17, 17, 17, 17, 17, 17 ] }
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) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((VAR_1[2] > MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) { VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = VAR_0->sensors + VAR_1[2]; switch ((VAR_1[3] >> 4) & 0x3) { case 0: break; case 1: if (VAR_2 > 4) { sens->assert_enable |= VAR_1[4]; } if (VAR_2 > 5) { sens->assert_enable |= VAR_1[5] << 8; } if (VAR_2 > 6) { sens->deassert_enable |= VAR_1[6]; } if (VAR_2 > 7) { sens->deassert_enable |= VAR_1[7] << 8; } break; case 2: if (VAR_2 > 4) { sens->assert_enable &= ~VAR_1[4]; } if (VAR_2 > 5) { sens->assert_enable &= ~(VAR_1[5] << 8); } if (VAR_2 > 6) { sens->deassert_enable &= ~VAR_1[6]; } if (VAR_2 > 7) { sens->deassert_enable &= ~(VAR_1[7] << 8); } break; case 3: VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; return; } IPMI_SENSOR_SET_RET_STATUS(sens, VAR_1[3]); }
[ "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{", "IPMISensor *sens;", "IPMI_CHECK_CMD_LEN(4);", "if ((VAR_1[2] > MAX_SENSORS) ||\n!IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) {", "VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;", "return;", "}", "sens = VAR_0->sensors + VAR_1[2];", "switch ((VAR_1[3] >> 4) & 0x3) {", "case 0:\nbreak;", "case 1:\nif (VAR_2 > 4) {", "sens->assert_enable |= VAR_1[4];", "}", "if (VAR_2 > 5) {", "sens->assert_enable |= VAR_1[5] << 8;", "}", "if (VAR_2 > 6) {", "sens->deassert_enable |= VAR_1[6];", "}", "if (VAR_2 > 7) {", "sens->deassert_enable |= VAR_1[7] << 8;", "}", "break;", "case 2:\nif (VAR_2 > 4) {", "sens->assert_enable &= ~VAR_1[4];", "}", "if (VAR_2 > 5) {", "sens->assert_enable &= ~(VAR_1[5] << 8);", "}", "if (VAR_2 > 6) {", "sens->deassert_enable &= ~VAR_1[6];", "}", "if (VAR_2 > 7) {", "sens->deassert_enable &= ~(VAR_1[7] << 8);", "}", "break;", "case 3:\nVAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;", "return;", "}", "IPMI_SENSOR_SET_RET_STATUS(sens, VAR_1[3]);", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ] ]
11,700
static inline void *host_from_stream_offset(QEMUFile *f, ram_addr_t offset, int flags) { static RAMBlock *block = NULL; char id[256]; uint8_t len; if (flags & RAM_SAVE_FLAG_CONTINUE) { if (!block) { error_report("Ack, bad migration stream!"); return NULL; } return memory_region_get_ram_ptr(block->mr) + offset; } len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)id, len); id[len] = 0; QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) return memory_region_get_ram_ptr(block->mr) + offset; } error_report("Can't find block %s!", id); return NULL; }
true
qemu
0be839a2701369f669532ea5884c15bead1c6e08
static inline void *host_from_stream_offset(QEMUFile *f, ram_addr_t offset, int flags) { static RAMBlock *block = NULL; char id[256]; uint8_t len; if (flags & RAM_SAVE_FLAG_CONTINUE) { if (!block) { error_report("Ack, bad migration stream!"); return NULL; } return memory_region_get_ram_ptr(block->mr) + offset; } len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)id, len); id[len] = 0; QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) return memory_region_get_ram_ptr(block->mr) + offset; } error_report("Can't find block %s!", id); return NULL; }
{ "code": [ " if (!block) {", " if (!strncmp(id, block->idstr, sizeof(id)))" ], "line_no": [ 19, 45 ] }
static inline void *FUNC_0(QEMUFile *VAR_0, ram_addr_t VAR_1, int VAR_2) { static RAMBlock *VAR_3 = NULL; char VAR_4[256]; uint8_t len; if (VAR_2 & RAM_SAVE_FLAG_CONTINUE) { if (!VAR_3) { error_report("Ack, bad migration stream!"); return NULL; } return memory_region_get_ram_ptr(VAR_3->mr) + VAR_1; } len = qemu_get_byte(VAR_0); qemu_get_buffer(VAR_0, (uint8_t *)VAR_4, len); VAR_4[len] = 0; QTAILQ_FOREACH(VAR_3, &ram_list.blocks, next) { if (!strncmp(VAR_4, VAR_3->idstr, sizeof(VAR_4))) return memory_region_get_ram_ptr(VAR_3->mr) + VAR_1; } error_report("Can't find VAR_3 %s!", VAR_4); return NULL; }
[ "static inline void *FUNC_0(QEMUFile *VAR_0,\nram_addr_t VAR_1,\nint VAR_2)\n{", "static RAMBlock *VAR_3 = NULL;", "char VAR_4[256];", "uint8_t len;", "if (VAR_2 & RAM_SAVE_FLAG_CONTINUE) {", "if (!VAR_3) {", "error_report(\"Ack, bad migration stream!\");", "return NULL;", "}", "return memory_region_get_ram_ptr(VAR_3->mr) + VAR_1;", "}", "len = qemu_get_byte(VAR_0);", "qemu_get_buffer(VAR_0, (uint8_t *)VAR_4, len);", "VAR_4[len] = 0;", "QTAILQ_FOREACH(VAR_3, &ram_list.blocks, next) {", "if (!strncmp(VAR_4, VAR_3->idstr, sizeof(VAR_4)))\nreturn memory_region_get_ram_ptr(VAR_3->mr) + VAR_1;", "}", "error_report(\"Can't find VAR_3 %s!\", VAR_4);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ] ]
11,701
static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { int i; DiracContext *s = avctx->priv_data; DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr; for (i = 0; i < s->num_x; i++) decode_hq_slice(avctx, &slices[i]); return 0; }
true
FFmpeg
c43485f70765cb488bfdf95dc783bb9b14eb1179
static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { int i; DiracContext *s = avctx->priv_data; DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr; for (i = 0; i < s->num_x; i++) decode_hq_slice(avctx, &slices[i]); return 0; }
{ "code": [ " DiracContext *s = avctx->priv_data;", " decode_hq_slice(avctx, &slices[i]);" ], "line_no": [ 7, 13 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3) { int VAR_4; DiracContext *s = VAR_0->priv_data; DiracSlice *slices = ((DiracSlice *)VAR_1) + s->num_x*VAR_2; for (VAR_4 = 0; VAR_4 < s->num_x; VAR_4++) decode_hq_slice(VAR_0, &slices[VAR_4]); return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4;", "DiracContext *s = VAR_0->priv_data;", "DiracSlice *slices = ((DiracSlice *)VAR_1) + s->num_x*VAR_2;", "for (VAR_4 = 0; VAR_4 < s->num_x; VAR_4++)", "decode_hq_slice(VAR_0, &slices[VAR_4]);", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]