id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
sequencelengths
1
2.8k
label
sequencelengths
1
2.8k
line_no
sequencelengths
1
2.8k
0
static av_cold int vdadec_init(AVCodecContext *avctx) { VDADecoderContext *ctx = avctx->priv_data; struct vda_context *vda_ctx = &ctx->vda_ctx; OSStatus status; int ret; ctx->h264_initialized = 0; /* init pix_fmts of codec */ if (!ff_h264_vda_decoder.pix_fmts) { if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7) ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7; else ff_h264_vda_decoder.pix_fmts = vda_pixfmts; } /* init vda */ memset(vda_ctx, 0, sizeof(struct vda_context)); vda_ctx->width = avctx->width; vda_ctx->height = avctx->height; vda_ctx->format = 'avc1'; vda_ctx->use_sync_decoding = 1; vda_ctx->use_ref_buffer = 1; ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); switch (ctx->pix_fmt) { case AV_PIX_FMT_UYVY422: vda_ctx->cv_pix_fmt_type = '2vuy'; break; case AV_PIX_FMT_YUYV422: vda_ctx->cv_pix_fmt_type = 'yuvs'; break; case AV_PIX_FMT_NV12: vda_ctx->cv_pix_fmt_type = '420v'; break; case AV_PIX_FMT_YUV420P: vda_ctx->cv_pix_fmt_type = 'y420'; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt); goto failed; } status = ff_vda_create_decoder(vda_ctx, avctx->extradata, avctx->extradata_size); if (status != kVDADecoderNoErr) { av_log(avctx, AV_LOG_ERROR, "Failed to init VDA decoder: %d.\n", status); goto failed; } avctx->hwaccel_context = vda_ctx; /* changes callback functions */ avctx->get_format = get_format; avctx->get_buffer2 = get_buffer2; #if FF_API_GET_BUFFER // force the old get_buffer to be empty avctx->get_buffer = NULL; #endif /* init H.264 decoder */ ret = ff_h264_decoder.init(avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n"); goto failed; } ctx->h264_initialized = 1; return 0; failed: vdadec_close(avctx); return -1; }
false
FFmpeg
973b1a6b9070e2bf17d17568cbaf4043ce931f51
static av_cold int vdadec_init(AVCodecContext *avctx) { VDADecoderContext *ctx = avctx->priv_data; struct vda_context *vda_ctx = &ctx->vda_ctx; OSStatus status; int ret; ctx->h264_initialized = 0; if (!ff_h264_vda_decoder.pix_fmts) { if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7) ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7; else ff_h264_vda_decoder.pix_fmts = vda_pixfmts; } memset(vda_ctx, 0, sizeof(struct vda_context)); vda_ctx->width = avctx->width; vda_ctx->height = avctx->height; vda_ctx->format = 'avc1'; vda_ctx->use_sync_decoding = 1; vda_ctx->use_ref_buffer = 1; ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); switch (ctx->pix_fmt) { case AV_PIX_FMT_UYVY422: vda_ctx->cv_pix_fmt_type = '2vuy'; break; case AV_PIX_FMT_YUYV422: vda_ctx->cv_pix_fmt_type = 'yuvs'; break; case AV_PIX_FMT_NV12: vda_ctx->cv_pix_fmt_type = '420v'; break; case AV_PIX_FMT_YUV420P: vda_ctx->cv_pix_fmt_type = 'y420'; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt); goto failed; } status = ff_vda_create_decoder(vda_ctx, avctx->extradata, avctx->extradata_size); if (status != kVDADecoderNoErr) { av_log(avctx, AV_LOG_ERROR, "Failed to init VDA decoder: %d.\n", status); goto failed; } avctx->hwaccel_context = vda_ctx; avctx->get_format = get_format; avctx->get_buffer2 = get_buffer2; #if FF_API_GET_BUFFER avctx->get_buffer = NULL; #endif ret = ff_h264_decoder.init(avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n"); goto failed; } ctx->h264_initialized = 1; return 0; failed: vdadec_close(avctx); return -1; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { VDADecoderContext *ctx = avctx->priv_data; struct vda_context *VAR_0 = &ctx->VAR_0; OSStatus status; int VAR_1; ctx->h264_initialized = 0; if (!ff_h264_vda_decoder.pix_fmts) { if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7) ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7; else ff_h264_vda_decoder.pix_fmts = vda_pixfmts; } memset(VAR_0, 0, sizeof(struct vda_context)); VAR_0->width = avctx->width; VAR_0->height = avctx->height; VAR_0->format = 'avc1'; VAR_0->use_sync_decoding = 1; VAR_0->use_ref_buffer = 1; ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); switch (ctx->pix_fmt) { case AV_PIX_FMT_UYVY422: VAR_0->cv_pix_fmt_type = '2vuy'; break; case AV_PIX_FMT_YUYV422: VAR_0->cv_pix_fmt_type = 'yuvs'; break; case AV_PIX_FMT_NV12: VAR_0->cv_pix_fmt_type = '420v'; break; case AV_PIX_FMT_YUV420P: VAR_0->cv_pix_fmt_type = 'y420'; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt); goto failed; } status = ff_vda_create_decoder(VAR_0, avctx->extradata, avctx->extradata_size); if (status != kVDADecoderNoErr) { av_log(avctx, AV_LOG_ERROR, "Failed to init VDA decoder: %d.\n", status); goto failed; } avctx->hwaccel_context = VAR_0; avctx->get_format = get_format; avctx->get_buffer2 = get_buffer2; #if FF_API_GET_BUFFER avctx->get_buffer = NULL; #endif VAR_1 = ff_h264_decoder.init(avctx); if (VAR_1 < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n"); goto failed; } ctx->h264_initialized = 1; return 0; failed: vdadec_close(avctx); return -1; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "VDADecoderContext *ctx = avctx->priv_data;", "struct vda_context *VAR_0 = &ctx->VAR_0;", "OSStatus status;", "int VAR_1;", "ctx->h264_initialized = 0;", "if (!ff_h264_vda_decoder.pix_fmts) {", "if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)\nff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;", "else\nff_h264_vda_decoder.pix_fmts = vda_pixfmts;", "}", "memset(VAR_0, 0, sizeof(struct vda_context));", "VAR_0->width = avctx->width;", "VAR_0->height = avctx->height;", "VAR_0->format = 'avc1';", "VAR_0->use_sync_decoding = 1;", "VAR_0->use_ref_buffer = 1;", "ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);", "switch (ctx->pix_fmt) {", "case AV_PIX_FMT_UYVY422:\nVAR_0->cv_pix_fmt_type = '2vuy';", "break;", "case AV_PIX_FMT_YUYV422:\nVAR_0->cv_pix_fmt_type = 'yuvs';", "break;", "case AV_PIX_FMT_NV12:\nVAR_0->cv_pix_fmt_type = '420v';", "break;", "case AV_PIX_FMT_YUV420P:\nVAR_0->cv_pix_fmt_type = 'y420';", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"Unsupported pixel format: %d\\n\", avctx->pix_fmt);", "goto failed;", "}", "status = ff_vda_create_decoder(VAR_0,\navctx->extradata, avctx->extradata_size);", "if (status != kVDADecoderNoErr) {", "av_log(avctx, AV_LOG_ERROR,\n\"Failed to init VDA decoder: %d.\\n\", status);", "goto failed;", "}", "avctx->hwaccel_context = VAR_0;", "avctx->get_format = get_format;", "avctx->get_buffer2 = get_buffer2;", "#if FF_API_GET_BUFFER\navctx->get_buffer = NULL;", "#endif\nVAR_1 = ff_h264_decoder.init(avctx);", "if (VAR_1 < 0) {", "av_log(avctx, AV_LOG_ERROR, \"Failed to open H.264 decoder.\\n\");", "goto failed;", "}", "ctx->h264_initialized = 1;", "return 0;", "failed:\nvdadec_close(avctx);", "return -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 21 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 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 ], [ 105 ], [ 107 ], [ 109, 113 ], [ 115, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 139, 141 ], [ 143 ], [ 145 ] ]
1
static int transcode(AVFormatContext **output_files, int nb_output_files, InputFile *input_files, int nb_input_files, StreamMap *stream_maps, int nb_stream_maps) { int ret = 0, i, j, k, n, nb_ostreams = 0, step; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; OutputStream *ost, **ost_table = NULL; InputStream *ist; char error[1024]; int key; int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; int no_packet_count=0; int nb_frame_threshold[AVMEDIA_TYPE_NB]={0}; int nb_streams[AVMEDIA_TYPE_NB]={0}; if (rate_emu) for (i = 0; i < nb_input_streams; i++) input_streams[i].start = av_gettime(); /* output stream init */ nb_ostreams = 0; for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); ret = AVERROR(EINVAL); goto fail; } nb_ostreams += os->nb_streams; } if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) { fprintf(stderr, "Number of stream maps must match number of output streams\n"); ret = AVERROR(EINVAL); goto fail; } /* Sanity check the mapping args -- do the input files & streams exist? */ for(i=0;i<nb_stream_maps;i++) { int fi = stream_maps[i].file_index; int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > input_files[fi].ctx->nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } fi = stream_maps[i].sync_file_index; si = stream_maps[i].sync_stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > input_files[fi].ctx->nb_streams - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(OutputStream *) * nb_ostreams); if (!ost_table) goto fail; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { nb_streams[os->streams[i]->codec->codec_type]++; } } for(step=1<<30; step; step>>=1){ int found_streams[AVMEDIA_TYPE_NB]={0}; for(j=0; j<AVMEDIA_TYPE_NB; j++) nb_frame_threshold[j] += step; for(j=0; j<nb_input_streams; j++) { int skip=0; ist = &input_streams[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ found_streams[ist->st->codec->codec_type]++; } } for(j=0; j<AVMEDIA_TYPE_NB; j++) if(found_streams[j] < nb_streams[j]) nb_frame_threshold[j] -= step; } n = 0; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { int found; ost = ost_table[n] = output_streams_for_file[k][i]; if (nb_stream_maps > 0) { ost->source_index = input_files[stream_maps[n].file_index].ist_index + stream_maps[n].stream_index; /* Sanity check that the stream types match */ if (input_streams[ost->source_index].st->codec->codec_type != ost->st->codec->codec_type) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", stream_maps[n].file_index, stream_maps[n].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { /* get corresponding input stream index : we select the first one with the right type */ found = 0; for (j = 0; j < nb_input_streams; j++) { int skip=0; ist = &input_streams[j]; if(opt_programid){ int pi,si; AVFormatContext *f = input_files[ist->file_index].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && ist->st->codec->codec_type == ost->st->codec->codec_type && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = j; found = 1; break; } } if (!found) { if(! opt_programid) { /* try again and reuse existing stream */ for (j = 0; j < nb_input_streams; j++) { ist = &input_streams[j]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = j; found = 1; } } } if (!found) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = &input_streams[ost->source_index]; ist->discard = 0; ost->sync_ist = (nb_stream_maps > 0) ? &input_streams[input_files[stream_maps[n].sync_file_index].ist_index + stream_maps[n].sync_stream_index] : ist; } } /* for each output stream, we compute the right encoding parameters */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; os = output_files[ost->file_index]; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_dict_copy(&ost->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; /* if stream_copy is selected, no need to decode or encode */ codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) { codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; } if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { codec->bits_per_raw_sample= frame_bits_per_raw_sample; } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; if( av_q2d(codec->time_base) < 0.001 && video_sync_method && (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){ av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n" "Please consider specifiying a lower framerate, a different muxer or -vsync 2\n"); } #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } /* two pass mode */ if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); ffmpeg_exit(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ /* maximum video buffer size is 6-bytes per pixel, plus DPX header size */ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); ret = AVERROR(ENOMEM); goto fail; } /* open each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } /* open each decoder */ for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->st->index); ret = AVERROR(EINVAL); goto dump_format; } if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->st->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ost->opts); //if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD; } } /* init pts */ for (i = 0; i < nb_input_streams; i++) { AVStream *st; ist = &input_streams[i]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } /* set meta data information from input file if required */ for (i=0;i<nb_meta_data_maps;i++) { AVFormatContext *files[2]; AVDictionary **meta[2]; int j; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\ (desc), (index));\ ret = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[i][0].file; int in_file_index = meta_data_maps[i][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file") METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file") files[0] = output_files[out_file_index]; files[1] = input_files[in_file_index].ctx; for (j = 0; j < 2; j++) { MetadataMap *map = &meta_data_maps[i][j]; switch (map->type) { case 'g': meta[j] = &files[j]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream") meta[j] = &files[j]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter") meta[j] = &files[j]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program") meta[j] = &files[j]->programs[map->index]->metadata; break; } } av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE); } /* copy global metadata by default */ if (metadata_global_autocopy) { for (i = 0; i < nb_output_files; i++) av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata, AV_DICT_DONT_OVERWRITE); } /* copy chapters according to chapter maps */ for (i = 0; i < nb_chapter_maps; i++) { int infile = chapter_maps[i].in_file; int outfile = chapter_maps[i].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= nb_input_files) { snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile); ret = AVERROR(EINVAL); goto dump_format; } if (outfile >= nb_output_files) { snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile); ret = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } /* copy chapters from the first input file that has them*/ if (!nb_chapter_maps) for (i = 0; i < nb_input_files; i++) { if (!input_files[i].ctx->nb_chapters) continue; for (j = 0; j < nb_output_files; j++) if ((ret = copy_chapters(i, j)) < 0) goto dump_format; break; } /* open files and write file headers */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (avformat_write_header(os, &output_opts[i]) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_opts[i]); if (strcmp(output_files[i]->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: /* dump the file output parameters - cannot be done before in case of stream copy */ for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); } /* dump the stream mapping */ if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); goto fail; } if (want_sdp) { print_sdp(output_files, nb_output_files); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop, [?] for help\n"); avio_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; /* if 'q' pressed, exits */ if (!using_stdin) { if (q_pressed) break; /* read_key() returns 0 on EOF */ key = read_key(); if (key == 'q') break; if (key == '+') verbose++; if (key == '-') verbose--; if (key == 's') qp_hist ^= 1; if (key == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (key == 'd' || key == 'D'){ int debug=0; if(key == 'D') { debug = input_streams[0].st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash debug += debug; }else scanf("%d", &debug); for(i=0;i<nb_input_streams;i++) { input_streams[i].st->codec->debug = debug; } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); } if (key == '?'){ fprintf(stderr, "key function\n" "? show this help\n" "+ increase verbosity\n" "- decrease verbosity\n" "D cycle through available debug modes\n" "h dump packets/hex press to cycle through the 3 states\n" "q quit\n" "s Show QP histogram\n" ); } } /* select the stream that we must read now by looking at the smallest output pts */ file_index = -1; for(i=0;i<nb_ostreams;i++) { double ipts, opts; ost = ost_table[i]; os = output_files[ost->file_index]; ist = &input_streams[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!input_files[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } /* if none, if is finished */ if (file_index < 0) { if(no_packet_count){ no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } /* finish if limit size exhausted */ if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb)) break; /* read a frame from it and output it in the fifo */ is = input_files[file_index].ctx; ret= av_read_frame(is, &pkt); if(ret == AVERROR(EAGAIN)){ no_packet[file_index]=1; no_packet_count++; continue; } if (ret < 0) { input_files[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ if (pkt.stream_index >= input_files[file_index].ctx->nb_streams) goto discard_packet; ist_index = input_files[file_index].ist_index + pkt.stream_index; ist = &input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (ist->ts_scale) { if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; } // fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type); if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ input_files[ist->file_index].ts_offset -= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files[ist->file_index].ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if(pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } /* finish if recording time exhausted */ if (recording_time != INT64_MAX && (pkt.pts != AV_NOPTS_VALUE ? av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) : av_compare_ts(ist->pts, AV_TIME_BASE_Q, recording_time + start_time, (AVRational){1, 1000000}) )>= 0) { ist->is_past_recording_time = 1; goto discard_packet; } //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size); if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->st->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 0); } /* at the end of stream, we must flush the decoder buffers */ for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { output_packet(ist, i, ost_table, nb_ostreams, NULL); } } term_exit(); /* write the trailer if needed and close file */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; av_write_trailer(os); } /* dump report by using the first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 1); /* close each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } /* close each decoder */ for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } /* finished ! */ ret = 0; fail: av_freep(&bit_buffer); if (ost_table) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); /* works even if fifo is not initialized but set to zero */ av_freep(&ost->st->codec->subtitle_header); av_free(ost->resample_frame.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_dict_free(&ost->opts); av_free(ost); } } av_free(ost_table); } return ret; }
false
FFmpeg
321b2a9ded0468670b7678b7c098886930ae16b2
static int transcode(AVFormatContext **output_files, int nb_output_files, InputFile *input_files, int nb_input_files, StreamMap *stream_maps, int nb_stream_maps) { int ret = 0, i, j, k, n, nb_ostreams = 0, step; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; OutputStream *ost, **ost_table = NULL; InputStream *ist; char error[1024]; int key; int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; int no_packet_count=0; int nb_frame_threshold[AVMEDIA_TYPE_NB]={0}; int nb_streams[AVMEDIA_TYPE_NB]={0}; if (rate_emu) for (i = 0; i < nb_input_streams; i++) input_streams[i].start = av_gettime(); nb_ostreams = 0; for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); ret = AVERROR(EINVAL); goto fail; } nb_ostreams += os->nb_streams; } if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) { fprintf(stderr, "Number of stream maps must match number of output streams\n"); ret = AVERROR(EINVAL); goto fail; } for(i=0;i<nb_stream_maps;i++) { int fi = stream_maps[i].file_index; int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > input_files[fi].ctx->nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } fi = stream_maps[i].sync_file_index; si = stream_maps[i].sync_stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > input_files[fi].ctx->nb_streams - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(OutputStream *) * nb_ostreams); if (!ost_table) goto fail; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { nb_streams[os->streams[i]->codec->codec_type]++; } } for(step=1<<30; step; step>>=1){ int found_streams[AVMEDIA_TYPE_NB]={0}; for(j=0; j<AVMEDIA_TYPE_NB; j++) nb_frame_threshold[j] += step; for(j=0; j<nb_input_streams; j++) { int skip=0; ist = &input_streams[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ found_streams[ist->st->codec->codec_type]++; } } for(j=0; j<AVMEDIA_TYPE_NB; j++) if(found_streams[j] < nb_streams[j]) nb_frame_threshold[j] -= step; } n = 0; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { int found; ost = ost_table[n] = output_streams_for_file[k][i]; if (nb_stream_maps > 0) { ost->source_index = input_files[stream_maps[n].file_index].ist_index + stream_maps[n].stream_index; if (input_streams[ost->source_index].st->codec->codec_type != ost->st->codec->codec_type) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", stream_maps[n].file_index, stream_maps[n].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { found = 0; for (j = 0; j < nb_input_streams; j++) { int skip=0; ist = &input_streams[j]; if(opt_programid){ int pi,si; AVFormatContext *f = input_files[ist->file_index].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && ist->st->codec->codec_type == ost->st->codec->codec_type && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = j; found = 1; break; } } if (!found) { if(! opt_programid) { for (j = 0; j < nb_input_streams; j++) { ist = &input_streams[j]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = j; found = 1; } } } if (!found) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = &input_streams[ost->source_index]; ist->discard = 0; ost->sync_ist = (nb_stream_maps > 0) ? &input_streams[input_files[stream_maps[n].sync_file_index].ist_index + stream_maps[n].sync_stream_index] : ist; } } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; os = output_files[ost->file_index]; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_dict_copy(&ost->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) { codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; } if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { codec->bits_per_raw_sample= frame_bits_per_raw_sample; } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; if( av_q2d(codec->time_base) < 0.001 && video_sync_method && (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){ av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n" "Please consider specifiying a lower framerate, a different muxer or -vsync 2\n"); } #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); ffmpeg_exit(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); ret = AVERROR(ENOMEM); goto fail; } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->st->index); ret = AVERROR(EINVAL); goto dump_format; } if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->st->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ost->opts); } } for (i = 0; i < nb_input_streams; i++) { AVStream *st; ist = &input_streams[i]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } for (i=0;i<nb_meta_data_maps;i++) { AVFormatContext *files[2]; AVDictionary **meta[2]; int j; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\ (desc), (index));\ ret = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[i][0].file; int in_file_index = meta_data_maps[i][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file") METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file") files[0] = output_files[out_file_index]; files[1] = input_files[in_file_index].ctx; for (j = 0; j < 2; j++) { MetadataMap *map = &meta_data_maps[i][j]; switch (map->type) { case 'g': meta[j] = &files[j]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream") meta[j] = &files[j]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter") meta[j] = &files[j]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program") meta[j] = &files[j]->programs[map->index]->metadata; break; } } av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE); } if (metadata_global_autocopy) { for (i = 0; i < nb_output_files; i++) av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata, AV_DICT_DONT_OVERWRITE); } for (i = 0; i < nb_chapter_maps; i++) { int infile = chapter_maps[i].in_file; int outfile = chapter_maps[i].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= nb_input_files) { snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile); ret = AVERROR(EINVAL); goto dump_format; } if (outfile >= nb_output_files) { snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile); ret = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } if (!nb_chapter_maps) for (i = 0; i < nb_input_files; i++) { if (!input_files[i].ctx->nb_chapters) continue; for (j = 0; j < nb_output_files; j++) if ((ret = copy_chapters(i, j)) < 0) goto dump_format; break; } for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (avformat_write_header(os, &output_opts[i]) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_opts[i]); if (strcmp(output_files[i]->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); goto fail; } if (want_sdp) { print_sdp(output_files, nb_output_files); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop, [?] for help\n"); avio_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; if (!using_stdin) { if (q_pressed) break; key = read_key(); if (key == 'q') break; if (key == '+') verbose++; if (key == '-') verbose--; if (key == 's') qp_hist ^= 1; if (key == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (key == 'd' || key == 'D'){ int debug=0; if(key == 'D') { debug = input_streams[0].st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) debug += debug; }else scanf("%d", &debug); for(i=0;i<nb_input_streams;i++) { input_streams[i].st->codec->debug = debug; } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); } if (key == '?'){ fprintf(stderr, "key function\n" "? show this help\n" "+ increase verbosity\n" "- decrease verbosity\n" "D cycle through available debug modes\n" "h dump packets/hex press to cycle through the 3 states\n" "q quit\n" "s Show QP histogram\n" ); } } file_index = -1; for(i=0;i<nb_ostreams;i++) { double ipts, opts; ost = ost_table[i]; os = output_files[ost->file_index]; ist = &input_streams[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!input_files[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } if (file_index < 0) { if(no_packet_count){ no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb)) break; is = input_files[file_index].ctx; ret= av_read_frame(is, &pkt); if(ret == AVERROR(EAGAIN)){ no_packet[file_index]=1; no_packet_count++; continue; } if (ret < 0) { input_files[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } if (pkt.stream_index >= input_files[file_index].ctx->nb_streams) goto discard_packet; ist_index = input_files[file_index].ist_index + pkt.stream_index; ist = &input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (ist->ts_scale) { if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; } if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ input_files[ist->file_index].ts_offset -= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files[ist->file_index].ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if(pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } if (recording_time != INT64_MAX && (pkt.pts != AV_NOPTS_VALUE ? av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) : av_compare_ts(ist->pts, AV_TIME_BASE_Q, recording_time + start_time, (AVRational){1, 1000000}) )>= 0) { ist->is_past_recording_time = 1; goto discard_packet; } if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->st->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); print_report(output_files, ost_table, nb_ostreams, 0); } for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { output_packet(ist, i, ost_table, nb_ostreams, NULL); } } term_exit(); for(i=0;i<nb_output_files;i++) { os = output_files[i]; av_write_trailer(os); } print_report(output_files, ost_table, nb_ostreams, 1); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } ret = 0; fail: av_freep(&bit_buffer); if (ost_table) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); av_freep(&ost->st->codec->subtitle_header); av_free(ost->resample_frame.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_dict_free(&ost->opts); av_free(ost); } } av_free(ost_table); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext **VAR_0, int VAR_1, InputFile *VAR_2, int VAR_3, StreamMap *VAR_4, int VAR_5) { int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; OutputStream *ost, **ost_table = NULL; InputStream *ist; char VAR_13[1024]; int VAR_14; int VAR_15 = 1; uint8_t no_packet[MAX_FILES]={0}; int VAR_16=0; int VAR_17[AVMEDIA_TYPE_NB]={0}; int VAR_18[AVMEDIA_TYPE_NB]={0}; if (rate_emu) for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) input_streams[VAR_7].start = av_gettime(); VAR_11 = 0; for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; if (!os->VAR_18 && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\VAR_10", VAR_7); VAR_6 = AVERROR(EINVAL); goto fail; } VAR_11 += os->VAR_18; } if (VAR_5 > 0 && VAR_5 != VAR_11) { fprintf(stderr, "Number of stream maps must match number of output streams\VAR_10"); VAR_6 = AVERROR(EINVAL); goto fail; } for(VAR_7=0;VAR_7<VAR_5;VAR_7++) { int VAR_19 = VAR_4[VAR_7].file_index; int VAR_20 = VAR_4[VAR_7].stream_index; if (VAR_19 < 0 || VAR_19 > VAR_3 - 1 || VAR_20 < 0 || VAR_20 > VAR_2[VAR_19].ctx->VAR_18 - 1) { fprintf(stderr,"Could not find input stream #%d.%d\VAR_10", VAR_19, VAR_20); VAR_6 = AVERROR(EINVAL); goto fail; } VAR_19 = VAR_4[VAR_7].sync_file_index; VAR_20 = VAR_4[VAR_7].sync_stream_index; if (VAR_19 < 0 || VAR_19 > VAR_3 - 1 || VAR_20 < 0 || VAR_20 > VAR_2[VAR_19].ctx->VAR_18 - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\VAR_10", VAR_19, VAR_20); VAR_6 = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(OutputStream *) * VAR_11); if (!ost_table) goto fail; for(VAR_9=0;VAR_9<VAR_1;VAR_9++) { os = VAR_0[VAR_9]; for(VAR_7=0;VAR_7<os->VAR_18;VAR_7++,VAR_10++) { VAR_18[os->streams[VAR_7]->codec->codec_type]++; } } for(VAR_12=1<<30; VAR_12; VAR_12>>=1){ int VAR_21[AVMEDIA_TYPE_NB]={0}; for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++) VAR_17[VAR_8] += VAR_12; for(VAR_8=0; VAR_8<nb_input_streams; VAR_8++) { int skip=0; ist = &input_streams[VAR_8]; if(opt_programid){ int pi,VAR_20; AVFormatContext *f= VAR_2[ ist->file_index ].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(VAR_20=0; VAR_20<p->nb_stream_indexes; VAR_20++){ if(f->streams[ p->stream_index[VAR_20] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && VAR_17[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ VAR_21[ist->st->codec->codec_type]++; } } for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++) if(VAR_21[VAR_8] < VAR_18[VAR_8]) VAR_17[VAR_8] -= VAR_12; } VAR_10 = 0; for(VAR_9=0;VAR_9<VAR_1;VAR_9++) { os = VAR_0[VAR_9]; for(VAR_7=0;VAR_7<os->VAR_18;VAR_7++,VAR_10++) { int found; ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7]; if (VAR_5 > 0) { ost->source_index = VAR_2[VAR_4[VAR_10].file_index].ist_index + VAR_4[VAR_10].stream_index; if (input_streams[ost->source_index].st->codec->codec_type != ost->st->codec->codec_type) { int VAR_7= ost->file_index; av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\VAR_10", VAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { found = 0; for (VAR_8 = 0; VAR_8 < nb_input_streams; VAR_8++) { int skip=0; ist = &input_streams[VAR_8]; if(opt_programid){ int pi,VAR_20; AVFormatContext *f = VAR_2[ist->file_index].ctx; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(VAR_20=0; VAR_20<p->nb_stream_indexes; VAR_20++){ if(f->streams[ p->stream_index[VAR_20] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && ist->st->codec->codec_type == ost->st->codec->codec_type && VAR_17[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = VAR_8; found = 1; break; } } if (!found) { if(! opt_programid) { for (VAR_8 = 0; VAR_8 < nb_input_streams; VAR_8++) { ist = &input_streams[VAR_8]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = VAR_8; found = 1; } } } if (!found) { int VAR_7= ost->file_index; av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\VAR_10", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = &input_streams[ost->source_index]; ist->discard = 0; ost->sync_ist = (VAR_5 > 0) ? &input_streams[VAR_2[VAR_4[VAR_10].sync_file_index].ist_index + VAR_4[VAR_10].sync_stream_index] : ist; } } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; os = VAR_0[ost->file_index]; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_dict_copy(&ost->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\VAR_10"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) { codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; } if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\VAR_10"); ffmpeg_exit(1); } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { codec->bits_per_raw_sample= frame_bits_per_raw_sample; } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int VAR_22 = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[VAR_22]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; if( av_q2d(codec->time_base) < 0.001 && video_sync_method && (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){ av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\VAR_10" "Please consider specifiying a lower framerate, a different muxer or -vsync 2\VAR_10"); } #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\VAR_10"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char VAR_23[1024]; FILE *f; snprintf(VAR_23, sizeof(VAR_23), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, VAR_7); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(VAR_23, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\VAR_10", VAR_23, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *VAR_24; size_t logbuffer_size; if (read_file(VAR_23, &VAR_24, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\VAR_10", VAR_23); ffmpeg_exit(1); } codec->stats_in = VAR_24; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int VAR_25= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_25 + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\VAR_10", bit_buffer_size); VAR_6 = AVERROR(ENOMEM); goto fail; } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(VAR_13, sizeof(VAR_13), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { VAR_6 = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(VAR_13, sizeof(VAR_13), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\VAR_10"); extra_size += ost->st->codec->extradata_size; } } for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) { ist = &input_streams[VAR_7]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(VAR_13, sizeof(VAR_13), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->st->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(VAR_13, sizeof(VAR_13), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->st->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ost->opts); } } for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) { AVStream *st; ist = &input_streams[VAR_7]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) { AVFormatContext *files[2]; AVDictionary **meta[2]; int VAR_8; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(VAR_13, sizeof(VAR_13), "Invalid %s index %d while processing metadata maps\VAR_10",\ (desc), (index));\ VAR_6 = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[VAR_7][0].file; int in_file_index = meta_data_maps[VAR_7][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, VAR_1, "output file") METADATA_CHECK_INDEX(in_file_index, VAR_3, "input file") files[0] = VAR_0[out_file_index]; files[1] = VAR_2[in_file_index].ctx; for (VAR_8 = 0; VAR_8 < 2; VAR_8++) { MetadataMap *map = &meta_data_maps[VAR_7][VAR_8]; switch (map->type) { case 'g': meta[VAR_8] = &files[VAR_8]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_18, "stream") meta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, "chapter") meta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, "program") meta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata; break; } } av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE); } if (metadata_global_autocopy) { for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++) av_dict_copy(&VAR_0[VAR_7]->metadata, VAR_2[0].ctx->metadata, AV_DICT_DONT_OVERWRITE); } for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) { int infile = chapter_maps[VAR_7].in_file; int outfile = chapter_maps[VAR_7].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= VAR_3) { snprintf(VAR_13, sizeof(VAR_13), "Invalid input file index %d in chapter mapping.\VAR_10", infile); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (outfile >= VAR_1) { snprintf(VAR_13, sizeof(VAR_13), "Invalid output file index %d in chapter mapping.\VAR_10",outfile); VAR_6 = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } if (!nb_chapter_maps) for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) { if (!VAR_2[VAR_7].ctx->nb_chapters) continue; for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++) if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0) goto dump_format; break; } for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; if (avformat_write_header(os, &output_opts[VAR_7]) < 0) { snprintf(VAR_13, sizeof(VAR_13), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_7); VAR_6 = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_opts[VAR_7]); if (strcmp(VAR_0[VAR_7]->oformat->name, "rtp")) { VAR_15 = 0; } } dump_format: for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\VAR_10"); for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); fprintf(stderr, "\VAR_10"); } } if (VAR_6) { fprintf(stderr, "%s\VAR_10", VAR_13); goto fail; } if (VAR_15) { print_sdp(VAR_0, VAR_1); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop, [?] for help\VAR_10"); avio_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; if (!using_stdin) { if (q_pressed) break; VAR_14 = read_key(); if (VAR_14 == 'q') break; if (VAR_14 == '+') verbose++; if (VAR_14 == '-') verbose--; if (VAR_14 == 's') qp_hist ^= 1; if (VAR_14 == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (VAR_14 == 'd' || VAR_14 == 'D'){ int debug=0; if(VAR_14 == 'D') { debug = input_streams[0].st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) debug += debug; }else scanf("%d", &debug); for(VAR_7=0;VAR_7<nb_input_streams;VAR_7++) { input_streams[VAR_7].st->codec->debug = debug; } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\VAR_10", debug); } if (VAR_14 == '?'){ fprintf(stderr, "VAR_14 function\VAR_10" "? show this help\VAR_10" "+ increase verbosity\VAR_10" "- decrease verbosity\VAR_10" "D cycle through available debug modes\VAR_10" "h dump packets/hex press to cycle through the 3 states\VAR_10" "q quit\VAR_10" "s Show QP histogram\VAR_10" ); } } file_index = -1; for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { double ipts, opts; ost = ost_table[VAR_7]; os = VAR_0[ost->file_index]; ist = &input_streams[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!VAR_2[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } if (file_index < 0) { if(VAR_16){ VAR_16=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb)) break; is = VAR_2[file_index].ctx; VAR_6= av_read_frame(is, &pkt); if(VAR_6 == AVERROR(EAGAIN)){ no_packet[file_index]=1; VAR_16++; continue; } if (VAR_6 < 0) { VAR_2[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } VAR_16=0; memset(no_packet, 0, sizeof(no_packet)); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } if (pkt.stream_index >= VAR_2[file_index].ctx->VAR_18) goto discard_packet; ist_index = VAR_2[file_index].ist_index + pkt.stream_index; ist = &input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (ist->ts_scale) { if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; } if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ VAR_2[ist->file_index].ts_offset -= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\VAR_10", delta, VAR_2[ist->file_index].ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if(pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } if (recording_time != INT64_MAX && (pkt.pts != AV_NOPTS_VALUE ? av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) : av_compare_ts(ist->pts, AV_TIME_BASE_Q, recording_time + start_time, (AVRational){1, 1000000}) )>= 0) { ist->is_past_recording_time = 1; goto discard_packet; } if (output_packet(ist, ist_index, ost_table, VAR_11, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\VAR_10", ist->file_index, ist->st->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); print_report(VAR_0, ost_table, VAR_11, 0); } for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) { ist = &input_streams[VAR_7]; if (ist->decoding_needed) { output_packet(ist, VAR_7, ost_table, VAR_11, NULL); } } term_exit(); for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; av_write_trailer(os); } print_report(VAR_0, ost_table, VAR_11, 1); for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) { ist = &input_streams[VAR_7]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } VAR_6 = 0; fail: av_freep(&bit_buffer); if (ost_table) { for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ost = ost_table[VAR_7]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); av_freep(&ost->st->codec->subtitle_header); av_free(ost->resample_frame.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_dict_free(&ost->opts); av_free(ost); } } av_free(ost_table); } return VAR_6; }
[ "static int FUNC_0(AVFormatContext **VAR_0,\nint VAR_1,\nInputFile *VAR_2,\nint VAR_3,\nStreamMap *VAR_4, int VAR_5)\n{", "int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12;", "AVFormatContext *is, *os;", "AVCodecContext *codec, *icodec;", "OutputStream *ost, **ost_table = NULL;", "InputStream *ist;", "char VAR_13[1024];", "int VAR_14;", "int VAR_15 = 1;", "uint8_t no_packet[MAX_FILES]={0};", "int VAR_16=0;", "int VAR_17[AVMEDIA_TYPE_NB]={0};", "int VAR_18[AVMEDIA_TYPE_NB]={0};", "if (rate_emu)\nfor (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++)", "input_streams[VAR_7].start = av_gettime();", "VAR_11 = 0;", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "if (!os->VAR_18 && !(os->oformat->flags & AVFMT_NOSTREAMS)) {", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Output file #%d does not contain any stream\\VAR_10\", VAR_7);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_11 += os->VAR_18;", "}", "if (VAR_5 > 0 && VAR_5 != VAR_11) {", "fprintf(stderr, \"Number of stream maps must match number of output streams\\VAR_10\");", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "for(VAR_7=0;VAR_7<VAR_5;VAR_7++) {", "int VAR_19 = VAR_4[VAR_7].file_index;", "int VAR_20 = VAR_4[VAR_7].stream_index;", "if (VAR_19 < 0 || VAR_19 > VAR_3 - 1 ||\nVAR_20 < 0 || VAR_20 > VAR_2[VAR_19].ctx->VAR_18 - 1) {", "fprintf(stderr,\"Could not find input stream #%d.%d\\VAR_10\", VAR_19, VAR_20);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_19 = VAR_4[VAR_7].sync_file_index;", "VAR_20 = VAR_4[VAR_7].sync_stream_index;", "if (VAR_19 < 0 || VAR_19 > VAR_3 - 1 ||\nVAR_20 < 0 || VAR_20 > VAR_2[VAR_19].ctx->VAR_18 - 1) {", "fprintf(stderr,\"Could not find sync stream #%d.%d\\VAR_10\", VAR_19, VAR_20);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "}", "ost_table = av_mallocz(sizeof(OutputStream *) * VAR_11);", "if (!ost_table)\ngoto fail;", "for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {", "os = VAR_0[VAR_9];", "for(VAR_7=0;VAR_7<os->VAR_18;VAR_7++,VAR_10++) {", "VAR_18[os->streams[VAR_7]->codec->codec_type]++;", "}", "}", "for(VAR_12=1<<30; VAR_12; VAR_12>>=1){", "int VAR_21[AVMEDIA_TYPE_NB]={0};", "for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)", "VAR_17[VAR_8] += VAR_12;", "for(VAR_8=0; VAR_8<nb_input_streams; VAR_8++) {", "int skip=0;", "ist = &input_streams[VAR_8];", "if(opt_programid){", "int pi,VAR_20;", "AVFormatContext *f= VAR_2[ ist->file_index ].ctx;", "skip=1;", "for(pi=0; pi<f->nb_programs; pi++){", "AVProgram *p= f->programs[pi];", "if(p->id == opt_programid)\nfor(VAR_20=0; VAR_20<p->nb_stream_indexes; VAR_20++){", "if(f->streams[ p->stream_index[VAR_20] ] == ist->st)\nskip=0;", "}", "}", "}", "if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip\n&& VAR_17[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){", "VAR_21[ist->st->codec->codec_type]++;", "}", "}", "for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)", "if(VAR_21[VAR_8] < VAR_18[VAR_8])\nVAR_17[VAR_8] -= VAR_12;", "}", "VAR_10 = 0;", "for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {", "os = VAR_0[VAR_9];", "for(VAR_7=0;VAR_7<os->VAR_18;VAR_7++,VAR_10++) {", "int found;", "ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7];", "if (VAR_5 > 0) {", "ost->source_index = VAR_2[VAR_4[VAR_10].file_index].ist_index +\nVAR_4[VAR_10].stream_index;", "if (input_streams[ost->source_index].st->codec->codec_type != ost->st->codec->codec_type) {", "int VAR_7= ost->file_index;", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Codec type mismatch for mapping #%d.%d -> #%d.%d\\VAR_10\",\nVAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index,\nost->file_index, ost->index);", "ffmpeg_exit(1);", "}", "} else {", "found = 0;", "for (VAR_8 = 0; VAR_8 < nb_input_streams; VAR_8++) {", "int skip=0;", "ist = &input_streams[VAR_8];", "if(opt_programid){", "int pi,VAR_20;", "AVFormatContext *f = VAR_2[ist->file_index].ctx;", "skip=1;", "for(pi=0; pi<f->nb_programs; pi++){", "AVProgram *p= f->programs[pi];", "if(p->id == opt_programid)\nfor(VAR_20=0; VAR_20<p->nb_stream_indexes; VAR_20++){", "if(f->streams[ p->stream_index[VAR_20] ] == ist->st)\nskip=0;", "}", "}", "}", "if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip &&\nist->st->codec->codec_type == ost->st->codec->codec_type &&\nVAR_17[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {", "ost->source_index = VAR_8;", "found = 1;", "break;", "}", "}", "if (!found) {", "if(! opt_programid) {", "for (VAR_8 = 0; VAR_8 < nb_input_streams; VAR_8++) {", "ist = &input_streams[VAR_8];", "if ( ist->st->codec->codec_type == ost->st->codec->codec_type\n&& ist->st->discard != AVDISCARD_ALL) {", "ost->source_index = VAR_8;", "found = 1;", "}", "}", "}", "if (!found) {", "int VAR_7= ost->file_index;", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Could not find input stream matching output stream #%d.%d\\VAR_10\",\nost->file_index, ost->index);", "ffmpeg_exit(1);", "}", "}", "}", "ist = &input_streams[ost->source_index];", "ist->discard = 0;", "ost->sync_ist = (VAR_5 > 0) ?\n&input_streams[VAR_2[VAR_4[VAR_10].sync_file_index].ist_index +\nVAR_4[VAR_10].sync_stream_index] : ist;", "}", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "os = VAR_0[ost->file_index];", "ist = &input_streams[ost->source_index];", "codec = ost->st->codec;", "icodec = ist->st->codec;", "if (metadata_streams_autocopy)\nav_dict_copy(&ost->st->metadata, ist->st->metadata,\nAV_DICT_DONT_OVERWRITE);", "ost->st->disposition = ist->st->disposition;", "codec->bits_per_raw_sample= icodec->bits_per_raw_sample;", "codec->chroma_sample_location = icodec->chroma_sample_location;", "if (ost->st->stream_copy) {", "uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;", "if (extra_size > INT_MAX)\ngoto fail;", "codec->codec_id = icodec->codec_id;", "codec->codec_type = icodec->codec_type;", "if(!codec->codec_tag){", "if( !os->oformat->codec_tag\n|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id\n|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;", "}", "codec->bit_rate = icodec->bit_rate;", "codec->rc_max_rate = icodec->rc_max_rate;", "codec->rc_buffer_size = icodec->rc_buffer_size;", "codec->extradata= av_mallocz(extra_size);", "if (!codec->extradata)\ngoto fail;", "memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);", "codec->extradata_size= icodec->extradata_size;", "if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){", "codec->time_base = icodec->time_base;", "codec->time_base.num *= icodec->ticks_per_frame;", "av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);", "}else", "codec->time_base = ist->st->time_base;", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nif(audio_volume != 256) {", "fprintf(stderr,\"-acodec copy and -vol are incompatible (frames are not decoded)\\VAR_10\");", "ffmpeg_exit(1);", "}", "codec->channel_layout = icodec->channel_layout;", "codec->sample_rate = icodec->sample_rate;", "codec->channels = icodec->channels;", "codec->frame_size = icodec->frame_size;", "codec->audio_service_type = icodec->audio_service_type;", "codec->block_align= icodec->block_align;", "if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)\ncodec->block_align= 0;", "if(codec->codec_id == CODEC_ID_AC3)\ncodec->block_align= 0;", "break;", "case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;", "codec->width = icodec->width;", "codec->height = icodec->height;", "codec->has_b_frames = icodec->has_b_frames;", "if (!codec->sample_aspect_ratio.num) {", "codec->sample_aspect_ratio =\nost->st->sample_aspect_ratio =\nist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :\nist->st->codec->sample_aspect_ratio.num ?\nist->st->codec->sample_aspect_ratio : (AVRational){0, 1};", "}", "break;", "case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;", "codec->height = icodec->height;", "break;", "case AVMEDIA_TYPE_DATA:\nbreak;", "default:\nabort();", "}", "} else {", "if (!ost->enc)\nost->enc = avcodec_find_encoder(ost->st->codec->codec_id);", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nost->fifo= av_fifo_alloc(1024);", "if(!ost->fifo)\ngoto fail;", "ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);", "if (!codec->sample_rate) {", "codec->sample_rate = icodec->sample_rate;", "if (icodec->lowres)\ncodec->sample_rate >>= icodec->lowres;", "}", "choose_sample_rate(ost->st, ost->enc);", "codec->time_base = (AVRational){1, codec->sample_rate};", "if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)\ncodec->sample_fmt = icodec->sample_fmt;", "choose_sample_fmt(ost->st, ost->enc);", "if (!codec->channels) {", "codec->channels = icodec->channels;", "codec->channel_layout = icodec->channel_layout;", "}", "if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)\ncodec->channel_layout = 0;", "ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;", "icodec->request_channels = codec->channels;", "ist->decoding_needed = 1;", "ost->encoding_needed = 1;", "ost->resample_sample_fmt = icodec->sample_fmt;", "ost->resample_sample_rate = icodec->sample_rate;", "ost->resample_channels = icodec->channels;", "break;", "case AVMEDIA_TYPE_VIDEO:\nif (codec->pix_fmt == PIX_FMT_NONE)\ncodec->pix_fmt = icodec->pix_fmt;", "choose_pixel_fmt(ost->st, ost->enc);", "if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {", "fprintf(stderr, \"Video pixel format is unknown, stream cannot be encoded\\VAR_10\");", "ffmpeg_exit(1);", "}", "ost->video_resample = codec->width != icodec->width ||\ncodec->height != icodec->height ||\ncodec->pix_fmt != icodec->pix_fmt;", "if (ost->video_resample) {", "codec->bits_per_raw_sample= frame_bits_per_raw_sample;", "}", "if (!codec->width || !codec->height) {", "codec->width = icodec->width;", "codec->height = icodec->height;", "}", "ost->resample_height = icodec->height;", "ost->resample_width = icodec->width;", "ost->resample_pix_fmt= icodec->pix_fmt;", "ost->encoding_needed = 1;", "ist->decoding_needed = 1;", "if (!ost->frame_rate.num)\nost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};", "if (ost->enc && ost->enc->supported_framerates && !force_fps) {", "int VAR_22 = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);", "ost->frame_rate = ost->enc->supported_framerates[VAR_22];", "}", "codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};", "if( av_q2d(codec->time_base) < 0.001 && video_sync_method\n&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){", "av_log(os, AV_LOG_WARNING, \"Frame rate very high for a muxer not effciciently supporting it.\\VAR_10\"\n\"Please consider specifiying a lower framerate, a different muxer or -vsync 2\\VAR_10\");", "}", "#if CONFIG_AVFILTER\nif (configure_video_filters(ist, ost)) {", "fprintf(stderr, \"Error opening filters!\\VAR_10\");", "exit(1);", "}", "#endif\nbreak;", "case AVMEDIA_TYPE_SUBTITLE:\nost->encoding_needed = 1;", "ist->decoding_needed = 1;", "break;", "default:\nabort();", "break;", "}", "if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&\n(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {", "char VAR_23[1024];", "FILE *f;", "snprintf(VAR_23, sizeof(VAR_23), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_7);", "if (codec->flags & CODEC_FLAG_PASS1) {", "f = fopen(VAR_23, \"wb\");", "if (!f) {", "fprintf(stderr, \"Cannot write log file '%s' for pass-1 encoding: %s\\VAR_10\", VAR_23, strerror(errno));", "ffmpeg_exit(1);", "}", "ost->logfile = f;", "} else {", "char *VAR_24;", "size_t logbuffer_size;", "if (read_file(VAR_23, &VAR_24, &logbuffer_size) < 0) {", "fprintf(stderr, \"Error reading log file '%s' for pass-2 encoding\\VAR_10\", VAR_23);", "ffmpeg_exit(1);", "}", "codec->stats_in = VAR_24;", "}", "}", "}", "if(codec->codec_type == AVMEDIA_TYPE_VIDEO){", "int VAR_25= codec->width * codec->height;", "bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_25 + 1664);", "}", "}", "if (!bit_buffer)\nbit_buffer = av_malloc(bit_buffer_size);", "if (!bit_buffer) {", "fprintf(stderr, \"Cannot allocate %d bytes output buffer\\VAR_10\",\nbit_buffer_size);", "VAR_6 = AVERROR(ENOMEM);", "goto fail;", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost->encoding_needed) {", "AVCodec *codec = ost->enc;", "AVCodecContext *dec = input_streams[ost->source_index].st->codec;", "if (!codec) {", "snprintf(VAR_13, sizeof(VAR_13), \"Encoder (codec id %d) not found for output stream #%d.%d\",\nost->st->codec->codec_id, ost->file_index, ost->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (dec->subtitle_header) {", "ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);", "if (!ost->st->codec->subtitle_header) {", "VAR_6 = AVERROR(ENOMEM);", "goto dump_format;", "}", "memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);", "ost->st->codec->subtitle_header_size = dec->subtitle_header_size;", "}", "if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {", "snprintf(VAR_13, sizeof(VAR_13), \"Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "assert_codec_experimental(ost->st->codec, 1);", "assert_avoptions(ost->opts);", "if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)\nav_log(NULL, AV_LOG_WARNING, \"The bitrate parameter is set too low.\"\n\"It takes bits/s as argument, not kbits/s\\VAR_10\");", "extra_size += ost->st->codec->extradata_size;", "}", "}", "for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) {", "ist = &input_streams[VAR_7];", "if (ist->decoding_needed) {", "AVCodec *codec = ist->dec;", "if (!codec)\ncodec = avcodec_find_decoder(ist->st->codec->codec_id);", "if (!codec) {", "snprintf(VAR_13, sizeof(VAR_13), \"Decoder (codec id %d) not found for input stream #%d.%d\",\nist->st->codec->codec_id, ist->file_index, ist->st->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) {", "snprintf(VAR_13, sizeof(VAR_13), \"Error while opening decoder for input stream #%d.%d\",\nist->file_index, ist->st->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "assert_codec_experimental(ist->st->codec, 0);", "assert_avoptions(ost->opts);", "}", "}", "for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) {", "AVStream *st;", "ist = &input_streams[VAR_7];", "st= ist->st;", "ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;", "ist->next_pts = AV_NOPTS_VALUE;", "ist->is_start = 1;", "}", "for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) {", "AVFormatContext *files[2];", "AVDictionary **meta[2];", "int VAR_8;", "#define METADATA_CHECK_INDEX(index, nb_elems, desc)\\\nif ((index) < 0 || (index) >= (nb_elems)) {\\", "snprintf(VAR_13, sizeof(VAR_13), \"Invalid %s index %d while processing metadata maps\\VAR_10\",\\\n(desc), (index));\\", "VAR_6 = AVERROR(EINVAL);\\", "goto dump_format;\\", "}", "int out_file_index = meta_data_maps[VAR_7][0].file;", "int in_file_index = meta_data_maps[VAR_7][1].file;", "if (in_file_index < 0 || out_file_index < 0)\ncontinue;", "METADATA_CHECK_INDEX(out_file_index, VAR_1, \"output file\")\nMETADATA_CHECK_INDEX(in_file_index, VAR_3, \"input file\")\nfiles[0] = VAR_0[out_file_index];", "files[1] = VAR_2[in_file_index].ctx;", "for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {", "MetadataMap *map = &meta_data_maps[VAR_7][VAR_8];", "switch (map->type) {", "case 'g':\nmeta[VAR_8] = &files[VAR_8]->metadata;", "break;", "case 's':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_18, \"stream\")\nmeta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata;", "break;", "case 'c':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, \"chapter\")\nmeta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata;", "break;", "case 'p':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, \"program\")\nmeta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata;", "break;", "}", "}", "av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);", "}", "if (metadata_global_autocopy) {", "for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)", "av_dict_copy(&VAR_0[VAR_7]->metadata, VAR_2[0].ctx->metadata,\nAV_DICT_DONT_OVERWRITE);", "}", "for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) {", "int infile = chapter_maps[VAR_7].in_file;", "int outfile = chapter_maps[VAR_7].out_file;", "if (infile < 0 || outfile < 0)\ncontinue;", "if (infile >= VAR_3) {", "snprintf(VAR_13, sizeof(VAR_13), \"Invalid input file index %d in chapter mapping.\\VAR_10\", infile);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (outfile >= VAR_1) {", "snprintf(VAR_13, sizeof(VAR_13), \"Invalid output file index %d in chapter mapping.\\VAR_10\",outfile);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "copy_chapters(infile, outfile);", "}", "if (!nb_chapter_maps)\nfor (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {", "if (!VAR_2[VAR_7].ctx->nb_chapters)\ncontinue;", "for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++)", "if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0)\ngoto dump_format;", "break;", "}", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "if (avformat_write_header(os, &output_opts[VAR_7]) < 0) {", "snprintf(VAR_13, sizeof(VAR_13), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_7);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "assert_avoptions(output_opts[VAR_7]);", "if (strcmp(VAR_0[VAR_7]->oformat->name, \"rtp\")) {", "VAR_15 = 0;", "}", "}", "dump_format:\nfor(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "}", "if (verbose >= 0) {", "fprintf(stderr, \"Stream mapping:\\VAR_10\");", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "fprintf(stderr, \" Stream #%d.%d -> #%d.%d\",\ninput_streams[ost->source_index].file_index,\ninput_streams[ost->source_index].st->index,\nost->file_index,\nost->index);", "if (ost->sync_ist != &input_streams[ost->source_index])\nfprintf(stderr, \" [sync #%d.%d]\",\nost->sync_ist->file_index,\nost->sync_ist->st->index);", "fprintf(stderr, \"\\VAR_10\");", "}", "}", "if (VAR_6) {", "fprintf(stderr, \"%s\\VAR_10\", VAR_13);", "goto fail;", "}", "if (VAR_15) {", "print_sdp(VAR_0, VAR_1);", "}", "if (!using_stdin) {", "if(verbose >= 0)\nfprintf(stderr, \"Press [q] to stop, [?] for help\\VAR_10\");", "avio_set_interrupt_cb(decode_interrupt_cb);", "}", "term_init();", "timer_start = av_gettime();", "for(; received_sigterm == 0;) {", "int file_index, ist_index;", "AVPacket pkt;", "double ipts_min;", "double opts_min;", "redo:\nipts_min= 1e100;", "opts_min= 1e100;", "if (!using_stdin) {", "if (q_pressed)\nbreak;", "VAR_14 = read_key();", "if (VAR_14 == 'q')\nbreak;", "if (VAR_14 == '+') verbose++;", "if (VAR_14 == '-') verbose--;", "if (VAR_14 == 's') qp_hist ^= 1;", "if (VAR_14 == 'h'){", "if (do_hex_dump){", "do_hex_dump = do_pkt_dump = 0;", "} else if(do_pkt_dump){", "do_hex_dump = 1;", "} else", "do_pkt_dump = 1;", "av_log_set_level(AV_LOG_DEBUG);", "}", "if (VAR_14 == 'd' || VAR_14 == 'D'){", "int debug=0;", "if(VAR_14 == 'D') {", "debug = input_streams[0].st->codec->debug<<1;", "if(!debug) debug = 1;", "while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))\ndebug += debug;", "}else", "scanf(\"%d\", &debug);", "for(VAR_7=0;VAR_7<nb_input_streams;VAR_7++) {", "input_streams[VAR_7].st->codec->debug = debug;", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "ost->st->codec->debug = debug;", "}", "if(debug) av_log_set_level(AV_LOG_DEBUG);", "fprintf(stderr,\"debug=%d\\VAR_10\", debug);", "}", "if (VAR_14 == '?'){", "fprintf(stderr, \"VAR_14 function\\VAR_10\"\n\"? show this help\\VAR_10\"\n\"+ increase verbosity\\VAR_10\"\n\"- decrease verbosity\\VAR_10\"\n\"D cycle through available debug modes\\VAR_10\"\n\"h dump packets/hex press to cycle through the 3 states\\VAR_10\"\n\"q quit\\VAR_10\"\n\"s Show QP histogram\\VAR_10\"\n);", "}", "}", "file_index = -1;", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "double ipts, opts;", "ost = ost_table[VAR_7];", "os = VAR_0[ost->file_index];", "ist = &input_streams[ost->source_index];", "if(ist->is_past_recording_time || no_packet[ist->file_index])\ncontinue;", "opts = ost->st->pts.val * av_q2d(ost->st->time_base);", "ipts = (double)ist->pts;", "if (!VAR_2[ist->file_index].eof_reached){", "if(ipts < ipts_min) {", "ipts_min = ipts;", "if(input_sync ) file_index = ist->file_index;", "}", "if(opts < opts_min) {", "opts_min = opts;", "if(!input_sync) file_index = ist->file_index;", "}", "}", "if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){", "file_index= -1;", "break;", "}", "}", "if (file_index < 0) {", "if(VAR_16){", "VAR_16=0;", "memset(no_packet, 0, sizeof(no_packet));", "usleep(10000);", "continue;", "}", "break;", "}", "if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb))\nbreak;", "is = VAR_2[file_index].ctx;", "VAR_6= av_read_frame(is, &pkt);", "if(VAR_6 == AVERROR(EAGAIN)){", "no_packet[file_index]=1;", "VAR_16++;", "continue;", "}", "if (VAR_6 < 0) {", "VAR_2[file_index].eof_reached = 1;", "if (opt_shortest)\nbreak;", "else\ncontinue;", "}", "VAR_16=0;", "memset(no_packet, 0, sizeof(no_packet));", "if (do_pkt_dump) {", "av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);", "}", "if (pkt.stream_index >= VAR_2[file_index].ctx->VAR_18)\ngoto discard_packet;", "ist_index = VAR_2[file_index].ist_index + pkt.stream_index;", "ist = &input_streams[ist_index];", "if (ist->discard)\ngoto discard_packet;", "if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);", "if (ist->ts_scale) {", "if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;", "if(pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;", "}", "if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE\n&& (is->iformat->flags & AVFMT_TS_DISCONT)) {", "int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);", "int64_t delta= pkt_dts - ist->next_pts;", "if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){", "VAR_2[ist->file_index].ts_offset -= delta;", "if (verbose > 2)\nfprintf(stderr, \"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\VAR_10\",\ndelta, VAR_2[ist->file_index].ts_offset);", "pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);", "if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);", "}", "}", "if (recording_time != INT64_MAX &&\n(pkt.pts != AV_NOPTS_VALUE ?\nav_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000})", ":\nav_compare_ts(ist->pts, AV_TIME_BASE_Q, recording_time + start_time, (AVRational){1, 1000000})", ")>= 0) {", "ist->is_past_recording_time = 1;", "goto discard_packet;", "}", "if (output_packet(ist, ist_index, ost_table, VAR_11, &pkt) < 0) {", "if (verbose >= 0)\nfprintf(stderr, \"Error while decoding stream #%d.%d\\VAR_10\",\nist->file_index, ist->st->index);", "if (exit_on_error)\nffmpeg_exit(1);", "av_free_packet(&pkt);", "goto redo;", "}", "discard_packet:\nav_free_packet(&pkt);", "print_report(VAR_0, ost_table, VAR_11, 0);", "}", "for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) {", "ist = &input_streams[VAR_7];", "if (ist->decoding_needed) {", "output_packet(ist, VAR_7, ost_table, VAR_11, NULL);", "}", "}", "term_exit();", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "av_write_trailer(os);", "}", "print_report(VAR_0, ost_table, VAR_11, 1);", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost->encoding_needed) {", "av_freep(&ost->st->codec->stats_in);", "avcodec_close(ost->st->codec);", "}", "#if CONFIG_AVFILTER\navfilter_graph_free(&ost->graph);", "#endif\n}", "for (VAR_7 = 0; VAR_7 < nb_input_streams; VAR_7++) {", "ist = &input_streams[VAR_7];", "if (ist->decoding_needed) {", "avcodec_close(ist->st->codec);", "}", "}", "VAR_6 = 0;", "fail:\nav_freep(&bit_buffer);", "if (ost_table) {", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost) {", "if (ost->st->stream_copy)\nav_freep(&ost->st->codec->extradata);", "if (ost->logfile) {", "fclose(ost->logfile);", "ost->logfile = NULL;", "}", "av_fifo_free(ost->fifo);", "av_freep(&ost->st->codec->subtitle_header);", "av_free(ost->resample_frame.data[0]);", "av_free(ost->forced_kf_pts);", "if (ost->video_resample)\nsws_freeContext(ost->img_resample_ctx);", "if (ost->resample)\naudio_resample_close(ost->resample);", "if (ost->reformat_ctx)\nav_audio_convert_free(ost->reformat_ctx);", "av_dict_free(&ost->opts);", "av_free(ost);", "}", "}", "av_free(ost_table);", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 41, 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 87 ], [ 89 ], [ 91 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129, 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 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 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 237, 239 ], [ 241 ], [ 243 ], [ 247 ], [ 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 ], [ 303 ], [ 305 ], [ 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 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 373 ], [ 375 ], [ 379, 381, 383 ], [ 387 ], [ 389 ], [ 391 ], [ 395 ], [ 397 ], [ 401, 403 ], [ 409 ], [ 411 ], [ 415 ], [ 417, 419, 421, 423 ], [ 425 ], [ 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, 547 ], [ 549, 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559, 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569, 571 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581 ], [ 583, 585 ], [ 587 ], [ 589 ], [ 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599 ], [ 601 ], [ 603, 605, 607 ], [ 609 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621, 623, 625 ], [ 627 ], [ 629 ], [ 631 ], [ 633 ], [ 635 ], [ 637 ], [ 639 ], [ 641 ], [ 643 ], [ 645 ], [ 647 ], [ 649 ], [ 653, 655 ], [ 657 ], [ 659 ], [ 661 ], [ 663 ], [ 665 ], [ 667, 669 ], [ 671, 673 ], [ 675 ], [ 679, 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689, 691 ], [ 693, 695 ], [ 697 ], [ 699 ], [ 701, 703 ], [ 705 ], [ 707 ], [ 711, 713 ], [ 715 ], [ 717 ], [ 721, 723, 725 ], [ 727 ], [ 729 ], [ 731 ], [ 733 ], [ 735 ], [ 737 ], [ 739 ], [ 741 ], [ 743 ], [ 745 ], [ 747 ], [ 749 ], [ 751 ], [ 753 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 767 ], [ 769 ], [ 771 ], [ 773 ], [ 777, 779 ], [ 781 ], [ 783, 785 ], [ 787 ], [ 789 ], [ 791 ], [ 797 ], [ 799 ], [ 801 ], [ 803 ], [ 805 ], [ 807 ], [ 809, 811 ], [ 813 ], [ 815 ], [ 817 ], [ 819 ], [ 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 837 ], [ 839, 841 ], [ 843 ], [ 845 ], [ 847 ], [ 849 ], [ 851 ], [ 853, 855, 857 ], [ 859 ], [ 861 ], [ 863 ], [ 869 ], [ 871 ], [ 873 ], [ 875 ], [ 877, 879 ], [ 881 ], [ 883, 885 ], [ 887 ], [ 889 ], [ 891 ], [ 893 ], [ 895, 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 907 ], [ 913 ], [ 915 ], [ 921 ], [ 923 ], [ 925 ], [ 927 ], [ 929 ], [ 931 ], [ 933 ], [ 935 ], [ 941 ], [ 943 ], [ 945 ], [ 947 ], [ 951, 953 ], [ 955, 957 ], [ 959 ], [ 961 ], [ 963 ], [ 967 ], [ 969 ], [ 971, 973 ], [ 975, 977, 981 ], [ 983 ], [ 987 ], [ 989 ], [ 993 ], [ 995, 997 ], [ 999 ], [ 1001, 1003, 1005 ], [ 1007 ], [ 1009, 1011, 1013 ], [ 1015 ], [ 1017, 1019, 1021 ], [ 1023 ], [ 1025 ], [ 1027 ], [ 1031 ], [ 1033 ], [ 1039 ], [ 1043 ], [ 1045, 1047 ], [ 1049 ], [ 1055 ], [ 1057 ], [ 1059 ], [ 1063, 1065 ], [ 1067 ], [ 1069 ], [ 1071 ], [ 1073 ], [ 1075 ], [ 1077 ], [ 1079 ], [ 1081 ], [ 1083 ], [ 1085 ], [ 1087 ], [ 1089 ], [ 1095, 1097 ], [ 1099, 1101 ], [ 1105 ], [ 1107, 1109 ], [ 1111 ], [ 1113 ], [ 1119 ], [ 1121 ], [ 1123 ], [ 1125 ], [ 1127 ], [ 1129 ], [ 1131 ], [ 1133 ], [ 1135 ], [ 1137 ], [ 1139 ], [ 1141 ], [ 1145, 1151 ], [ 1153 ], [ 1155 ], [ 1161 ], [ 1163 ], [ 1165 ], [ 1167 ], [ 1169, 1171, 1173, 1175, 1177 ], [ 1179, 1181, 1183, 1185 ], [ 1187 ], [ 1189 ], [ 1191 ], [ 1195 ], [ 1197 ], [ 1199 ], [ 1201 ], [ 1205 ], [ 1207 ], [ 1209 ], [ 1213 ], [ 1215, 1217 ], [ 1219 ], [ 1221 ], [ 1223 ], [ 1227 ], [ 1231 ], [ 1233 ], [ 1235 ], [ 1237 ], [ 1239 ], [ 1243, 1245 ], [ 1247 ], [ 1251 ], [ 1253, 1255 ], [ 1259 ], [ 1261, 1263 ], [ 1265 ], [ 1267 ], [ 1269 ], [ 1271 ], [ 1273 ], [ 1275 ], [ 1277 ], [ 1279 ], [ 1281 ], [ 1283 ], [ 1285 ], [ 1287 ], [ 1289 ], [ 1291 ], [ 1293 ], [ 1295 ], [ 1297 ], [ 1299, 1301 ], [ 1303 ], [ 1305 ], [ 1307 ], [ 1309 ], [ 1311 ], [ 1313 ], [ 1315 ], [ 1317 ], [ 1319 ], [ 1321 ], [ 1323 ], [ 1325 ], [ 1327 ], [ 1329, 1331, 1333, 1335, 1337, 1339, 1341, 1343, 1345 ], [ 1347 ], [ 1349 ], [ 1357 ], [ 1359 ], [ 1361 ], [ 1363 ], [ 1365 ], [ 1367 ], [ 1369, 1371 ], [ 1373 ], [ 1375 ], [ 1377 ], [ 1379 ], [ 1381 ], [ 1383 ], [ 1385 ], [ 1387 ], [ 1389 ], [ 1391 ], [ 1393 ], [ 1395 ], [ 1397 ], [ 1399 ], [ 1401 ], [ 1403 ], [ 1405 ], [ 1409 ], [ 1411 ], [ 1413 ], [ 1415 ], [ 1417 ], [ 1419 ], [ 1421 ], [ 1423 ], [ 1425 ], [ 1431, 1433 ], [ 1439 ], [ 1441 ], [ 1443 ], [ 1445 ], [ 1447 ], [ 1449 ], [ 1451 ], [ 1453 ], [ 1455 ], [ 1457, 1459 ], [ 1461, 1463 ], [ 1465 ], [ 1469 ], [ 1471 ], [ 1475 ], [ 1477, 1479 ], [ 1481 ], [ 1487, 1489 ], [ 1491 ], [ 1493 ], [ 1495, 1497 ], [ 1501, 1503 ], [ 1505, 1507 ], [ 1511 ], [ 1513, 1515 ], [ 1517, 1519 ], [ 1521 ], [ 1527, 1529 ], [ 1531 ], [ 1533 ], [ 1535 ], [ 1537 ], [ 1539, 1541, 1543 ], [ 1545 ], [ 1547, 1549 ], [ 1551 ], [ 1553 ], [ 1559, 1561, 1563 ], [ 1565, 1567 ], [ 1569 ], [ 1571 ], [ 1573 ], [ 1575 ], [ 1581 ], [ 1585, 1587, 1589 ], [ 1591, 1593 ], [ 1595 ], [ 1597 ], [ 1599 ], [ 1603, 1605 ], [ 1611 ], [ 1613 ], [ 1619 ], [ 1621 ], [ 1623 ], [ 1625 ], [ 1627 ], [ 1629 ], [ 1633 ], [ 1639 ], [ 1641 ], [ 1643 ], [ 1645 ], [ 1651 ], [ 1657 ], [ 1659 ], [ 1661 ], [ 1663 ], [ 1665 ], [ 1667 ], [ 1669, 1671 ], [ 1673, 1675 ], [ 1681 ], [ 1683 ], [ 1685 ], [ 1687 ], [ 1689 ], [ 1691 ], [ 1697 ], [ 1701, 1703 ], [ 1707 ], [ 1709 ], [ 1711 ], [ 1713 ], [ 1715, 1717 ], [ 1719 ], [ 1721 ], [ 1723 ], [ 1725 ], [ 1727 ], [ 1731 ], [ 1733 ], [ 1735 ], [ 1737, 1739 ], [ 1741, 1743 ], [ 1745, 1747 ], [ 1749 ], [ 1751 ], [ 1753 ], [ 1755 ], [ 1757 ], [ 1759 ], [ 1761 ], [ 1763 ] ]
2
static void v4l2_free_buffer(void *opaque, uint8_t *unused) { V4L2Buffer* avbuf = opaque; V4L2m2mContext *s = buf_to_m2mctx(avbuf); if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) { atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel); if (s->reinit) { if (!atomic_load(&s->refcount)) sem_post(&s->refsync); } else if (avbuf->context->streamon) ff_v4l2_buffer_enqueue(avbuf); av_buffer_unref(&avbuf->context_ref); } }
false
FFmpeg
5d5de3eba4c7890c2e8077f5b4ae569671d11cf8
static void v4l2_free_buffer(void *opaque, uint8_t *unused) { V4L2Buffer* avbuf = opaque; V4L2m2mContext *s = buf_to_m2mctx(avbuf); if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) { atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel); if (s->reinit) { if (!atomic_load(&s->refcount)) sem_post(&s->refsync); } else if (avbuf->context->streamon) ff_v4l2_buffer_enqueue(avbuf); av_buffer_unref(&avbuf->context_ref); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, uint8_t *VAR_1) { V4L2Buffer* avbuf = VAR_0; V4L2m2mContext *s = buf_to_m2mctx(avbuf); if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) { atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel); if (s->reinit) { if (!atomic_load(&s->refcount)) sem_post(&s->refsync); } else if (avbuf->context->streamon) ff_v4l2_buffer_enqueue(avbuf); av_buffer_unref(&avbuf->context_ref); } }
[ "static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{", "V4L2Buffer* avbuf = VAR_0;", "V4L2m2mContext *s = buf_to_m2mctx(avbuf);", "if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) {", "atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);", "if (s->reinit) {", "if (!atomic_load(&s->refcount))\nsem_post(&s->refsync);", "} else if (avbuf->context->streamon)", "ff_v4l2_buffer_enqueue(avbuf);", "av_buffer_unref(&avbuf->context_ref);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ] ]
4
int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size) { cl_int status; void *mapped = clEnqueueMapBuffer(gpu_env.command_queue, dst_cl_buf, CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * buf_size, 0, NULL, NULL, &status); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not map OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } memcpy(mapped, src_buf, buf_size); status = clEnqueueUnmapMemObject(gpu_env.command_queue, dst_cl_buf, mapped, 0, NULL, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } return 0; }
false
FFmpeg
57d77b3963ce1023eaf5ada8cba58b9379405cc8
int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size) { cl_int status; void *mapped = clEnqueueMapBuffer(gpu_env.command_queue, dst_cl_buf, CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * buf_size, 0, NULL, NULL, &status); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not map OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } memcpy(mapped, src_buf, buf_size); status = clEnqueueUnmapMemObject(gpu_env.command_queue, dst_cl_buf, mapped, 0, NULL, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(cl_mem VAR_0, uint8_t *VAR_1, size_t VAR_2) { cl_int status; void *VAR_3 = clEnqueueMapBuffer(gpu_env.command_queue, VAR_0, CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * VAR_2, 0, NULL, NULL, &status); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not map OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } memcpy(VAR_3, VAR_1, VAR_2); status = clEnqueueUnmapMemObject(gpu_env.command_queue, VAR_0, VAR_3, 0, NULL, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } return 0; }
[ "int FUNC_0(cl_mem VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{", "cl_int status;", "void *VAR_3 = clEnqueueMapBuffer(gpu_env.command_queue, VAR_0,\nCL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * VAR_2,\n0, NULL, NULL, &status);", "if (status != CL_SUCCESS) {", "av_log(&openclutils, AV_LOG_ERROR, \"Could not map OpenCL buffer: %s\\n\", opencl_errstr(status));", "return AVERROR_EXTERNAL;", "}", "memcpy(VAR_3, VAR_1, VAR_2);", "status = clEnqueueUnmapMemObject(gpu_env.command_queue, VAR_0, VAR_3, 0, NULL, NULL);", "if (status != CL_SUCCESS) {", "av_log(&openclutils, AV_LOG_ERROR, \"Could not unmap OpenCL buffer: %s\\n\", opencl_errstr(status));", "return AVERROR_EXTERNAL;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
5
static int r3d_read_rdvo(AVFormatContext *s, Atom *atom) { R3DContext *r3d = s->priv_data; AVStream *st = s->streams[0]; int i; r3d->video_offsets_count = (atom->size - 8) / 4; r3d->video_offsets = av_malloc(atom->size); if (!r3d->video_offsets) return AVERROR(ENOMEM); for (i = 0; i < r3d->video_offsets_count; i++) { r3d->video_offsets[i] = avio_rb32(s->pb); if (!r3d->video_offsets[i]) { r3d->video_offsets_count = i; break; } av_dlog(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]); } if (st->r_frame_rate.num) st->duration = av_rescale_q(r3d->video_offsets_count, (AVRational){st->r_frame_rate.den, st->r_frame_rate.num}, st->time_base); av_dlog(s, "duration %"PRId64"\n", st->duration); return 0; }
true
FFmpeg
aba232cfa9b193604ed98f3fa505378d006b1b3b
static int r3d_read_rdvo(AVFormatContext *s, Atom *atom) { R3DContext *r3d = s->priv_data; AVStream *st = s->streams[0]; int i; r3d->video_offsets_count = (atom->size - 8) / 4; r3d->video_offsets = av_malloc(atom->size); if (!r3d->video_offsets) return AVERROR(ENOMEM); for (i = 0; i < r3d->video_offsets_count; i++) { r3d->video_offsets[i] = avio_rb32(s->pb); if (!r3d->video_offsets[i]) { r3d->video_offsets_count = i; break; } av_dlog(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]); } if (st->r_frame_rate.num) st->duration = av_rescale_q(r3d->video_offsets_count, (AVRational){st->r_frame_rate.den, st->r_frame_rate.num}, st->time_base); av_dlog(s, "duration %"PRId64"\n", st->duration); return 0; }
{ "code": [ " if (st->r_frame_rate.num)", " (AVRational){st->r_frame_rate.den,", " st->r_frame_rate.num},", " if (st->r_frame_rate.num)" ], "line_no": [ 41, 45, 47, 41 ] }
static int FUNC_0(AVFormatContext *VAR_0, Atom *VAR_1) { R3DContext *r3d = VAR_0->priv_data; AVStream *st = VAR_0->streams[0]; int VAR_2; r3d->video_offsets_count = (VAR_1->size - 8) / 4; r3d->video_offsets = av_malloc(VAR_1->size); if (!r3d->video_offsets) return AVERROR(ENOMEM); for (VAR_2 = 0; VAR_2 < r3d->video_offsets_count; VAR_2++) { r3d->video_offsets[VAR_2] = avio_rb32(VAR_0->pb); if (!r3d->video_offsets[VAR_2]) { r3d->video_offsets_count = VAR_2; break; } av_dlog(VAR_0, "video offset %d: %#x\n", VAR_2, r3d->video_offsets[VAR_2]); } if (st->r_frame_rate.num) st->duration = av_rescale_q(r3d->video_offsets_count, (AVRational){st->r_frame_rate.den, st->r_frame_rate.num}, st->time_base); av_dlog(VAR_0, "duration %"PRId64"\n", st->duration); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, Atom *VAR_1)\n{", "R3DContext *r3d = VAR_0->priv_data;", "AVStream *st = VAR_0->streams[0];", "int VAR_2;", "r3d->video_offsets_count = (VAR_1->size - 8) / 4;", "r3d->video_offsets = av_malloc(VAR_1->size);", "if (!r3d->video_offsets)\nreturn AVERROR(ENOMEM);", "for (VAR_2 = 0; VAR_2 < r3d->video_offsets_count; VAR_2++) {", "r3d->video_offsets[VAR_2] = avio_rb32(VAR_0->pb);", "if (!r3d->video_offsets[VAR_2]) {", "r3d->video_offsets_count = VAR_2;", "break;", "}", "av_dlog(VAR_0, \"video offset %d: %#x\\n\", VAR_2, r3d->video_offsets[VAR_2]);", "}", "if (st->r_frame_rate.num)\nst->duration = av_rescale_q(r3d->video_offsets_count,\n(AVRational){st->r_frame_rate.den,", "st->r_frame_rate.num},", "st->time_base);", "av_dlog(VAR_0, \"duration %\"PRId64\"\\n\", st->duration);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ] ]
6
static int dds_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { DDSContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; AVFrame *frame = data; int mipmap; int ret; ff_texturedsp_init(&ctx->texdsp); bytestream2_init(gbc, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(gbc) < 128) { av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", bytestream2_get_bytes_left(gbc)); return AVERROR_INVALIDDATA; } if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') || bytestream2_get_le32(gbc) != 124) { // header size av_log(avctx, AV_LOG_ERROR, "Invalid DDS header.\n"); return AVERROR_INVALIDDATA; } bytestream2_skip(gbc, 4); // flags avctx->height = bytestream2_get_le32(gbc); avctx->width = bytestream2_get_le32(gbc); ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", avctx->width, avctx->height); return ret; } /* Since codec is based on 4x4 blocks, size is aligned to 4. */ avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W); avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H); bytestream2_skip(gbc, 4); // pitch bytestream2_skip(gbc, 4); // depth mipmap = bytestream2_get_le32(gbc); if (mipmap != 0) av_log(avctx, AV_LOG_VERBOSE, "Found %d mipmaps (ignored).\n", mipmap); /* Extract pixel format information, considering additional elements * in reserved1 and reserved2. */ ret = parse_pixel_format(avctx); if (ret < 0) return ret; ret = ff_get_buffer(avctx, frame, 0); if (ret < 0) return ret; if (ctx->compressed) { int size = (avctx->coded_height / TEXTURE_BLOCK_H) * (avctx->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio; ctx->slice_count = av_clip(avctx->thread_count, 1, avctx->coded_height / TEXTURE_BLOCK_H); if (bytestream2_get_bytes_left(gbc) < size) { av_log(avctx, AV_LOG_ERROR, "Compressed Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), size); return AVERROR_INVALIDDATA; } /* Use the decompress function on the texture, one block per thread. */ ctx->tex_data = gbc->buffer; avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->data[0]; int x, y, i; /* Use the first 64 bytes as palette, then copy the rest. */ bytestream2_get_buffer(gbc, frame->data[1], 16 * 4); for (i = 0; i < 16; i++) { AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); } frame->palette_has_changed = 1; if (bytestream2_get_bytes_left(gbc) < frame->height * frame->width / 2) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * frame->width / 2); return AVERROR_INVALIDDATA; } for (y = 0; y < frame->height; y++) { for (x = 0; x < frame->width; x += 2) { uint8_t val = bytestream2_get_byte(gbc); dst[x ] = val & 0xF; dst[x + 1] = val >> 4; } dst += frame->linesize[0]; } } else { int linesize = av_image_get_linesize(avctx->pix_fmt, frame->width, 0); if (ctx->paletted) { int i; /* Use the first 1024 bytes as palette, then copy the rest. */ bytestream2_get_buffer(gbc, frame->data[1], 256 * 4); for (i = 0; i < 256; i++) AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); frame->palette_has_changed = 1; } if (bytestream2_get_bytes_left(gbc) < frame->height * linesize) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * linesize); return AVERROR_INVALIDDATA; } av_image_copy_plane(frame->data[0], frame->linesize[0], gbc->buffer, linesize, linesize, frame->height); } /* Run any post processing here if needed. */ if (ctx->postproc != DDS_NONE) run_postproc(avctx, frame); /* Frame is ready to be output. */ frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; *got_frame = 1; return avpkt->size; }
true
FFmpeg
afb4632cc30e83287338690c785ebac180436a59
static int dds_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { DDSContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; AVFrame *frame = data; int mipmap; int ret; ff_texturedsp_init(&ctx->texdsp); bytestream2_init(gbc, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(gbc) < 128) { av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", bytestream2_get_bytes_left(gbc)); return AVERROR_INVALIDDATA; } if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') || bytestream2_get_le32(gbc) != 124) { av_log(avctx, AV_LOG_ERROR, "Invalid DDS header.\n"); return AVERROR_INVALIDDATA; } bytestream2_skip(gbc, 4); avctx->height = bytestream2_get_le32(gbc); avctx->width = bytestream2_get_le32(gbc); ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", avctx->width, avctx->height); return ret; } avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W); avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H); bytestream2_skip(gbc, 4); bytestream2_skip(gbc, 4); mipmap = bytestream2_get_le32(gbc); if (mipmap != 0) av_log(avctx, AV_LOG_VERBOSE, "Found %d mipmaps (ignored).\n", mipmap); ret = parse_pixel_format(avctx); if (ret < 0) return ret; ret = ff_get_buffer(avctx, frame, 0); if (ret < 0) return ret; if (ctx->compressed) { int size = (avctx->coded_height / TEXTURE_BLOCK_H) * (avctx->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio; ctx->slice_count = av_clip(avctx->thread_count, 1, avctx->coded_height / TEXTURE_BLOCK_H); if (bytestream2_get_bytes_left(gbc) < size) { av_log(avctx, AV_LOG_ERROR, "Compressed Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), size); return AVERROR_INVALIDDATA; } ctx->tex_data = gbc->buffer; avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->data[0]; int x, y, i; bytestream2_get_buffer(gbc, frame->data[1], 16 * 4); for (i = 0; i < 16; i++) { AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); } frame->palette_has_changed = 1; if (bytestream2_get_bytes_left(gbc) < frame->height * frame->width / 2) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * frame->width / 2); return AVERROR_INVALIDDATA; } for (y = 0; y < frame->height; y++) { for (x = 0; x < frame->width; x += 2) { uint8_t val = bytestream2_get_byte(gbc); dst[x ] = val & 0xF; dst[x + 1] = val >> 4; } dst += frame->linesize[0]; } } else { int linesize = av_image_get_linesize(avctx->pix_fmt, frame->width, 0); if (ctx->paletted) { int i; bytestream2_get_buffer(gbc, frame->data[1], 256 * 4); for (i = 0; i < 256; i++) AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); frame->palette_has_changed = 1; } if (bytestream2_get_bytes_left(gbc) < frame->height * linesize) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * linesize); return AVERROR_INVALIDDATA; } av_image_copy_plane(frame->data[0], frame->linesize[0], gbc->buffer, linesize, linesize, frame->height); } if (ctx->postproc != DDS_NONE) run_postproc(avctx, frame); frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; *got_frame = 1; return avpkt->size; }
{ "code": [ " (frame->data[1][3+i*4]<<24)" ], "line_no": [ 227 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { DDSContext *ctx = VAR_0->priv_data; GetByteContext *gbc = &ctx->gbc; AVFrame *frame = VAR_1; int VAR_4; int VAR_5; ff_texturedsp_init(&ctx->texdsp); bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->VAR_6); if (bytestream2_get_bytes_left(gbc) < 128) { av_log(VAR_0, AV_LOG_ERROR, "Frame is too small (%d).\n", bytestream2_get_bytes_left(gbc)); return AVERROR_INVALIDDATA; } if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') || bytestream2_get_le32(gbc) != 124) { av_log(VAR_0, AV_LOG_ERROR, "Invalid DDS header.\n"); return AVERROR_INVALIDDATA; } bytestream2_skip(gbc, 4); VAR_0->height = bytestream2_get_le32(gbc); VAR_0->width = bytestream2_get_le32(gbc); VAR_5 = av_image_check_size(VAR_0->width, VAR_0->height, 0, VAR_0); if (VAR_5 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid image VAR_6 %dx%d.\n", VAR_0->width, VAR_0->height); return VAR_5; } VAR_0->coded_width = FFALIGN(VAR_0->width, TEXTURE_BLOCK_W); VAR_0->coded_height = FFALIGN(VAR_0->height, TEXTURE_BLOCK_H); bytestream2_skip(gbc, 4); bytestream2_skip(gbc, 4); VAR_4 = bytestream2_get_le32(gbc); if (VAR_4 != 0) av_log(VAR_0, AV_LOG_VERBOSE, "Found %d mipmaps (ignored).\n", VAR_4); VAR_5 = parse_pixel_format(VAR_0); if (VAR_5 < 0) return VAR_5; VAR_5 = ff_get_buffer(VAR_0, frame, 0); if (VAR_5 < 0) return VAR_5; if (ctx->compressed) { int VAR_6 = (VAR_0->coded_height / TEXTURE_BLOCK_H) * (VAR_0->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio; ctx->slice_count = av_clip(VAR_0->thread_count, 1, VAR_0->coded_height / TEXTURE_BLOCK_H); if (bytestream2_get_bytes_left(gbc) < VAR_6) { av_log(VAR_0, AV_LOG_ERROR, "Compressed Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), VAR_6); return AVERROR_INVALIDDATA; } ctx->tex_data = gbc->buffer; VAR_0->execute2(VAR_0, decompress_texture_thread, frame, NULL, ctx->slice_count); } else if (!ctx->paletted && ctx->bpp == 4 && VAR_0->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->VAR_1[0]; int VAR_7, VAR_8, VAR_11; bytestream2_get_buffer(gbc, frame->VAR_1[1], 16 * 4); for (VAR_11 = 0; VAR_11 < 16; VAR_11++) { AV_WN32(frame->VAR_1[1] + VAR_11*4, (frame->VAR_1[1][2+VAR_11*4]<<0)+ (frame->VAR_1[1][1+VAR_11*4]<<8)+ (frame->VAR_1[1][0+VAR_11*4]<<16)+ (frame->VAR_1[1][3+VAR_11*4]<<24) ); } frame->palette_has_changed = 1; if (bytestream2_get_bytes_left(gbc) < frame->height * frame->width / 2) { av_log(VAR_0, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * frame->width / 2); return AVERROR_INVALIDDATA; } for (VAR_8 = 0; VAR_8 < frame->height; VAR_8++) { for (VAR_7 = 0; VAR_7 < frame->width; VAR_7 += 2) { uint8_t val = bytestream2_get_byte(gbc); dst[VAR_7 ] = val & 0xF; dst[VAR_7 + 1] = val >> 4; } dst += frame->VAR_10[0]; } } else { int VAR_10 = av_image_get_linesize(VAR_0->pix_fmt, frame->width, 0); if (ctx->paletted) { int VAR_11; bytestream2_get_buffer(gbc, frame->VAR_1[1], 256 * 4); for (VAR_11 = 0; VAR_11 < 256; VAR_11++) AV_WN32(frame->VAR_1[1] + VAR_11*4, (frame->VAR_1[1][2+VAR_11*4]<<0)+ (frame->VAR_1[1][1+VAR_11*4]<<8)+ (frame->VAR_1[1][0+VAR_11*4]<<16)+ (frame->VAR_1[1][3+VAR_11*4]<<24) ); frame->palette_has_changed = 1; } if (bytestream2_get_bytes_left(gbc) < frame->height * VAR_10) { av_log(VAR_0, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * VAR_10); return AVERROR_INVALIDDATA; } av_image_copy_plane(frame->VAR_1[0], frame->VAR_10[0], gbc->buffer, VAR_10, VAR_10, frame->height); } if (ctx->postproc != DDS_NONE) run_postproc(VAR_0, frame); frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; *VAR_2 = 1; return VAR_3->VAR_6; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{", "DDSContext *ctx = VAR_0->priv_data;", "GetByteContext *gbc = &ctx->gbc;", "AVFrame *frame = VAR_1;", "int VAR_4;", "int VAR_5;", "ff_texturedsp_init(&ctx->texdsp);", "bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->VAR_6);", "if (bytestream2_get_bytes_left(gbc) < 128) {", "av_log(VAR_0, AV_LOG_ERROR, \"Frame is too small (%d).\\n\",\nbytestream2_get_bytes_left(gbc));", "return AVERROR_INVALIDDATA;", "}", "if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') ||\nbytestream2_get_le32(gbc) != 124) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid DDS header.\\n\");", "return AVERROR_INVALIDDATA;", "}", "bytestream2_skip(gbc, 4);", "VAR_0->height = bytestream2_get_le32(gbc);", "VAR_0->width = bytestream2_get_le32(gbc);", "VAR_5 = av_image_check_size(VAR_0->width, VAR_0->height, 0, VAR_0);", "if (VAR_5 < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid image VAR_6 %dx%d.\\n\",\nVAR_0->width, VAR_0->height);", "return VAR_5;", "}", "VAR_0->coded_width = FFALIGN(VAR_0->width, TEXTURE_BLOCK_W);", "VAR_0->coded_height = FFALIGN(VAR_0->height, TEXTURE_BLOCK_H);", "bytestream2_skip(gbc, 4);", "bytestream2_skip(gbc, 4);", "VAR_4 = bytestream2_get_le32(gbc);", "if (VAR_4 != 0)\nav_log(VAR_0, AV_LOG_VERBOSE, \"Found %d mipmaps (ignored).\\n\", VAR_4);", "VAR_5 = parse_pixel_format(VAR_0);", "if (VAR_5 < 0)\nreturn VAR_5;", "VAR_5 = ff_get_buffer(VAR_0, frame, 0);", "if (VAR_5 < 0)\nreturn VAR_5;", "if (ctx->compressed) {", "int VAR_6 = (VAR_0->coded_height / TEXTURE_BLOCK_H) *\n(VAR_0->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio;", "ctx->slice_count = av_clip(VAR_0->thread_count, 1,\nVAR_0->coded_height / TEXTURE_BLOCK_H);", "if (bytestream2_get_bytes_left(gbc) < VAR_6) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Compressed Buffer is too small (%d < %d).\\n\",\nbytestream2_get_bytes_left(gbc), VAR_6);", "return AVERROR_INVALIDDATA;", "}", "ctx->tex_data = gbc->buffer;", "VAR_0->execute2(VAR_0, decompress_texture_thread, frame, NULL, ctx->slice_count);", "} else if (!ctx->paletted && ctx->bpp == 4 && VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {", "uint8_t *dst = frame->VAR_1[0];", "int VAR_7, VAR_8, VAR_11;", "bytestream2_get_buffer(gbc, frame->VAR_1[1], 16 * 4);", "for (VAR_11 = 0; VAR_11 < 16; VAR_11++) {", "AV_WN32(frame->VAR_1[1] + VAR_11*4,\n(frame->VAR_1[1][2+VAR_11*4]<<0)+\n(frame->VAR_1[1][1+VAR_11*4]<<8)+\n(frame->VAR_1[1][0+VAR_11*4]<<16)+\n(frame->VAR_1[1][3+VAR_11*4]<<24)\n);", "}", "frame->palette_has_changed = 1;", "if (bytestream2_get_bytes_left(gbc) < frame->height * frame->width / 2) {", "av_log(VAR_0, AV_LOG_ERROR, \"Buffer is too small (%d < %d).\\n\",\nbytestream2_get_bytes_left(gbc), frame->height * frame->width / 2);", "return AVERROR_INVALIDDATA;", "}", "for (VAR_8 = 0; VAR_8 < frame->height; VAR_8++) {", "for (VAR_7 = 0; VAR_7 < frame->width; VAR_7 += 2) {", "uint8_t val = bytestream2_get_byte(gbc);", "dst[VAR_7 ] = val & 0xF;", "dst[VAR_7 + 1] = val >> 4;", "}", "dst += frame->VAR_10[0];", "}", "} else {", "int VAR_10 = av_image_get_linesize(VAR_0->pix_fmt, frame->width, 0);", "if (ctx->paletted) {", "int VAR_11;", "bytestream2_get_buffer(gbc, frame->VAR_1[1], 256 * 4);", "for (VAR_11 = 0; VAR_11 < 256; VAR_11++)", "AV_WN32(frame->VAR_1[1] + VAR_11*4,\n(frame->VAR_1[1][2+VAR_11*4]<<0)+\n(frame->VAR_1[1][1+VAR_11*4]<<8)+\n(frame->VAR_1[1][0+VAR_11*4]<<16)+\n(frame->VAR_1[1][3+VAR_11*4]<<24)\n);", "frame->palette_has_changed = 1;", "}", "if (bytestream2_get_bytes_left(gbc) < frame->height * VAR_10) {", "av_log(VAR_0, AV_LOG_ERROR, \"Buffer is too small (%d < %d).\\n\",\nbytestream2_get_bytes_left(gbc), frame->height * VAR_10);", "return AVERROR_INVALIDDATA;", "}", "av_image_copy_plane(frame->VAR_1[0], frame->VAR_10[0],\ngbc->buffer, VAR_10,\nVAR_10, frame->height);", "}", "if (ctx->postproc != DDS_NONE)\nrun_postproc(VAR_0, frame);", "frame->pict_type = AV_PICTURE_TYPE_I;", "frame->key_frame = 1;", "*VAR_2 = 1;", "return VAR_3->VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 95 ], [ 97, 99 ], [ 103 ], [ 105, 107 ], [ 111 ], [ 113, 115 ], [ 117, 119 ], [ 123 ], [ 125, 127, 129 ], [ 131 ], [ 133 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 153 ], [ 155 ], [ 157, 159, 161, 163, 165, 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 215 ], [ 217 ], [ 219, 221, 223, 225, 227, 229 ], [ 233 ], [ 235 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 251, 253, 255 ], [ 257 ], [ 263, 265 ], [ 271 ], [ 273 ], [ 275 ], [ 279 ], [ 281 ] ]
7
static void check_lowpass_line(int depth){ LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]); LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]); LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]); int w = WIDTH; int mref = WIDTH_PADDED * -1; int pref = WIDTH_PADDED; int i, depth_byte; InterlaceContext s; declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max); s.lowpass = 1; s.lowpass = VLPF_LIN; depth_byte = depth >> 3; w /= depth_byte; memset(src, 0, SRC_SIZE); memset(dst_ref, 0, WIDTH_PADDED); memset(dst_new, 0, WIDTH_PADDED); randomize_buffers(src, SRC_SIZE); ff_interlace_init(&s, depth); if (check_func(s.lowpass_line, "lowpass_line_%d", depth)) { for (i = 0; i < 32; i++) { /* simulate crop */ call_ref(dst_ref, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0); call_new(dst_new, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0); if (memcmp(dst_ref, dst_new, WIDTH - i)) fail(); } bench_new(dst_new, w, src + WIDTH_PADDED, mref, pref, 0); } }
true
FFmpeg
da032427786d9db4ab21014998cb1245083d6c85
static void check_lowpass_line(int depth){ LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]); LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]); LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]); int w = WIDTH; int mref = WIDTH_PADDED * -1; int pref = WIDTH_PADDED; int i, depth_byte; InterlaceContext s; declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max); s.lowpass = 1; s.lowpass = VLPF_LIN; depth_byte = depth >> 3; w /= depth_byte; memset(src, 0, SRC_SIZE); memset(dst_ref, 0, WIDTH_PADDED); memset(dst_new, 0, WIDTH_PADDED); randomize_buffers(src, SRC_SIZE); ff_interlace_init(&s, depth); if (check_func(s.lowpass_line, "lowpass_line_%d", depth)) { for (i = 0; i < 32; i++) { call_ref(dst_ref, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0); call_new(dst_new, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0); if (memcmp(dst_ref, dst_new, WIDTH - i)) fail(); } bench_new(dst_new, w, src + WIDTH_PADDED, mref, pref, 0); } }
{ "code": [ "static void check_lowpass_line(int depth){", " LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);", " LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);", " LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);", " int w = WIDTH;", " int mref = WIDTH_PADDED * -1;", " int pref = WIDTH_PADDED;", " int i, depth_byte;", " InterlaceContext s;", " declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp,", " ptrdiff_t mref, ptrdiff_t pref, int clip_max);", " s.lowpass = 1;", " s.lowpass = VLPF_LIN;", " depth_byte = depth >> 3;", " w /= depth_byte;", " memset(src, 0, SRC_SIZE);", " memset(dst_ref, 0, WIDTH_PADDED);", " memset(dst_new, 0, WIDTH_PADDED);", " randomize_buffers(src, SRC_SIZE);", " ff_interlace_init(&s, depth);", " if (check_func(s.lowpass_line, \"lowpass_line_%d\", depth)) {", " call_ref(dst_ref, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0);", " call_new(dst_new, w, src + WIDTH_PADDED, mref - i*depth_byte, pref, 0);", " if (memcmp(dst_ref, dst_new, WIDTH - i))", " fail();", " bench_new(dst_new, w, src + WIDTH_PADDED, mref, pref, 0);" ], "line_no": [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 51, 55, 57, 59, 61, 65 ] }
static void FUNC_0(int VAR_0){ LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]); LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]); LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]); int VAR_1 = WIDTH; int VAR_2 = WIDTH_PADDED * -1; int VAR_3 = WIDTH_PADDED; int VAR_4, VAR_5; InterlaceContext s; declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp, ptrdiff_t VAR_2, ptrdiff_t VAR_3, int clip_max); s.lowpass = 1; s.lowpass = VLPF_LIN; VAR_5 = VAR_0 >> 3; VAR_1 /= VAR_5; memset(src, 0, SRC_SIZE); memset(dst_ref, 0, WIDTH_PADDED); memset(dst_new, 0, WIDTH_PADDED); randomize_buffers(src, SRC_SIZE); ff_interlace_init(&s, VAR_0); if (check_func(s.lowpass_line, "lowpass_line_%d", VAR_0)) { for (VAR_4 = 0; VAR_4 < 32; VAR_4++) { call_ref(dst_ref, VAR_1, src + WIDTH_PADDED, VAR_2 - VAR_4*VAR_5, VAR_3, 0); call_new(dst_new, VAR_1, src + WIDTH_PADDED, VAR_2 - VAR_4*VAR_5, VAR_3, 0); if (memcmp(dst_ref, dst_new, WIDTH - VAR_4)) fail(); } bench_new(dst_new, VAR_1, src + WIDTH_PADDED, VAR_2, VAR_3, 0); } }
[ "static void FUNC_0(int VAR_0){", "LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);", "LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);", "LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);", "int VAR_1 = WIDTH;", "int VAR_2 = WIDTH_PADDED * -1;", "int VAR_3 = WIDTH_PADDED;", "int VAR_4, VAR_5;", "InterlaceContext s;", "declare_func(void, uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp,\nptrdiff_t VAR_2, ptrdiff_t VAR_3, int clip_max);", "s.lowpass = 1;", "s.lowpass = VLPF_LIN;", "VAR_5 = VAR_0 >> 3;", "VAR_1 /= VAR_5;", "memset(src, 0, SRC_SIZE);", "memset(dst_ref, 0, WIDTH_PADDED);", "memset(dst_new, 0, WIDTH_PADDED);", "randomize_buffers(src, SRC_SIZE);", "ff_interlace_init(&s, VAR_0);", "if (check_func(s.lowpass_line, \"lowpass_line_%d\", VAR_0)) {", "for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {", "call_ref(dst_ref, VAR_1, src + WIDTH_PADDED, VAR_2 - VAR_4*VAR_5, VAR_3, 0);", "call_new(dst_new, VAR_1, src + WIDTH_PADDED, VAR_2 - VAR_4*VAR_5, VAR_3, 0);", "if (memcmp(dst_ref, dst_new, WIDTH - VAR_4))\nfail();", "}", "bench_new(dst_new, VAR_1, src + WIDTH_PADDED, VAR_2, VAR_3, 0);", "}", "}" ]
[ 1, 1, 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, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ] ]
9
static void test_init(TestData *d) { QPCIBus *bus; QTestState *qs; char *s; s = g_strdup_printf("-machine q35 %s %s", d->noreboot ? "" : "-global ICH9-LPC.noreboot=false", !d->args ? "" : d->args); qs = qtest_start(s); qtest_irq_intercept_in(qs, "ioapic"); g_free(s); bus = qpci_init_pc(NULL); d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00)); g_assert(d->dev != NULL); qpci_device_enable(d->dev); /* set ACPI PM I/O space base address */ qpci_config_writel(d->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1); /* enable ACPI I/O */ qpci_config_writeb(d->dev, ICH9_LPC_ACPI_CTRL, 0x80); /* set Root Complex BAR */ qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1); d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
static void test_init(TestData *d) { QPCIBus *bus; QTestState *qs; char *s; s = g_strdup_printf("-machine q35 %s %s", d->noreboot ? "" : "-global ICH9-LPC.noreboot=false", !d->args ? "" : d->args); qs = qtest_start(s); qtest_irq_intercept_in(qs, "ioapic"); g_free(s); bus = qpci_init_pc(NULL); d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00)); g_assert(d->dev != NULL); qpci_device_enable(d->dev); qpci_config_writel(d->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1); qpci_config_writeb(d->dev, ICH9_LPC_ACPI_CTRL, 0x80); qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1); d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60); }
{ "code": [ " d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60);" ], "line_no": [ 53 ] }
static void FUNC_0(TestData *VAR_0) { QPCIBus *bus; QTestState *qs; char *VAR_1; VAR_1 = g_strdup_printf("-machine q35 %VAR_1 %VAR_1", VAR_0->noreboot ? "" : "-global ICH9-LPC.noreboot=false", !VAR_0->args ? "" : VAR_0->args); qs = qtest_start(VAR_1); qtest_irq_intercept_in(qs, "ioapic"); g_free(VAR_1); bus = qpci_init_pc(NULL); VAR_0->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00)); g_assert(VAR_0->dev != NULL); qpci_device_enable(VAR_0->dev); qpci_config_writel(VAR_0->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1); qpci_config_writeb(VAR_0->dev, ICH9_LPC_ACPI_CTRL, 0x80); qpci_config_writel(VAR_0->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1); VAR_0->tco_io_base = qpci_legacy_iomap(VAR_0->dev, PM_IO_BASE_ADDR + 0x60); }
[ "static void FUNC_0(TestData *VAR_0)\n{", "QPCIBus *bus;", "QTestState *qs;", "char *VAR_1;", "VAR_1 = g_strdup_printf(\"-machine q35 %VAR_1 %VAR_1\",\nVAR_0->noreboot ? \"\" : \"-global ICH9-LPC.noreboot=false\",\n!VAR_0->args ? \"\" : VAR_0->args);", "qs = qtest_start(VAR_1);", "qtest_irq_intercept_in(qs, \"ioapic\");", "g_free(VAR_1);", "bus = qpci_init_pc(NULL);", "VAR_0->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));", "g_assert(VAR_0->dev != NULL);", "qpci_device_enable(VAR_0->dev);", "qpci_config_writel(VAR_0->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1);", "qpci_config_writeb(VAR_0->dev, ICH9_LPC_ACPI_CTRL, 0x80);", "qpci_config_writel(VAR_0->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);", "VAR_0->tco_io_base = qpci_legacy_iomap(VAR_0->dev, PM_IO_BASE_ADDR + 0x60);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13, 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 41 ], [ 45 ], [ 49 ], [ 53 ], [ 55 ] ]
11
void assert_avoptions(AVDictionary *m) { AVDictionaryEntry *t; if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); exit(1); } }
true
FFmpeg
636ced8e1dc8248a1353b416240b93d70ad03edb
void assert_avoptions(AVDictionary *m) { AVDictionaryEntry *t; if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); exit(1); } }
{ "code": [ " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);", " exit(1);" ], "line_no": [ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 ] }
void FUNC_0(AVDictionary *VAR_0) { AVDictionaryEntry *t; if ((t = av_dict_get(VAR_0, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); exit(1); } }
[ "void FUNC_0(AVDictionary *VAR_0)\n{", "AVDictionaryEntry *t;", "if ((t = av_dict_get(VAR_0, \"\", NULL, AV_DICT_IGNORE_SUFFIX))) {", "av_log(NULL, AV_LOG_FATAL, \"Option %s not found.\\n\", t->key);", "exit(1);", "}", "}" ]
[ 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
13
static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVNBDState *s = bs->opaque; QDict *opts = qdict_new(); QObject *saddr_qdict; Visitor *ov; const char *host = NULL, *port = NULL, *path = NULL; if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) { const InetSocketAddress *inet = s->saddr->u.inet.data; if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) { host = inet->host; port = inet->port; } } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) { path = s->saddr->u.q_unix.data->path; } qdict_put(opts, "driver", qstring_from_str("nbd")); if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix:///%s?socket=%s", s->export, path); } else if (path && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix://?socket=%s", path); } else if (host && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd://%s:%s/%s", host, port, s->export); } else if (host && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd://%s:%s", host, port); } ov = qobject_output_visitor_new(&saddr_qdict); visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); assert(qobject_type(saddr_qdict) == QTYPE_QDICT); qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { qdict_put(opts, "export", qstring_from_str(s->export)); } if (s->tlscredsid) { qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); } qdict_flatten(opts); bs->full_open_options = opts; }
true
qemu
a1d4e38a8b01a6699355c31867d524f8d4cd480e
static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVNBDState *s = bs->opaque; QDict *opts = qdict_new(); QObject *saddr_qdict; Visitor *ov; const char *host = NULL, *port = NULL, *path = NULL; if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) { const InetSocketAddress *inet = s->saddr->u.inet.data; if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) { host = inet->host; port = inet->port; } } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) { path = s->saddr->u.q_unix.data->path; } qdict_put(opts, "driver", qstring_from_str("nbd")); if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (path && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (host && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } else if (host && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } ov = qobject_output_visitor_new(&saddr_qdict); visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); assert(qobject_type(saddr_qdict) == QTYPE_QDICT); qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { qdict_put(opts, "export", qstring_from_str(s->export)); } if (s->tlscredsid) { qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); } qdict_flatten(opts); bs->full_open_options = opts; }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1) { BDRVNBDState *s = VAR_0->opaque; QDict *opts = qdict_new(); QObject *saddr_qdict; Visitor *ov; const char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL; if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) { const InetSocketAddress *VAR_5 = s->saddr->u.VAR_5.data; if (!VAR_5->has_ipv4 && !VAR_5->has_ipv6 && !VAR_5->has_to) { VAR_2 = VAR_5->VAR_2; VAR_3 = VAR_5->VAR_3; } } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) { VAR_4 = s->saddr->u.q_unix.data->VAR_4; } qdict_put(opts, "driver", qstring_from_str("nbd")); if (VAR_4 && s->export) { snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), "nbd+unix: } else if (VAR_4 && !s->export) { snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), "nbd+unix: } else if (VAR_2 && s->export) { snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), "nbd: } else if (VAR_2 && !s->export) { snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), "nbd: } ov = qobject_output_visitor_new(&saddr_qdict); visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); assert(qobject_type(saddr_qdict) == QTYPE_QDICT); qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { qdict_put(opts, "export", qstring_from_str(s->export)); } if (s->tlscredsid) { qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); } qdict_flatten(opts); VAR_0->full_open_options = opts; }
[ "static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1)\n{", "BDRVNBDState *s = VAR_0->opaque;", "QDict *opts = qdict_new();", "QObject *saddr_qdict;", "Visitor *ov;", "const char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL;", "if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) {", "const InetSocketAddress *VAR_5 = s->saddr->u.VAR_5.data;", "if (!VAR_5->has_ipv4 && !VAR_5->has_ipv6 && !VAR_5->has_to) {", "VAR_2 = VAR_5->VAR_2;", "VAR_3 = VAR_5->VAR_3;", "}", "} else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) {", "VAR_4 = s->saddr->u.q_unix.data->VAR_4;", "}", "qdict_put(opts, \"driver\", qstring_from_str(\"nbd\"));", "if (VAR_4 && s->export) {", "snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd+unix:\n} else if (VAR_4 && !s->export) {", "snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd+unix:\n} else if (VAR_2 && s->export) {", "snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n} else if (VAR_2 && !s->export) {", "snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n}", "ov = qobject_output_visitor_new(&saddr_qdict);", "visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort);", "visit_complete(ov, &saddr_qdict);", "assert(qobject_type(saddr_qdict) == QTYPE_QDICT);", "qdict_put_obj(opts, \"server\", saddr_qdict);", "if (s->export) {", "qdict_put(opts, \"export\", qstring_from_str(s->export));", "}", "if (s->tlscredsid) {", "qdict_put(opts, \"tls-creds\", qstring_from_str(s->tlscredsid));", "}", "qdict_flatten(opts);", "VAR_0->full_open_options = opts;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 37 ], [ 41 ], [ 43, 45, 47 ], [ 49, 51, 53 ], [ 55, 57, 59 ], [ 61, 63, 65 ], [ 69 ], [ 71 ], [ 73 ], [ 76 ], [ 80 ], [ 84 ], [ 86 ], [ 88 ], [ 90 ], [ 92 ], [ 94 ], [ 98 ], [ 100 ], [ 102 ] ]
14
int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan) { const char *ifname; ifname = qemu_opt_get(opts, "ifname"); if (!ifname) { error_report("tap: no interface name"); return -1; } if (tap_win32_init(vlan, "tap", name, ifname) == -1) { return -1; } return 0; }
true
qemu
6687b79d636cd60ed9adb1177d0d946b58fa7717
int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan) { const char *ifname; ifname = qemu_opt_get(opts, "ifname"); if (!ifname) { error_report("tap: no interface name"); return -1; } if (tap_win32_init(vlan, "tap", name, ifname) == -1) { return -1; } return 0; }
{ "code": [ " return -1;", "int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan)", "int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan)" ], "line_no": [ 17, 1, 1 ] }
int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2) { const char *VAR_3; VAR_3 = qemu_opt_get(VAR_0, "VAR_3"); if (!VAR_3) { error_report("tap: no interface VAR_1"); return -1; } if (tap_win32_init(VAR_2, "tap", VAR_1, VAR_3) == -1) { return -1; } return 0; }
[ "int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2)\n{", "const char *VAR_3;", "VAR_3 = qemu_opt_get(VAR_0, \"VAR_3\");", "if (!VAR_3) {", "error_report(\"tap: no interface VAR_1\");", "return -1;", "}", "if (tap_win32_init(VAR_2, \"tap\", VAR_1, VAR_3) == -1) {", "return -1;", "}", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ] ]
16
print_insn (bfd_vma pc, disassemble_info *info) { const struct dis386 *dp; int i; char *op_txt[MAX_OPERANDS]; int needcomma; unsigned char uses_DATA_prefix, uses_LOCK_prefix; unsigned char uses_REPNZ_prefix, uses_REPZ_prefix; int sizeflag; const char *p; struct dis_private priv; unsigned char op; unsigned char threebyte; if (info->mach == bfd_mach_x86_64_intel_syntax || info->mach == bfd_mach_x86_64) address_mode = mode_64bit; else address_mode = mode_32bit; if (intel_syntax == (char) -1) intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax || info->mach == bfd_mach_x86_64_intel_syntax); if (info->mach == bfd_mach_i386_i386 || info->mach == bfd_mach_x86_64 || info->mach == bfd_mach_i386_i386_intel_syntax || info->mach == bfd_mach_x86_64_intel_syntax) priv.orig_sizeflag = AFLAG | DFLAG; else if (info->mach == bfd_mach_i386_i8086) priv.orig_sizeflag = 0; else abort (); for (p = info->disassembler_options; p != NULL; ) { if (strncmp (p, "x86-64", 6) == 0) { address_mode = mode_64bit; priv.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (p, "i386", 4) == 0) { address_mode = mode_32bit; priv.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (p, "i8086", 5) == 0) { address_mode = mode_16bit; priv.orig_sizeflag = 0; } else if (strncmp (p, "intel", 5) == 0) { intel_syntax = 1; } else if (strncmp (p, "att", 3) == 0) { intel_syntax = 0; } else if (strncmp (p, "addr", 4) == 0) { if (address_mode == mode_64bit) { if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag &= ~AFLAG; else if (p[4] == '6' && p[5] == '4') priv.orig_sizeflag |= AFLAG; } else { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~AFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= AFLAG; } } else if (strncmp (p, "data", 4) == 0) { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~DFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= DFLAG; } else if (strncmp (p, "suffix", 6) == 0) priv.orig_sizeflag |= SUFFIX_ALWAYS; p = strchr (p, ','); if (p != NULL) p++; } if (intel_syntax) { names64 = intel_names64; names32 = intel_names32; names16 = intel_names16; names8 = intel_names8; names8rex = intel_names8rex; names_seg = intel_names_seg; index16 = intel_index16; open_char = '['; close_char = ']'; separator_char = '+'; scale_char = '*'; } else { names64 = att_names64; names32 = att_names32; names16 = att_names16; names8 = att_names8; names8rex = att_names8rex; names_seg = att_names_seg; index16 = att_index16; open_char = '('; close_char = ')'; separator_char = ','; scale_char = ','; } /* The output looks better if we put 7 bytes on a line, since that puts most long word instructions on a single line. */ info->bytes_per_line = 7; info->private_data = &priv; priv.max_fetched = priv.the_buffer; priv.insn_start = pc; obuf[0] = 0; for (i = 0; i < MAX_OPERANDS; ++i) { op_out[i][0] = 0; op_index[i] = -1; } the_info = info; start_pc = pc; start_codep = priv.the_buffer; codep = priv.the_buffer; if (sigsetjmp(priv.bailout, 0) != 0) { const char *name; /* Getting here means we tried for data but didn't get it. That means we have an incomplete instruction of some sort. Just print the first byte as a prefix or a .byte pseudo-op. */ if (codep > priv.the_buffer) { name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name != NULL) (*info->fprintf_func) (info->stream, "%s", name); else { /* Just print the first byte as a .byte instruction. */ (*info->fprintf_func) (info->stream, ".byte 0x%x", (unsigned int) priv.the_buffer[0]); } return 1; } return -1; } obufp = obuf; ckprefix (); ckvexprefix (); insn_codep = codep; sizeflag = priv.orig_sizeflag; fetch_data(info, codep + 1); two_source_ops = (*codep == 0x62) || (*codep == 0xc8); if (((prefixes & PREFIX_FWAIT) && ((*codep < 0xd8) || (*codep > 0xdf))) || (rex && rex_used)) { const char *name; /* fwait not followed by floating point instruction, or rex followed by other prefixes. Print the first prefix. */ name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s", name); return 1; } op = 0; if (prefixes & PREFIX_VEX_0F) { used_prefixes |= PREFIX_VEX_0F | PREFIX_VEX_0F38 | PREFIX_VEX_0F3A; if (prefixes & PREFIX_VEX_0F38) threebyte = 0x38; else if (prefixes & PREFIX_VEX_0F3A) threebyte = 0x3a; else threebyte = *codep++; goto vex_opcode; } if (*codep == 0x0f) { fetch_data(info, codep + 2); threebyte = codep[1]; codep += 2; vex_opcode: dp = &dis386_twobyte[threebyte]; need_modrm = twobyte_has_modrm[threebyte]; uses_DATA_prefix = twobyte_uses_DATA_prefix[threebyte]; uses_REPNZ_prefix = twobyte_uses_REPNZ_prefix[threebyte]; uses_REPZ_prefix = twobyte_uses_REPZ_prefix[threebyte]; uses_LOCK_prefix = (threebyte & ~0x02) == 0x20; if (dp->name == NULL && dp->op[0].bytemode == IS_3BYTE_OPCODE) { fetch_data(info, codep + 2); op = *codep++; switch (threebyte) { case 0x38: uses_DATA_prefix = threebyte_0x38_uses_DATA_prefix[op]; uses_REPNZ_prefix = threebyte_0x38_uses_REPNZ_prefix[op]; uses_REPZ_prefix = threebyte_0x38_uses_REPZ_prefix[op]; break; case 0x3a: uses_DATA_prefix = threebyte_0x3a_uses_DATA_prefix[op]; uses_REPNZ_prefix = threebyte_0x3a_uses_REPNZ_prefix[op]; uses_REPZ_prefix = threebyte_0x3a_uses_REPZ_prefix[op]; break; default: break; } } } else { dp = &dis386[*codep]; need_modrm = onebyte_has_modrm[*codep]; uses_DATA_prefix = 0; uses_REPNZ_prefix = 0; /* pause is 0xf3 0x90. */ uses_REPZ_prefix = *codep == 0x90; uses_LOCK_prefix = 0; codep++; } if (!uses_REPZ_prefix && (prefixes & PREFIX_REPZ)) { oappend ("repz "); used_prefixes |= PREFIX_REPZ; } if (!uses_REPNZ_prefix && (prefixes & PREFIX_REPNZ)) { oappend ("repnz "); used_prefixes |= PREFIX_REPNZ; } if (!uses_LOCK_prefix && (prefixes & PREFIX_LOCK)) { oappend ("lock "); used_prefixes |= PREFIX_LOCK; } if (prefixes & PREFIX_ADDR) { sizeflag ^= AFLAG; if (dp->op[2].bytemode != loop_jcxz_mode || intel_syntax) { if ((sizeflag & AFLAG) || address_mode == mode_64bit) oappend ("addr32 "); else oappend ("addr16 "); used_prefixes |= PREFIX_ADDR; } } if (!uses_DATA_prefix && (prefixes & PREFIX_DATA)) { sizeflag ^= DFLAG; if (dp->op[2].bytemode == cond_jump_mode && dp->op[0].bytemode == v_mode && !intel_syntax) { if (sizeflag & DFLAG) oappend ("data32 "); else oappend ("data16 "); used_prefixes |= PREFIX_DATA; } } if (dp->name == NULL && dp->op[0].bytemode == IS_3BYTE_OPCODE) { dp = &three_byte_table[dp->op[1].bytemode][op]; modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } else if (need_modrm) { fetch_data(info, codep + 1); modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } if (dp->name == NULL && dp->op[0].bytemode == FLOATCODE) { dofloat (sizeflag); } else { int index; if (dp->name == NULL) { switch (dp->op[0].bytemode) { case USE_GROUPS: dp = &grps[dp->op[1].bytemode][modrm.reg]; break; case USE_PREFIX_USER_TABLE: index = 0; used_prefixes |= (prefixes & PREFIX_REPZ); if (prefixes & PREFIX_REPZ) index = 1; else { /* We should check PREFIX_REPNZ and PREFIX_REPZ before PREFIX_DATA. */ used_prefixes |= (prefixes & PREFIX_REPNZ); if (prefixes & PREFIX_REPNZ) index = 3; else { used_prefixes |= (prefixes & PREFIX_DATA); if (prefixes & PREFIX_DATA) index = 2; } } dp = &prefix_user_table[dp->op[1].bytemode][index]; break; case X86_64_SPECIAL: index = address_mode == mode_64bit ? 1 : 0; dp = &x86_64_table[dp->op[1].bytemode][index]; break; default: oappend (INTERNAL_DISASSEMBLER_ERROR); break; } } if (putop (dp->name, sizeflag) == 0) { for (i = 0; i < MAX_OPERANDS; ++i) { obufp = op_out[i]; op_ad = MAX_OPERANDS - 1 - i; if (dp->op[i].rtn) (*dp->op[i].rtn) (dp->op[i].bytemode, sizeflag); } } } /* See if any prefixes were not used. If so, print the first one separately. If we don't do this, we'll wind up printing an instruction stream which does not precisely correspond to the bytes we are disassembling. */ if ((prefixes & ~used_prefixes) != 0) { const char *name; name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s", name); return 1; } if (rex & ~rex_used) { const char *name; name = prefix_name (rex | 0x40, priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s ", name); } obufp = obuf + strlen (obuf); for (i = strlen (obuf); i < 6; i++) oappend (" "); oappend (" "); (*info->fprintf_func) (info->stream, "%s", obuf); /* The enter and bound instructions are printed with operands in the same order as the intel book; everything else is printed in reverse order. */ if (intel_syntax || two_source_ops) { bfd_vma riprel; for (i = 0; i < MAX_OPERANDS; ++i) op_txt[i] = op_out[i]; for (i = 0; i < (MAX_OPERANDS >> 1); ++i) { op_ad = op_index[i]; op_index[i] = op_index[MAX_OPERANDS - 1 - i]; op_index[MAX_OPERANDS - 1 - i] = op_ad; riprel = op_riprel[i]; op_riprel[i] = op_riprel [MAX_OPERANDS - 1 - i]; op_riprel[MAX_OPERANDS - 1 - i] = riprel; } } else { for (i = 0; i < MAX_OPERANDS; ++i) op_txt[MAX_OPERANDS - 1 - i] = op_out[i]; } needcomma = 0; for (i = 0; i < MAX_OPERANDS; ++i) if (*op_txt[i]) { if (needcomma) (*info->fprintf_func) (info->stream, ","); if (op_index[i] != -1 && !op_riprel[i]) (*info->print_address_func) ((bfd_vma) op_address[op_index[i]], info); else (*info->fprintf_func) (info->stream, "%s", op_txt[i]); needcomma = 1; } for (i = 0; i < MAX_OPERANDS; i++) if (op_index[i] != -1 && op_riprel[i]) { (*info->fprintf_func) (info->stream, " # "); (*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep + op_address[op_index[i]]), info); break; } return codep - priv.the_buffer; }
true
qemu
3f168b5d353fa68baab55ea0c6ba791f0df027dc
print_insn (bfd_vma pc, disassemble_info *info) { const struct dis386 *dp; int i; char *op_txt[MAX_OPERANDS]; int needcomma; unsigned char uses_DATA_prefix, uses_LOCK_prefix; unsigned char uses_REPNZ_prefix, uses_REPZ_prefix; int sizeflag; const char *p; struct dis_private priv; unsigned char op; unsigned char threebyte; if (info->mach == bfd_mach_x86_64_intel_syntax || info->mach == bfd_mach_x86_64) address_mode = mode_64bit; else address_mode = mode_32bit; if (intel_syntax == (char) -1) intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax || info->mach == bfd_mach_x86_64_intel_syntax); if (info->mach == bfd_mach_i386_i386 || info->mach == bfd_mach_x86_64 || info->mach == bfd_mach_i386_i386_intel_syntax || info->mach == bfd_mach_x86_64_intel_syntax) priv.orig_sizeflag = AFLAG | DFLAG; else if (info->mach == bfd_mach_i386_i8086) priv.orig_sizeflag = 0; else abort (); for (p = info->disassembler_options; p != NULL; ) { if (strncmp (p, "x86-64", 6) == 0) { address_mode = mode_64bit; priv.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (p, "i386", 4) == 0) { address_mode = mode_32bit; priv.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (p, "i8086", 5) == 0) { address_mode = mode_16bit; priv.orig_sizeflag = 0; } else if (strncmp (p, "intel", 5) == 0) { intel_syntax = 1; } else if (strncmp (p, "att", 3) == 0) { intel_syntax = 0; } else if (strncmp (p, "addr", 4) == 0) { if (address_mode == mode_64bit) { if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag &= ~AFLAG; else if (p[4] == '6' && p[5] == '4') priv.orig_sizeflag |= AFLAG; } else { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~AFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= AFLAG; } } else if (strncmp (p, "data", 4) == 0) { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~DFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= DFLAG; } else if (strncmp (p, "suffix", 6) == 0) priv.orig_sizeflag |= SUFFIX_ALWAYS; p = strchr (p, ','); if (p != NULL) p++; } if (intel_syntax) { names64 = intel_names64; names32 = intel_names32; names16 = intel_names16; names8 = intel_names8; names8rex = intel_names8rex; names_seg = intel_names_seg; index16 = intel_index16; open_char = '['; close_char = ']'; separator_char = '+'; scale_char = '*'; } else { names64 = att_names64; names32 = att_names32; names16 = att_names16; names8 = att_names8; names8rex = att_names8rex; names_seg = att_names_seg; index16 = att_index16; open_char = '('; close_char = ')'; separator_char = ','; scale_char = ','; } info->bytes_per_line = 7; info->private_data = &priv; priv.max_fetched = priv.the_buffer; priv.insn_start = pc; obuf[0] = 0; for (i = 0; i < MAX_OPERANDS; ++i) { op_out[i][0] = 0; op_index[i] = -1; } the_info = info; start_pc = pc; start_codep = priv.the_buffer; codep = priv.the_buffer; if (sigsetjmp(priv.bailout, 0) != 0) { const char *name; if (codep > priv.the_buffer) { name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name != NULL) (*info->fprintf_func) (info->stream, "%s", name); else { (*info->fprintf_func) (info->stream, ".byte 0x%x", (unsigned int) priv.the_buffer[0]); } return 1; } return -1; } obufp = obuf; ckprefix (); ckvexprefix (); insn_codep = codep; sizeflag = priv.orig_sizeflag; fetch_data(info, codep + 1); two_source_ops = (*codep == 0x62) || (*codep == 0xc8); if (((prefixes & PREFIX_FWAIT) && ((*codep < 0xd8) || (*codep > 0xdf))) || (rex && rex_used)) { const char *name; name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s", name); return 1; } op = 0; if (prefixes & PREFIX_VEX_0F) { used_prefixes |= PREFIX_VEX_0F | PREFIX_VEX_0F38 | PREFIX_VEX_0F3A; if (prefixes & PREFIX_VEX_0F38) threebyte = 0x38; else if (prefixes & PREFIX_VEX_0F3A) threebyte = 0x3a; else threebyte = *codep++; goto vex_opcode; } if (*codep == 0x0f) { fetch_data(info, codep + 2); threebyte = codep[1]; codep += 2; vex_opcode: dp = &dis386_twobyte[threebyte]; need_modrm = twobyte_has_modrm[threebyte]; uses_DATA_prefix = twobyte_uses_DATA_prefix[threebyte]; uses_REPNZ_prefix = twobyte_uses_REPNZ_prefix[threebyte]; uses_REPZ_prefix = twobyte_uses_REPZ_prefix[threebyte]; uses_LOCK_prefix = (threebyte & ~0x02) == 0x20; if (dp->name == NULL && dp->op[0].bytemode == IS_3BYTE_OPCODE) { fetch_data(info, codep + 2); op = *codep++; switch (threebyte) { case 0x38: uses_DATA_prefix = threebyte_0x38_uses_DATA_prefix[op]; uses_REPNZ_prefix = threebyte_0x38_uses_REPNZ_prefix[op]; uses_REPZ_prefix = threebyte_0x38_uses_REPZ_prefix[op]; break; case 0x3a: uses_DATA_prefix = threebyte_0x3a_uses_DATA_prefix[op]; uses_REPNZ_prefix = threebyte_0x3a_uses_REPNZ_prefix[op]; uses_REPZ_prefix = threebyte_0x3a_uses_REPZ_prefix[op]; break; default: break; } } } else { dp = &dis386[*codep]; need_modrm = onebyte_has_modrm[*codep]; uses_DATA_prefix = 0; uses_REPNZ_prefix = 0; uses_REPZ_prefix = *codep == 0x90; uses_LOCK_prefix = 0; codep++; } if (!uses_REPZ_prefix && (prefixes & PREFIX_REPZ)) { oappend ("repz "); used_prefixes |= PREFIX_REPZ; } if (!uses_REPNZ_prefix && (prefixes & PREFIX_REPNZ)) { oappend ("repnz "); used_prefixes |= PREFIX_REPNZ; } if (!uses_LOCK_prefix && (prefixes & PREFIX_LOCK)) { oappend ("lock "); used_prefixes |= PREFIX_LOCK; } if (prefixes & PREFIX_ADDR) { sizeflag ^= AFLAG; if (dp->op[2].bytemode != loop_jcxz_mode || intel_syntax) { if ((sizeflag & AFLAG) || address_mode == mode_64bit) oappend ("addr32 "); else oappend ("addr16 "); used_prefixes |= PREFIX_ADDR; } } if (!uses_DATA_prefix && (prefixes & PREFIX_DATA)) { sizeflag ^= DFLAG; if (dp->op[2].bytemode == cond_jump_mode && dp->op[0].bytemode == v_mode && !intel_syntax) { if (sizeflag & DFLAG) oappend ("data32 "); else oappend ("data16 "); used_prefixes |= PREFIX_DATA; } } if (dp->name == NULL && dp->op[0].bytemode == IS_3BYTE_OPCODE) { dp = &three_byte_table[dp->op[1].bytemode][op]; modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } else if (need_modrm) { fetch_data(info, codep + 1); modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } if (dp->name == NULL && dp->op[0].bytemode == FLOATCODE) { dofloat (sizeflag); } else { int index; if (dp->name == NULL) { switch (dp->op[0].bytemode) { case USE_GROUPS: dp = &grps[dp->op[1].bytemode][modrm.reg]; break; case USE_PREFIX_USER_TABLE: index = 0; used_prefixes |= (prefixes & PREFIX_REPZ); if (prefixes & PREFIX_REPZ) index = 1; else { used_prefixes |= (prefixes & PREFIX_REPNZ); if (prefixes & PREFIX_REPNZ) index = 3; else { used_prefixes |= (prefixes & PREFIX_DATA); if (prefixes & PREFIX_DATA) index = 2; } } dp = &prefix_user_table[dp->op[1].bytemode][index]; break; case X86_64_SPECIAL: index = address_mode == mode_64bit ? 1 : 0; dp = &x86_64_table[dp->op[1].bytemode][index]; break; default: oappend (INTERNAL_DISASSEMBLER_ERROR); break; } } if (putop (dp->name, sizeflag) == 0) { for (i = 0; i < MAX_OPERANDS; ++i) { obufp = op_out[i]; op_ad = MAX_OPERANDS - 1 - i; if (dp->op[i].rtn) (*dp->op[i].rtn) (dp->op[i].bytemode, sizeflag); } } } if ((prefixes & ~used_prefixes) != 0) { const char *name; name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s", name); return 1; } if (rex & ~rex_used) { const char *name; name = prefix_name (rex | 0x40, priv.orig_sizeflag); if (name == NULL) name = INTERNAL_DISASSEMBLER_ERROR; (*info->fprintf_func) (info->stream, "%s ", name); } obufp = obuf + strlen (obuf); for (i = strlen (obuf); i < 6; i++) oappend (" "); oappend (" "); (*info->fprintf_func) (info->stream, "%s", obuf); if (intel_syntax || two_source_ops) { bfd_vma riprel; for (i = 0; i < MAX_OPERANDS; ++i) op_txt[i] = op_out[i]; for (i = 0; i < (MAX_OPERANDS >> 1); ++i) { op_ad = op_index[i]; op_index[i] = op_index[MAX_OPERANDS - 1 - i]; op_index[MAX_OPERANDS - 1 - i] = op_ad; riprel = op_riprel[i]; op_riprel[i] = op_riprel [MAX_OPERANDS - 1 - i]; op_riprel[MAX_OPERANDS - 1 - i] = riprel; } } else { for (i = 0; i < MAX_OPERANDS; ++i) op_txt[MAX_OPERANDS - 1 - i] = op_out[i]; } needcomma = 0; for (i = 0; i < MAX_OPERANDS; ++i) if (*op_txt[i]) { if (needcomma) (*info->fprintf_func) (info->stream, ","); if (op_index[i] != -1 && !op_riprel[i]) (*info->print_address_func) ((bfd_vma) op_address[op_index[i]], info); else (*info->fprintf_func) (info->stream, "%s", op_txt[i]); needcomma = 1; } for (i = 0; i < MAX_OPERANDS; i++) if (op_index[i] != -1 && op_riprel[i]) { (*info->fprintf_func) (info->stream, " # "); (*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep + op_address[op_index[i]]), info); break; } return codep - priv.the_buffer; }
{ "code": [ " if (putop (dp->name, sizeflag) == 0)" ], "line_no": [ 711 ] }
FUNC_0 (bfd_vma VAR_0, disassemble_info *VAR_1) { const struct dis386 *VAR_2; int VAR_3; char *VAR_4[MAX_OPERANDS]; int VAR_5; unsigned char VAR_6, VAR_7; unsigned char VAR_8, VAR_9; int VAR_10; const char *VAR_11; struct dis_private VAR_12; unsigned char VAR_13; unsigned char VAR_14; if (VAR_1->mach == bfd_mach_x86_64_intel_syntax || VAR_1->mach == bfd_mach_x86_64) address_mode = mode_64bit; else address_mode = mode_32bit; if (intel_syntax == (char) -1) intel_syntax = (VAR_1->mach == bfd_mach_i386_i386_intel_syntax || VAR_1->mach == bfd_mach_x86_64_intel_syntax); if (VAR_1->mach == bfd_mach_i386_i386 || VAR_1->mach == bfd_mach_x86_64 || VAR_1->mach == bfd_mach_i386_i386_intel_syntax || VAR_1->mach == bfd_mach_x86_64_intel_syntax) VAR_12.orig_sizeflag = AFLAG | DFLAG; else if (VAR_1->mach == bfd_mach_i386_i8086) VAR_12.orig_sizeflag = 0; else abort (); for (VAR_11 = VAR_1->disassembler_options; VAR_11 != NULL; ) { if (strncmp (VAR_11, "x86-64", 6) == 0) { address_mode = mode_64bit; VAR_12.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (VAR_11, "i386", 4) == 0) { address_mode = mode_32bit; VAR_12.orig_sizeflag = AFLAG | DFLAG; } else if (strncmp (VAR_11, "i8086", 5) == 0) { address_mode = mode_16bit; VAR_12.orig_sizeflag = 0; } else if (strncmp (VAR_11, "intel", 5) == 0) { intel_syntax = 1; } else if (strncmp (VAR_11, "att", 3) == 0) { intel_syntax = 0; } else if (strncmp (VAR_11, "addr", 4) == 0) { if (address_mode == mode_64bit) { if (VAR_11[4] == '3' && VAR_11[5] == '2') VAR_12.orig_sizeflag &= ~AFLAG; else if (VAR_11[4] == '6' && VAR_11[5] == '4') VAR_12.orig_sizeflag |= AFLAG; } else { if (VAR_11[4] == '1' && VAR_11[5] == '6') VAR_12.orig_sizeflag &= ~AFLAG; else if (VAR_11[4] == '3' && VAR_11[5] == '2') VAR_12.orig_sizeflag |= AFLAG; } } else if (strncmp (VAR_11, "data", 4) == 0) { if (VAR_11[4] == '1' && VAR_11[5] == '6') VAR_12.orig_sizeflag &= ~DFLAG; else if (VAR_11[4] == '3' && VAR_11[5] == '2') VAR_12.orig_sizeflag |= DFLAG; } else if (strncmp (VAR_11, "suffix", 6) == 0) VAR_12.orig_sizeflag |= SUFFIX_ALWAYS; VAR_11 = strchr (VAR_11, ','); if (VAR_11 != NULL) VAR_11++; } if (intel_syntax) { names64 = intel_names64; names32 = intel_names32; names16 = intel_names16; names8 = intel_names8; names8rex = intel_names8rex; names_seg = intel_names_seg; index16 = intel_index16; open_char = '['; close_char = ']'; separator_char = '+'; scale_char = '*'; } else { names64 = att_names64; names32 = att_names32; names16 = att_names16; names8 = att_names8; names8rex = att_names8rex; names_seg = att_names_seg; index16 = att_index16; open_char = '('; close_char = ')'; separator_char = ','; scale_char = ','; } VAR_1->bytes_per_line = 7; VAR_1->private_data = &VAR_12; VAR_12.max_fetched = VAR_12.the_buffer; VAR_12.insn_start = VAR_0; obuf[0] = 0; for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3) { op_out[VAR_3][0] = 0; op_index[VAR_3] = -1; } the_info = VAR_1; start_pc = VAR_0; start_codep = VAR_12.the_buffer; codep = VAR_12.the_buffer; if (sigsetjmp(VAR_12.bailout, 0) != 0) { const char *VAR_17; if (codep > VAR_12.the_buffer) { VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag); if (VAR_17 != NULL) (*VAR_1->fprintf_func) (VAR_1->stream, "%s", VAR_17); else { (*VAR_1->fprintf_func) (VAR_1->stream, ".byte 0x%x", (unsigned int) VAR_12.the_buffer[0]); } return 1; } return -1; } obufp = obuf; ckprefix (); ckvexprefix (); insn_codep = codep; VAR_10 = VAR_12.orig_sizeflag; fetch_data(VAR_1, codep + 1); two_source_ops = (*codep == 0x62) || (*codep == 0xc8); if (((prefixes & PREFIX_FWAIT) && ((*codep < 0xd8) || (*codep > 0xdf))) || (rex && rex_used)) { const char *VAR_17; VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag); if (VAR_17 == NULL) VAR_17 = INTERNAL_DISASSEMBLER_ERROR; (*VAR_1->fprintf_func) (VAR_1->stream, "%s", VAR_17); return 1; } VAR_13 = 0; if (prefixes & PREFIX_VEX_0F) { used_prefixes |= PREFIX_VEX_0F | PREFIX_VEX_0F38 | PREFIX_VEX_0F3A; if (prefixes & PREFIX_VEX_0F38) VAR_14 = 0x38; else if (prefixes & PREFIX_VEX_0F3A) VAR_14 = 0x3a; else VAR_14 = *codep++; goto vex_opcode; } if (*codep == 0x0f) { fetch_data(VAR_1, codep + 2); VAR_14 = codep[1]; codep += 2; vex_opcode: VAR_2 = &dis386_twobyte[VAR_14]; need_modrm = twobyte_has_modrm[VAR_14]; VAR_6 = twobyte_uses_DATA_prefix[VAR_14]; VAR_8 = twobyte_uses_REPNZ_prefix[VAR_14]; VAR_9 = twobyte_uses_REPZ_prefix[VAR_14]; VAR_7 = (VAR_14 & ~0x02) == 0x20; if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == IS_3BYTE_OPCODE) { fetch_data(VAR_1, codep + 2); VAR_13 = *codep++; switch (VAR_14) { case 0x38: VAR_6 = threebyte_0x38_uses_DATA_prefix[VAR_13]; VAR_8 = threebyte_0x38_uses_REPNZ_prefix[VAR_13]; VAR_9 = threebyte_0x38_uses_REPZ_prefix[VAR_13]; break; case 0x3a: VAR_6 = threebyte_0x3a_uses_DATA_prefix[VAR_13]; VAR_8 = threebyte_0x3a_uses_REPNZ_prefix[VAR_13]; VAR_9 = threebyte_0x3a_uses_REPZ_prefix[VAR_13]; break; default: break; } } } else { VAR_2 = &dis386[*codep]; need_modrm = onebyte_has_modrm[*codep]; VAR_6 = 0; VAR_8 = 0; VAR_9 = *codep == 0x90; VAR_7 = 0; codep++; } if (!VAR_9 && (prefixes & PREFIX_REPZ)) { oappend ("repz "); used_prefixes |= PREFIX_REPZ; } if (!VAR_8 && (prefixes & PREFIX_REPNZ)) { oappend ("repnz "); used_prefixes |= PREFIX_REPNZ; } if (!VAR_7 && (prefixes & PREFIX_LOCK)) { oappend ("lock "); used_prefixes |= PREFIX_LOCK; } if (prefixes & PREFIX_ADDR) { VAR_10 ^= AFLAG; if (VAR_2->VAR_13[2].bytemode != loop_jcxz_mode || intel_syntax) { if ((VAR_10 & AFLAG) || address_mode == mode_64bit) oappend ("addr32 "); else oappend ("addr16 "); used_prefixes |= PREFIX_ADDR; } } if (!VAR_6 && (prefixes & PREFIX_DATA)) { VAR_10 ^= DFLAG; if (VAR_2->VAR_13[2].bytemode == cond_jump_mode && VAR_2->VAR_13[0].bytemode == v_mode && !intel_syntax) { if (VAR_10 & DFLAG) oappend ("data32 "); else oappend ("data16 "); used_prefixes |= PREFIX_DATA; } } if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == IS_3BYTE_OPCODE) { VAR_2 = &three_byte_table[VAR_2->VAR_13[1].bytemode][VAR_13]; modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } else if (need_modrm) { fetch_data(VAR_1, codep + 1); modrm.mod = (*codep >> 6) & 3; modrm.reg = (*codep >> 3) & 7; modrm.rm = *codep & 7; } if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == FLOATCODE) { dofloat (VAR_10); } else { int VAR_16; if (VAR_2->VAR_17 == NULL) { switch (VAR_2->VAR_13[0].bytemode) { case USE_GROUPS: VAR_2 = &grps[VAR_2->VAR_13[1].bytemode][modrm.reg]; break; case USE_PREFIX_USER_TABLE: VAR_16 = 0; used_prefixes |= (prefixes & PREFIX_REPZ); if (prefixes & PREFIX_REPZ) VAR_16 = 1; else { used_prefixes |= (prefixes & PREFIX_REPNZ); if (prefixes & PREFIX_REPNZ) VAR_16 = 3; else { used_prefixes |= (prefixes & PREFIX_DATA); if (prefixes & PREFIX_DATA) VAR_16 = 2; } } VAR_2 = &prefix_user_table[VAR_2->VAR_13[1].bytemode][VAR_16]; break; case X86_64_SPECIAL: VAR_16 = address_mode == mode_64bit ? 1 : 0; VAR_2 = &x86_64_table[VAR_2->VAR_13[1].bytemode][VAR_16]; break; default: oappend (INTERNAL_DISASSEMBLER_ERROR); break; } } if (putop (VAR_2->VAR_17, VAR_10) == 0) { for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3) { obufp = op_out[VAR_3]; op_ad = MAX_OPERANDS - 1 - VAR_3; if (VAR_2->VAR_13[VAR_3].rtn) (*VAR_2->VAR_13[VAR_3].rtn) (VAR_2->VAR_13[VAR_3].bytemode, VAR_10); } } } if ((prefixes & ~used_prefixes) != 0) { const char *VAR_17; VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag); if (VAR_17 == NULL) VAR_17 = INTERNAL_DISASSEMBLER_ERROR; (*VAR_1->fprintf_func) (VAR_1->stream, "%s", VAR_17); return 1; } if (rex & ~rex_used) { const char *VAR_17; VAR_17 = prefix_name (rex | 0x40, VAR_12.orig_sizeflag); if (VAR_17 == NULL) VAR_17 = INTERNAL_DISASSEMBLER_ERROR; (*VAR_1->fprintf_func) (VAR_1->stream, "%s ", VAR_17); } obufp = obuf + strlen (obuf); for (VAR_3 = strlen (obuf); VAR_3 < 6; VAR_3++) oappend (" "); oappend (" "); (*VAR_1->fprintf_func) (VAR_1->stream, "%s", obuf); if (intel_syntax || two_source_ops) { bfd_vma riprel; for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3) VAR_4[VAR_3] = op_out[VAR_3]; for (VAR_3 = 0; VAR_3 < (MAX_OPERANDS >> 1); ++VAR_3) { op_ad = op_index[VAR_3]; op_index[VAR_3] = op_index[MAX_OPERANDS - 1 - VAR_3]; op_index[MAX_OPERANDS - 1 - VAR_3] = op_ad; riprel = op_riprel[VAR_3]; op_riprel[VAR_3] = op_riprel [MAX_OPERANDS - 1 - VAR_3]; op_riprel[MAX_OPERANDS - 1 - VAR_3] = riprel; } } else { for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3) VAR_4[MAX_OPERANDS - 1 - VAR_3] = op_out[VAR_3]; } VAR_5 = 0; for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3) if (*VAR_4[VAR_3]) { if (VAR_5) (*VAR_1->fprintf_func) (VAR_1->stream, ","); if (op_index[VAR_3] != -1 && !op_riprel[VAR_3]) (*VAR_1->print_address_func) ((bfd_vma) op_address[op_index[VAR_3]], VAR_1); else (*VAR_1->fprintf_func) (VAR_1->stream, "%s", VAR_4[VAR_3]); VAR_5 = 1; } for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; VAR_3++) if (op_index[VAR_3] != -1 && op_riprel[VAR_3]) { (*VAR_1->fprintf_func) (VAR_1->stream, " # "); (*VAR_1->print_address_func) ((bfd_vma) (start_pc + codep - start_codep + op_address[op_index[VAR_3]]), VAR_1); break; } return codep - VAR_12.the_buffer; }
[ "FUNC_0 (bfd_vma VAR_0, disassemble_info *VAR_1)\n{", "const struct dis386 *VAR_2;", "int VAR_3;", "char *VAR_4[MAX_OPERANDS];", "int VAR_5;", "unsigned char VAR_6, VAR_7;", "unsigned char VAR_8, VAR_9;", "int VAR_10;", "const char *VAR_11;", "struct dis_private VAR_12;", "unsigned char VAR_13;", "unsigned char VAR_14;", "if (VAR_1->mach == bfd_mach_x86_64_intel_syntax\n|| VAR_1->mach == bfd_mach_x86_64)\naddress_mode = mode_64bit;", "else\naddress_mode = mode_32bit;", "if (intel_syntax == (char) -1)\nintel_syntax = (VAR_1->mach == bfd_mach_i386_i386_intel_syntax\n|| VAR_1->mach == bfd_mach_x86_64_intel_syntax);", "if (VAR_1->mach == bfd_mach_i386_i386\n|| VAR_1->mach == bfd_mach_x86_64\n|| VAR_1->mach == bfd_mach_i386_i386_intel_syntax\n|| VAR_1->mach == bfd_mach_x86_64_intel_syntax)\nVAR_12.orig_sizeflag = AFLAG | DFLAG;", "else if (VAR_1->mach == bfd_mach_i386_i8086)\nVAR_12.orig_sizeflag = 0;", "else\nabort ();", "for (VAR_11 = VAR_1->disassembler_options; VAR_11 != NULL; )", "{", "if (strncmp (VAR_11, \"x86-64\", 6) == 0)\n{", "address_mode = mode_64bit;", "VAR_12.orig_sizeflag = AFLAG | DFLAG;", "}", "else if (strncmp (VAR_11, \"i386\", 4) == 0)\n{", "address_mode = mode_32bit;", "VAR_12.orig_sizeflag = AFLAG | DFLAG;", "}", "else if (strncmp (VAR_11, \"i8086\", 5) == 0)\n{", "address_mode = mode_16bit;", "VAR_12.orig_sizeflag = 0;", "}", "else if (strncmp (VAR_11, \"intel\", 5) == 0)\n{", "intel_syntax = 1;", "}", "else if (strncmp (VAR_11, \"att\", 3) == 0)\n{", "intel_syntax = 0;", "}", "else if (strncmp (VAR_11, \"addr\", 4) == 0)\n{", "if (address_mode == mode_64bit)\n{", "if (VAR_11[4] == '3' && VAR_11[5] == '2')\nVAR_12.orig_sizeflag &= ~AFLAG;", "else if (VAR_11[4] == '6' && VAR_11[5] == '4')\nVAR_12.orig_sizeflag |= AFLAG;", "}", "else\n{", "if (VAR_11[4] == '1' && VAR_11[5] == '6')\nVAR_12.orig_sizeflag &= ~AFLAG;", "else if (VAR_11[4] == '3' && VAR_11[5] == '2')\nVAR_12.orig_sizeflag |= AFLAG;", "}", "}", "else if (strncmp (VAR_11, \"data\", 4) == 0)\n{", "if (VAR_11[4] == '1' && VAR_11[5] == '6')\nVAR_12.orig_sizeflag &= ~DFLAG;", "else if (VAR_11[4] == '3' && VAR_11[5] == '2')\nVAR_12.orig_sizeflag |= DFLAG;", "}", "else if (strncmp (VAR_11, \"suffix\", 6) == 0)\nVAR_12.orig_sizeflag |= SUFFIX_ALWAYS;", "VAR_11 = strchr (VAR_11, ',');", "if (VAR_11 != NULL)\nVAR_11++;", "}", "if (intel_syntax)\n{", "names64 = intel_names64;", "names32 = intel_names32;", "names16 = intel_names16;", "names8 = intel_names8;", "names8rex = intel_names8rex;", "names_seg = intel_names_seg;", "index16 = intel_index16;", "open_char = '[';", "close_char = ']';", "separator_char = '+';", "scale_char = '*';", "}", "else\n{", "names64 = att_names64;", "names32 = att_names32;", "names16 = att_names16;", "names8 = att_names8;", "names8rex = att_names8rex;", "names_seg = att_names_seg;", "index16 = att_index16;", "open_char = '(';", "close_char = ')';", "separator_char = ',';", "scale_char = ',';", "}", "VAR_1->bytes_per_line = 7;", "VAR_1->private_data = &VAR_12;", "VAR_12.max_fetched = VAR_12.the_buffer;", "VAR_12.insn_start = VAR_0;", "obuf[0] = 0;", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3)", "{", "op_out[VAR_3][0] = 0;", "op_index[VAR_3] = -1;", "}", "the_info = VAR_1;", "start_pc = VAR_0;", "start_codep = VAR_12.the_buffer;", "codep = VAR_12.the_buffer;", "if (sigsetjmp(VAR_12.bailout, 0) != 0)\n{", "const char *VAR_17;", "if (codep > VAR_12.the_buffer)\n{", "VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag);", "if (VAR_17 != NULL)\n(*VAR_1->fprintf_func) (VAR_1->stream, \"%s\", VAR_17);", "else\n{", "(*VAR_1->fprintf_func) (VAR_1->stream, \".byte 0x%x\",\n(unsigned int) VAR_12.the_buffer[0]);", "}", "return 1;", "}", "return -1;", "}", "obufp = obuf;", "ckprefix ();", "ckvexprefix ();", "insn_codep = codep;", "VAR_10 = VAR_12.orig_sizeflag;", "fetch_data(VAR_1, codep + 1);", "two_source_ops = (*codep == 0x62) || (*codep == 0xc8);", "if (((prefixes & PREFIX_FWAIT)\n&& ((*codep < 0xd8) || (*codep > 0xdf)))\n|| (rex && rex_used))\n{", "const char *VAR_17;", "VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag);", "if (VAR_17 == NULL)\nVAR_17 = INTERNAL_DISASSEMBLER_ERROR;", "(*VAR_1->fprintf_func) (VAR_1->stream, \"%s\", VAR_17);", "return 1;", "}", "VAR_13 = 0;", "if (prefixes & PREFIX_VEX_0F)\n{", "used_prefixes |= PREFIX_VEX_0F | PREFIX_VEX_0F38 | PREFIX_VEX_0F3A;", "if (prefixes & PREFIX_VEX_0F38)\nVAR_14 = 0x38;", "else if (prefixes & PREFIX_VEX_0F3A)\nVAR_14 = 0x3a;", "else\nVAR_14 = *codep++;", "goto vex_opcode;", "}", "if (*codep == 0x0f)\n{", "fetch_data(VAR_1, codep + 2);", "VAR_14 = codep[1];", "codep += 2;", "vex_opcode:\nVAR_2 = &dis386_twobyte[VAR_14];", "need_modrm = twobyte_has_modrm[VAR_14];", "VAR_6 = twobyte_uses_DATA_prefix[VAR_14];", "VAR_8 = twobyte_uses_REPNZ_prefix[VAR_14];", "VAR_9 = twobyte_uses_REPZ_prefix[VAR_14];", "VAR_7 = (VAR_14 & ~0x02) == 0x20;", "if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == IS_3BYTE_OPCODE)\n{", "fetch_data(VAR_1, codep + 2);", "VAR_13 = *codep++;", "switch (VAR_14)\n{", "case 0x38:\nVAR_6 = threebyte_0x38_uses_DATA_prefix[VAR_13];", "VAR_8 = threebyte_0x38_uses_REPNZ_prefix[VAR_13];", "VAR_9 = threebyte_0x38_uses_REPZ_prefix[VAR_13];", "break;", "case 0x3a:\nVAR_6 = threebyte_0x3a_uses_DATA_prefix[VAR_13];", "VAR_8 = threebyte_0x3a_uses_REPNZ_prefix[VAR_13];", "VAR_9 = threebyte_0x3a_uses_REPZ_prefix[VAR_13];", "break;", "default:\nbreak;", "}", "}", "}", "else\n{", "VAR_2 = &dis386[*codep];", "need_modrm = onebyte_has_modrm[*codep];", "VAR_6 = 0;", "VAR_8 = 0;", "VAR_9 = *codep == 0x90;", "VAR_7 = 0;", "codep++;", "}", "if (!VAR_9 && (prefixes & PREFIX_REPZ))\n{", "oappend (\"repz \");", "used_prefixes |= PREFIX_REPZ;", "}", "if (!VAR_8 && (prefixes & PREFIX_REPNZ))\n{", "oappend (\"repnz \");", "used_prefixes |= PREFIX_REPNZ;", "}", "if (!VAR_7 && (prefixes & PREFIX_LOCK))\n{", "oappend (\"lock \");", "used_prefixes |= PREFIX_LOCK;", "}", "if (prefixes & PREFIX_ADDR)\n{", "VAR_10 ^= AFLAG;", "if (VAR_2->VAR_13[2].bytemode != loop_jcxz_mode || intel_syntax)\n{", "if ((VAR_10 & AFLAG) || address_mode == mode_64bit)\noappend (\"addr32 \");", "else\noappend (\"addr16 \");", "used_prefixes |= PREFIX_ADDR;", "}", "}", "if (!VAR_6 && (prefixes & PREFIX_DATA))\n{", "VAR_10 ^= DFLAG;", "if (VAR_2->VAR_13[2].bytemode == cond_jump_mode\n&& VAR_2->VAR_13[0].bytemode == v_mode\n&& !intel_syntax)\n{", "if (VAR_10 & DFLAG)\noappend (\"data32 \");", "else\noappend (\"data16 \");", "used_prefixes |= PREFIX_DATA;", "}", "}", "if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == IS_3BYTE_OPCODE)\n{", "VAR_2 = &three_byte_table[VAR_2->VAR_13[1].bytemode][VAR_13];", "modrm.mod = (*codep >> 6) & 3;", "modrm.reg = (*codep >> 3) & 7;", "modrm.rm = *codep & 7;", "}", "else if (need_modrm)\n{", "fetch_data(VAR_1, codep + 1);", "modrm.mod = (*codep >> 6) & 3;", "modrm.reg = (*codep >> 3) & 7;", "modrm.rm = *codep & 7;", "}", "if (VAR_2->VAR_17 == NULL && VAR_2->VAR_13[0].bytemode == FLOATCODE)\n{", "dofloat (VAR_10);", "}", "else\n{", "int VAR_16;", "if (VAR_2->VAR_17 == NULL)\n{", "switch (VAR_2->VAR_13[0].bytemode)\n{", "case USE_GROUPS:\nVAR_2 = &grps[VAR_2->VAR_13[1].bytemode][modrm.reg];", "break;", "case USE_PREFIX_USER_TABLE:\nVAR_16 = 0;", "used_prefixes |= (prefixes & PREFIX_REPZ);", "if (prefixes & PREFIX_REPZ)\nVAR_16 = 1;", "else\n{", "used_prefixes |= (prefixes & PREFIX_REPNZ);", "if (prefixes & PREFIX_REPNZ)\nVAR_16 = 3;", "else\n{", "used_prefixes |= (prefixes & PREFIX_DATA);", "if (prefixes & PREFIX_DATA)\nVAR_16 = 2;", "}", "}", "VAR_2 = &prefix_user_table[VAR_2->VAR_13[1].bytemode][VAR_16];", "break;", "case X86_64_SPECIAL:\nVAR_16 = address_mode == mode_64bit ? 1 : 0;", "VAR_2 = &x86_64_table[VAR_2->VAR_13[1].bytemode][VAR_16];", "break;", "default:\noappend (INTERNAL_DISASSEMBLER_ERROR);", "break;", "}", "}", "if (putop (VAR_2->VAR_17, VAR_10) == 0)\n{", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3)", "{", "obufp = op_out[VAR_3];", "op_ad = MAX_OPERANDS - 1 - VAR_3;", "if (VAR_2->VAR_13[VAR_3].rtn)\n(*VAR_2->VAR_13[VAR_3].rtn) (VAR_2->VAR_13[VAR_3].bytemode, VAR_10);", "}", "}", "}", "if ((prefixes & ~used_prefixes) != 0)\n{", "const char *VAR_17;", "VAR_17 = prefix_name (VAR_12.the_buffer[0], VAR_12.orig_sizeflag);", "if (VAR_17 == NULL)\nVAR_17 = INTERNAL_DISASSEMBLER_ERROR;", "(*VAR_1->fprintf_func) (VAR_1->stream, \"%s\", VAR_17);", "return 1;", "}", "if (rex & ~rex_used)\n{", "const char *VAR_17;", "VAR_17 = prefix_name (rex | 0x40, VAR_12.orig_sizeflag);", "if (VAR_17 == NULL)\nVAR_17 = INTERNAL_DISASSEMBLER_ERROR;", "(*VAR_1->fprintf_func) (VAR_1->stream, \"%s \", VAR_17);", "}", "obufp = obuf + strlen (obuf);", "for (VAR_3 = strlen (obuf); VAR_3 < 6; VAR_3++)", "oappend (\" \");", "oappend (\" \");", "(*VAR_1->fprintf_func) (VAR_1->stream, \"%s\", obuf);", "if (intel_syntax || two_source_ops)\n{", "bfd_vma riprel;", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3)", "VAR_4[VAR_3] = op_out[VAR_3];", "for (VAR_3 = 0; VAR_3 < (MAX_OPERANDS >> 1); ++VAR_3)", "{", "op_ad = op_index[VAR_3];", "op_index[VAR_3] = op_index[MAX_OPERANDS - 1 - VAR_3];", "op_index[MAX_OPERANDS - 1 - VAR_3] = op_ad;", "riprel = op_riprel[VAR_3];", "op_riprel[VAR_3] = op_riprel [MAX_OPERANDS - 1 - VAR_3];", "op_riprel[MAX_OPERANDS - 1 - VAR_3] = riprel;", "}", "}", "else\n{", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3)", "VAR_4[MAX_OPERANDS - 1 - VAR_3] = op_out[VAR_3];", "}", "VAR_5 = 0;", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; ++VAR_3)", "if (*VAR_4[VAR_3])\n{", "if (VAR_5)\n(*VAR_1->fprintf_func) (VAR_1->stream, \",\");", "if (op_index[VAR_3] != -1 && !op_riprel[VAR_3])\n(*VAR_1->print_address_func) ((bfd_vma) op_address[op_index[VAR_3]], VAR_1);", "else\n(*VAR_1->fprintf_func) (VAR_1->stream, \"%s\", VAR_4[VAR_3]);", "VAR_5 = 1;", "}", "for (VAR_3 = 0; VAR_3 < MAX_OPERANDS; VAR_3++)", "if (op_index[VAR_3] != -1 && op_riprel[VAR_3])\n{", "(*VAR_1->fprintf_func) (VAR_1->stream, \" # \");", "(*VAR_1->print_address_func) ((bfd_vma) (start_pc + codep - start_codep\n+ op_address[op_index[VAR_3]]), VAR_1);", "break;", "}", "return codep - VAR_12.the_buffer;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31, 33 ], [ 35, 37 ], [ 41, 43, 45 ], [ 49, 51, 53, 55, 57 ], [ 59, 61 ], [ 63, 65 ], [ 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 ], [ 173 ], [ 175, 177 ], [ 179 ], [ 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 ], [ 245 ], [ 249 ], [ 251 ], [ 253 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281, 283 ], [ 285 ], [ 295, 297 ], [ 299 ], [ 301, 303 ], [ 305, 307 ], [ 311, 313 ], [ 315 ], [ 319 ], [ 321 ], [ 325 ], [ 327 ], [ 331 ], [ 333 ], [ 335 ], [ 339 ], [ 341 ], [ 345 ], [ 347 ], [ 351, 353, 355, 357 ], [ 359 ], [ 367 ], [ 369, 371 ], [ 373 ], [ 375 ], [ 377 ], [ 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 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 495, 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505, 507 ], [ 509 ], [ 511 ], [ 513 ], [ 517, 519 ], [ 521 ], [ 523 ], [ 525 ], [ 529, 531 ], [ 533 ], [ 535, 537 ], [ 539, 541 ], [ 543, 545 ], [ 547 ], [ 549 ], [ 551 ], [ 555, 557 ], [ 559 ], [ 561, 563, 565, 567 ], [ 569, 571 ], [ 573, 575 ], [ 577 ], [ 579 ], [ 581 ], [ 585, 587 ], [ 589 ], [ 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599, 601 ], [ 603 ], [ 605 ], [ 607 ], [ 609 ], [ 611 ], [ 615, 617 ], [ 619 ], [ 621 ], [ 623, 625 ], [ 627 ], [ 629, 631 ], [ 633, 635 ], [ 637, 639 ], [ 641 ], [ 645, 647 ], [ 649 ], [ 651, 653 ], [ 655, 657 ], [ 663 ], [ 665, 667 ], [ 669, 671 ], [ 673 ], [ 675, 677 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 689, 691 ], [ 693 ], [ 695 ], [ 699, 701 ], [ 703 ], [ 705 ], [ 707 ], [ 711, 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723, 725 ], [ 727 ], [ 729 ], [ 731 ], [ 743, 745 ], [ 747 ], [ 751 ], [ 753, 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763, 765 ], [ 767 ], [ 769 ], [ 771, 773 ], [ 775 ], [ 777 ], [ 781 ], [ 783 ], [ 785 ], [ 787 ], [ 789 ], [ 797, 799 ], [ 801 ], [ 805 ], [ 807 ], [ 811 ], [ 813 ], [ 815 ], [ 817 ], [ 819 ], [ 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831, 833 ], [ 835 ], [ 837 ], [ 839 ], [ 843 ], [ 845 ], [ 847, 849 ], [ 851, 853 ], [ 855, 857 ], [ 859, 861 ], [ 863 ], [ 865 ], [ 869 ], [ 871, 873 ], [ 875 ], [ 877, 879 ], [ 881 ], [ 883 ], [ 885 ], [ 887 ] ]
17
static void vp6_parse_coeff_huffman(VP56Context *s) { VP56Model *model = s->modelp; uint8_t *permute = s->scantable.permutated; VLC *vlc_coeff; int coeff, sign, coeff_idx; int b, cg, idx; int pt = 0; /* plane type (0 for Y, 1 for U or V) */ for (b=0; b<6; b++) { int ct = 0; /* code type */ if (b > 3) pt = 1; vlc_coeff = &s->dccv_vlc[pt]; for (coeff_idx=0; coeff_idx<64; ) { int run = 1; if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { s->nb_null[coeff_idx][pt]--; if (coeff_idx) break; } else { if (get_bits_count(&s->gb) >= s->gb.size_in_bits) return; coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3); if (coeff == 0) { if (coeff_idx) { int pt = (coeff_idx >= 6); run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3); if (run >= 9) run += get_bits(&s->gb, 6); } else s->nb_null[0][pt] = vp6_get_nb_null(s); ct = 0; } else if (coeff == 11) { /* end of block */ if (coeff_idx == 1) /* first AC coeff ? */ s->nb_null[1][pt] = vp6_get_nb_null(s); break; } else { int coeff2 = vp56_coeff_bias[coeff]; if (coeff > 4) coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11); ct = 1 + (coeff2 > 1); sign = get_bits1(&s->gb); coeff2 = (coeff2 ^ -sign) + sign; if (coeff_idx) coeff2 *= s->dequant_ac; idx = model->coeff_index_to_pos[coeff_idx]; s->block_coeff[b][permute[idx]] = coeff2; } } coeff_idx+=run; cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); vlc_coeff = &s->ract_vlc[pt][ct][cg]; } } }
true
FFmpeg
2a6eb06254df79e96b3d791b6b89b2534ced3119
static void vp6_parse_coeff_huffman(VP56Context *s) { VP56Model *model = s->modelp; uint8_t *permute = s->scantable.permutated; VLC *vlc_coeff; int coeff, sign, coeff_idx; int b, cg, idx; int pt = 0; for (b=0; b<6; b++) { int ct = 0; if (b > 3) pt = 1; vlc_coeff = &s->dccv_vlc[pt]; for (coeff_idx=0; coeff_idx<64; ) { int run = 1; if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { s->nb_null[coeff_idx][pt]--; if (coeff_idx) break; } else { if (get_bits_count(&s->gb) >= s->gb.size_in_bits) return; coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3); if (coeff == 0) { if (coeff_idx) { int pt = (coeff_idx >= 6); run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3); if (run >= 9) run += get_bits(&s->gb, 6); } else s->nb_null[0][pt] = vp6_get_nb_null(s); ct = 0; } else if (coeff == 11) { if (coeff_idx == 1) s->nb_null[1][pt] = vp6_get_nb_null(s); break; } else { int coeff2 = vp56_coeff_bias[coeff]; if (coeff > 4) coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11); ct = 1 + (coeff2 > 1); sign = get_bits1(&s->gb); coeff2 = (coeff2 ^ -sign) + sign; if (coeff_idx) coeff2 *= s->dequant_ac; idx = model->coeff_index_to_pos[coeff_idx]; s->block_coeff[b][permute[idx]] = coeff2; } } coeff_idx+=run; cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); vlc_coeff = &s->ract_vlc[pt][ct][cg]; } } }
{ "code": [ " for (coeff_idx=0; coeff_idx<64; ) {" ], "line_no": [ 29 ] }
static void FUNC_0(VP56Context *VAR_0) { VP56Model *model = VAR_0->modelp; uint8_t *permute = VAR_0->scantable.permutated; VLC *vlc_coeff; int VAR_1, VAR_2, VAR_3; int VAR_4, VAR_5, VAR_6; int VAR_10 = 0; for (VAR_4=0; VAR_4<6; VAR_4++) { int VAR_8 = 0; if (VAR_4 > 3) VAR_10 = 1; vlc_coeff = &VAR_0->dccv_vlc[VAR_10]; for (VAR_3=0; VAR_3<64; ) { int VAR_9 = 1; if (VAR_3<2 && VAR_0->nb_null[VAR_3][VAR_10]) { VAR_0->nb_null[VAR_3][VAR_10]--; if (VAR_3) break; } else { if (get_bits_count(&VAR_0->gb) >= VAR_0->gb.size_in_bits) return; VAR_1 = get_vlc2(&VAR_0->gb, vlc_coeff->table, 9, 3); if (VAR_1 == 0) { if (VAR_3) { int VAR_10 = (VAR_3 >= 6); VAR_9 += get_vlc2(&VAR_0->gb, VAR_0->runv_vlc[VAR_10].table, 9, 3); if (VAR_9 >= 9) VAR_9 += get_bits(&VAR_0->gb, 6); } else VAR_0->nb_null[0][VAR_10] = vp6_get_nb_null(VAR_0); VAR_8 = 0; } else if (VAR_1 == 11) { if (VAR_3 == 1) VAR_0->nb_null[1][VAR_10] = vp6_get_nb_null(VAR_0); break; } else { int VAR_10 = vp56_coeff_bias[VAR_1]; if (VAR_1 > 4) VAR_10 += get_bits(&VAR_0->gb, VAR_1 <= 9 ? VAR_1 - 4 : 11); VAR_8 = 1 + (VAR_10 > 1); VAR_2 = get_bits1(&VAR_0->gb); VAR_10 = (VAR_10 ^ -VAR_2) + VAR_2; if (VAR_3) VAR_10 *= VAR_0->dequant_ac; VAR_6 = model->coeff_index_to_pos[VAR_3]; VAR_0->block_coeff[VAR_4][permute[VAR_6]] = VAR_10; } } VAR_3+=VAR_9; VAR_5 = FFMIN(vp6_coeff_groups[VAR_3], 3); vlc_coeff = &VAR_0->ract_vlc[VAR_10][VAR_8][VAR_5]; } } }
[ "static void FUNC_0(VP56Context *VAR_0)\n{", "VP56Model *model = VAR_0->modelp;", "uint8_t *permute = VAR_0->scantable.permutated;", "VLC *vlc_coeff;", "int VAR_1, VAR_2, VAR_3;", "int VAR_4, VAR_5, VAR_6;", "int VAR_10 = 0;", "for (VAR_4=0; VAR_4<6; VAR_4++) {", "int VAR_8 = 0;", "if (VAR_4 > 3) VAR_10 = 1;", "vlc_coeff = &VAR_0->dccv_vlc[VAR_10];", "for (VAR_3=0; VAR_3<64; ) {", "int VAR_9 = 1;", "if (VAR_3<2 && VAR_0->nb_null[VAR_3][VAR_10]) {", "VAR_0->nb_null[VAR_3][VAR_10]--;", "if (VAR_3)\nbreak;", "} else {", "if (get_bits_count(&VAR_0->gb) >= VAR_0->gb.size_in_bits)\nreturn;", "VAR_1 = get_vlc2(&VAR_0->gb, vlc_coeff->table, 9, 3);", "if (VAR_1 == 0) {", "if (VAR_3) {", "int VAR_10 = (VAR_3 >= 6);", "VAR_9 += get_vlc2(&VAR_0->gb, VAR_0->runv_vlc[VAR_10].table, 9, 3);", "if (VAR_9 >= 9)\nVAR_9 += get_bits(&VAR_0->gb, 6);", "} else", "VAR_0->nb_null[0][VAR_10] = vp6_get_nb_null(VAR_0);", "VAR_8 = 0;", "} else if (VAR_1 == 11) {", "if (VAR_3 == 1)\nVAR_0->nb_null[1][VAR_10] = vp6_get_nb_null(VAR_0);", "break;", "} else {", "int VAR_10 = vp56_coeff_bias[VAR_1];", "if (VAR_1 > 4)\nVAR_10 += get_bits(&VAR_0->gb, VAR_1 <= 9 ? VAR_1 - 4 : 11);", "VAR_8 = 1 + (VAR_10 > 1);", "VAR_2 = get_bits1(&VAR_0->gb);", "VAR_10 = (VAR_10 ^ -VAR_2) + VAR_2;", "if (VAR_3)\nVAR_10 *= VAR_0->dequant_ac;", "VAR_6 = model->coeff_index_to_pos[VAR_3];", "VAR_0->block_coeff[VAR_4][permute[VAR_6]] = VAR_10;", "}", "}", "VAR_3+=VAR_9;", "VAR_5 = FFMIN(vp6_coeff_groups[VAR_3], 3);", "vlc_coeff = &VAR_0->ract_vlc[VAR_10][VAR_8][VAR_5];", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 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 ] ]
18
static int vncws_start_tls_handshake(VncState *vs) { int ret = gnutls_handshake(vs->tls.session); if (ret < 0) { if (!gnutls_error_is_fatal(ret)) { VNC_DEBUG("Handshake interrupted (blocking)\n"); if (!gnutls_record_get_direction(vs->tls.session)) { qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs); } else { qemu_set_fd_handler(vs->csock, NULL, vncws_tls_handshake_io, vs); } return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret)); vnc_client_error(vs); return -1; } if (vs->vd->tls.x509verify) { if (vnc_tls_validate_certificate(vs) < 0) { VNC_DEBUG("Client verification failed\n"); vnc_client_error(vs); return -1; } else { VNC_DEBUG("Client verification passed\n"); } } VNC_DEBUG("Handshake done, switching to TLS data mode\n"); qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs); return 0; }
true
qemu
3e305e4a4752f70c0b5c3cf5b43ec957881714f7
static int vncws_start_tls_handshake(VncState *vs) { int ret = gnutls_handshake(vs->tls.session); if (ret < 0) { if (!gnutls_error_is_fatal(ret)) { VNC_DEBUG("Handshake interrupted (blocking)\n"); if (!gnutls_record_get_direction(vs->tls.session)) { qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs); } else { qemu_set_fd_handler(vs->csock, NULL, vncws_tls_handshake_io, vs); } return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret)); vnc_client_error(vs); return -1; } if (vs->vd->tls.x509verify) { if (vnc_tls_validate_certificate(vs) < 0) { VNC_DEBUG("Client verification failed\n"); vnc_client_error(vs); return -1; } else { VNC_DEBUG("Client verification passed\n"); } } VNC_DEBUG("Handshake done, switching to TLS data mode\n"); qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs); return 0; }
{ "code": [ " if (vs->vd->tls.x509verify) {", " if (vnc_tls_validate_certificate(vs) < 0) {", " VNC_DEBUG(\"Client verification failed\\n\");", " vnc_client_error(vs);", " return -1;", " } else {", " VNC_DEBUG(\"Client verification passed\\n\");", " VNC_DEBUG(\"Handshake done, switching to TLS data mode\\n\");", " if (ret < 0) {", " return -1;", " if (ret < 0) {", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return -1;", " return 0;", " return -1;", " return 0;", " return -1;", " return -1;", " return -1;", " return 0;", " vnc_client_error(vs);", " return -1;", " vnc_client_error(vs);", " return -1;", " vnc_client_error(vs);", " return -1;", " vnc_client_error(vs);", " return -1;", " } else {", " return 0;", " return 0;", " return -1;", " return 0;", " return 0;", " int ret = gnutls_handshake(vs->tls.session);", " if (ret < 0) {", " if (!gnutls_error_is_fatal(ret)) {", " VNC_DEBUG(\"Handshake interrupted (blocking)\\n\");", " if (!gnutls_record_get_direction(vs->tls.session)) {", " qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io,", " NULL, vs);", " } else {", " qemu_set_fd_handler(vs->csock, NULL, vncws_tls_handshake_io,", " vs);", " return 0;", " VNC_DEBUG(\"Handshake failed %s\\n\", gnutls_strerror(ret));", " vnc_client_error(vs);", " return -1;", " if (vs->vd->tls.x509verify) {", " if (vnc_tls_validate_certificate(vs) < 0) {", " VNC_DEBUG(\"Client verification failed\\n\");", " vnc_client_error(vs);", " return -1;", " } else {", " VNC_DEBUG(\"Client verification passed\\n\");", " VNC_DEBUG(\"Handshake done, switching to TLS data mode\\n\");", " qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs);", " } else {", " if (ret < 0) {", " } else {", " } else {", " } else {", " } else {" ], "line_no": [ 43, 45, 47, 49, 51, 53, 55, 63, 9, 37, 9, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 69, 37, 69, 37, 37, 37, 69, 35, 37, 49, 51, 49, 51, 49, 51, 53, 69, 29, 37, 69, 69, 5, 9, 11, 13, 15, 17, 19, 21, 23, 25, 29, 33, 35, 37, 43, 45, 47, 49, 51, 53, 55, 63, 65, 53, 9, 53, 21, 21, 21 ] }
static int FUNC_0(VncState *VAR_0) { int VAR_1 = gnutls_handshake(VAR_0->tls.session); if (VAR_1 < 0) { if (!gnutls_error_is_fatal(VAR_1)) { VNC_DEBUG("Handshake interrupted (blocking)\n"); if (!gnutls_record_get_direction(VAR_0->tls.session)) { qemu_set_fd_handler(VAR_0->csock, vncws_tls_handshake_io, NULL, VAR_0); } else { qemu_set_fd_handler(VAR_0->csock, NULL, vncws_tls_handshake_io, VAR_0); } return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(VAR_1)); vnc_client_error(VAR_0); return -1; } if (VAR_0->vd->tls.x509verify) { if (vnc_tls_validate_certificate(VAR_0) < 0) { VNC_DEBUG("Client verification failed\n"); vnc_client_error(VAR_0); return -1; } else { VNC_DEBUG("Client verification passed\n"); } } VNC_DEBUG("Handshake done, switching to TLS data mode\n"); qemu_set_fd_handler(VAR_0->csock, vncws_handshake_read, NULL, VAR_0); return 0; }
[ "static int FUNC_0(VncState *VAR_0)\n{", "int VAR_1 = gnutls_handshake(VAR_0->tls.session);", "if (VAR_1 < 0) {", "if (!gnutls_error_is_fatal(VAR_1)) {", "VNC_DEBUG(\"Handshake interrupted (blocking)\\n\");", "if (!gnutls_record_get_direction(VAR_0->tls.session)) {", "qemu_set_fd_handler(VAR_0->csock, vncws_tls_handshake_io,\nNULL, VAR_0);", "} else {", "qemu_set_fd_handler(VAR_0->csock, NULL, vncws_tls_handshake_io,\nVAR_0);", "}", "return 0;", "}", "VNC_DEBUG(\"Handshake failed %s\\n\", gnutls_strerror(VAR_1));", "vnc_client_error(VAR_0);", "return -1;", "}", "if (VAR_0->vd->tls.x509verify) {", "if (vnc_tls_validate_certificate(VAR_0) < 0) {", "VNC_DEBUG(\"Client verification failed\\n\");", "vnc_client_error(VAR_0);", "return -1;", "} else {", "VNC_DEBUG(\"Client verification passed\\n\");", "}", "}", "VNC_DEBUG(\"Handshake done, switching to TLS data mode\\n\");", "qemu_set_fd_handler(VAR_0->csock, vncws_handshake_read, NULL, VAR_0);", "return 0;", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ] ]
19
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq) { afq->avctx = avctx; afq->next_pts = AV_NOPTS_VALUE; afq->remaining_delay = avctx->delay; afq->remaining_samples = avctx->delay; afq->frame_queue = NULL; }
false
FFmpeg
2df0c32ea12ddfa72ba88309812bfb13b674130f
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq) { afq->avctx = avctx; afq->next_pts = AV_NOPTS_VALUE; afq->remaining_delay = avctx->delay; afq->remaining_samples = avctx->delay; afq->frame_queue = NULL; }
{ "code": [], "line_no": [] }
av_cold void FUNC_0(AVCodecContext *avctx, AudioFrameQueue *afq) { afq->avctx = avctx; afq->next_pts = AV_NOPTS_VALUE; afq->remaining_delay = avctx->delay; afq->remaining_samples = avctx->delay; afq->frame_queue = NULL; }
[ "av_cold void FUNC_0(AVCodecContext *avctx, AudioFrameQueue *afq)\n{", "afq->avctx = avctx;", "afq->next_pts = AV_NOPTS_VALUE;", "afq->remaining_delay = avctx->delay;", "afq->remaining_samples = avctx->delay;", "afq->frame_queue = NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
20
static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp) { char *backing_file = NULL; char *backing_fmt = NULL; char *buf = NULL; uint64_t size = 0; int flags = 0; size_t cluster_size = DEFAULT_CLUSTER_SIZE; PreallocMode prealloc; int version; uint64_t refcount_bits; int refcount_order; const char *encryptfmt = NULL; Error *local_err = NULL; int ret; /* Read out options */ size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE); backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT); encryptfmt = qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT_FORMAT); if (encryptfmt) { if (qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT)) { error_setg(errp, "Options " BLOCK_OPT_ENCRYPT " and " BLOCK_OPT_ENCRYPT_FORMAT " are mutually exclusive"); ret = -EINVAL; goto finish; } } else if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) { encryptfmt = "aes"; } cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, buf, PREALLOC_MODE__MAX, PREALLOC_MODE_OFF, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } version = qcow2_opt_get_version_del(opts, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } if (qemu_opt_get_bool_del(opts, BLOCK_OPT_LAZY_REFCOUNTS, false)) { flags |= BLOCK_FLAG_LAZY_REFCOUNTS; } if (backing_file && prealloc != PREALLOC_MODE_OFF) { error_setg(errp, "Backing file and preallocation cannot be used at " "the same time"); ret = -EINVAL; goto finish; } if (version < 3 && (flags & BLOCK_FLAG_LAZY_REFCOUNTS)) { error_setg(errp, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)"); ret = -EINVAL; goto finish; } refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } refcount_order = ctz32(refcount_bits); ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags, cluster_size, prealloc, opts, version, refcount_order, encryptfmt, &local_err); error_propagate(errp, local_err); finish: g_free(backing_file); g_free(backing_fmt); g_free(buf); return ret; }
true
qemu
0696ae2c9236a3589f5eaf5b00c12868b6f30a17
static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp) { char *backing_file = NULL; char *backing_fmt = NULL; char *buf = NULL; uint64_t size = 0; int flags = 0; size_t cluster_size = DEFAULT_CLUSTER_SIZE; PreallocMode prealloc; int version; uint64_t refcount_bits; int refcount_order; const char *encryptfmt = NULL; Error *local_err = NULL; int ret; size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE); backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT); encryptfmt = qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT_FORMAT); if (encryptfmt) { if (qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT)) { error_setg(errp, "Options " BLOCK_OPT_ENCRYPT " and " BLOCK_OPT_ENCRYPT_FORMAT " are mutually exclusive"); ret = -EINVAL; goto finish; } } else if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) { encryptfmt = "aes"; } cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, buf, PREALLOC_MODE__MAX, PREALLOC_MODE_OFF, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } version = qcow2_opt_get_version_del(opts, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } if (qemu_opt_get_bool_del(opts, BLOCK_OPT_LAZY_REFCOUNTS, false)) { flags |= BLOCK_FLAG_LAZY_REFCOUNTS; } if (backing_file && prealloc != PREALLOC_MODE_OFF) { error_setg(errp, "Backing file and preallocation cannot be used at " "the same time"); ret = -EINVAL; goto finish; } if (version < 3 && (flags & BLOCK_FLAG_LAZY_REFCOUNTS)) { error_setg(errp, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)"); ret = -EINVAL; goto finish; } refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto finish; } refcount_order = ctz32(refcount_bits); ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags, cluster_size, prealloc, opts, version, refcount_order, encryptfmt, &local_err); error_propagate(errp, local_err); finish: g_free(backing_file); g_free(backing_fmt); g_free(buf); return ret; }
{ "code": [ " const char *encryptfmt = NULL;", " encryptfmt = \"aes\";", " const char *encryptfmt = NULL;", " if (qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT)) {", " encryptfmt = \"aes\";" ], "line_no": [ 25, 61, 25, 47, 61 ] }
static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2) { char *VAR_3 = NULL; char *VAR_4 = NULL; char *VAR_5 = NULL; uint64_t size = 0; int VAR_6 = 0; size_t cluster_size = DEFAULT_CLUSTER_SIZE; PreallocMode prealloc; int VAR_7; uint64_t refcount_bits; int VAR_8; const char *VAR_9 = NULL; Error *local_err = NULL; int VAR_10; size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); VAR_3 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FILE); VAR_4 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FMT); VAR_9 = qemu_opt_get_del(VAR_1, BLOCK_OPT_ENCRYPT_FORMAT); if (VAR_9) { if (qemu_opt_get_del(VAR_1, BLOCK_OPT_ENCRYPT)) { error_setg(VAR_2, "Options " BLOCK_OPT_ENCRYPT " and " BLOCK_OPT_ENCRYPT_FORMAT " are mutually exclusive"); VAR_10 = -EINVAL; goto finish; } } else if (qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_ENCRYPT, false)) { VAR_9 = "aes"; } cluster_size = qcow2_opt_get_cluster_size_del(VAR_1, &local_err); if (local_err) { error_propagate(VAR_2, local_err); VAR_10 = -EINVAL; goto finish; } VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, VAR_5, PREALLOC_MODE__MAX, PREALLOC_MODE_OFF, &local_err); if (local_err) { error_propagate(VAR_2, local_err); VAR_10 = -EINVAL; goto finish; } VAR_7 = qcow2_opt_get_version_del(VAR_1, &local_err); if (local_err) { error_propagate(VAR_2, local_err); VAR_10 = -EINVAL; goto finish; } if (qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_LAZY_REFCOUNTS, false)) { VAR_6 |= BLOCK_FLAG_LAZY_REFCOUNTS; } if (VAR_3 && prealloc != PREALLOC_MODE_OFF) { error_setg(VAR_2, "Backing file and preallocation cannot be used at " "the same time"); VAR_10 = -EINVAL; goto finish; } if (VAR_7 < 3 && (VAR_6 & BLOCK_FLAG_LAZY_REFCOUNTS)) { error_setg(VAR_2, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)"); VAR_10 = -EINVAL; goto finish; } refcount_bits = qcow2_opt_get_refcount_bits_del(VAR_1, VAR_7, &local_err); if (local_err) { error_propagate(VAR_2, local_err); VAR_10 = -EINVAL; goto finish; } VAR_8 = ctz32(refcount_bits); VAR_10 = qcow2_create2(VAR_0, size, VAR_3, VAR_4, VAR_6, cluster_size, prealloc, VAR_1, VAR_7, VAR_8, VAR_9, &local_err); error_propagate(VAR_2, local_err); finish: g_free(VAR_3); g_free(VAR_4); g_free(VAR_5); return VAR_10; }
[ "static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{", "char *VAR_3 = NULL;", "char *VAR_4 = NULL;", "char *VAR_5 = NULL;", "uint64_t size = 0;", "int VAR_6 = 0;", "size_t cluster_size = DEFAULT_CLUSTER_SIZE;", "PreallocMode prealloc;", "int VAR_7;", "uint64_t refcount_bits;", "int VAR_8;", "const char *VAR_9 = NULL;", "Error *local_err = NULL;", "int VAR_10;", "size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0),\nBDRV_SECTOR_SIZE);", "VAR_3 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FILE);", "VAR_4 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FMT);", "VAR_9 = qemu_opt_get_del(VAR_1, BLOCK_OPT_ENCRYPT_FORMAT);", "if (VAR_9) {", "if (qemu_opt_get_del(VAR_1, BLOCK_OPT_ENCRYPT)) {", "error_setg(VAR_2, \"Options \" BLOCK_OPT_ENCRYPT \" and \"\nBLOCK_OPT_ENCRYPT_FORMAT \" are mutually exclusive\");", "VAR_10 = -EINVAL;", "goto finish;", "}", "} else if (qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_ENCRYPT, false)) {", "VAR_9 = \"aes\";", "}", "cluster_size = qcow2_opt_get_cluster_size_del(VAR_1, &local_err);", "if (local_err) {", "error_propagate(VAR_2, local_err);", "VAR_10 = -EINVAL;", "goto finish;", "}", "VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);", "prealloc = qapi_enum_parse(PreallocMode_lookup, VAR_5,\nPREALLOC_MODE__MAX, PREALLOC_MODE_OFF,\n&local_err);", "if (local_err) {", "error_propagate(VAR_2, local_err);", "VAR_10 = -EINVAL;", "goto finish;", "}", "VAR_7 = qcow2_opt_get_version_del(VAR_1, &local_err);", "if (local_err) {", "error_propagate(VAR_2, local_err);", "VAR_10 = -EINVAL;", "goto finish;", "}", "if (qemu_opt_get_bool_del(VAR_1, BLOCK_OPT_LAZY_REFCOUNTS, false)) {", "VAR_6 |= BLOCK_FLAG_LAZY_REFCOUNTS;", "}", "if (VAR_3 && prealloc != PREALLOC_MODE_OFF) {", "error_setg(VAR_2, \"Backing file and preallocation cannot be used at \"\n\"the same time\");", "VAR_10 = -EINVAL;", "goto finish;", "}", "if (VAR_7 < 3 && (VAR_6 & BLOCK_FLAG_LAZY_REFCOUNTS)) {", "error_setg(VAR_2, \"Lazy refcounts only supported with compatibility \"\n\"level 1.1 and above (use compat=1.1 or greater)\");", "VAR_10 = -EINVAL;", "goto finish;", "}", "refcount_bits = qcow2_opt_get_refcount_bits_del(VAR_1, VAR_7, &local_err);", "if (local_err) {", "error_propagate(VAR_2, local_err);", "VAR_10 = -EINVAL;", "goto finish;", "}", "VAR_8 = ctz32(refcount_bits);", "VAR_10 = qcow2_create2(VAR_0, size, VAR_3, VAR_4, VAR_6,\ncluster_size, prealloc, VAR_1, VAR_7, VAR_8,\nVAR_9, &local_err);", "error_propagate(VAR_2, local_err);", "finish:\ng_free(VAR_3);", "g_free(VAR_4);", "g_free(VAR_5);", "return VAR_10;", "}" ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 35, 37 ], [ 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 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 165, 167, 169 ], [ 171 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ] ]
21
static void quantize_mantissas(AC3EncodeContext *s) { int blk, ch; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; s->mant1_cnt = s->mant2_cnt = s->mant4_cnt = 0; s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL; for (ch = 0; ch < s->channels; ch++) { quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch], block->exp[ch], block->bap[ch], block->qmant[ch], s->nb_coefs[ch]); } } }
true
FFmpeg
323e6fead07c75f418e4b60704a4f437bb3483b2
static void quantize_mantissas(AC3EncodeContext *s) { int blk, ch; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; s->mant1_cnt = s->mant2_cnt = s->mant4_cnt = 0; s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL; for (ch = 0; ch < s->channels; ch++) { quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch], block->exp[ch], block->bap[ch], block->qmant[ch], s->nb_coefs[ch]); } } }
{ "code": [ " quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch]," ], "line_no": [ 23 ] }
static void FUNC_0(AC3EncodeContext *VAR_0) { int VAR_1, VAR_2; for (VAR_1 = 0; VAR_1 < AC3_MAX_BLOCKS; VAR_1++) { AC3Block *block = &VAR_0->blocks[VAR_1]; VAR_0->mant1_cnt = VAR_0->mant2_cnt = VAR_0->mant4_cnt = 0; VAR_0->qmant1_ptr = VAR_0->qmant2_ptr = VAR_0->qmant4_ptr = NULL; for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) { quantize_mantissas_blk_ch(VAR_0, block->fixed_coef[VAR_2], block->exp_shift[VAR_2], block->exp[VAR_2], block->bap[VAR_2], block->qmant[VAR_2], VAR_0->nb_coefs[VAR_2]); } } }
[ "static void FUNC_0(AC3EncodeContext *VAR_0)\n{", "int VAR_1, VAR_2;", "for (VAR_1 = 0; VAR_1 < AC3_MAX_BLOCKS; VAR_1++) {", "AC3Block *block = &VAR_0->blocks[VAR_1];", "VAR_0->mant1_cnt = VAR_0->mant2_cnt = VAR_0->mant4_cnt = 0;", "VAR_0->qmant1_ptr = VAR_0->qmant2_ptr = VAR_0->qmant4_ptr = NULL;", "for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) {", "quantize_mantissas_blk_ch(VAR_0, block->fixed_coef[VAR_2], block->exp_shift[VAR_2],\nblock->exp[VAR_2], block->bap[VAR_2],\nblock->qmant[VAR_2], VAR_0->nb_coefs[VAR_2]);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25, 27 ], [ 29 ], [ 31 ], [ 33 ] ]
23
static void dma_blk_cb(void *opaque, int ret) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; dma_addr_t cur_addr, cur_len; void *mem; trace_dma_blk_cb(dbs, ret); dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dma_complete(dbs, ret); return; } dma_blk_unmap(dbs); while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); if (!mem) break; qemu_iovec_add(&dbs->iov, mem, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { trace_dma_map_wait(dbs); cpu_register_map_client(dbs, continue_after_map_failure); return; } if (dbs->iov.size & ~BDRV_SECTOR_MASK) { qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK); } dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, dma_blk_cb, dbs); assert(dbs->acb); }
true
qemu
e95205e1f9cd2c4262b7a7b1c992a94512c86d0e
static void dma_blk_cb(void *opaque, int ret) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; dma_addr_t cur_addr, cur_len; void *mem; trace_dma_blk_cb(dbs, ret); dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dma_complete(dbs, ret); return; } dma_blk_unmap(dbs); while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); if (!mem) break; qemu_iovec_add(&dbs->iov, mem, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { trace_dma_map_wait(dbs); cpu_register_map_client(dbs, continue_after_map_failure); return; } if (dbs->iov.size & ~BDRV_SECTOR_MASK) { qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK); } dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, dma_blk_cb, dbs); assert(dbs->acb); }
{ "code": [ " DMAAIOCB *dbs = (DMAAIOCB *)opaque;", " cpu_register_map_client(dbs, continue_after_map_failure);" ], "line_no": [ 5, 67 ] }
static void FUNC_0(void *VAR_0, int VAR_1) { DMAAIOCB *dbs = (DMAAIOCB *)VAR_0; dma_addr_t cur_addr, cur_len; void *VAR_2; trace_dma_blk_cb(dbs, VAR_1); dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; if (dbs->sg_cur_index == dbs->sg->nsg || VAR_1 < 0) { dma_complete(dbs, VAR_1); return; } dma_blk_unmap(dbs); while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; VAR_2 = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); if (!VAR_2) break; qemu_iovec_add(&dbs->iov, VAR_2, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { trace_dma_map_wait(dbs); cpu_register_map_client(dbs, continue_after_map_failure); return; } if (dbs->iov.size & ~BDRV_SECTOR_MASK) { qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK); } dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, FUNC_0, dbs); assert(dbs->acb); }
[ "static void FUNC_0(void *VAR_0, int VAR_1)\n{", "DMAAIOCB *dbs = (DMAAIOCB *)VAR_0;", "dma_addr_t cur_addr, cur_len;", "void *VAR_2;", "trace_dma_blk_cb(dbs, VAR_1);", "dbs->acb = NULL;", "dbs->sector_num += dbs->iov.size / 512;", "if (dbs->sg_cur_index == dbs->sg->nsg || VAR_1 < 0) {", "dma_complete(dbs, VAR_1);", "return;", "}", "dma_blk_unmap(dbs);", "while (dbs->sg_cur_index < dbs->sg->nsg) {", "cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;", "cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;", "VAR_2 = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir);", "if (!VAR_2)\nbreak;", "qemu_iovec_add(&dbs->iov, VAR_2, cur_len);", "dbs->sg_cur_byte += cur_len;", "if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {", "dbs->sg_cur_byte = 0;", "++dbs->sg_cur_index;", "}", "}", "if (dbs->iov.size == 0) {", "trace_dma_map_wait(dbs);", "cpu_register_map_client(dbs, continue_after_map_failure);", "return;", "}", "if (dbs->iov.size & ~BDRV_SECTOR_MASK) {", "qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK);", "}", "dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov,\ndbs->iov.size / 512, FUNC_0, dbs);", "assert(dbs->acb);", "}" ]
[ 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, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 89 ] ]
24
long do_sigreturn(CPUPPCState *env) { struct target_sigcontext *sc = NULL; struct target_mcontext *sr = NULL; target_ulong sr_addr = 0, sc_addr; sigset_t blocked; target_sigset_t set; sc_addr = env->gpr[1] + SIGNAL_FRAMESIZE; if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) goto sigsegv; #if defined(TARGET_PPC64) set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32); #else __get_user(set.sig[0], &sc->oldmask); __get_user(set.sig[1], &sc->_unused[3]); #endif target_to_host_sigset_internal(&blocked, &set); set_sigmask(&blocked); __get_user(sr_addr, &sc->regs); if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1)) goto sigsegv; restore_user_regs(env, sr, 1); unlock_user_struct(sr, sr_addr, 1); unlock_user_struct(sc, sc_addr, 1); return -TARGET_QEMU_ESIGRETURN; sigsegv: unlock_user_struct(sr, sr_addr, 1); unlock_user_struct(sc, sc_addr, 1); force_sig(TARGET_SIGSEGV); return 0; }
true
qemu
c599d4d6d6e9bfdb64e54c33a22cb26e3496b96d
long do_sigreturn(CPUPPCState *env) { struct target_sigcontext *sc = NULL; struct target_mcontext *sr = NULL; target_ulong sr_addr = 0, sc_addr; sigset_t blocked; target_sigset_t set; sc_addr = env->gpr[1] + SIGNAL_FRAMESIZE; if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) goto sigsegv; #if defined(TARGET_PPC64) set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32); #else __get_user(set.sig[0], &sc->oldmask); __get_user(set.sig[1], &sc->_unused[3]); #endif target_to_host_sigset_internal(&blocked, &set); set_sigmask(&blocked); __get_user(sr_addr, &sc->regs); if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1)) goto sigsegv; restore_user_regs(env, sr, 1); unlock_user_struct(sr, sr_addr, 1); unlock_user_struct(sc, sc_addr, 1); return -TARGET_QEMU_ESIGRETURN; sigsegv: unlock_user_struct(sr, sr_addr, 1); unlock_user_struct(sc, sc_addr, 1); force_sig(TARGET_SIGSEGV); return 0; }
{ "code": [ " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;" ], "line_no": [ 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69 ] }
long FUNC_0(CPUPPCState *VAR_0) { struct target_sigcontext *VAR_1 = NULL; struct target_mcontext *VAR_2 = NULL; target_ulong sr_addr = 0, sc_addr; sigset_t blocked; target_sigset_t set; sc_addr = VAR_0->gpr[1] + SIGNAL_FRAMESIZE; if (!lock_user_struct(VERIFY_READ, VAR_1, sc_addr, 1)) goto sigsegv; #if defined(TARGET_PPC64) set.sig[0] = VAR_1->oldmask + ((uint64_t)(VAR_1->_unused[3]) << 32); #else __get_user(set.sig[0], &VAR_1->oldmask); __get_user(set.sig[1], &VAR_1->_unused[3]); #endif target_to_host_sigset_internal(&blocked, &set); set_sigmask(&blocked); __get_user(sr_addr, &VAR_1->regs); if (!lock_user_struct(VERIFY_READ, VAR_2, sr_addr, 1)) goto sigsegv; restore_user_regs(VAR_0, VAR_2, 1); unlock_user_struct(VAR_2, sr_addr, 1); unlock_user_struct(VAR_1, sc_addr, 1); return -TARGET_QEMU_ESIGRETURN; sigsegv: unlock_user_struct(VAR_2, sr_addr, 1); unlock_user_struct(VAR_1, sc_addr, 1); force_sig(TARGET_SIGSEGV); return 0; }
[ "long FUNC_0(CPUPPCState *VAR_0)\n{", "struct target_sigcontext *VAR_1 = NULL;", "struct target_mcontext *VAR_2 = NULL;", "target_ulong sr_addr = 0, sc_addr;", "sigset_t blocked;", "target_sigset_t set;", "sc_addr = VAR_0->gpr[1] + SIGNAL_FRAMESIZE;", "if (!lock_user_struct(VERIFY_READ, VAR_1, sc_addr, 1))\ngoto sigsegv;", "#if defined(TARGET_PPC64)\nset.sig[0] = VAR_1->oldmask + ((uint64_t)(VAR_1->_unused[3]) << 32);", "#else\n__get_user(set.sig[0], &VAR_1->oldmask);", "__get_user(set.sig[1], &VAR_1->_unused[3]);", "#endif\ntarget_to_host_sigset_internal(&blocked, &set);", "set_sigmask(&blocked);", "__get_user(sr_addr, &VAR_1->regs);", "if (!lock_user_struct(VERIFY_READ, VAR_2, sr_addr, 1))\ngoto sigsegv;", "restore_user_regs(VAR_0, VAR_2, 1);", "unlock_user_struct(VAR_2, sr_addr, 1);", "unlock_user_struct(VAR_1, sc_addr, 1);", "return -TARGET_QEMU_ESIGRETURN;", "sigsegv:\nunlock_user_struct(VAR_2, sr_addr, 1);", "unlock_user_struct(VAR_1, sc_addr, 1);", "force_sig(TARGET_SIGSEGV);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 25, 27 ], [ 29, 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
25
static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; int i; g->hostmem = 0; resource_id = qemu_get_be32(f); while (resource_id != 0) { res = g_new0(struct virtio_gpu_simple_resource, 1); res->resource_id = resource_id; res->width = qemu_get_be32(f); res->height = qemu_get_be32(f); res->format = qemu_get_be32(f); res->iov_cnt = qemu_get_be32(f); /* allocate */ pformat = get_pixman_format(res->format); if (!pformat) { return -EINVAL; res->image = pixman_image_create_bits(pformat, res->width, res->height, NULL, 0); if (!res->image) { return -EINVAL; res->hostmem = PIXMAN_FORMAT_BPP(pformat) * res->width * res->height; res->addrs = g_new(uint64_t, res->iov_cnt); res->iov = g_new(struct iovec, res->iov_cnt); /* read data */ for (i = 0; i < res->iov_cnt; i++) { res->addrs[i] = qemu_get_be64(f); res->iov[i].iov_len = qemu_get_be32(f); qemu_get_buffer(f, (void *)pixman_image_get_data(res->image), pixman_image_get_stride(res->image) * res->height); /* restore mapping */ for (i = 0; i < res->iov_cnt; i++) { hwaddr len = res->iov[i].iov_len; res->iov[i].iov_base = cpu_physical_memory_map(res->addrs[i], &len, 1); if (!res->iov[i].iov_base || len != res->iov[i].iov_len) { return -EINVAL; QTAILQ_INSERT_HEAD(&g->reslist, res, next); g->hostmem += res->hostmem; resource_id = qemu_get_be32(f); /* load & apply scanout state */ vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); for (i = 0; i < g->conf.max_outputs; i++) { scanout = &g->scanout[i]; if (!scanout->resource_id) { continue; res = virtio_gpu_find_resource(g, scanout->resource_id); if (!res) { return -EINVAL; scanout->ds = qemu_create_displaysurface_pixman(res->image); if (!scanout->ds) { return -EINVAL; dpy_gfx_replace_surface(scanout->con, scanout->ds); dpy_gfx_update(scanout->con, 0, 0, scanout->width, scanout->height); update_cursor(g, &scanout->cursor); res->scanout_bitmask |= (1 << i); return 0;
true
qemu
c84f0f25db2eaab101665ddb60c1ddf1decce76a
static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; int i; g->hostmem = 0; resource_id = qemu_get_be32(f); while (resource_id != 0) { res = g_new0(struct virtio_gpu_simple_resource, 1); res->resource_id = resource_id; res->width = qemu_get_be32(f); res->height = qemu_get_be32(f); res->format = qemu_get_be32(f); res->iov_cnt = qemu_get_be32(f); pformat = get_pixman_format(res->format); if (!pformat) { return -EINVAL; res->image = pixman_image_create_bits(pformat, res->width, res->height, NULL, 0); if (!res->image) { return -EINVAL; res->hostmem = PIXMAN_FORMAT_BPP(pformat) * res->width * res->height; res->addrs = g_new(uint64_t, res->iov_cnt); res->iov = g_new(struct iovec, res->iov_cnt); for (i = 0; i < res->iov_cnt; i++) { res->addrs[i] = qemu_get_be64(f); res->iov[i].iov_len = qemu_get_be32(f); qemu_get_buffer(f, (void *)pixman_image_get_data(res->image), pixman_image_get_stride(res->image) * res->height); for (i = 0; i < res->iov_cnt; i++) { hwaddr len = res->iov[i].iov_len; res->iov[i].iov_base = cpu_physical_memory_map(res->addrs[i], &len, 1); if (!res->iov[i].iov_base || len != res->iov[i].iov_len) { return -EINVAL; QTAILQ_INSERT_HEAD(&g->reslist, res, next); g->hostmem += res->hostmem; resource_id = qemu_get_be32(f); vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); for (i = 0; i < g->conf.max_outputs; i++) { scanout = &g->scanout[i]; if (!scanout->resource_id) { continue; res = virtio_gpu_find_resource(g, scanout->resource_id); if (!res) { return -EINVAL; scanout->ds = qemu_create_displaysurface_pixman(res->image); if (!scanout->ds) { return -EINVAL; dpy_gfx_replace_surface(scanout->con, scanout->ds); dpy_gfx_update(scanout->con, 0, 0, scanout->width, scanout->height); update_cursor(g, &scanout->cursor); res->scanout_bitmask |= (1 << i); return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2) { VirtIOGPU *g = VAR_1; struct virtio_gpu_simple_resource *VAR_3; struct virtio_gpu_scanout *VAR_4; uint32_t resource_id, pformat; int VAR_5; g->hostmem = 0; resource_id = qemu_get_be32(VAR_0); while (resource_id != 0) { VAR_3 = g_new0(struct virtio_gpu_simple_resource, 1); VAR_3->resource_id = resource_id; VAR_3->width = qemu_get_be32(VAR_0); VAR_3->height = qemu_get_be32(VAR_0); VAR_3->format = qemu_get_be32(VAR_0); VAR_3->iov_cnt = qemu_get_be32(VAR_0); pformat = get_pixman_format(VAR_3->format); if (!pformat) { return -EINVAL; VAR_3->image = pixman_image_create_bits(pformat, VAR_3->width, VAR_3->height, NULL, 0); if (!VAR_3->image) { return -EINVAL; VAR_3->hostmem = PIXMAN_FORMAT_BPP(pformat) * VAR_3->width * VAR_3->height; VAR_3->addrs = g_new(uint64_t, VAR_3->iov_cnt); VAR_3->iov = g_new(struct iovec, VAR_3->iov_cnt); for (VAR_5 = 0; VAR_5 < VAR_3->iov_cnt; VAR_5++) { VAR_3->addrs[VAR_5] = qemu_get_be64(VAR_0); VAR_3->iov[VAR_5].iov_len = qemu_get_be32(VAR_0); qemu_get_buffer(VAR_0, (void *)pixman_image_get_data(VAR_3->image), pixman_image_get_stride(VAR_3->image) * VAR_3->height); for (VAR_5 = 0; VAR_5 < VAR_3->iov_cnt; VAR_5++) { hwaddr len = VAR_3->iov[VAR_5].iov_len; VAR_3->iov[VAR_5].iov_base = cpu_physical_memory_map(VAR_3->addrs[VAR_5], &len, 1); if (!VAR_3->iov[VAR_5].iov_base || len != VAR_3->iov[VAR_5].iov_len) { return -EINVAL; QTAILQ_INSERT_HEAD(&g->reslist, VAR_3, next); g->hostmem += VAR_3->hostmem; resource_id = qemu_get_be32(VAR_0); vmstate_load_state(VAR_0, &vmstate_virtio_gpu_scanouts, g, 1); for (VAR_5 = 0; VAR_5 < g->conf.max_outputs; VAR_5++) { VAR_4 = &g->VAR_4[VAR_5]; if (!VAR_4->resource_id) { continue; VAR_3 = virtio_gpu_find_resource(g, VAR_4->resource_id); if (!VAR_3) { return -EINVAL; VAR_4->ds = qemu_create_displaysurface_pixman(VAR_3->image); if (!VAR_4->ds) { return -EINVAL; dpy_gfx_replace_surface(VAR_4->con, VAR_4->ds); dpy_gfx_update(VAR_4->con, 0, 0, VAR_4->width, VAR_4->height); update_cursor(g, &VAR_4->cursor); VAR_3->scanout_bitmask |= (1 << VAR_5); return 0;
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{", "VirtIOGPU *g = VAR_1;", "struct virtio_gpu_simple_resource *VAR_3;", "struct virtio_gpu_scanout *VAR_4;", "uint32_t resource_id, pformat;", "int VAR_5;", "g->hostmem = 0;", "resource_id = qemu_get_be32(VAR_0);", "while (resource_id != 0) {", "VAR_3 = g_new0(struct virtio_gpu_simple_resource, 1);", "VAR_3->resource_id = resource_id;", "VAR_3->width = qemu_get_be32(VAR_0);", "VAR_3->height = qemu_get_be32(VAR_0);", "VAR_3->format = qemu_get_be32(VAR_0);", "VAR_3->iov_cnt = qemu_get_be32(VAR_0);", "pformat = get_pixman_format(VAR_3->format);", "if (!pformat) {", "return -EINVAL;", "VAR_3->image = pixman_image_create_bits(pformat,\nVAR_3->width, VAR_3->height,\nNULL, 0);", "if (!VAR_3->image) {", "return -EINVAL;", "VAR_3->hostmem = PIXMAN_FORMAT_BPP(pformat) * VAR_3->width * VAR_3->height;", "VAR_3->addrs = g_new(uint64_t, VAR_3->iov_cnt);", "VAR_3->iov = g_new(struct iovec, VAR_3->iov_cnt);", "for (VAR_5 = 0; VAR_5 < VAR_3->iov_cnt; VAR_5++) {", "VAR_3->addrs[VAR_5] = qemu_get_be64(VAR_0);", "VAR_3->iov[VAR_5].iov_len = qemu_get_be32(VAR_0);", "qemu_get_buffer(VAR_0, (void *)pixman_image_get_data(VAR_3->image),\npixman_image_get_stride(VAR_3->image) * VAR_3->height);", "for (VAR_5 = 0; VAR_5 < VAR_3->iov_cnt; VAR_5++) {", "hwaddr len = VAR_3->iov[VAR_5].iov_len;", "VAR_3->iov[VAR_5].iov_base =\ncpu_physical_memory_map(VAR_3->addrs[VAR_5], &len, 1);", "if (!VAR_3->iov[VAR_5].iov_base || len != VAR_3->iov[VAR_5].iov_len) {", "return -EINVAL;", "QTAILQ_INSERT_HEAD(&g->reslist, VAR_3, next);", "g->hostmem += VAR_3->hostmem;", "resource_id = qemu_get_be32(VAR_0);", "vmstate_load_state(VAR_0, &vmstate_virtio_gpu_scanouts, g, 1);", "for (VAR_5 = 0; VAR_5 < g->conf.max_outputs; VAR_5++) {", "VAR_4 = &g->VAR_4[VAR_5];", "if (!VAR_4->resource_id) {", "continue;", "VAR_3 = virtio_gpu_find_resource(g, VAR_4->resource_id);", "if (!VAR_3) {", "return -EINVAL;", "VAR_4->ds = qemu_create_displaysurface_pixman(VAR_3->image);", "if (!VAR_4->ds) {", "return -EINVAL;", "dpy_gfx_replace_surface(VAR_4->con, VAR_4->ds);", "dpy_gfx_update(VAR_4->con, 0, 0, VAR_4->width, VAR_4->height);", "update_cursor(g, &VAR_4->cursor);", "VAR_3->scanout_bitmask |= (1 << VAR_5);", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 41 ], [ 43 ], [ 46 ], [ 49, 51, 53 ], [ 55 ], [ 58 ], [ 63 ], [ 67 ], [ 69 ], [ 75 ], [ 77 ], [ 79 ], [ 82, 84 ], [ 90 ], [ 92 ], [ 94, 96 ], [ 98 ], [ 110 ], [ 116 ], [ 118 ], [ 122 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 140 ], [ 142 ], [ 144 ], [ 147 ], [ 149 ], [ 151 ], [ 156 ], [ 158 ], [ 160 ], [ 162 ], [ 167 ] ]
26
static av_cold int iv_alloc_frames(Indeo3DecodeContext *s) { int luma_width = (s->width + 3) & ~3, luma_height = (s->height + 3) & ~3, chroma_width = ((luma_width >> 2) + 3) & ~3, chroma_height = ((luma_height >> 2) + 3) & ~3, luma_pixels = luma_width * luma_height, chroma_pixels = chroma_width * chroma_height, i; unsigned int bufsize = luma_pixels * 2 + luma_width * 3 + (chroma_pixels + chroma_width) * 4; if(!(s->buf = av_malloc(bufsize))) return AVERROR(ENOMEM); s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width; s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height; s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width; s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height; s->iv_frame[0].Ybuf = s->buf + luma_width; i = luma_pixels + luma_width * 2; s->iv_frame[1].Ybuf = s->buf + i; i += (luma_pixels + luma_width); s->iv_frame[0].Ubuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[1].Ubuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[0].Vbuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[1].Vbuf = s->buf + i; for(i = 1; i <= luma_width; i++) s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] = s->iv_frame[0].Ubuf[-i] = 0x80; for(i = 1; i <= chroma_width; i++) { s->iv_frame[1].Ubuf[-i] = 0x80; s->iv_frame[0].Vbuf[-i] = 0x80; s->iv_frame[1].Vbuf[-i] = 0x80; s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80; } return 0; }
true
FFmpeg
16c831851384ab59e73579fdd9913fbff3c0284a
static av_cold int iv_alloc_frames(Indeo3DecodeContext *s) { int luma_width = (s->width + 3) & ~3, luma_height = (s->height + 3) & ~3, chroma_width = ((luma_width >> 2) + 3) & ~3, chroma_height = ((luma_height >> 2) + 3) & ~3, luma_pixels = luma_width * luma_height, chroma_pixels = chroma_width * chroma_height, i; unsigned int bufsize = luma_pixels * 2 + luma_width * 3 + (chroma_pixels + chroma_width) * 4; if(!(s->buf = av_malloc(bufsize))) return AVERROR(ENOMEM); s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width; s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height; s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width; s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height; s->iv_frame[0].Ybuf = s->buf + luma_width; i = luma_pixels + luma_width * 2; s->iv_frame[1].Ybuf = s->buf + i; i += (luma_pixels + luma_width); s->iv_frame[0].Ubuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[1].Ubuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[0].Vbuf = s->buf + i; i += (chroma_pixels + chroma_width); s->iv_frame[1].Vbuf = s->buf + i; for(i = 1; i <= luma_width; i++) s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] = s->iv_frame[0].Ubuf[-i] = 0x80; for(i = 1; i <= chroma_width; i++) { s->iv_frame[1].Ubuf[-i] = 0x80; s->iv_frame[0].Vbuf[-i] = 0x80; s->iv_frame[1].Vbuf[-i] = 0x80; s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80; } return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(Indeo3DecodeContext *s) { int VAR_0 = (s->width + 3) & ~3, VAR_1 = (s->height + 3) & ~3, VAR_2 = ((VAR_0 >> 2) + 3) & ~3, VAR_3 = ((VAR_1 >> 2) + 3) & ~3, VAR_4 = VAR_0 * VAR_1, VAR_5 = VAR_2 * VAR_3, VAR_6; unsigned int VAR_7 = VAR_4 * 2 + VAR_0 * 3 + (VAR_5 + VAR_2) * 4; if(!(s->buf = av_malloc(VAR_7))) return AVERROR(ENOMEM); s->iv_frame[0].y_w = s->iv_frame[1].y_w = VAR_0; s->iv_frame[0].y_h = s->iv_frame[1].y_h = VAR_1; s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = VAR_2; s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = VAR_3; s->iv_frame[0].Ybuf = s->buf + VAR_0; VAR_6 = VAR_4 + VAR_0 * 2; s->iv_frame[1].Ybuf = s->buf + VAR_6; VAR_6 += (VAR_4 + VAR_0); s->iv_frame[0].Ubuf = s->buf + VAR_6; VAR_6 += (VAR_5 + VAR_2); s->iv_frame[1].Ubuf = s->buf + VAR_6; VAR_6 += (VAR_5 + VAR_2); s->iv_frame[0].Vbuf = s->buf + VAR_6; VAR_6 += (VAR_5 + VAR_2); s->iv_frame[1].Vbuf = s->buf + VAR_6; for(VAR_6 = 1; VAR_6 <= VAR_0; VAR_6++) s->iv_frame[0].Ybuf[-VAR_6] = s->iv_frame[1].Ybuf[-VAR_6] = s->iv_frame[0].Ubuf[-VAR_6] = 0x80; for(VAR_6 = 1; VAR_6 <= VAR_2; VAR_6++) { s->iv_frame[1].Ubuf[-VAR_6] = 0x80; s->iv_frame[0].Vbuf[-VAR_6] = 0x80; s->iv_frame[1].Vbuf[-VAR_6] = 0x80; s->iv_frame[1].Vbuf[VAR_5+VAR_6-1] = 0x80; } return 0; }
[ "static av_cold int FUNC_0(Indeo3DecodeContext *s)\n{", "int VAR_0 = (s->width + 3) & ~3,\nVAR_1 = (s->height + 3) & ~3,\nVAR_2 = ((VAR_0 >> 2) + 3) & ~3,\nVAR_3 = ((VAR_1 >> 2) + 3) & ~3,\nVAR_4 = VAR_0 * VAR_1,\nVAR_5 = VAR_2 * VAR_3,\nVAR_6;", "unsigned int VAR_7 = VAR_4 * 2 + VAR_0 * 3 +\n(VAR_5 + VAR_2) * 4;", "if(!(s->buf = av_malloc(VAR_7)))\nreturn AVERROR(ENOMEM);", "s->iv_frame[0].y_w = s->iv_frame[1].y_w = VAR_0;", "s->iv_frame[0].y_h = s->iv_frame[1].y_h = VAR_1;", "s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = VAR_2;", "s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = VAR_3;", "s->iv_frame[0].Ybuf = s->buf + VAR_0;", "VAR_6 = VAR_4 + VAR_0 * 2;", "s->iv_frame[1].Ybuf = s->buf + VAR_6;", "VAR_6 += (VAR_4 + VAR_0);", "s->iv_frame[0].Ubuf = s->buf + VAR_6;", "VAR_6 += (VAR_5 + VAR_2);", "s->iv_frame[1].Ubuf = s->buf + VAR_6;", "VAR_6 += (VAR_5 + VAR_2);", "s->iv_frame[0].Vbuf = s->buf + VAR_6;", "VAR_6 += (VAR_5 + VAR_2);", "s->iv_frame[1].Vbuf = s->buf + VAR_6;", "for(VAR_6 = 1; VAR_6 <= VAR_0; VAR_6++)", "s->iv_frame[0].Ybuf[-VAR_6] = s->iv_frame[1].Ybuf[-VAR_6] =\ns->iv_frame[0].Ubuf[-VAR_6] = 0x80;", "for(VAR_6 = 1; VAR_6 <= VAR_2; VAR_6++) {", "s->iv_frame[1].Ubuf[-VAR_6] = 0x80;", "s->iv_frame[0].Vbuf[-VAR_6] = 0x80;", "s->iv_frame[1].Vbuf[-VAR_6] = 0x80;", "s->iv_frame[1].Vbuf[VAR_5+VAR_6-1] = 0x80;", "}", "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 ]
[ [ 1, 3 ], [ 5, 7, 9, 11, 13, 15, 17 ], [ 19, 21 ], [ 26, 28 ], [ 30 ], [ 32 ], [ 34 ], [ 36 ], [ 40 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 50 ], [ 52 ], [ 54 ], [ 56 ], [ 58 ], [ 60 ], [ 64 ], [ 66, 68 ], [ 72 ], [ 74 ], [ 76 ], [ 78 ], [ 80 ], [ 82 ], [ 86 ], [ 88 ] ]
27
static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t pos = avio_tell(pb); int ret; avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "minf"); if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) mov_write_vmhd_tag(pb); else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) mov_write_smhd_tag(pb); else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) { mov_write_gmhd_tag(pb, track); } else { mov_write_nmhd_tag(pb); } } else if (track->tag == MKTAG('r','t','p',' ')) { mov_write_hmhd_tag(pb); } else if (track->tag == MKTAG('t','m','c','d')) { mov_write_gmhd_tag(pb, track); } if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */ mov_write_hdlr_tag(pb, NULL); mov_write_dinf_tag(pb); if ((ret = mov_write_stbl_tag(pb, mov, track)) < 0) return ret; return update_size(pb, pos); }
false
FFmpeg
b4dcd351ec50caaa484bc5c66b4a8d5557a0f1ea
static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t pos = avio_tell(pb); int ret; avio_wb32(pb, 0); ffio_wfourcc(pb, "minf"); if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) mov_write_vmhd_tag(pb); else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) mov_write_smhd_tag(pb); else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) { mov_write_gmhd_tag(pb, track); } else { mov_write_nmhd_tag(pb); } } else if (track->tag == MKTAG('r','t','p',' ')) { mov_write_hmhd_tag(pb); } else if (track->tag == MKTAG('t','m','c','d')) { mov_write_gmhd_tag(pb, track); } if (track->mode == MODE_MOV) mov_write_hdlr_tag(pb, NULL); mov_write_dinf_tag(pb); if ((ret = mov_write_stbl_tag(pb, mov, track)) < 0) return ret; return update_size(pb, pos); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVIOContext *VAR_0, MOVMuxContext *VAR_1, MOVTrack *VAR_2) { int64_t pos = avio_tell(VAR_0); int VAR_3; avio_wb32(VAR_0, 0); ffio_wfourcc(VAR_0, "minf"); if (VAR_2->enc->codec_type == AVMEDIA_TYPE_VIDEO) mov_write_vmhd_tag(VAR_0); else if (VAR_2->enc->codec_type == AVMEDIA_TYPE_AUDIO) mov_write_smhd_tag(VAR_0); else if (VAR_2->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (VAR_2->tag == MKTAG('t','e','x','t') || is_clcp_track(VAR_2)) { mov_write_gmhd_tag(VAR_0, VAR_2); } else { mov_write_nmhd_tag(VAR_0); } } else if (VAR_2->tag == MKTAG('r','t','p',' ')) { mov_write_hmhd_tag(VAR_0); } else if (VAR_2->tag == MKTAG('t','m','c','d')) { mov_write_gmhd_tag(VAR_0, VAR_2); } if (VAR_2->mode == MODE_MOV) mov_write_hdlr_tag(VAR_0, NULL); mov_write_dinf_tag(VAR_0); if ((VAR_3 = mov_write_stbl_tag(VAR_0, VAR_1, VAR_2)) < 0) return VAR_3; return update_size(VAR_0, pos); }
[ "static int FUNC_0(AVIOContext *VAR_0, MOVMuxContext *VAR_1, MOVTrack *VAR_2)\n{", "int64_t pos = avio_tell(VAR_0);", "int VAR_3;", "avio_wb32(VAR_0, 0);", "ffio_wfourcc(VAR_0, \"minf\");", "if (VAR_2->enc->codec_type == AVMEDIA_TYPE_VIDEO)\nmov_write_vmhd_tag(VAR_0);", "else if (VAR_2->enc->codec_type == AVMEDIA_TYPE_AUDIO)\nmov_write_smhd_tag(VAR_0);", "else if (VAR_2->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {", "if (VAR_2->tag == MKTAG('t','e','x','t') || is_clcp_track(VAR_2)) {", "mov_write_gmhd_tag(VAR_0, VAR_2);", "} else {", "mov_write_nmhd_tag(VAR_0);", "}", "} else if (VAR_2->tag == MKTAG('r','t','p',' ')) {", "mov_write_hmhd_tag(VAR_0);", "} else if (VAR_2->tag == MKTAG('t','m','c','d')) {", "mov_write_gmhd_tag(VAR_0, VAR_2);", "}", "if (VAR_2->mode == MODE_MOV)\nmov_write_hdlr_tag(VAR_0, NULL);", "mov_write_dinf_tag(VAR_0);", "if ((VAR_3 = mov_write_stbl_tag(VAR_0, VAR_1, VAR_2)) < 0)\nreturn VAR_3;", "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 ]
[ [ 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 ] ]
28
int av_packet_ref(AVPacket *dst, AVPacket *src) { int ret; ret = av_packet_copy_props(dst, src); if (ret < 0) return ret; if (!src->buf) { ret = packet_alloc(&dst->buf, src->size); if (ret < 0) goto fail; memcpy(dst->buf->data, src->data, src->size); } else dst->buf = av_buffer_ref(src->buf); dst->size = src->size; dst->data = dst->buf->data; return 0; fail: av_packet_free_side_data(dst); return ret; }
false
FFmpeg
fe0f4e56577a2dbd373bb50b0ae2d49e69d822fc
int av_packet_ref(AVPacket *dst, AVPacket *src) { int ret; ret = av_packet_copy_props(dst, src); if (ret < 0) return ret; if (!src->buf) { ret = packet_alloc(&dst->buf, src->size); if (ret < 0) goto fail; memcpy(dst->buf->data, src->data, src->size); } else dst->buf = av_buffer_ref(src->buf); dst->size = src->size; dst->data = dst->buf->data; return 0; fail: av_packet_free_side_data(dst); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(AVPacket *VAR_0, AVPacket *VAR_1) { int VAR_2; VAR_2 = av_packet_copy_props(VAR_0, VAR_1); if (VAR_2 < 0) return VAR_2; if (!VAR_1->buf) { VAR_2 = packet_alloc(&VAR_0->buf, VAR_1->size); if (VAR_2 < 0) goto fail; memcpy(VAR_0->buf->data, VAR_1->data, VAR_1->size); } else VAR_0->buf = av_buffer_ref(VAR_1->buf); VAR_0->size = VAR_1->size; VAR_0->data = VAR_0->buf->data; return 0; fail: av_packet_free_side_data(VAR_0); return VAR_2; }
[ "int FUNC_0(AVPacket *VAR_0, AVPacket *VAR_1)\n{", "int VAR_2;", "VAR_2 = av_packet_copy_props(VAR_0, VAR_1);", "if (VAR_2 < 0)\nreturn VAR_2;", "if (!VAR_1->buf) {", "VAR_2 = packet_alloc(&VAR_0->buf, VAR_1->size);", "if (VAR_2 < 0)\ngoto fail;", "memcpy(VAR_0->buf->data, VAR_1->data, VAR_1->size);", "} else", "VAR_0->buf = av_buffer_ref(VAR_1->buf);", "VAR_0->size = VAR_1->size;", "VAR_0->data = VAR_0->buf->data;", "return 0;", "fail:\nav_packet_free_side_data(VAR_0);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ] ]
29
av_cold void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int bit_exact) { #if HAVE_ALTIVEC if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; fdsp->vector_fmul = ff_vector_fmul_altivec; fdsp->vector_fmul_add = ff_vector_fmul_add_altivec; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_altivec; if (!bit_exact) { fdsp->vector_fmul_window = ff_vector_fmul_window_altivec; } #endif }
false
FFmpeg
f61bece684d9685b07895508e6c1c733b5564ccf
av_cold void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int bit_exact) { #if HAVE_ALTIVEC if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; fdsp->vector_fmul = ff_vector_fmul_altivec; fdsp->vector_fmul_add = ff_vector_fmul_add_altivec; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_altivec; if (!bit_exact) { fdsp->vector_fmul_window = ff_vector_fmul_window_altivec; } #endif }
{ "code": [], "line_no": [] }
av_cold void FUNC_0(AVFloatDSPContext *fdsp, int bit_exact) { #if HAVE_ALTIVEC if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; fdsp->vector_fmul = ff_vector_fmul_altivec; fdsp->vector_fmul_add = ff_vector_fmul_add_altivec; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_altivec; if (!bit_exact) { fdsp->vector_fmul_window = ff_vector_fmul_window_altivec; } #endif }
[ "av_cold void FUNC_0(AVFloatDSPContext *fdsp, int bit_exact)\n{", "#if HAVE_ALTIVEC\nif (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))\nreturn;", "fdsp->vector_fmul = ff_vector_fmul_altivec;", "fdsp->vector_fmul_add = ff_vector_fmul_add_altivec;", "fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_altivec;", "if (!bit_exact) {", "fdsp->vector_fmul_window = ff_vector_fmul_window_altivec;", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7, 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ] ]
30
static int config_props(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; LutContext *lut = ctx->priv; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format]; int min[4], max[4]; int val, comp, ret; lut->hsub = desc->log2_chroma_w; lut->vsub = desc->log2_chroma_h; lut->var_values[VAR_W] = inlink->w; lut->var_values[VAR_H] = inlink->h; switch (inlink->format) { case PIX_FMT_YUV410P: case PIX_FMT_YUV411P: case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: case PIX_FMT_YUV440P: case PIX_FMT_YUV444P: case PIX_FMT_YUVA420P: min[Y] = min[U] = min[V] = 16; max[Y] = 235; max[U] = max[V] = 240; min[A] = 0; max[A] = 255; break; default: min[0] = min[1] = min[2] = min[3] = 0; max[0] = max[1] = max[2] = max[3] = 255; } lut->is_yuv = lut->is_rgb = 0; if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; if (lut->is_rgb) { switch (inlink->format) { case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break; case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break; case PIX_FMT_RGBA: case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break; } lut->step = av_get_bits_per_pixel(desc) >> 3; } for (comp = 0; comp < desc->nb_components; comp++) { double res; /* create the parsed expression */ ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp], var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Error when parsing the expression '%s' for the component %d.\n", lut->comp_expr_str[comp], comp); return AVERROR(EINVAL); } /* compute the lut */ lut->var_values[VAR_MAXVAL] = max[comp]; lut->var_values[VAR_MINVAL] = min[comp]; for (val = 0; val < 256; val++) { lut->var_values[VAR_VAL] = val; lut->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]); lut->var_values[VAR_NEGVAL] = av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL], min[comp], max[comp]); res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut); if (isnan(res)) { av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for the value %d for the component #%d.\n", lut->comp_expr_str[comp], val, comp); return AVERROR(EINVAL); } lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]); } } return 0; }
false
FFmpeg
38477e1981a7729b02d9a2f45142c53dc78625fe
static int config_props(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; LutContext *lut = ctx->priv; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format]; int min[4], max[4]; int val, comp, ret; lut->hsub = desc->log2_chroma_w; lut->vsub = desc->log2_chroma_h; lut->var_values[VAR_W] = inlink->w; lut->var_values[VAR_H] = inlink->h; switch (inlink->format) { case PIX_FMT_YUV410P: case PIX_FMT_YUV411P: case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: case PIX_FMT_YUV440P: case PIX_FMT_YUV444P: case PIX_FMT_YUVA420P: min[Y] = min[U] = min[V] = 16; max[Y] = 235; max[U] = max[V] = 240; min[A] = 0; max[A] = 255; break; default: min[0] = min[1] = min[2] = min[3] = 0; max[0] = max[1] = max[2] = max[3] = 255; } lut->is_yuv = lut->is_rgb = 0; if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; if (lut->is_rgb) { switch (inlink->format) { case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break; case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break; case PIX_FMT_RGBA: case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break; } lut->step = av_get_bits_per_pixel(desc) >> 3; } for (comp = 0; comp < desc->nb_components; comp++) { double res; ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp], var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Error when parsing the expression '%s' for the component %d.\n", lut->comp_expr_str[comp], comp); return AVERROR(EINVAL); } lut->var_values[VAR_MAXVAL] = max[comp]; lut->var_values[VAR_MINVAL] = min[comp]; for (val = 0; val < 256; val++) { lut->var_values[VAR_VAL] = val; lut->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]); lut->var_values[VAR_NEGVAL] = av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL], min[comp], max[comp]); res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut); if (isnan(res)) { av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for the value %d for the component #%d.\n", lut->comp_expr_str[comp], val, comp); return AVERROR(EINVAL); } lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]); } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFilterLink *VAR_0) { AVFilterContext *ctx = VAR_0->dst; LutContext *lut = ctx->priv; const AVPixFmtDescriptor *VAR_1 = &av_pix_fmt_descriptors[VAR_0->format]; int VAR_2[4], VAR_3[4]; int VAR_4, VAR_5, VAR_6; lut->hsub = VAR_1->log2_chroma_w; lut->vsub = VAR_1->log2_chroma_h; lut->var_values[VAR_W] = VAR_0->w; lut->var_values[VAR_H] = VAR_0->h; switch (VAR_0->format) { case PIX_FMT_YUV410P: case PIX_FMT_YUV411P: case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: case PIX_FMT_YUV440P: case PIX_FMT_YUV444P: case PIX_FMT_YUVA420P: VAR_2[Y] = VAR_2[U] = VAR_2[V] = 16; VAR_3[Y] = 235; VAR_3[U] = VAR_3[V] = 240; VAR_2[A] = 0; VAR_3[A] = 255; break; default: VAR_2[0] = VAR_2[1] = VAR_2[2] = VAR_2[3] = 0; VAR_3[0] = VAR_3[1] = VAR_3[2] = VAR_3[3] = 255; } lut->is_yuv = lut->is_rgb = 0; if (ff_fmt_is_in(VAR_0->format, yuv_pix_fmts)) lut->is_yuv = 1; else if (ff_fmt_is_in(VAR_0->format, rgb_pix_fmts)) lut->is_rgb = 1; if (lut->is_rgb) { switch (VAR_0->format) { case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break; case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break; case PIX_FMT_RGBA: case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break; } lut->step = av_get_bits_per_pixel(VAR_1) >> 3; } for (VAR_5 = 0; VAR_5 < VAR_1->nb_components; VAR_5++) { double res; VAR_6 = av_expr_parse(&lut->comp_expr[VAR_5], lut->comp_expr_str[VAR_5], var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx); if (VAR_6 < 0) { av_log(ctx, AV_LOG_ERROR, "Error when parsing the expression '%s' for the component %d.\n", lut->comp_expr_str[VAR_5], VAR_5); return AVERROR(EINVAL); } lut->var_values[VAR_MAXVAL] = VAR_3[VAR_5]; lut->var_values[VAR_MINVAL] = VAR_2[VAR_5]; for (VAR_4 = 0; VAR_4 < 256; VAR_4++) { lut->var_values[VAR_VAL] = VAR_4; lut->var_values[VAR_CLIPVAL] = av_clip(VAR_4, VAR_2[VAR_5], VAR_3[VAR_5]); lut->var_values[VAR_NEGVAL] = av_clip(VAR_2[VAR_5] + VAR_3[VAR_5] - lut->var_values[VAR_VAL], VAR_2[VAR_5], VAR_3[VAR_5]); res = av_expr_eval(lut->comp_expr[VAR_5], lut->var_values, lut); if (isnan(res)) { av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for the value %d for the component #%d.\n", lut->comp_expr_str[VAR_5], VAR_4, VAR_5); return AVERROR(EINVAL); } lut->lut[VAR_5][VAR_4] = av_clip((int)res, VAR_2[VAR_5], VAR_3[VAR_5]); av_log(ctx, AV_LOG_DEBUG, "VAR_4[%d][%d] = %d\n", VAR_5, VAR_4, lut->lut[VAR_5][VAR_4]); } } return 0; }
[ "static int FUNC_0(AVFilterLink *VAR_0)\n{", "AVFilterContext *ctx = VAR_0->dst;", "LutContext *lut = ctx->priv;", "const AVPixFmtDescriptor *VAR_1 = &av_pix_fmt_descriptors[VAR_0->format];", "int VAR_2[4], VAR_3[4];", "int VAR_4, VAR_5, VAR_6;", "lut->hsub = VAR_1->log2_chroma_w;", "lut->vsub = VAR_1->log2_chroma_h;", "lut->var_values[VAR_W] = VAR_0->w;", "lut->var_values[VAR_H] = VAR_0->h;", "switch (VAR_0->format) {", "case PIX_FMT_YUV410P:\ncase PIX_FMT_YUV411P:\ncase PIX_FMT_YUV420P:\ncase PIX_FMT_YUV422P:\ncase PIX_FMT_YUV440P:\ncase PIX_FMT_YUV444P:\ncase PIX_FMT_YUVA420P:\nVAR_2[Y] = VAR_2[U] = VAR_2[V] = 16;", "VAR_3[Y] = 235;", "VAR_3[U] = VAR_3[V] = 240;", "VAR_2[A] = 0; VAR_3[A] = 255;", "break;", "default:\nVAR_2[0] = VAR_2[1] = VAR_2[2] = VAR_2[3] = 0;", "VAR_3[0] = VAR_3[1] = VAR_3[2] = VAR_3[3] = 255;", "}", "lut->is_yuv = lut->is_rgb = 0;", "if (ff_fmt_is_in(VAR_0->format, yuv_pix_fmts)) lut->is_yuv = 1;", "else if (ff_fmt_is_in(VAR_0->format, rgb_pix_fmts)) lut->is_rgb = 1;", "if (lut->is_rgb) {", "switch (VAR_0->format) {", "case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break;", "case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break;", "case PIX_FMT_RGBA:\ncase PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break;", "case PIX_FMT_BGRA:\ncase PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break;", "}", "lut->step = av_get_bits_per_pixel(VAR_1) >> 3;", "}", "for (VAR_5 = 0; VAR_5 < VAR_1->nb_components; VAR_5++) {", "double res;", "VAR_6 = av_expr_parse(&lut->comp_expr[VAR_5], lut->comp_expr_str[VAR_5],\nvar_names, funcs1_names, funcs1, NULL, NULL, 0, ctx);", "if (VAR_6 < 0) {", "av_log(ctx, AV_LOG_ERROR,\n\"Error when parsing the expression '%s' for the component %d.\\n\",\nlut->comp_expr_str[VAR_5], VAR_5);", "return AVERROR(EINVAL);", "}", "lut->var_values[VAR_MAXVAL] = VAR_3[VAR_5];", "lut->var_values[VAR_MINVAL] = VAR_2[VAR_5];", "for (VAR_4 = 0; VAR_4 < 256; VAR_4++) {", "lut->var_values[VAR_VAL] = VAR_4;", "lut->var_values[VAR_CLIPVAL] = av_clip(VAR_4, VAR_2[VAR_5], VAR_3[VAR_5]);", "lut->var_values[VAR_NEGVAL] =\nav_clip(VAR_2[VAR_5] + VAR_3[VAR_5] - lut->var_values[VAR_VAL],\nVAR_2[VAR_5], VAR_3[VAR_5]);", "res = av_expr_eval(lut->comp_expr[VAR_5], lut->var_values, lut);", "if (isnan(res)) {", "av_log(ctx, AV_LOG_ERROR,\n\"Error when evaluating the expression '%s' for the value %d for the component #%d.\\n\",\nlut->comp_expr_str[VAR_5], VAR_4, VAR_5);", "return AVERROR(EINVAL);", "}", "lut->lut[VAR_5][VAR_4] = av_clip((int)res, VAR_2[VAR_5], VAR_3[VAR_5]);", "av_log(ctx, AV_LOG_DEBUG, \"VAR_4[%d][%d] = %d\\n\", VAR_5, VAR_4, lut->lut[VAR_5][VAR_4]);", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31, 33, 35, 37, 39, 41, 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 105, 107 ], [ 109 ], [ 111, 113, 115 ], [ 117 ], [ 119 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139, 141 ], [ 145 ], [ 147 ], [ 149, 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ] ]
31
static av_cold int rpza_decode_init(AVCodecContext *avctx) { RpzaContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_RGB555; s->frame.data[0] = NULL; return 0; }
false
FFmpeg
3b199d29cd597a3518136d78860e172060b9e83d
static av_cold int rpza_decode_init(AVCodecContext *avctx) { RpzaContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_RGB555; s->frame.data[0] = NULL; return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { RpzaContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_RGB555; s->frame.data[0] = NULL; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "RpzaContext *s = avctx->priv_data;", "s->avctx = avctx;", "avctx->pix_fmt = AV_PIX_FMT_RGB555;", "s->frame.data[0] = NULL;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ] ]
32
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2) { int s_index; int i; int last_pos, bits_left; VLC *vlc; int end_pos = FFMIN(end_pos2, s->gb.size_in_bits); /* low frequencies (called big values) */ s_index = 0; for (i = 0; i < 3; i++) { int j, k, l, linbits; j = g->region_size[i]; if (j == 0) continue; /* select vlc table */ k = g->table_select[i]; l = mpa_huff_data[k][0]; linbits = mpa_huff_data[k][1]; vlc = &huff_vlc[l]; if (!l) { memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j); s_index += 2 * j; continue; } /* read huffcode and compute each couple */ for (; j > 0; j--) { int exponent, x, y; int v; int pos = get_bits_count(&s->gb); if (pos >= end_pos){ switch_buffer(s, &pos, &end_pos, &end_pos2); if (pos >= end_pos) break; } y = get_vlc2(&s->gb, vlc->table, 7, 3); if (!y) { g->sb_hybrid[s_index ] = g->sb_hybrid[s_index+1] = 0; s_index += 2; continue; } exponent= exponents[s_index]; ff_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", i, g->region_size[i] - j, x, y, exponent); if (y & 16) { x = y >> 5; y = y & 0x0f; if (x < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index, RENAME(expval_table)[exponent] + x) } else { x += get_bitsz(&s->gb, linbits); v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index] = v; } if (y < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index + 1, RENAME(expval_table)[exponent] + y) } else { y += get_bitsz(&s->gb, linbits); v = l3_unscale(y, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+1] = v; } } else { x = y >> 5; y = y & 0x0f; x += y; if (x < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index + !!y, RENAME(expval_table)[exponent] + x) } else { x += get_bitsz(&s->gb, linbits); v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+!!y] = v; } g->sb_hybrid[s_index + !y] = 0; } s_index += 2; } } /* high frequencies */ vlc = &huff_quad_vlc[g->count1table_select]; last_pos = 0; while (s_index <= 572) { int pos, code; pos = get_bits_count(&s->gb); if (pos >= end_pos) { if (pos > end_pos2 && last_pos) { /* some encoders generate an incorrect size for this part. We must go back into the data */ s_index -= 4; skip_bits_long(&s->gb, last_pos - pos); av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); if(s->err_recognition & AV_EF_BITSTREAM) s_index=0; break; } switch_buffer(s, &pos, &end_pos, &end_pos2); if (pos >= end_pos) break; } last_pos = pos; code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); ff_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code); g->sb_hybrid[s_index+0] = g->sb_hybrid[s_index+1] = g->sb_hybrid[s_index+2] = g->sb_hybrid[s_index+3] = 0; while (code) { static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 }; int v; int pos = s_index + idxtab[code]; code ^= 8 >> idxtab[code]; READ_FLIP_SIGN(g->sb_hybrid + pos, RENAME(exp_table)+exponents[pos]) } s_index += 4; } /* skip extension bits */ bits_left = end_pos2 - get_bits_count(&s->gb); if (bits_left < 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index=0; } else if (bits_left > 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index = 0; } memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * (576 - s_index)); skip_bits_long(&s->gb, bits_left); i = get_bits_count(&s->gb); switch_buffer(s, &i, &end_pos, &end_pos2); return 0; }
true
FFmpeg
74b1bf632f125a795e66e5fd0a060b9c7c55b7a3
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2) { int s_index; int i; int last_pos, bits_left; VLC *vlc; int end_pos = FFMIN(end_pos2, s->gb.size_in_bits); s_index = 0; for (i = 0; i < 3; i++) { int j, k, l, linbits; j = g->region_size[i]; if (j == 0) continue; k = g->table_select[i]; l = mpa_huff_data[k][0]; linbits = mpa_huff_data[k][1]; vlc = &huff_vlc[l]; if (!l) { memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j); s_index += 2 * j; continue; } for (; j > 0; j--) { int exponent, x, y; int v; int pos = get_bits_count(&s->gb); if (pos >= end_pos){ switch_buffer(s, &pos, &end_pos, &end_pos2); if (pos >= end_pos) break; } y = get_vlc2(&s->gb, vlc->table, 7, 3); if (!y) { g->sb_hybrid[s_index ] = g->sb_hybrid[s_index+1] = 0; s_index += 2; continue; } exponent= exponents[s_index]; ff_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", i, g->region_size[i] - j, x, y, exponent); if (y & 16) { x = y >> 5; y = y & 0x0f; if (x < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index, RENAME(expval_table)[exponent] + x) } else { x += get_bitsz(&s->gb, linbits); v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index] = v; } if (y < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index + 1, RENAME(expval_table)[exponent] + y) } else { y += get_bitsz(&s->gb, linbits); v = l3_unscale(y, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+1] = v; } } else { x = y >> 5; y = y & 0x0f; x += y; if (x < 15) { READ_FLIP_SIGN(g->sb_hybrid + s_index + !!y, RENAME(expval_table)[exponent] + x) } else { x += get_bitsz(&s->gb, linbits); v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+!!y] = v; } g->sb_hybrid[s_index + !y] = 0; } s_index += 2; } } vlc = &huff_quad_vlc[g->count1table_select]; last_pos = 0; while (s_index <= 572) { int pos, code; pos = get_bits_count(&s->gb); if (pos >= end_pos) { if (pos > end_pos2 && last_pos) { s_index -= 4; skip_bits_long(&s->gb, last_pos - pos); av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); if(s->err_recognition & AV_EF_BITSTREAM) s_index=0; break; } switch_buffer(s, &pos, &end_pos, &end_pos2); if (pos >= end_pos) break; } last_pos = pos; code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); ff_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code); g->sb_hybrid[s_index+0] = g->sb_hybrid[s_index+1] = g->sb_hybrid[s_index+2] = g->sb_hybrid[s_index+3] = 0; while (code) { static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 }; int v; int pos = s_index + idxtab[code]; code ^= 8 >> idxtab[code]; READ_FLIP_SIGN(g->sb_hybrid + pos, RENAME(exp_table)+exponents[pos]) } s_index += 4; } bits_left = end_pos2 - get_bits_count(&s->gb); if (bits_left < 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index=0; } else if (bits_left > 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index = 0; } memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * (576 - s_index)); skip_bits_long(&s->gb, bits_left); i = get_bits_count(&s->gb); switch_buffer(s, &i, &end_pos, &end_pos2); return 0; }
{ "code": [ " int end_pos = FFMIN(end_pos2, s->gb.size_in_bits);" ], "line_no": [ 15 ] }
static int FUNC_0(MPADecodeContext *VAR_0, GranuleDef *VAR_1, int16_t *VAR_2, int VAR_3) { int VAR_4; int VAR_5; int VAR_6, VAR_7; VLC *vlc; int VAR_8 = FFMIN(VAR_3, VAR_0->gb.size_in_bits); VAR_4 = 0; for (VAR_5 = 0; VAR_5 < 3; VAR_5++) { int VAR_9, VAR_10, VAR_11, VAR_12; VAR_9 = VAR_1->region_size[VAR_5]; if (VAR_9 == 0) continue; VAR_10 = VAR_1->table_select[VAR_5]; VAR_11 = mpa_huff_data[VAR_10][0]; VAR_12 = mpa_huff_data[VAR_10][1]; vlc = &huff_vlc[VAR_11]; if (!VAR_11) { memset(&VAR_1->sb_hybrid[VAR_4], 0, sizeof(*VAR_1->sb_hybrid) * 2 * VAR_9); VAR_4 += 2 * VAR_9; continue; } for (; VAR_9 > 0; VAR_9--) { int VAR_13, VAR_14, VAR_15; int VAR_20; int VAR_20 = get_bits_count(&VAR_0->gb); if (VAR_20 >= VAR_8){ switch_buffer(VAR_0, &VAR_20, &VAR_8, &VAR_3); if (VAR_20 >= VAR_8) break; } VAR_15 = get_vlc2(&VAR_0->gb, vlc->table, 7, 3); if (!VAR_15) { VAR_1->sb_hybrid[VAR_4 ] = VAR_1->sb_hybrid[VAR_4+1] = 0; VAR_4 += 2; continue; } VAR_13= VAR_2[VAR_4]; ff_dlog(VAR_0->avctx, "region=%d n=%d VAR_14=%d VAR_15=%d exp=%d\n", VAR_5, VAR_1->region_size[VAR_5] - VAR_9, VAR_14, VAR_15, VAR_13); if (VAR_15 & 16) { VAR_14 = VAR_15 >> 5; VAR_15 = VAR_15 & 0x0f; if (VAR_14 < 15) { READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4, RENAME(expval_table)[VAR_13] + VAR_14) } else { VAR_14 += get_bitsz(&VAR_0->gb, VAR_12); VAR_20 = l3_unscale(VAR_14, VAR_13); if (get_bits1(&VAR_0->gb)) VAR_20 = -VAR_20; VAR_1->sb_hybrid[VAR_4] = VAR_20; } if (VAR_15 < 15) { READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4 + 1, RENAME(expval_table)[VAR_13] + VAR_15) } else { VAR_15 += get_bitsz(&VAR_0->gb, VAR_12); VAR_20 = l3_unscale(VAR_15, VAR_13); if (get_bits1(&VAR_0->gb)) VAR_20 = -VAR_20; VAR_1->sb_hybrid[VAR_4+1] = VAR_20; } } else { VAR_14 = VAR_15 >> 5; VAR_15 = VAR_15 & 0x0f; VAR_14 += VAR_15; if (VAR_14 < 15) { READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4 + !!VAR_15, RENAME(expval_table)[VAR_13] + VAR_14) } else { VAR_14 += get_bitsz(&VAR_0->gb, VAR_12); VAR_20 = l3_unscale(VAR_14, VAR_13); if (get_bits1(&VAR_0->gb)) VAR_20 = -VAR_20; VAR_1->sb_hybrid[VAR_4+!!VAR_15] = VAR_20; } VAR_1->sb_hybrid[VAR_4 + !VAR_15] = 0; } VAR_4 += 2; } } vlc = &huff_quad_vlc[VAR_1->count1table_select]; VAR_6 = 0; while (VAR_4 <= 572) { int VAR_20, VAR_18; VAR_20 = get_bits_count(&VAR_0->gb); if (VAR_20 >= VAR_8) { if (VAR_20 > VAR_3 && VAR_6) { VAR_4 -= 4; skip_bits_long(&VAR_0->gb, VAR_6 - VAR_20); av_log(VAR_0->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", VAR_6 - VAR_20, VAR_8-VAR_20, VAR_3-VAR_20); if(VAR_0->err_recognition & AV_EF_BITSTREAM) VAR_4=0; break; } switch_buffer(VAR_0, &VAR_20, &VAR_8, &VAR_3); if (VAR_20 >= VAR_8) break; } VAR_6 = VAR_20; VAR_18 = get_vlc2(&VAR_0->gb, vlc->table, vlc->bits, 1); ff_dlog(VAR_0->avctx, "t=%d VAR_18=%d\n", VAR_1->count1table_select, VAR_18); VAR_1->sb_hybrid[VAR_4+0] = VAR_1->sb_hybrid[VAR_4+1] = VAR_1->sb_hybrid[VAR_4+2] = VAR_1->sb_hybrid[VAR_4+3] = 0; while (VAR_18) { static const int VAR_19[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 }; int VAR_20; int VAR_20 = VAR_4 + VAR_19[VAR_18]; VAR_18 ^= 8 >> VAR_19[VAR_18]; READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_20, RENAME(exp_table)+VAR_2[VAR_20]) } VAR_4 += 4; } VAR_7 = VAR_3 - get_bits_count(&VAR_0->gb); if (VAR_7 < 0 && (VAR_0->err_recognition & AV_EF_BUFFER)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_7=%d\n", VAR_7); VAR_4=0; } else if (VAR_7 > 0 && (VAR_0->err_recognition & AV_EF_BUFFER)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_7=%d\n", VAR_7); VAR_4 = 0; } memset(&VAR_1->sb_hybrid[VAR_4], 0, sizeof(*VAR_1->sb_hybrid) * (576 - VAR_4)); skip_bits_long(&VAR_0->gb, VAR_7); VAR_5 = get_bits_count(&VAR_0->gb); switch_buffer(VAR_0, &VAR_5, &VAR_8, &VAR_3); return 0; }
[ "static int FUNC_0(MPADecodeContext *VAR_0, GranuleDef *VAR_1,\nint16_t *VAR_2, int VAR_3)\n{", "int VAR_4;", "int VAR_5;", "int VAR_6, VAR_7;", "VLC *vlc;", "int VAR_8 = FFMIN(VAR_3, VAR_0->gb.size_in_bits);", "VAR_4 = 0;", "for (VAR_5 = 0; VAR_5 < 3; VAR_5++) {", "int VAR_9, VAR_10, VAR_11, VAR_12;", "VAR_9 = VAR_1->region_size[VAR_5];", "if (VAR_9 == 0)\ncontinue;", "VAR_10 = VAR_1->table_select[VAR_5];", "VAR_11 = mpa_huff_data[VAR_10][0];", "VAR_12 = mpa_huff_data[VAR_10][1];", "vlc = &huff_vlc[VAR_11];", "if (!VAR_11) {", "memset(&VAR_1->sb_hybrid[VAR_4], 0, sizeof(*VAR_1->sb_hybrid) * 2 * VAR_9);", "VAR_4 += 2 * VAR_9;", "continue;", "}", "for (; VAR_9 > 0; VAR_9--) {", "int VAR_13, VAR_14, VAR_15;", "int VAR_20;", "int VAR_20 = get_bits_count(&VAR_0->gb);", "if (VAR_20 >= VAR_8){", "switch_buffer(VAR_0, &VAR_20, &VAR_8, &VAR_3);", "if (VAR_20 >= VAR_8)\nbreak;", "}", "VAR_15 = get_vlc2(&VAR_0->gb, vlc->table, 7, 3);", "if (!VAR_15) {", "VAR_1->sb_hybrid[VAR_4 ] =\nVAR_1->sb_hybrid[VAR_4+1] = 0;", "VAR_4 += 2;", "continue;", "}", "VAR_13= VAR_2[VAR_4];", "ff_dlog(VAR_0->avctx, \"region=%d n=%d VAR_14=%d VAR_15=%d exp=%d\\n\",\nVAR_5, VAR_1->region_size[VAR_5] - VAR_9, VAR_14, VAR_15, VAR_13);", "if (VAR_15 & 16) {", "VAR_14 = VAR_15 >> 5;", "VAR_15 = VAR_15 & 0x0f;", "if (VAR_14 < 15) {", "READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4, RENAME(expval_table)[VAR_13] + VAR_14)\n} else {", "VAR_14 += get_bitsz(&VAR_0->gb, VAR_12);", "VAR_20 = l3_unscale(VAR_14, VAR_13);", "if (get_bits1(&VAR_0->gb))\nVAR_20 = -VAR_20;", "VAR_1->sb_hybrid[VAR_4] = VAR_20;", "}", "if (VAR_15 < 15) {", "READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4 + 1, RENAME(expval_table)[VAR_13] + VAR_15)\n} else {", "VAR_15 += get_bitsz(&VAR_0->gb, VAR_12);", "VAR_20 = l3_unscale(VAR_15, VAR_13);", "if (get_bits1(&VAR_0->gb))\nVAR_20 = -VAR_20;", "VAR_1->sb_hybrid[VAR_4+1] = VAR_20;", "}", "} else {", "VAR_14 = VAR_15 >> 5;", "VAR_15 = VAR_15 & 0x0f;", "VAR_14 += VAR_15;", "if (VAR_14 < 15) {", "READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_4 + !!VAR_15, RENAME(expval_table)[VAR_13] + VAR_14)\n} else {", "VAR_14 += get_bitsz(&VAR_0->gb, VAR_12);", "VAR_20 = l3_unscale(VAR_14, VAR_13);", "if (get_bits1(&VAR_0->gb))\nVAR_20 = -VAR_20;", "VAR_1->sb_hybrid[VAR_4+!!VAR_15] = VAR_20;", "}", "VAR_1->sb_hybrid[VAR_4 + !VAR_15] = 0;", "}", "VAR_4 += 2;", "}", "}", "vlc = &huff_quad_vlc[VAR_1->count1table_select];", "VAR_6 = 0;", "while (VAR_4 <= 572) {", "int VAR_20, VAR_18;", "VAR_20 = get_bits_count(&VAR_0->gb);", "if (VAR_20 >= VAR_8) {", "if (VAR_20 > VAR_3 && VAR_6) {", "VAR_4 -= 4;", "skip_bits_long(&VAR_0->gb, VAR_6 - VAR_20);", "av_log(VAR_0->avctx, AV_LOG_INFO, \"overread, skip %d enddists: %d %d\\n\", VAR_6 - VAR_20, VAR_8-VAR_20, VAR_3-VAR_20);", "if(VAR_0->err_recognition & AV_EF_BITSTREAM)\nVAR_4=0;", "break;", "}", "switch_buffer(VAR_0, &VAR_20, &VAR_8, &VAR_3);", "if (VAR_20 >= VAR_8)\nbreak;", "}", "VAR_6 = VAR_20;", "VAR_18 = get_vlc2(&VAR_0->gb, vlc->table, vlc->bits, 1);", "ff_dlog(VAR_0->avctx, \"t=%d VAR_18=%d\\n\", VAR_1->count1table_select, VAR_18);", "VAR_1->sb_hybrid[VAR_4+0] =\nVAR_1->sb_hybrid[VAR_4+1] =\nVAR_1->sb_hybrid[VAR_4+2] =\nVAR_1->sb_hybrid[VAR_4+3] = 0;", "while (VAR_18) {", "static const int VAR_19[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };", "int VAR_20;", "int VAR_20 = VAR_4 + VAR_19[VAR_18];", "VAR_18 ^= 8 >> VAR_19[VAR_18];", "READ_FLIP_SIGN(VAR_1->sb_hybrid + VAR_20, RENAME(exp_table)+VAR_2[VAR_20])\n}", "VAR_4 += 4;", "}", "VAR_7 = VAR_3 - get_bits_count(&VAR_0->gb);", "if (VAR_7 < 0 && (VAR_0->err_recognition & AV_EF_BUFFER)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_7=%d\\n\", VAR_7);", "VAR_4=0;", "} else if (VAR_7 > 0 && (VAR_0->err_recognition & AV_EF_BUFFER)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_7=%d\\n\", VAR_7);", "VAR_4 = 0;", "}", "memset(&VAR_1->sb_hybrid[VAR_4], 0, sizeof(*VAR_1->sb_hybrid) * (576 - VAR_4));", "skip_bits_long(&VAR_0->gb, VAR_7);", "VAR_5 = get_bits_count(&VAR_0->gb);", "switch_buffer(VAR_0, &VAR_5, &VAR_8, &VAR_3);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 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 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 205 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 231 ], [ 233 ], [ 235, 237, 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 285 ], [ 287 ], [ 291 ], [ 293 ] ]
33
void helper_slbie(CPUPPCState *env, target_ulong addr) { PowerPCCPU *cpu = ppc_env_get_cpu(env); ppc_slb_t *slb; slb = slb_lookup(cpu, addr); if (!slb) { return; } if (slb->esid & SLB_ESID_V) { slb->esid &= ~SLB_ESID_V; /* XXX: given the fact that segment size is 256 MB or 1TB, * and we still don't have a tlb_flush_mask(env, n, mask) * in QEMU, we just invalidate all TLBs */ tlb_flush(CPU(cpu), 1); } }
true
qemu
cd0c6f473532bfaf20a095bc90a18e45162981b5
void helper_slbie(CPUPPCState *env, target_ulong addr) { PowerPCCPU *cpu = ppc_env_get_cpu(env); ppc_slb_t *slb; slb = slb_lookup(cpu, addr); if (!slb) { return; } if (slb->esid & SLB_ESID_V) { slb->esid &= ~SLB_ESID_V; tlb_flush(CPU(cpu), 1); } }
{ "code": [ " PowerPCCPU *cpu = ppc_env_get_cpu(env);", " tlb_flush(CPU(cpu), 1);", " tlb_flush(CPU(cpu), 1);", " tlb_flush(CPU(cpu), 1);" ], "line_no": [ 5, 35, 35, 35 ] }
void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1) { PowerPCCPU *cpu = ppc_env_get_cpu(VAR_0); ppc_slb_t *slb; slb = slb_lookup(cpu, VAR_1); if (!slb) { return; } if (slb->esid & SLB_ESID_V) { slb->esid &= ~SLB_ESID_V; tlb_flush(CPU(cpu), 1); } }
[ "void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1)\n{", "PowerPCCPU *cpu = ppc_env_get_cpu(VAR_0);", "ppc_slb_t *slb;", "slb = slb_lookup(cpu, VAR_1);", "if (!slb) {", "return;", "}", "if (slb->esid & SLB_ESID_V) {", "slb->esid &= ~SLB_ESID_V;", "tlb_flush(CPU(cpu), 1);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 35 ], [ 37 ], [ 39 ] ]
34
static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr) { CPUState *cs = CPU(ppc_env_get_cpu(env)); /* MSR:POW cannot be set by any form of rfi */ msr &= ~(1ULL << MSR_POW); #if defined(TARGET_PPC64) /* Switching to 32-bit ? Crop the nip */ if (!msr_is_64bit(env, msr)) { nip = (uint32_t)nip; } #else nip = (uint32_t)nip; #endif /* XXX: beware: this is false if VLE is supported */ env->nip = nip & ~((target_ulong)0x00000003); hreg_store_msr(env, msr, 1); #if defined(DEBUG_OP) cpu_dump_rfi(env->nip, env->msr); #endif /* No need to raise an exception here, * as rfi is always the last insn of a TB */ cs->interrupt_request |= CPU_INTERRUPT_EXITTB; /* Context synchronizing: check if TCG TLB needs flush */ check_tlb_flush(env); }
true
qemu
e3cffe6fad29e07d401eabb913a6d88501d5c143
static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr) { CPUState *cs = CPU(ppc_env_get_cpu(env)); msr &= ~(1ULL << MSR_POW); #if defined(TARGET_PPC64) if (!msr_is_64bit(env, msr)) { nip = (uint32_t)nip; } #else nip = (uint32_t)nip; #endif env->nip = nip & ~((target_ulong)0x00000003); hreg_store_msr(env, msr, 1); #if defined(DEBUG_OP) cpu_dump_rfi(env->nip, env->msr); #endif cs->interrupt_request |= CPU_INTERRUPT_EXITTB; check_tlb_flush(env); }
{ "code": [ " check_tlb_flush(env);", " check_tlb_flush(env);", " check_tlb_flush(env);", " check_tlb_flush(env);" ], "line_no": [ 55, 55, 55, 55 ] }
static inline void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, target_ulong VAR_2) { CPUState *cs = CPU(ppc_env_get_cpu(VAR_0)); VAR_2 &= ~(1ULL << MSR_POW); #if defined(TARGET_PPC64) if (!msr_is_64bit(VAR_0, VAR_2)) { VAR_1 = (uint32_t)VAR_1; } #else VAR_1 = (uint32_t)VAR_1; #endif VAR_0->VAR_1 = VAR_1 & ~((target_ulong)0x00000003); hreg_store_msr(VAR_0, VAR_2, 1); #if defined(DEBUG_OP) cpu_dump_rfi(VAR_0->VAR_1, VAR_0->VAR_2); #endif cs->interrupt_request |= CPU_INTERRUPT_EXITTB; check_tlb_flush(VAR_0); }
[ "static inline void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, target_ulong VAR_2)\n{", "CPUState *cs = CPU(ppc_env_get_cpu(VAR_0));", "VAR_2 &= ~(1ULL << MSR_POW);", "#if defined(TARGET_PPC64)\nif (!msr_is_64bit(VAR_0, VAR_2)) {", "VAR_1 = (uint32_t)VAR_1;", "}", "#else\nVAR_1 = (uint32_t)VAR_1;", "#endif\nVAR_0->VAR_1 = VAR_1 & ~((target_ulong)0x00000003);", "hreg_store_msr(VAR_0, VAR_2, 1);", "#if defined(DEBUG_OP)\ncpu_dump_rfi(VAR_0->VAR_1, VAR_0->VAR_2);", "#endif\ncs->interrupt_request |= CPU_INTERRUPT_EXITTB;", "check_tlb_flush(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 15, 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 33 ], [ 35 ], [ 37, 39 ], [ 41, 49 ], [ 55 ], [ 57 ] ]
36
static void d3d11va_device_uninit(AVHWDeviceContext *hwdev) { AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx; if (device_hwctx->device) ID3D11Device_Release(device_hwctx->device); if (device_hwctx->device_context) ID3D11DeviceContext_Release(device_hwctx->device_context); if (device_hwctx->video_device) ID3D11VideoDevice_Release(device_hwctx->video_device); if (device_hwctx->video_context) ID3D11VideoContext_Release(device_hwctx->video_context); if (device_hwctx->lock == d3d11va_default_lock) CloseHandle(device_hwctx->lock_ctx); }
true
FFmpeg
f6d49a0dc84aade2adf150c25afb66cbda1d5528
static void d3d11va_device_uninit(AVHWDeviceContext *hwdev) { AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx; if (device_hwctx->device) ID3D11Device_Release(device_hwctx->device); if (device_hwctx->device_context) ID3D11DeviceContext_Release(device_hwctx->device_context); if (device_hwctx->video_device) ID3D11VideoDevice_Release(device_hwctx->video_device); if (device_hwctx->video_context) ID3D11VideoContext_Release(device_hwctx->video_context); if (device_hwctx->lock == d3d11va_default_lock) CloseHandle(device_hwctx->lock_ctx); }
{ "code": [ " if (device_hwctx->device)", " if (device_hwctx->device_context)", " if (device_hwctx->video_device)", " if (device_hwctx->video_context)", " if (device_hwctx->lock == d3d11va_default_lock)" ], "line_no": [ 9, 15, 21, 27, 33 ] }
static void FUNC_0(AVHWDeviceContext *VAR_0) { AVD3D11VADeviceContext *device_hwctx = VAR_0->hwctx; if (device_hwctx->device) ID3D11Device_Release(device_hwctx->device); if (device_hwctx->device_context) ID3D11DeviceContext_Release(device_hwctx->device_context); if (device_hwctx->video_device) ID3D11VideoDevice_Release(device_hwctx->video_device); if (device_hwctx->video_context) ID3D11VideoContext_Release(device_hwctx->video_context); if (device_hwctx->lock == d3d11va_default_lock) CloseHandle(device_hwctx->lock_ctx); }
[ "static void FUNC_0(AVHWDeviceContext *VAR_0)\n{", "AVD3D11VADeviceContext *device_hwctx = VAR_0->hwctx;", "if (device_hwctx->device)\nID3D11Device_Release(device_hwctx->device);", "if (device_hwctx->device_context)\nID3D11DeviceContext_Release(device_hwctx->device_context);", "if (device_hwctx->video_device)\nID3D11VideoDevice_Release(device_hwctx->video_device);", "if (device_hwctx->video_context)\nID3D11VideoContext_Release(device_hwctx->video_context);", "if (device_hwctx->lock == d3d11va_default_lock)\nCloseHandle(device_hwctx->lock_ctx);", "}" ]
[ 0, 0, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15, 17 ], [ 21, 23 ], [ 27, 29 ], [ 33, 35 ], [ 37 ] ]
37
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian) { int id; uint64_t bitrate; if (size < 14) { avpriv_request_sample(codec, "wav header size < 14"); return AVERROR_INVALIDDATA; } codec->codec_type = AVMEDIA_TYPE_AUDIO; if (!big_endian) { id = avio_rl16(pb); codec->channels = avio_rl16(pb); codec->sample_rate = avio_rl32(pb); bitrate = avio_rl32(pb) * 8; codec->block_align = avio_rl16(pb); } else { id = avio_rb16(pb); codec->channels = avio_rb16(pb); codec->sample_rate = avio_rb32(pb); bitrate = avio_rb32(pb) * 8; codec->block_align = avio_rb16(pb); } if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */ codec->bits_per_coded_sample = 8; } else { if (!big_endian) { codec->bits_per_coded_sample = avio_rl16(pb); } else { codec->bits_per_coded_sample = avio_rb16(pb); } } if (id == 0xFFFE) { codec->codec_tag = 0; } else { codec->codec_tag = id; codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample); } if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */ int cbSize = avio_rl16(pb); /* cbSize */ if (big_endian) { avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files\n"); return AVERROR_PATCHWELCOME; } size -= 18; cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ parse_waveformatex(pb, codec); cbSize -= 22; size -= 22; } if (cbSize > 0) { av_freep(&codec->extradata); if (ff_get_extradata(codec, pb, cbSize) < 0) return AVERROR(ENOMEM); size -= cbSize; } /* It is possible for the chunk to contain garbage at the end */ if (size > 0) avio_skip(pb, size); } if (bitrate > INT_MAX) { if (s->error_recognition & AV_EF_EXPLODE) { av_log(s, AV_LOG_ERROR, "The bitrate %"PRIu64" is too large.\n", bitrate); return AVERROR_INVALIDDATA; } else { av_log(s, AV_LOG_WARNING, "The bitrate %"PRIu64" is too large, resetting to 0.", bitrate); codec->bit_rate = 0; } } else { codec->bit_rate = bitrate; } if (codec->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", codec->sample_rate); return AVERROR_INVALIDDATA; } if (codec->codec_id == AV_CODEC_ID_AAC_LATM) { /* Channels and sample_rate values are those prior to applying SBR * and/or PS. */ codec->channels = 0; codec->sample_rate = 0; } /* override bits_per_coded_sample for G.726 */ if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate) codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate; return 0; }
true
FFmpeg
839d6bc192f7ef94343872ff039799501af38855
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian) { int id; uint64_t bitrate; if (size < 14) { avpriv_request_sample(codec, "wav header size < 14"); return AVERROR_INVALIDDATA; } codec->codec_type = AVMEDIA_TYPE_AUDIO; if (!big_endian) { id = avio_rl16(pb); codec->channels = avio_rl16(pb); codec->sample_rate = avio_rl32(pb); bitrate = avio_rl32(pb) * 8; codec->block_align = avio_rl16(pb); } else { id = avio_rb16(pb); codec->channels = avio_rb16(pb); codec->sample_rate = avio_rb32(pb); bitrate = avio_rb32(pb) * 8; codec->block_align = avio_rb16(pb); } if (size == 14) { codec->bits_per_coded_sample = 8; } else { if (!big_endian) { codec->bits_per_coded_sample = avio_rl16(pb); } else { codec->bits_per_coded_sample = avio_rb16(pb); } } if (id == 0xFFFE) { codec->codec_tag = 0; } else { codec->codec_tag = id; codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample); } if (size >= 18) { int cbSize = avio_rl16(pb); if (big_endian) { avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files\n"); return AVERROR_PATCHWELCOME; } size -= 18; cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { parse_waveformatex(pb, codec); cbSize -= 22; size -= 22; } if (cbSize > 0) { av_freep(&codec->extradata); if (ff_get_extradata(codec, pb, cbSize) < 0) return AVERROR(ENOMEM); size -= cbSize; } if (size > 0) avio_skip(pb, size); } if (bitrate > INT_MAX) { if (s->error_recognition & AV_EF_EXPLODE) { av_log(s, AV_LOG_ERROR, "The bitrate %"PRIu64" is too large.\n", bitrate); return AVERROR_INVALIDDATA; } else { av_log(s, AV_LOG_WARNING, "The bitrate %"PRIu64" is too large, resetting to 0.", bitrate); codec->bit_rate = 0; } } else { codec->bit_rate = bitrate; } if (codec->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", codec->sample_rate); return AVERROR_INVALIDDATA; } if (codec->codec_id == AV_CODEC_ID_AAC_LATM) { codec->channels = 0; codec->sample_rate = 0; } if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate) codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate; return 0; }
{ "code": [ " bitrate = avio_rl32(pb) * 8;", " bitrate = avio_rb32(pb) * 8;" ], "line_no": [ 33, 45 ] }
int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVCodecContext *VAR_2, int VAR_3, int VAR_4) { int VAR_5; uint64_t bitrate; if (VAR_3 < 14) { avpriv_request_sample(VAR_2, "wav header VAR_3 < 14"); return AVERROR_INVALIDDATA; } VAR_2->codec_type = AVMEDIA_TYPE_AUDIO; if (!VAR_4) { VAR_5 = avio_rl16(VAR_1); VAR_2->channels = avio_rl16(VAR_1); VAR_2->sample_rate = avio_rl32(VAR_1); bitrate = avio_rl32(VAR_1) * 8; VAR_2->block_align = avio_rl16(VAR_1); } else { VAR_5 = avio_rb16(VAR_1); VAR_2->channels = avio_rb16(VAR_1); VAR_2->sample_rate = avio_rb32(VAR_1); bitrate = avio_rb32(VAR_1) * 8; VAR_2->block_align = avio_rb16(VAR_1); } if (VAR_3 == 14) { VAR_2->bits_per_coded_sample = 8; } else { if (!VAR_4) { VAR_2->bits_per_coded_sample = avio_rl16(VAR_1); } else { VAR_2->bits_per_coded_sample = avio_rb16(VAR_1); } } if (VAR_5 == 0xFFFE) { VAR_2->codec_tag = 0; } else { VAR_2->codec_tag = VAR_5; VAR_2->codec_id = ff_wav_codec_get_id(VAR_5, VAR_2->bits_per_coded_sample); } if (VAR_3 >= 18) { int VAR_6 = avio_rl16(VAR_1); if (VAR_4) { avpriv_report_missing_feature(VAR_2, "WAVEFORMATEX support for RIFX files\n"); return AVERROR_PATCHWELCOME; } VAR_3 -= 18; VAR_6 = FFMIN(VAR_3, VAR_6); if (VAR_6 >= 22 && VAR_5 == 0xfffe) { parse_waveformatex(VAR_1, VAR_2); VAR_6 -= 22; VAR_3 -= 22; } if (VAR_6 > 0) { av_freep(&VAR_2->extradata); if (ff_get_extradata(VAR_2, VAR_1, VAR_6) < 0) return AVERROR(ENOMEM); VAR_3 -= VAR_6; } if (VAR_3 > 0) avio_skip(VAR_1, VAR_3); } if (bitrate > INT_MAX) { if (VAR_0->error_recognition & AV_EF_EXPLODE) { av_log(VAR_0, AV_LOG_ERROR, "The bitrate %"PRIu64" is too large.\n", bitrate); return AVERROR_INVALIDDATA; } else { av_log(VAR_0, AV_LOG_WARNING, "The bitrate %"PRIu64" is too large, resetting to 0.", bitrate); VAR_2->bit_rate = 0; } } else { VAR_2->bit_rate = bitrate; } if (VAR_2->sample_rate <= 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid sample rate: %d\n", VAR_2->sample_rate); return AVERROR_INVALIDDATA; } if (VAR_2->codec_id == AV_CODEC_ID_AAC_LATM) { VAR_2->channels = 0; VAR_2->sample_rate = 0; } if (VAR_2->codec_id == AV_CODEC_ID_ADPCM_G726 && VAR_2->sample_rate) VAR_2->bits_per_coded_sample = VAR_2->bit_rate / VAR_2->sample_rate; return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1,\nAVCodecContext *VAR_2, int VAR_3, int VAR_4)\n{", "int VAR_5;", "uint64_t bitrate;", "if (VAR_3 < 14) {", "avpriv_request_sample(VAR_2, \"wav header VAR_3 < 14\");", "return AVERROR_INVALIDDATA;", "}", "VAR_2->codec_type = AVMEDIA_TYPE_AUDIO;", "if (!VAR_4) {", "VAR_5 = avio_rl16(VAR_1);", "VAR_2->channels = avio_rl16(VAR_1);", "VAR_2->sample_rate = avio_rl32(VAR_1);", "bitrate = avio_rl32(VAR_1) * 8;", "VAR_2->block_align = avio_rl16(VAR_1);", "} else {", "VAR_5 = avio_rb16(VAR_1);", "VAR_2->channels = avio_rb16(VAR_1);", "VAR_2->sample_rate = avio_rb32(VAR_1);", "bitrate = avio_rb32(VAR_1) * 8;", "VAR_2->block_align = avio_rb16(VAR_1);", "}", "if (VAR_3 == 14) {", "VAR_2->bits_per_coded_sample = 8;", "} else {", "if (!VAR_4) {", "VAR_2->bits_per_coded_sample = avio_rl16(VAR_1);", "} else {", "VAR_2->bits_per_coded_sample = avio_rb16(VAR_1);", "}", "}", "if (VAR_5 == 0xFFFE) {", "VAR_2->codec_tag = 0;", "} else {", "VAR_2->codec_tag = VAR_5;", "VAR_2->codec_id = ff_wav_codec_get_id(VAR_5,\nVAR_2->bits_per_coded_sample);", "}", "if (VAR_3 >= 18) {", "int VAR_6 = avio_rl16(VAR_1);", "if (VAR_4) {", "avpriv_report_missing_feature(VAR_2, \"WAVEFORMATEX support for RIFX files\\n\");", "return AVERROR_PATCHWELCOME;", "}", "VAR_3 -= 18;", "VAR_6 = FFMIN(VAR_3, VAR_6);", "if (VAR_6 >= 22 && VAR_5 == 0xfffe) {", "parse_waveformatex(VAR_1, VAR_2);", "VAR_6 -= 22;", "VAR_3 -= 22;", "}", "if (VAR_6 > 0) {", "av_freep(&VAR_2->extradata);", "if (ff_get_extradata(VAR_2, VAR_1, VAR_6) < 0)\nreturn AVERROR(ENOMEM);", "VAR_3 -= VAR_6;", "}", "if (VAR_3 > 0)\navio_skip(VAR_1, VAR_3);", "}", "if (bitrate > INT_MAX) {", "if (VAR_0->error_recognition & AV_EF_EXPLODE) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"The bitrate %\"PRIu64\" is too large.\\n\",\nbitrate);", "return AVERROR_INVALIDDATA;", "} else {", "av_log(VAR_0, AV_LOG_WARNING,\n\"The bitrate %\"PRIu64\" is too large, resetting to 0.\",\nbitrate);", "VAR_2->bit_rate = 0;", "}", "} else {", "VAR_2->bit_rate = bitrate;", "}", "if (VAR_2->sample_rate <= 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid sample rate: %d\\n\", VAR_2->sample_rate);", "return AVERROR_INVALIDDATA;", "}", "if (VAR_2->codec_id == AV_CODEC_ID_AAC_LATM) {", "VAR_2->channels = 0;", "VAR_2->sample_rate = 0;", "}", "if (VAR_2->codec_id == AV_CODEC_ID_ADPCM_G726 && VAR_2->sample_rate)\nVAR_2->bits_per_coded_sample = VAR_2->bit_rate / VAR_2->sample_rate;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 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 ], [ 125, 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137, 139, 141 ], [ 143 ], [ 145 ], [ 147, 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 181 ], [ 183 ], [ 185 ], [ 189, 191 ], [ 195 ], [ 197 ] ]
38
static void test_acpi_asl(test_data *data) { int i; AcpiSdtTable *sdt, *exp_sdt; test_data exp_data; gboolean exp_err, err; memset(&exp_data, 0, sizeof(exp_data)); exp_data.tables = load_expected_aml(data); dump_aml_files(data, false); for (i = 0; i < data->tables->len; ++i) { GString *asl, *exp_asl; sdt = &g_array_index(data->tables, AcpiSdtTable, i); exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i); err = load_asl(data->tables, sdt); asl = normalize_asl(sdt->asl); exp_err = load_asl(exp_data.tables, exp_sdt); exp_asl = normalize_asl(exp_sdt->asl); /* TODO: check for warnings */ g_assert(!err || exp_err); if (g_strcmp0(asl->str, exp_asl->str)) { uint32_t signature = cpu_to_le32(exp_sdt->header.signature); sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true; fprintf(stderr, "acpi-test: Warning! %.4s mismatch. " "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n", (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); } g_string_free(asl, true); g_string_free(exp_asl, true); } free_test_data(&exp_data); }
true
qemu
dac23a6c05e543590508b48b8ed31d89b0c99c61
static void test_acpi_asl(test_data *data) { int i; AcpiSdtTable *sdt, *exp_sdt; test_data exp_data; gboolean exp_err, err; memset(&exp_data, 0, sizeof(exp_data)); exp_data.tables = load_expected_aml(data); dump_aml_files(data, false); for (i = 0; i < data->tables->len; ++i) { GString *asl, *exp_asl; sdt = &g_array_index(data->tables, AcpiSdtTable, i); exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i); err = load_asl(data->tables, sdt); asl = normalize_asl(sdt->asl); exp_err = load_asl(exp_data.tables, exp_sdt); exp_asl = normalize_asl(exp_sdt->asl); g_assert(!err || exp_err); if (g_strcmp0(asl->str, exp_asl->str)) { uint32_t signature = cpu_to_le32(exp_sdt->header.signature); sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true; fprintf(stderr, "acpi-test: Warning! %.4s mismatch. " "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n", (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); } g_string_free(asl, true); g_string_free(exp_asl, true); } free_test_data(&exp_data); }
{ "code": [ " uint32_t signature = cpu_to_le32(exp_sdt->header.signature);", " sdt->tmp_files_retain = true;", " exp_sdt->tmp_files_retain = true;", " fprintf(stderr,", " \"acpi-test: Warning! %.4s mismatch. \"", " \"Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\\n\",", " (gchar *)&signature,", " sdt->asl_file, sdt->aml_file,", " exp_sdt->asl_file, exp_sdt->aml_file);" ], "line_no": [ 53, 55, 57, 59, 61, 63, 65, 67, 69 ] }
static void FUNC_0(test_data *VAR_0) { int VAR_1; AcpiSdtTable *sdt, *exp_sdt; test_data exp_data; gboolean exp_err, err; memset(&exp_data, 0, sizeof(exp_data)); exp_data.tables = load_expected_aml(VAR_0); dump_aml_files(VAR_0, false); for (VAR_1 = 0; VAR_1 < VAR_0->tables->len; ++VAR_1) { GString *asl, *exp_asl; sdt = &g_array_index(VAR_0->tables, AcpiSdtTable, VAR_1); exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, VAR_1); err = load_asl(VAR_0->tables, sdt); asl = normalize_asl(sdt->asl); exp_err = load_asl(exp_data.tables, exp_sdt); exp_asl = normalize_asl(exp_sdt->asl); g_assert(!err || exp_err); if (g_strcmp0(asl->str, exp_asl->str)) { uint32_t signature = cpu_to_le32(exp_sdt->header.signature); sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true; fprintf(stderr, "acpi-test: Warning! %.4s mismatch. " "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n", (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); } g_string_free(asl, true); g_string_free(exp_asl, true); } free_test_data(&exp_data); }
[ "static void FUNC_0(test_data *VAR_0)\n{", "int VAR_1;", "AcpiSdtTable *sdt, *exp_sdt;", "test_data exp_data;", "gboolean exp_err, err;", "memset(&exp_data, 0, sizeof(exp_data));", "exp_data.tables = load_expected_aml(VAR_0);", "dump_aml_files(VAR_0, false);", "for (VAR_1 = 0; VAR_1 < VAR_0->tables->len; ++VAR_1) {", "GString *asl, *exp_asl;", "sdt = &g_array_index(VAR_0->tables, AcpiSdtTable, VAR_1);", "exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, VAR_1);", "err = load_asl(VAR_0->tables, sdt);", "asl = normalize_asl(sdt->asl);", "exp_err = load_asl(exp_data.tables, exp_sdt);", "exp_asl = normalize_asl(exp_sdt->asl);", "g_assert(!err || exp_err);", "if (g_strcmp0(asl->str, exp_asl->str)) {", "uint32_t signature = cpu_to_le32(exp_sdt->header.signature);", "sdt->tmp_files_retain = true;", "exp_sdt->tmp_files_retain = true;", "fprintf(stderr,\n\"acpi-test: Warning! %.4s mismatch. \"\n\"Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\\n\",\n(gchar *)&signature,\nsdt->asl_file, sdt->aml_file,\nexp_sdt->asl_file, exp_sdt->aml_file);", "}", "g_string_free(asl, true);", "g_string_free(exp_asl, true);", "}", "free_test_data(&exp_data);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61, 63, 65, 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ] ]
39
static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, int size, int type, uint32_t **lace_buf, int *laces) { int res = 0, n; uint8_t *data = *buf; uint32_t *lace_size; if (!type) { *laces = 1; *lace_buf = av_mallocz(sizeof(int)); if (!*lace_buf) return AVERROR(ENOMEM); *lace_buf[0] = size; return 0; } assert(size > 0); *laces = *data + 1; data += 1; size -= 1; lace_size = av_mallocz(*laces * sizeof(int)); if (!lace_size) return AVERROR(ENOMEM); switch (type) { case 0x1: /* Xiph lacing */ { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < *laces - 1; n++) { while (1) { if (size == 0) { res = AVERROR_EOF; break; } temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) break; } total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[n] = size - total; break; } case 0x2: /* fixed-size lacing */ if (size != (size / *laces) * size) { res = AVERROR_INVALIDDATA; break; } for (n = 0; n < *laces; n++) lace_size[n] = size / *laces; break; case 0x3: /* EBML lacing */ { uint64_t num; uint32_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = n; break; } data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < *laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = r; break; } data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[*laces - 1] = size - total; break; } } *buf = data; *lace_buf = lace_size; return res; }
true
FFmpeg
87b017a298c12b9a2451276649f3932358b943fc
static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, int size, int type, uint32_t **lace_buf, int *laces) { int res = 0, n; uint8_t *data = *buf; uint32_t *lace_size; if (!type) { *laces = 1; *lace_buf = av_mallocz(sizeof(int)); if (!*lace_buf) return AVERROR(ENOMEM); *lace_buf[0] = size; return 0; } assert(size > 0); *laces = *data + 1; data += 1; size -= 1; lace_size = av_mallocz(*laces * sizeof(int)); if (!lace_size) return AVERROR(ENOMEM); switch (type) { case 0x1: { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < *laces - 1; n++) { while (1) { if (size == 0) { res = AVERROR_EOF; break; } temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) break; } total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[n] = size - total; break; } case 0x2: if (size != (size / *laces) * size) { res = AVERROR_INVALIDDATA; break; } for (n = 0; n < *laces; n++) lace_size[n] = size / *laces; break; case 0x3: { uint64_t num; uint32_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = n; break; } data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < *laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); res = r; break; } data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } if (size <= total) { res = AVERROR_INVALIDDATA; break; } lace_size[*laces - 1] = size - total; break; } } *buf = data; *lace_buf = lace_size; return res; }
{ "code": [ " if (size != (size / *laces) * size) {" ], "line_no": [ 111 ] }
static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t **VAR_1, int VAR_2, int VAR_3, uint32_t **VAR_4, int *VAR_5) { int VAR_6 = 0, VAR_7; uint8_t *data = *VAR_1; uint32_t *lace_size; if (!VAR_3) { *VAR_5 = 1; *VAR_4 = av_mallocz(sizeof(int)); if (!*VAR_4) return AVERROR(ENOMEM); *VAR_4[0] = VAR_2; return 0; } assert(VAR_2 > 0); *VAR_5 = *data + 1; data += 1; VAR_2 -= 1; lace_size = av_mallocz(*VAR_5 * sizeof(int)); if (!lace_size) return AVERROR(ENOMEM); switch (VAR_3) { case 0x1: { uint8_t temp; uint32_t total = 0; for (VAR_7 = 0; VAR_6 == 0 && VAR_7 < *VAR_5 - 1; VAR_7++) { while (1) { if (VAR_2 == 0) { VAR_6 = AVERROR_EOF; break; } temp = *data; lace_size[VAR_7] += temp; data += 1; VAR_2 -= 1; if (temp != 0xff) break; } total += lace_size[VAR_7]; } if (VAR_2 <= total) { VAR_6 = AVERROR_INVALIDDATA; break; } lace_size[VAR_7] = VAR_2 - total; break; } case 0x2: if (VAR_2 != (VAR_2 / *VAR_5) * VAR_2) { VAR_6 = AVERROR_INVALIDDATA; break; } for (VAR_7 = 0; VAR_7 < *VAR_5; VAR_7++) lace_size[VAR_7] = VAR_2 / *VAR_5; break; case 0x3: { uint64_t num; uint32_t total; VAR_7 = matroska_ebmlnum_uint(VAR_0, data, VAR_2, &num); if (VAR_7 < 0) { av_log(VAR_0->ctx, AV_LOG_INFO, "EBML block data error\VAR_7"); VAR_6 = VAR_7; break; } data += VAR_7; VAR_2 -= VAR_7; total = lace_size[0] = num; for (VAR_7 = 1; VAR_6 == 0 && VAR_7 < *VAR_5 - 1; VAR_7++) { int64_t snum; int VAR_8; VAR_8 = matroska_ebmlnum_sint(VAR_0, data, VAR_2, &snum); if (VAR_8 < 0) { av_log(VAR_0->ctx, AV_LOG_INFO, "EBML block data error\VAR_7"); VAR_6 = VAR_8; break; } data += VAR_8; VAR_2 -= VAR_8; lace_size[VAR_7] = lace_size[VAR_7 - 1] + snum; total += lace_size[VAR_7]; } if (VAR_2 <= total) { VAR_6 = AVERROR_INVALIDDATA; break; } lace_size[*VAR_5 - 1] = VAR_2 - total; break; } } *VAR_1 = data; *VAR_4 = lace_size; return VAR_6; }
[ "static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t **VAR_1,\nint VAR_2, int VAR_3,\nuint32_t **VAR_4, int *VAR_5)\n{", "int VAR_6 = 0, VAR_7;", "uint8_t *data = *VAR_1;", "uint32_t *lace_size;", "if (!VAR_3) {", "*VAR_5 = 1;", "*VAR_4 = av_mallocz(sizeof(int));", "if (!*VAR_4)\nreturn AVERROR(ENOMEM);", "*VAR_4[0] = VAR_2;", "return 0;", "}", "assert(VAR_2 > 0);", "*VAR_5 = *data + 1;", "data += 1;", "VAR_2 -= 1;", "lace_size = av_mallocz(*VAR_5 * sizeof(int));", "if (!lace_size)\nreturn AVERROR(ENOMEM);", "switch (VAR_3) {", "case 0x1: {", "uint8_t temp;", "uint32_t total = 0;", "for (VAR_7 = 0; VAR_6 == 0 && VAR_7 < *VAR_5 - 1; VAR_7++) {", "while (1) {", "if (VAR_2 == 0) {", "VAR_6 = AVERROR_EOF;", "break;", "}", "temp = *data;", "lace_size[VAR_7] += temp;", "data += 1;", "VAR_2 -= 1;", "if (temp != 0xff)\nbreak;", "}", "total += lace_size[VAR_7];", "}", "if (VAR_2 <= total) {", "VAR_6 = AVERROR_INVALIDDATA;", "break;", "}", "lace_size[VAR_7] = VAR_2 - total;", "break;", "}", "case 0x2:\nif (VAR_2 != (VAR_2 / *VAR_5) * VAR_2) {", "VAR_6 = AVERROR_INVALIDDATA;", "break;", "}", "for (VAR_7 = 0; VAR_7 < *VAR_5; VAR_7++)", "lace_size[VAR_7] = VAR_2 / *VAR_5;", "break;", "case 0x3: {", "uint64_t num;", "uint32_t total;", "VAR_7 = matroska_ebmlnum_uint(VAR_0, data, VAR_2, &num);", "if (VAR_7 < 0) {", "av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block data error\\VAR_7\");", "VAR_6 = VAR_7;", "break;", "}", "data += VAR_7;", "VAR_2 -= VAR_7;", "total = lace_size[0] = num;", "for (VAR_7 = 1; VAR_6 == 0 && VAR_7 < *VAR_5 - 1; VAR_7++) {", "int64_t snum;", "int VAR_8;", "VAR_8 = matroska_ebmlnum_sint(VAR_0, data, VAR_2, &snum);", "if (VAR_8 < 0) {", "av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block data error\\VAR_7\");", "VAR_6 = VAR_8;", "break;", "}", "data += VAR_8;", "VAR_2 -= VAR_8;", "lace_size[VAR_7] = lace_size[VAR_7 - 1] + snum;", "total += lace_size[VAR_7];", "}", "if (VAR_2 <= total) {", "VAR_6 = AVERROR_INVALIDDATA;", "break;", "}", "lace_size[*VAR_5 - 1] = VAR_2 - total;", "break;", "}", "}", "*VAR_1 = data;", "*VAR_4 = lace_size;", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ] ]
40
static int parse_picture_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { PGSSubContext *ctx = avctx->priv_data; uint8_t sequence_desc; unsigned int rle_bitmap_len, width, height; if (buf_size <= 4) return -1; buf_size -= 4; /* skip 3 unknown bytes: Object ID (2 bytes), Version Number */ buf += 3; /* Read the Sequence Description to determine if start of RLE data or appended to previous RLE */ sequence_desc = bytestream_get_byte(&buf); if (!(sequence_desc & 0x80)) { /* Additional RLE data */ if (buf_size > ctx->picture.rle_remaining_len) return -1; memcpy(ctx->picture.rle + ctx->picture.rle_data_len, buf, buf_size); ctx->picture.rle_data_len += buf_size; ctx->picture.rle_remaining_len -= buf_size; return 0; } if (buf_size <= 7) return -1; buf_size -= 7; /* Decode rle bitmap length, stored size includes width/height data */ rle_bitmap_len = bytestream_get_be24(&buf) - 2*2; /* Get bitmap dimensions from data */ width = bytestream_get_be16(&buf); height = bytestream_get_be16(&buf); /* Make sure the bitmap is not too large */ if (avctx->width < width || avctx->height < height) { av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; } ctx->picture.w = width; ctx->picture.h = height; av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, rle_bitmap_len); if (!ctx->picture.rle) return -1; memcpy(ctx->picture.rle, buf, buf_size); ctx->picture.rle_data_len = buf_size; ctx->picture.rle_remaining_len = rle_bitmap_len - buf_size; return 0; }
false
FFmpeg
d150a147dac67faeaf6b1f25a523ae330168ee1e
static int parse_picture_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { PGSSubContext *ctx = avctx->priv_data; uint8_t sequence_desc; unsigned int rle_bitmap_len, width, height; if (buf_size <= 4) return -1; buf_size -= 4; buf += 3; sequence_desc = bytestream_get_byte(&buf); if (!(sequence_desc & 0x80)) { if (buf_size > ctx->picture.rle_remaining_len) return -1; memcpy(ctx->picture.rle + ctx->picture.rle_data_len, buf, buf_size); ctx->picture.rle_data_len += buf_size; ctx->picture.rle_remaining_len -= buf_size; return 0; } if (buf_size <= 7) return -1; buf_size -= 7; rle_bitmap_len = bytestream_get_be24(&buf) - 2*2; width = bytestream_get_be16(&buf); height = bytestream_get_be16(&buf); if (avctx->width < width || avctx->height < height) { av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; } ctx->picture.w = width; ctx->picture.h = height; av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, rle_bitmap_len); if (!ctx->picture.rle) return -1; memcpy(ctx->picture.rle, buf, buf_size); ctx->picture.rle_data_len = buf_size; ctx->picture.rle_remaining_len = rle_bitmap_len - buf_size; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1, int VAR_2) { PGSSubContext *ctx = VAR_0->priv_data; uint8_t sequence_desc; unsigned int VAR_3, VAR_4, VAR_5; if (VAR_2 <= 4) return -1; VAR_2 -= 4; VAR_1 += 3; sequence_desc = bytestream_get_byte(&VAR_1); if (!(sequence_desc & 0x80)) { if (VAR_2 > ctx->picture.rle_remaining_len) return -1; memcpy(ctx->picture.rle + ctx->picture.rle_data_len, VAR_1, VAR_2); ctx->picture.rle_data_len += VAR_2; ctx->picture.rle_remaining_len -= VAR_2; return 0; } if (VAR_2 <= 7) return -1; VAR_2 -= 7; VAR_3 = bytestream_get_be24(&VAR_1) - 2*2; VAR_4 = bytestream_get_be16(&VAR_1); VAR_5 = bytestream_get_be16(&VAR_1); if (VAR_0->VAR_4 < VAR_4 || VAR_0->VAR_5 < VAR_5) { av_log(VAR_0, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; } ctx->picture.w = VAR_4; ctx->picture.h = VAR_5; av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, VAR_3); if (!ctx->picture.rle) return -1; memcpy(ctx->picture.rle, VAR_1, VAR_2); ctx->picture.rle_data_len = VAR_2; ctx->picture.rle_remaining_len = VAR_3 - VAR_2; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{", "PGSSubContext *ctx = VAR_0->priv_data;", "uint8_t sequence_desc;", "unsigned int VAR_3, VAR_4, VAR_5;", "if (VAR_2 <= 4)\nreturn -1;", "VAR_2 -= 4;", "VAR_1 += 3;", "sequence_desc = bytestream_get_byte(&VAR_1);", "if (!(sequence_desc & 0x80)) {", "if (VAR_2 > ctx->picture.rle_remaining_len)\nreturn -1;", "memcpy(ctx->picture.rle + ctx->picture.rle_data_len, VAR_1, VAR_2);", "ctx->picture.rle_data_len += VAR_2;", "ctx->picture.rle_remaining_len -= VAR_2;", "return 0;", "}", "if (VAR_2 <= 7)\nreturn -1;", "VAR_2 -= 7;", "VAR_3 = bytestream_get_be24(&VAR_1) - 2*2;", "VAR_4 = bytestream_get_be16(&VAR_1);", "VAR_5 = bytestream_get_be16(&VAR_1);", "if (VAR_0->VAR_4 < VAR_4 || VAR_0->VAR_5 < VAR_5) {", "av_log(VAR_0, AV_LOG_ERROR, \"Bitmap dimensions larger than video.\\n\");", "return -1;", "}", "ctx->picture.w = VAR_4;", "ctx->picture.h = VAR_5;", "av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, VAR_3);", "if (!ctx->picture.rle)\nreturn -1;", "memcpy(ctx->picture.rle, VAR_1, VAR_2);", "ctx->picture.rle_data_len = VAR_2;", "ctx->picture.rle_remaining_len = VAR_3 - VAR_2;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 21 ], [ 27 ], [ 33 ], [ 37 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 71 ], [ 77 ], [ 79 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 101 ], [ 105, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ] ]
41
void hmp_info_io_apic(Monitor *mon, const QDict *qdict) { if (kvm_irqchip_in_kernel()) { kvm_ioapic_dump_state(mon, qdict); } else { ioapic_dump_state(mon, qdict); } }
true
qemu
456d97d364e34adc4e68cbd51c2ad6ecd548492d
void hmp_info_io_apic(Monitor *mon, const QDict *qdict) { if (kvm_irqchip_in_kernel()) { kvm_ioapic_dump_state(mon, qdict); } else { ioapic_dump_state(mon, qdict); } }
{ "code": [ " if (kvm_irqchip_in_kernel()) {" ], "line_no": [ 5 ] }
void FUNC_0(Monitor *VAR_0, const QDict *VAR_1) { if (kvm_irqchip_in_kernel()) { kvm_ioapic_dump_state(VAR_0, VAR_1); } else { ioapic_dump_state(VAR_0, VAR_1); } }
[ "void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{", "if (kvm_irqchip_in_kernel()) {", "kvm_ioapic_dump_state(VAR_0, VAR_1);", "} else {", "ioapic_dump_state(VAR_0, VAR_1);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
42
static av_cold int split_init(AVFilterContext *ctx) { SplitContext *s = ctx->priv; int i; for (i = 0; i < s->nb_outputs; i++) { char name[32]; AVFilterPad pad = { 0 }; snprintf(name, sizeof(name), "output%d", i); pad.type = ctx->filter->inputs[0].type; pad.name = av_strdup(name); if (!pad.name) return AVERROR(ENOMEM); ff_insert_outpad(ctx, i, &pad); } return 0; }
true
FFmpeg
5e706a2afb09009bad49c4b12aaa997acf4491b1
static av_cold int split_init(AVFilterContext *ctx) { SplitContext *s = ctx->priv; int i; for (i = 0; i < s->nb_outputs; i++) { char name[32]; AVFilterPad pad = { 0 }; snprintf(name, sizeof(name), "output%d", i); pad.type = ctx->filter->inputs[0].type; pad.name = av_strdup(name); if (!pad.name) return AVERROR(ENOMEM); ff_insert_outpad(ctx, i, &pad); } return 0; }
{ "code": [ " int i;", " ff_insert_outpad(ctx, i, &pad);" ], "line_no": [ 7, 31 ] }
static av_cold int FUNC_0(AVFilterContext *ctx) { SplitContext *s = ctx->priv; int VAR_0; for (VAR_0 = 0; VAR_0 < s->nb_outputs; VAR_0++) { char name[32]; AVFilterPad pad = { 0 }; snprintf(name, sizeof(name), "output%d", VAR_0); pad.type = ctx->filter->inputs[0].type; pad.name = av_strdup(name); if (!pad.name) return AVERROR(ENOMEM); ff_insert_outpad(ctx, VAR_0, &pad); } return 0; }
[ "static av_cold int FUNC_0(AVFilterContext *ctx)\n{", "SplitContext *s = ctx->priv;", "int VAR_0;", "for (VAR_0 = 0; VAR_0 < s->nb_outputs; VAR_0++) {", "char name[32];", "AVFilterPad pad = { 0 };", "snprintf(name, sizeof(name), \"output%d\", VAR_0);", "pad.type = ctx->filter->inputs[0].type;", "pad.name = av_strdup(name);", "if (!pad.name)\nreturn AVERROR(ENOMEM);", "ff_insert_outpad(ctx, VAR_0, &pad);", "}", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ] ]
44
static void ide_set_signature(IDEState *s) { s->select &= 0xf0; /* clear head */ /* put signature */ s->nsector = 1; s->sector = 1; if (s->drive_kind == IDE_CD) { s->lcyl = 0x14; s->hcyl = 0xeb; } else if (s->bs) { s->lcyl = 0; s->hcyl = 0; } else { s->lcyl = 0xff; s->hcyl = 0xff; } }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void ide_set_signature(IDEState *s) { s->select &= 0xf0; s->nsector = 1; s->sector = 1; if (s->drive_kind == IDE_CD) { s->lcyl = 0x14; s->hcyl = 0xeb; } else if (s->bs) { s->lcyl = 0; s->hcyl = 0; } else { s->lcyl = 0xff; s->hcyl = 0xff; } }
{ "code": [], "line_no": [] }
static void FUNC_0(IDEState *VAR_0) { VAR_0->select &= 0xf0; VAR_0->nsector = 1; VAR_0->sector = 1; if (VAR_0->drive_kind == IDE_CD) { VAR_0->lcyl = 0x14; VAR_0->hcyl = 0xeb; } else if (VAR_0->bs) { VAR_0->lcyl = 0; VAR_0->hcyl = 0; } else { VAR_0->lcyl = 0xff; VAR_0->hcyl = 0xff; } }
[ "static void FUNC_0(IDEState *VAR_0)\n{", "VAR_0->select &= 0xf0;", "VAR_0->nsector = 1;", "VAR_0->sector = 1;", "if (VAR_0->drive_kind == IDE_CD) {", "VAR_0->lcyl = 0x14;", "VAR_0->hcyl = 0xeb;", "} else if (VAR_0->bs) {", "VAR_0->lcyl = 0;", "VAR_0->hcyl = 0;", "} else {", "VAR_0->lcyl = 0xff;", "VAR_0->hcyl = 0xff;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
45
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size) { MemoryRegion *mr = g_malloc(sizeof(*mr)); isa_mmio_setup(mr, size); memory_region_add_subregion(get_system_memory(), base, mr); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size) { MemoryRegion *mr = g_malloc(sizeof(*mr)); isa_mmio_setup(mr, size); memory_region_add_subregion(get_system_memory(), base, mr); }
{ "code": [], "line_no": [] }
void FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1) { MemoryRegion *mr = g_malloc(sizeof(*mr)); isa_mmio_setup(mr, VAR_1); memory_region_add_subregion(get_system_memory(), VAR_0, mr); }
[ "void FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1)\n{", "MemoryRegion *mr = g_malloc(sizeof(*mr));", "isa_mmio_setup(mr, VAR_1);", "memory_region_add_subregion(get_system_memory(), VAR_0, mr);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
46
static int find_allocation(BlockDriverState *bs, off_t start, off_t *data, off_t *hole) { BDRVGlusterState *s = bs->opaque; off_t offs; if (!s->supports_seek_data) { return -ENOTSUP; } /* * SEEK_DATA cases: * D1. offs == start: start is in data * D2. offs > start: start is in a hole, next data at offs * D3. offs < 0, errno = ENXIO: either start is in a trailing hole * or start is beyond EOF * If the latter happens, the file has been truncated behind * our back since we opened it. All bets are off then. * Treating like a trailing hole is simplest. * D4. offs < 0, errno != ENXIO: we learned nothing */ offs = glfs_lseek(s->fd, start, SEEK_DATA); if (offs < 0) { return -errno; /* D3 or D4 */ } assert(offs >= start); if (offs > start) { /* D2: in hole, next data at offs */ *hole = start; *data = offs; return 0; } /* D1: in data, end not yet known */ /* * SEEK_HOLE cases: * H1. offs == start: start is in a hole * If this happens here, a hole has been dug behind our back * since the previous lseek(). * H2. offs > start: either start is in data, next hole at offs, * or start is in trailing hole, EOF at offs * Linux treats trailing holes like any other hole: offs == * start. Solaris seeks to EOF instead: offs > start (blech). * If that happens here, a hole has been dug behind our back * since the previous lseek(). * H3. offs < 0, errno = ENXIO: start is beyond EOF * If this happens, the file has been truncated behind our * back since we opened it. Treat it like a trailing hole. * H4. offs < 0, errno != ENXIO: we learned nothing * Pretend we know nothing at all, i.e. "forget" about D1. */ offs = glfs_lseek(s->fd, start, SEEK_HOLE); if (offs < 0) { return -errno; /* D1 and (H3 or H4) */ } assert(offs >= start); if (offs > start) { /* * D1 and H2: either in data, next hole at offs, or it was in * data but is now in a trailing hole. In the latter case, * all bets are off. Treating it as if it there was data all * the way to EOF is safe, so simply do that. */ *data = start; *hole = offs; return 0; } /* D1 and H1 */ return -EBUSY; }
false
qemu
d9b789745b88df367674e45c55df29e9c7de8d8a
static int find_allocation(BlockDriverState *bs, off_t start, off_t *data, off_t *hole) { BDRVGlusterState *s = bs->opaque; off_t offs; if (!s->supports_seek_data) { return -ENOTSUP; } offs = glfs_lseek(s->fd, start, SEEK_DATA); if (offs < 0) { return -errno; } assert(offs >= start); if (offs > start) { *hole = start; *data = offs; return 0; } offs = glfs_lseek(s->fd, start, SEEK_HOLE); if (offs < 0) { return -errno; } assert(offs >= start); if (offs > start) { *data = start; *hole = offs; return 0; } return -EBUSY; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, off_t VAR_1, off_t *VAR_2, off_t *VAR_3) { BDRVGlusterState *s = VAR_0->opaque; off_t offs; if (!s->supports_seek_data) { return -ENOTSUP; } offs = glfs_lseek(s->fd, VAR_1, SEEK_DATA); if (offs < 0) { return -errno; } assert(offs >= VAR_1); if (offs > VAR_1) { *VAR_3 = VAR_1; *VAR_2 = offs; return 0; } offs = glfs_lseek(s->fd, VAR_1, SEEK_HOLE); if (offs < 0) { return -errno; } assert(offs >= VAR_1); if (offs > VAR_1) { *VAR_2 = VAR_1; *VAR_3 = offs; return 0; } return -EBUSY; }
[ "static int FUNC_0(BlockDriverState *VAR_0, off_t VAR_1,\noff_t *VAR_2, off_t *VAR_3)\n{", "BDRVGlusterState *s = VAR_0->opaque;", "off_t offs;", "if (!s->supports_seek_data) {", "return -ENOTSUP;", "}", "offs = glfs_lseek(s->fd, VAR_1, SEEK_DATA);", "if (offs < 0) {", "return -errno;", "}", "assert(offs >= VAR_1);", "if (offs > VAR_1) {", "*VAR_3 = VAR_1;", "*VAR_2 = offs;", "return 0;", "}", "offs = glfs_lseek(s->fd, VAR_1, SEEK_HOLE);", "if (offs < 0) {", "return -errno;", "}", "assert(offs >= VAR_1);", "if (offs > VAR_1) {", "*VAR_2 = VAR_1;", "*VAR_3 = offs;", "return 0;", "}", "return -EBUSY;", "}" ]
[ 0, 0, 0, 0, 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 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 147 ] ]
47
static void test_validate_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefTwo *udp = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', " "'dict1': { 'string1': 'string1', " "'dict2': { 'userdef': { 'integer': 42, " "'string': 'string' }, 'string': 'string2'}}}"); visit_type_UserDefTwo(v, NULL, &udp, &error_abort); qapi_free_UserDefTwo(udp); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
static void test_validate_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefTwo *udp = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', " "'dict1': { 'string1': 'string1', " "'dict2': { 'userdef': { 'integer': 42, " "'string': 'string' }, 'string': 'string2'}}}"); visit_type_UserDefTwo(v, NULL, &udp, &error_abort); qapi_free_UserDefTwo(udp); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestInputVisitorData *VAR_0, const void *VAR_1) { UserDefTwo *udp = NULL; Visitor *v; v = validate_test_init(VAR_0, "{ 'string0': 'string0', " "'dict1': { 'string1': 'string1', " "'dict2': { 'userdef': { 'integer': 42, " "'string': 'string' }, 'string': 'string2'}}}"); visit_type_UserDefTwo(v, NULL, &udp, &error_abort); qapi_free_UserDefTwo(udp); }
[ "static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "UserDefTwo *udp = NULL;", "Visitor *v;", "v = validate_test_init(VAR_0, \"{ 'string0': 'string0', \"", "\"'dict1': { 'string1': 'string1', \"", "\"'dict2': { 'userdef': { 'integer': 42, \"", "\"'string': 'string' }, 'string': 'string2'}}}\");", "visit_type_UserDefTwo(v, NULL, &udp, &error_abort);", "qapi_free_UserDefTwo(udp);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ] ]
48
void v9fs_device_unrealize_common(V9fsState *s, Error **errp) { g_free(s->ctx.fs_root); g_free(s->tag); }
false
qemu
4774718e5c194026ba5ee7a28d9be49be3080e42
void v9fs_device_unrealize_common(V9fsState *s, Error **errp) { g_free(s->ctx.fs_root); g_free(s->tag); }
{ "code": [], "line_no": [] }
void FUNC_0(V9fsState *VAR_0, Error **VAR_1) { g_free(VAR_0->ctx.fs_root); g_free(VAR_0->tag); }
[ "void FUNC_0(V9fsState *VAR_0, Error **VAR_1)\n{", "g_free(VAR_0->ctx.fs_root);", "g_free(VAR_0->tag);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
49
static int copy_moof(AVFormatContext *s, const char* infile, const char *outfile, int64_t size) { AVIOContext *in, *out; int ret = 0; if ((ret = avio_open2(&in, infile, AVIO_FLAG_READ, &s->interrupt_callback, NULL)) < 0) return ret; if ((ret = avio_open2(&out, outfile, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) { avio_close(in); return ret; } while (size > 0) { uint8_t buf[8192]; int n = FFMIN(size, sizeof(buf)); n = avio_read(in, buf, n); if (n <= 0) { ret = AVERROR(EIO); break; } avio_write(out, buf, n); size -= n; } avio_flush(out); avio_close(out); avio_close(in); return ret; }
false
FFmpeg
9f61abc8111c7c43f49ca012e957a108b9cc7610
static int copy_moof(AVFormatContext *s, const char* infile, const char *outfile, int64_t size) { AVIOContext *in, *out; int ret = 0; if ((ret = avio_open2(&in, infile, AVIO_FLAG_READ, &s->interrupt_callback, NULL)) < 0) return ret; if ((ret = avio_open2(&out, outfile, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) { avio_close(in); return ret; } while (size > 0) { uint8_t buf[8192]; int n = FFMIN(size, sizeof(buf)); n = avio_read(in, buf, n); if (n <= 0) { ret = AVERROR(EIO); break; } avio_write(out, buf, n); size -= n; } avio_flush(out); avio_close(out); avio_close(in); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, const char* VAR_1, const char *VAR_2, int64_t VAR_3) { AVIOContext *in, *out; int VAR_4 = 0; if ((VAR_4 = avio_open2(&in, VAR_1, AVIO_FLAG_READ, &VAR_0->interrupt_callback, NULL)) < 0) return VAR_4; if ((VAR_4 = avio_open2(&out, VAR_2, AVIO_FLAG_WRITE, &VAR_0->interrupt_callback, NULL)) < 0) { avio_close(in); return VAR_4; } while (VAR_3 > 0) { uint8_t buf[8192]; int VAR_5 = FFMIN(VAR_3, sizeof(buf)); VAR_5 = avio_read(in, buf, VAR_5); if (VAR_5 <= 0) { VAR_4 = AVERROR(EIO); break; } avio_write(out, buf, VAR_5); VAR_3 -= VAR_5; } avio_flush(out); avio_close(out); avio_close(in); return VAR_4; }
[ "static int FUNC_0(AVFormatContext *VAR_0, const char* VAR_1, const char *VAR_2, int64_t VAR_3)\n{", "AVIOContext *in, *out;", "int VAR_4 = 0;", "if ((VAR_4 = avio_open2(&in, VAR_1, AVIO_FLAG_READ, &VAR_0->interrupt_callback, NULL)) < 0)\nreturn VAR_4;", "if ((VAR_4 = avio_open2(&out, VAR_2, AVIO_FLAG_WRITE, &VAR_0->interrupt_callback, NULL)) < 0) {", "avio_close(in);", "return VAR_4;", "}", "while (VAR_3 > 0) {", "uint8_t buf[8192];", "int VAR_5 = FFMIN(VAR_3, sizeof(buf));", "VAR_5 = avio_read(in, buf, VAR_5);", "if (VAR_5 <= 0) {", "VAR_4 = AVERROR(EIO);", "break;", "}", "avio_write(out, buf, VAR_5);", "VAR_3 -= VAR_5;", "}", "avio_flush(out);", "avio_close(out);", "avio_close(in);", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ] ]
50
static int get_uint64_as_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint64_t *v = pv; *v = qemu_get_be32(f); return 0; }
false
qemu
08b277ac46da8b02e50cec455eca7cb2d12ffcf0
static int get_uint64_as_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint64_t *v = pv; *v = qemu_get_be32(f); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2, VMStateField *VAR_3) { uint64_t *v = VAR_1; *v = qemu_get_be32(VAR_0); return 0; }
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2,\nVMStateField *VAR_3)\n{", "uint64_t *v = VAR_1;", "*v = qemu_get_be32(VAR_0);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
52
void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { MemStatus *mdev; DeviceClass *dc = DEVICE_GET_CLASS(dev); if (!dc->hotpluggable) { return; } mdev = acpi_memory_slot_status(mem_st, dev, errp); if (!mdev) { return; } mdev->dimm = dev; mdev->is_enabled = true; if (dev->hotplugged) { mdev->is_inserting = true; acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS); } }
false
qemu
b097cc52fc9126bd1a71dae8302b8536d28104dd
void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { MemStatus *mdev; DeviceClass *dc = DEVICE_GET_CLASS(dev); if (!dc->hotpluggable) { return; } mdev = acpi_memory_slot_status(mem_st, dev, errp); if (!mdev) { return; } mdev->dimm = dev; mdev->is_enabled = true; if (dev->hotplugged) { mdev->is_inserting = true; acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS); } }
{ "code": [], "line_no": [] }
void FUNC_0(HotplugHandler *VAR_0, MemHotplugState *VAR_1, DeviceState *VAR_2, Error **VAR_3) { MemStatus *mdev; DeviceClass *dc = DEVICE_GET_CLASS(VAR_2); if (!dc->hotpluggable) { return; } mdev = acpi_memory_slot_status(VAR_1, VAR_2, VAR_3); if (!mdev) { return; } mdev->dimm = VAR_2; mdev->is_enabled = true; if (VAR_2->hotplugged) { mdev->is_inserting = true; acpi_send_event(DEVICE(VAR_0), ACPI_MEMORY_HOTPLUG_STATUS); } }
[ "void FUNC_0(HotplugHandler *VAR_0, MemHotplugState *VAR_1,\nDeviceState *VAR_2, Error **VAR_3)\n{", "MemStatus *mdev;", "DeviceClass *dc = DEVICE_GET_CLASS(VAR_2);", "if (!dc->hotpluggable) {", "return;", "}", "mdev = acpi_memory_slot_status(VAR_1, VAR_2, VAR_3);", "if (!mdev) {", "return;", "}", "mdev->dimm = VAR_2;", "mdev->is_enabled = true;", "if (VAR_2->hotplugged) {", "mdev->is_inserting = true;", "acpi_send_event(DEVICE(VAR_0), ACPI_MEMORY_HOTPLUG_STATUS);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
53
uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; hwaddr address_index; hwaddr address_offset; hwaddr cache_size = size; hwaddr test_bit_size; bool translated = false; tryagain: address_index = phys_addr >> MCACHE_BUCKET_SHIFT; address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); trace_xen_map_cache(phys_addr); /* test_bit_size is always a multiple of XC_PAGE_SIZE */ if (size) { test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1)); if (test_bit_size % XC_PAGE_SIZE) { test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE); } } else { test_bit_size = XC_PAGE_SIZE; } if (mapcache->last_entry != NULL && mapcache->last_entry->paddr_index == address_index && !lock && !size && test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; } /* size is always a multiple of MCACHE_BUCKET_SIZE */ if (size) { cache_size = size + address_offset; if (cache_size % MCACHE_BUCKET_SIZE) { cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE); } } else { cache_size = MCACHE_BUCKET_SIZE; } entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, cache_size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, cache_size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_entry = NULL; if (!translated && mapcache->phys_offset_to_gaddr) { phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque); translated = true; goto tryagain; } trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_entry = entry; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset; reventry->paddr_index = mapcache->last_entry->paddr_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; }
false
qemu
86a6a9bf551ffa183880480b37c5836d3916687a
uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; hwaddr address_index; hwaddr address_offset; hwaddr cache_size = size; hwaddr test_bit_size; bool translated = false; tryagain: address_index = phys_addr >> MCACHE_BUCKET_SHIFT; address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); trace_xen_map_cache(phys_addr); if (size) { test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1)); if (test_bit_size % XC_PAGE_SIZE) { test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE); } } else { test_bit_size = XC_PAGE_SIZE; } if (mapcache->last_entry != NULL && mapcache->last_entry->paddr_index == address_index && !lock && !size && test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; } if (size) { cache_size = size + address_offset; if (cache_size % MCACHE_BUCKET_SIZE) { cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE); } } else { cache_size = MCACHE_BUCKET_SIZE; } entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, cache_size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, cache_size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_entry = NULL; if (!translated && mapcache->phys_offset_to_gaddr) { phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque); translated = true; goto tryagain; } trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_entry = entry; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset; reventry->paddr_index = mapcache->last_entry->paddr_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; }
{ "code": [], "line_no": [] }
uint8_t *FUNC_0(hwaddr phys_addr, hwaddr size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; hwaddr address_index; hwaddr address_offset; hwaddr cache_size = size; hwaddr test_bit_size; bool translated = false; tryagain: address_index = phys_addr >> MCACHE_BUCKET_SHIFT; address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); trace_xen_map_cache(phys_addr); if (size) { test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1)); if (test_bit_size % XC_PAGE_SIZE) { test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE); } } else { test_bit_size = XC_PAGE_SIZE; } if (mapcache->last_entry != NULL && mapcache->last_entry->paddr_index == address_index && !lock && !size && test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; } if (size) { cache_size = size + address_offset; if (cache_size % MCACHE_BUCKET_SIZE) { cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE); } } else { cache_size = MCACHE_BUCKET_SIZE; } entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, cache_size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, cache_size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_entry = NULL; if (!translated && mapcache->phys_offset_to_gaddr) { phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque); translated = true; goto tryagain; } trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_entry = entry; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset; reventry->paddr_index = mapcache->last_entry->paddr_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; }
[ "uint8_t *FUNC_0(hwaddr phys_addr, hwaddr size,\nuint8_t lock)\n{", "MapCacheEntry *entry, *pentry = NULL;", "hwaddr address_index;", "hwaddr address_offset;", "hwaddr cache_size = size;", "hwaddr test_bit_size;", "bool translated = false;", "tryagain:\naddress_index = phys_addr >> MCACHE_BUCKET_SHIFT;", "address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);", "trace_xen_map_cache(phys_addr);", "if (size) {", "test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1));", "if (test_bit_size % XC_PAGE_SIZE) {", "test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE);", "}", "} else {", "test_bit_size = XC_PAGE_SIZE;", "}", "if (mapcache->last_entry != NULL &&\nmapcache->last_entry->paddr_index == address_index &&\n!lock && !size &&\ntest_bits(address_offset >> XC_PAGE_SHIFT,\ntest_bit_size >> XC_PAGE_SHIFT,\nmapcache->last_entry->valid_mapping)) {", "trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);", "return mapcache->last_entry->vaddr_base + address_offset;", "}", "if (size) {", "cache_size = size + address_offset;", "if (cache_size % MCACHE_BUCKET_SIZE) {", "cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE);", "}", "} else {", "cache_size = MCACHE_BUCKET_SIZE;", "}", "entry = &mapcache->entry[address_index % mapcache->nr_buckets];", "while (entry && entry->lock && entry->vaddr_base &&\n(entry->paddr_index != address_index || entry->size != cache_size ||\n!test_bits(address_offset >> XC_PAGE_SHIFT,\ntest_bit_size >> XC_PAGE_SHIFT,\nentry->valid_mapping))) {", "pentry = entry;", "entry = entry->next;", "}", "if (!entry) {", "entry = g_malloc0(sizeof (MapCacheEntry));", "pentry->next = entry;", "xen_remap_bucket(entry, cache_size, address_index);", "} else if (!entry->lock) {", "if (!entry->vaddr_base || entry->paddr_index != address_index ||\nentry->size != cache_size ||\n!test_bits(address_offset >> XC_PAGE_SHIFT,\ntest_bit_size >> XC_PAGE_SHIFT,\nentry->valid_mapping)) {", "xen_remap_bucket(entry, cache_size, address_index);", "}", "}", "if(!test_bits(address_offset >> XC_PAGE_SHIFT,\ntest_bit_size >> XC_PAGE_SHIFT,\nentry->valid_mapping)) {", "mapcache->last_entry = NULL;", "if (!translated && mapcache->phys_offset_to_gaddr) {", "phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque);", "translated = true;", "goto tryagain;", "}", "trace_xen_map_cache_return(NULL);", "return NULL;", "}", "mapcache->last_entry = entry;", "if (lock) {", "MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));", "entry->lock++;", "reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset;", "reventry->paddr_index = mapcache->last_entry->paddr_index;", "reventry->size = entry->size;", "QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);", "}", "trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);", "return mapcache->last_entry->vaddr_base + address_offset;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 29 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55, 57, 59, 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 99, 101, 103, 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125, 127, 129, 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 143, 145, 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ] ]
54
static void usb_hid_changed(HIDState *hs) { USBHIDState *us = container_of(hs, USBHIDState, hid); us->changed = 1; if (us->datain) { us->datain(us->datain_opaque); } usb_wakeup(&us->dev); }
false
qemu
38931fa8cfb074a08ce65fd1982bd4a5bef9d6fb
static void usb_hid_changed(HIDState *hs) { USBHIDState *us = container_of(hs, USBHIDState, hid); us->changed = 1; if (us->datain) { us->datain(us->datain_opaque); } usb_wakeup(&us->dev); }
{ "code": [], "line_no": [] }
static void FUNC_0(HIDState *VAR_0) { USBHIDState *us = container_of(VAR_0, USBHIDState, hid); us->changed = 1; if (us->datain) { us->datain(us->datain_opaque); } usb_wakeup(&us->dev); }
[ "static void FUNC_0(HIDState *VAR_0)\n{", "USBHIDState *us = container_of(VAR_0, USBHIDState, hid);", "us->changed = 1;", "if (us->datain) {", "us->datain(us->datain_opaque);", "}", "usb_wakeup(&us->dev);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ] ]
55
static int nbd_errno_to_system_errno(int err) { switch (err) { case NBD_SUCCESS: return 0; case NBD_EPERM: return EPERM; case NBD_EIO: return EIO; case NBD_ENOMEM: return ENOMEM; case NBD_ENOSPC: return ENOSPC; default: TRACE("Squashing unexpected error %d to EINVAL", err); /* fallthrough */ case NBD_EINVAL: return EINVAL; } }
false
qemu
8b34a9dbc3f2c0afe3450cb20b94cc30f450e77b
static int nbd_errno_to_system_errno(int err) { switch (err) { case NBD_SUCCESS: return 0; case NBD_EPERM: return EPERM; case NBD_EIO: return EIO; case NBD_ENOMEM: return ENOMEM; case NBD_ENOSPC: return ENOSPC; default: TRACE("Squashing unexpected error %d to EINVAL", err); case NBD_EINVAL: return EINVAL; } }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0) { switch (VAR_0) { case NBD_SUCCESS: return 0; case NBD_EPERM: return EPERM; case NBD_EIO: return EIO; case NBD_ENOMEM: return ENOMEM; case NBD_ENOSPC: return ENOSPC; default: TRACE("Squashing unexpected error %d to EINVAL", VAR_0); case NBD_EINVAL: return EINVAL; } }
[ "static int FUNC_0(int VAR_0)\n{", "switch (VAR_0) {", "case NBD_SUCCESS:\nreturn 0;", "case NBD_EPERM:\nreturn EPERM;", "case NBD_EIO:\nreturn EIO;", "case NBD_ENOMEM:\nreturn ENOMEM;", "case NBD_ENOSPC:\nreturn ENOSPC;", "default:\nTRACE(\"Squashing unexpected error %d to EINVAL\", VAR_0);", "case NBD_EINVAL:\nreturn EINVAL;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11, 13 ], [ 15, 17 ], [ 19, 21 ], [ 23, 25 ], [ 27, 29 ], [ 33, 35 ], [ 37 ], [ 39 ] ]
56
static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; *refcount_table = g_try_new0(uint16_t, *nb_clusters); if (*nb_clusters && *refcount_table == NULL) { res->check_errors++; return -ENOMEM; } /* header */ ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, 0, s->cluster_size); if (ret < 0) { return ret; } /* current L1 table */ ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO); if (ret < 0) { return ret; } /* snapshots */ for (i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, sn->l1_table_offset, sn->l1_size, 0); if (ret < 0) { return ret; } } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->snapshots_offset, s->snapshots_size); if (ret < 0) { return ret; } /* refcount data */ ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); if (ret < 0) { return ret; } return check_refblocks(bs, res, fix, refcount_table, nb_clusters); }
false
qemu
641bb63cd6b003ab0ca2e312a014449037d71647
static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; *refcount_table = g_try_new0(uint16_t, *nb_clusters); if (*nb_clusters && *refcount_table == NULL) { res->check_errors++; return -ENOMEM; } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, 0, s->cluster_size); if (ret < 0) { return ret; } ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO); if (ret < 0) { return ret; } for (i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, sn->l1_table_offset, sn->l1_size, 0); if (ret < 0) { return ret; } } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->snapshots_offset, s->snapshots_size); if (ret < 0) { return ret; } ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters, s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); if (ret < 0) { return ret; } return check_refblocks(bs, res, fix, refcount_table, nb_clusters); }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1, BdrvCheckMode VAR_2, uint16_t **VAR_3, int64_t *VAR_4) { BDRVQcowState *s = VAR_0->opaque; int64_t i; QCowSnapshot *sn; int VAR_5; *VAR_3 = g_try_new0(uint16_t, *VAR_4); if (*VAR_4 && *VAR_3 == NULL) { VAR_1->check_errors++; return -ENOMEM; } VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4, 0, s->cluster_size); if (VAR_5 < 0) { return VAR_5; } VAR_5 = check_refcounts_l1(VAR_0, VAR_1, *VAR_3, *VAR_4, s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO); if (VAR_5 < 0) { return VAR_5; } for (i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; VAR_5 = check_refcounts_l1(VAR_0, VAR_1, *VAR_3, *VAR_4, sn->l1_table_offset, sn->l1_size, 0); if (VAR_5 < 0) { return VAR_5; } } VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4, s->snapshots_offset, s->snapshots_size); if (VAR_5 < 0) { return VAR_5; } VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4, s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); if (VAR_5 < 0) { return VAR_5; } return check_refblocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); }
[ "static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nBdrvCheckMode VAR_2, uint16_t **VAR_3,\nint64_t *VAR_4)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int64_t i;", "QCowSnapshot *sn;", "int VAR_5;", "*VAR_3 = g_try_new0(uint16_t, *VAR_4);", "if (*VAR_4 && *VAR_3 == NULL) {", "VAR_1->check_errors++;", "return -ENOMEM;", "}", "VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4,\n0, s->cluster_size);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "VAR_5 = check_refcounts_l1(VAR_0, VAR_1, *VAR_3, *VAR_4,\ns->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "for (i = 0; i < s->nb_snapshots; i++) {", "sn = s->snapshots + i;", "VAR_5 = check_refcounts_l1(VAR_0, VAR_1, *VAR_3, *VAR_4,\nsn->l1_table_offset, sn->l1_size, 0);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "}", "VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4,\ns->snapshots_offset, s->snapshots_size);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "VAR_5 = inc_refcounts(VAR_0, VAR_1, *VAR_3, *VAR_4,\ns->refcount_table_offset,\ns->refcount_table_size * sizeof(uint64_t));", "if (VAR_5 < 0) {", "return VAR_5;", "}", "return check_refblocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 91, 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ] ]
57
void aio_context_setup(AioContext *ctx) { }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
void aio_context_setup(AioContext *ctx) { }
{ "code": [], "line_no": [] }
void FUNC_0(AioContext *VAR_0) { }
[ "void FUNC_0(AioContext *VAR_0)\n{", "}" ]
[ 0, 0 ]
[ [ 1, 3 ], [ 5 ] ]
58
static uint64_t timer_read(void *opaque, target_phys_addr_t addr, unsigned size) { LM32TimerState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_SR: case R_CR: case R_PERIOD: r = s->regs[addr]; break; case R_SNAPSHOT: r = (uint32_t)ptimer_get_count(s->ptimer); break; default: error_report("lm32_timer: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_lm32_timer_memory_read(addr << 2, r); return r; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t timer_read(void *opaque, target_phys_addr_t addr, unsigned size) { LM32TimerState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_SR: case R_CR: case R_PERIOD: r = s->regs[addr]; break; case R_SNAPSHOT: r = (uint32_t)ptimer_get_count(s->ptimer); break; default: error_report("lm32_timer: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_lm32_timer_memory_read(addr << 2, r); return r; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { LM32TimerState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_SR: case R_CR: case R_PERIOD: r = s->regs[addr]; break; case R_SNAPSHOT: r = (uint32_t)ptimer_get_count(s->ptimer); break; default: error_report("lm32_timer: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_lm32_timer_memory_read(addr << 2, r); return r; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size)\n{", "LM32TimerState *s = opaque;", "uint32_t r = 0;", "addr >>= 2;", "switch (addr) {", "case R_SR:\ncase R_CR:\ncase R_PERIOD:\nr = s->regs[addr];", "break;", "case R_SNAPSHOT:\nr = (uint32_t)ptimer_get_count(s->ptimer);", "break;", "default:\nerror_report(\"lm32_timer: read access to unknown register 0x\"\nTARGET_FMT_plx, addr << 2);", "break;", "}", "trace_lm32_timer_memory_read(addr << 2, r);", "return r;", "}" ]
[ 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 ], [ 43 ], [ 45 ], [ 47 ] ]
59
void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIRequest *sreq = req->sreq; if (scsi_req_enqueue(sreq)) { scsi_req_continue(sreq); } bdrv_io_unplug(sreq->dev->conf.bs); scsi_req_unref(sreq); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIRequest *sreq = req->sreq; if (scsi_req_enqueue(sreq)) { scsi_req_continue(sreq); } bdrv_io_unplug(sreq->dev->conf.bs); scsi_req_unref(sreq); }
{ "code": [], "line_no": [] }
void FUNC_0(VirtIOSCSI *VAR_0, VirtIOSCSIReq *VAR_1) { SCSIRequest *sreq = VAR_1->sreq; if (scsi_req_enqueue(sreq)) { scsi_req_continue(sreq); } bdrv_io_unplug(sreq->dev->conf.bs); scsi_req_unref(sreq); }
[ "void FUNC_0(VirtIOSCSI *VAR_0, VirtIOSCSIReq *VAR_1)\n{", "SCSIRequest *sreq = VAR_1->sreq;", "if (scsi_req_enqueue(sreq)) {", "scsi_req_continue(sreq);", "}", "bdrv_io_unplug(sreq->dev->conf.bs);", "scsi_req_unref(sreq);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
61
static int truespeech_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TSContext *c = avctx->priv_data; int i, j; short *samples = data; int consumed = 0; int16_t out_buf[240]; int iterations; if (!buf_size) return 0; if (buf_size < 32) { av_log(avctx, AV_LOG_ERROR, "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size); return -1; } iterations = FFMIN(buf_size / 32, *data_size / 480); for(j = 0; j < iterations; j++) { truespeech_read_frame(c, buf + consumed); consumed += 32; truespeech_correlate_filter(c); truespeech_filters_merge(c); memset(out_buf, 0, 240 * 2); for(i = 0; i < 4; i++) { truespeech_apply_twopoint_filter(c, i); truespeech_place_pulses(c, out_buf + i * 60, i); truespeech_update_filters(c, out_buf + i * 60, i); truespeech_synth(c, out_buf + i * 60, i); } truespeech_save_prevvec(c); /* finally output decoded frame */ for(i = 0; i < 240; i++) *samples++ = out_buf[i]; } *data_size = consumed * 15; return consumed; }
false
FFmpeg
595cf1a1aa09f6214eed57bd9eb6493456918efe
static int truespeech_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TSContext *c = avctx->priv_data; int i, j; short *samples = data; int consumed = 0; int16_t out_buf[240]; int iterations; if (!buf_size) return 0; if (buf_size < 32) { av_log(avctx, AV_LOG_ERROR, "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size); return -1; } iterations = FFMIN(buf_size / 32, *data_size / 480); for(j = 0; j < iterations; j++) { truespeech_read_frame(c, buf + consumed); consumed += 32; truespeech_correlate_filter(c); truespeech_filters_merge(c); memset(out_buf, 0, 240 * 2); for(i = 0; i < 4; i++) { truespeech_apply_twopoint_filter(c, i); truespeech_place_pulses(c, out_buf + i * 60, i); truespeech_update_filters(c, out_buf + i * 60, i); truespeech_synth(c, out_buf + i * 60, i); } truespeech_save_prevvec(c); for(i = 0; i < 240; i++) *samples++ = out_buf[i]; } *data_size = consumed * 15; return consumed; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; TSContext *c = VAR_0->priv_data; int VAR_6, VAR_7; short *VAR_8 = VAR_1; int VAR_9 = 0; int16_t out_buf[240]; int VAR_10; if (!VAR_5) return 0; if (VAR_5 < 32) { av_log(VAR_0, AV_LOG_ERROR, "Too small input buffer (%d bytes), need at least 32 bytes\n", VAR_5); return -1; } VAR_10 = FFMIN(VAR_5 / 32, *VAR_2 / 480); for(VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) { truespeech_read_frame(c, VAR_4 + VAR_9); VAR_9 += 32; truespeech_correlate_filter(c); truespeech_filters_merge(c); memset(out_buf, 0, 240 * 2); for(VAR_6 = 0; VAR_6 < 4; VAR_6++) { truespeech_apply_twopoint_filter(c, VAR_6); truespeech_place_pulses(c, out_buf + VAR_6 * 60, VAR_6); truespeech_update_filters(c, out_buf + VAR_6 * 60, VAR_6); truespeech_synth(c, out_buf + VAR_6 * 60, VAR_6); } truespeech_save_prevvec(c); for(VAR_6 = 0; VAR_6 < 240; VAR_6++) *VAR_8++ = out_buf[VAR_6]; } *VAR_2 = VAR_9 * 15; return VAR_9; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "TSContext *c = VAR_0->priv_data;", "int VAR_6, VAR_7;", "short *VAR_8 = VAR_1;", "int VAR_9 = 0;", "int16_t out_buf[240];", "int VAR_10;", "if (!VAR_5)\nreturn 0;", "if (VAR_5 < 32) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Too small input buffer (%d bytes), need at least 32 bytes\\n\", VAR_5);", "return -1;", "}", "VAR_10 = FFMIN(VAR_5 / 32, *VAR_2 / 480);", "for(VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) {", "truespeech_read_frame(c, VAR_4 + VAR_9);", "VAR_9 += 32;", "truespeech_correlate_filter(c);", "truespeech_filters_merge(c);", "memset(out_buf, 0, 240 * 2);", "for(VAR_6 = 0; VAR_6 < 4; VAR_6++) {", "truespeech_apply_twopoint_filter(c, VAR_6);", "truespeech_place_pulses(c, out_buf + VAR_6 * 60, VAR_6);", "truespeech_update_filters(c, out_buf + VAR_6 * 60, VAR_6);", "truespeech_synth(c, out_buf + VAR_6 * 60, VAR_6);", "}", "truespeech_save_prevvec(c);", "for(VAR_6 = 0; VAR_6 < 240; VAR_6++)", "*VAR_8++ = out_buf[VAR_6];", "}", "*VAR_2 = VAR_9 * 15;", "return VAR_9;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 83 ], [ 85 ], [ 89 ], [ 93 ], [ 97 ], [ 99 ] ]
63
static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, const uint8_t * src) { uint8_t *dst; dst = s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask); if (blit_is_unsafe(s, false)) return 0; (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); return 1; }
false
qemu
5858dd1801883309bdd208d72ddb81c4e9fee30c
static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, const uint8_t * src) { uint8_t *dst; dst = s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask); if (blit_is_unsafe(s, false)) return 0; (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); return 1; }
{ "code": [], "line_no": [] }
static int FUNC_0(CirrusVGAState * VAR_0, const uint8_t * VAR_1) { uint8_t *dst; dst = VAR_0->vga.vram_ptr + (VAR_0->cirrus_blt_dstaddr & VAR_0->cirrus_addr_mask); if (blit_is_unsafe(VAR_0, false)) return 0; (*VAR_0->cirrus_rop) (VAR_0, dst, VAR_1, VAR_0->cirrus_blt_dstpitch, 0, VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height); cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr, VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height); return 1; }
[ "static int FUNC_0(CirrusVGAState * VAR_0,\nconst uint8_t * VAR_1)\n{", "uint8_t *dst;", "dst = VAR_0->vga.vram_ptr + (VAR_0->cirrus_blt_dstaddr & VAR_0->cirrus_addr_mask);", "if (blit_is_unsafe(VAR_0, false))\nreturn 0;", "(*VAR_0->cirrus_rop) (VAR_0, dst, VAR_1,\nVAR_0->cirrus_blt_dstpitch, 0,\nVAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);", "cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,\nVAR_0->cirrus_blt_height);", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 15, 17 ], [ 21, 23, 25 ], [ 27, 29, 31 ], [ 33 ], [ 35 ] ]
64
static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uint64_t end_offset, void **p_feature_table, int flags, Error **errp) { BDRVQcow2State *s = bs->opaque; QCowExtension ext; uint64_t offset; int ret; #ifdef DEBUG_EXT printf("qcow2_read_extensions: start=%ld end=%ld\n", start_offset, end_offset); #endif offset = start_offset; while (offset < end_offset) { #ifdef DEBUG_EXT /* Sanity check */ if (offset > s->cluster_size) printf("qcow2_read_extension: suspicious offset %lu\n", offset); printf("attempting to read extended header in offset %lu\n", offset); #endif ret = bdrv_pread(bs->file, offset, &ext, sizeof(ext)); if (ret < 0) { error_setg_errno(errp, -ret, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); return 1; } be32_to_cpus(&ext.magic); be32_to_cpus(&ext.len); offset += sizeof(ext); #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); #endif if (offset > end_offset || ext.len > end_offset - offset) { error_setg(errp, "Header extension too large"); return -EINVAL; } switch (ext.magic) { case QCOW2_EXT_MAGIC_END: return 0; case QCOW2_EXT_MAGIC_BACKING_FORMAT: if (ext.len >= sizeof(bs->backing_format)) { error_setg(errp, "ERROR: ext_backing_format: len=%" PRIu32 " too large (>=%zu)", ext.len, sizeof(bs->backing_format)); return 2; } ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_backing_format: " "Could not read format name"); return 3; } bs->backing_format[ext.len] = '\0'; s->image_backing_format = g_strdup(bs->backing_format); #ifdef DEBUG_EXT printf("Qcow2: Got format extension %s\n", bs->backing_format); #endif break; case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table != NULL) { void* feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature)); ret = bdrv_pread(bs->file, offset , feature_table, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_feature_table: " "Could not read table"); return ret; } *p_feature_table = feature_table; } break; case QCOW2_EXT_MAGIC_CRYPTO_HEADER: { unsigned int cflags = 0; if (s->crypt_method_header != QCOW_CRYPT_LUKS) { error_setg(errp, "CRYPTO header extension only " "expected with LUKS encryption method"); return -EINVAL; } if (ext.len != sizeof(Qcow2CryptoHeaderExtension)) { error_setg(errp, "CRYPTO header extension size %u, " "but expected size %zu", ext.len, sizeof(Qcow2CryptoHeaderExtension)); return -EINVAL; } ret = bdrv_pread(bs->file, offset, &s->crypto_header, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read CRYPTO header extension"); return ret; } be64_to_cpus(&s->crypto_header.offset); be64_to_cpus(&s->crypto_header.length); if ((s->crypto_header.offset % s->cluster_size) != 0) { error_setg(errp, "Encryption header offset '%" PRIu64 "' is " "not a multiple of cluster size '%u'", s->crypto_header.offset, s->cluster_size); return -EINVAL; } if (flags & BDRV_O_NO_IO) { cflags |= QCRYPTO_BLOCK_OPEN_NO_IO; } s->crypto = qcrypto_block_open(s->crypto_opts, "encrypt.", qcow2_crypto_hdr_read_func, bs, cflags, errp); if (!s->crypto) { return -EINVAL; } } break; default: /* unknown magic - save it in case we need to rewrite the header */ { Qcow2UnknownHeaderExtension *uext; uext = g_malloc0(sizeof(*uext) + ext.len); uext->magic = ext.magic; uext->len = ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); ret = bdrv_pread(bs->file, offset , uext->data, uext->len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: unknown extension: " "Could not read data"); return ret; } } break; } offset += ((ext.len + 7) & ~7); } return 0; }
false
qemu
88ddffae8fc1e30cc907c2dbb989b7eba9e62319
static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uint64_t end_offset, void **p_feature_table, int flags, Error **errp) { BDRVQcow2State *s = bs->opaque; QCowExtension ext; uint64_t offset; int ret; #ifdef DEBUG_EXT printf("qcow2_read_extensions: start=%ld end=%ld\n", start_offset, end_offset); #endif offset = start_offset; while (offset < end_offset) { #ifdef DEBUG_EXT if (offset > s->cluster_size) printf("qcow2_read_extension: suspicious offset %lu\n", offset); printf("attempting to read extended header in offset %lu\n", offset); #endif ret = bdrv_pread(bs->file, offset, &ext, sizeof(ext)); if (ret < 0) { error_setg_errno(errp, -ret, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); return 1; } be32_to_cpus(&ext.magic); be32_to_cpus(&ext.len); offset += sizeof(ext); #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); #endif if (offset > end_offset || ext.len > end_offset - offset) { error_setg(errp, "Header extension too large"); return -EINVAL; } switch (ext.magic) { case QCOW2_EXT_MAGIC_END: return 0; case QCOW2_EXT_MAGIC_BACKING_FORMAT: if (ext.len >= sizeof(bs->backing_format)) { error_setg(errp, "ERROR: ext_backing_format: len=%" PRIu32 " too large (>=%zu)", ext.len, sizeof(bs->backing_format)); return 2; } ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_backing_format: " "Could not read format name"); return 3; } bs->backing_format[ext.len] = '\0'; s->image_backing_format = g_strdup(bs->backing_format); #ifdef DEBUG_EXT printf("Qcow2: Got format extension %s\n", bs->backing_format); #endif break; case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table != NULL) { void* feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature)); ret = bdrv_pread(bs->file, offset , feature_table, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_feature_table: " "Could not read table"); return ret; } *p_feature_table = feature_table; } break; case QCOW2_EXT_MAGIC_CRYPTO_HEADER: { unsigned int cflags = 0; if (s->crypt_method_header != QCOW_CRYPT_LUKS) { error_setg(errp, "CRYPTO header extension only " "expected with LUKS encryption method"); return -EINVAL; } if (ext.len != sizeof(Qcow2CryptoHeaderExtension)) { error_setg(errp, "CRYPTO header extension size %u, " "but expected size %zu", ext.len, sizeof(Qcow2CryptoHeaderExtension)); return -EINVAL; } ret = bdrv_pread(bs->file, offset, &s->crypto_header, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read CRYPTO header extension"); return ret; } be64_to_cpus(&s->crypto_header.offset); be64_to_cpus(&s->crypto_header.length); if ((s->crypto_header.offset % s->cluster_size) != 0) { error_setg(errp, "Encryption header offset '%" PRIu64 "' is " "not a multiple of cluster size '%u'", s->crypto_header.offset, s->cluster_size); return -EINVAL; } if (flags & BDRV_O_NO_IO) { cflags |= QCRYPTO_BLOCK_OPEN_NO_IO; } s->crypto = qcrypto_block_open(s->crypto_opts, "encrypt.", qcow2_crypto_hdr_read_func, bs, cflags, errp); if (!s->crypto) { return -EINVAL; } } break; default: { Qcow2UnknownHeaderExtension *uext; uext = g_malloc0(sizeof(*uext) + ext.len); uext->magic = ext.magic; uext->len = ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); ret = bdrv_pread(bs->file, offset , uext->data, uext->len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: unknown extension: " "Could not read data"); return ret; } } break; } offset += ((ext.len + 7) & ~7); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2, void **VAR_3, int VAR_4, Error **VAR_5) { BDRVQcow2State *s = VAR_0->opaque; QCowExtension ext; uint64_t offset; int VAR_6; #ifdef DEBUG_EXT printf("FUNC_0: start=%ld end=%ld\n", VAR_1, VAR_2); #endif offset = VAR_1; while (offset < VAR_2) { #ifdef DEBUG_EXT if (offset > s->cluster_size) printf("qcow2_read_extension: suspicious offset %lu\n", offset); printf("attempting to read extended header in offset %lu\n", offset); #endif VAR_6 = bdrv_pread(VAR_0->file, offset, &ext, sizeof(ext)); if (VAR_6 < 0) { error_setg_errno(VAR_5, -VAR_6, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); return 1; } be32_to_cpus(&ext.magic); be32_to_cpus(&ext.len); offset += sizeof(ext); #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); #endif if (offset > VAR_2 || ext.len > VAR_2 - offset) { error_setg(VAR_5, "Header extension too large"); return -EINVAL; } switch (ext.magic) { case QCOW2_EXT_MAGIC_END: return 0; case QCOW2_EXT_MAGIC_BACKING_FORMAT: if (ext.len >= sizeof(VAR_0->backing_format)) { error_setg(VAR_5, "ERROR: ext_backing_format: len=%" PRIu32 " too large (>=%zu)", ext.len, sizeof(VAR_0->backing_format)); return 2; } VAR_6 = bdrv_pread(VAR_0->file, offset, VAR_0->backing_format, ext.len); if (VAR_6 < 0) { error_setg_errno(VAR_5, -VAR_6, "ERROR: ext_backing_format: " "Could not read format name"); return 3; } VAR_0->backing_format[ext.len] = '\0'; s->image_backing_format = g_strdup(VAR_0->backing_format); #ifdef DEBUG_EXT printf("Qcow2: Got format extension %s\n", VAR_0->backing_format); #endif break; case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (VAR_3 != NULL) { void* VAR_7 = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature)); VAR_6 = bdrv_pread(VAR_0->file, offset , VAR_7, ext.len); if (VAR_6 < 0) { error_setg_errno(VAR_5, -VAR_6, "ERROR: ext_feature_table: " "Could not read table"); return VAR_6; } *VAR_3 = VAR_7; } break; case QCOW2_EXT_MAGIC_CRYPTO_HEADER: { unsigned int VAR_8 = 0; if (s->crypt_method_header != QCOW_CRYPT_LUKS) { error_setg(VAR_5, "CRYPTO header extension only " "expected with LUKS encryption method"); return -EINVAL; } if (ext.len != sizeof(Qcow2CryptoHeaderExtension)) { error_setg(VAR_5, "CRYPTO header extension size %u, " "but expected size %zu", ext.len, sizeof(Qcow2CryptoHeaderExtension)); return -EINVAL; } VAR_6 = bdrv_pread(VAR_0->file, offset, &s->crypto_header, ext.len); if (VAR_6 < 0) { error_setg_errno(VAR_5, -VAR_6, "Unable to read CRYPTO header extension"); return VAR_6; } be64_to_cpus(&s->crypto_header.offset); be64_to_cpus(&s->crypto_header.length); if ((s->crypto_header.offset % s->cluster_size) != 0) { error_setg(VAR_5, "Encryption header offset '%" PRIu64 "' is " "not a multiple of cluster size '%u'", s->crypto_header.offset, s->cluster_size); return -EINVAL; } if (VAR_4 & BDRV_O_NO_IO) { VAR_8 |= QCRYPTO_BLOCK_OPEN_NO_IO; } s->crypto = qcrypto_block_open(s->crypto_opts, "encrypt.", qcow2_crypto_hdr_read_func, VAR_0, VAR_8, VAR_5); if (!s->crypto) { return -EINVAL; } } break; default: { Qcow2UnknownHeaderExtension *uext; uext = g_malloc0(sizeof(*uext) + ext.len); uext->magic = ext.magic; uext->len = ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); VAR_6 = bdrv_pread(VAR_0->file, offset , uext->data, uext->len); if (VAR_6 < 0) { error_setg_errno(VAR_5, -VAR_6, "ERROR: unknown extension: " "Could not read data"); return VAR_6; } } break; } offset += ((ext.len + 7) & ~7); } return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t VAR_2, void **VAR_3,\nint VAR_4, Error **VAR_5)\n{", "BDRVQcow2State *s = VAR_0->opaque;", "QCowExtension ext;", "uint64_t offset;", "int VAR_6;", "#ifdef DEBUG_EXT\nprintf(\"FUNC_0: start=%ld end=%ld\\n\", VAR_1, VAR_2);", "#endif\noffset = VAR_1;", "while (offset < VAR_2) {", "#ifdef DEBUG_EXT\nif (offset > s->cluster_size)\nprintf(\"qcow2_read_extension: suspicious offset %lu\\n\", offset);", "printf(\"attempting to read extended header in offset %lu\\n\", offset);", "#endif\nVAR_6 = bdrv_pread(VAR_0->file, offset, &ext, sizeof(ext));", "if (VAR_6 < 0) {", "error_setg_errno(VAR_5, -VAR_6, \"qcow2_read_extension: ERROR: \"\n\"pread fail from offset %\" PRIu64, offset);", "return 1;", "}", "be32_to_cpus(&ext.magic);", "be32_to_cpus(&ext.len);", "offset += sizeof(ext);", "#ifdef DEBUG_EXT\nprintf(\"ext.magic = 0x%x\\n\", ext.magic);", "#endif\nif (offset > VAR_2 || ext.len > VAR_2 - offset) {", "error_setg(VAR_5, \"Header extension too large\");", "return -EINVAL;", "}", "switch (ext.magic) {", "case QCOW2_EXT_MAGIC_END:\nreturn 0;", "case QCOW2_EXT_MAGIC_BACKING_FORMAT:\nif (ext.len >= sizeof(VAR_0->backing_format)) {", "error_setg(VAR_5, \"ERROR: ext_backing_format: len=%\" PRIu32\n\" too large (>=%zu)\", ext.len,\nsizeof(VAR_0->backing_format));", "return 2;", "}", "VAR_6 = bdrv_pread(VAR_0->file, offset, VAR_0->backing_format, ext.len);", "if (VAR_6 < 0) {", "error_setg_errno(VAR_5, -VAR_6, \"ERROR: ext_backing_format: \"\n\"Could not read format name\");", "return 3;", "}", "VAR_0->backing_format[ext.len] = '\\0';", "s->image_backing_format = g_strdup(VAR_0->backing_format);", "#ifdef DEBUG_EXT\nprintf(\"Qcow2: Got format extension %s\\n\", VAR_0->backing_format);", "#endif\nbreak;", "case QCOW2_EXT_MAGIC_FEATURE_TABLE:\nif (VAR_3 != NULL) {", "void* VAR_7 = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature));", "VAR_6 = bdrv_pread(VAR_0->file, offset , VAR_7, ext.len);", "if (VAR_6 < 0) {", "error_setg_errno(VAR_5, -VAR_6, \"ERROR: ext_feature_table: \"\n\"Could not read table\");", "return VAR_6;", "}", "*VAR_3 = VAR_7;", "}", "break;", "case QCOW2_EXT_MAGIC_CRYPTO_HEADER: {", "unsigned int VAR_8 = 0;", "if (s->crypt_method_header != QCOW_CRYPT_LUKS) {", "error_setg(VAR_5, \"CRYPTO header extension only \"\n\"expected with LUKS encryption method\");", "return -EINVAL;", "}", "if (ext.len != sizeof(Qcow2CryptoHeaderExtension)) {", "error_setg(VAR_5, \"CRYPTO header extension size %u, \"\n\"but expected size %zu\", ext.len,\nsizeof(Qcow2CryptoHeaderExtension));", "return -EINVAL;", "}", "VAR_6 = bdrv_pread(VAR_0->file, offset, &s->crypto_header, ext.len);", "if (VAR_6 < 0) {", "error_setg_errno(VAR_5, -VAR_6,\n\"Unable to read CRYPTO header extension\");", "return VAR_6;", "}", "be64_to_cpus(&s->crypto_header.offset);", "be64_to_cpus(&s->crypto_header.length);", "if ((s->crypto_header.offset % s->cluster_size) != 0) {", "error_setg(VAR_5, \"Encryption header offset '%\" PRIu64 \"' is \"\n\"not a multiple of cluster size '%u'\",\ns->crypto_header.offset, s->cluster_size);", "return -EINVAL;", "}", "if (VAR_4 & BDRV_O_NO_IO) {", "VAR_8 |= QCRYPTO_BLOCK_OPEN_NO_IO;", "}", "s->crypto = qcrypto_block_open(s->crypto_opts, \"encrypt.\",\nqcow2_crypto_hdr_read_func,\nVAR_0, VAR_8, VAR_5);", "if (!s->crypto) {", "return -EINVAL;", "}", "} break;", "default:\n{", "Qcow2UnknownHeaderExtension *uext;", "uext = g_malloc0(sizeof(*uext) + ext.len);", "uext->magic = ext.magic;", "uext->len = ext.len;", "QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next);", "VAR_6 = bdrv_pread(VAR_0->file, offset , uext->data, uext->len);", "if (VAR_6 < 0) {", "error_setg_errno(VAR_5, -VAR_6, \"ERROR: unknown extension: \"\n\"Could not read data\");", "return VAR_6;", "}", "}", "break;", "}", "offset += ((ext.len + 7) & ~7);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 31, 35, 37 ], [ 41 ], [ 43, 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 89, 91 ], [ 93, 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123, 125 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173, 175, 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205, 207, 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223, 225, 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239, 243 ], [ 245 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279 ], [ 281 ], [ 285 ], [ 287 ] ]
65
static void listener_add_address_space(MemoryListener *listener, AddressSpace *as) { FlatView *view; FlatRange *fr; if (listener->address_space_filter && listener->address_space_filter != as) { return; } if (global_dirty_log) { if (listener->log_global_start) { listener->log_global_start(listener); } } view = as->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = { .mr = fr->mr, .address_space = as, .offset_within_region = fr->offset_in_region, .size = fr->addr.size, .offset_within_address_space = int128_get64(fr->addr.start), .readonly = fr->readonly, }; if (listener->region_add) { listener->region_add(listener, &section); } } }
false
qemu
856d72454f03aea26fd61c728762ef9cd1d71512
static void listener_add_address_space(MemoryListener *listener, AddressSpace *as) { FlatView *view; FlatRange *fr; if (listener->address_space_filter && listener->address_space_filter != as) { return; } if (global_dirty_log) { if (listener->log_global_start) { listener->log_global_start(listener); } } view = as->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = { .mr = fr->mr, .address_space = as, .offset_within_region = fr->offset_in_region, .size = fr->addr.size, .offset_within_address_space = int128_get64(fr->addr.start), .readonly = fr->readonly, }; if (listener->region_add) { listener->region_add(listener, &section); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(MemoryListener *VAR_0, AddressSpace *VAR_1) { FlatView *view; FlatRange *fr; if (VAR_0->address_space_filter && VAR_0->address_space_filter != VAR_1) { return; } if (global_dirty_log) { if (VAR_0->log_global_start) { VAR_0->log_global_start(VAR_0); } } view = VAR_1->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = { .mr = fr->mr, .address_space = VAR_1, .offset_within_region = fr->offset_in_region, .size = fr->addr.size, .offset_within_address_space = int128_get64(fr->addr.start), .readonly = fr->readonly, }; if (VAR_0->region_add) { VAR_0->region_add(VAR_0, &section); } } }
[ "static void FUNC_0(MemoryListener *VAR_0,\nAddressSpace *VAR_1)\n{", "FlatView *view;", "FlatRange *fr;", "if (VAR_0->address_space_filter\n&& VAR_0->address_space_filter != VAR_1) {", "return;", "}", "if (global_dirty_log) {", "if (VAR_0->log_global_start) {", "VAR_0->log_global_start(VAR_0);", "}", "}", "view = VAR_1->current_map;", "FOR_EACH_FLAT_RANGE(fr, view) {", "MemoryRegionSection section = {", ".mr = fr->mr,\n.address_space = VAR_1,\n.offset_within_region = fr->offset_in_region,\n.size = fr->addr.size,\n.offset_within_address_space = int128_get64(fr->addr.start),\n.readonly = fr->readonly,\n};", "if (VAR_0->region_add) {", "VAR_0->region_add(VAR_0, &section);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43, 45, 47, 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ] ]
66
long do_sigreturn(CPUM68KState *env) { struct target_sigframe *frame; abi_ulong frame_addr = env->aregs[7] - 4; target_sigset_t target_set; sigset_t set; int d0, i; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; /* set blocked signals */ if (__get_user(target_set.sig[0], &frame->sc.sc_mask)) goto badframe; for(i = 1; i < TARGET_NSIG_WORDS; i++) { if (__get_user(target_set.sig[i], &frame->extramask[i - 1])) goto badframe; } target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); /* restore registers */ if (restore_sigcontext(env, &frame->sc, &d0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return d0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
false
qemu
1c275925bfbbc2de84a8f0e09d1dd70bbefb6da3
long do_sigreturn(CPUM68KState *env) { struct target_sigframe *frame; abi_ulong frame_addr = env->aregs[7] - 4; target_sigset_t target_set; sigset_t set; int d0, i; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; if (__get_user(target_set.sig[0], &frame->sc.sc_mask)) goto badframe; for(i = 1; i < TARGET_NSIG_WORDS; i++) { if (__get_user(target_set.sig[i], &frame->extramask[i - 1])) goto badframe; } target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); if (restore_sigcontext(env, &frame->sc, &d0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return d0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
{ "code": [], "line_no": [] }
long FUNC_0(CPUM68KState *VAR_0) { struct target_sigframe *VAR_1; abi_ulong frame_addr = VAR_0->aregs[7] - 4; target_sigset_t target_set; sigset_t set; int VAR_2, VAR_3; if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) goto badframe; if (__get_user(target_set.sig[0], &VAR_1->sc.sc_mask)) goto badframe; for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) { if (__get_user(target_set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1])) goto badframe; } target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); if (restore_sigcontext(VAR_0, &VAR_1->sc, &VAR_2)) goto badframe; unlock_user_struct(VAR_1, frame_addr, 0); return VAR_2; badframe: unlock_user_struct(VAR_1, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
[ "long FUNC_0(CPUM68KState *VAR_0)\n{", "struct target_sigframe *VAR_1;", "abi_ulong frame_addr = VAR_0->aregs[7] - 4;", "target_sigset_t target_set;", "sigset_t set;", "int VAR_2, VAR_3;", "if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;", "if (__get_user(target_set.sig[0], &VAR_1->sc.sc_mask))\ngoto badframe;", "for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) {", "if (__get_user(target_set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1]))\ngoto badframe;", "}", "target_to_host_sigset_internal(&set, &target_set);", "sigprocmask(SIG_SETMASK, &set, NULL);", "if (restore_sigcontext(VAR_0, &VAR_1->sc, &VAR_2))\ngoto badframe;", "unlock_user_struct(VAR_1, frame_addr, 0);", "return VAR_2;", "badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);", "force_sig(TARGET_SIGSEGV);", "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 ], [ 13 ], [ 17, 19 ], [ 27, 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 43 ], [ 45 ], [ 53, 55 ], [ 59 ], [ 61 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ] ]
67
static int tcg_match_cmpi(TCGType type, tcg_target_long val) { if (facilities & FACILITY_EXT_IMM) { /* The COMPARE IMMEDIATE instruction is available. */ if (type == TCG_TYPE_I32) { /* We have a 32-bit immediate and can compare against anything. */ return 1; } else { /* ??? We have no insight here into whether the comparison is signed or unsigned. The COMPARE IMMEDIATE insn uses a 32-bit signed immediate, and the COMPARE LOGICAL IMMEDIATE insn uses a 32-bit unsigned immediate. If we were to use the (semi) obvious "val == (int32_t)val" we would be enabling unsigned comparisons vs very large numbers. The only solution is to take the intersection of the ranges. */ /* ??? Another possible solution is to simply lie and allow all constants here and force the out-of-range values into a temp register in tgen_cmp when we have knowledge of the actual comparison code in use. */ return val >= 0 && val <= 0x7fffffff; } } else { /* Only the LOAD AND TEST instruction is available. */ return val == 0; } }
false
qemu
b2c98d9d392c87c9b9e975d30f79924719d9cbbe
static int tcg_match_cmpi(TCGType type, tcg_target_long val) { if (facilities & FACILITY_EXT_IMM) { if (type == TCG_TYPE_I32) { return 1; } else { return val >= 0 && val <= 0x7fffffff; } } else { return val == 0; } }
{ "code": [], "line_no": [] }
static int FUNC_0(TCGType VAR_0, tcg_target_long VAR_1) { if (facilities & FACILITY_EXT_IMM) { if (VAR_0 == TCG_TYPE_I32) { return 1; } else { return VAR_1 >= 0 && VAR_1 <= 0x7fffffff; } } else { return VAR_1 == 0; } }
[ "static int FUNC_0(TCGType VAR_0, tcg_target_long VAR_1)\n{", "if (facilities & FACILITY_EXT_IMM) {", "if (VAR_0 == TCG_TYPE_I32) {", "return 1;", "} else {", "return VAR_1 >= 0 && VAR_1 <= 0x7fffffff;", "}", "} else {", "return VAR_1 == 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ] ]
68
static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return false; } #ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN return !virtio_is_big_endian(vdev); #else return virtio_is_big_endian(vdev); #endif #else return false; #endif }
false
qemu
46f70ff148ae01e2dc96e64c393e295a0092555d
static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return false; } #ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN return !virtio_is_big_endian(vdev); #else return virtio_is_big_endian(vdev); #endif #else return false; #endif }
{ "code": [], "line_no": [] }
static inline bool FUNC_0(VirtIODevice *vdev) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return false; } #ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN return !virtio_is_big_endian(vdev); #else return virtio_is_big_endian(vdev); #endif #else return false; #endif }
[ "static inline bool FUNC_0(VirtIODevice *vdev)\n{", "if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {", "return false;", "}", "#ifdef TARGET_IS_BIENDIAN\n#ifdef HOST_WORDS_BIGENDIAN\nreturn !virtio_is_big_endian(vdev);", "#else\nreturn virtio_is_big_endian(vdev);", "#endif\n#else\nreturn false;", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13, 15 ], [ 17, 19 ], [ 21, 23, 25 ], [ 27, 29 ] ]
69
int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext) { QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); QXLCursor *cursor; QEMUCursor *c; if (!cmd) { return 1; } if (!dpy_cursor_define_supported(qxl->vga.con)) { return 0; } if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) { fprintf(stderr, "%s", __FUNCTION__); qxl_log_cmd_cursor(qxl, cmd, ext->group_id); fprintf(stderr, "\n"); } switch (cmd->type) { case QXL_CURSOR_SET: cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id); if (!cursor) { return 1; } c = qxl_cursor(qxl, cursor, ext->group_id); if (c == NULL) { c = cursor_builtin_left_ptr(); } qemu_mutex_lock(&qxl->ssd.lock); if (qxl->ssd.cursor) { cursor_put(qxl->ssd.cursor); } qxl->ssd.cursor = c; qxl->ssd.mouse_x = cmd->u.set.position.x; qxl->ssd.mouse_y = cmd->u.set.position.y; qemu_mutex_unlock(&qxl->ssd.lock); qemu_bh_schedule(qxl->ssd.cursor_bh); break; case QXL_CURSOR_MOVE: qemu_mutex_lock(&qxl->ssd.lock); qxl->ssd.mouse_x = cmd->u.position.x; qxl->ssd.mouse_y = cmd->u.position.y; qemu_mutex_unlock(&qxl->ssd.lock); qemu_bh_schedule(qxl->ssd.cursor_bh); break; } return 0; }
false
qemu
a89f364ae8740dfc31b321eed9ee454e996dc3c1
int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext) { QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); QXLCursor *cursor; QEMUCursor *c; if (!cmd) { return 1; } if (!dpy_cursor_define_supported(qxl->vga.con)) { return 0; } if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) { fprintf(stderr, "%s", __FUNCTION__); qxl_log_cmd_cursor(qxl, cmd, ext->group_id); fprintf(stderr, "\n"); } switch (cmd->type) { case QXL_CURSOR_SET: cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id); if (!cursor) { return 1; } c = qxl_cursor(qxl, cursor, ext->group_id); if (c == NULL) { c = cursor_builtin_left_ptr(); } qemu_mutex_lock(&qxl->ssd.lock); if (qxl->ssd.cursor) { cursor_put(qxl->ssd.cursor); } qxl->ssd.cursor = c; qxl->ssd.mouse_x = cmd->u.set.position.x; qxl->ssd.mouse_y = cmd->u.set.position.y; qemu_mutex_unlock(&qxl->ssd.lock); qemu_bh_schedule(qxl->ssd.cursor_bh); break; case QXL_CURSOR_MOVE: qemu_mutex_lock(&qxl->ssd.lock); qxl->ssd.mouse_x = cmd->u.position.x; qxl->ssd.mouse_y = cmd->u.position.y; qemu_mutex_unlock(&qxl->ssd.lock); qemu_bh_schedule(qxl->ssd.cursor_bh); break; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(PCIQXLDevice *VAR_0, QXLCommandExt *VAR_1) { QXLCursorCmd *cmd = qxl_phys2virt(VAR_0, VAR_1->cmd.data, VAR_1->group_id); QXLCursor *cursor; QEMUCursor *c; if (!cmd) { return 1; } if (!dpy_cursor_define_supported(VAR_0->vga.con)) { return 0; } if (VAR_0->debug > 1 && cmd->type != QXL_CURSOR_MOVE) { fprintf(stderr, "%s", __FUNCTION__); qxl_log_cmd_cursor(VAR_0, cmd, VAR_1->group_id); fprintf(stderr, "\n"); } switch (cmd->type) { case QXL_CURSOR_SET: cursor = qxl_phys2virt(VAR_0, cmd->u.set.shape, VAR_1->group_id); if (!cursor) { return 1; } c = qxl_cursor(VAR_0, cursor, VAR_1->group_id); if (c == NULL) { c = cursor_builtin_left_ptr(); } qemu_mutex_lock(&VAR_0->ssd.lock); if (VAR_0->ssd.cursor) { cursor_put(VAR_0->ssd.cursor); } VAR_0->ssd.cursor = c; VAR_0->ssd.mouse_x = cmd->u.set.position.x; VAR_0->ssd.mouse_y = cmd->u.set.position.y; qemu_mutex_unlock(&VAR_0->ssd.lock); qemu_bh_schedule(VAR_0->ssd.cursor_bh); break; case QXL_CURSOR_MOVE: qemu_mutex_lock(&VAR_0->ssd.lock); VAR_0->ssd.mouse_x = cmd->u.position.x; VAR_0->ssd.mouse_y = cmd->u.position.y; qemu_mutex_unlock(&VAR_0->ssd.lock); qemu_bh_schedule(VAR_0->ssd.cursor_bh); break; } return 0; }
[ "int FUNC_0(PCIQXLDevice *VAR_0, QXLCommandExt *VAR_1)\n{", "QXLCursorCmd *cmd = qxl_phys2virt(VAR_0, VAR_1->cmd.data, VAR_1->group_id);", "QXLCursor *cursor;", "QEMUCursor *c;", "if (!cmd) {", "return 1;", "}", "if (!dpy_cursor_define_supported(VAR_0->vga.con)) {", "return 0;", "}", "if (VAR_0->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {", "fprintf(stderr, \"%s\", __FUNCTION__);", "qxl_log_cmd_cursor(VAR_0, cmd, VAR_1->group_id);", "fprintf(stderr, \"\\n\");", "}", "switch (cmd->type) {", "case QXL_CURSOR_SET:\ncursor = qxl_phys2virt(VAR_0, cmd->u.set.shape, VAR_1->group_id);", "if (!cursor) {", "return 1;", "}", "c = qxl_cursor(VAR_0, cursor, VAR_1->group_id);", "if (c == NULL) {", "c = cursor_builtin_left_ptr();", "}", "qemu_mutex_lock(&VAR_0->ssd.lock);", "if (VAR_0->ssd.cursor) {", "cursor_put(VAR_0->ssd.cursor);", "}", "VAR_0->ssd.cursor = c;", "VAR_0->ssd.mouse_x = cmd->u.set.position.x;", "VAR_0->ssd.mouse_y = cmd->u.set.position.y;", "qemu_mutex_unlock(&VAR_0->ssd.lock);", "qemu_bh_schedule(VAR_0->ssd.cursor_bh);", "break;", "case QXL_CURSOR_MOVE:\nqemu_mutex_lock(&VAR_0->ssd.lock);", "VAR_0->ssd.mouse_x = cmd->u.position.x;", "VAR_0->ssd.mouse_y = cmd->u.position.y;", "qemu_mutex_unlock(&VAR_0->ssd.lock);", "qemu_bh_schedule(VAR_0->ssd.cursor_bh);", "break;", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 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 ] ]
72
static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) { int compno, reslevelno, bandno; int x, y, *src[4]; uint8_t *line; Jpeg2000T1Context t1; /* Loop on tile components */ for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; /* Loop on resolution levels */ for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) { Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; /* Loop on bands */ for (bandno = 0; bandno < rlevel->nbands; bandno++) { int nb_precincts, precno; Jpeg2000Band *band = rlevel->band + bandno; int cblkx, cblky, cblkno=0, bandpos; bandpos = bandno + (reslevelno > 0); if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y; /* Loop on precincts */ for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; /* Loop on codeblocks */ for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { int x, y; int i, j; Jpeg2000Cblk *cblk = prec->cblk + cblkno; decode_cblk(s, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], cblk->coord[1][1] - cblk->coord[1][0], bandpos); /* Manage band offsets */ x = cblk->coord[0][0]; y = cblk->coord[1][0]; dequantization_int(x, y, cblk, comp, &t1, band); } /* end cblk */ } /*end prec */ } /* end band */ } /* end reslevel */ ff_dwt_decode(&comp->dwt, comp->data); src[compno] = comp->data; } /*end comp */ /* inverse MCT transformation */ if (tile->codsty[0].mct) mct_decode(s, tile); if (s->precision <= 8) { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint8_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + x * s->ncomponents + compno; for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { int val = *src[compno]++ << (8 - s->cbps[compno]); val += 1 << 7; val = av_clip(val, 0, (1 << 8) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } else { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint16_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = (uint16_t *)(line + (x * s->ncomponents + compno) * 2); for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) { int32_t val; val = *src[compno]++ << (16 - s->cbps[compno]); val += 1 << 15; val = av_clip(val, 0, (1 << 16) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } return 0; }
false
FFmpeg
83fd377c94d8fbffdb3e69fb3efe1976ff897a88
static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) { int compno, reslevelno, bandno; int x, y, *src[4]; uint8_t *line; Jpeg2000T1Context t1; for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) { Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; for (bandno = 0; bandno < rlevel->nbands; bandno++) { int nb_precincts, precno; Jpeg2000Band *band = rlevel->band + bandno; int cblkx, cblky, cblkno=0, bandpos; bandpos = bandno + (reslevelno > 0); if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { int x, y; int i, j; Jpeg2000Cblk *cblk = prec->cblk + cblkno; decode_cblk(s, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], cblk->coord[1][1] - cblk->coord[1][0], bandpos); x = cblk->coord[0][0]; y = cblk->coord[1][0]; dequantization_int(x, y, cblk, comp, &t1, band); } } } } ff_dwt_decode(&comp->dwt, comp->data); src[compno] = comp->data; } if (tile->codsty[0].mct) mct_decode(s, tile); if (s->precision <= 8) { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint8_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + x * s->ncomponents + compno; for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { int val = *src[compno]++ << (8 - s->cbps[compno]); val += 1 << 7; val = av_clip(val, 0, (1 << 8) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } else { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint16_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = (uint16_t *)(line + (x * s->ncomponents + compno) * 2); for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) { int32_t val; val = *src[compno]++ << (16 - s->cbps[compno]); val += 1 << 15; val = av_clip(val, 0, (1 << 16) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000Tile *VAR_1) { int VAR_2, VAR_3, VAR_4; int VAR_5, VAR_6, *VAR_7[4]; uint8_t *line; Jpeg2000T1Context t1; for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) { Jpeg2000Component *comp = VAR_1->comp + VAR_2; Jpeg2000CodingStyle *codsty = VAR_1->codsty + VAR_2; for (VAR_3 = 0; VAR_3 < codsty->nreslevels2decode; VAR_3++) { Jpeg2000ResLevel *rlevel = comp->reslevel + VAR_3; for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++) { int nb_precincts, precno; Jpeg2000Band *band = rlevel->band + VAR_4; int cblkx, cblky, cblkno=0, bandpos; bandpos = VAR_4 + (VAR_3 > 0); if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { int VAR_5, VAR_6; int i, j; Jpeg2000Cblk *cblk = prec->cblk + cblkno; decode_cblk(VAR_0, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], cblk->coord[1][1] - cblk->coord[1][0], bandpos); VAR_5 = cblk->coord[0][0]; VAR_6 = cblk->coord[1][0]; dequantization_int(VAR_5, VAR_6, cblk, comp, &t1, band); } } } } ff_dwt_decode(&comp->dwt, comp->data); VAR_7[VAR_2] = comp->data; } if (VAR_1->codsty[0].mct) mct_decode(VAR_0, VAR_1); if (VAR_0->precision <= 8) { for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) { VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y; line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0]; for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) { uint8_t *dst; VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x; dst = line + VAR_5 * VAR_0->ncomponents + VAR_2; for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) { int val = *VAR_7[VAR_2]++ << (8 - VAR_0->cbps[VAR_2]); val += 1 << 7; val = av_clip(val, 0, (1 << 8) - 1); *dst = val; dst += VAR_0->ncomponents; } line += VAR_0->picture->linesize[0]; } } } else { for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) { VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y; line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0]; for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) { uint16_t *dst; VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x; dst = (uint16_t *)(line + (VAR_5 * VAR_0->ncomponents + VAR_2) * 2); for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) { int32_t val; val = *VAR_7[VAR_2]++ << (16 - VAR_0->cbps[VAR_2]); val += 1 << 15; val = av_clip(val, 0, (1 << 16) - 1); *dst = val; dst += VAR_0->ncomponents; } line += VAR_0->picture->linesize[0]; } } } return 0; }
[ "static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000Tile *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4;", "int VAR_5, VAR_6, *VAR_7[4];", "uint8_t *line;", "Jpeg2000T1Context t1;", "for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {", "Jpeg2000Component *comp = VAR_1->comp + VAR_2;", "Jpeg2000CodingStyle *codsty = VAR_1->codsty + VAR_2;", "for (VAR_3 = 0; VAR_3 < codsty->nreslevels2decode; VAR_3++) {", "Jpeg2000ResLevel *rlevel = comp->reslevel + VAR_3;", "for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++) {", "int nb_precincts, precno;", "Jpeg2000Band *band = rlevel->band + VAR_4;", "int cblkx, cblky, cblkno=0, bandpos;", "bandpos = VAR_4 + (VAR_3 > 0);", "if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])\ncontinue;", "nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;", "for (precno = 0; precno < nb_precincts; precno++) {", "Jpeg2000Prec *prec = band->prec + precno;", "for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {", "int VAR_5, VAR_6;", "int i, j;", "Jpeg2000Cblk *cblk = prec->cblk + cblkno;", "decode_cblk(VAR_0, codsty, &t1, cblk,\ncblk->coord[0][1] - cblk->coord[0][0],\ncblk->coord[1][1] - cblk->coord[1][0],\nbandpos);", "VAR_5 = cblk->coord[0][0];", "VAR_6 = cblk->coord[1][0];", "dequantization_int(VAR_5, VAR_6, cblk, comp, &t1, band);", "}", "}", "}", "}", "ff_dwt_decode(&comp->dwt, comp->data);", "VAR_7[VAR_2] = comp->data;", "}", "if (VAR_1->codsty[0].mct)\nmct_decode(VAR_0, VAR_1);", "if (VAR_0->precision <= 8) {", "for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {", "VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;", "line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0];", "for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {", "uint8_t *dst;", "VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;", "dst = line + VAR_5 * VAR_0->ncomponents + VAR_2;", "for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) {", "int val = *VAR_7[VAR_2]++ << (8 - VAR_0->cbps[VAR_2]);", "val += 1 << 7;", "val = av_clip(val, 0, (1 << 8) - 1);", "*dst = val;", "dst += VAR_0->ncomponents;", "}", "line += VAR_0->picture->linesize[0];", "}", "}", "} else {", "for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {", "VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;", "line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0];", "for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {", "uint16_t *dst;", "VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;", "dst = (uint16_t *)(line + (VAR_5 * VAR_0->ncomponents + VAR_2) * 2);", "for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) {", "int32_t val;", "val = *VAR_7[VAR_2]++ << (16 - VAR_0->cbps[VAR_2]);", "val += 1 << 15;", "val = av_clip(val, 0, (1 << 16) - 1);", "*dst = val;", "dst += VAR_0->ncomponents;", "}", "line += VAR_0->picture->linesize[0];", "}", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47, 49 ], [ 53 ], [ 57 ], [ 59 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75, 77, 79 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ] ]
73
static void omap_pwl_init(target_phys_addr_t base, struct omap_mpu_state_s *s, omap_clk clk) { int iomemtype; s->pwl.base = base; omap_pwl_reset(s); iomemtype = cpu_register_io_memory(0, omap_pwl_readfn, omap_pwl_writefn, s); cpu_register_physical_memory(s->pwl.base, 0x800, iomemtype); omap_clk_adduser(clk, qemu_allocate_irqs(omap_pwl_clk_update, s, 1)[0]); }
false
qemu
b854bc196f5c4b4e3299c0b0ee63cf828ece9e77
static void omap_pwl_init(target_phys_addr_t base, struct omap_mpu_state_s *s, omap_clk clk) { int iomemtype; s->pwl.base = base; omap_pwl_reset(s); iomemtype = cpu_register_io_memory(0, omap_pwl_readfn, omap_pwl_writefn, s); cpu_register_physical_memory(s->pwl.base, 0x800, iomemtype); omap_clk_adduser(clk, qemu_allocate_irqs(omap_pwl_clk_update, s, 1)[0]); }
{ "code": [], "line_no": [] }
static void FUNC_0(target_phys_addr_t VAR_0, struct omap_mpu_state_s *VAR_1, omap_clk VAR_2) { int VAR_3; VAR_1->pwl.VAR_0 = VAR_0; omap_pwl_reset(VAR_1); VAR_3 = cpu_register_io_memory(0, omap_pwl_readfn, omap_pwl_writefn, VAR_1); cpu_register_physical_memory(VAR_1->pwl.VAR_0, 0x800, VAR_3); omap_clk_adduser(VAR_2, qemu_allocate_irqs(omap_pwl_clk_update, VAR_1, 1)[0]); }
[ "static void FUNC_0(target_phys_addr_t VAR_0, struct omap_mpu_state_s *VAR_1,\nomap_clk VAR_2)\n{", "int VAR_3;", "VAR_1->pwl.VAR_0 = VAR_0;", "omap_pwl_reset(VAR_1);", "VAR_3 = cpu_register_io_memory(0, omap_pwl_readfn,\nomap_pwl_writefn, VAR_1);", "cpu_register_physical_memory(VAR_1->pwl.VAR_0, 0x800, VAR_3);", "omap_clk_adduser(VAR_2, qemu_allocate_irqs(omap_pwl_clk_update, VAR_1, 1)[0]);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 21 ], [ 25 ], [ 27 ] ]
74
static void virt_acpi_build_update(void *build_opaque) { AcpiBuildState *build_state = build_opaque; AcpiBuildTables tables; /* No state to update or already patched? Nothing to do. */ if (!build_state || build_state->patched) { return; } build_state->patched = true; acpi_build_tables_init(&tables); virt_acpi_build(build_state->guest_info, &tables); acpi_ram_update(build_state->table_mr, tables.table_data); acpi_ram_update(build_state->rsdp_mr, tables.rsdp); acpi_ram_update(build_state->linker_mr, tables.linker); acpi_build_tables_cleanup(&tables, true); }
false
qemu
0e9b9edae7bebfd31fdbead4ccbbce03876a7edd
static void virt_acpi_build_update(void *build_opaque) { AcpiBuildState *build_state = build_opaque; AcpiBuildTables tables; if (!build_state || build_state->patched) { return; } build_state->patched = true; acpi_build_tables_init(&tables); virt_acpi_build(build_state->guest_info, &tables); acpi_ram_update(build_state->table_mr, tables.table_data); acpi_ram_update(build_state->rsdp_mr, tables.rsdp); acpi_ram_update(build_state->linker_mr, tables.linker); acpi_build_tables_cleanup(&tables, true); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { AcpiBuildState *build_state = VAR_0; AcpiBuildTables tables; if (!build_state || build_state->patched) { return; } build_state->patched = true; acpi_build_tables_init(&tables); virt_acpi_build(build_state->guest_info, &tables); acpi_ram_update(build_state->table_mr, tables.table_data); acpi_ram_update(build_state->rsdp_mr, tables.rsdp); acpi_ram_update(build_state->linker_mr, tables.linker); acpi_build_tables_cleanup(&tables, true); }
[ "static void FUNC_0(void *VAR_0)\n{", "AcpiBuildState *build_state = VAR_0;", "AcpiBuildTables tables;", "if (!build_state || build_state->patched) {", "return;", "}", "build_state->patched = true;", "acpi_build_tables_init(&tables);", "virt_acpi_build(build_state->guest_info, &tables);", "acpi_ram_update(build_state->table_mr, tables.table_data);", "acpi_ram_update(build_state->rsdp_mr, tables.rsdp);", "acpi_ram_update(build_state->linker_mr, tables.linker);", "acpi_build_tables_cleanup(&tables, true);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 41 ], [ 43 ] ]
76
static void uart_rx_reset(UartState *s) { s->rx_wpos = 0; s->rx_count = 0; qemu_chr_accept_input(s->chr); s->r[R_SR] |= UART_SR_INTR_REMPTY; s->r[R_SR] &= ~UART_SR_INTR_RFUL; }
false
qemu
9121d02cb33c96b444a3973579f5edc119597e81
static void uart_rx_reset(UartState *s) { s->rx_wpos = 0; s->rx_count = 0; qemu_chr_accept_input(s->chr); s->r[R_SR] |= UART_SR_INTR_REMPTY; s->r[R_SR] &= ~UART_SR_INTR_RFUL; }
{ "code": [], "line_no": [] }
static void FUNC_0(UartState *VAR_0) { VAR_0->rx_wpos = 0; VAR_0->rx_count = 0; qemu_chr_accept_input(VAR_0->chr); VAR_0->r[R_SR] |= UART_SR_INTR_REMPTY; VAR_0->r[R_SR] &= ~UART_SR_INTR_RFUL; }
[ "static void FUNC_0(UartState *VAR_0)\n{", "VAR_0->rx_wpos = 0;", "VAR_0->rx_count = 0;", "qemu_chr_accept_input(VAR_0->chr);", "VAR_0->r[R_SR] |= UART_SR_INTR_REMPTY;", "VAR_0->r[R_SR] &= ~UART_SR_INTR_RFUL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ] ]
77
static int rndis_set_response(USBNetState *s, rndis_set_msg_type *buf, unsigned int length) { rndis_set_cmplt_type *resp = rndis_queue_response(s, sizeof(rndis_set_cmplt_type)); uint32_t bufoffs, buflen; int ret; if (!resp) return USB_RET_STALL; bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8; buflen = le32_to_cpu(buf->InformationBufferLength); if (bufoffs + buflen > length) return USB_RET_STALL; ret = ndis_set(s, le32_to_cpu(buf->OID), bufoffs + (uint8_t *) buf, buflen); resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT); resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type)); if (ret < 0) { /* OID not supported */ resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); return 0; } resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); return 0; }
true
qemu
fe3c546c5ff2a6210f9a4d8561cc64051ca8603e
static int rndis_set_response(USBNetState *s, rndis_set_msg_type *buf, unsigned int length) { rndis_set_cmplt_type *resp = rndis_queue_response(s, sizeof(rndis_set_cmplt_type)); uint32_t bufoffs, buflen; int ret; if (!resp) return USB_RET_STALL; bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8; buflen = le32_to_cpu(buf->InformationBufferLength); if (bufoffs + buflen > length) return USB_RET_STALL; ret = ndis_set(s, le32_to_cpu(buf->OID), bufoffs + (uint8_t *) buf, buflen); resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT); resp->RequestID = buf->RequestID; resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type)); if (ret < 0) { resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); return 0; } resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); return 0; }
{ "code": [ " if (bufoffs + buflen > length)", " if (bufoffs + buflen > length)" ], "line_no": [ 27, 27 ] }
static int FUNC_0(USBNetState *VAR_0, rndis_set_msg_type *VAR_1, unsigned int VAR_2) { rndis_set_cmplt_type *resp = rndis_queue_response(VAR_0, sizeof(rndis_set_cmplt_type)); uint32_t bufoffs, buflen; int VAR_3; if (!resp) return USB_RET_STALL; bufoffs = le32_to_cpu(VAR_1->InformationBufferOffset) + 8; buflen = le32_to_cpu(VAR_1->InformationBufferLength); if (bufoffs + buflen > VAR_2) return USB_RET_STALL; VAR_3 = ndis_set(VAR_0, le32_to_cpu(VAR_1->OID), bufoffs + (uint8_t *) VAR_1, buflen); resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT); resp->RequestID = VAR_1->RequestID; resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type)); if (VAR_3 < 0) { resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); return 0; } resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); return 0; }
[ "static int FUNC_0(USBNetState *VAR_0,\nrndis_set_msg_type *VAR_1, unsigned int VAR_2)\n{", "rndis_set_cmplt_type *resp =\nrndis_queue_response(VAR_0, sizeof(rndis_set_cmplt_type));", "uint32_t bufoffs, buflen;", "int VAR_3;", "if (!resp)\nreturn USB_RET_STALL;", "bufoffs = le32_to_cpu(VAR_1->InformationBufferOffset) + 8;", "buflen = le32_to_cpu(VAR_1->InformationBufferLength);", "if (bufoffs + buflen > VAR_2)\nreturn USB_RET_STALL;", "VAR_3 = ndis_set(VAR_0, le32_to_cpu(VAR_1->OID),\nbufoffs + (uint8_t *) VAR_1, buflen);", "resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT);", "resp->RequestID = VAR_1->RequestID;", "resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type));", "if (VAR_3 < 0) {", "resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);", "return 0;", "}", "resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ] ]
78
SwsContext *sws_alloc_context(void) { SwsContext *c = av_mallocz(sizeof(SwsContext)); c->av_class = &sws_context_class; av_opt_set_defaults(c); return c; }
true
FFmpeg
f73f76fd202b310e8e1d0215b2e0cf038cd18c4a
SwsContext *sws_alloc_context(void) { SwsContext *c = av_mallocz(sizeof(SwsContext)); c->av_class = &sws_context_class; av_opt_set_defaults(c); return c; }
{ "code": [ " c->av_class = &sws_context_class;", " av_opt_set_defaults(c);" ], "line_no": [ 9, 11 ] }
SwsContext *FUNC_0(void) { SwsContext *c = av_mallocz(sizeof(SwsContext)); c->av_class = &sws_context_class; av_opt_set_defaults(c); return c; }
[ "SwsContext *FUNC_0(void)\n{", "SwsContext *c = av_mallocz(sizeof(SwsContext));", "c->av_class = &sws_context_class;", "av_opt_set_defaults(c);", "return c;", "}" ]
[ 0, 0, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ] ]
79
static i2c_interface *musicpal_audio_init(qemu_irq irq) { AudioState *audio; musicpal_audio_state *s; i2c_interface *i2c; int iomemtype; audio = AUD_init(); if (!audio) { AUD_log(audio_name, "No audio state\n"); return NULL; } s = qemu_mallocz(sizeof(musicpal_audio_state)); s->irq = irq; i2c = qemu_mallocz(sizeof(i2c_interface)); i2c->bus = i2c_init_bus(); i2c->current_addr = -1; s->wm = wm8750_init(i2c->bus, audio); if (!s->wm) return NULL; i2c_set_slave_address(s->wm, MP_WM_ADDR); wm8750_data_req_set(s->wm, audio_callback, s); iomemtype = cpu_register_io_memory(0, musicpal_audio_readfn, musicpal_audio_writefn, s); cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, iomemtype); qemu_register_reset(musicpal_audio_reset, s); return i2c; }
true
qemu
0d9acba8fddbf970c7353083e6a60b47017ce3e4
static i2c_interface *musicpal_audio_init(qemu_irq irq) { AudioState *audio; musicpal_audio_state *s; i2c_interface *i2c; int iomemtype; audio = AUD_init(); if (!audio) { AUD_log(audio_name, "No audio state\n"); return NULL; } s = qemu_mallocz(sizeof(musicpal_audio_state)); s->irq = irq; i2c = qemu_mallocz(sizeof(i2c_interface)); i2c->bus = i2c_init_bus(); i2c->current_addr = -1; s->wm = wm8750_init(i2c->bus, audio); if (!s->wm) return NULL; i2c_set_slave_address(s->wm, MP_WM_ADDR); wm8750_data_req_set(s->wm, audio_callback, s); iomemtype = cpu_register_io_memory(0, musicpal_audio_readfn, musicpal_audio_writefn, s); cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, iomemtype); qemu_register_reset(musicpal_audio_reset, s); return i2c; }
{ "code": [ " return NULL;", " return NULL;", " if (!audio) {", " AUD_log(audio_name, \"No audio state\\n\");", " return NULL;" ], "line_no": [ 21, 21, 17, 19, 21 ] }
static i2c_interface *FUNC_0(qemu_irq irq) { AudioState *audio; musicpal_audio_state *s; i2c_interface *i2c; int VAR_0; audio = AUD_init(); if (!audio) { AUD_log(audio_name, "No audio state\n"); return NULL; } s = qemu_mallocz(sizeof(musicpal_audio_state)); s->irq = irq; i2c = qemu_mallocz(sizeof(i2c_interface)); i2c->bus = i2c_init_bus(); i2c->current_addr = -1; s->wm = wm8750_init(i2c->bus, audio); if (!s->wm) return NULL; i2c_set_slave_address(s->wm, MP_WM_ADDR); wm8750_data_req_set(s->wm, audio_callback, s); VAR_0 = cpu_register_io_memory(0, musicpal_audio_readfn, musicpal_audio_writefn, s); cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, VAR_0); qemu_register_reset(musicpal_audio_reset, s); return i2c; }
[ "static i2c_interface *FUNC_0(qemu_irq irq)\n{", "AudioState *audio;", "musicpal_audio_state *s;", "i2c_interface *i2c;", "int VAR_0;", "audio = AUD_init();", "if (!audio) {", "AUD_log(audio_name, \"No audio state\\n\");", "return NULL;", "}", "s = qemu_mallocz(sizeof(musicpal_audio_state));", "s->irq = irq;", "i2c = qemu_mallocz(sizeof(i2c_interface));", "i2c->bus = i2c_init_bus();", "i2c->current_addr = -1;", "s->wm = wm8750_init(i2c->bus, audio);", "if (!s->wm)\nreturn NULL;", "i2c_set_slave_address(s->wm, MP_WM_ADDR);", "wm8750_data_req_set(s->wm, audio_callback, s);", "VAR_0 = cpu_register_io_memory(0, musicpal_audio_readfn,\nmusicpal_audio_writefn, s);", "cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, VAR_0);", "qemu_register_reset(musicpal_audio_reset, s);", "return i2c;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57 ], [ 61 ], [ 65 ], [ 67 ] ]
80
void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error) { assert(error >= 0); bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); if (action == BDRV_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(bs, error); } }
true
qemu
2bd3bce8efebe86b031beab5c0e3b9bbaec0b502
void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error) { assert(error >= 0); bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); if (action == BDRV_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(bs, error); } }
{ "code": [ " bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);", " vm_stop(RUN_STATE_IO_ERROR);" ], "line_no": [ 9, 13 ] }
void FUNC_0(BlockDriverState *VAR_0, BlockErrorAction VAR_1, bool VAR_2, int VAR_3) { assert(VAR_3 >= 0); bdrv_emit_qmp_error_event(VAR_0, QEVENT_BLOCK_IO_ERROR, VAR_1, VAR_2); if (VAR_1 == BDRV_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(VAR_0, VAR_3); } }
[ "void FUNC_0(BlockDriverState *VAR_0, BlockErrorAction VAR_1,\nbool VAR_2, int VAR_3)\n{", "assert(VAR_3 >= 0);", "bdrv_emit_qmp_error_event(VAR_0, QEVENT_BLOCK_IO_ERROR, VAR_1, VAR_2);", "if (VAR_1 == BDRV_ACTION_STOP) {", "vm_stop(RUN_STATE_IO_ERROR);", "bdrv_iostatus_set_err(VAR_0, VAR_3);", "}", "}" ]
[ 0, 0, 1, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
81
static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size, uint64_t max_mem) { DeviceState *dev; SysBusDevice *s; RamDevice *d; /* allocate RAM */ if ((uint64_t)RAM_size > max_mem) { fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n", (unsigned int)(RAM_size / (1024 * 1024)), (unsigned int)(max_mem / (1024 * 1024))); exit(1); } dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; qdev_init(dev); sysbus_mmio_map(s, 0, addr); }
true
qemu
e23a1b33b53d25510320b26d9f154e19c6c99725
static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size, uint64_t max_mem) { DeviceState *dev; SysBusDevice *s; RamDevice *d; if ((uint64_t)RAM_size > max_mem) { fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n", (unsigned int)(RAM_size / (1024 * 1024)), (unsigned int)(max_mem / (1024 * 1024))); exit(1); } dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; qdev_init(dev); sysbus_mmio_map(s, 0, addr); }
{ "code": [ " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);", " qdev_init(dev);" ], "line_no": [ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41 ] }
static void FUNC_0(target_phys_addr_t VAR_0, ram_addr_t VAR_1, uint64_t VAR_2) { DeviceState *dev; SysBusDevice *s; RamDevice *d; if ((uint64_t)VAR_1 > VAR_2) { fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n", (unsigned int)(VAR_1 / (1024 * 1024)), (unsigned int)(VAR_2 / (1024 * 1024))); exit(1); } dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = VAR_1; qdev_init(dev); sysbus_mmio_map(s, 0, VAR_0); }
[ "static void FUNC_0(target_phys_addr_t VAR_0, ram_addr_t VAR_1,\nuint64_t VAR_2)\n{", "DeviceState *dev;", "SysBusDevice *s;", "RamDevice *d;", "if ((uint64_t)VAR_1 > VAR_2) {", "fprintf(stderr,\n\"qemu: Too much memory for this machine: %d, maximum %d\\n\",\n(unsigned int)(VAR_1 / (1024 * 1024)),\n(unsigned int)(VAR_2 / (1024 * 1024)));", "exit(1);", "}", "dev = qdev_create(NULL, \"memory\");", "s = sysbus_from_qdev(dev);", "d = FROM_SYSBUS(RamDevice, s);", "d->size = VAR_1;", "qdev_init(dev);", "sysbus_mmio_map(s, 0, VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 19, 21, 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ] ]
82
int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align) { int i, first = -1; ICSState *ics = &icp->ics[src]; assert(src == 0); /* * MSIMesage::data is used for storing VIRQ so * it has to be aligned to num to support multiple * MSI vectors. MSI-X is not affected by this. * The hint is used for the first IRQ, the rest should * be allocated continuously. */ if (align) { assert((num == 1) || (num == 2) || (num == 4) || (num == 8) || (num == 16) || (num == 32)); first = ics_find_free_block(ics, num, num); } else { first = ics_find_free_block(ics, num, 1); } if (first >= 0) { for (i = first; i < first + num; ++i) { ics_set_irq_type(ics, i, lsi); } } first += ics->offset; trace_xics_alloc_block(src, first, num, lsi, align); return first; }
true
qemu
a005b3ef50439b5bc6b2eb0b5bda8e8c7c2368bf
int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align) { int i, first = -1; ICSState *ics = &icp->ics[src]; assert(src == 0); if (align) { assert((num == 1) || (num == 2) || (num == 4) || (num == 8) || (num == 16) || (num == 32)); first = ics_find_free_block(ics, num, num); } else { first = ics_find_free_block(ics, num, 1); } if (first >= 0) { for (i = first; i < first + num; ++i) { ics_set_irq_type(ics, i, lsi); } } first += ics->offset; trace_xics_alloc_block(src, first, num, lsi, align); return first; }
{ "code": [ "int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align)" ], "line_no": [ 1 ] }
int FUNC_0(XICSState *VAR_0, int VAR_1, int VAR_2, bool VAR_3, bool VAR_4) { int VAR_5, VAR_6 = -1; ICSState *ics = &VAR_0->ics[VAR_1]; assert(VAR_1 == 0); if (VAR_4) { assert((VAR_2 == 1) || (VAR_2 == 2) || (VAR_2 == 4) || (VAR_2 == 8) || (VAR_2 == 16) || (VAR_2 == 32)); VAR_6 = ics_find_free_block(ics, VAR_2, VAR_2); } else { VAR_6 = ics_find_free_block(ics, VAR_2, 1); } if (VAR_6 >= 0) { for (VAR_5 = VAR_6; VAR_5 < VAR_6 + VAR_2; ++VAR_5) { ics_set_irq_type(ics, VAR_5, VAR_3); } } VAR_6 += ics->offset; trace_xics_alloc_block(VAR_1, VAR_6, VAR_2, VAR_3, VAR_4); return VAR_6; }
[ "int FUNC_0(XICSState *VAR_0, int VAR_1, int VAR_2, bool VAR_3, bool VAR_4)\n{", "int VAR_5, VAR_6 = -1;", "ICSState *ics = &VAR_0->ics[VAR_1];", "assert(VAR_1 == 0);", "if (VAR_4) {", "assert((VAR_2 == 1) || (VAR_2 == 2) || (VAR_2 == 4) ||\n(VAR_2 == 8) || (VAR_2 == 16) || (VAR_2 == 32));", "VAR_6 = ics_find_free_block(ics, VAR_2, VAR_2);", "} else {", "VAR_6 = ics_find_free_block(ics, VAR_2, 1);", "}", "if (VAR_6 >= 0) {", "for (VAR_5 = VAR_6; VAR_5 < VAR_6 + VAR_2; ++VAR_5) {", "ics_set_irq_type(ics, VAR_5, VAR_3);", "}", "}", "VAR_6 += ics->offset;", "trace_xics_alloc_block(VAR_1, VAR_6, VAR_2, VAR_3, VAR_4);", "return VAR_6;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 61 ], [ 63 ] ]
85
void object_property_get_uint16List(Object *obj, const char *name, uint16List **list, Error **errp) { StringOutputVisitor *ov; StringInputVisitor *iv; ov = string_output_visitor_new(false); object_property_get(obj, string_output_get_visitor(ov), name, errp); iv = string_input_visitor_new(string_output_get_string(ov)); visit_type_uint16List(string_input_get_visitor(iv), list, NULL, errp); string_output_visitor_cleanup(ov); string_input_visitor_cleanup(iv); }
true
qemu
976620ac4018db142d82cd42bb7774f40290ce7e
void object_property_get_uint16List(Object *obj, const char *name, uint16List **list, Error **errp) { StringOutputVisitor *ov; StringInputVisitor *iv; ov = string_output_visitor_new(false); object_property_get(obj, string_output_get_visitor(ov), name, errp); iv = string_input_visitor_new(string_output_get_string(ov)); visit_type_uint16List(string_input_get_visitor(iv), list, NULL, errp); string_output_visitor_cleanup(ov); string_input_visitor_cleanup(iv); }
{ "code": [ " iv = string_input_visitor_new(string_output_get_string(ov));" ], "line_no": [ 19 ] }
void FUNC_0(Object *VAR_0, const char *VAR_1, uint16List **VAR_2, Error **VAR_3) { StringOutputVisitor *ov; StringInputVisitor *iv; ov = string_output_visitor_new(false); object_property_get(VAR_0, string_output_get_visitor(ov), VAR_1, VAR_3); iv = string_input_visitor_new(string_output_get_string(ov)); visit_type_uint16List(string_input_get_visitor(iv), VAR_2, NULL, VAR_3); string_output_visitor_cleanup(ov); string_input_visitor_cleanup(iv); }
[ "void FUNC_0(Object *VAR_0, const char *VAR_1,\nuint16List **VAR_2, Error **VAR_3)\n{", "StringOutputVisitor *ov;", "StringInputVisitor *iv;", "ov = string_output_visitor_new(false);", "object_property_get(VAR_0, string_output_get_visitor(ov),\nVAR_1, VAR_3);", "iv = string_input_visitor_new(string_output_get_string(ov));", "visit_type_uint16List(string_input_get_visitor(iv),\nVAR_2, NULL, VAR_3);", "string_output_visitor_cleanup(ov);", "string_input_visitor_cleanup(iv);", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ] ]
86
static int raw_create(const char *filename, QEMUOptionParameter *options) { int fd; int64_t total_size = 0; /* Read out options */ while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { total_size = options->value.n / 512; } options++; } fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; ftruncate(fd, total_size * 512); close(fd); return 0; }
true
qemu
1e37d05904e300a0bfc8e3240e24ecc83d54c2e3
static int raw_create(const char *filename, QEMUOptionParameter *options) { int fd; int64_t total_size = 0; while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { total_size = options->value.n / 512; } options++; } fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; ftruncate(fd, total_size * 512); close(fd); return 0; }
{ "code": [ " if (fd < 0)", " return -EIO;", " ftruncate(fd, total_size * 512);", " close(fd);", " return 0;" ], "line_no": [ 31, 33, 35, 37, 39 ] }
static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1) { int VAR_2; int64_t total_size = 0; while (VAR_1 && VAR_1->name) { if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) { total_size = VAR_1->value.n / 512; } VAR_1++; } VAR_2 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (VAR_2 < 0) return -EIO; ftruncate(VAR_2, total_size * 512); close(VAR_2); return 0; }
[ "static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)\n{", "int VAR_2;", "int64_t total_size = 0;", "while (VAR_1 && VAR_1->name) {", "if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) {", "total_size = VAR_1->value.n / 512;", "}", "VAR_1++;", "}", "VAR_2 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,\n0644);", "if (VAR_2 < 0)\nreturn -EIO;", "ftruncate(VAR_2, total_size * 512);", "close(VAR_2);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
87
static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { int i; assert(src1==src2); for (i=0; i<width; i++) { int r= src1[6*i + 0] + src1[6*i + 3]; int g= src1[6*i + 1] + src1[6*i + 4]; int b= src1[6*i + 2] + src1[6*i + 5]; dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); } }
true
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { int i; assert(src1==src2); for (i=0; i<width; i++) { int r= src1[6*i + 0] + src1[6*i + 3]; int g= src1[6*i + 1] + src1[6*i + 4]; int b= src1[6*i + 2] + src1[6*i + 5]; dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); } }
{ "code": [ "static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)" ], "line_no": [ 1 ] }
static inline void FUNC_0(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { int VAR_0; assert(src1==src2); for (VAR_0=0; VAR_0<width; VAR_0++) { int r= src1[6*VAR_0 + 0] + src1[6*VAR_0 + 3]; int g= src1[6*VAR_0 + 1] + src1[6*VAR_0 + 4]; int b= src1[6*VAR_0 + 2] + src1[6*VAR_0 + 5]; dstU[VAR_0]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); dstV[VAR_0]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1); } }
[ "static inline void FUNC_0(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)\n{", "int VAR_0;", "assert(src1==src2);", "for (VAR_0=0; VAR_0<width; VAR_0++) {", "int r= src1[6*VAR_0 + 0] + src1[6*VAR_0 + 3];", "int g= src1[6*VAR_0 + 1] + src1[6*VAR_0 + 4];", "int b= src1[6*VAR_0 + 2] + src1[6*VAR_0 + 5];", "dstU[VAR_0]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);", "dstV[VAR_0]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
89
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_clusters, i = 0; QCowL2Meta *old_alloc; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); /* We keep all QCOW_OFLAG_COPIED clusters */ if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->nb_clusters = 0; goto out; } /* for the moment, multiple compressed clusters are not managed */ if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; /* how many available clusters ? */ while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index], i, 0); if(be64_to_cpu(l2_table[l2_index + i])) break; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } nb_clusters = i; /* * Check if there already is an AIO write request in flight which allocates * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. */ QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + nb_clusters * s->cluster_size; uint64_t old_offset = old_alloc->offset; uint64_t old_end_offset = old_alloc->offset + old_alloc->nb_clusters * s->cluster_size; if (end_offset < old_offset || offset > old_end_offset) { /* No intersection */ } else { if (offset < old_offset) { /* Stop at the start of a running allocation */ nb_clusters = (old_offset - offset) >> s->cluster_bits; } else { nb_clusters = 0; } if (nb_clusters == 0) { /* Set dependency and wait for a callback */ m->depends_on = old_alloc; m->nb_clusters = 0; *num = 0; return 0; } } } if (!nb_clusters) { abort(); } QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); /* allocate a new cluster */ cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size); /* save info needed for meta data update */ m->offset = offset; m->n_start = n_start; m->nb_clusters = nb_clusters; out: m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
true
qemu
80ee15a6b274dfcedb0ad7db8c9e7d392210d6a1
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_clusters, i = 0; QCowL2Meta *old_alloc; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->nb_clusters = 0; goto out; } if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index], i, 0); if(be64_to_cpu(l2_table[l2_index + i])) break; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } nb_clusters = i; QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + nb_clusters * s->cluster_size; uint64_t old_offset = old_alloc->offset; uint64_t old_end_offset = old_alloc->offset + old_alloc->nb_clusters * s->cluster_size; if (end_offset < old_offset || offset > old_end_offset) { } else { if (offset < old_offset) { nb_clusters = (old_offset - offset) >> s->cluster_bits; } else { nb_clusters = 0; } if (nb_clusters == 0) { m->depends_on = old_alloc; m->nb_clusters = 0; *num = 0; return 0; } } } if (!nb_clusters) { abort(); } QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size); m->offset = offset; m->n_start = n_start; m->nb_clusters = nb_clusters; out: m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
{ "code": [ " int nb_clusters, i = 0;" ], "line_no": [ 17 ] }
uint64_t FUNC_0(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int VAR_0, VAR_1; uint64_t l2_offset, *l2_table, cluster_offset; int VAR_2, VAR_3 = 0; QCowL2Meta *old_alloc; VAR_1 = get_cluster_table(bs, offset, &l2_table, &l2_offset, &VAR_0); if (VAR_1 == 0) return 0; VAR_2 = size_to_clusters(s, n_end << 9); VAR_2 = MIN(VAR_2, s->l2_size - VAR_0); cluster_offset = be64_to_cpu(l2_table[VAR_0]); if (cluster_offset & QCOW_OFLAG_COPIED) { VAR_2 = count_contiguous_clusters(VAR_2, s->cluster_size, &l2_table[VAR_0], 0, 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->VAR_2 = 0; goto out; } if (cluster_offset & QCOW_OFLAG_COMPRESSED) VAR_2 = 1; while (VAR_3 < VAR_2) { VAR_3 += count_contiguous_clusters(VAR_2 - VAR_3, s->cluster_size, &l2_table[VAR_0], VAR_3, 0); if(be64_to_cpu(l2_table[VAR_0 + VAR_3])) break; VAR_3 += count_contiguous_free_clusters(VAR_2 - VAR_3, &l2_table[VAR_0 + VAR_3]); cluster_offset = be64_to_cpu(l2_table[VAR_0 + VAR_3]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } VAR_2 = VAR_3; QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + VAR_2 * s->cluster_size; uint64_t old_offset = old_alloc->offset; uint64_t old_end_offset = old_alloc->offset + old_alloc->VAR_2 * s->cluster_size; if (end_offset < old_offset || offset > old_end_offset) { } else { if (offset < old_offset) { VAR_2 = (old_offset - offset) >> s->cluster_bits; } else { VAR_2 = 0; } if (VAR_2 == 0) { m->depends_on = old_alloc; m->VAR_2 = 0; *num = 0; return 0; } } } if (!VAR_2) { abort(); } QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); cluster_offset = qcow2_alloc_clusters(bs, VAR_2 * s->cluster_size); m->offset = offset; m->n_start = n_start; m->VAR_2 = VAR_2; out: m->nb_available = MIN(VAR_2 << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
[ "uint64_t FUNC_0(BlockDriverState *bs,\nuint64_t offset,\nint n_start, int n_end,\nint *num, QCowL2Meta *m)\n{", "BDRVQcowState *s = bs->opaque;", "int VAR_0, VAR_1;", "uint64_t l2_offset, *l2_table, cluster_offset;", "int VAR_2, VAR_3 = 0;", "QCowL2Meta *old_alloc;", "VAR_1 = get_cluster_table(bs, offset, &l2_table, &l2_offset, &VAR_0);", "if (VAR_1 == 0)\nreturn 0;", "VAR_2 = size_to_clusters(s, n_end << 9);", "VAR_2 = MIN(VAR_2, s->l2_size - VAR_0);", "cluster_offset = be64_to_cpu(l2_table[VAR_0]);", "if (cluster_offset & QCOW_OFLAG_COPIED) {", "VAR_2 = count_contiguous_clusters(VAR_2, s->cluster_size,\n&l2_table[VAR_0], 0, 0);", "cluster_offset &= ~QCOW_OFLAG_COPIED;", "m->VAR_2 = 0;", "goto out;", "}", "if (cluster_offset & QCOW_OFLAG_COMPRESSED)\nVAR_2 = 1;", "while (VAR_3 < VAR_2) {", "VAR_3 += count_contiguous_clusters(VAR_2 - VAR_3, s->cluster_size,\n&l2_table[VAR_0], VAR_3, 0);", "if(be64_to_cpu(l2_table[VAR_0 + VAR_3]))\nbreak;", "VAR_3 += count_contiguous_free_clusters(VAR_2 - VAR_3,\n&l2_table[VAR_0 + VAR_3]);", "cluster_offset = be64_to_cpu(l2_table[VAR_0 + VAR_3]);", "if ((cluster_offset & QCOW_OFLAG_COPIED) ||\n(cluster_offset & QCOW_OFLAG_COMPRESSED))\nbreak;", "}", "VAR_2 = VAR_3;", "QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {", "uint64_t end_offset = offset + VAR_2 * s->cluster_size;", "uint64_t old_offset = old_alloc->offset;", "uint64_t old_end_offset = old_alloc->offset +\nold_alloc->VAR_2 * s->cluster_size;", "if (end_offset < old_offset || offset > old_end_offset) {", "} else {", "if (offset < old_offset) {", "VAR_2 = (old_offset - offset) >> s->cluster_bits;", "} else {", "VAR_2 = 0;", "}", "if (VAR_2 == 0) {", "m->depends_on = old_alloc;", "m->VAR_2 = 0;", "*num = 0;", "return 0;", "}", "}", "}", "if (!VAR_2) {", "abort();", "}", "QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight);", "cluster_offset = qcow2_alloc_clusters(bs, VAR_2 * s->cluster_size);", "m->offset = offset;", "m->n_start = n_start;", "m->VAR_2 = VAR_2;", "out:\nm->nb_available = MIN(VAR_2 << (s->cluster_bits - 9), n_end);", "*num = m->nb_available - n_start;", "return cluster_offset;", "}" ]
[ 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 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 35 ], [ 39 ], [ 47 ], [ 49, 51 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 71, 73 ], [ 81 ], [ 83, 85 ], [ 89, 91 ], [ 95, 97 ], [ 101 ], [ 105, 107, 109 ], [ 111 ], [ 113 ], [ 127 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 141 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 197 ], [ 203 ], [ 205 ], [ 207 ], [ 211, 213 ], [ 217 ], [ 221 ], [ 223 ] ]
90
void ff_xvmc_init_block(MpegEncContext *s) { struct xvmc_render_state *render = (struct xvmc_render_state*)s->current_picture.data[2]; assert(render); if (!render || render->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return; // make sure that this is a render packet } s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); }
true
FFmpeg
967d2ae616a1fc6ffc2c00810e09c232dfdb7911
void ff_xvmc_init_block(MpegEncContext *s) { struct xvmc_render_state *render = (struct xvmc_render_state*)s->current_picture.data[2]; assert(render); if (!render || render->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return; } s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); }
{ "code": [ " assert(render);" ], "line_no": [ 7 ] }
void FUNC_0(MpegEncContext *VAR_0) { struct xvmc_render_state *VAR_1 = (struct xvmc_render_state*)VAR_0->current_picture.data[2]; assert(VAR_1); if (!VAR_1 || VAR_1->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return; } VAR_0->block = (DCTELEM *)(VAR_1->data_blocks + VAR_1->next_free_data_block_num * 64); }
[ "void FUNC_0(MpegEncContext *VAR_0)\n{", "struct xvmc_render_state *VAR_1 = (struct xvmc_render_state*)VAR_0->current_picture.data[2];", "assert(VAR_1);", "if (!VAR_1 || VAR_1->magic != AV_XVMC_RENDER_MAGIC) {", "assert(0);", "return;", "}", "VAR_0->block = (DCTELEM *)(VAR_1->data_blocks + VAR_1->next_free_data_block_num * 64);", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
91
void do_adde (void) { T2 = T0; T0 += T1 + xer_ca; if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) { xer_ca = 0; } else { xer_ca = 1; } }
true
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
void do_adde (void) { T2 = T0; T0 += T1 + xer_ca; if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) { xer_ca = 0; } else { xer_ca = 1; } }
{ "code": [ " T2 = T0;", " xer_ca = 1;", " } else {", " xer_ca = 0;", " xer_ca = 1;", " } else {", " xer_ca = 0;", " xer_ca = 1;", " } else {", " T2 = T0;", " } else {", " T2 = T0;", " xer_ca = 0;", " } else {", " xer_ca = 1;", " } else {", " if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) {", " if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) {", " } else {", " xer_ca = 0;", " } else {", " T2 = T0;", " T2 = T0;", " xer_ca = 0;", " } else {", " xer_ca = 1;", " T2 = T0;", " xer_ca = 0;", " } else {" ], "line_no": [ 5, 15, 13, 11, 15, 13, 11, 15, 13, 5, 13, 5, 11, 13, 15, 13, 9, 9, 13, 11, 13, 5, 5, 11, 13, 15, 5, 11, 13 ] }
void FUNC_0 (void) { T2 = T0; T0 += T1 + xer_ca; if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) { xer_ca = 0; } else { xer_ca = 1; } }
[ "void FUNC_0 (void)\n{", "T2 = T0;", "T0 += T1 + xer_ca;", "if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) {", "xer_ca = 0;", "} else {", "xer_ca = 1;", "}", "}" ]
[ 0, 1, 0, 1, 1, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
92
static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr) { ECCState *s = opaque; uint32_t ret = 0; switch (addr & ECC_ADDR_MASK) { case ECC_MER: ret = s->regs[0]; DPRINTF("Read memory enable %08x\n", ret); break; case ECC_MDR: ret = s->regs[1]; DPRINTF("Read memory delay %08x\n", ret); break; case ECC_MFSR: ret = s->regs[2]; DPRINTF("Read memory fault status %08x\n", ret); break; case ECC_VCR: ret = s->regs[3]; DPRINTF("Read slot configuration %08x\n", ret); break; case ECC_MFAR0: ret = s->regs[4]; DPRINTF("Read memory fault address 0 %08x\n", ret); break; case ECC_MFAR1: ret = s->regs[5]; DPRINTF("Read memory fault address 1 %08x\n", ret); break; case ECC_DR: ret = s->regs[6]; DPRINTF("Read diagnostic %08x\n", ret); break; case ECC_ECR0: ret = s->regs[7]; DPRINTF("Read event count 1 %08x\n", ret); break; case ECC_ECR1: ret = s->regs[7]; DPRINTF("Read event count 2 %08x\n", ret); break; } return ret; }
true
qemu
8f2ad0a3fc5e3569183d44bf1c7fcb95294be4c0
static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr) { ECCState *s = opaque; uint32_t ret = 0; switch (addr & ECC_ADDR_MASK) { case ECC_MER: ret = s->regs[0]; DPRINTF("Read memory enable %08x\n", ret); break; case ECC_MDR: ret = s->regs[1]; DPRINTF("Read memory delay %08x\n", ret); break; case ECC_MFSR: ret = s->regs[2]; DPRINTF("Read memory fault status %08x\n", ret); break; case ECC_VCR: ret = s->regs[3]; DPRINTF("Read slot configuration %08x\n", ret); break; case ECC_MFAR0: ret = s->regs[4]; DPRINTF("Read memory fault address 0 %08x\n", ret); break; case ECC_MFAR1: ret = s->regs[5]; DPRINTF("Read memory fault address 1 %08x\n", ret); break; case ECC_DR: ret = s->regs[6]; DPRINTF("Read diagnostic %08x\n", ret); break; case ECC_ECR0: ret = s->regs[7]; DPRINTF("Read event count 1 %08x\n", ret); break; case ECC_ECR1: ret = s->regs[7]; DPRINTF("Read event count 2 %08x\n", ret); break; } return ret; }
{ "code": [ " switch (addr & ECC_ADDR_MASK) {", " switch (addr & ECC_ADDR_MASK) {", " ret = s->regs[0];", " ret = s->regs[1];", " ret = s->regs[2];", " ret = s->regs[3];", " ret = s->regs[4];", " ret = s->regs[5];", " ret = s->regs[6];", " ret = s->regs[7];", " ret = s->regs[7];" ], "line_no": [ 11, 11, 15, 23, 31, 39, 47, 55, 63, 71, 71 ] }
static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr) { ECCState *s = opaque; uint32_t ret = 0; switch (addr & ECC_ADDR_MASK) { case ECC_MER: ret = s->regs[0]; DPRINTF("Read memory enable %08x\n", ret); break; case ECC_MDR: ret = s->regs[1]; DPRINTF("Read memory delay %08x\n", ret); break; case ECC_MFSR: ret = s->regs[2]; DPRINTF("Read memory fault status %08x\n", ret); break; case ECC_VCR: ret = s->regs[3]; DPRINTF("Read slot configuration %08x\n", ret); break; case ECC_MFAR0: ret = s->regs[4]; DPRINTF("Read memory fault address 0 %08x\n", ret); break; case ECC_MFAR1: ret = s->regs[5]; DPRINTF("Read memory fault address 1 %08x\n", ret); break; case ECC_DR: ret = s->regs[6]; DPRINTF("Read diagnostic %08x\n", ret); break; case ECC_ECR0: ret = s->regs[7]; DPRINTF("Read event count 1 %08x\n", ret); break; case ECC_ECR1: ret = s->regs[7]; DPRINTF("Read event count 2 %08x\n", ret); break; } return ret; }
[ "static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{", "ECCState *s = opaque;", "uint32_t ret = 0;", "switch (addr & ECC_ADDR_MASK) {", "case ECC_MER:\nret = s->regs[0];", "DPRINTF(\"Read memory enable %08x\\n\", ret);", "break;", "case ECC_MDR:\nret = s->regs[1];", "DPRINTF(\"Read memory delay %08x\\n\", ret);", "break;", "case ECC_MFSR:\nret = s->regs[2];", "DPRINTF(\"Read memory fault status %08x\\n\", ret);", "break;", "case ECC_VCR:\nret = s->regs[3];", "DPRINTF(\"Read slot configuration %08x\\n\", ret);", "break;", "case ECC_MFAR0:\nret = s->regs[4];", "DPRINTF(\"Read memory fault address 0 %08x\\n\", ret);", "break;", "case ECC_MFAR1:\nret = s->regs[5];", "DPRINTF(\"Read memory fault address 1 %08x\\n\", ret);", "break;", "case ECC_DR:\nret = s->regs[6];", "DPRINTF(\"Read diagnostic %08x\\n\", ret);", "break;", "case ECC_ECR0:\nret = s->regs[7];", "DPRINTF(\"Read event count 1 %08x\\n\", ret);", "break;", "case ECC_ECR1:\nret = s->regs[7];", "DPRINTF(\"Read event count 2 %08x\\n\", ret);", "break;", "}", "return ret;", "}" ]
[ 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 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 ] ]
93
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int i, ret = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *got_sub_ptr = 0; avcodec_get_subtitle_defaults(sub); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); //apply_param_change(avctx, &tmp); pkt_recoded = tmp; ret = recode_subtitle(avctx, &pkt_recoded, &tmp); if (ret < 0) { *got_sub_ptr = 0; } else { avctx->internal->pkt = &pkt_recoded; if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded); av_assert1((ret >= 0) >= !!*got_sub_ptr && !!*got_sub_ptr >= !!sub->num_rects); if (sub->num_rects && !sub->end_display_time && avpkt->duration && avctx->pkt_timebase.num) { AVRational ms = { 1, 1000 }; sub->end_display_time = av_rescale_q(avpkt->duration, avctx->pkt_timebase, ms); for (i = 0; i < sub->num_rects; i++) { if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { av_log(avctx, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(sub); return AVERROR_INVALIDDATA; if (tmp.data != pkt_recoded.data) { // did we recode? /* prevent from destroying side data from original packet */ pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; av_free_packet(&pkt_recoded); if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 0; else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) sub->format = 1; avctx->internal->pkt = NULL; av_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; if (*got_sub_ptr) avctx->frame_number++; return ret;
true
FFmpeg
01923bab98506b1e98b4cbf08419364ce6ffea6d
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int i, ret = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *got_sub_ptr = 0; avcodec_get_subtitle_defaults(sub); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); pkt_recoded = tmp; ret = recode_subtitle(avctx, &pkt_recoded, &tmp); if (ret < 0) { *got_sub_ptr = 0; } else { avctx->internal->pkt = &pkt_recoded; if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded); av_assert1((ret >= 0) >= !!*got_sub_ptr && !!*got_sub_ptr >= !!sub->num_rects); if (sub->num_rects && !sub->end_display_time && avpkt->duration && avctx->pkt_timebase.num) { AVRational ms = { 1, 1000 }; sub->end_display_time = av_rescale_q(avpkt->duration, avctx->pkt_timebase, ms); for (i = 0; i < sub->num_rects; i++) { if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { av_log(avctx, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(sub); return AVERROR_INVALIDDATA; if (tmp.data != pkt_recoded.data) { pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; av_free_packet(&pkt_recoded); if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 0; else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) sub->format = 1; avctx->internal->pkt = NULL; av_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; if (*got_sub_ptr) avctx->frame_number++; return ret;
{ "code": [], "line_no": [] }
int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1, int *VAR_2, AVPacket *VAR_3) { int VAR_4, VAR_5 = 0; if (!VAR_3->data && VAR_3->size) { av_log(VAR_0, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!VAR_0->codec) return AVERROR(EINVAL); if (VAR_0->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(VAR_0, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *VAR_2 = 0; avcodec_get_subtitle_defaults(VAR_1); if ((VAR_0->codec->capabilities & CODEC_CAP_DELAY) || VAR_3->size) { AVPacket pkt_recoded; AVPacket tmp = *VAR_3; int VAR_6 = av_packet_split_side_data(&tmp); pkt_recoded = tmp; VAR_5 = recode_subtitle(VAR_0, &pkt_recoded, &tmp); if (VAR_5 < 0) { *VAR_2 = 0; } else { VAR_0->internal->pkt = &pkt_recoded; if (VAR_0->pkt_timebase.den && VAR_3->pts != AV_NOPTS_VALUE) VAR_1->pts = av_rescale_q(VAR_3->pts, VAR_0->pkt_timebase, AV_TIME_BASE_Q); VAR_5 = VAR_0->codec->decode(VAR_0, VAR_1, VAR_2, &pkt_recoded); av_assert1((VAR_5 >= 0) >= !!*VAR_2 && !!*VAR_2 >= !!VAR_1->num_rects); if (VAR_1->num_rects && !VAR_1->end_display_time && VAR_3->duration && VAR_0->pkt_timebase.num) { AVRational ms = { 1, 1000 }; VAR_1->end_display_time = av_rescale_q(VAR_3->duration, VAR_0->pkt_timebase, ms); for (VAR_4 = 0; VAR_4 < VAR_1->num_rects; VAR_4++) { if (VAR_1->rects[VAR_4]->ass && !utf8_check(VAR_1->rects[VAR_4]->ass)) { av_log(VAR_0, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(VAR_1); return AVERROR_INVALIDDATA; if (tmp.data != pkt_recoded.data) { pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; av_free_packet(&pkt_recoded); if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) VAR_1->format = 0; else if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) VAR_1->format = 1; VAR_0->internal->pkt = NULL; av_packet_free_side_data(&tmp); if(VAR_5 == tmp.size) VAR_5 = VAR_3->size; if (*VAR_2) VAR_0->frame_number++; return VAR_5;
[ "int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1,\nint *VAR_2,\nAVPacket *VAR_3)\n{", "int VAR_4, VAR_5 = 0;", "if (!VAR_3->data && VAR_3->size) {", "av_log(VAR_0, AV_LOG_ERROR, \"invalid packet: NULL data, size != 0\\n\");", "return AVERROR(EINVAL);", "if (!VAR_0->codec)\nreturn AVERROR(EINVAL);", "if (VAR_0->codec->type != AVMEDIA_TYPE_SUBTITLE) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid media type for subtitles\\n\");", "return AVERROR(EINVAL);", "*VAR_2 = 0;", "avcodec_get_subtitle_defaults(VAR_1);", "if ((VAR_0->codec->capabilities & CODEC_CAP_DELAY) || VAR_3->size) {", "AVPacket pkt_recoded;", "AVPacket tmp = *VAR_3;", "int VAR_6 = av_packet_split_side_data(&tmp);", "pkt_recoded = tmp;", "VAR_5 = recode_subtitle(VAR_0, &pkt_recoded, &tmp);", "if (VAR_5 < 0) {", "*VAR_2 = 0;", "} else {", "VAR_0->internal->pkt = &pkt_recoded;", "if (VAR_0->pkt_timebase.den && VAR_3->pts != AV_NOPTS_VALUE)\nVAR_1->pts = av_rescale_q(VAR_3->pts,\nVAR_0->pkt_timebase, AV_TIME_BASE_Q);", "VAR_5 = VAR_0->codec->decode(VAR_0, VAR_1, VAR_2, &pkt_recoded);", "av_assert1((VAR_5 >= 0) >= !!*VAR_2 &&\n!!*VAR_2 >= !!VAR_1->num_rects);", "if (VAR_1->num_rects && !VAR_1->end_display_time && VAR_3->duration &&\nVAR_0->pkt_timebase.num) {", "AVRational ms = { 1, 1000 };", "VAR_1->end_display_time = av_rescale_q(VAR_3->duration,\nVAR_0->pkt_timebase, ms);", "for (VAR_4 = 0; VAR_4 < VAR_1->num_rects; VAR_4++) {", "if (VAR_1->rects[VAR_4]->ass && !utf8_check(VAR_1->rects[VAR_4]->ass)) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid UTF-8 in decoded subtitles text; \"", "\"maybe missing -sub_charenc option\\n\");", "avsubtitle_free(VAR_1);", "return AVERROR_INVALIDDATA;", "if (tmp.data != pkt_recoded.data) {", "pkt_recoded.side_data = NULL;", "pkt_recoded.side_data_elems = 0;", "av_free_packet(&pkt_recoded);", "if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)\nVAR_1->format = 0;", "else if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)\nVAR_1->format = 1;", "VAR_0->internal->pkt = NULL;", "av_packet_free_side_data(&tmp);", "if(VAR_5 == tmp.size)\nVAR_5 = VAR_3->size;", "if (*VAR_2)\nVAR_0->frame_number++;", "return VAR_5;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9, 10 ], [ 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ], [ 27, 28, 29 ], [ 30 ], [ 31, 32 ], [ 33, 34 ], [ 35 ], [ 36, 37 ], [ 38 ], [ 39 ], [ 40, 41 ], [ 42 ], [ 43 ], [ 44 ], [ 45 ], [ 47 ], [ 48 ], [ 49 ], [ 50, 51 ], [ 52, 53 ], [ 54 ], [ 55 ], [ 56, 57 ], [ 58, 59 ], [ 60 ] ]
94
static int mp_decode_frame(MPADecodeContext *s, short *samples) { int i, nb_frames, ch; short *samples_ptr; init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, s->inbuf_ptr - s->inbuf - HEADER_SIZE); /* skip error protection field */ if (s->error_protection) get_bits(&s->gb, 16); dprintf("frame %d:\n", s->frame_count); switch(s->layer) { case 1: nb_frames = mp_decode_layer1(s); break; case 2: nb_frames = mp_decode_layer2(s); break; case 3: default: nb_frames = mp_decode_layer3(s); break; } #if defined(DEBUG) for(i=0;i<nb_frames;i++) { for(ch=0;ch<s->nb_channels;ch++) { int j; printf("%d-%d:", i, ch); for(j=0;j<SBLIMIT;j++) printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); printf("\n"); } } #endif /* apply the synthesis filter */ for(ch=0;ch<s->nb_channels;ch++) { samples_ptr = samples + ch; for(i=0;i<nb_frames;i++) { synth_filter(s, ch, samples_ptr, s->nb_channels, s->sb_samples[ch][i]); samples_ptr += 32 * s->nb_channels; } } #ifdef DEBUG s->frame_count++; #endif return nb_frames * 32 * sizeof(short) * s->nb_channels; }
false
FFmpeg
68f593b48433842f3407586679fe07f3e5199ab9
static int mp_decode_frame(MPADecodeContext *s, short *samples) { int i, nb_frames, ch; short *samples_ptr; init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, s->inbuf_ptr - s->inbuf - HEADER_SIZE); if (s->error_protection) get_bits(&s->gb, 16); dprintf("frame %d:\n", s->frame_count); switch(s->layer) { case 1: nb_frames = mp_decode_layer1(s); break; case 2: nb_frames = mp_decode_layer2(s); break; case 3: default: nb_frames = mp_decode_layer3(s); break; } #if defined(DEBUG) for(i=0;i<nb_frames;i++) { for(ch=0;ch<s->nb_channels;ch++) { int j; printf("%d-%d:", i, ch); for(j=0;j<SBLIMIT;j++) printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); printf("\n"); } } #endif for(ch=0;ch<s->nb_channels;ch++) { samples_ptr = samples + ch; for(i=0;i<nb_frames;i++) { synth_filter(s, ch, samples_ptr, s->nb_channels, s->sb_samples[ch][i]); samples_ptr += 32 * s->nb_channels; } } #ifdef DEBUG s->frame_count++; #endif return nb_frames * 32 * sizeof(short) * s->nb_channels; }
{ "code": [], "line_no": [] }
static int FUNC_0(MPADecodeContext *VAR_0, short *VAR_1) { int VAR_2, VAR_3, VAR_4; short *VAR_5; init_get_bits(&VAR_0->gb, VAR_0->inbuf + HEADER_SIZE, VAR_0->inbuf_ptr - VAR_0->inbuf - HEADER_SIZE); if (VAR_0->error_protection) get_bits(&VAR_0->gb, 16); dprintf("frame %d:\n", VAR_0->frame_count); switch(VAR_0->layer) { case 1: VAR_3 = mp_decode_layer1(VAR_0); break; case 2: VAR_3 = mp_decode_layer2(VAR_0); break; case 3: default: VAR_3 = mp_decode_layer3(VAR_0); break; } #if defined(DEBUG) for(VAR_2=0;VAR_2<VAR_3;VAR_2++) { for(VAR_4=0;VAR_4<VAR_0->nb_channels;VAR_4++) { int j; printf("%d-%d:", VAR_2, VAR_4); for(j=0;j<SBLIMIT;j++) printf(" %0.6f", (double)VAR_0->sb_samples[VAR_4][VAR_2][j] / FRAC_ONE); printf("\n"); } } #endif for(VAR_4=0;VAR_4<VAR_0->nb_channels;VAR_4++) { VAR_5 = VAR_1 + VAR_4; for(VAR_2=0;VAR_2<VAR_3;VAR_2++) { synth_filter(VAR_0, VAR_4, VAR_5, VAR_0->nb_channels, VAR_0->sb_samples[VAR_4][VAR_2]); VAR_5 += 32 * VAR_0->nb_channels; } } #ifdef DEBUG VAR_0->frame_count++; #endif return VAR_3 * 32 * sizeof(short) * VAR_0->nb_channels; }
[ "static int FUNC_0(MPADecodeContext *VAR_0,\nshort *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4;", "short *VAR_5;", "init_get_bits(&VAR_0->gb, VAR_0->inbuf + HEADER_SIZE,\nVAR_0->inbuf_ptr - VAR_0->inbuf - HEADER_SIZE);", "if (VAR_0->error_protection)\nget_bits(&VAR_0->gb, 16);", "dprintf(\"frame %d:\\n\", VAR_0->frame_count);", "switch(VAR_0->layer) {", "case 1:\nVAR_3 = mp_decode_layer1(VAR_0);", "break;", "case 2:\nVAR_3 = mp_decode_layer2(VAR_0);", "break;", "case 3:\ndefault:\nVAR_3 = mp_decode_layer3(VAR_0);", "break;", "}", "#if defined(DEBUG)\nfor(VAR_2=0;VAR_2<VAR_3;VAR_2++) {", "for(VAR_4=0;VAR_4<VAR_0->nb_channels;VAR_4++) {", "int j;", "printf(\"%d-%d:\", VAR_2, VAR_4);", "for(j=0;j<SBLIMIT;j++)", "printf(\" %0.6f\", (double)VAR_0->sb_samples[VAR_4][VAR_2][j] / FRAC_ONE);", "printf(\"\\n\");", "}", "}", "#endif\nfor(VAR_4=0;VAR_4<VAR_0->nb_channels;VAR_4++) {", "VAR_5 = VAR_1 + VAR_4;", "for(VAR_2=0;VAR_2<VAR_3;VAR_2++) {", "synth_filter(VAR_0, VAR_4, VAR_5, VAR_0->nb_channels,\nVAR_0->sb_samples[VAR_4][VAR_2]);", "VAR_5 += 32 * VAR_0->nb_channels;", "}", "}", "#ifdef DEBUG\nVAR_0->frame_count++;", "#endif\nreturn VAR_3 * 32 * sizeof(short) * VAR_0->nb_channels;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43, 45, 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97, 99 ], [ 101 ] ]
95
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { PCMDecode *s = avctx->priv_data; int sample_size, c, n; short *samples; const uint8_t *src, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; samples = data; src = buf; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); return -1; } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ if (CODEC_ID_PCM_DVD == avctx->codec_id) /* 2 samples are interleaved per block in PCM_DVD */ sample_size = avctx->bits_per_coded_sample * 2 / 8; n = avctx->channels * sample_size; if(n && buf_size % n){ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } buf_size= FFMIN(buf_size, *data_size/2); *data_size=0; n = buf_size/sample_size; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; // sync flags are here *samples++ = ff_reverse[(v >> 8) & 0xff] + (ff_reverse[v & 0xff] << 8); } break; case CODEC_ID_PCM_S16LE_PLANAR: n /= avctx->channels; for(c=0;c<avctx->channels;c++) src2[c] = &src[c*n*2]; for(;n>0;n--) for(c=0;c<avctx->channels;c++) *samples++ = bytestream_get_le16(&src2[c]); src = src2[avctx->channels-1]; break; case CODEC_ID_PCM_U16LE: DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: DECODE(uint16_t, be16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: dstu8= (uint8_t*)samples; for(;n>0;n--) { *dstu8++ = *src++ + 128; } samples= (short*)dstu8; break; #if WORDS_BIGENDIAN case CODEC_ID_PCM_F64LE: DECODE(int64_t, le64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: DECODE(int32_t, le32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16LE: DECODE(int16_t, le16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: DECODE(int64_t, be64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: DECODE(int32_t, be32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16BE: DECODE(int16_t, be16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif /* WORDS_BIGENDIAN */ case CODEC_ID_PCM_U8: memcpy(samples, src, n*sample_size); src += n*sample_size; samples = (short*)((uint8_t*)data + n*sample_size); break; case CODEC_ID_PCM_ZORK: for(;n>0;n--) { int x= *src++; if(x&128) x-= 128; else x = -x; *samples++ = x << 8; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;n>0;n--) { *samples++ = s->table[*src++]; } break; case CODEC_ID_PCM_DVD: dst_int32_t = data; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12); } src = src8; } break; case 24: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); } src = src8; } break; default: av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return -1; break; } samples = (short *) dst_int32_t; break; default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
false
FFmpeg
469f5f251dc3acbb4c4fd12c597d57768119af4a
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { PCMDecode *s = avctx->priv_data; int sample_size, c, n; short *samples; const uint8_t *src, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; samples = data; src = buf; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); return -1; } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; if (CODEC_ID_PCM_DVD == avctx->codec_id) sample_size = avctx->bits_per_coded_sample * 2 / 8; n = avctx->channels * sample_size; if(n && buf_size % n){ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } buf_size= FFMIN(buf_size, *data_size/2); *data_size=0; n = buf_size/sample_size; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; *samples++ = ff_reverse[(v >> 8) & 0xff] + (ff_reverse[v & 0xff] << 8); } break; case CODEC_ID_PCM_S16LE_PLANAR: n /= avctx->channels; for(c=0;c<avctx->channels;c++) src2[c] = &src[c*n*2]; for(;n>0;n--) for(c=0;c<avctx->channels;c++) *samples++ = bytestream_get_le16(&src2[c]); src = src2[avctx->channels-1]; break; case CODEC_ID_PCM_U16LE: DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: DECODE(uint16_t, be16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: dstu8= (uint8_t*)samples; for(;n>0;n--) { *dstu8++ = *src++ + 128; } samples= (short*)dstu8; break; #if WORDS_BIGENDIAN case CODEC_ID_PCM_F64LE: DECODE(int64_t, le64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: DECODE(int32_t, le32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16LE: DECODE(int16_t, le16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: DECODE(int64_t, be64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: DECODE(int32_t, be32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16BE: DECODE(int16_t, be16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif case CODEC_ID_PCM_U8: memcpy(samples, src, n*sample_size); src += n*sample_size; samples = (short*)((uint8_t*)data + n*sample_size); break; case CODEC_ID_PCM_ZORK: for(;n>0;n--) { int x= *src++; if(x&128) x-= 128; else x = -x; *samples++ = x << 8; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;n>0;n--) { *samples++ = s->table[*src++]; } break; case CODEC_ID_PCM_DVD: dst_int32_t = data; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12); } src = src8; } break; case 24: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); } src = src8; } break; default: av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return -1; break; } samples = (short *) dst_int32_t; break; default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, const uint8_t *VAR_3, int VAR_4) { PCMDecode *s = VAR_0->priv_data; int VAR_5, VAR_6, VAR_7; short *VAR_8; const uint8_t *VAR_9, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; VAR_8 = VAR_1; VAR_9 = VAR_3; if (VAR_0->sample_fmt!=VAR_0->codec->sample_fmts[0]) { av_log(VAR_0, AV_LOG_ERROR, "invalid sample_fmt\VAR_7"); return -1; } if(VAR_0->channels <= 0 || VAR_0->channels > MAX_CHANNELS){ av_log(VAR_0, AV_LOG_ERROR, "PCM channels out of bounds\VAR_7"); return -1; } VAR_5 = av_get_bits_per_sample(VAR_0->codec_id)/8; if (CODEC_ID_PCM_DVD == VAR_0->codec_id) VAR_5 = VAR_0->bits_per_coded_sample * 2 / 8; VAR_7 = VAR_0->channels * VAR_5; if(VAR_7 && VAR_4 % VAR_7){ av_log(VAR_0, AV_LOG_ERROR, "invalid PCM packet\VAR_7"); return -1; } VAR_4= FFMIN(VAR_4, *VAR_2/2); *VAR_2=0; VAR_7 = VAR_4/VAR_5; switch(VAR_0->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, VAR_9, VAR_8, VAR_7, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, VAR_9, VAR_8, VAR_7, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, VAR_9, VAR_8, VAR_7, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, VAR_9, VAR_8, VAR_7, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, VAR_9, VAR_8, VAR_7, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, VAR_9, VAR_8, VAR_7, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;VAR_7>0;VAR_7--) { uint32_t v = bytestream_get_be24(&VAR_9); v >>= 4; *VAR_8++ = ff_reverse[(v >> 8) & 0xff] + (ff_reverse[v & 0xff] << 8); } break; case CODEC_ID_PCM_S16LE_PLANAR: VAR_7 /= VAR_0->channels; for(VAR_6=0;VAR_6<VAR_0->channels;VAR_6++) src2[VAR_6] = &VAR_9[VAR_6*VAR_7*2]; for(;VAR_7>0;VAR_7--) for(VAR_6=0;VAR_6<VAR_0->channels;VAR_6++) *VAR_8++ = bytestream_get_le16(&src2[VAR_6]); VAR_9 = src2[VAR_0->channels-1]; break; case CODEC_ID_PCM_U16LE: DECODE(uint16_t, le16, VAR_9, VAR_8, VAR_7, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: DECODE(uint16_t, be16, VAR_9, VAR_8, VAR_7, 0, 0x8000) break; case CODEC_ID_PCM_S8: dstu8= (uint8_t*)VAR_8; for(;VAR_7>0;VAR_7--) { *dstu8++ = *VAR_9++ + 128; } VAR_8= (short*)dstu8; break; #if WORDS_BIGENDIAN case CODEC_ID_PCM_F64LE: DECODE(int64_t, le64, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: DECODE(int32_t, le32, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_S16LE: DECODE(int16_t, le16, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: DECODE(int64_t, be64, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: DECODE(int32_t, be32, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_S16BE: DECODE(int16_t, be16, VAR_9, VAR_8, VAR_7, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif case CODEC_ID_PCM_U8: memcpy(VAR_8, VAR_9, VAR_7*VAR_5); VAR_9 += VAR_7*VAR_5; VAR_8 = (short*)((uint8_t*)VAR_1 + VAR_7*VAR_5); break; case CODEC_ID_PCM_ZORK: for(;VAR_7>0;VAR_7--) { int VAR_10= *VAR_9++; if(VAR_10&128) VAR_10-= 128; else VAR_10 = -VAR_10; *VAR_8++ = VAR_10 << 8; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;VAR_7>0;VAR_7--) { *VAR_8++ = s->table[*VAR_9++]; } break; case CODEC_ID_PCM_DVD: dst_int32_t = VAR_1; VAR_7 /= VAR_0->channels; switch (VAR_0->bits_per_coded_sample) { case 20: while (VAR_7--) { VAR_6 = VAR_0->channels; src8 = VAR_9 + 4*VAR_6; while (VAR_6--) { *dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8 &0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++ &0x0f) << 12); } VAR_9 = src8; } break; case 24: while (VAR_7--) { VAR_6 = VAR_0->channels; src8 = VAR_9 + 4*VAR_6; while (VAR_6--) { *dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++) << 8); } VAR_9 = src8; } break; default: av_log(VAR_0, AV_LOG_ERROR, "PCM DVD unsupported sample depth\VAR_7"); return -1; break; } VAR_8 = (short *) dst_int32_t; break; default: return -1; } *VAR_2 = (uint8_t *)VAR_8 - (uint8_t *)VAR_1; return VAR_9 - VAR_3; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{", "PCMDecode *s = VAR_0->priv_data;", "int VAR_5, VAR_6, VAR_7;", "short *VAR_8;", "const uint8_t *VAR_9, *src8, *src2[MAX_CHANNELS];", "uint8_t *dstu8;", "int16_t *dst_int16_t;", "int32_t *dst_int32_t;", "int64_t *dst_int64_t;", "uint16_t *dst_uint16_t;", "uint32_t *dst_uint32_t;", "VAR_8 = VAR_1;", "VAR_9 = VAR_3;", "if (VAR_0->sample_fmt!=VAR_0->codec->sample_fmts[0]) {", "av_log(VAR_0, AV_LOG_ERROR, \"invalid sample_fmt\\VAR_7\");", "return -1;", "}", "if(VAR_0->channels <= 0 || VAR_0->channels > MAX_CHANNELS){", "av_log(VAR_0, AV_LOG_ERROR, \"PCM channels out of bounds\\VAR_7\");", "return -1;", "}", "VAR_5 = av_get_bits_per_sample(VAR_0->codec_id)/8;", "if (CODEC_ID_PCM_DVD == VAR_0->codec_id)\nVAR_5 = VAR_0->bits_per_coded_sample * 2 / 8;", "VAR_7 = VAR_0->channels * VAR_5;", "if(VAR_7 && VAR_4 % VAR_7){", "av_log(VAR_0, AV_LOG_ERROR, \"invalid PCM packet\\VAR_7\");", "return -1;", "}", "VAR_4= FFMIN(VAR_4, *VAR_2/2);", "*VAR_2=0;", "VAR_7 = VAR_4/VAR_5;", "switch(VAR_0->codec->id) {", "case CODEC_ID_PCM_U32LE:\nDECODE(uint32_t, le32, VAR_9, VAR_8, VAR_7, 0, 0x80000000)\nbreak;", "case CODEC_ID_PCM_U32BE:\nDECODE(uint32_t, be32, VAR_9, VAR_8, VAR_7, 0, 0x80000000)\nbreak;", "case CODEC_ID_PCM_S24LE:\nDECODE(int32_t, le24, VAR_9, VAR_8, VAR_7, 8, 0)\nbreak;", "case CODEC_ID_PCM_S24BE:\nDECODE(int32_t, be24, VAR_9, VAR_8, VAR_7, 8, 0)\nbreak;", "case CODEC_ID_PCM_U24LE:\nDECODE(uint32_t, le24, VAR_9, VAR_8, VAR_7, 8, 0x800000)\nbreak;", "case CODEC_ID_PCM_U24BE:\nDECODE(uint32_t, be24, VAR_9, VAR_8, VAR_7, 8, 0x800000)\nbreak;", "case CODEC_ID_PCM_S24DAUD:\nfor(;VAR_7>0;VAR_7--) {", "uint32_t v = bytestream_get_be24(&VAR_9);", "v >>= 4;", "*VAR_8++ = ff_reverse[(v >> 8) & 0xff] +\n(ff_reverse[v & 0xff] << 8);", "}", "break;", "case CODEC_ID_PCM_S16LE_PLANAR:\nVAR_7 /= VAR_0->channels;", "for(VAR_6=0;VAR_6<VAR_0->channels;VAR_6++)", "src2[VAR_6] = &VAR_9[VAR_6*VAR_7*2];", "for(;VAR_7>0;VAR_7--)", "for(VAR_6=0;VAR_6<VAR_0->channels;VAR_6++)", "*VAR_8++ = bytestream_get_le16(&src2[VAR_6]);", "VAR_9 = src2[VAR_0->channels-1];", "break;", "case CODEC_ID_PCM_U16LE:\nDECODE(uint16_t, le16, VAR_9, VAR_8, VAR_7, 0, 0x8000)\nbreak;", "case CODEC_ID_PCM_U16BE:\nDECODE(uint16_t, be16, VAR_9, VAR_8, VAR_7, 0, 0x8000)\nbreak;", "case CODEC_ID_PCM_S8:\ndstu8= (uint8_t*)VAR_8;", "for(;VAR_7>0;VAR_7--) {", "*dstu8++ = *VAR_9++ + 128;", "}", "VAR_8= (short*)dstu8;", "break;", "#if WORDS_BIGENDIAN\ncase CODEC_ID_PCM_F64LE:\nDECODE(int64_t, le64, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_S32LE:\ncase CODEC_ID_PCM_F32LE:\nDECODE(int32_t, le32, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_S16LE:\nDECODE(int16_t, le16, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_F64BE:\ncase CODEC_ID_PCM_F32BE:\ncase CODEC_ID_PCM_S32BE:\ncase CODEC_ID_PCM_S16BE:\n#else\ncase CODEC_ID_PCM_F64BE:\nDECODE(int64_t, be64, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_F32BE:\ncase CODEC_ID_PCM_S32BE:\nDECODE(int32_t, be32, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_S16BE:\nDECODE(int16_t, be16, VAR_9, VAR_8, VAR_7, 0, 0)\nbreak;", "case CODEC_ID_PCM_F64LE:\ncase CODEC_ID_PCM_F32LE:\ncase CODEC_ID_PCM_S32LE:\ncase CODEC_ID_PCM_S16LE:\n#endif\ncase CODEC_ID_PCM_U8:\nmemcpy(VAR_8, VAR_9, VAR_7*VAR_5);", "VAR_9 += VAR_7*VAR_5;", "VAR_8 = (short*)((uint8_t*)VAR_1 + VAR_7*VAR_5);", "break;", "case CODEC_ID_PCM_ZORK:\nfor(;VAR_7>0;VAR_7--) {", "int VAR_10= *VAR_9++;", "if(VAR_10&128) VAR_10-= 128;", "else VAR_10 = -VAR_10;", "*VAR_8++ = VAR_10 << 8;", "}", "break;", "case CODEC_ID_PCM_ALAW:\ncase CODEC_ID_PCM_MULAW:\nfor(;VAR_7>0;VAR_7--) {", "*VAR_8++ = s->table[*VAR_9++];", "}", "break;", "case CODEC_ID_PCM_DVD:\ndst_int32_t = VAR_1;", "VAR_7 /= VAR_0->channels;", "switch (VAR_0->bits_per_coded_sample) {", "case 20:\nwhile (VAR_7--) {", "VAR_6 = VAR_0->channels;", "src8 = VAR_9 + 4*VAR_6;", "while (VAR_6--) {", "*dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8 &0xf0) << 8);", "*dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++ &0x0f) << 12);", "}", "VAR_9 = src8;", "}", "break;", "case 24:\nwhile (VAR_7--) {", "VAR_6 = VAR_0->channels;", "src8 = VAR_9 + 4*VAR_6;", "while (VAR_6--) {", "*dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++) << 8);", "*dst_int32_t++ = (bytestream_get_be16(&VAR_9) << 16) + ((*src8++) << 8);", "}", "VAR_9 = src8;", "}", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"PCM DVD unsupported sample depth\\VAR_7\");", "return -1;", "break;", "}", "VAR_8 = (short *) dst_int32_t;", "break;", "default:\nreturn -1;", "}", "*VAR_2 = (uint8_t *)VAR_8 - (uint8_t *)VAR_1;", "return VAR_9 - VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 63, 67 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 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 ] ]
96
static int write_trailer(AVFormatContext *s) { WVMuxContext *wc = s->priv_data; AVIOContext *pb = s->pb; ff_ape_write(s); if (pb->seekable) { avio_seek(pb, 12, SEEK_SET); avio_wl32(pb, wc->duration); avio_flush(pb); } return 0; }
false
FFmpeg
269fc8e04906ffd965aa19425ca90980b23c6508
static int write_trailer(AVFormatContext *s) { WVMuxContext *wc = s->priv_data; AVIOContext *pb = s->pb; ff_ape_write(s); if (pb->seekable) { avio_seek(pb, 12, SEEK_SET); avio_wl32(pb, wc->duration); avio_flush(pb); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { WVMuxContext *wc = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; ff_ape_write(VAR_0); if (pb->seekable) { avio_seek(pb, 12, SEEK_SET); avio_wl32(pb, wc->duration); avio_flush(pb); } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "WVMuxContext *wc = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "ff_ape_write(VAR_0);", "if (pb->seekable) {", "avio_seek(pb, 12, SEEK_SET);", "avio_wl32(pb, wc->duration);", "avio_flush(pb);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ] ]
97
void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); /* virtio-1 compliant devices cannot change the alignment */ if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } /* Check that the transport told us it was going to do this * (so a buggy transport will immediately assert rather than * silently failing to migrate this state) */ assert(k->has_variable_vring_alignment); vdev->vq[n].vring.align = align; virtio_queue_update_rings(vdev, n); }
false
qemu
95129d6fc9ead97155627a4ca0cfd37282883658
void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } assert(k->has_variable_vring_alignment); vdev->vq[n].vring.align = align; virtio_queue_update_rings(vdev, n); }
{ "code": [], "line_no": [] }
void FUNC_0(VirtIODevice *VAR_0, int VAR_1, int VAR_2) { BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); if (virtio_has_feature(VAR_0, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } assert(k->has_variable_vring_alignment); VAR_0->vq[VAR_1].vring.VAR_2 = VAR_2; virtio_queue_update_rings(VAR_0, VAR_1); }
[ "void FUNC_0(VirtIODevice *VAR_0, int VAR_1, int VAR_2)\n{", "BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));", "VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);", "if (virtio_has_feature(VAR_0, VIRTIO_F_VERSION_1)) {", "error_report(\"tried to modify queue alignment for virtio-1 device\");", "return;", "}", "assert(k->has_variable_vring_alignment);", "VAR_0->vq[VAR_1].vring.VAR_2 = VAR_2;", "virtio_queue_update_rings(VAR_0, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ] ]
98
static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, long width, long height, long lumStride, long chromStride, long dstStride, long vertLumPerChroma) { long y; const x86_reg chromWidth= width>>1; for (y=0; y<height; y++) { #if COMPILE_TEMPLATE_MMX //FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, but very likely memory-limited anyway) __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a", 2) \n\t" PREFETCH" 32(%2, %%"REG_a") \n\t" PREFETCH" 32(%3, %%"REG_a") \n\t" "movq (%2, %%"REG_a"), %%mm0 \n\t" // U(0) "movq %%mm0, %%mm2 \n\t" // U(0) "movq (%3, %%"REG_a"), %%mm1 \n\t" // V(0) "punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0) "punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8) "movq (%1, %%"REG_a",2), %%mm3 \n\t" // Y(0) "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" // Y(8) "movq %%mm0, %%mm4 \n\t" // Y(0) "movq %%mm2, %%mm6 \n\t" // Y(8) "punpcklbw %%mm3, %%mm0 \n\t" // YUYV YUYV(0) "punpckhbw %%mm3, %%mm4 \n\t" // YUYV YUYV(4) "punpcklbw %%mm5, %%mm2 \n\t" // YUYV YUYV(8) "punpckhbw %%mm5, %%mm6 \n\t" // YUYV YUYV(12) MOVNTQ" %%mm0, (%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth) : "%"REG_a ); #else //FIXME adapt the Alpha ASM code from yv12->yuy2 #if HAVE_FAST_64BIT int i; uint64_t *ldst = (uint64_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i += 2) { uint64_t k, l; k = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); l = uc[1] + (yc[2] << 8) + (vc[1] << 16) + (yc[3] << 24); *ldst++ = k + (l << 32); yc += 4; uc += 2; vc += 2; } #else int i, *idst = (int32_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i++) { #if HAVE_BIGENDIAN *idst++ = (uc[0] << 24)+ (yc[0] << 16) + (vc[0] << 8) + (yc[1] << 0); #else *idst++ = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); #endif yc += 2; uc++; vc++; } #endif #endif if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) { usrc += chromStride; vsrc += chromStride; } ysrc += lumStride; dst += dstStride; } #if COMPILE_TEMPLATE_MMX __asm__(EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
false
FFmpeg
d1adad3cca407f493c3637e20ecd4f7124e69212
static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, long width, long height, long lumStride, long chromStride, long dstStride, long vertLumPerChroma) { long y; const x86_reg chromWidth= width>>1; for (y=0; y<height; y++) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a", 2) \n\t" PREFETCH" 32(%2, %%"REG_a") \n\t" PREFETCH" 32(%3, %%"REG_a") \n\t" "movq (%2, %%"REG_a"), %%mm0 \n\t" "movq %%mm0, %%mm2 \n\t" "movq (%3, %%"REG_a"), %%mm1 \n\t" "punpcklbw %%mm1, %%mm0 \n\t" "punpckhbw %%mm1, %%mm2 \n\t" "movq (%1, %%"REG_a",2), %%mm3 \n\t" "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" "movq %%mm0, %%mm4 \n\t" "movq %%mm2, %%mm6 \n\t" "punpcklbw %%mm3, %%mm0 \n\t" "punpckhbw %%mm3, %%mm4 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm6 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth) : "%"REG_a ); #else #if HAVE_FAST_64BIT int i; uint64_t *ldst = (uint64_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i += 2) { uint64_t k, l; k = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); l = uc[1] + (yc[2] << 8) + (vc[1] << 16) + (yc[3] << 24); *ldst++ = k + (l << 32); yc += 4; uc += 2; vc += 2; } #else int i, *idst = (int32_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < chromWidth; i++) { #if HAVE_BIGENDIAN *idst++ = (uc[0] << 24)+ (yc[0] << 16) + (vc[0] << 8) + (yc[1] << 0); #else *idst++ = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); #endif yc += 2; uc++; vc++; } #endif #endif if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) { usrc += chromStride; vsrc += chromStride; } ysrc += lumStride; dst += dstStride; } #if COMPILE_TEMPLATE_MMX __asm__(EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
{ "code": [], "line_no": [] }
static inline void FUNC_0(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, long width, long height, long lumStride, long chromStride, long dstStride, long vertLumPerChroma) { long VAR_0; const x86_reg VAR_1= width>>1; for (VAR_0=0; VAR_0<height; VAR_0++) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a", 2) \n\t" PREFETCH" 32(%2, %%"REG_a") \n\t" PREFETCH" 32(%3, %%"REG_a") \n\t" "movq (%2, %%"REG_a"), %%mm0 \n\t" "movq %%mm0, %%mm2 \n\t" "movq (%3, %%"REG_a"), %%mm1 \n\t" "punpcklbw %%mm1, %%mm0 \n\t" "punpckhbw %%mm1, %%mm2 \n\t" "movq (%1, %%"REG_a",2), %%mm3 \n\t" "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" "movq %%mm0, %%mm4 \n\t" "movq %%mm2, %%mm6 \n\t" "punpcklbw %%mm3, %%mm0 \n\t" "punpckhbw %%mm3, %%mm4 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm6 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 4) \n\t" MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (VAR_1) : "%"REG_a ); #else #if HAVE_FAST_64BIT int i; uint64_t *ldst = (uint64_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < VAR_1; i += 2) { uint64_t k, l; k = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); l = uc[1] + (yc[2] << 8) + (vc[1] << 16) + (yc[3] << 24); *ldst++ = k + (l << 32); yc += 4; uc += 2; vc += 2; } #else int i, *idst = (int32_t *) dst; const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; for (i = 0; i < VAR_1; i++) { #if HAVE_BIGENDIAN *idst++ = (uc[0] << 24)+ (yc[0] << 16) + (vc[0] << 8) + (yc[1] << 0); #else *idst++ = uc[0] + (yc[0] << 8) + (vc[0] << 16) + (yc[1] << 24); #endif yc += 2; uc++; vc++; } #endif #endif if ((VAR_0&(vertLumPerChroma-1)) == vertLumPerChroma-1) { usrc += chromStride; vsrc += chromStride; } ysrc += lumStride; dst += dstStride; } #if COMPILE_TEMPLATE_MMX __asm__(EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
[ "static inline void FUNC_0(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\nlong width, long height,\nlong lumStride, long chromStride, long dstStride, long vertLumPerChroma)\n{", "long VAR_0;", "const x86_reg VAR_1= width>>1;", "for (VAR_0=0; VAR_0<height; VAR_0++) {", "#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\".p2align 4 \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 32(%1, %%\"REG_a\", 2) \\n\\t\"\nPREFETCH\" 32(%2, %%\"REG_a\") \\n\\t\"\nPREFETCH\" 32(%3, %%\"REG_a\") \\n\\t\"\n\"movq (%2, %%\"REG_a\"), %%mm0 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq (%3, %%\"REG_a\"), %%mm1 \\n\\t\"\n\"punpcklbw %%mm1, %%mm0 \\n\\t\"\n\"punpckhbw %%mm1, %%mm2 \\n\\t\"\n\"movq (%1, %%\"REG_a\",2), %%mm3 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",2), %%mm5 \\n\\t\"\n\"movq %%mm0, %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm6 \\n\\t\"\n\"punpcklbw %%mm3, %%mm0 \\n\\t\"\n\"punpckhbw %%mm3, %%mm4 \\n\\t\"\n\"punpcklbw %%mm5, %%mm2 \\n\\t\"\n\"punpckhbw %%mm5, %%mm6 \\n\\t\"\nMOVNTQ\" %%mm0, (%0, %%\"REG_a\", 4) \\n\\t\"\nMOVNTQ\" %%mm4, 8(%0, %%\"REG_a\", 4) \\n\\t\"\nMOVNTQ\" %%mm2, 16(%0, %%\"REG_a\", 4) \\n\\t\"\nMOVNTQ\" %%mm6, 24(%0, %%\"REG_a\", 4) \\n\\t\"\n\"add $8, %%\"REG_a\" \\n\\t\"\n\"cmp %4, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n::\"r\"(dst), \"r\"(ysrc), \"r\"(usrc), \"r\"(vsrc), \"g\" (VAR_1)\n: \"%\"REG_a\n);", "#else\n#if HAVE_FAST_64BIT\nint i;", "uint64_t *ldst = (uint64_t *) dst;", "const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;", "for (i = 0; i < VAR_1; i += 2) {", "uint64_t k, l;", "k = uc[0] + (yc[0] << 8) +\n(vc[0] << 16) + (yc[1] << 24);", "l = uc[1] + (yc[2] << 8) +\n(vc[1] << 16) + (yc[3] << 24);", "*ldst++ = k + (l << 32);", "yc += 4;", "uc += 2;", "vc += 2;", "}", "#else\nint i, *idst = (int32_t *) dst;", "const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;", "for (i = 0; i < VAR_1; i++) {", "#if HAVE_BIGENDIAN\n*idst++ = (uc[0] << 24)+ (yc[0] << 16) +\n(vc[0] << 8) + (yc[1] << 0);", "#else\n*idst++ = uc[0] + (yc[0] << 8) +\n(vc[0] << 16) + (yc[1] << 24);", "#endif\nyc += 2;", "uc++;", "vc++;", "}", "#endif\n#endif\nif ((VAR_0&(vertLumPerChroma-1)) == vertLumPerChroma-1) {", "usrc += chromStride;", "vsrc += chromStride;", "}", "ysrc += lumStride;", "dst += dstStride;", "}", "#if COMPILE_TEMPLATE_MMX\n__asm__(EMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n:::\"memory\");", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 45, 47, 49, 51, 53, 55, 57, 59, 63, 65, 67, 69, 73, 75, 77, 79, 81, 83 ], [ 85, 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 107, 109 ], [ 111 ], [ 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 ], [ 179, 181 ] ]
99
int qcrypto_init(Error **errp) { int ret; ret = gnutls_global_init(); if (ret < 0) { error_setg(errp, "Unable to initialize GNUTLS library: %s", gnutls_strerror(ret)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(errp, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif /* QCRYPTO_INIT_GCRYPT_THREADS */ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
false
qemu
91bfcdb01d4869aa8f4cb67007827de63b8c2217
int qcrypto_init(Error **errp) { int ret; ret = gnutls_global_init(); if (ret < 0) { error_setg(errp, "Unable to initialize GNUTLS library: %s", gnutls_strerror(ret)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(errp, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(Error **VAR_0) { int VAR_1; VAR_1 = gnutls_global_init(); if (VAR_1 < 0) { error_setg(VAR_0, "Unable to initialize GNUTLS library: %s", gnutls_strerror(VAR_1)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(VAR_0, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
[ "int FUNC_0(Error **VAR_0)\n{", "int VAR_1;", "VAR_1 = gnutls_global_init();", "if (VAR_1 < 0) {", "error_setg(VAR_0,\n\"Unable to initialize GNUTLS library: %s\",\ngnutls_strerror(VAR_1));", "return -1;", "}", "#ifdef DEBUG_GNUTLS\ngnutls_global_set_log_level(10);", "gnutls_global_set_log_function(qcrypto_gnutls_log);", "#endif\n#ifdef CONFIG_GNUTLS_GCRYPT\nif (!gcry_check_version(GCRYPT_VERSION)) {", "error_setg(VAR_0, \"Unable to initialize gcrypt\");", "return -1;", "}", "#ifdef QCRYPTO_INIT_GCRYPT_THREADS\ngcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl);", "#endif\ngcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);", "#endif\nreturn 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13, 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27, 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45, 47 ], [ 49, 53 ], [ 55 ] ]
100
static void read_vec_element_i32(DisasContext *s, TCGv_i32 tcg_dest, int srcidx, int element, TCGMemOp memop) { int vect_off = vec_reg_offset(srcidx, element, memop & MO_SIZE); switch (memop) { case MO_8: tcg_gen_ld8u_i32(tcg_dest, cpu_env, vect_off); break; case MO_16: tcg_gen_ld16u_i32(tcg_dest, cpu_env, vect_off); break; case MO_8|MO_SIGN: tcg_gen_ld8s_i32(tcg_dest, cpu_env, vect_off); break; case MO_16|MO_SIGN: tcg_gen_ld16s_i32(tcg_dest, cpu_env, vect_off); break; case MO_32: case MO_32|MO_SIGN: tcg_gen_ld_i32(tcg_dest, cpu_env, vect_off); break; default: g_assert_not_reached(); } }
false
qemu
90e496386fe7fd32c189561f846b7913f95b8cf4
static void read_vec_element_i32(DisasContext *s, TCGv_i32 tcg_dest, int srcidx, int element, TCGMemOp memop) { int vect_off = vec_reg_offset(srcidx, element, memop & MO_SIZE); switch (memop) { case MO_8: tcg_gen_ld8u_i32(tcg_dest, cpu_env, vect_off); break; case MO_16: tcg_gen_ld16u_i32(tcg_dest, cpu_env, vect_off); break; case MO_8|MO_SIGN: tcg_gen_ld8s_i32(tcg_dest, cpu_env, vect_off); break; case MO_16|MO_SIGN: tcg_gen_ld16s_i32(tcg_dest, cpu_env, vect_off); break; case MO_32: case MO_32|MO_SIGN: tcg_gen_ld_i32(tcg_dest, cpu_env, vect_off); break; default: g_assert_not_reached(); } }
{ "code": [], "line_no": [] }
static void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1, int VAR_2, int VAR_3, TCGMemOp VAR_4) { int VAR_5 = vec_reg_offset(VAR_2, VAR_3, VAR_4 & MO_SIZE); switch (VAR_4) { case MO_8: tcg_gen_ld8u_i32(VAR_1, cpu_env, VAR_5); break; case MO_16: tcg_gen_ld16u_i32(VAR_1, cpu_env, VAR_5); break; case MO_8|MO_SIGN: tcg_gen_ld8s_i32(VAR_1, cpu_env, VAR_5); break; case MO_16|MO_SIGN: tcg_gen_ld16s_i32(VAR_1, cpu_env, VAR_5); break; case MO_32: case MO_32|MO_SIGN: tcg_gen_ld_i32(VAR_1, cpu_env, VAR_5); break; default: g_assert_not_reached(); } }
[ "static void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1, int VAR_2,\nint VAR_3, TCGMemOp VAR_4)\n{", "int VAR_5 = vec_reg_offset(VAR_2, VAR_3, VAR_4 & MO_SIZE);", "switch (VAR_4) {", "case MO_8:\ntcg_gen_ld8u_i32(VAR_1, cpu_env, VAR_5);", "break;", "case MO_16:\ntcg_gen_ld16u_i32(VAR_1, cpu_env, VAR_5);", "break;", "case MO_8|MO_SIGN:\ntcg_gen_ld8s_i32(VAR_1, cpu_env, VAR_5);", "break;", "case MO_16|MO_SIGN:\ntcg_gen_ld16s_i32(VAR_1, cpu_env, VAR_5);", "break;", "case MO_32:\ncase MO_32|MO_SIGN:\ntcg_gen_ld_i32(VAR_1, cpu_env, VAR_5);", "break;", "default:\ng_assert_not_reached();", "}", "}" ]
[ 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 ] ]
101
static void vring_desc_read(VirtIODevice *vdev, VRingDesc *desc, hwaddr desc_pa, int i) { address_space_read(&address_space_memory, desc_pa + i * sizeof(VRingDesc), MEMTXATTRS_UNSPECIFIED, (void *)desc, sizeof(VRingDesc)); virtio_tswap64s(vdev, &desc->addr); virtio_tswap32s(vdev, &desc->len); virtio_tswap16s(vdev, &desc->flags); virtio_tswap16s(vdev, &desc->next); }
false
qemu
8607f5c3072caeebbe0217df28651fffd3a79fd9
static void vring_desc_read(VirtIODevice *vdev, VRingDesc *desc, hwaddr desc_pa, int i) { address_space_read(&address_space_memory, desc_pa + i * sizeof(VRingDesc), MEMTXATTRS_UNSPECIFIED, (void *)desc, sizeof(VRingDesc)); virtio_tswap64s(vdev, &desc->addr); virtio_tswap32s(vdev, &desc->len); virtio_tswap16s(vdev, &desc->flags); virtio_tswap16s(vdev, &desc->next); }
{ "code": [], "line_no": [] }
static void FUNC_0(VirtIODevice *VAR_0, VRingDesc *VAR_1, hwaddr VAR_2, int VAR_3) { address_space_read(&address_space_memory, VAR_2 + VAR_3 * sizeof(VRingDesc), MEMTXATTRS_UNSPECIFIED, (void *)VAR_1, sizeof(VRingDesc)); virtio_tswap64s(VAR_0, &VAR_1->addr); virtio_tswap32s(VAR_0, &VAR_1->len); virtio_tswap16s(VAR_0, &VAR_1->flags); virtio_tswap16s(VAR_0, &VAR_1->next); }
[ "static void FUNC_0(VirtIODevice *VAR_0, VRingDesc *VAR_1,\nhwaddr VAR_2, int VAR_3)\n{", "address_space_read(&address_space_memory, VAR_2 + VAR_3 * sizeof(VRingDesc),\nMEMTXATTRS_UNSPECIFIED, (void *)VAR_1, sizeof(VRingDesc));", "virtio_tswap64s(VAR_0, &VAR_1->addr);", "virtio_tswap32s(VAR_0, &VAR_1->len);", "virtio_tswap16s(VAR_0, &VAR_1->flags);", "virtio_tswap16s(VAR_0, &VAR_1->next);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
102
static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { IntelIOMMUState *s = opaque; VTDAddressSpace **pvtd_as; int bus_num = pci_bus_num(bus); assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX); assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); pvtd_as = s->address_spaces[bus_num]; if (!pvtd_as) { /* No corresponding free() */ pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); s->address_spaces[bus_num] = pvtd_as; } if (!pvtd_as[devfn]) { pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); pvtd_as[devfn]->bus_num = (uint8_t)bus_num; pvtd_as[devfn]->devfn = (uint8_t)devfn; pvtd_as[devfn]->iommu_state = s; pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); address_space_init(&pvtd_as[devfn]->as, &pvtd_as[devfn]->iommu, "intel_iommu"); } return &pvtd_as[devfn]->as; }
false
qemu
7df953bd456da45f761064974820ab5c3fd7b2aa
static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { IntelIOMMUState *s = opaque; VTDAddressSpace **pvtd_as; int bus_num = pci_bus_num(bus); assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX); assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); pvtd_as = s->address_spaces[bus_num]; if (!pvtd_as) { pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); s->address_spaces[bus_num] = pvtd_as; } if (!pvtd_as[devfn]) { pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); pvtd_as[devfn]->bus_num = (uint8_t)bus_num; pvtd_as[devfn]->devfn = (uint8_t)devfn; pvtd_as[devfn]->iommu_state = s; pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); address_space_init(&pvtd_as[devfn]->as, &pvtd_as[devfn]->iommu, "intel_iommu"); } return &pvtd_as[devfn]->as; }
{ "code": [], "line_no": [] }
static AddressSpace *FUNC_0(PCIBus *bus, void *opaque, int devfn) { IntelIOMMUState *s = opaque; VTDAddressSpace **pvtd_as; int VAR_0 = pci_bus_num(bus); assert(0 <= VAR_0 && VAR_0 <= VTD_PCI_BUS_MAX); assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); pvtd_as = s->address_spaces[VAR_0]; if (!pvtd_as) { pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); s->address_spaces[VAR_0] = pvtd_as; } if (!pvtd_as[devfn]) { pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); pvtd_as[devfn]->VAR_0 = (uint8_t)VAR_0; pvtd_as[devfn]->devfn = (uint8_t)devfn; pvtd_as[devfn]->iommu_state = s; pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); address_space_init(&pvtd_as[devfn]->as, &pvtd_as[devfn]->iommu, "intel_iommu"); } return &pvtd_as[devfn]->as; }
[ "static AddressSpace *FUNC_0(PCIBus *bus, void *opaque, int devfn)\n{", "IntelIOMMUState *s = opaque;", "VTDAddressSpace **pvtd_as;", "int VAR_0 = pci_bus_num(bus);", "assert(0 <= VAR_0 && VAR_0 <= VTD_PCI_BUS_MAX);", "assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);", "pvtd_as = s->address_spaces[VAR_0];", "if (!pvtd_as) {", "pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);", "s->address_spaces[VAR_0] = pvtd_as;", "}", "if (!pvtd_as[devfn]) {", "pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace));", "pvtd_as[devfn]->VAR_0 = (uint8_t)VAR_0;", "pvtd_as[devfn]->devfn = (uint8_t)devfn;", "pvtd_as[devfn]->iommu_state = s;", "pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0;", "memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s),\n&s->iommu_ops, \"intel_iommu\", UINT64_MAX);", "address_space_init(&pvtd_as[devfn]->as,\n&pvtd_as[devfn]->iommu, \"intel_iommu\");", "}", "return &pvtd_as[devfn]->as;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ] ]
103
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
false
qemu
9be385980d37e8f4fd33f605f5fb1c3d144170a8
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
{ "code": [], "line_no": [] }
static inline uint64_t FUNC_0(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
[ "static inline uint64_t FUNC_0(VmdkExtent *extent,\nint64_t offset)\n{", "uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset;", "uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE;", "extent_begin_offset =\n(extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE;", "extent_relative_offset = offset - extent_begin_offset;", "offset_in_cluster = extent_relative_offset % cluster_size;", "return offset_in_cluster;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ] ]
104
static unsigned int dec_move_pr(DisasContext *dc) { TCGv t0; DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, 0); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op1], cpu_R[dc->op1], t0, preg_sizes[dc->op2]); tcg_temp_free(t0); return 2; }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static unsigned int dec_move_pr(DisasContext *dc) { TCGv t0; DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, 0); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op1], cpu_R[dc->op1], t0, preg_sizes[dc->op2]); tcg_temp_free(t0); return 2; }
{ "code": [], "line_no": [] }
static unsigned int FUNC_0(DisasContext *VAR_0) { TCGv t0; DIS(fprintf (logfile, "move $p%u, $r%u\n", VAR_0->op1, VAR_0->op2)); cris_cc_mask(VAR_0, 0); if (VAR_0->op2 == PR_CCS) cris_evaluate_flags(VAR_0); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, VAR_0->op2); cris_alu(VAR_0, CC_OP_MOVE, cpu_R[VAR_0->op1], cpu_R[VAR_0->op1], t0, preg_sizes[VAR_0->op2]); tcg_temp_free(t0); return 2; }
[ "static unsigned int FUNC_0(DisasContext *VAR_0)\n{", "TCGv t0;", "DIS(fprintf (logfile, \"move $p%u, $r%u\\n\", VAR_0->op1, VAR_0->op2));", "cris_cc_mask(VAR_0, 0);", "if (VAR_0->op2 == PR_CCS)\ncris_evaluate_flags(VAR_0);", "t0 = tcg_temp_new(TCG_TYPE_TL);", "t_gen_mov_TN_preg(t0, VAR_0->op2);", "cris_alu(VAR_0, CC_OP_MOVE,\ncpu_R[VAR_0->op1], cpu_R[VAR_0->op1], t0, preg_sizes[VAR_0->op2]);", "tcg_temp_free(t0);", "return 2;", "}" ]
[ 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 ] ]
105
static void virtio_balloon_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = virtio_balloon_init_pci; k->exit = virtio_balloon_exit_pci; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_MEMORY_RAM; dc->alias = "virtio-balloon"; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
false
qemu
6acbe4c6f18e7de00481ff30574262b58526de45
static void virtio_balloon_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = virtio_balloon_init_pci; k->exit = virtio_balloon_exit_pci; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_MEMORY_RAM; dc->alias = "virtio-balloon"; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
{ "code": [], "line_no": [] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0); k->init = virtio_balloon_init_pci; k->exit = virtio_balloon_exit_pci; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_MEMORY_RAM; dc->alias = "virtio-balloon"; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);", "k->init = virtio_balloon_init_pci;", "k->exit = virtio_balloon_exit_pci;", "k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;", "k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;", "k->revision = VIRTIO_PCI_ABI_VERSION;", "k->class_id = PCI_CLASS_MEMORY_RAM;", "dc->alias = \"virtio-balloon\";", "dc->reset = virtio_pci_reset;", "dc->props = virtio_balloon_properties;", "}" ]
[ 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 ] ]
106
static int fetch_active_ports_list(QEMUFile *f, VirtIOSerial *s, uint32_t nr_active_ports) { uint32_t i; s->post_load = g_malloc0(sizeof(*s->post_load)); s->post_load->nr_active_ports = nr_active_ports; s->post_load->connected = g_malloc0(sizeof(*s->post_load->connected) * nr_active_ports); s->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, s); /* Items in struct VirtIOSerialPort */ for (i = 0; i < nr_active_ports; i++) { VirtIOSerialPort *port; uint32_t elem_popped; uint32_t id; id = qemu_get_be32(f); port = find_port_by_id(s, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(f); s->post_load->connected[i].port = port; s->post_load->connected[i].host_connected = qemu_get_byte(f); qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); port->elem = qemu_get_virtqueue_element(f, sizeof(VirtQueueElement)); /* * Port was throttled on source machine. Let's * unthrottle it here so data starts flowing again. */ virtio_serial_throttle_port(port, false); } } timer_mod(s->post_load->timer, 1); return 0; }
false
qemu
8607f5c3072caeebbe0217df28651fffd3a79fd9
static int fetch_active_ports_list(QEMUFile *f, VirtIOSerial *s, uint32_t nr_active_ports) { uint32_t i; s->post_load = g_malloc0(sizeof(*s->post_load)); s->post_load->nr_active_ports = nr_active_ports; s->post_load->connected = g_malloc0(sizeof(*s->post_load->connected) * nr_active_ports); s->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, s); for (i = 0; i < nr_active_ports; i++) { VirtIOSerialPort *port; uint32_t elem_popped; uint32_t id; id = qemu_get_be32(f); port = find_port_by_id(s, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(f); s->post_load->connected[i].port = port; s->post_load->connected[i].host_connected = qemu_get_byte(f); qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); port->elem = qemu_get_virtqueue_element(f, sizeof(VirtQueueElement)); virtio_serial_throttle_port(port, false); } } timer_mod(s->post_load->timer, 1); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, VirtIOSerial *VAR_1, uint32_t VAR_2) { uint32_t i; VAR_1->post_load = g_malloc0(sizeof(*VAR_1->post_load)); VAR_1->post_load->VAR_2 = VAR_2; VAR_1->post_load->connected = g_malloc0(sizeof(*VAR_1->post_load->connected) * VAR_2); VAR_1->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, VAR_1); for (i = 0; i < VAR_2; i++) { VirtIOSerialPort *port; uint32_t elem_popped; uint32_t id; id = qemu_get_be32(VAR_0); port = find_port_by_id(VAR_1, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(VAR_0); VAR_1->post_load->connected[i].port = port; VAR_1->post_load->connected[i].host_connected = qemu_get_byte(VAR_0); qemu_get_be32s(VAR_0, &elem_popped); if (elem_popped) { qemu_get_be32s(VAR_0, &port->iov_idx); qemu_get_be64s(VAR_0, &port->iov_offset); port->elem = qemu_get_virtqueue_element(VAR_0, sizeof(VirtQueueElement)); virtio_serial_throttle_port(port, false); } } timer_mod(VAR_1->post_load->timer, 1); return 0; }
[ "static int FUNC_0(QEMUFile *VAR_0,\nVirtIOSerial *VAR_1, uint32_t VAR_2)\n{", "uint32_t i;", "VAR_1->post_load = g_malloc0(sizeof(*VAR_1->post_load));", "VAR_1->post_load->VAR_2 = VAR_2;", "VAR_1->post_load->connected =\ng_malloc0(sizeof(*VAR_1->post_load->connected) * VAR_2);", "VAR_1->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\nvirtio_serial_post_load_timer_cb,\nVAR_1);", "for (i = 0; i < VAR_2; i++) {", "VirtIOSerialPort *port;", "uint32_t elem_popped;", "uint32_t id;", "id = qemu_get_be32(VAR_0);", "port = find_port_by_id(VAR_1, id);", "if (!port) {", "return -EINVAL;", "}", "port->guest_connected = qemu_get_byte(VAR_0);", "VAR_1->post_load->connected[i].port = port;", "VAR_1->post_load->connected[i].host_connected = qemu_get_byte(VAR_0);", "qemu_get_be32s(VAR_0, &elem_popped);", "if (elem_popped) {", "qemu_get_be32s(VAR_0, &port->iov_idx);", "qemu_get_be64s(VAR_0, &port->iov_offset);", "port->elem =\nqemu_get_virtqueue_element(VAR_0, sizeof(VirtQueueElement));", "virtio_serial_throttle_port(port, false);", "}", "}", "timer_mod(VAR_1->post_load->timer, 1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 21, 23, 25 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
107
void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env) { int flag; flag = float32_compare_quiet(a, b, &env->ucf64.fp_status); env->CF = 0; switch (c & 0x7) { case 0: /* F */ break; case 1: /* UN */ if (flag == 2) { env->CF = 1; } break; case 2: /* EQ */ if (flag == 0) { env->CF = 1; } break; case 3: /* UEQ */ if ((flag == 0) || (flag == 2)) { env->CF = 1; } break; case 4: /* OLT */ if (flag == -1) { env->CF = 1; } break; case 5: /* ULT */ if ((flag == -1) || (flag == 2)) { env->CF = 1; } break; case 6: /* OLE */ if ((flag == -1) || (flag == 0)) { env->CF = 1; } break; case 7: /* ULE */ if (flag != 1) { env->CF = 1; } break; } env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29) | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff); }
false
qemu
e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe
void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env) { int flag; flag = float32_compare_quiet(a, b, &env->ucf64.fp_status); env->CF = 0; switch (c & 0x7) { case 0: break; case 1: if (flag == 2) { env->CF = 1; } break; case 2: if (flag == 0) { env->CF = 1; } break; case 3: if ((flag == 0) || (flag == 2)) { env->CF = 1; } break; case 4: if (flag == -1) { env->CF = 1; } break; case 5: if ((flag == -1) || (flag == 2)) { env->CF = 1; } break; case 6: if ((flag == -1) || (flag == 0)) { env->CF = 1; } break; case 7: if (flag != 1) { env->CF = 1; } break; } env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29) | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff); }
{ "code": [], "line_no": [] }
void FUNC_0(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env) { int VAR_0; VAR_0 = float32_compare_quiet(a, b, &env->ucf64.fp_status); env->CF = 0; switch (c & 0x7) { case 0: break; case 1: if (VAR_0 == 2) { env->CF = 1; } break; case 2: if (VAR_0 == 0) { env->CF = 1; } break; case 3: if ((VAR_0 == 0) || (VAR_0 == 2)) { env->CF = 1; } break; case 4: if (VAR_0 == -1) { env->CF = 1; } break; case 5: if ((VAR_0 == -1) || (VAR_0 == 2)) { env->CF = 1; } break; case 6: if ((VAR_0 == -1) || (VAR_0 == 0)) { env->CF = 1; } break; case 7: if (VAR_0 != 1) { env->CF = 1; } break; } env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29) | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff); }
[ "void FUNC_0(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env)\n{", "int VAR_0;", "VAR_0 = float32_compare_quiet(a, b, &env->ucf64.fp_status);", "env->CF = 0;", "switch (c & 0x7) {", "case 0:\nbreak;", "case 1:\nif (VAR_0 == 2) {", "env->CF = 1;", "}", "break;", "case 2:\nif (VAR_0 == 0) {", "env->CF = 1;", "}", "break;", "case 3:\nif ((VAR_0 == 0) || (VAR_0 == 2)) {", "env->CF = 1;", "}", "break;", "case 4:\nif (VAR_0 == -1) {", "env->CF = 1;", "}", "break;", "case 5:\nif ((VAR_0 == -1) || (VAR_0 == 2)) {", "env->CF = 1;", "}", "break;", "case 6:\nif ((VAR_0 == -1) || (VAR_0 == 0)) {", "env->CF = 1;", "}", "break;", "case 7:\nif (VAR_0 != 1) {", "env->CF = 1;", "}", "break;", "}", "env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)\n| (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ] ]
109
static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); }
false
FFmpeg
13a099799e89a76eb921ca452e1b04a7a28a9855
static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); }
{ "code": [], "line_no": [] }
static void FUNC_0(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); }
[ "static void FUNC_0(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *buf1, const uint16_t *ubuf0,\nconst uint16_t *ubuf1, const uint16_t *vbuf0,\nconst uint16_t *vbuf1, const uint16_t *abuf0,\nconst uint16_t *abuf1, uint8_t *dest,\nint dstW, int yalpha, int uvalpha, int y)\n{", "__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2PACKED(%%REGBP, %5)\nWRITEYUY2(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13 ], [ 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37 ], [ 39 ] ]
110
static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */ if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(r, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
false
qemu
b456a71c4a1eb5704d135fd08da9a0de8fd81231
static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(r, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(SCSIDiskReq *VAR_0) { SCSIRequest *req = &VAR_0->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(VAR_0, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
[ "static int FUNC_0(SCSIDiskReq *VAR_0)\n{", "SCSIRequest *req = &VAR_0->req;", "SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);", "bool start = req->cmd.buf[4] & 1;", "bool loej = req->cmd.buf[4] & 2;", "if (s->qdev.type == TYPE_ROM && loej) {", "if (!start && !s->tray_open && s->tray_locked) {", "scsi_check_condition(VAR_0,\nbdrv_is_inserted(s->qdev.conf.bs)\n? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED)\n: SENSE_CODE(NOT_READY_REMOVAL_PREVENTED));", "return -1;", "}", "if (s->tray_open != !start) {", "bdrv_eject(s->qdev.conf.bs, !start);", "s->tray_open = !start;", "}", "}", "return 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 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ] ]
111
static void ecc_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { printf("ECC: Unsupported write 0x" TARGET_FMT_plx " %04x\n", addr, val & 0xffff); }
false
qemu
7c560456707bfe53eb1728fcde759be7d9418b62
static void ecc_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { printf("ECC: Unsupported write 0x" TARGET_FMT_plx " %04x\n", addr, val & 0xffff); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { printf("ECC: Unsupported write 0x" TARGET_FMT_plx " %04x\n", VAR_1, VAR_2 & 0xffff); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{", "printf(\"ECC: Unsupported write 0x\" TARGET_FMT_plx \" %04x\\n\",\nVAR_1, VAR_2 & 0xffff);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ] ]
112
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = arch_info->exception; cpu_single_env->has_error_code = 0; } return handle; }
false
qemu
b9bec74bcb16519a876ec21cd5277c526a9b512d
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = arch_info->exception; cpu_single_env->has_error_code = 0; } return handle; }
{ "code": [], "line_no": [] }
int FUNC_0(struct kvm_debug_exit_arch *VAR_0) { int VAR_1 = 0; int VAR_2; if (VAR_0->exception == 1) { if (VAR_0->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) VAR_1 = 1; } else { for (VAR_2 = 0; VAR_2 < 4; VAR_2++) if (VAR_0->dr6 & (1 << VAR_2)) switch ((VAR_0->dr7 >> (16 + VAR_2*4)) & 0x3) { case 0x0: VAR_1 = 1; break; case 0x1: VAR_1 = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[VAR_2].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: VAR_1 = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[VAR_2].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, VAR_0->pc)) VAR_1 = 1; if (!VAR_1) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = VAR_0->exception; cpu_single_env->has_error_code = 0; } return VAR_1; }
[ "int FUNC_0(struct kvm_debug_exit_arch *VAR_0)\n{", "int VAR_1 = 0;", "int VAR_2;", "if (VAR_0->exception == 1) {", "if (VAR_0->dr6 & (1 << 14)) {", "if (cpu_single_env->singlestep_enabled)\nVAR_1 = 1;", "} else {", "for (VAR_2 = 0; VAR_2 < 4; VAR_2++)", "if (VAR_0->dr6 & (1 << VAR_2))\nswitch ((VAR_0->dr7 >> (16 + VAR_2*4)) & 0x3) {", "case 0x0:\nVAR_1 = 1;", "break;", "case 0x1:\nVAR_1 = 1;", "cpu_single_env->watchpoint_hit = &hw_watchpoint;", "hw_watchpoint.vaddr = hw_breakpoint[VAR_2].addr;", "hw_watchpoint.flags = BP_MEM_WRITE;", "break;", "case 0x3:\nVAR_1 = 1;", "cpu_single_env->watchpoint_hit = &hw_watchpoint;", "hw_watchpoint.vaddr = hw_breakpoint[VAR_2].addr;", "hw_watchpoint.flags = BP_MEM_ACCESS;", "break;", "}", "}", "} else if (kvm_find_sw_breakpoint(cpu_single_env, VAR_0->pc))", "VAR_1 = 1;", "if (!VAR_1) {", "cpu_synchronize_state(cpu_single_env);", "assert(cpu_single_env->exception_injected == -1);", "cpu_single_env->exception_injected = VAR_0->exception;", "cpu_single_env->has_error_code = 0;", "}", "return VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ] ]
113
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { ChardevStdio *stdio; stdio = backend->u.stdio = g_new0(ChardevStdio, 1); qemu_chr_parse_common(opts, qapi_ChardevStdio_base(stdio)); stdio->has_signal = true; stdio->signal = qemu_opt_get_bool(opts, "signal", true); }
false
qemu
32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { ChardevStdio *stdio; stdio = backend->u.stdio = g_new0(ChardevStdio, 1); qemu_chr_parse_common(opts, qapi_ChardevStdio_base(stdio)); stdio->has_signal = true; stdio->signal = qemu_opt_get_bool(opts, "signal", true); }
{ "code": [], "line_no": [] }
static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1, Error **VAR_2) { ChardevStdio *stdio; stdio = VAR_1->u.stdio = g_new0(ChardevStdio, 1); qemu_chr_parse_common(VAR_0, qapi_ChardevStdio_base(stdio)); stdio->has_signal = true; stdio->signal = qemu_opt_get_bool(VAR_0, "signal", true); }
[ "static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1,\nError **VAR_2)\n{", "ChardevStdio *stdio;", "stdio = VAR_1->u.stdio = g_new0(ChardevStdio, 1);", "qemu_chr_parse_common(VAR_0, qapi_ChardevStdio_base(stdio));", "stdio->has_signal = true;", "stdio->signal = qemu_opt_get_bool(VAR_0, \"signal\", true);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
114
static void mirror_complete(BlockJob *job, Error **errp) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); Error *local_err = NULL; int ret; ret = bdrv_open_backing_file(s->target, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; } if (!s->synced) { error_setg(errp, QERR_BLOCK_JOB_NOT_READY, bdrv_get_device_name(job->bs)); return; } /* check the target bs is not blocked and block all operations on it */ if (s->replaces) { AioContext *replace_aio_context; s->to_replace = check_to_replace_node(s->replaces, &local_err); if (!s->to_replace) { error_propagate(errp, local_err); return; } replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); error_setg(&s->replace_blocker, "block device is in use by block-job-complete"); bdrv_op_block_all(s->to_replace, s->replace_blocker); bdrv_ref(s->to_replace); aio_context_release(replace_aio_context); } s->should_complete = true; block_job_enter(&s->common); }
false
qemu
e12f3784097a26a1ba51be420f41038b4c0ae5d1
static void mirror_complete(BlockJob *job, Error **errp) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); Error *local_err = NULL; int ret; ret = bdrv_open_backing_file(s->target, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; } if (!s->synced) { error_setg(errp, QERR_BLOCK_JOB_NOT_READY, bdrv_get_device_name(job->bs)); return; } if (s->replaces) { AioContext *replace_aio_context; s->to_replace = check_to_replace_node(s->replaces, &local_err); if (!s->to_replace) { error_propagate(errp, local_err); return; } replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); error_setg(&s->replace_blocker, "block device is in use by block-job-complete"); bdrv_op_block_all(s->to_replace, s->replace_blocker); bdrv_ref(s->to_replace); aio_context_release(replace_aio_context); } s->should_complete = true; block_job_enter(&s->common); }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockJob *VAR_0, Error **VAR_1) { MirrorBlockJob *s = container_of(VAR_0, MirrorBlockJob, common); Error *local_err = NULL; int VAR_2; VAR_2 = bdrv_open_backing_file(s->target, NULL, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return; } if (!s->synced) { error_setg(VAR_1, QERR_BLOCK_JOB_NOT_READY, bdrv_get_device_name(VAR_0->bs)); return; } if (s->replaces) { AioContext *replace_aio_context; s->to_replace = check_to_replace_node(s->replaces, &local_err); if (!s->to_replace) { error_propagate(VAR_1, local_err); return; } replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); error_setg(&s->replace_blocker, "block device is in use by block-VAR_0-complete"); bdrv_op_block_all(s->to_replace, s->replace_blocker); bdrv_ref(s->to_replace); aio_context_release(replace_aio_context); } s->should_complete = true; block_job_enter(&s->common); }
[ "static void FUNC_0(BlockJob *VAR_0, Error **VAR_1)\n{", "MirrorBlockJob *s = container_of(VAR_0, MirrorBlockJob, common);", "Error *local_err = NULL;", "int VAR_2;", "VAR_2 = bdrv_open_backing_file(s->target, NULL, &local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return;", "}", "if (!s->synced) {", "error_setg(VAR_1, QERR_BLOCK_JOB_NOT_READY,\nbdrv_get_device_name(VAR_0->bs));", "return;", "}", "if (s->replaces) {", "AioContext *replace_aio_context;", "s->to_replace = check_to_replace_node(s->replaces, &local_err);", "if (!s->to_replace) {", "error_propagate(VAR_1, local_err);", "return;", "}", "replace_aio_context = bdrv_get_aio_context(s->to_replace);", "aio_context_acquire(replace_aio_context);", "error_setg(&s->replace_blocker,\n\"block device is in use by block-VAR_0-complete\");", "bdrv_op_block_all(s->to_replace, s->replace_blocker);", "bdrv_ref(s->to_replace);", "aio_context_release(replace_aio_context);", "}", "s->should_complete = true;", "block_job_enter(&s->common);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ] ]
115
static bool scsi_target_emulate_inquiry(SCSITargetReq *r) { assert(r->req.dev->lun != r->req.lun); scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); if (r->req.cmd.buf[1] & 0x2) { /* Command support data - optional, not implemented */ return false; } if (r->req.cmd.buf[1] & 0x1) { /* Vital product data */ uint8_t page_code = r->req.cmd.buf[2]; r->buf[r->len++] = page_code ; /* this page */ r->buf[r->len++] = 0x00; switch (page_code) { case 0x00: /* Supported page codes, mandatory */ { int pages; pages = r->len++; r->buf[r->len++] = 0x00; /* list of supported pages (this page) */ r->buf[pages] = r->len - pages - 1; /* number of pages */ break; } default: return false; } /* done with EVPD */ assert(r->len < r->buf_len); r->len = MIN(r->req.cmd.xfer, r->len); return true; } /* Standard INQUIRY data */ if (r->req.cmd.buf[2] != 0) { return false; } /* PAGE CODE == 0 */ r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); memset(r->buf, 0, r->len); if (r->req.lun != 0) { r->buf[0] = TYPE_NO_LUN; } else { r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; r->buf[2] = 5; /* Version */ r->buf[3] = 2 | 0x10; /* HiSup, response data format */ r->buf[4] = r->len - 5; /* Additional Length = (Len - 1) - 4 */ r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); /* Sync, TCQ. */ memcpy(&r->buf[8], "QEMU ", 8); memcpy(&r->buf[16], "QEMU TARGET ", 16); pstrcpy((char *) &r->buf[32], 4, qemu_get_version()); } return true; }
false
qemu
35c2c8dc8c0899882a8e0d349d93bd657772f1e7
static bool scsi_target_emulate_inquiry(SCSITargetReq *r) { assert(r->req.dev->lun != r->req.lun); scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); if (r->req.cmd.buf[1] & 0x2) { return false; } if (r->req.cmd.buf[1] & 0x1) { uint8_t page_code = r->req.cmd.buf[2]; r->buf[r->len++] = page_code ; r->buf[r->len++] = 0x00; switch (page_code) { case 0x00: { int pages; pages = r->len++; r->buf[r->len++] = 0x00; r->buf[pages] = r->len - pages - 1; break; } default: return false; } assert(r->len < r->buf_len); r->len = MIN(r->req.cmd.xfer, r->len); return true; } if (r->req.cmd.buf[2] != 0) { return false; } r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); memset(r->buf, 0, r->len); if (r->req.lun != 0) { r->buf[0] = TYPE_NO_LUN; } else { r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; r->buf[2] = 5; r->buf[3] = 2 | 0x10; r->buf[4] = r->len - 5; r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); memcpy(&r->buf[8], "QEMU ", 8); memcpy(&r->buf[16], "QEMU TARGET ", 16); pstrcpy((char *) &r->buf[32], 4, qemu_get_version()); } return true; }
{ "code": [], "line_no": [] }
static bool FUNC_0(SCSITargetReq *r) { assert(r->req.dev->lun != r->req.lun); scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); if (r->req.cmd.buf[1] & 0x2) { return false; } if (r->req.cmd.buf[1] & 0x1) { uint8_t page_code = r->req.cmd.buf[2]; r->buf[r->len++] = page_code ; r->buf[r->len++] = 0x00; switch (page_code) { case 0x00: { int VAR_0; VAR_0 = r->len++; r->buf[r->len++] = 0x00; r->buf[VAR_0] = r->len - VAR_0 - 1; break; } default: return false; } assert(r->len < r->buf_len); r->len = MIN(r->req.cmd.xfer, r->len); return true; } if (r->req.cmd.buf[2] != 0) { return false; } r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); memset(r->buf, 0, r->len); if (r->req.lun != 0) { r->buf[0] = TYPE_NO_LUN; } else { r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; r->buf[2] = 5; r->buf[3] = 2 | 0x10; r->buf[4] = r->len - 5; r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); memcpy(&r->buf[8], "QEMU ", 8); memcpy(&r->buf[16], "QEMU TARGET ", 16); pstrcpy((char *) &r->buf[32], 4, qemu_get_version()); } return true; }
[ "static bool FUNC_0(SCSITargetReq *r)\n{", "assert(r->req.dev->lun != r->req.lun);", "scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN);", "if (r->req.cmd.buf[1] & 0x2) {", "return false;", "}", "if (r->req.cmd.buf[1] & 0x1) {", "uint8_t page_code = r->req.cmd.buf[2];", "r->buf[r->len++] = page_code ;", "r->buf[r->len++] = 0x00;", "switch (page_code) {", "case 0x00:\n{", "int VAR_0;", "VAR_0 = r->len++;", "r->buf[r->len++] = 0x00;", "r->buf[VAR_0] = r->len - VAR_0 - 1;", "break;", "}", "default:\nreturn false;", "}", "assert(r->len < r->buf_len);", "r->len = MIN(r->req.cmd.xfer, r->len);", "return true;", "}", "if (r->req.cmd.buf[2] != 0) {", "return false;", "}", "r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN);", "memset(r->buf, 0, r->len);", "if (r->req.lun != 0) {", "r->buf[0] = TYPE_NO_LUN;", "} else {", "r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE;", "r->buf[2] = 5;", "r->buf[3] = 2 | 0x10;", "r->buf[4] = r->len - 5;", "r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0);", "memcpy(&r->buf[8], \"QEMU \", 8);", "memcpy(&r->buf[16], \"QEMU TARGET \", 16);", "pstrcpy((char *) &r->buf[32], 4, qemu_get_version());", "}", "return true;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ], [ 77 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ] ]
116
void OPPROTO op_movl_npc_T0(void) { env->npc = T0; }
false
qemu
d2889a3efc3851e62de69cb9d88fb784c28e0ed8
void OPPROTO op_movl_npc_T0(void) { env->npc = T0; }
{ "code": [], "line_no": [] }
void VAR_0 op_movl_npc_T0(void) { env->npc = T0; }
[ "void VAR_0 op_movl_npc_T0(void)\n{", "env->npc = T0;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
117
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce) { TemporalNoiseShaping *tns = &sce->tns; int w, g, order, sfb_start, sfb_len, coef_start, shift[MAX_LPC_ORDER], count = 0; const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int tns_max_order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float freq_mult = mpeg4audio_sample_rates[s->samplerate_index]/(1024.0f/sce->ics.num_windows)/2.0f; float max_coef = 0.0f; sce->tns.present = 0; return; for (coef_start = 0; coef_start < 1024; coef_start++) max_coef = FFMAX(max_coef, sce->pcoeffs[coef_start]); for (w = 0; w < sce->ics.num_windows; w++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; /* Determine start sfb + coef - excludes anything below threshold */ for (g = 0; g < sce->ics.num_swb; g++) { if (start*freq_mult > TNS_LOW_LIMIT) { sfb_start = w*16+g; sfb_len = (w+1)*16 + g - sfb_start; coef_start = sce->ics.swb_offset[sfb_start]; coef_len = sce->ics.swb_offset[sfb_start + sfb_len] - coef_start; break; } start += sce->ics.swb_sizes[g]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &sce->pcoeffs[coef_start], coef_len, max_coef); /* LPC */ order = ff_lpc_calc_coefs(&s->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, tns_max_order, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; /* Works surprisingly well, remember to tweak MAX_LPC_SHIFT if you want to play around with this */ if (shift[order] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[w] = filters++; conv_to_float(tns_coefs_raw, coefs_t[order], order); for (g = 0; g < tns->n_filt[w]; g++) { process_tns_coeffs(tns, tns_coefs_raw, order, w, g); apply_tns_filter(&sce->coeffs[coef_start], sce->pcoeffs, order, direction, tns->coef[w][g], sce->ics.ltp.present, w, g, coef_start, coef_len); tns->order[w][g] = order; tns->length[w][g] = sfb_len; tns->direction[w][g] = direction; } count++; } } sce->tns.present = !!count; }
false
FFmpeg
f20b67173ca6a05b8c3dee02dad3b7243b96292b
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce) { TemporalNoiseShaping *tns = &sce->tns; int w, g, order, sfb_start, sfb_len, coef_start, shift[MAX_LPC_ORDER], count = 0; const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int tns_max_order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float freq_mult = mpeg4audio_sample_rates[s->samplerate_index]/(1024.0f/sce->ics.num_windows)/2.0f; float max_coef = 0.0f; sce->tns.present = 0; return; for (coef_start = 0; coef_start < 1024; coef_start++) max_coef = FFMAX(max_coef, sce->pcoeffs[coef_start]); for (w = 0; w < sce->ics.num_windows; w++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; for (g = 0; g < sce->ics.num_swb; g++) { if (start*freq_mult > TNS_LOW_LIMIT) { sfb_start = w*16+g; sfb_len = (w+1)*16 + g - sfb_start; coef_start = sce->ics.swb_offset[sfb_start]; coef_len = sce->ics.swb_offset[sfb_start + sfb_len] - coef_start; break; } start += sce->ics.swb_sizes[g]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &sce->pcoeffs[coef_start], coef_len, max_coef); order = ff_lpc_calc_coefs(&s->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, tns_max_order, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; if (shift[order] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[w] = filters++; conv_to_float(tns_coefs_raw, coefs_t[order], order); for (g = 0; g < tns->n_filt[w]; g++) { process_tns_coeffs(tns, tns_coefs_raw, order, w, g); apply_tns_filter(&sce->coeffs[coef_start], sce->pcoeffs, order, direction, tns->coef[w][g], sce->ics.ltp.present, w, g, coef_start, coef_len); tns->order[w][g] = order; tns->length[w][g] = sfb_len; tns->direction[w][g] = direction; } count++; } } sce->tns.present = !!count; }
{ "code": [], "line_no": [] }
void FUNC_0(AACEncContext *VAR_0, SingleChannelElement *VAR_1) { TemporalNoiseShaping *tns = &VAR_1->tns; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, shift[MAX_LPC_ORDER], count = 0; const int VAR_8 = VAR_1->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int VAR_9 = VAR_8 ? 7 : VAR_0->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float VAR_10 = mpeg4audio_sample_rates[VAR_0->samplerate_index]/(1024.0f/VAR_1->ics.num_windows)/2.0f; float VAR_11 = 0.0f; VAR_1->tns.present = 0; return; for (VAR_7 = 0; VAR_7 < 1024; VAR_7++) VAR_11 = FFMAX(VAR_11, VAR_1->pcoeffs[VAR_7]); for (VAR_2 = 0; VAR_2 < VAR_1->ics.num_windows; VAR_2++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; for (VAR_3 = 0; VAR_3 < VAR_1->ics.num_swb; VAR_3++) { if (start*VAR_10 > TNS_LOW_LIMIT) { VAR_5 = VAR_2*16+VAR_3; VAR_6 = (VAR_2+1)*16 + VAR_3 - VAR_5; VAR_7 = VAR_1->ics.swb_offset[VAR_5]; coef_len = VAR_1->ics.swb_offset[VAR_5 + VAR_6] - VAR_7; break; } start += VAR_1->ics.swb_sizes[VAR_3]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &VAR_1->pcoeffs[VAR_7], coef_len, VAR_11); VAR_4 = ff_lpc_calc_coefs(&VAR_0->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, VAR_9, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; if (shift[VAR_4] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[VAR_2] = filters++; conv_to_float(tns_coefs_raw, coefs_t[VAR_4], VAR_4); for (VAR_3 = 0; VAR_3 < tns->n_filt[VAR_2]; VAR_3++) { process_tns_coeffs(tns, tns_coefs_raw, VAR_4, VAR_2, VAR_3); apply_tns_filter(&VAR_1->coeffs[VAR_7], VAR_1->pcoeffs, VAR_4, direction, tns->coef[VAR_2][VAR_3], VAR_1->ics.ltp.present, VAR_2, VAR_3, VAR_7, coef_len); tns->VAR_4[VAR_2][VAR_3] = VAR_4; tns->length[VAR_2][VAR_3] = VAR_6; tns->direction[VAR_2][VAR_3] = direction; } count++; } } VAR_1->tns.present = !!count; }
[ "void FUNC_0(AACEncContext *VAR_0, SingleChannelElement *VAR_1)\n{", "TemporalNoiseShaping *tns = &VAR_1->tns;", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, shift[MAX_LPC_ORDER], count = 0;", "const int VAR_8 = VAR_1->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE;", "const int VAR_9 = VAR_8 ? 7 : VAR_0->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER;", "const float VAR_10 = mpeg4audio_sample_rates[VAR_0->samplerate_index]/(1024.0f/VAR_1->ics.num_windows)/2.0f;", "float VAR_11 = 0.0f;", "VAR_1->tns.present = 0;", "return;", "for (VAR_7 = 0; VAR_7 < 1024; VAR_7++)", "VAR_11 = FFMAX(VAR_11, VAR_1->pcoeffs[VAR_7]);", "for (VAR_2 = 0; VAR_2 < VAR_1->ics.num_windows; VAR_2++) {", "int filters = 1, start = 0, coef_len = 0;", "int32_t conv_coeff[1024] = {0};", "int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}};", "for (VAR_3 = 0; VAR_3 < VAR_1->ics.num_swb; VAR_3++) {", "if (start*VAR_10 > TNS_LOW_LIMIT) {", "VAR_5 = VAR_2*16+VAR_3;", "VAR_6 = (VAR_2+1)*16 + VAR_3 - VAR_5;", "VAR_7 = VAR_1->ics.swb_offset[VAR_5];", "coef_len = VAR_1->ics.swb_offset[VAR_5 + VAR_6] - VAR_7;", "break;", "}", "start += VAR_1->ics.swb_sizes[VAR_3];", "}", "if (coef_len <= 0)\ncontinue;", "conv_to_int32(conv_coeff, &VAR_1->pcoeffs[VAR_7], coef_len, VAR_11);", "VAR_4 = ff_lpc_calc_coefs(&VAR_0->lpc, conv_coeff, coef_len,\nTNS_MIN_PRED_ORDER, VAR_9,\n32, coefs_t, shift,\nFF_LPC_TYPE_LEVINSON, 10,\nORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1;", "if (shift[VAR_4] > 3) {", "int direction = 0;", "float tns_coefs_raw[TNS_MAX_ORDER];", "tns->n_filt[VAR_2] = filters++;", "conv_to_float(tns_coefs_raw, coefs_t[VAR_4], VAR_4);", "for (VAR_3 = 0; VAR_3 < tns->n_filt[VAR_2]; VAR_3++) {", "process_tns_coeffs(tns, tns_coefs_raw, VAR_4, VAR_2, VAR_3);", "apply_tns_filter(&VAR_1->coeffs[VAR_7], VAR_1->pcoeffs, VAR_4, direction, tns->coef[VAR_2][VAR_3],\nVAR_1->ics.ltp.present, VAR_2, VAR_3, VAR_7, coef_len);", "tns->VAR_4[VAR_2][VAR_3] = VAR_4;", "tns->length[VAR_2][VAR_3] = VAR_6;", "tns->direction[VAR_2][VAR_3] = direction;", "}", "count++;", "}", "}", "VAR_1->tns.present = !!count;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65, 67 ], [ 71 ], [ 77, 79, 81, 83, 85 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ] ]