id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
13,834 | int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
int ret;
// copy to ensure we do not change avpkt
AVPacket tmp = *avpkt;
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr= 0;
if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
int did_split = av_packet_split_side_data(&tmp);
apply_param_change(avctx, &tmp);
avctx->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts= avpkt->dts;
if(!avctx->has_b_frames){
picture->pkt_pos= avpkt->pos;
}
//FIXME these should be under if(!avctx->has_b_frames)
if (!picture->sample_aspect_ratio.num)
picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width)
picture->width = avctx->width;
if (!picture->height)
picture->height = avctx->height;
if (picture->format == PIX_FMT_NONE)
picture->format = avctx->pix_fmt;
}
emms_c(); //needed to avoid an emms_c() call before every return;
avctx->pkt = NULL;
if (did_split) {
ff_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr){
avctx->frame_number++;
picture->best_effort_timestamp = guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts);
}
}else
ret= 0;
return ret;
}
| false | FFmpeg | 3cc1a8988112896e302c96f9df8839d983677891 | int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
int ret;
AVPacket tmp = *avpkt;
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr= 0;
if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
int did_split = av_packet_split_side_data(&tmp);
apply_param_change(avctx, &tmp);
avctx->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts= avpkt->dts;
if(!avctx->has_b_frames){
picture->pkt_pos= avpkt->pos;
}
if (!picture->sample_aspect_ratio.num)
picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width)
picture->width = avctx->width;
if (!picture->height)
picture->height = avctx->height;
if (picture->format == PIX_FMT_NONE)
picture->format = avctx->pix_fmt;
}
emms_c();
avctx->pkt = NULL;
if (did_split) {
ff_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr){
avctx->frame_number++;
picture->best_effort_timestamp = guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts);
}
}else
ret= 0;
return ret;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
int ret;
AVPacket tmp = *avpkt;
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr= 0;
if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
int did_split = av_packet_split_side_data(&tmp);
apply_param_change(avctx, &tmp);
avctx->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts= avpkt->dts;
if(!avctx->has_b_frames){
picture->pkt_pos= avpkt->pos;
}
if (!picture->sample_aspect_ratio.num)
picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width)
picture->width = avctx->width;
if (!picture->height)
picture->height = avctx->height;
if (picture->format == PIX_FMT_NONE)
picture->format = avctx->pix_fmt;
}
emms_c();
avctx->pkt = NULL;
if (did_split) {
ff_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr){
avctx->frame_number++;
picture->best_effort_timestamp = guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts);
}
}else
ret= 0;
return ret;
}
| [
"int VAR_0 avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,\nint *got_picture_ptr,\nconst AVPacket *avpkt)\n{",
"int ret;",
"AVPacket tmp = *avpkt;",
"if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {",
"av_log(avctx, AV_LOG_ERROR, \"Invalid media type for video\\n\");",
"return AVERROR(EINVAL);",
"}",
"*got_picture_ptr= 0;",
"if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))\nreturn -1;",
"if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){",
"int did_split = av_packet_split_side_data(&tmp);",
"apply_param_change(avctx, &tmp);",
"avctx->pkt = &tmp;",
"if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)\nret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,\n&tmp);",
"else {",
"ret = avctx->codec->decode(avctx, picture, got_picture_ptr,\n&tmp);",
"picture->pkt_dts= avpkt->dts;",
"if(!avctx->has_b_frames){",
"picture->pkt_pos= avpkt->pos;",
"}",
"if (!picture->sample_aspect_ratio.num)\npicture->sample_aspect_ratio = avctx->sample_aspect_ratio;",
"if (!picture->width)\npicture->width = avctx->width;",
"if (!picture->height)\npicture->height = avctx->height;",
"if (picture->format == PIX_FMT_NONE)\npicture->format = avctx->pix_fmt;",
"}",
"emms_c();",
"avctx->pkt = NULL;",
"if (did_split) {",
"ff_packet_free_side_data(&tmp);",
"if(ret == tmp.size)\nret = avpkt->size;",
"}",
"if (*got_picture_ptr){",
"avctx->frame_number++;",
"picture->best_effort_timestamp = guess_correct_pts(avctx,\npicture->pkt_pts,\npicture->pkt_dts);",
"}",
"}else",
"ret= 0;",
"return ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
105
],
[
107
],
[
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
]
]
|
13,835 | static void evalPrimary(Parser *p){
double d, d2=NAN;
char *next= p->s;
int i;
/* number */
d= strtod(p->s, &next);
if(next != p->s){
push(p, d);
p->s= next;
return;
}
/* named constants */
for(i=0; p->const_name[i]; i++){
if(strmatch(p->s, p->const_name[i])){
push(p, p->const_value[i]);
p->s+= strlen(p->const_name[i]);
return;
}
}
p->s= strchr(p->s, '(');
if(p->s==NULL){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next);
return;
}
p->s++; // "("
evalExpression(p);
d= pop(p);
p->s++; // ")" or ","
if(p->s[-1]== ','){
evalExpression(p);
d2= pop(p);
p->s++; // ")"
}
if( strmatch(next, "sinh" ) ) d= sinh(d);
else if( strmatch(next, "cosh" ) ) d= cosh(d);
else if( strmatch(next, "tanh" ) ) d= tanh(d);
else if( strmatch(next, "sin" ) ) d= sin(d);
else if( strmatch(next, "cos" ) ) d= cos(d);
else if( strmatch(next, "tan" ) ) d= tan(d);
else if( strmatch(next, "exp" ) ) d= exp(d);
else if( strmatch(next, "log" ) ) d= log(d);
else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
else if( strmatch(next, "abs" ) ) d= fabs(d);
else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2;
else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2;
else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0;
else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0;
else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0;
// else if( strmatch(next, "l1" ) ) d= 1 + d2*(d - 1);
// else if( strmatch(next, "sq01" ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0;
else{
int error=1;
for(i=0; p->func1_name && p->func1_name[i]; i++){
if(strmatch(next, p->func1_name[i])){
d= p->func1[i](p->opaque, d);
error=0;
break;
}
}
for(i=0; p->func2_name && p->func2_name[i]; i++){
if(strmatch(next, p->func2_name[i])){
d= p->func2[i](p->opaque, d, d2);
error=0;
break;
}
}
if(error){
av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
return;
}
}
if(p->s[-1]!= ')'){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next);
return;
}
push(p, d);
}
| false | FFmpeg | 69f5de1855fb7a8d188f8f915887a9b00c7795f2 | static void evalPrimary(Parser *p){
double d, d2=NAN;
char *next= p->s;
int i;
d= strtod(p->s, &next);
if(next != p->s){
push(p, d);
p->s= next;
return;
}
for(i=0; p->const_name[i]; i++){
if(strmatch(p->s, p->const_name[i])){
push(p, p->const_value[i]);
p->s+= strlen(p->const_name[i]);
return;
}
}
p->s= strchr(p->s, '(');
if(p->s==NULL){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next);
return;
}
p->s++;
evalExpression(p);
d= pop(p);
p->s++;
if(p->s[-1]== ','){
evalExpression(p);
d2= pop(p);
p->s++;
}
if( strmatch(next, "sinh" ) ) d= sinh(d);
else if( strmatch(next, "cosh" ) ) d= cosh(d);
else if( strmatch(next, "tanh" ) ) d= tanh(d);
else if( strmatch(next, "sin" ) ) d= sin(d);
else if( strmatch(next, "cos" ) ) d= cos(d);
else if( strmatch(next, "tan" ) ) d= tan(d);
else if( strmatch(next, "exp" ) ) d= exp(d);
else if( strmatch(next, "log" ) ) d= log(d);
else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
else if( strmatch(next, "abs" ) ) d= fabs(d);
else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2;
else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2;
else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0;
else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0;
else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0;
else{
int error=1;
for(i=0; p->func1_name && p->func1_name[i]; i++){
if(strmatch(next, p->func1_name[i])){
d= p->func1[i](p->opaque, d);
error=0;
break;
}
}
for(i=0; p->func2_name && p->func2_name[i]; i++){
if(strmatch(next, p->func2_name[i])){
d= p->func2[i](p->opaque, d, d2);
error=0;
break;
}
}
if(error){
av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
return;
}
}
if(p->s[-1]!= ')'){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next);
return;
}
push(p, d);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Parser *VAR_0){
double VAR_1, VAR_2=NAN;
char *VAR_3= VAR_0->s;
int VAR_4;
VAR_1= strtod(VAR_0->s, &VAR_3);
if(VAR_3 != VAR_0->s){
push(VAR_0, VAR_1);
VAR_0->s= VAR_3;
return;
}
for(VAR_4=0; VAR_0->const_name[VAR_4]; VAR_4++){
if(strmatch(VAR_0->s, VAR_0->const_name[VAR_4])){
push(VAR_0, VAR_0->const_value[VAR_4]);
VAR_0->s+= strlen(VAR_0->const_name[VAR_4]);
return;
}
}
VAR_0->s= strchr(VAR_0->s, '(');
if(VAR_0->s==NULL){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", VAR_3);
return;
}
VAR_0->s++;
evalExpression(VAR_0);
VAR_1= pop(VAR_0);
VAR_0->s++;
if(VAR_0->s[-1]== ','){
evalExpression(VAR_0);
VAR_2= pop(VAR_0);
VAR_0->s++;
}
if( strmatch(VAR_3, "sinh" ) ) VAR_1= sinh(VAR_1);
else if( strmatch(VAR_3, "cosh" ) ) VAR_1= cosh(VAR_1);
else if( strmatch(VAR_3, "tanh" ) ) VAR_1= tanh(VAR_1);
else if( strmatch(VAR_3, "sin" ) ) VAR_1= sin(VAR_1);
else if( strmatch(VAR_3, "cos" ) ) VAR_1= cos(VAR_1);
else if( strmatch(VAR_3, "tan" ) ) VAR_1= tan(VAR_1);
else if( strmatch(VAR_3, "exp" ) ) VAR_1= exp(VAR_1);
else if( strmatch(VAR_3, "log" ) ) VAR_1= log(VAR_1);
else if( strmatch(VAR_3, "squish") ) VAR_1= 1/(1+exp(4*VAR_1));
else if( strmatch(VAR_3, "gauss" ) ) VAR_1= exp(-VAR_1*VAR_1/2)/sqrt(2*M_PI);
else if( strmatch(VAR_3, "abs" ) ) VAR_1= fabs(VAR_1);
else if( strmatch(VAR_3, "max" ) ) VAR_1= VAR_1 > VAR_2 ? VAR_1 : VAR_2;
else if( strmatch(VAR_3, "min" ) ) VAR_1= VAR_1 < VAR_2 ? VAR_1 : VAR_2;
else if( strmatch(VAR_3, "gt" ) ) VAR_1= VAR_1 > VAR_2 ? 1.0 : 0.0;
else if( strmatch(VAR_3, "lt" ) ) VAR_1= VAR_1 > VAR_2 ? 0.0 : 1.0;
else if( strmatch(VAR_3, "eq" ) ) VAR_1= VAR_1 == VAR_2 ? 1.0 : 0.0;
else{
int VAR_5=1;
for(VAR_4=0; VAR_0->func1_name && VAR_0->func1_name[VAR_4]; VAR_4++){
if(strmatch(VAR_3, VAR_0->func1_name[VAR_4])){
VAR_1= VAR_0->func1[VAR_4](VAR_0->opaque, VAR_1);
VAR_5=0;
break;
}
}
for(VAR_4=0; VAR_0->func2_name && VAR_0->func2_name[VAR_4]; VAR_4++){
if(strmatch(VAR_3, VAR_0->func2_name[VAR_4])){
VAR_1= VAR_0->func2[VAR_4](VAR_0->opaque, VAR_1, VAR_2);
VAR_5=0;
break;
}
}
if(VAR_5){
av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", VAR_3);
return;
}
}
if(VAR_0->s[-1]!= ')'){
av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", VAR_3);
return;
}
push(VAR_0, VAR_1);
}
| [
"static void FUNC_0(Parser *VAR_0){",
"double VAR_1, VAR_2=NAN;",
"char *VAR_3= VAR_0->s;",
"int VAR_4;",
"VAR_1= strtod(VAR_0->s, &VAR_3);",
"if(VAR_3 != VAR_0->s){",
"push(VAR_0, VAR_1);",
"VAR_0->s= VAR_3;",
"return;",
"}",
"for(VAR_4=0; VAR_0->const_name[VAR_4]; VAR_4++){",
"if(strmatch(VAR_0->s, VAR_0->const_name[VAR_4])){",
"push(VAR_0, VAR_0->const_value[VAR_4]);",
"VAR_0->s+= strlen(VAR_0->const_name[VAR_4]);",
"return;",
"}",
"}",
"VAR_0->s= strchr(VAR_0->s, '(');",
"if(VAR_0->s==NULL){",
"av_log(NULL, AV_LOG_ERROR, \"Parser: missing ( in \\\"%s\\\"\\n\", VAR_3);",
"return;",
"}",
"VAR_0->s++;",
"evalExpression(VAR_0);",
"VAR_1= pop(VAR_0);",
"VAR_0->s++;",
"if(VAR_0->s[-1]== ','){",
"evalExpression(VAR_0);",
"VAR_2= pop(VAR_0);",
"VAR_0->s++;",
"}",
"if( strmatch(VAR_3, \"sinh\" ) ) VAR_1= sinh(VAR_1);",
"else if( strmatch(VAR_3, \"cosh\" ) ) VAR_1= cosh(VAR_1);",
"else if( strmatch(VAR_3, \"tanh\" ) ) VAR_1= tanh(VAR_1);",
"else if( strmatch(VAR_3, \"sin\" ) ) VAR_1= sin(VAR_1);",
"else if( strmatch(VAR_3, \"cos\" ) ) VAR_1= cos(VAR_1);",
"else if( strmatch(VAR_3, \"tan\" ) ) VAR_1= tan(VAR_1);",
"else if( strmatch(VAR_3, \"exp\" ) ) VAR_1= exp(VAR_1);",
"else if( strmatch(VAR_3, \"log\" ) ) VAR_1= log(VAR_1);",
"else if( strmatch(VAR_3, \"squish\") ) VAR_1= 1/(1+exp(4*VAR_1));",
"else if( strmatch(VAR_3, \"gauss\" ) ) VAR_1= exp(-VAR_1*VAR_1/2)/sqrt(2*M_PI);",
"else if( strmatch(VAR_3, \"abs\" ) ) VAR_1= fabs(VAR_1);",
"else if( strmatch(VAR_3, \"max\" ) ) VAR_1= VAR_1 > VAR_2 ? VAR_1 : VAR_2;",
"else if( strmatch(VAR_3, \"min\" ) ) VAR_1= VAR_1 < VAR_2 ? VAR_1 : VAR_2;",
"else if( strmatch(VAR_3, \"gt\" ) ) VAR_1= VAR_1 > VAR_2 ? 1.0 : 0.0;",
"else if( strmatch(VAR_3, \"lt\" ) ) VAR_1= VAR_1 > VAR_2 ? 0.0 : 1.0;",
"else if( strmatch(VAR_3, \"eq\" ) ) VAR_1= VAR_1 == VAR_2 ? 1.0 : 0.0;",
"else{",
"int VAR_5=1;",
"for(VAR_4=0; VAR_0->func1_name && VAR_0->func1_name[VAR_4]; VAR_4++){",
"if(strmatch(VAR_3, VAR_0->func1_name[VAR_4])){",
"VAR_1= VAR_0->func1[VAR_4](VAR_0->opaque, VAR_1);",
"VAR_5=0;",
"break;",
"}",
"}",
"for(VAR_4=0; VAR_0->func2_name && VAR_0->func2_name[VAR_4]; VAR_4++){",
"if(strmatch(VAR_3, VAR_0->func2_name[VAR_4])){",
"VAR_1= VAR_0->func2[VAR_4](VAR_0->opaque, VAR_1, VAR_2);",
"VAR_5=0;",
"break;",
"}",
"}",
"if(VAR_5){",
"av_log(NULL, AV_LOG_ERROR, \"Parser: unknown function in \\\"%s\\\"\\n\", VAR_3);",
"return;",
"}",
"}",
"if(VAR_0->s[-1]!= ')'){",
"av_log(NULL, AV_LOG_ERROR, \"Parser: missing ) in \\\"%s\\\"\\n\", VAR_3);",
"return;",
"}",
"push(VAR_0, VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
]
]
|
13,837 | void do_POWER_dozo (void)
{
if (Ts1 > Ts0) {
T2 = T0;
T0 = T1 - T0;
if (((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)) {
xer_so = 1;
xer_ov = 1;
} else {
xer_ov = 0;
}
} else {
T0 = 0;
xer_ov = 0;
}
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void do_POWER_dozo (void)
{
if (Ts1 > Ts0) {
T2 = T0;
T0 = T1 - T0;
if (((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)) {
xer_so = 1;
xer_ov = 1;
} else {
xer_ov = 0;
}
} else {
T0 = 0;
xer_ov = 0;
}
}
| {
"code": [
" } else {",
" } else {",
" } else {",
" xer_ov = 0;",
" } else {",
" } else {",
" xer_ov = 0;",
" } else {",
" xer_ov = 0;",
" } else {",
" } else {",
" } else {",
" } else {",
" if (Ts1 > Ts0) {",
" if (((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)) {"
],
"line_no": [
23,
23,
23,
27,
23,
23,
27,
23,
27,
23,
23,
23,
23,
5,
11
]
} | void FUNC_0 (void)
{
if (Ts1 > Ts0) {
T2 = T0;
T0 = T1 - T0;
if (((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)) {
xer_so = 1;
xer_ov = 1;
} else {
xer_ov = 0;
}
} else {
T0 = 0;
xer_ov = 0;
}
}
| [
"void FUNC_0 (void)\n{",
"if (Ts1 > Ts0) {",
"T2 = T0;",
"T0 = T1 - T0;",
"if (((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)) {",
"xer_so = 1;",
"xer_ov = 1;",
"} else {",
"xer_ov = 0;",
"}",
"} else {",
"T0 = 0;",
"xer_ov = 0;",
"}",
"}"
]
| [
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
13,838 | static void test_i440fx_defaults(gconstpointer opaque)
{
const TestData *s = opaque;
QPCIBus *bus;
QPCIDevice *dev;
uint32_t value;
bus = test_start_get_bus(s);
dev = qpci_device_find(bus, QPCI_DEVFN(0, 0));
g_assert(dev != NULL);
/* 3.2.2 */
g_assert_cmpint(qpci_config_readw(dev, PCI_VENDOR_ID), ==, 0x8086);
/* 3.2.3 */
g_assert_cmpint(qpci_config_readw(dev, PCI_DEVICE_ID), ==, 0x1237);
#ifndef BROKEN
/* 3.2.4 */
g_assert_cmpint(qpci_config_readw(dev, PCI_COMMAND), ==, 0x0006);
/* 3.2.5 */
g_assert_cmpint(qpci_config_readw(dev, PCI_STATUS), ==, 0x0280);
#endif
/* 3.2.7 */
g_assert_cmpint(qpci_config_readb(dev, PCI_CLASS_PROG), ==, 0x00);
g_assert_cmpint(qpci_config_readw(dev, PCI_CLASS_DEVICE), ==, 0x0600);
/* 3.2.8 */
g_assert_cmpint(qpci_config_readb(dev, PCI_LATENCY_TIMER), ==, 0x00);
/* 3.2.9 */
g_assert_cmpint(qpci_config_readb(dev, PCI_HEADER_TYPE), ==, 0x00);
/* 3.2.10 */
g_assert_cmpint(qpci_config_readb(dev, PCI_BIST), ==, 0x00);
/* 3.2.11 */
value = qpci_config_readw(dev, 0x50); /* PMCCFG */
if (s->num_cpus == 1) { /* WPE */
g_assert(!(value & (1 << 15)));
} else {
g_assert((value & (1 << 15)));
}
g_assert(!(value & (1 << 6))); /* EPTE */
/* 3.2.12 */
g_assert_cmpint(qpci_config_readb(dev, 0x52), ==, 0x00); /* DETURBO */
/* 3.2.13 */
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x53), ==, 0x80); /* DBC */
#endif
/* 3.2.14 */
g_assert_cmpint(qpci_config_readb(dev, 0x54), ==, 0x00); /* AXC */
/* 3.2.15 */
g_assert_cmpint(qpci_config_readw(dev, 0x55), ==, 0x0000); /* DRT */
#ifndef BROKEN
/* 3.2.16 */
g_assert_cmpint(qpci_config_readb(dev, 0x57), ==, 0x01); /* DRAMC */
/* 3.2.17 */
g_assert_cmpint(qpci_config_readb(dev, 0x58), ==, 0x10); /* DRAMT */
#endif
/* 3.2.18 */
g_assert_cmpint(qpci_config_readb(dev, 0x59), ==, 0x00); /* PAM0 */
g_assert_cmpint(qpci_config_readb(dev, 0x5A), ==, 0x00); /* PAM1 */
g_assert_cmpint(qpci_config_readb(dev, 0x5B), ==, 0x00); /* PAM2 */
g_assert_cmpint(qpci_config_readb(dev, 0x5C), ==, 0x00); /* PAM3 */
g_assert_cmpint(qpci_config_readb(dev, 0x5D), ==, 0x00); /* PAM4 */
g_assert_cmpint(qpci_config_readb(dev, 0x5E), ==, 0x00); /* PAM5 */
g_assert_cmpint(qpci_config_readb(dev, 0x5F), ==, 0x00); /* PAM6 */
#ifndef BROKEN
/* 3.2.19 */
g_assert_cmpint(qpci_config_readb(dev, 0x60), ==, 0x01); /* DRB0 */
g_assert_cmpint(qpci_config_readb(dev, 0x61), ==, 0x01); /* DRB1 */
g_assert_cmpint(qpci_config_readb(dev, 0x62), ==, 0x01); /* DRB2 */
g_assert_cmpint(qpci_config_readb(dev, 0x63), ==, 0x01); /* DRB3 */
g_assert_cmpint(qpci_config_readb(dev, 0x64), ==, 0x01); /* DRB4 */
g_assert_cmpint(qpci_config_readb(dev, 0x65), ==, 0x01); /* DRB5 */
g_assert_cmpint(qpci_config_readb(dev, 0x66), ==, 0x01); /* DRB6 */
g_assert_cmpint(qpci_config_readb(dev, 0x67), ==, 0x01); /* DRB7 */
#endif
/* 3.2.20 */
g_assert_cmpint(qpci_config_readb(dev, 0x68), ==, 0x00); /* FDHC */
/* 3.2.21 */
g_assert_cmpint(qpci_config_readb(dev, 0x70), ==, 0x00); /* MTT */
#ifndef BROKEN
/* 3.2.22 */
g_assert_cmpint(qpci_config_readb(dev, 0x71), ==, 0x10); /* CLT */
#endif
/* 3.2.23 */
g_assert_cmpint(qpci_config_readb(dev, 0x72), ==, 0x02); /* SMRAM */
/* 3.2.24 */
g_assert_cmpint(qpci_config_readb(dev, 0x90), ==, 0x00); /* ERRCMD */
/* 3.2.25 */
g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00); /* ERRSTS */
/* 3.2.26 */
g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00); /* TRC */
qtest_end();
} | true | qemu | 1bab33ab4ab4702f53012551cad333beb270f30d | static void test_i440fx_defaults(gconstpointer opaque)
{
const TestData *s = opaque;
QPCIBus *bus;
QPCIDevice *dev;
uint32_t value;
bus = test_start_get_bus(s);
dev = qpci_device_find(bus, QPCI_DEVFN(0, 0));
g_assert(dev != NULL);
g_assert_cmpint(qpci_config_readw(dev, PCI_VENDOR_ID), ==, 0x8086);
g_assert_cmpint(qpci_config_readw(dev, PCI_DEVICE_ID), ==, 0x1237);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readw(dev, PCI_COMMAND), ==, 0x0006);
g_assert_cmpint(qpci_config_readw(dev, PCI_STATUS), ==, 0x0280);
#endif
g_assert_cmpint(qpci_config_readb(dev, PCI_CLASS_PROG), ==, 0x00);
g_assert_cmpint(qpci_config_readw(dev, PCI_CLASS_DEVICE), ==, 0x0600);
g_assert_cmpint(qpci_config_readb(dev, PCI_LATENCY_TIMER), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, PCI_HEADER_TYPE), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, PCI_BIST), ==, 0x00);
value = qpci_config_readw(dev, 0x50);
if (s->num_cpus == 1) {
g_assert(!(value & (1 << 15)));
} else {
g_assert((value & (1 << 15)));
}
g_assert(!(value & (1 << 6)));
g_assert_cmpint(qpci_config_readb(dev, 0x52), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x53), ==, 0x80);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x54), ==, 0x00);
g_assert_cmpint(qpci_config_readw(dev, 0x55), ==, 0x0000);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x57), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x58), ==, 0x10);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x59), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5A), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5B), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5C), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5D), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5E), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5F), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x60), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x61), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x62), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x63), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x64), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x65), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x66), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x67), ==, 0x01);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x68), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x70), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x71), ==, 0x10);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x72), ==, 0x02);
g_assert_cmpint(qpci_config_readb(dev, 0x90), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00);
qtest_end();
} | {
"code": [],
"line_no": []
} | static void FUNC_0(gconstpointer VAR_0)
{
const TestData *VAR_1 = VAR_0;
QPCIBus *bus;
QPCIDevice *dev;
uint32_t value;
bus = test_start_get_bus(VAR_1);
dev = qpci_device_find(bus, QPCI_DEVFN(0, 0));
g_assert(dev != NULL);
g_assert_cmpint(qpci_config_readw(dev, PCI_VENDOR_ID), ==, 0x8086);
g_assert_cmpint(qpci_config_readw(dev, PCI_DEVICE_ID), ==, 0x1237);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readw(dev, PCI_COMMAND), ==, 0x0006);
g_assert_cmpint(qpci_config_readw(dev, PCI_STATUS), ==, 0x0280);
#endif
g_assert_cmpint(qpci_config_readb(dev, PCI_CLASS_PROG), ==, 0x00);
g_assert_cmpint(qpci_config_readw(dev, PCI_CLASS_DEVICE), ==, 0x0600);
g_assert_cmpint(qpci_config_readb(dev, PCI_LATENCY_TIMER), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, PCI_HEADER_TYPE), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, PCI_BIST), ==, 0x00);
value = qpci_config_readw(dev, 0x50);
if (VAR_1->num_cpus == 1) {
g_assert(!(value & (1 << 15)));
} else {
g_assert((value & (1 << 15)));
}
g_assert(!(value & (1 << 6)));
g_assert_cmpint(qpci_config_readb(dev, 0x52), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x53), ==, 0x80);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x54), ==, 0x00);
g_assert_cmpint(qpci_config_readw(dev, 0x55), ==, 0x0000);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x57), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x58), ==, 0x10);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x59), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5A), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5B), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5C), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5D), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5E), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x5F), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x60), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x61), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x62), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x63), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x64), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x65), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x66), ==, 0x01);
g_assert_cmpint(qpci_config_readb(dev, 0x67), ==, 0x01);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x68), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x70), ==, 0x00);
#ifndef BROKEN
g_assert_cmpint(qpci_config_readb(dev, 0x71), ==, 0x10);
#endif
g_assert_cmpint(qpci_config_readb(dev, 0x72), ==, 0x02);
g_assert_cmpint(qpci_config_readb(dev, 0x90), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00);
g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00);
qtest_end();
} | [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"const TestData *VAR_1 = VAR_0;",
"QPCIBus *bus;",
"QPCIDevice *dev;",
"uint32_t value;",
"bus = test_start_get_bus(VAR_1);",
"dev = qpci_device_find(bus, QPCI_DEVFN(0, 0));",
"g_assert(dev != NULL);",
"g_assert_cmpint(qpci_config_readw(dev, PCI_VENDOR_ID), ==, 0x8086);",
"g_assert_cmpint(qpci_config_readw(dev, PCI_DEVICE_ID), ==, 0x1237);",
"#ifndef BROKEN\ng_assert_cmpint(qpci_config_readw(dev, PCI_COMMAND), ==, 0x0006);",
"g_assert_cmpint(qpci_config_readw(dev, PCI_STATUS), ==, 0x0280);",
"#endif\ng_assert_cmpint(qpci_config_readb(dev, PCI_CLASS_PROG), ==, 0x00);",
"g_assert_cmpint(qpci_config_readw(dev, PCI_CLASS_DEVICE), ==, 0x0600);",
"g_assert_cmpint(qpci_config_readb(dev, PCI_LATENCY_TIMER), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, PCI_HEADER_TYPE), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, PCI_BIST), ==, 0x00);",
"value = qpci_config_readw(dev, 0x50);",
"if (VAR_1->num_cpus == 1) {",
"g_assert(!(value & (1 << 15)));",
"} else {",
"g_assert((value & (1 << 15)));",
"}",
"g_assert(!(value & (1 << 6)));",
"g_assert_cmpint(qpci_config_readb(dev, 0x52), ==, 0x00);",
"#ifndef BROKEN\ng_assert_cmpint(qpci_config_readb(dev, 0x53), ==, 0x80);",
"#endif\ng_assert_cmpint(qpci_config_readb(dev, 0x54), ==, 0x00);",
"g_assert_cmpint(qpci_config_readw(dev, 0x55), ==, 0x0000);",
"#ifndef BROKEN\ng_assert_cmpint(qpci_config_readb(dev, 0x57), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x58), ==, 0x10);",
"#endif\ng_assert_cmpint(qpci_config_readb(dev, 0x59), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5A), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5B), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5C), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5D), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5E), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x5F), ==, 0x00);",
"#ifndef BROKEN\ng_assert_cmpint(qpci_config_readb(dev, 0x60), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x61), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x62), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x63), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x64), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x65), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x66), ==, 0x01);",
"g_assert_cmpint(qpci_config_readb(dev, 0x67), ==, 0x01);",
"#endif\ng_assert_cmpint(qpci_config_readb(dev, 0x68), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x70), ==, 0x00);",
"#ifndef BROKEN\ng_assert_cmpint(qpci_config_readb(dev, 0x71), ==, 0x10);",
"#endif\ng_assert_cmpint(qpci_config_readb(dev, 0x72), ==, 0x02);",
"g_assert_cmpint(qpci_config_readb(dev, 0x90), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00);",
"g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00);",
"qtest_end();",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
25
],
[
29
],
[
31,
35
],
[
39
],
[
41,
45
],
[
47
],
[
51
],
[
55
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
85
],
[
89,
91
],
[
93,
97
],
[
101
],
[
103,
107
],
[
111
],
[
113,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
155
],
[
159
],
[
161,
165
],
[
167,
171
],
[
175
],
[
179
],
[
183
],
[
189
],
[
191
]
]
|
13,839 | BlockInfoList *qmp_query_block(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockBackend *blk;
Error *local_err = NULL;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
BlockInfoList *info = g_malloc0(sizeof(*info));
bdrv_query_info(blk, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err;
}
*p_next = info;
p_next = &info->next;
}
return head;
err:
qapi_free_BlockInfoList(head);
return NULL;
}
| true | qemu | 903c341d5742b160e52752eb6fdc1ba9b87dc52e | BlockInfoList *qmp_query_block(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockBackend *blk;
Error *local_err = NULL;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
BlockInfoList *info = g_malloc0(sizeof(*info));
bdrv_query_info(blk, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err;
}
*p_next = info;
p_next = &info->next;
}
return head;
err:
qapi_free_BlockInfoList(head);
return NULL;
}
| {
"code": [
" goto err;",
" err:",
" qapi_free_BlockInfoList(head);",
" return NULL;"
],
"line_no": [
23,
41,
43,
45
]
} | BlockInfoList *FUNC_0(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockBackend *blk;
Error *local_err = NULL;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
BlockInfoList *info = g_malloc0(sizeof(*info));
bdrv_query_info(blk, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err;
}
*p_next = info;
p_next = &info->next;
}
return head;
err:
qapi_free_BlockInfoList(head);
return NULL;
}
| [
"BlockInfoList *FUNC_0(Error **errp)\n{",
"BlockInfoList *head = NULL, **p_next = &head;",
"BlockBackend *blk;",
"Error *local_err = NULL;",
"for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {",
"BlockInfoList *info = g_malloc0(sizeof(*info));",
"bdrv_query_info(blk, &info->value, &local_err);",
"if (local_err) {",
"error_propagate(errp, local_err);",
"goto err;",
"}",
"*p_next = info;",
"p_next = &info->next;",
"}",
"return head;",
"err:\nqapi_free_BlockInfoList(head);",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41,
43
],
[
45
],
[
47
]
]
|
13,840 | static int asf_write_header(AVFormatContext *s)
{
ASFContext *asf = s->priv_data;
s->packet_size = PACKET_SIZE;
s->max_interleave_delta = 0;
asf->nb_packets = 0;
asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
asf->maximum_packet = 0;
/* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
* data_size - asf->data_offset at the moment this function is done.
* It is needed to use asf as a streamable format. */
if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
//av_free(asf);
return -1;
}
avio_flush(s->pb);
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;
return 0;
} | true | FFmpeg | 2c8cff2be4a044c66e4904efa156dafd0d332d25 | static int asf_write_header(AVFormatContext *s)
{
ASFContext *asf = s->priv_data;
s->packet_size = PACKET_SIZE;
s->max_interleave_delta = 0;
asf->nb_packets = 0;
asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
asf->maximum_packet = 0;
if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
return -1;
}
avio_flush(s->pb);
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
ASFContext *asf = VAR_0->priv_data;
VAR_0->packet_size = PACKET_SIZE;
VAR_0->max_interleave_delta = 0;
asf->nb_packets = 0;
asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
asf->maximum_packet = 0;
if (asf_write_header1(VAR_0, 0, DATA_HEADER_SIZE) < 0) {
return -1;
}
avio_flush(VAR_0->pb);
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
ffio_init_context(&asf->pb, asf->packet_buf, VAR_0->packet_size, 1,
NULL, NULL, NULL, NULL);
if (VAR_0->avoid_negative_ts < 0)
VAR_0->avoid_negative_ts = 1;
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"VAR_0->packet_size = PACKET_SIZE;",
"VAR_0->max_interleave_delta = 0;",
"asf->nb_packets = 0;",
"asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);",
"asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;",
"asf->maximum_packet = 0;",
"if (asf_write_header1(VAR_0, 0, DATA_HEADER_SIZE) < 0) {",
"return -1;",
"}",
"avio_flush(VAR_0->pb);",
"asf->packet_nb_payloads = 0;",
"asf->packet_timestamp_start = -1;",
"asf->packet_timestamp_end = -1;",
"ffio_init_context(&asf->pb, asf->packet_buf, VAR_0->packet_size, 1,\nNULL, NULL, NULL, NULL);",
"if (VAR_0->avoid_negative_ts < 0)\nVAR_0->avoid_negative_ts = 1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
31
],
[
36
],
[
38
],
[
42
],
[
46
],
[
48
],
[
50
],
[
52,
54
],
[
58,
60
],
[
64
],
[
66
]
]
|
13,841 | static int mp3_write_xing(AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
int32_t header;
MPADecodeHeader mpah;
int srate_idx, i, channels;
int bitrate_idx;
int best_bitrate_idx = -1;
int best_bitrate_error = INT_MAX;
int xing_offset;
int ver = 0;
int bytes_needed, lsf;
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
if (!s->pb->seekable || !mp3->write_xing)
return 0;
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
const uint16_t base_freq = avpriv_mpa_freq_tab[i];
if (codec->sample_rate == base_freq) ver = 0x3; // MPEG 1
else if (codec->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
else if (codec->sample_rate == base_freq / 4) ver = 0x0; // MPEG 2.5
else continue;
srate_idx = i;
break;
}
if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
return -1;
}
switch (codec->channels) {
case 1: channels = MPA_MONO; break;
case 2: channels = MPA_STEREO; break;
default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, "
"not writing Xing header.\n");
return -1;
}
/* dummy MPEG audio header */
header = 0xffU << 24; // sync
header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; // sync/audio-version/layer 3/no crc*/
header |= (srate_idx << 2) << 8;
header |= channels << 6;
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];
int error = FFABS(bit_rate - codec->bit_rate);
if (error < best_bitrate_error) {
best_bitrate_error = error;
best_bitrate_idx = bitrate_idx;
}
}
av_assert0(best_bitrate_idx >= 0);
for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) {
int32_t mask = bitrate_idx << (4 + 8);
if (15 == bitrate_idx)
return -1;
header |= mask;
avpriv_mpegaudio_decode_header(&mpah, header);
xing_offset=xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
bytes_needed = 4 // header
+ xing_offset
+ 4 // xing tag
+ 4 // frames/size/toc flags
+ 4 // frames
+ 4 // size
+ XING_TOC_SIZE // toc
+ 24
;
if (bytes_needed <= mpah.frame_size)
break;
header &= ~mask;
}
avio_wb32(s->pb, header);
ffio_fill(s->pb, 0, xing_offset);
mp3->xing_offset = avio_tell(s->pb);
ffio_wfourcc(s->pb, "Xing");
avio_wb32(s->pb, 0x01 | 0x02 | 0x04); // frames / size / TOC
mp3->size = mpah.frame_size;
mp3->want=1;
mp3->seen=0;
mp3->pos=0;
avio_wb32(s->pb, 0); // frames
avio_wb32(s->pb, 0); // size
// toc
for (i = 0; i < XING_TOC_SIZE; ++i)
avio_w8(s->pb, (uint8_t)(255 * i / XING_TOC_SIZE));
for (i = 0; i < strlen(vendor); ++i)
avio_w8(s->pb, vendor[i]);
for (; i < 21; ++i)
avio_w8(s->pb, 0);
avio_wb24(s->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);
ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed);
return 0;
}
| true | FFmpeg | eccec203978e53f897a3c6105d011bbdff2a978b | static int mp3_write_xing(AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
int32_t header;
MPADecodeHeader mpah;
int srate_idx, i, channels;
int bitrate_idx;
int best_bitrate_idx = -1;
int best_bitrate_error = INT_MAX;
int xing_offset;
int ver = 0;
int bytes_needed, lsf;
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
if (!s->pb->seekable || !mp3->write_xing)
return 0;
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
const uint16_t base_freq = avpriv_mpa_freq_tab[i];
if (codec->sample_rate == base_freq) ver = 0x3;
else if (codec->sample_rate == base_freq / 2) ver = 0x2;
else if (codec->sample_rate == base_freq / 4) ver = 0x0; .5
else continue;
srate_idx = i;
break;
}
if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
return -1;
}
switch (codec->channels) {
case 1: channels = MPA_MONO; break;
case 2: channels = MPA_STEREO; break;
default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, "
"not writing Xing header.\n");
return -1;
}
header = 0xffU << 24;
header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; /audio-version/layer 3/no crc*/
header |= (srate_idx << 2) << 8;
header |= channels << 6;
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];
int error = FFABS(bit_rate - codec->bit_rate);
if (error < best_bitrate_error) {
best_bitrate_error = error;
best_bitrate_idx = bitrate_idx;
}
}
av_assert0(best_bitrate_idx >= 0);
for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) {
int32_t mask = bitrate_idx << (4 + 8);
if (15 == bitrate_idx)
return -1;
header |= mask;
avpriv_mpegaudio_decode_header(&mpah, header);
xing_offset=xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
bytes_needed = 4
+ xing_offset
+ 4
+ 4
+ 4
+ 4
+ XING_TOC_SIZE
+ 24
;
if (bytes_needed <= mpah.frame_size)
break;
header &= ~mask;
}
avio_wb32(s->pb, header);
ffio_fill(s->pb, 0, xing_offset);
mp3->xing_offset = avio_tell(s->pb);
ffio_wfourcc(s->pb, "Xing");
avio_wb32(s->pb, 0x01 | 0x02 | 0x04); / size / TOC
mp3->size = mpah.frame_size;
mp3->want=1;
mp3->seen=0;
mp3->pos=0;
avio_wb32(s->pb, 0);
avio_wb32(s->pb, 0);
for (i = 0; i < XING_TOC_SIZE; ++i)
avio_w8(s->pb, (uint8_t)(255 * i / XING_TOC_SIZE));
for (i = 0; i < strlen(vendor); ++i)
avio_w8(s->pb, vendor[i]);
for (; i < 21; ++i)
avio_w8(s->pb, 0);
avio_wb24(s->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);
ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed);
return 0;
}
| {
"code": [
" int bytes_needed, lsf;",
" int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];"
],
"line_no": [
25,
99
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MP3Context *mp3 = VAR_0->priv_data;
AVCodecContext *codec = VAR_0->streams[mp3->audio_stream_idx]->codec;
int32_t header;
MPADecodeHeader mpah;
int VAR_1, VAR_2, VAR_3;
int VAR_4;
int VAR_5 = -1;
int VAR_6 = INT_MAX;
int VAR_7;
int VAR_8 = 0;
int VAR_9, VAR_10;
const char *VAR_11 = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
if (!VAR_0->pb->seekable || !mp3->write_xing)
return 0;
for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); VAR_2++) {
const uint16_t base_freq = avpriv_mpa_freq_tab[VAR_2];
if (codec->sample_rate == base_freq) VAR_8 = 0x3;
else if (codec->sample_rate == base_freq / 2) VAR_8 = 0x2;
else if (codec->sample_rate == base_freq / 4) VAR_8 = 0x0; .5
else continue;
VAR_1 = VAR_2;
break;
}
if (VAR_2 == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
av_log(VAR_0, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
return -1;
}
switch (codec->VAR_3) {
case 1: VAR_3 = MPA_MONO; break;
case 2: VAR_3 = MPA_STEREO; break;
default: av_log(VAR_0, AV_LOG_WARNING, "Unsupported number of VAR_3, "
"not writing Xing header.\n");
return -1;
}
header = 0xffU << 24;
header |= (0x7 << 5 | VAR_8 << 3 | 0x1 << 1 | 0x1) << 16; /audio-version/layer 3/no crc*/
header |= (VAR_1 << 2) << 8;
header |= VAR_3 << 6;
for (VAR_4 = 1; VAR_4 < 15; VAR_4++) {
int VAR_12 = 1000 * avpriv_mpa_bitrate_tab[VAR_10][3 - 1][VAR_4];
int VAR_13 = FFABS(VAR_12 - codec->VAR_12);
if (VAR_13 < VAR_6) {
VAR_6 = VAR_13;
VAR_5 = VAR_4;
}
}
av_assert0(VAR_5 >= 0);
for (VAR_4 = VAR_5; ; VAR_4++) {
int32_t mask = VAR_4 << (4 + 8);
if (15 == VAR_4)
return -1;
header |= mask;
avpriv_mpegaudio_decode_header(&mpah, header);
VAR_7=xing_offtbl[mpah.VAR_10 == 1][mpah.nb_channels == 1];
VAR_9 = 4
+ VAR_7
+ 4
+ 4
+ 4
+ 4
+ XING_TOC_SIZE
+ 24
;
if (VAR_9 <= mpah.frame_size)
break;
header &= ~mask;
}
avio_wb32(VAR_0->pb, header);
ffio_fill(VAR_0->pb, 0, VAR_7);
mp3->VAR_7 = avio_tell(VAR_0->pb);
ffio_wfourcc(VAR_0->pb, "Xing");
avio_wb32(VAR_0->pb, 0x01 | 0x02 | 0x04); / size / TOC
mp3->size = mpah.frame_size;
mp3->want=1;
mp3->seen=0;
mp3->pos=0;
avio_wb32(VAR_0->pb, 0);
avio_wb32(VAR_0->pb, 0);
for (VAR_2 = 0; VAR_2 < XING_TOC_SIZE; ++VAR_2)
avio_w8(VAR_0->pb, (uint8_t)(255 * VAR_2 / XING_TOC_SIZE));
for (VAR_2 = 0; VAR_2 < strlen(VAR_11); ++VAR_2)
avio_w8(VAR_0->pb, VAR_11[VAR_2]);
for (; VAR_2 < 21; ++VAR_2)
avio_w8(VAR_0->pb, 0);
avio_wb24(VAR_0->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);
ffio_fill(VAR_0->pb, 0, mpah.frame_size - VAR_9);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MP3Context *mp3 = VAR_0->priv_data;",
"AVCodecContext *codec = VAR_0->streams[mp3->audio_stream_idx]->codec;",
"int32_t header;",
"MPADecodeHeader mpah;",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4;",
"int VAR_5 = -1;",
"int VAR_6 = INT_MAX;",
"int VAR_7;",
"int VAR_8 = 0;",
"int VAR_9, VAR_10;",
"const char *VAR_11 = (codec->flags & CODEC_FLAG_BITEXACT) ? \"Lavf\" : LIBAVFORMAT_IDENT;",
"if (!VAR_0->pb->seekable || !mp3->write_xing)\nreturn 0;",
"for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); VAR_2++) {",
"const uint16_t base_freq = avpriv_mpa_freq_tab[VAR_2];",
"if (codec->sample_rate == base_freq) VAR_8 = 0x3;",
"else if (codec->sample_rate == base_freq / 2) VAR_8 = 0x2;",
"else if (codec->sample_rate == base_freq / 4) VAR_8 = 0x0; .5",
"else continue;",
"VAR_1 = VAR_2;",
"break;",
"}",
"if (VAR_2 == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unsupported sample rate, not writing Xing header.\\n\");",
"return -1;",
"}",
"switch (codec->VAR_3) {",
"case 1: VAR_3 = MPA_MONO; break;",
"case 2: VAR_3 = MPA_STEREO; break;",
"default: av_log(VAR_0, AV_LOG_WARNING, \"Unsupported number of VAR_3, \"\n\"not writing Xing header.\\n\");",
"return -1;",
"}",
"header = 0xffU << 24;",
"header |= (0x7 << 5 | VAR_8 << 3 | 0x1 << 1 | 0x1) << 16; /audio-version/layer 3/no crc*/",
"header |= (VAR_1 << 2) << 8;",
"header |= VAR_3 << 6;",
"for (VAR_4 = 1; VAR_4 < 15; VAR_4++) {",
"int VAR_12 = 1000 * avpriv_mpa_bitrate_tab[VAR_10][3 - 1][VAR_4];",
"int VAR_13 = FFABS(VAR_12 - codec->VAR_12);",
"if (VAR_13 < VAR_6) {",
"VAR_6 = VAR_13;",
"VAR_5 = VAR_4;",
"}",
"}",
"av_assert0(VAR_5 >= 0);",
"for (VAR_4 = VAR_5; ; VAR_4++) {",
"int32_t mask = VAR_4 << (4 + 8);",
"if (15 == VAR_4)\nreturn -1;",
"header |= mask;",
"avpriv_mpegaudio_decode_header(&mpah, header);",
"VAR_7=xing_offtbl[mpah.VAR_10 == 1][mpah.nb_channels == 1];",
"VAR_9 = 4\n+ VAR_7\n+ 4\n+ 4\n+ 4\n+ 4\n+ XING_TOC_SIZE\n+ 24\n;",
"if (VAR_9 <= mpah.frame_size)\nbreak;",
"header &= ~mask;",
"}",
"avio_wb32(VAR_0->pb, header);",
"ffio_fill(VAR_0->pb, 0, VAR_7);",
"mp3->VAR_7 = avio_tell(VAR_0->pb);",
"ffio_wfourcc(VAR_0->pb, \"Xing\");",
"avio_wb32(VAR_0->pb, 0x01 | 0x02 | 0x04); / size / TOC",
"mp3->size = mpah.frame_size;",
"mp3->want=1;",
"mp3->seen=0;",
"mp3->pos=0;",
"avio_wb32(VAR_0->pb, 0);",
"avio_wb32(VAR_0->pb, 0);",
"for (VAR_2 = 0; VAR_2 < XING_TOC_SIZE; ++VAR_2)",
"avio_w8(VAR_0->pb, (uint8_t)(255 * VAR_2 / XING_TOC_SIZE));",
"for (VAR_2 = 0; VAR_2 < strlen(VAR_11); ++VAR_2)",
"avio_w8(VAR_0->pb, VAR_11[VAR_2]);",
"for (; VAR_2 < 21; ++VAR_2)",
"avio_w8(VAR_0->pb, 0);",
"avio_wb24(VAR_0->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);",
"ffio_fill(VAR_0->pb, 0, mpah.frame_size - VAR_9);",
"return 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
131
],
[
133
],
[
135,
137,
139,
141,
143,
145,
147,
149,
151
],
[
155,
157
],
[
161
],
[
163
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
221
],
[
223
]
]
|
13,842 | static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
// check if we have an audio packet cached
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
av_free_packet(&mkv->cur_audio_pkt);
if (ret < 0) {
av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
return ret;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(s);
} else if (mkv->cluster_pos != -1) {
end_ebml_master(pb, mkv->cluster);
}
if (mkv->mode != MODE_WEBM) {
ret = mkv_write_chapters(s);
if (ret < 0)
return ret;
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
if (mkv->reserve_cues_space) {
int64_t cues_end;
currentpos = avio_tell(pb);
avio_seek(pb, mkv->cues_pos, SEEK_SET);
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
cues_end = avio_tell(pb);
if (cues_end > cuespos + mkv->reserve_cues_space) {
av_log(s, AV_LOG_ERROR,
"Insufficient space reserved for cues: %d "
"(needed: %" PRId64 ").\n",
mkv->reserve_cues_space, cues_end - cuespos);
return AVERROR(EINVAL);
}
if (cues_end < cuespos + mkv->reserve_cues_space)
put_ebml_void(pb, mkv->reserve_cues_space -
(cues_end - cuespos));
avio_seek(pb, currentpos, SEEK_SET);
} else {
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
}
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES,
cuespos);
if (ret < 0)
return ret;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
// update the duration
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
// update stream durations
if (mkv->stream_durations) {
int i;
for (i = 0; i < s->nb_streams; ++i) {
AVStream *st = s->streams[i];
double duration_sec = mkv->stream_durations[i] * av_q2d(st->time_base);
char duration_string[20] = "";
av_log(s, AV_LOG_DEBUG, "stream %d end duration = %" PRIu64 "\n", i,
mkv->stream_durations[i]);
if (!mkv->is_live && mkv->stream_duration_offsets[i] > 0) {
avio_seek(pb, mkv->stream_duration_offsets[i], SEEK_SET);
snprintf(duration_string, 20, "%02d:%02d:%012.9f",
(int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
fmod(duration_sec, 60));
put_ebml_binary(pb, MATROSKA_ID_TAGSTRING, duration_string, 20);
}
}
}
avio_seek(pb, currentpos, SEEK_SET);
}
if (!mkv->is_live) {
end_ebml_master(pb, mkv->segment);
}
av_freep(&mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_freep(&mkv->stream_durations);
av_freep(&mkv->stream_duration_offsets);
return 0;
}
| true | FFmpeg | 3dabebc272b0ab5455610975a6d75de08b97dc62 | static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
av_free_packet(&mkv->cur_audio_pkt);
if (ret < 0) {
av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
return ret;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(s);
} else if (mkv->cluster_pos != -1) {
end_ebml_master(pb, mkv->cluster);
}
if (mkv->mode != MODE_WEBM) {
ret = mkv_write_chapters(s);
if (ret < 0)
return ret;
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
if (mkv->reserve_cues_space) {
int64_t cues_end;
currentpos = avio_tell(pb);
avio_seek(pb, mkv->cues_pos, SEEK_SET);
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
cues_end = avio_tell(pb);
if (cues_end > cuespos + mkv->reserve_cues_space) {
av_log(s, AV_LOG_ERROR,
"Insufficient space reserved for cues: %d "
"(needed: %" PRId64 ").\n",
mkv->reserve_cues_space, cues_end - cuespos);
return AVERROR(EINVAL);
}
if (cues_end < cuespos + mkv->reserve_cues_space)
put_ebml_void(pb, mkv->reserve_cues_space -
(cues_end - cuespos));
avio_seek(pb, currentpos, SEEK_SET);
} else {
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
}
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES,
cuespos);
if (ret < 0)
return ret;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
if (mkv->stream_durations) {
int i;
for (i = 0; i < s->nb_streams; ++i) {
AVStream *st = s->streams[i];
double duration_sec = mkv->stream_durations[i] * av_q2d(st->time_base);
char duration_string[20] = "";
av_log(s, AV_LOG_DEBUG, "stream %d end duration = %" PRIu64 "\n", i,
mkv->stream_durations[i]);
if (!mkv->is_live && mkv->stream_duration_offsets[i] > 0) {
avio_seek(pb, mkv->stream_duration_offsets[i], SEEK_SET);
snprintf(duration_string, 20, "%02d:%02d:%012.9f",
(int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
fmod(duration_sec, 60));
put_ebml_binary(pb, MATROSKA_ID_TAGSTRING, duration_string, 20);
}
}
}
avio_seek(pb, currentpos, SEEK_SET);
}
if (!mkv->is_live) {
end_ebml_master(pb, mkv->segment);
}
av_freep(&mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_freep(&mkv->stream_durations);
av_freep(&mkv->stream_duration_offsets);
return 0;
}
| {
"code": [
" return ret;",
" return ret;",
" return ret;",
" mkv_write_seekhead(pb, mkv->main_seekhead);",
" mkv_write_seekhead(pb, mkv->main_seekhead);",
" av_freep(&mkv->tracks);",
" av_freep(&mkv->cues->entries);",
" av_freep(&mkv->cues);",
" av_freep(&mkv->stream_durations);",
" av_freep(&mkv->stream_duration_offsets);"
],
"line_no": [
29,
29,
29,
129,
129,
203,
205,
207,
209,
211
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MatroskaMuxContext *mkv = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int64_t currentpos, cuespos;
int VAR_1;
if (mkv->cur_audio_pkt.size > 0) {
VAR_1 = mkv_write_packet_internal(VAR_0, &mkv->cur_audio_pkt, 0);
av_free_packet(&mkv->cur_audio_pkt);
if (VAR_1 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Could not write cached audio packet VAR_1:%d\n", VAR_1);
return VAR_1;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(VAR_0);
} else if (mkv->cluster_pos != -1) {
end_ebml_master(pb, mkv->cluster);
}
if (mkv->mode != MODE_WEBM) {
VAR_1 = mkv_write_chapters(VAR_0);
if (VAR_1 < 0)
return VAR_1;
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
if (mkv->reserve_cues_space) {
int64_t cues_end;
currentpos = avio_tell(pb);
avio_seek(pb, mkv->cues_pos, SEEK_SET);
cuespos = mkv_write_cues(VAR_0, mkv->cues, mkv->tracks, VAR_0->nb_streams);
cues_end = avio_tell(pb);
if (cues_end > cuespos + mkv->reserve_cues_space) {
av_log(VAR_0, AV_LOG_ERROR,
"Insufficient space reserved for cues: %d "
"(needed: %" PRId64 ").\n",
mkv->reserve_cues_space, cues_end - cuespos);
return AVERROR(EINVAL);
}
if (cues_end < cuespos + mkv->reserve_cues_space)
put_ebml_void(pb, mkv->reserve_cues_space -
(cues_end - cuespos));
avio_seek(pb, currentpos, SEEK_SET);
} else {
cuespos = mkv_write_cues(VAR_0, mkv->cues, mkv->tracks, VAR_0->nb_streams);
}
VAR_1 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES,
cuespos);
if (VAR_1 < 0)
return VAR_1;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
av_log(VAR_0, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
if (mkv->stream_durations) {
int VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; ++VAR_2) {
AVStream *st = VAR_0->streams[VAR_2];
double duration_sec = mkv->stream_durations[VAR_2] * av_q2d(st->time_base);
char duration_string[20] = "";
av_log(VAR_0, AV_LOG_DEBUG, "stream %d end duration = %" PRIu64 "\n", VAR_2,
mkv->stream_durations[VAR_2]);
if (!mkv->is_live && mkv->stream_duration_offsets[VAR_2] > 0) {
avio_seek(pb, mkv->stream_duration_offsets[VAR_2], SEEK_SET);
snprintf(duration_string, 20, "%02d:%02d:%012.9f",
(int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
fmod(duration_sec, 60));
put_ebml_binary(pb, MATROSKA_ID_TAGSTRING, duration_string, 20);
}
}
}
avio_seek(pb, currentpos, SEEK_SET);
}
if (!mkv->is_live) {
end_ebml_master(pb, mkv->segment);
}
av_freep(&mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_freep(&mkv->stream_durations);
av_freep(&mkv->stream_duration_offsets);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MatroskaMuxContext *mkv = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int64_t currentpos, cuespos;",
"int VAR_1;",
"if (mkv->cur_audio_pkt.size > 0) {",
"VAR_1 = mkv_write_packet_internal(VAR_0, &mkv->cur_audio_pkt, 0);",
"av_free_packet(&mkv->cur_audio_pkt);",
"if (VAR_1 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Could not write cached audio packet VAR_1:%d\\n\", VAR_1);",
"return VAR_1;",
"}",
"}",
"if (mkv->dyn_bc) {",
"end_ebml_master(mkv->dyn_bc, mkv->cluster);",
"mkv_flush_dynbuf(VAR_0);",
"} else if (mkv->cluster_pos != -1) {",
"end_ebml_master(pb, mkv->cluster);",
"}",
"if (mkv->mode != MODE_WEBM) {",
"VAR_1 = mkv_write_chapters(VAR_0);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"}",
"if (pb->seekable) {",
"if (mkv->cues->num_entries) {",
"if (mkv->reserve_cues_space) {",
"int64_t cues_end;",
"currentpos = avio_tell(pb);",
"avio_seek(pb, mkv->cues_pos, SEEK_SET);",
"cuespos = mkv_write_cues(VAR_0, mkv->cues, mkv->tracks, VAR_0->nb_streams);",
"cues_end = avio_tell(pb);",
"if (cues_end > cuespos + mkv->reserve_cues_space) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Insufficient space reserved for cues: %d \"\n\"(needed: %\" PRId64 \").\\n\",\nmkv->reserve_cues_space, cues_end - cuespos);",
"return AVERROR(EINVAL);",
"}",
"if (cues_end < cuespos + mkv->reserve_cues_space)\nput_ebml_void(pb, mkv->reserve_cues_space -\n(cues_end - cuespos));",
"avio_seek(pb, currentpos, SEEK_SET);",
"} else {",
"cuespos = mkv_write_cues(VAR_0, mkv->cues, mkv->tracks, VAR_0->nb_streams);",
"}",
"VAR_1 = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES,\ncuespos);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"}",
"mkv_write_seekhead(pb, mkv->main_seekhead);",
"av_log(VAR_0, AV_LOG_DEBUG, \"end duration = %\" PRIu64 \"\\n\", mkv->duration);",
"currentpos = avio_tell(pb);",
"avio_seek(pb, mkv->duration_offset, SEEK_SET);",
"put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);",
"if (mkv->stream_durations) {",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; ++VAR_2) {",
"AVStream *st = VAR_0->streams[VAR_2];",
"double duration_sec = mkv->stream_durations[VAR_2] * av_q2d(st->time_base);",
"char duration_string[20] = \"\";",
"av_log(VAR_0, AV_LOG_DEBUG, \"stream %d end duration = %\" PRIu64 \"\\n\", VAR_2,\nmkv->stream_durations[VAR_2]);",
"if (!mkv->is_live && mkv->stream_duration_offsets[VAR_2] > 0) {",
"avio_seek(pb, mkv->stream_duration_offsets[VAR_2], SEEK_SET);",
"snprintf(duration_string, 20, \"%02d:%02d:%012.9f\",\n(int) duration_sec / 3600, ((int) duration_sec / 60) % 60,\nfmod(duration_sec, 60));",
"put_ebml_binary(pb, MATROSKA_ID_TAGSTRING, duration_string, 20);",
"}",
"}",
"}",
"avio_seek(pb, currentpos, SEEK_SET);",
"}",
"if (!mkv->is_live) {",
"end_ebml_master(pb, mkv->segment);",
"}",
"av_freep(&mkv->tracks);",
"av_freep(&mkv->cues->entries);",
"av_freep(&mkv->cues);",
"av_freep(&mkv->stream_durations);",
"av_freep(&mkv->stream_duration_offsets);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85,
87,
89,
91
],
[
93
],
[
95
],
[
99,
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121,
123
],
[
125
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161,
163
],
[
167
],
[
169
],
[
173,
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
]
]
|
13,843 | static int quantize(CinepakEncContext *s, int h, AVPicture *pict, int v1mode, int size, int v4, strip_info *info)
{
int x, y, i, j, k, x2, y2, x3, y3, plane, shift;
int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;
int *codebook = v1mode ? info->v1_codebook : info->v4_codebook;
int64_t total_error = 0;
uint8_t vq_pict_buf[(MB_AREA*3)/2];
AVPicture sub_pict, vq_pict;
for(i = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, i += v1mode ? 1 : 4) {
int *base = s->codebook_input + i*entry_size;
if(v1mode) {
//subsample
for(j = y2 = 0; y2 < entry_size; y2 += 2) {
for(x2 = 0; x2 < 4; x2 += 2, j++) {
plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
shift = y2 < 4 ? 0 : 1;
x3 = shift ? 0 : x2;
y3 = shift ? 0 : y2;
base[j] = (pict->data[plane][((x+x3) >> shift) + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + (((y+y3) >> shift) + 1) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + (((y+y3) >> shift) + 1) * pict->linesize[plane]]) >> 2;
}
}
} else {
//copy
for(j = y2 = 0; y2 < MB_SIZE; y2 += 2) {
for(x2 = 0; x2 < MB_SIZE; x2 += 2) {
for(k = 0; k < entry_size; k++, j++) {
plane = k >= 4 ? k - 3 : 0;
if(k >= 4) {
x3 = (x+x2) >> 1;
y3 = (y+y2) >> 1;
} else {
x3 = x + x2 + (k & 1);
y3 = y + y2 + (k >> 1);
}
base[j] = pict->data[plane][x3 + y3*pict->linesize[plane]];
}
}
}
}
}
}
ff_init_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
ff_do_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
//setup vq_pict, which contains a single MB
vq_pict.data[0] = vq_pict_buf;
vq_pict.linesize[0] = MB_SIZE;
vq_pict.data[1] = &vq_pict_buf[MB_AREA];
vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);
vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;
//copy indices
for(i = j = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, j++, i += v1mode ? 1 : 4) {
mb_info *mb = &s->mb[j];
//point sub_pict to current MB
get_sub_picture(s, x, y, pict, &sub_pict);
if(v1mode) {
mb->v1_vector = s->codebook_closest[i];
//fill in vq_pict with V1 data
decode_v1_vector(s, &vq_pict, mb, info);
mb->v1_error = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v1_error;
} else {
for(k = 0; k < 4; k++)
mb->v4_vector[v4][k] = s->codebook_closest[i+k];
//fill in vq_pict with V4 data
decode_v4_vector(s, &vq_pict, mb->v4_vector[v4], info);
mb->v4_error[v4] = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v4_error[v4];
}
}
}
//av_log(s->avctx, AV_LOG_INFO, "mode %i size %i i %i error %li\n", v1mode, size, i, total_error);
return 0;
}
| true | FFmpeg | 7da9f4523159670d577a2808d4481e64008a8894 | static int quantize(CinepakEncContext *s, int h, AVPicture *pict, int v1mode, int size, int v4, strip_info *info)
{
int x, y, i, j, k, x2, y2, x3, y3, plane, shift;
int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;
int *codebook = v1mode ? info->v1_codebook : info->v4_codebook;
int64_t total_error = 0;
uint8_t vq_pict_buf[(MB_AREA*3)/2];
AVPicture sub_pict, vq_pict;
for(i = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, i += v1mode ? 1 : 4) {
int *base = s->codebook_input + i*entry_size;
if(v1mode) {
for(j = y2 = 0; y2 < entry_size; y2 += 2) {
for(x2 = 0; x2 < 4; x2 += 2, j++) {
plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
shift = y2 < 4 ? 0 : 1;
x3 = shift ? 0 : x2;
y3 = shift ? 0 : y2;
base[j] = (pict->data[plane][((x+x3) >> shift) + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + (((y+y3) >> shift) + 1) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + (((y+y3) >> shift) + 1) * pict->linesize[plane]]) >> 2;
}
}
} else {
for(j = y2 = 0; y2 < MB_SIZE; y2 += 2) {
for(x2 = 0; x2 < MB_SIZE; x2 += 2) {
for(k = 0; k < entry_size; k++, j++) {
plane = k >= 4 ? k - 3 : 0;
if(k >= 4) {
x3 = (x+x2) >> 1;
y3 = (y+y2) >> 1;
} else {
x3 = x + x2 + (k & 1);
y3 = y + y2 + (k >> 1);
}
base[j] = pict->data[plane][x3 + y3*pict->linesize[plane]];
}
}
}
}
}
}
ff_init_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
ff_do_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
vq_pict.data[0] = vq_pict_buf;
vq_pict.linesize[0] = MB_SIZE;
vq_pict.data[1] = &vq_pict_buf[MB_AREA];
vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);
vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;
indices
for(i = j = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, j++, i += v1mode ? 1 : 4) {
mb_info *mb = &s->mb[j];
get_sub_picture(s, x, y, pict, &sub_pict);
if(v1mode) {
mb->v1_vector = s->codebook_closest[i];
decode_v1_vector(s, &vq_pict, mb, info);
mb->v1_error = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v1_error;
} else {
for(k = 0; k < 4; k++)
mb->v4_vector[v4][k] = s->codebook_closest[i+k];
decode_v4_vector(s, &vq_pict, mb->v4_vector[v4], info);
mb->v4_error[v4] = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v4_error[v4];
}
}
}
return 0;
}
| {
"code": [
" int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;",
" } else {",
" } else {",
" int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;",
"static int quantize(CinepakEncContext *s, int h, AVPicture *pict, int v1mode, int size, int v4, strip_info *info)",
" int x, y, i, j, k, x2, y2, x3, y3, plane, shift;",
" int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;",
" for(i = y = 0; y < h; y += MB_SIZE) {",
" for(x = 0; x < s->w; x += MB_SIZE, i += v1mode ? 1 : 4) {",
" int *base = s->codebook_input + i*entry_size;",
" for(x = 0; x < s->w; x += MB_SIZE, j++, i += v1mode ? 1 : 4) {",
" decode_v1_vector(s, &vq_pict, mb, info);",
" mb->v4_vector[v4][k] = s->codebook_closest[i+k];",
" decode_v4_vector(s, &vq_pict, mb->v4_vector[v4], info);",
" mb->v4_error[v4] = compute_mb_distortion(s, &sub_pict, &vq_pict);",
" total_error += mb->v4_error[v4];",
" return 0;"
],
"line_no": [
7,
55,
55,
7,
1,
5,
7,
19,
21,
23,
125,
145,
157,
163,
167,
169,
183
]
} | static int FUNC_0(CinepakEncContext *VAR_0, int VAR_1, AVPicture *VAR_2, int VAR_3, int VAR_4, int VAR_5, strip_info *VAR_6)
{
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;
int VAR_18 = VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;
int *VAR_19 = VAR_3 ? VAR_6->v1_codebook : VAR_6->v4_codebook;
int64_t total_error = 0;
uint8_t vq_pict_buf[(MB_AREA*3)/2];
AVPicture sub_pict, vq_pict;
for(VAR_9 = VAR_8 = 0; VAR_8 < VAR_1; VAR_8 += MB_SIZE) {
for(VAR_7 = 0; VAR_7 < VAR_0->w; VAR_7 += MB_SIZE, VAR_9 += VAR_3 ? 1 : 4) {
int *base = VAR_0->codebook_input + VAR_9*VAR_18;
if(VAR_3) {
for(VAR_10 = VAR_13 = 0; VAR_13 < VAR_18; VAR_13 += 2) {
for(VAR_12 = 0; VAR_12 < 4; VAR_12 += 2, VAR_10++) {
VAR_16 = VAR_13 < 4 ? 0 : 1 + (VAR_12 >> 1);
VAR_17 = VAR_13 < 4 ? 0 : 1;
VAR_14 = VAR_17 ? 0 : VAR_12;
VAR_15 = VAR_17 ? 0 : VAR_13;
base[VAR_10] = (VAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + ((VAR_8+VAR_15) >> VAR_17) * VAR_2->linesize[VAR_16]] +
VAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + 1 + ((VAR_8+VAR_15) >> VAR_17) * VAR_2->linesize[VAR_16]] +
VAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + (((VAR_8+VAR_15) >> VAR_17) + 1) * VAR_2->linesize[VAR_16]] +
VAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + 1 + (((VAR_8+VAR_15) >> VAR_17) + 1) * VAR_2->linesize[VAR_16]]) >> 2;
}
}
} else {
for(VAR_10 = VAR_13 = 0; VAR_13 < MB_SIZE; VAR_13 += 2) {
for(VAR_12 = 0; VAR_12 < MB_SIZE; VAR_12 += 2) {
for(VAR_11 = 0; VAR_11 < VAR_18; VAR_11++, VAR_10++) {
VAR_16 = VAR_11 >= 4 ? VAR_11 - 3 : 0;
if(VAR_11 >= 4) {
VAR_14 = (VAR_7+VAR_12) >> 1;
VAR_15 = (VAR_8+VAR_13) >> 1;
} else {
VAR_14 = VAR_7 + VAR_12 + (VAR_11 & 1);
VAR_15 = VAR_8 + VAR_13 + (VAR_11 >> 1);
}
base[VAR_10] = VAR_2->data[VAR_16][VAR_14 + VAR_15*VAR_2->linesize[VAR_16]];
}
}
}
}
}
}
ff_init_elbg(VAR_0->codebook_input, VAR_18, VAR_9, VAR_19, VAR_4, 1, VAR_0->codebook_closest, &VAR_0->randctx);
ff_do_elbg(VAR_0->codebook_input, VAR_18, VAR_9, VAR_19, VAR_4, 1, VAR_0->codebook_closest, &VAR_0->randctx);
vq_pict.data[0] = vq_pict_buf;
vq_pict.linesize[0] = MB_SIZE;
vq_pict.data[1] = &vq_pict_buf[MB_AREA];
vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);
vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;
indices
for(VAR_9 = VAR_10 = VAR_8 = 0; VAR_8 < VAR_1; VAR_8 += MB_SIZE) {
for(VAR_7 = 0; VAR_7 < VAR_0->w; VAR_7 += MB_SIZE, VAR_10++, VAR_9 += VAR_3 ? 1 : 4) {
mb_info *mb = &VAR_0->mb[VAR_10];
get_sub_picture(VAR_0, VAR_7, VAR_8, VAR_2, &sub_pict);
if(VAR_3) {
mb->v1_vector = VAR_0->codebook_closest[VAR_9];
decode_v1_vector(VAR_0, &vq_pict, mb, VAR_6);
mb->v1_error = compute_mb_distortion(VAR_0, &sub_pict, &vq_pict);
total_error += mb->v1_error;
} else {
for(VAR_11 = 0; VAR_11 < 4; VAR_11++)
mb->v4_vector[VAR_5][VAR_11] = VAR_0->codebook_closest[VAR_9+VAR_11];
decode_v4_vector(VAR_0, &vq_pict, mb->v4_vector[VAR_5], VAR_6);
mb->v4_error[VAR_5] = compute_mb_distortion(VAR_0, &sub_pict, &vq_pict);
total_error += mb->v4_error[VAR_5];
}
}
}
return 0;
}
| [
"static int FUNC_0(CinepakEncContext *VAR_0, int VAR_1, AVPicture *VAR_2, int VAR_3, int VAR_4, int VAR_5, strip_info *VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;",
"int VAR_18 = VAR_0->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;",
"int *VAR_19 = VAR_3 ? VAR_6->v1_codebook : VAR_6->v4_codebook;",
"int64_t total_error = 0;",
"uint8_t vq_pict_buf[(MB_AREA*3)/2];",
"AVPicture sub_pict, vq_pict;",
"for(VAR_9 = VAR_8 = 0; VAR_8 < VAR_1; VAR_8 += MB_SIZE) {",
"for(VAR_7 = 0; VAR_7 < VAR_0->w; VAR_7 += MB_SIZE, VAR_9 += VAR_3 ? 1 : 4) {",
"int *base = VAR_0->codebook_input + VAR_9*VAR_18;",
"if(VAR_3) {",
"for(VAR_10 = VAR_13 = 0; VAR_13 < VAR_18; VAR_13 += 2) {",
"for(VAR_12 = 0; VAR_12 < 4; VAR_12 += 2, VAR_10++) {",
"VAR_16 = VAR_13 < 4 ? 0 : 1 + (VAR_12 >> 1);",
"VAR_17 = VAR_13 < 4 ? 0 : 1;",
"VAR_14 = VAR_17 ? 0 : VAR_12;",
"VAR_15 = VAR_17 ? 0 : VAR_13;",
"base[VAR_10] = (VAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + ((VAR_8+VAR_15) >> VAR_17) * VAR_2->linesize[VAR_16]] +\nVAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + 1 + ((VAR_8+VAR_15) >> VAR_17) * VAR_2->linesize[VAR_16]] +\nVAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + (((VAR_8+VAR_15) >> VAR_17) + 1) * VAR_2->linesize[VAR_16]] +\nVAR_2->data[VAR_16][((VAR_7+VAR_14) >> VAR_17) + 1 + (((VAR_8+VAR_15) >> VAR_17) + 1) * VAR_2->linesize[VAR_16]]) >> 2;",
"}",
"}",
"} else {",
"for(VAR_10 = VAR_13 = 0; VAR_13 < MB_SIZE; VAR_13 += 2) {",
"for(VAR_12 = 0; VAR_12 < MB_SIZE; VAR_12 += 2) {",
"for(VAR_11 = 0; VAR_11 < VAR_18; VAR_11++, VAR_10++) {",
"VAR_16 = VAR_11 >= 4 ? VAR_11 - 3 : 0;",
"if(VAR_11 >= 4) {",
"VAR_14 = (VAR_7+VAR_12) >> 1;",
"VAR_15 = (VAR_8+VAR_13) >> 1;",
"} else {",
"VAR_14 = VAR_7 + VAR_12 + (VAR_11 & 1);",
"VAR_15 = VAR_8 + VAR_13 + (VAR_11 >> 1);",
"}",
"base[VAR_10] = VAR_2->data[VAR_16][VAR_14 + VAR_15*VAR_2->linesize[VAR_16]];",
"}",
"}",
"}",
"}",
"}",
"}",
"ff_init_elbg(VAR_0->codebook_input, VAR_18, VAR_9, VAR_19, VAR_4, 1, VAR_0->codebook_closest, &VAR_0->randctx);",
"ff_do_elbg(VAR_0->codebook_input, VAR_18, VAR_9, VAR_19, VAR_4, 1, VAR_0->codebook_closest, &VAR_0->randctx);",
"vq_pict.data[0] = vq_pict_buf;",
"vq_pict.linesize[0] = MB_SIZE;",
"vq_pict.data[1] = &vq_pict_buf[MB_AREA];",
"vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);",
"vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;",
"indices\nfor(VAR_9 = VAR_10 = VAR_8 = 0; VAR_8 < VAR_1; VAR_8 += MB_SIZE) {",
"for(VAR_7 = 0; VAR_7 < VAR_0->w; VAR_7 += MB_SIZE, VAR_10++, VAR_9 += VAR_3 ? 1 : 4) {",
"mb_info *mb = &VAR_0->mb[VAR_10];",
"get_sub_picture(VAR_0, VAR_7, VAR_8, VAR_2, &sub_pict);",
"if(VAR_3) {",
"mb->v1_vector = VAR_0->codebook_closest[VAR_9];",
"decode_v1_vector(VAR_0, &vq_pict, mb, VAR_6);",
"mb->v1_error = compute_mb_distortion(VAR_0, &sub_pict, &vq_pict);",
"total_error += mb->v1_error;",
"} else {",
"for(VAR_11 = 0; VAR_11 < 4; VAR_11++)",
"mb->v4_vector[VAR_5][VAR_11] = VAR_0->codebook_closest[VAR_9+VAR_11];",
"decode_v4_vector(VAR_0, &vq_pict, mb->v4_vector[VAR_5], VAR_6);",
"mb->v4_error[VAR_5] = compute_mb_distortion(VAR_0, &sub_pict, &vq_pict);",
"total_error += mb->v4_error[VAR_5];",
"}",
"}",
"}",
"return 0;",
"}"
]
| [
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
],
[
133
],
[
137
],
[
139
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
183
],
[
185
]
]
|
13,844 | void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size)
{
if (!f->ops->writev_buffer) {
qemu_put_buffer(f, buf, size);
return;
}
if (f->last_error) {
return;
}
f->bytes_xfer += size;
add_to_iovec(f, buf, size);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size)
{
if (!f->ops->writev_buffer) {
qemu_put_buffer(f, buf, size);
return;
}
if (f->last_error) {
return;
}
f->bytes_xfer += size;
add_to_iovec(f, buf, size);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
if (!VAR_0->ops->writev_buffer) {
qemu_put_buffer(VAR_0, VAR_1, VAR_2);
return;
}
if (VAR_0->last_error) {
return;
}
VAR_0->bytes_xfer += VAR_2;
add_to_iovec(VAR_0, VAR_1, VAR_2);
}
| [
"void FUNC_0(QEMUFile *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"if (!VAR_0->ops->writev_buffer) {",
"qemu_put_buffer(VAR_0, VAR_1, VAR_2);",
"return;",
"}",
"if (VAR_0->last_error) {",
"return;",
"}",
"VAR_0->bytes_xfer += VAR_2;",
"add_to_iovec(VAR_0, VAR_1, VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
]
]
|
13,845 | static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcowState *s = bs->opaque;
int l2_index;
uint64_t *l2_table;
uint64_t entry;
unsigned int nb_clusters;
int ret;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
*bytes);
assert(*bytes > 0);
/*
* Calculate the number of clusters to look for. We stop at L2 table
* boundaries to keep things simple.
*/
nb_clusters =
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
l2_index = offset_to_l2_index(s, guest_offset);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
/* Find L2 entry for the first involved cluster */
ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
}
entry = be64_to_cpu(l2_table[l2_index]);
/* For the moment, overwrite compressed clusters one by one */
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
}
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
return ret;
}
if (nb_clusters == 0) {
*bytes = 0;
return 0;
}
/* Allocate, if necessary at a given offset in the image file */
alloc_cluster_offset = start_of_cluster(s, *host_offset);
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
&nb_clusters);
if (ret < 0) {
goto fail;
}
/* Can't extend contiguous allocation */
if (nb_clusters == 0) {
*bytes = 0;
return 0;
}
/*
* Save info needed for meta data update.
*
* requested_sectors: Number of sectors from the start of the first
* newly allocated cluster to the end of the (possibly shortened
* before) write request.
*
* avail_sectors: Number of sectors from the start of the first
* newly allocated to the end of the last newly allocated cluster.
*
* nb_sectors: The number of sectors from the start of the first
* newly allocated cluster to the end of the area that the write
* request actually writes to (excluding COW at the end)
*/
int requested_sectors =
(*bytes + offset_into_cluster(s, guest_offset))
>> BDRV_SECTOR_BITS;
int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int alloc_n_start = offset_into_cluster(s, guest_offset)
>> BDRV_SECTOR_BITS;
int nb_sectors = MIN(requested_sectors, avail_sectors);
QCowL2Meta *old_m = *m;
*m = g_malloc0(sizeof(**m));
**m = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, guest_offset),
.nb_clusters = nb_clusters,
.nb_available = nb_sectors,
.cow_start = {
.offset = 0,
.nb_sectors = alloc_n_start,
},
.cow_end = {
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
};
qemu_co_queue_init(&(*m)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight);
*host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset);
*bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, guest_offset));
assert(*bytes != 0);
return 1;
fail:
if (*m && (*m)->nb_clusters > 0) {
QLIST_REMOVE(*m, next_in_flight);
}
return ret;
}
| true | qemu | ecdd5333ab9ed3f2b848066aaaef02c027b25e36 | static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcowState *s = bs->opaque;
int l2_index;
uint64_t *l2_table;
uint64_t entry;
unsigned int nb_clusters;
int ret;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
*bytes);
assert(*bytes > 0);
nb_clusters =
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
l2_index = offset_to_l2_index(s, guest_offset);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
}
entry = be64_to_cpu(l2_table[l2_index]);
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
}
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
return ret;
}
if (nb_clusters == 0) {
*bytes = 0;
return 0;
}
alloc_cluster_offset = start_of_cluster(s, *host_offset);
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
&nb_clusters);
if (ret < 0) {
goto fail;
}
if (nb_clusters == 0) {
*bytes = 0;
return 0;
}
int requested_sectors =
(*bytes + offset_into_cluster(s, guest_offset))
>> BDRV_SECTOR_BITS;
int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int alloc_n_start = offset_into_cluster(s, guest_offset)
>> BDRV_SECTOR_BITS;
int nb_sectors = MIN(requested_sectors, avail_sectors);
QCowL2Meta *old_m = *m;
*m = g_malloc0(sizeof(**m));
**m = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, guest_offset),
.nb_clusters = nb_clusters,
.nb_available = nb_sectors,
.cow_start = {
.offset = 0,
.nb_sectors = alloc_n_start,
},
.cow_end = {
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
};
qemu_co_queue_init(&(*m)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight);
*host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset);
*bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, guest_offset));
assert(*bytes != 0);
return 1;
fail:
if (*m && (*m)->nb_clusters > 0) {
QLIST_REMOVE(*m, next_in_flight);
}
return ret;
}
| {
"code": [
" if (nb_clusters == 0) {",
" *bytes = 0;",
" return 0;"
],
"line_no": [
93,
95,
97
]
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_5;
uint64_t *l2_table;
uint64_t entry;
unsigned int VAR_6;
int VAR_7;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2,
*VAR_3);
assert(*VAR_3 > 0);
VAR_6 =
size_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3);
VAR_5 = offset_to_l2_index(s, VAR_1);
VAR_6 = MIN(VAR_6, s->l2_size - VAR_5);
VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5);
if (VAR_7 < 0) {
return VAR_7;
}
entry = be64_to_cpu(l2_table[VAR_5]);
if (entry & QCOW_OFLAG_COMPRESSED) {
VAR_6 = 1;
} else {
VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5);
}
VAR_7 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void**) &l2_table);
if (VAR_7 < 0) {
return VAR_7;
}
if (VAR_6 == 0) {
*VAR_3 = 0;
return 0;
}
alloc_cluster_offset = start_of_cluster(s, *VAR_2);
VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset,
&VAR_6);
if (VAR_7 < 0) {
goto fail;
}
if (VAR_6 == 0) {
*VAR_3 = 0;
return 0;
}
int VAR_8 =
(*VAR_3 + offset_into_cluster(s, VAR_1))
>> BDRV_SECTOR_BITS;
int VAR_9 = VAR_6
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int VAR_10 = offset_into_cluster(s, VAR_1)
>> BDRV_SECTOR_BITS;
int VAR_11 = MIN(VAR_8, VAR_9);
QCowL2Meta *old_m = *VAR_4;
*VAR_4 = g_malloc0(sizeof(**VAR_4));
**VAR_4 = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, VAR_1),
.VAR_6 = VAR_6,
.nb_available = VAR_11,
.cow_start = {
.offset = 0,
.VAR_11 = VAR_10,
},
.cow_end = {
.offset = VAR_11 * BDRV_SECTOR_SIZE,
.VAR_11 = VAR_9 - VAR_11,
},
};
qemu_co_queue_init(&(*VAR_4)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight);
*VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1);
*VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, VAR_1));
assert(*VAR_3 != 0);
return 1;
fail:
if (*VAR_4 && (*VAR_4)->VAR_6 > 0) {
QLIST_REMOVE(*VAR_4, next_in_flight);
}
return VAR_7;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_5;",
"uint64_t *l2_table;",
"uint64_t entry;",
"unsigned int VAR_6;",
"int VAR_7;",
"uint64_t alloc_cluster_offset;",
"trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2,\n*VAR_3);",
"assert(*VAR_3 > 0);",
"VAR_6 =\nsize_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3);",
"VAR_5 = offset_to_l2_index(s, VAR_1);",
"VAR_6 = MIN(VAR_6, s->l2_size - VAR_5);",
"VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"entry = be64_to_cpu(l2_table[VAR_5]);",
"if (entry & QCOW_OFLAG_COMPRESSED) {",
"VAR_6 = 1;",
"} else {",
"VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5);",
"}",
"VAR_7 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void**) &l2_table);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"if (VAR_6 == 0) {",
"*VAR_3 = 0;",
"return 0;",
"}",
"alloc_cluster_offset = start_of_cluster(s, *VAR_2);",
"VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset,\n&VAR_6);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"if (VAR_6 == 0) {",
"*VAR_3 = 0;",
"return 0;",
"}",
"int VAR_8 =\n(*VAR_3 + offset_into_cluster(s, VAR_1))\n>> BDRV_SECTOR_BITS;",
"int VAR_9 = VAR_6\n<< (s->cluster_bits - BDRV_SECTOR_BITS);",
"int VAR_10 = offset_into_cluster(s, VAR_1)\n>> BDRV_SECTOR_BITS;",
"int VAR_11 = MIN(VAR_8, VAR_9);",
"QCowL2Meta *old_m = *VAR_4;",
"*VAR_4 = g_malloc0(sizeof(**VAR_4));",
"**VAR_4 = (QCowL2Meta) {",
".next = old_m,\n.alloc_offset = alloc_cluster_offset,\n.offset = start_of_cluster(s, VAR_1),\n.VAR_6 = VAR_6,\n.nb_available = VAR_11,\n.cow_start = {",
".offset = 0,\n.VAR_11 = VAR_10,\n},",
".cow_end = {",
".offset = VAR_11 * BDRV_SECTOR_SIZE,\n.VAR_11 = VAR_9 - VAR_11,\n},",
"};",
"qemu_co_queue_init(&(*VAR_4)->dependent_requests);",
"QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight);",
"*VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1);",
"*VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE)\n- offset_into_cluster(s, VAR_1));",
"assert(*VAR_3 != 0);",
"return 1;",
"fail:\nif (*VAR_4 && (*VAR_4)->VAR_6 > 0) {",
"QLIST_REMOVE(*VAR_4, next_in_flight);",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
],
[
41,
43
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
159,
161,
163
],
[
165,
167
],
[
169,
171
],
[
173
],
[
175
],
[
179
],
[
183
],
[
185,
189,
191,
193,
195,
199
],
[
201,
203,
205
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225,
227
],
[
229
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
]
]
|
13,846 | static uint32_t parse_peak(const uint8_t *peak)
{
int64_t val = 0;
int64_t scale = 1;
if (!peak)
return 0;
peak += strspn(peak, " \t");
if (peak[0] == '1' && peak[1] == '.')
return UINT32_MAX;
else if (!(peak[0] == '0' && peak[1] == '.'))
return 0;
peak += 2;
while (av_isdigit(*peak)) {
int digit = *peak - '0';
if (scale > INT64_MAX / 10)
break;
val = 10 * val + digit;
scale *= 10;
peak++;
}
return av_rescale(val, UINT32_MAX, scale);
}
| true | FFmpeg | 8542f9c4f17125d483c40c0c5723842f1c982f81 | static uint32_t parse_peak(const uint8_t *peak)
{
int64_t val = 0;
int64_t scale = 1;
if (!peak)
return 0;
peak += strspn(peak, " \t");
if (peak[0] == '1' && peak[1] == '.')
return UINT32_MAX;
else if (!(peak[0] == '0' && peak[1] == '.'))
return 0;
peak += 2;
while (av_isdigit(*peak)) {
int digit = *peak - '0';
if (scale > INT64_MAX / 10)
break;
val = 10 * val + digit;
scale *= 10;
peak++;
}
return av_rescale(val, UINT32_MAX, scale);
}
| {
"code": [
"static uint32_t parse_peak(const uint8_t *peak)",
" int64_t val = 0;",
" int64_t scale = 1;",
" if (!peak)",
" return 0;",
" peak += strspn(peak, \" \\t\");",
" if (peak[0] == '1' && peak[1] == '.')",
" return UINT32_MAX;",
" else if (!(peak[0] == '0' && peak[1] == '.'))",
" return 0;",
" peak += 2;",
" while (av_isdigit(*peak)) {",
" int digit = *peak - '0';",
" if (scale > INT64_MAX / 10)",
" break;",
" val = 10 * val + digit;",
" scale *= 10;",
" peak++;",
" return av_rescale(val, UINT32_MAX, scale);"
],
"line_no": [
1,
5,
7,
11,
13,
17,
21,
23,
25,
13,
31,
35,
37,
41,
43,
47,
49,
53,
59
]
} | static uint32_t FUNC_0(const uint8_t *peak)
{
int64_t val = 0;
int64_t scale = 1;
if (!peak)
return 0;
peak += strspn(peak, " \t");
if (peak[0] == '1' && peak[1] == '.')
return UINT32_MAX;
else if (!(peak[0] == '0' && peak[1] == '.'))
return 0;
peak += 2;
while (av_isdigit(*peak)) {
int VAR_0 = *peak - '0';
if (scale > INT64_MAX / 10)
break;
val = 10 * val + VAR_0;
scale *= 10;
peak++;
}
return av_rescale(val, UINT32_MAX, scale);
}
| [
"static uint32_t FUNC_0(const uint8_t *peak)\n{",
"int64_t val = 0;",
"int64_t scale = 1;",
"if (!peak)\nreturn 0;",
"peak += strspn(peak, \" \\t\");",
"if (peak[0] == '1' && peak[1] == '.')\nreturn UINT32_MAX;",
"else if (!(peak[0] == '0' && peak[1] == '.'))\nreturn 0;",
"peak += 2;",
"while (av_isdigit(*peak)) {",
"int VAR_0 = *peak - '0';",
"if (scale > INT64_MAX / 10)\nbreak;",
"val = 10 * val + VAR_0;",
"scale *= 10;",
"peak++;",
"}",
"return av_rescale(val, UINT32_MAX, scale);",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
21,
23
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
41,
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
]
]
|
13,847 | void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
const uint8_t *src_data[4], const int src_linesizes[4],
enum AVPixelFormat pix_fmt, int width, int height)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
if (!desc || desc->flags & PIX_FMT_HWACCEL)
if (desc->flags & PIX_FMT_PAL ||
desc->flags & PIX_FMT_PSEUDOPAL) {
av_image_copy_plane(dst_data[0], dst_linesizes[0],
src_data[0], src_linesizes[0],
width, height);
/* copy the palette */
memcpy(dst_data[1], src_data[1], 4*256);
} else {
int i, planes_nb = 0;
for (i = 0; i < desc->nb_components; i++)
planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
for (i = 0; i < planes_nb; i++) {
int h = height;
int bwidth = av_image_get_linesize(pix_fmt, width, i);
if (i == 1 || i == 2) {
h= -((-height)>>desc->log2_chroma_h);
av_image_copy_plane(dst_data[i], dst_linesizes[i],
src_data[i], src_linesizes[i],
bwidth, h);
| true | FFmpeg | adc39b28a5264591b9f8e5838a752c3d547e8110 | void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
const uint8_t *src_data[4], const int src_linesizes[4],
enum AVPixelFormat pix_fmt, int width, int height)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
if (!desc || desc->flags & PIX_FMT_HWACCEL)
if (desc->flags & PIX_FMT_PAL ||
desc->flags & PIX_FMT_PSEUDOPAL) {
av_image_copy_plane(dst_data[0], dst_linesizes[0],
src_data[0], src_linesizes[0],
width, height);
memcpy(dst_data[1], src_data[1], 4*256);
} else {
int i, planes_nb = 0;
for (i = 0; i < desc->nb_components; i++)
planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
for (i = 0; i < planes_nb; i++) {
int h = height;
int bwidth = av_image_get_linesize(pix_fmt, width, i);
if (i == 1 || i == 2) {
h= -((-height)>>desc->log2_chroma_h);
av_image_copy_plane(dst_data[i], dst_linesizes[i],
src_data[i], src_linesizes[i],
bwidth, h);
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],
const uint8_t *VAR_2[4], const int VAR_3[4],
enum AVPixelFormat VAR_4, int VAR_5, int VAR_6)
{
const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_4);
if (!VAR_7 || VAR_7->flags & PIX_FMT_HWACCEL)
if (VAR_7->flags & PIX_FMT_PAL ||
VAR_7->flags & PIX_FMT_PSEUDOPAL) {
av_image_copy_plane(VAR_0[0], VAR_1[0],
VAR_2[0], VAR_3[0],
VAR_5, VAR_6);
memcpy(VAR_0[1], VAR_2[1], 4*256);
} else {
int VAR_8, VAR_9 = 0;
for (VAR_8 = 0; VAR_8 < VAR_7->nb_components; VAR_8++)
VAR_9 = FFMAX(VAR_9, VAR_7->comp[VAR_8].plane + 1);
for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {
int VAR_10 = VAR_6;
int VAR_11 = av_image_get_linesize(VAR_4, VAR_5, VAR_8);
if (VAR_8 == 1 || VAR_8 == 2) {
VAR_10= -((-VAR_6)>>VAR_7->log2_chroma_h);
av_image_copy_plane(VAR_0[VAR_8], VAR_1[VAR_8],
VAR_2[VAR_8], VAR_3[VAR_8],
VAR_11, VAR_10);
| [
"void FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],\nconst uint8_t *VAR_2[4], const int VAR_3[4],\nenum AVPixelFormat VAR_4, int VAR_5, int VAR_6)\n{",
"const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_4);",
"if (!VAR_7 || VAR_7->flags & PIX_FMT_HWACCEL)\nif (VAR_7->flags & PIX_FMT_PAL ||\nVAR_7->flags & PIX_FMT_PSEUDOPAL) {",
"av_image_copy_plane(VAR_0[0], VAR_1[0],\nVAR_2[0], VAR_3[0],\nVAR_5, VAR_6);",
"memcpy(VAR_0[1], VAR_2[1], 4*256);",
"} else {",
"int VAR_8, VAR_9 = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_7->nb_components; VAR_8++)",
"VAR_9 = FFMAX(VAR_9, VAR_7->comp[VAR_8].plane + 1);",
"for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {",
"int VAR_10 = VAR_6;",
"int VAR_11 = av_image_get_linesize(VAR_4, VAR_5, VAR_8);",
"if (VAR_8 == 1 || VAR_8 == 2) {",
"VAR_10= -((-VAR_6)>>VAR_7->log2_chroma_h);",
"av_image_copy_plane(VAR_0[VAR_8], VAR_1[VAR_8],\nVAR_2[VAR_8], VAR_3[VAR_8],\nVAR_11, VAR_10);"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13,
18,
20
],
[
22,
24,
26
],
[
30
],
[
32
],
[
34
],
[
38
],
[
40
],
[
44
],
[
46
],
[
48
],
[
54
],
[
56
],
[
59,
61,
63
]
]
|
13,848 | static void gen_ld (CPUMIPSState *env, DisasContext *ctx, uint32_t opc,
int rt, int base, int16_t offset)
{
const char *opn = "ld";
TCGv t0, t1;
if (rt == 0 && env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
/* Loongson CPU uses a load to zero register for prefetch.
We emulate it as a NOP. On other CPU we must perform the
actual memory access. */
MIPS_DEBUG("NOP");
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(ctx, t0, base, offset);
switch (opc) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld32u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lwu";
break;
case OPC_LD:
tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "ld";
break;
case OPC_LLD:
save_cpu_state(ctx, 1);
op_ld_lld(t0, t0, ctx);
gen_store_gpr(t0, rt);
opn = "lld";
break;
case OPC_LDL:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(ldl, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "ldl";
break;
case OPC_LDR:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(ldr, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "ldr";
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "ldpc";
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lwpc";
break;
case OPC_LW:
tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lw";
break;
case OPC_LH:
tcg_gen_qemu_ld16s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lh";
break;
case OPC_LHU:
tcg_gen_qemu_ld16u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lhu";
break;
case OPC_LB:
tcg_gen_qemu_ld8s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lb";
break;
case OPC_LBU:
tcg_gen_qemu_ld8u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lbu";
break;
case OPC_LWL:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(lwl, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "lwl";
break;
case OPC_LWR:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(lwr, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "lwr";
break;
case OPC_LL:
save_cpu_state(ctx, 1);
op_ld_ll(t0, t0, ctx);
gen_store_gpr(t0, rt);
opn = "ll";
break;
}
(void)opn; /* avoid a compiler warning */
MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]);
tcg_temp_free(t0);
}
| true | qemu | fc40787abcf8452b8f50d92b7a13243a12972c7a | static void gen_ld (CPUMIPSState *env, DisasContext *ctx, uint32_t opc,
int rt, int base, int16_t offset)
{
const char *opn = "ld";
TCGv t0, t1;
if (rt == 0 && env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
MIPS_DEBUG("NOP");
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(ctx, t0, base, offset);
switch (opc) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld32u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lwu";
break;
case OPC_LD:
tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "ld";
break;
case OPC_LLD:
save_cpu_state(ctx, 1);
op_ld_lld(t0, t0, ctx);
gen_store_gpr(t0, rt);
opn = "lld";
break;
case OPC_LDL:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(ldl, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "ldl";
break;
case OPC_LDR:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(ldr, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "ldr";
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "ldpc";
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lwpc";
break;
case OPC_LW:
tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lw";
break;
case OPC_LH:
tcg_gen_qemu_ld16s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lh";
break;
case OPC_LHU:
tcg_gen_qemu_ld16u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lhu";
break;
case OPC_LB:
tcg_gen_qemu_ld8s(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lb";
break;
case OPC_LBU:
tcg_gen_qemu_ld8u(t0, t0, ctx->mem_idx);
gen_store_gpr(t0, rt);
opn = "lbu";
break;
case OPC_LWL:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(lwl, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "lwl";
break;
case OPC_LWR:
save_cpu_state(ctx, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, rt);
gen_helper_1e2i(lwr, t1, t1, t0, ctx->mem_idx);
gen_store_gpr(t1, rt);
tcg_temp_free(t1);
opn = "lwr";
break;
case OPC_LL:
save_cpu_state(ctx, 1);
op_ld_ll(t0, t0, ctx);
gen_store_gpr(t0, rt);
opn = "ll";
break;
}
(void)opn;
MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]);
tcg_temp_free(t0);
}
| {
"code": [
" TCGv t0, t1;",
" save_cpu_state(ctx, 1);",
" gen_helper_1e2i(ldl, t1, t1, t0, ctx->mem_idx);",
" gen_store_gpr(t1, rt);",
" save_cpu_state(ctx, 1);",
" gen_helper_1e2i(ldr, t1, t1, t0, ctx->mem_idx);",
" gen_store_gpr(t1, rt);",
" save_cpu_state(ctx, 1);",
" gen_helper_1e2i(lwl, t1, t1, t0, ctx->mem_idx);",
" gen_store_gpr(t1, rt);",
" save_cpu_state(ctx, 1);",
" gen_helper_1e2i(lwr, t1, t1, t0, ctx->mem_idx);",
" gen_store_gpr(t1, rt);"
],
"line_no": [
9,
61,
79,
81,
61,
97,
81,
61,
199,
81,
61,
217,
81
]
} | static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2,
int VAR_3, int VAR_4, int16_t VAR_5)
{
const char *VAR_6 = "ld";
TCGv t0, t1;
if (VAR_3 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
MIPS_DEBUG("NOP");
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(VAR_1, t0, VAR_4, VAR_5);
switch (VAR_2) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld32u(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lwu";
break;
case OPC_LD:
tcg_gen_qemu_ld64(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "ld";
break;
case OPC_LLD:
save_cpu_state(VAR_1, 1);
op_ld_lld(t0, t0, VAR_1);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lld";
break;
case OPC_LDL:
save_cpu_state(VAR_1, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, VAR_3);
gen_helper_1e2i(ldl, t1, t1, t0, VAR_1->mem_idx);
gen_store_gpr(t1, VAR_3);
tcg_temp_free(t1);
VAR_6 = "ldl";
break;
case OPC_LDR:
save_cpu_state(VAR_1, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, VAR_3);
gen_helper_1e2i(ldr, t1, t1, t0, VAR_1->mem_idx);
gen_store_gpr(t1, VAR_3);
tcg_temp_free(t1);
VAR_6 = "ldr";
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(VAR_1));
gen_op_addr_add(VAR_1, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld64(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "ldpc";
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(VAR_1));
gen_op_addr_add(VAR_1, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld32s(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lwpc";
break;
case OPC_LW:
tcg_gen_qemu_ld32s(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lw";
break;
case OPC_LH:
tcg_gen_qemu_ld16s(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lh";
break;
case OPC_LHU:
tcg_gen_qemu_ld16u(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lhu";
break;
case OPC_LB:
tcg_gen_qemu_ld8s(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lb";
break;
case OPC_LBU:
tcg_gen_qemu_ld8u(t0, t0, VAR_1->mem_idx);
gen_store_gpr(t0, VAR_3);
VAR_6 = "lbu";
break;
case OPC_LWL:
save_cpu_state(VAR_1, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, VAR_3);
gen_helper_1e2i(lwl, t1, t1, t0, VAR_1->mem_idx);
gen_store_gpr(t1, VAR_3);
tcg_temp_free(t1);
VAR_6 = "lwl";
break;
case OPC_LWR:
save_cpu_state(VAR_1, 1);
t1 = tcg_temp_new();
gen_load_gpr(t1, VAR_3);
gen_helper_1e2i(lwr, t1, t1, t0, VAR_1->mem_idx);
gen_store_gpr(t1, VAR_3);
tcg_temp_free(t1);
VAR_6 = "lwr";
break;
case OPC_LL:
save_cpu_state(VAR_1, 1);
op_ld_ll(t0, t0, VAR_1);
gen_store_gpr(t0, VAR_3);
VAR_6 = "ll";
break;
}
(void)VAR_6;
MIPS_DEBUG("%s %s, %d(%s)", VAR_6, regnames[VAR_3], VAR_5, regnames[VAR_4]);
tcg_temp_free(t0);
}
| [
"static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2,\nint VAR_3, int VAR_4, int16_t VAR_5)\n{",
"const char *VAR_6 = \"ld\";",
"TCGv t0, t1;",
"if (VAR_3 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {",
"MIPS_DEBUG(\"NOP\");",
"return;",
"}",
"t0 = tcg_temp_new();",
"gen_base_offset_addr(VAR_1, t0, VAR_4, VAR_5);",
"switch (VAR_2) {",
"#if defined(TARGET_MIPS64)\ncase OPC_LWU:\ntcg_gen_qemu_ld32u(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lwu\";",
"break;",
"case OPC_LD:\ntcg_gen_qemu_ld64(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"ld\";",
"break;",
"case OPC_LLD:\nsave_cpu_state(VAR_1, 1);",
"op_ld_lld(t0, t0, VAR_1);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lld\";",
"break;",
"case OPC_LDL:\nsave_cpu_state(VAR_1, 1);",
"t1 = tcg_temp_new();",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_1e2i(ldl, t1, t1, t0, VAR_1->mem_idx);",
"gen_store_gpr(t1, VAR_3);",
"tcg_temp_free(t1);",
"VAR_6 = \"ldl\";",
"break;",
"case OPC_LDR:\nsave_cpu_state(VAR_1, 1);",
"t1 = tcg_temp_new();",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_1e2i(ldr, t1, t1, t0, VAR_1->mem_idx);",
"gen_store_gpr(t1, VAR_3);",
"tcg_temp_free(t1);",
"VAR_6 = \"ldr\";",
"break;",
"case OPC_LDPC:\nt1 = tcg_const_tl(pc_relative_pc(VAR_1));",
"gen_op_addr_add(VAR_1, t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_qemu_ld64(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"ldpc\";",
"break;",
"#endif\ncase OPC_LWPC:\nt1 = tcg_const_tl(pc_relative_pc(VAR_1));",
"gen_op_addr_add(VAR_1, t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_qemu_ld32s(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lwpc\";",
"break;",
"case OPC_LW:\ntcg_gen_qemu_ld32s(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lw\";",
"break;",
"case OPC_LH:\ntcg_gen_qemu_ld16s(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lh\";",
"break;",
"case OPC_LHU:\ntcg_gen_qemu_ld16u(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lhu\";",
"break;",
"case OPC_LB:\ntcg_gen_qemu_ld8s(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lb\";",
"break;",
"case OPC_LBU:\ntcg_gen_qemu_ld8u(t0, t0, VAR_1->mem_idx);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"lbu\";",
"break;",
"case OPC_LWL:\nsave_cpu_state(VAR_1, 1);",
"t1 = tcg_temp_new();",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_1e2i(lwl, t1, t1, t0, VAR_1->mem_idx);",
"gen_store_gpr(t1, VAR_3);",
"tcg_temp_free(t1);",
"VAR_6 = \"lwl\";",
"break;",
"case OPC_LWR:\nsave_cpu_state(VAR_1, 1);",
"t1 = tcg_temp_new();",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_1e2i(lwr, t1, t1, t0, VAR_1->mem_idx);",
"gen_store_gpr(t1, VAR_3);",
"tcg_temp_free(t1);",
"VAR_6 = \"lwr\";",
"break;",
"case OPC_LL:\nsave_cpu_state(VAR_1, 1);",
"op_ld_ll(t0, t0, VAR_1);",
"gen_store_gpr(t0, VAR_3);",
"VAR_6 = \"ll\";",
"break;",
"}",
"(void)VAR_6;",
"MIPS_DEBUG(\"%s %s, %d(%s)\", VAR_6, regnames[VAR_3], VAR_5, regnames[VAR_4]);",
"tcg_temp_free(t0);",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
13
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
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
]
]
|
13,849 | static void gxf_read_index(AVFormatContext *s, int pkt_len) {
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
uint32_t fields_per_map = avio_rl32(pb);
uint32_t map_cnt = avio_rl32(pb);
int i;
pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) {
avio_skip(pb, pkt_len);
return;
}
if (map_cnt > 1000) {
av_log(s, AV_LOG_ERROR, "too many index entries %u (%x)\n", map_cnt, map_cnt);
map_cnt = 1000;
}
if (pkt_len < 4 * map_cnt) {
av_log(s, AV_LOG_ERROR, "invalid index length\n");
avio_skip(pb, pkt_len);
return;
}
pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++)
av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
i * (uint64_t)fields_per_map + 1, 0, 0, 0);
avio_skip(pb, pkt_len);
}
| true | FFmpeg | 5aedee4facb2295cfdeaf322bc67fd15323862d9 | static void gxf_read_index(AVFormatContext *s, int pkt_len) {
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
uint32_t fields_per_map = avio_rl32(pb);
uint32_t map_cnt = avio_rl32(pb);
int i;
pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) {
avio_skip(pb, pkt_len);
return;
}
if (map_cnt > 1000) {
av_log(s, AV_LOG_ERROR, "too many index entries %u (%x)\n", map_cnt, map_cnt);
map_cnt = 1000;
}
if (pkt_len < 4 * map_cnt) {
av_log(s, AV_LOG_ERROR, "invalid index length\n");
avio_skip(pb, pkt_len);
return;
}
pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++)
av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
i * (uint64_t)fields_per_map + 1, 0, 0, 0);
avio_skip(pb, pkt_len);
}
| {
"code": [
" AVStream *st = s->streams[0];",
" if (s->flags & AVFMT_FLAG_IGNIDX) {"
],
"line_no": [
5,
15
]
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1) {
AVIOContext *pb = VAR_0->pb;
AVStream *st = VAR_0->streams[0];
uint32_t fields_per_map = avio_rl32(pb);
uint32_t map_cnt = avio_rl32(pb);
int VAR_2;
VAR_1 -= 8;
if (VAR_0->flags & AVFMT_FLAG_IGNIDX) {
avio_skip(pb, VAR_1);
return;
}
if (map_cnt > 1000) {
av_log(VAR_0, AV_LOG_ERROR, "too many index entries %u (%x)\n", map_cnt, map_cnt);
map_cnt = 1000;
}
if (VAR_1 < 4 * map_cnt) {
av_log(VAR_0, AV_LOG_ERROR, "invalid index length\n");
avio_skip(pb, VAR_1);
return;
}
VAR_1 -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (VAR_2 = 0; VAR_2 < map_cnt; VAR_2++)
av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
VAR_2 * (uint64_t)fields_per_map + 1, 0, 0, 0);
avio_skip(pb, VAR_1);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1) {",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *st = VAR_0->streams[0];",
"uint32_t fields_per_map = avio_rl32(pb);",
"uint32_t map_cnt = avio_rl32(pb);",
"int VAR_2;",
"VAR_1 -= 8;",
"if (VAR_0->flags & AVFMT_FLAG_IGNIDX) {",
"avio_skip(pb, VAR_1);",
"return;",
"}",
"if (map_cnt > 1000) {",
"av_log(VAR_0, AV_LOG_ERROR, \"too many index entries %u (%x)\\n\", map_cnt, map_cnt);",
"map_cnt = 1000;",
"}",
"if (VAR_1 < 4 * map_cnt) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid index length\\n\");",
"avio_skip(pb, VAR_1);",
"return;",
"}",
"VAR_1 -= 4 * map_cnt;",
"av_add_index_entry(st, 0, 0, 0, 0, 0);",
"for (VAR_2 = 0; VAR_2 < map_cnt; VAR_2++)",
"av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,\nVAR_2 * (uint64_t)fields_per_map + 1, 0, 0, 0);",
"avio_skip(pb, VAR_1);",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
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
]
]
|
13,850 | static void draw_char(AVCodecContext *avctx, int c, int a)
{
XbinContext *s = avctx->priv_data;
if (s->y > avctx->height - s->font_height)
return;
ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
s->frame.linesize[0], s->font, s->font_height, c,
a & 0x0F, a >> 4);
s->x += FONT_WIDTH;
if (s->x >= avctx->width) {
s->x = 0;
s->y += s->font_height;
}
}
| true | FFmpeg | b9dbaa409f51545a840929665fa0303b46e7e8a5 | static void draw_char(AVCodecContext *avctx, int c, int a)
{
XbinContext *s = avctx->priv_data;
if (s->y > avctx->height - s->font_height)
return;
ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
s->frame.linesize[0], s->font, s->font_height, c,
a & 0x0F, a >> 4);
s->x += FONT_WIDTH;
if (s->x >= avctx->width) {
s->x = 0;
s->y += s->font_height;
}
}
| {
"code": [
" if (s->x >= avctx->width) {"
],
"line_no": [
19
]
} | static void FUNC_0(AVCodecContext *VAR_0, int VAR_1, int VAR_2)
{
XbinContext *s = VAR_0->priv_data;
if (s->y > VAR_0->height - s->font_height)
return;
ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
s->frame.linesize[0], s->font, s->font_height, VAR_1,
VAR_2 & 0x0F, VAR_2 >> 4);
s->x += FONT_WIDTH;
if (s->x >= VAR_0->width) {
s->x = 0;
s->y += s->font_height;
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, int VAR_1, int VAR_2)\n{",
"XbinContext *s = VAR_0->priv_data;",
"if (s->y > VAR_0->height - s->font_height)\nreturn;",
"ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,\ns->frame.linesize[0], s->font, s->font_height, VAR_1,\nVAR_2 & 0x0F, VAR_2 >> 4);",
"s->x += FONT_WIDTH;",
"if (s->x >= VAR_0->width) {",
"s->x = 0;",
"s->y += s->font_height;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
13,851 | static int xwma_read_header(AVFormatContext *s)
{
int64_t size;
int ret;
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = 0;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
XWMAContext *xwma = s->priv_data;
int i;
/* The following code is mostly copied from wav.c, with some
* minor alterations.
*/
/* check RIFF header */
tag = avio_rl32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb); /* file size */
tag = avio_rl32(pb);
if (tag != MKTAG('X', 'W', 'M', 'A'))
return -1;
/* parse fmt header */
tag = avio_rl32(pb);
if (tag != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
ret = ff_get_wav_header(pb, st->codec, size);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
/* All xWMA files I have seen contained WMAv2 data. If there are files
* using WMA Pro or some other codec, then we need to figure out the right
* extradata for that. Thus, ask the user for feedback, but try to go on
* anyway.
*/
if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {
av_log(s, AV_LOG_WARNING, "unexpected codec (tag 0x04%x; id %d)\n",
st->codec->codec_tag, st->codec->codec_id);
av_log_ask_for_sample(s, NULL);
} else {
/* In all xWMA files I have seen, there is no extradata. But the WMA
* codecs require extradata, so we provide our own fake extradata.
*
* First, check that there really was no extradata in the header. If
* there was, then try to use it, after asking the user to provide a
* sample of this unusual file.
*/
if (st->codec->extradata_size != 0) {
/* Surprise, surprise: We *did* get some extradata. No idea
* if it will work, but just go on and try it, after asking
* the user for a sample.
*/
av_log(s, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n",
st->codec->extradata_size);
av_log_ask_for_sample(s, NULL);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
/* setup extradata with our experimentally obtained value */
st->codec->extradata[4] = 31;
if (!st->codec->channels) {
av_log(s, AV_LOG_WARNING, "Invalid channel count: %d\n",
st->codec->channels);
if (!st->codec->bits_per_coded_sample) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codec->bits_per_coded_sample);
/* set the sample rate */
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
/* parse the remaining RIFF chunks */
for (;;) {
if (pb->eof_reached)
return -1;
/* read next chunk tag */
tag = avio_rl32(pb);
size = avio_rl32(pb);
if (tag == MKTAG('d', 'a', 't', 'a')) {
/* We assume that the data chunk comes last. */
break;
} else if (tag == MKTAG('d','p','d','s')) {
/* Quoting the MSDN xWMA docs on the dpds chunk: "Contains the
* decoded packet cumulative data size array, each element is the
* number of bytes accumulated after the corresponding xWMA packet
* is decoded in order."
*
* Each packet has size equal to st->codec->block_align, which in
* all cases I saw so far was always 2230. Thus, we can use the
* dpds data to compute a seeking index.
*/
/* Error out if there is more than one dpds chunk. */
if (dpds_table) {
av_log(s, AV_LOG_ERROR, "two dpds chunks present\n");
return -1;
/* Compute the number of entries in the dpds chunk. */
if (size & 3) { /* Size should be divisible by four */
av_log(s, AV_LOG_WARNING,
"dpds chunk size %"PRId64" not divisible by 4\n", size);
dpds_table_size = size / 4;
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(s, AV_LOG_ERROR,
"dpds chunk size %"PRId64" invalid\n", size);
return -1;
/* Allocate some temporary storage to keep the dpds data around.
* for processing later on.
*/
dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
for (i = 0; i < dpds_table_size; ++i) {
dpds_table[i] = avio_rl32(pb);
size -= 4;
avio_skip(pb, size);
/* Determine overall data length */
if (size < 0)
return -1;
if (!size) {
xwma->data_end = INT64_MAX;
} else
xwma->data_end = avio_tell(pb) + size;
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
/* Estimate the duration from the total number of output bytes. */
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
st->duration = total_decoded_bytes / bytes_per_sample;
/* Use the dpds data to build a seek table. We can only do this after
* we know the offset to the data chunk, as we need that to determine
* the actual offset to each input block.
* Note: If we allowed ourselves to assume that the data chunk always
* follows immediately after the dpds block, we could of course guess
* the data block's start offset already while reading the dpds chunk.
* I decided against that, just in case other chunks ever are
* discovered.
*/
cur_pos = avio_tell(pb);
for (i = 0; i < dpds_table_size; ++i) {
/* From the number of output bytes that would accumulate in the
* output buffer after decoding the first (i+1) packets, we compute
* an offset / timestamp pair.
*/
av_add_index_entry(st,
cur_pos + (i+1) * st->codec->block_align, /* pos */
dpds_table[i] / bytes_per_sample, /* timestamp */
st->codec->block_align, /* size */
0, /* duration */
AVINDEX_KEYFRAME);
} else if (st->codec->bit_rate) {
/* No dpds chunk was present (or only an empty one), so estimate
* the total duration using the average bits per sample and the
* total data length.
*/
st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
av_free(dpds_table);
return 0; | true | FFmpeg | a3cb7f992f88fcfa524bd9cd08b28e09d6718f75 | static int xwma_read_header(AVFormatContext *s)
{
int64_t size;
int ret;
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = 0;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
XWMAContext *xwma = s->priv_data;
int i;
tag = avio_rl32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('X', 'W', 'M', 'A'))
return -1;
tag = avio_rl32(pb);
if (tag != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
ret = ff_get_wav_header(pb, st->codec, size);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {
av_log(s, AV_LOG_WARNING, "unexpected codec (tag 0x04%x; id %d)\n",
st->codec->codec_tag, st->codec->codec_id);
av_log_ask_for_sample(s, NULL);
} else {
if (st->codec->extradata_size != 0) {
av_log(s, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n",
st->codec->extradata_size);
av_log_ask_for_sample(s, NULL);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata[4] = 31;
if (!st->codec->channels) {
av_log(s, AV_LOG_WARNING, "Invalid channel count: %d\n",
st->codec->channels);
if (!st->codec->bits_per_coded_sample) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codec->bits_per_coded_sample);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
for (;;) {
if (pb->eof_reached)
return -1;
tag = avio_rl32(pb);
size = avio_rl32(pb);
if (tag == MKTAG('d', 'a', 't', 'a')) {
break;
} else if (tag == MKTAG('d','p','d','s')) {
if (dpds_table) {
av_log(s, AV_LOG_ERROR, "two dpds chunks present\n");
return -1;
if (size & 3) {
av_log(s, AV_LOG_WARNING,
"dpds chunk size %"PRId64" not divisible by 4\n", size);
dpds_table_size = size / 4;
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(s, AV_LOG_ERROR,
"dpds chunk size %"PRId64" invalid\n", size);
return -1;
dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
for (i = 0; i < dpds_table_size; ++i) {
dpds_table[i] = avio_rl32(pb);
size -= 4;
avio_skip(pb, size);
if (size < 0)
return -1;
if (!size) {
xwma->data_end = INT64_MAX;
} else
xwma->data_end = avio_tell(pb) + size;
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
st->duration = total_decoded_bytes / bytes_per_sample;
cur_pos = avio_tell(pb);
for (i = 0; i < dpds_table_size; ++i) {
av_add_index_entry(st,
cur_pos + (i+1) * st->codec->block_align,
dpds_table[i] / bytes_per_sample,
st->codec->block_align,
0,
AVINDEX_KEYFRAME);
} else if (st->codec->bit_rate) {
st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
av_free(dpds_table);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
int64_t size;
int VAR_1;
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = 0;
unsigned int VAR_2;
AVIOContext *pb = VAR_0->pb;
AVStream *st;
XWMAContext *xwma = VAR_0->priv_data;
int VAR_3;
VAR_2 = avio_rl32(pb);
if (VAR_2 != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb);
VAR_2 = avio_rl32(pb);
if (VAR_2 != MKTAG('X', 'W', 'M', 'A'))
return -1;
VAR_2 = avio_rl32(pb);
if (VAR_2 != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
VAR_1 = ff_get_wav_header(pb, st->codec, size);
if (VAR_1 < 0)
return VAR_1;
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {
av_log(VAR_0, AV_LOG_WARNING, "unexpected codec (VAR_2 0x04%x; id %d)\n",
st->codec->codec_tag, st->codec->codec_id);
av_log_ask_for_sample(VAR_0, NULL);
} else {
if (st->codec->extradata_size != 0) {
av_log(VAR_0, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n",
st->codec->extradata_size);
av_log_ask_for_sample(VAR_0, NULL);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata[4] = 31;
if (!st->codec->channels) {
av_log(VAR_0, AV_LOG_WARNING, "Invalid channel count: %d\n",
st->codec->channels);
if (!st->codec->bits_per_coded_sample) {
av_log(VAR_0, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codec->bits_per_coded_sample);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
for (;;) {
if (pb->eof_reached)
return -1;
VAR_2 = avio_rl32(pb);
size = avio_rl32(pb);
if (VAR_2 == MKTAG('d', 'a', 't', 'a')) {
break;
} else if (VAR_2 == MKTAG('d','p','d','VAR_0')) {
if (dpds_table) {
av_log(VAR_0, AV_LOG_ERROR, "two dpds chunks present\n");
return -1;
if (size & 3) {
av_log(VAR_0, AV_LOG_WARNING,
"dpds chunk size %"PRId64" not divisible by 4\n", size);
dpds_table_size = size / 4;
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(VAR_0, AV_LOG_ERROR,
"dpds chunk size %"PRId64" invalid\n", size);
return -1;
dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
for (VAR_3 = 0; VAR_3 < dpds_table_size; ++VAR_3) {
dpds_table[VAR_3] = avio_rl32(pb);
size -= 4;
avio_skip(pb, size);
if (size < 0)
return -1;
if (!size) {
xwma->data_end = INT64_MAX;
} else
xwma->data_end = avio_tell(pb) + size;
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
st->duration = total_decoded_bytes / bytes_per_sample;
cur_pos = avio_tell(pb);
for (VAR_3 = 0; VAR_3 < dpds_table_size; ++VAR_3) {
av_add_index_entry(st,
cur_pos + (VAR_3+1) * st->codec->block_align,
dpds_table[VAR_3] / bytes_per_sample,
st->codec->block_align,
0,
AVINDEX_KEYFRAME);
} else if (st->codec->bit_rate) {
st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
av_free(dpds_table);
return 0; | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"int64_t size;",
"int VAR_1;",
"uint32_t dpds_table_size = 0;",
"uint32_t *dpds_table = 0;",
"unsigned int VAR_2;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *st;",
"XWMAContext *xwma = VAR_0->priv_data;",
"int VAR_3;",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 != MKTAG('R', 'I', 'F', 'F'))\nreturn -1;",
"avio_rl32(pb);",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 != MKTAG('X', 'W', 'M', 'A'))\nreturn -1;",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 != MKTAG('f', 'm', 't', ' '))\nreturn -1;",
"size = avio_rl32(pb);",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"VAR_1 = ff_get_wav_header(pb, st->codec, size);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"st->need_parsing = AVSTREAM_PARSE_NONE;",
"if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {",
"av_log(VAR_0, AV_LOG_WARNING, \"unexpected codec (VAR_2 0x04%x; id %d)\\n\",",
"st->codec->codec_tag, st->codec->codec_id);",
"av_log_ask_for_sample(VAR_0, NULL);",
"} else {",
"if (st->codec->extradata_size != 0) {",
"av_log(VAR_0, AV_LOG_WARNING, \"unexpected extradata (%d bytes)\\n\",\nst->codec->extradata_size);",
"av_log_ask_for_sample(VAR_0, NULL);",
"} else {",
"st->codec->extradata_size = 6;",
"st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!st->codec->extradata)\nreturn AVERROR(ENOMEM);",
"st->codec->extradata[4] = 31;",
"if (!st->codec->channels) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Invalid channel count: %d\\n\",\nst->codec->channels);",
"if (!st->codec->bits_per_coded_sample) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Invalid bits_per_coded_sample: %d\\n\",\nst->codec->bits_per_coded_sample);",
"avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);",
"for (;;) {",
"if (pb->eof_reached)\nreturn -1;",
"VAR_2 = avio_rl32(pb);",
"size = avio_rl32(pb);",
"if (VAR_2 == MKTAG('d', 'a', 't', 'a')) {",
"break;",
"} else if (VAR_2 == MKTAG('d','p','d','VAR_0')) {",
"if (dpds_table) {",
"av_log(VAR_0, AV_LOG_ERROR, \"two dpds chunks present\\n\");",
"return -1;",
"if (size & 3) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"dpds chunk size %\"PRId64\" not divisible by 4\\n\", size);",
"dpds_table_size = size / 4;",
"if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"dpds chunk size %\"PRId64\" invalid\\n\", size);",
"return -1;",
"dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));",
"if (!dpds_table) {",
"return AVERROR(ENOMEM);",
"for (VAR_3 = 0; VAR_3 < dpds_table_size; ++VAR_3) {",
"dpds_table[VAR_3] = avio_rl32(pb);",
"size -= 4;",
"avio_skip(pb, size);",
"if (size < 0)\nreturn -1;",
"if (!size) {",
"xwma->data_end = INT64_MAX;",
"} else",
"xwma->data_end = avio_tell(pb) + size;",
"if (dpds_table && dpds_table_size) {",
"int64_t cur_pos;",
"const uint32_t bytes_per_sample\n= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;",
"const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];",
"st->duration = total_decoded_bytes / bytes_per_sample;",
"cur_pos = avio_tell(pb);",
"for (VAR_3 = 0; VAR_3 < dpds_table_size; ++VAR_3) {",
"av_add_index_entry(st,\ncur_pos + (VAR_3+1) * st->codec->block_align,\ndpds_table[VAR_3] / bytes_per_sample,\nst->codec->block_align,\n0,\nAVINDEX_KEYFRAME);",
"} else if (st->codec->bit_rate) {",
"st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;",
"av_free(dpds_table);",
"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
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
16
],
[
17,
18
],
[
19
],
[
20
],
[
21,
22
],
[
24
],
[
25,
26
],
[
27
],
[
28
],
[
29,
30
],
[
31
],
[
32,
33
],
[
34
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
52
],
[
57,
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63,
64
],
[
66
],
[
67
],
[
68,
69
],
[
70
],
[
71,
72
],
[
74
],
[
76
],
[
77,
78
],
[
80
],
[
81
],
[
82
],
[
84
],
[
85
],
[
96
],
[
97
],
[
98
],
[
100
],
[
101,
102
],
[
103
],
[
104
],
[
105,
106
],
[
107
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
119,
120
],
[
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127,
128
],
[
130
],
[
131
],
[
141
],
[
142
],
[
147,
148,
149,
150,
151,
152
],
[
153
],
[
158
],
[
159
],
[
160
]
]
|
13,852 | static int openfile(char *name, int flags, int growable, QDict *opts)
{
Error *local_err = NULL;
if (qemuio_bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
if (growable) {
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags | BDRV_O_PROTOCOL,
NULL, &local_err))
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
return 1;
}
} else {
qemuio_bs = bdrv_new("hda", &error_abort);
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags, NULL, &local_err)
< 0)
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
bdrv_unref(qemuio_bs);
qemuio_bs = NULL;
return 1;
}
}
return 0;
} | true | qemu | 29f2601aa605f0af0cba8eedcff7812c6c8532e9 | static int openfile(char *name, int flags, int growable, QDict *opts)
{
Error *local_err = NULL;
if (qemuio_bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
if (growable) {
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags | BDRV_O_PROTOCOL,
NULL, &local_err))
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
return 1;
}
} else {
qemuio_bs = bdrv_new("hda", &error_abort);
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags, NULL, &local_err)
< 0)
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
bdrv_unref(qemuio_bs);
qemuio_bs = NULL;
return 1;
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(char *VAR_0, int VAR_1, int VAR_2, QDict *VAR_3)
{
Error *local_err = NULL;
if (qemuio_bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
if (VAR_2) {
if (bdrv_open(&qemuio_bs, VAR_0, NULL, VAR_3, VAR_1 | BDRV_O_PROTOCOL,
NULL, &local_err))
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, VAR_0,
error_get_pretty(local_err));
error_free(local_err);
return 1;
}
} else {
qemuio_bs = bdrv_new("hda", &error_abort);
if (bdrv_open(&qemuio_bs, VAR_0, NULL, VAR_3, VAR_1, NULL, &local_err)
< 0)
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, VAR_0,
error_get_pretty(local_err));
error_free(local_err);
bdrv_unref(qemuio_bs);
qemuio_bs = NULL;
return 1;
}
}
return 0;
} | [
"static int FUNC_0(char *VAR_0, int VAR_1, int VAR_2, QDict *VAR_3)\n{",
"Error *local_err = NULL;",
"if (qemuio_bs) {",
"fprintf(stderr, \"file open already, try 'help close'\\n\");",
"return 1;",
"}",
"if (VAR_2) {",
"if (bdrv_open(&qemuio_bs, VAR_0, NULL, VAR_3, VAR_1 | BDRV_O_PROTOCOL,\nNULL, &local_err))\n{",
"fprintf(stderr, \"%s: can't open device %s: %s\\n\", progname, VAR_0,\nerror_get_pretty(local_err));",
"error_free(local_err);",
"return 1;",
"}",
"} else {",
"qemuio_bs = bdrv_new(\"hda\", &error_abort);",
"if (bdrv_open(&qemuio_bs, VAR_0, NULL, VAR_3, VAR_1, NULL, &local_err)\n< 0)\n{",
"fprintf(stderr, \"%s: can't open device %s: %s\\n\", progname, VAR_0,\nerror_get_pretty(local_err));",
"error_free(local_err);",
"bdrv_unref(qemuio_bs);",
"qemuio_bs = NULL;",
"return 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
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
14
],
[
16
],
[
20
],
[
22,
24,
26
],
[
28,
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
44,
46,
48
],
[
50,
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
68
],
[
70
]
]
|
13,853 | static int cirrus_bitblt_videotovideo_copy(CirrusVGAState * s)
{
if (blit_is_unsafe(s))
return 0;
return cirrus_do_copy(s, s->cirrus_blt_dstaddr - s->vga.start_addr,
s->cirrus_blt_srcaddr - s->vga.start_addr,
s->cirrus_blt_width, s->cirrus_blt_height);
}
| true | qemu | 913a87885f589d263e682c2eb6637c6e14538061 | static int cirrus_bitblt_videotovideo_copy(CirrusVGAState * s)
{
if (blit_is_unsafe(s))
return 0;
return cirrus_do_copy(s, s->cirrus_blt_dstaddr - s->vga.start_addr,
s->cirrus_blt_srcaddr - s->vga.start_addr,
s->cirrus_blt_width, s->cirrus_blt_height);
}
| {
"code": [
" if (blit_is_unsafe(s))",
" if (blit_is_unsafe(s))"
],
"line_no": [
5,
5
]
} | static int FUNC_0(CirrusVGAState * VAR_0)
{
if (blit_is_unsafe(VAR_0))
return 0;
return cirrus_do_copy(VAR_0, VAR_0->cirrus_blt_dstaddr - VAR_0->vga.start_addr,
VAR_0->cirrus_blt_srcaddr - VAR_0->vga.start_addr,
VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);
}
| [
"static int FUNC_0(CirrusVGAState * VAR_0)\n{",
"if (blit_is_unsafe(VAR_0))\nreturn 0;",
"return cirrus_do_copy(VAR_0, VAR_0->cirrus_blt_dstaddr - VAR_0->vga.start_addr,\nVAR_0->cirrus_blt_srcaddr - VAR_0->vga.start_addr,\nVAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);",
"}"
]
| [
0,
1,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
11,
13,
15
],
[
17
]
]
|
13,854 | static void vpb_sic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = vpb_sic_init;
dc->no_user = 1;
dc->vmsd = &vmstate_vpb_sic;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void vpb_sic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = vpb_sic_init;
dc->no_user = 1;
dc->vmsd = &vmstate_vpb_sic;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0);
k->init = vpb_sic_init;
dc->no_user = 1;
dc->vmsd = &vmstate_vpb_sic;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0);",
"k->init = vpb_sic_init;",
"dc->no_user = 1;",
"dc->vmsd = &vmstate_vpb_sic;",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
13,856 | static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame,
NvencSurface *nvenc_frame)
{
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
int res;
NVENCSTATUS nv_status;
if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) {
int reg_idx = nvenc_register_frame(avctx, frame);
if (reg_idx < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not register an input HW frame\n");
return reg_idx;
}
res = av_frame_ref(nvenc_frame->in_ref, frame);
if (res < 0)
return res;
nvenc_frame->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER;
nvenc_frame->in_map.registeredResource = ctx->registered_frames[reg_idx].regptr;
nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &nvenc_frame->in_map);
if (nv_status != NV_ENC_SUCCESS) {
av_frame_unref(nvenc_frame->in_ref);
return nvenc_print_error(avctx, nv_status, "Error mapping an input resource");
}
ctx->registered_frames[reg_idx].mapped = 1;
nvenc_frame->reg_idx = reg_idx;
nvenc_frame->input_surface = nvenc_frame->in_map.mappedResource;
nvenc_frame->format = nvenc_frame->in_map.mappedBufferFmt;
nvenc_frame->pitch = frame->linesize[0];
return 0;
} else {
NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 };
lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER;
lockBufferParams.inputBuffer = nvenc_frame->input_surface;
nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(avctx, nv_status, "Failed locking nvenc input buffer");
}
nvenc_frame->pitch = lockBufferParams.pitch;
res = nvenc_copy_frame(avctx, nvenc_frame, &lockBufferParams, frame);
nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, nvenc_frame->input_surface);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(avctx, nv_status, "Failed unlocking input buffer!");
}
return res;
}
}
| true | FFmpeg | bbe1b21022e4872bc64066d46a4567dc1b655f7a | static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame,
NvencSurface *nvenc_frame)
{
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
int res;
NVENCSTATUS nv_status;
if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) {
int reg_idx = nvenc_register_frame(avctx, frame);
if (reg_idx < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not register an input HW frame\n");
return reg_idx;
}
res = av_frame_ref(nvenc_frame->in_ref, frame);
if (res < 0)
return res;
nvenc_frame->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER;
nvenc_frame->in_map.registeredResource = ctx->registered_frames[reg_idx].regptr;
nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &nvenc_frame->in_map);
if (nv_status != NV_ENC_SUCCESS) {
av_frame_unref(nvenc_frame->in_ref);
return nvenc_print_error(avctx, nv_status, "Error mapping an input resource");
}
ctx->registered_frames[reg_idx].mapped = 1;
nvenc_frame->reg_idx = reg_idx;
nvenc_frame->input_surface = nvenc_frame->in_map.mappedResource;
nvenc_frame->format = nvenc_frame->in_map.mappedBufferFmt;
nvenc_frame->pitch = frame->linesize[0];
return 0;
} else {
NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 };
lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER;
lockBufferParams.inputBuffer = nvenc_frame->input_surface;
nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(avctx, nv_status, "Failed locking nvenc input buffer");
}
nvenc_frame->pitch = lockBufferParams.pitch;
res = nvenc_copy_frame(avctx, nvenc_frame, &lockBufferParams, frame);
nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, nvenc_frame->input_surface);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(avctx, nv_status, "Failed unlocking input buffer!");
}
return res;
}
}
| {
"code": [
" nvenc_frame->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER;",
" nvenc_frame->in_map.registeredResource = ctx->registered_frames[reg_idx].regptr;",
" nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &nvenc_frame->in_map);",
" if (nv_status != NV_ENC_SUCCESS) {",
" av_frame_unref(nvenc_frame->in_ref);",
" return nvenc_print_error(avctx, nv_status, \"Error mapping an input resource\");",
" ctx->registered_frames[reg_idx].mapped = 1;",
" nvenc_frame->input_surface = nvenc_frame->in_map.mappedResource;",
" nvenc_frame->format = nvenc_frame->in_map.mappedBufferFmt;"
],
"line_no": [
43,
45,
47,
49,
51,
53,
59,
63,
65
]
} | static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,
NvencSurface *VAR_2)
{
NvencContext *ctx = VAR_0->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
int VAR_3;
NVENCSTATUS nv_status;
if (VAR_0->pix_fmt == AV_PIX_FMT_CUDA || VAR_0->pix_fmt == AV_PIX_FMT_D3D11) {
int VAR_4 = nvenc_register_frame(VAR_0, VAR_1);
if (VAR_4 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Could not register an input HW VAR_1\n");
return VAR_4;
}
VAR_3 = av_frame_ref(VAR_2->in_ref, VAR_1);
if (VAR_3 < 0)
return VAR_3;
VAR_2->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER;
VAR_2->in_map.registeredResource = ctx->registered_frames[VAR_4].regptr;
nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &VAR_2->in_map);
if (nv_status != NV_ENC_SUCCESS) {
av_frame_unref(VAR_2->in_ref);
return nvenc_print_error(VAR_0, nv_status, "Error mapping an input resource");
}
ctx->registered_frames[VAR_4].mapped = 1;
VAR_2->VAR_4 = VAR_4;
VAR_2->input_surface = VAR_2->in_map.mappedResource;
VAR_2->format = VAR_2->in_map.mappedBufferFmt;
VAR_2->pitch = VAR_1->linesize[0];
return 0;
} else {
NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 };
lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER;
lockBufferParams.inputBuffer = VAR_2->input_surface;
nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(VAR_0, nv_status, "Failed locking nvenc input buffer");
}
VAR_2->pitch = lockBufferParams.pitch;
VAR_3 = nvenc_copy_frame(VAR_0, VAR_2, &lockBufferParams, VAR_1);
nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, VAR_2->input_surface);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(VAR_0, nv_status, "Failed unlocking input buffer!");
}
return VAR_3;
}
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,\nNvencSurface *VAR_2)\n{",
"NvencContext *ctx = VAR_0->priv_data;",
"NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;",
"NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;",
"int VAR_3;",
"NVENCSTATUS nv_status;",
"if (VAR_0->pix_fmt == AV_PIX_FMT_CUDA || VAR_0->pix_fmt == AV_PIX_FMT_D3D11) {",
"int VAR_4 = nvenc_register_frame(VAR_0, VAR_1);",
"if (VAR_4 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not register an input HW VAR_1\\n\");",
"return VAR_4;",
"}",
"VAR_3 = av_frame_ref(VAR_2->in_ref, VAR_1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"VAR_2->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER;",
"VAR_2->in_map.registeredResource = ctx->registered_frames[VAR_4].regptr;",
"nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &VAR_2->in_map);",
"if (nv_status != NV_ENC_SUCCESS) {",
"av_frame_unref(VAR_2->in_ref);",
"return nvenc_print_error(VAR_0, nv_status, \"Error mapping an input resource\");",
"}",
"ctx->registered_frames[VAR_4].mapped = 1;",
"VAR_2->VAR_4 = VAR_4;",
"VAR_2->input_surface = VAR_2->in_map.mappedResource;",
"VAR_2->format = VAR_2->in_map.mappedBufferFmt;",
"VAR_2->pitch = VAR_1->linesize[0];",
"return 0;",
"} else {",
"NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 };",
"lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER;",
"lockBufferParams.inputBuffer = VAR_2->input_surface;",
"nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams);",
"if (nv_status != NV_ENC_SUCCESS) {",
"return nvenc_print_error(VAR_0, nv_status, \"Failed locking nvenc input buffer\");",
"}",
"VAR_2->pitch = lockBufferParams.pitch;",
"VAR_3 = nvenc_copy_frame(VAR_0, VAR_2, &lockBufferParams, VAR_1);",
"nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, VAR_2->input_surface);",
"if (nv_status != NV_ENC_SUCCESS) {",
"return nvenc_print_error(VAR_0, nv_status, \"Failed unlocking input buffer!\");",
"}",
"return VAR_3;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
]
]
|
13,858 | void QEMU_NORETURN do_unassigned_access(target_phys_addr_t addr, int is_write,
int is_exec, int unused, int size)
{
env->trap_arg0 = addr;
env->trap_arg1 = is_write;
dynamic_excp(EXCP_MCHK, 0);
}
| true | qemu | b14ef7c9ab41ea824c3ccadb070ad95567cca84e | void QEMU_NORETURN do_unassigned_access(target_phys_addr_t addr, int is_write,
int is_exec, int unused, int size)
{
env->trap_arg0 = addr;
env->trap_arg1 = is_write;
dynamic_excp(EXCP_MCHK, 0);
}
| {
"code": [
"void QEMU_NORETURN do_unassigned_access(target_phys_addr_t addr, int is_write,",
" int is_exec, int unused, int size)"
],
"line_no": [
1,
3
]
} | void VAR_0 do_unassigned_access(target_phys_addr_t addr, int is_write,
int is_exec, int unused, int size)
{
env->trap_arg0 = addr;
env->trap_arg1 = is_write;
dynamic_excp(EXCP_MCHK, 0);
}
| [
"void VAR_0 do_unassigned_access(target_phys_addr_t addr, int is_write,\nint is_exec, int unused, int size)\n{",
"env->trap_arg0 = addr;",
"env->trap_arg1 = is_write;",
"dynamic_excp(EXCP_MCHK, 0);",
"}"
]
| [
1,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
13,860 | static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
DCTELEM *block, int16_t *weight, DCTELEM *orig,
int n, int qscale){
int16_t rem[64];
DCTELEM d1[64];
const int *qmat;
const uint8_t *scantable= s->intra_scantable.scantable;
const uint8_t *perm_scantable= s->intra_scantable.permutated;
// unsigned int threshold1, threshold2;
// int bias=0;
int run_tab[65];
int prev_run=0;
int prev_level=0;
int qmul, qadd, start_i, last_non_zero, i, dc;
uint8_t * length;
uint8_t * last_length;
int lambda;
int rle_index, run, q, sum;
#ifdef REFINE_STATS
static int count=0;
static int after_last=0;
static int to_zero=0;
static int from_zero=0;
static int raise=0;
static int lower=0;
static int messed_sign=0;
#endif
if(basis[0][0] == 0)
build_basis(s->dsp.idct_permutation);
qmul= qscale*2;
qadd= (qscale-1)|1;
if (s->mb_intra) {
if (!s->h263_aic) {
if (n < 4)
q = s->y_dc_scale;
else
q = s->c_dc_scale;
} else{
/* For AIC we skip quant/dequant of INTRADC */
q = 1;
qadd=0;
}
q <<= RECON_SHIFT-3;
/* note: block[0] is assumed to be positive */
dc= block[0]*q;
// block[0] = (block[0] + (q >> 1)) / q;
start_i = 1;
qmat = s->q_intra_matrix[qscale];
// if(s->mpeg_quant || s->out_format == FMT_MPEG1)
// bias= 1<<(QMAT_SHIFT-1);
length = s->intra_ac_vlc_length;
last_length= s->intra_ac_vlc_last_length;
} else {
dc= 0;
start_i = 0;
qmat = s->q_inter_matrix[qscale];
length = s->inter_ac_vlc_length;
last_length= s->inter_ac_vlc_last_length;
}
last_non_zero = s->block_last_index[n];
#ifdef REFINE_STATS
{START_TIMER
#endif
dc += (1<<(RECON_SHIFT-1));
for(i=0; i<64; i++){
rem[i]= dc - (orig[i]<<RECON_SHIFT); //FIXME use orig dirrectly insteadof copying to rem[]
}
#ifdef REFINE_STATS
STOP_TIMER("memset rem[]")}
#endif
sum=0;
for(i=0; i<64; i++){
int one= 36;
int qns=4;
int w;
w= ABS(weight[i]) + qns*one;
w= 15 + (48*qns*one + w/2)/w; // 16 .. 63
weight[i] = w;
// w=weight[i] = (63*qns + (w/2)) / w;
assert(w>0);
assert(w<(1<<6));
sum += w*w;
}
lambda= sum*(uint64_t)s->lambda2 >> (FF_LAMBDA_SHIFT - 6 + 6 + 6 + 6);
#ifdef REFINE_STATS
{START_TIMER
#endif
run=0;
rle_index=0;
for(i=start_i; i<=last_non_zero; i++){
int j= perm_scantable[i];
const int level= block[j];
int coeff;
if(level){
if(level<0) coeff= qmul*level - qadd;
else coeff= qmul*level + qadd;
run_tab[rle_index++]=run;
run=0;
s->dsp.add_8x8basis(rem, basis[j], coeff);
}else{
run++;
}
}
#ifdef REFINE_STATS
if(last_non_zero>0){
STOP_TIMER("init rem[]")
}
}
{START_TIMER
#endif
for(;;){
int best_score=s->dsp.try_8x8basis(rem, weight, basis[0], 0);
int best_coeff=0;
int best_change=0;
int run2, best_unquant_change=0, analyze_gradient;
#ifdef REFINE_STATS
{START_TIMER
#endif
analyze_gradient = last_non_zero > 2 || s->avctx->quantizer_noise_shaping >= 3;
if(analyze_gradient){
#ifdef REFINE_STATS
{START_TIMER
#endif
for(i=0; i<64; i++){
int w= weight[i];
d1[i] = (rem[i]*w*w + (1<<(RECON_SHIFT+12-1)))>>(RECON_SHIFT+12);
}
#ifdef REFINE_STATS
STOP_TIMER("rem*w*w")}
{START_TIMER
#endif
s->dsp.fdct(d1);
#ifdef REFINE_STATS
STOP_TIMER("dct")}
#endif
}
if(start_i){
const int level= block[0];
int change, old_coeff;
assert(s->mb_intra);
old_coeff= q*level;
for(change=-1; change<=1; change+=2){
int new_level= level + change;
int score, new_coeff;
new_coeff= q*new_level;
if(new_coeff >= 2048 || new_coeff < 0)
continue;
score= s->dsp.try_8x8basis(rem, weight, basis[0], new_coeff - old_coeff);
if(score<best_score){
best_score= score;
best_coeff= 0;
best_change= change;
best_unquant_change= new_coeff - old_coeff;
}
}
}
run=0;
rle_index=0;
run2= run_tab[rle_index++];
prev_level=0;
prev_run=0;
for(i=start_i; i<64; i++){
int j= perm_scantable[i];
const int level= block[j];
int change, old_coeff;
if(s->avctx->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
break;
if(level){
if(level<0) old_coeff= qmul*level - qadd;
else old_coeff= qmul*level + qadd;
run2= run_tab[rle_index++]; //FIXME ! maybe after last
}else{
old_coeff=0;
run2--;
assert(run2>=0 || i >= last_non_zero );
}
for(change=-1; change<=1; change+=2){
int new_level= level + change;
int score, new_coeff, unquant_change;
score=0;
if(s->avctx->quantizer_noise_shaping < 2 && ABS(new_level) > ABS(level))
continue;
if(new_level){
if(new_level<0) new_coeff= qmul*new_level - qadd;
else new_coeff= qmul*new_level + qadd;
if(new_coeff >= 2048 || new_coeff <= -2048)
continue;
//FIXME check for overflow
if(level){
if(level < 63 && level > -63){
if(i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run, new_level+64)]
- length[UNI_AC_ENC_INDEX(run, level+64)];
else
score += last_length[UNI_AC_ENC_INDEX(run, new_level+64)]
- last_length[UNI_AC_ENC_INDEX(run, level+64)];
}
}else{
assert(ABS(new_level)==1);
if(analyze_gradient){
int g= d1[ scantable[i] ];
if(g && (g^new_level) >= 0)
continue;
}
if(i < last_non_zero){
int next_i= i + run2 + 1;
int next_level= block[ perm_scantable[next_i] ] + 64;
if(next_level&(~127))
next_level= 0;
if(next_i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run, 65)]
+ length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
else
score += length[UNI_AC_ENC_INDEX(run, 65)]
+ last_length[UNI_AC_ENC_INDEX(run2, next_level)]
- last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
}else{
score += last_length[UNI_AC_ENC_INDEX(run, 65)];
if(prev_level){
score += length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
- last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
}
}
}
}else{
new_coeff=0;
assert(ABS(level)==1);
if(i < last_non_zero){
int next_i= i + run2 + 1;
int next_level= block[ perm_scantable[next_i] ] + 64;
if(next_level&(~127))
next_level= 0;
if(next_i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
- length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run, 65)];
else
score += last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
- last_length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run, 65)];
}else{
score += -last_length[UNI_AC_ENC_INDEX(run, 65)];
if(prev_level){
score += last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
- length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
}
}
}
score *= lambda;
unquant_change= new_coeff - old_coeff;
assert((score < 100*lambda && score > -100*lambda) || lambda==0);
score+= s->dsp.try_8x8basis(rem, weight, basis[j], unquant_change);
if(score<best_score){
best_score= score;
best_coeff= i;
best_change= change;
best_unquant_change= unquant_change;
}
}
if(level){
prev_level= level + 64;
if(prev_level&(~127))
prev_level= 0;
prev_run= run;
run=0;
}else{
run++;
}
}
#ifdef REFINE_STATS
STOP_TIMER("iterative step")}
#endif
if(best_change){
int j= perm_scantable[ best_coeff ];
block[j] += best_change;
if(best_coeff > last_non_zero){
last_non_zero= best_coeff;
assert(block[j]);
#ifdef REFINE_STATS
after_last++;
#endif
}else{
#ifdef REFINE_STATS
if(block[j]){
if(block[j] - best_change){
if(ABS(block[j]) > ABS(block[j] - best_change)){
raise++;
}else{
lower++;
}
}else{
from_zero++;
}
}else{
to_zero++;
}
#endif
for(; last_non_zero>=start_i; last_non_zero--){
if(block[perm_scantable[last_non_zero]])
break;
}
}
#ifdef REFINE_STATS
count++;
if(256*256*256*64 % count == 0){
printf("after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\n", after_last, to_zero, from_zero, raise, lower, messed_sign, s->mb_x, s->mb_y, s->picture_number);
}
#endif
run=0;
rle_index=0;
for(i=start_i; i<=last_non_zero; i++){
int j= perm_scantable[i];
const int level= block[j];
if(level){
run_tab[rle_index++]=run;
run=0;
}else{
run++;
}
}
s->dsp.add_8x8basis(rem, basis[j], best_unquant_change);
}else{
break;
}
}
#ifdef REFINE_STATS
if(last_non_zero>0){
STOP_TIMER("iterative search")
}
}
#endif
return last_non_zero;
}
| true | FFmpeg | 125af022434fbb6a61ba8244eb19d3a43f9687e9 | static int dct_quantize_refine(MpegEncContext *s,
DCTELEM *block, int16_t *weight, DCTELEM *orig,
int n, int qscale){
int16_t rem[64];
DCTELEM d1[64];
const int *qmat;
const uint8_t *scantable= s->intra_scantable.scantable;
const uint8_t *perm_scantable= s->intra_scantable.permutated;
int run_tab[65];
int prev_run=0;
int prev_level=0;
int qmul, qadd, start_i, last_non_zero, i, dc;
uint8_t * length;
uint8_t * last_length;
int lambda;
int rle_index, run, q, sum;
#ifdef REFINE_STATS
static int count=0;
static int after_last=0;
static int to_zero=0;
static int from_zero=0;
static int raise=0;
static int lower=0;
static int messed_sign=0;
#endif
if(basis[0][0] == 0)
build_basis(s->dsp.idct_permutation);
qmul= qscale*2;
qadd= (qscale-1)|1;
if (s->mb_intra) {
if (!s->h263_aic) {
if (n < 4)
q = s->y_dc_scale;
else
q = s->c_dc_scale;
} else{
q = 1;
qadd=0;
}
q <<= RECON_SHIFT-3;
dc= block[0]*q;
start_i = 1;
qmat = s->q_intra_matrix[qscale];
length = s->intra_ac_vlc_length;
last_length= s->intra_ac_vlc_last_length;
} else {
dc= 0;
start_i = 0;
qmat = s->q_inter_matrix[qscale];
length = s->inter_ac_vlc_length;
last_length= s->inter_ac_vlc_last_length;
}
last_non_zero = s->block_last_index[n];
#ifdef REFINE_STATS
{START_TIMER
#endif
dc += (1<<(RECON_SHIFT-1));
for(i=0; i<64; i++){
rem[i]= dc - (orig[i]<<RECON_SHIFT);
}
#ifdef REFINE_STATS
STOP_TIMER("memset rem[]")}
#endif
sum=0;
for(i=0; i<64; i++){
int one= 36;
int qns=4;
int w;
w= ABS(weight[i]) + qns*one;
w= 15 + (48*qns*one + w/2)/w;
weight[i] = w;
assert(w>0);
assert(w<(1<<6));
sum += w*w;
}
lambda= sum*(uint64_t)s->lambda2 >> (FF_LAMBDA_SHIFT - 6 + 6 + 6 + 6);
#ifdef REFINE_STATS
{START_TIMER
#endif
run=0;
rle_index=0;
for(i=start_i; i<=last_non_zero; i++){
int j= perm_scantable[i];
const int level= block[j];
int coeff;
if(level){
if(level<0) coeff= qmul*level - qadd;
else coeff= qmul*level + qadd;
run_tab[rle_index++]=run;
run=0;
s->dsp.add_8x8basis(rem, basis[j], coeff);
}else{
run++;
}
}
#ifdef REFINE_STATS
if(last_non_zero>0){
STOP_TIMER("init rem[]")
}
}
{START_TIMER
#endif
for(;;){
int best_score=s->dsp.try_8x8basis(rem, weight, basis[0], 0);
int best_coeff=0;
int best_change=0;
int run2, best_unquant_change=0, analyze_gradient;
#ifdef REFINE_STATS
{START_TIMER
#endif
analyze_gradient = last_non_zero > 2 || s->avctx->quantizer_noise_shaping >= 3;
if(analyze_gradient){
#ifdef REFINE_STATS
{START_TIMER
#endif
for(i=0; i<64; i++){
int w= weight[i];
d1[i] = (rem[i]*w*w + (1<<(RECON_SHIFT+12-1)))>>(RECON_SHIFT+12);
}
#ifdef REFINE_STATS
STOP_TIMER("rem*w*w")}
{START_TIMER
#endif
s->dsp.fdct(d1);
#ifdef REFINE_STATS
STOP_TIMER("dct")}
#endif
}
if(start_i){
const int level= block[0];
int change, old_coeff;
assert(s->mb_intra);
old_coeff= q*level;
for(change=-1; change<=1; change+=2){
int new_level= level + change;
int score, new_coeff;
new_coeff= q*new_level;
if(new_coeff >= 2048 || new_coeff < 0)
continue;
score= s->dsp.try_8x8basis(rem, weight, basis[0], new_coeff - old_coeff);
if(score<best_score){
best_score= score;
best_coeff= 0;
best_change= change;
best_unquant_change= new_coeff - old_coeff;
}
}
}
run=0;
rle_index=0;
run2= run_tab[rle_index++];
prev_level=0;
prev_run=0;
for(i=start_i; i<64; i++){
int j= perm_scantable[i];
const int level= block[j];
int change, old_coeff;
if(s->avctx->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
break;
if(level){
if(level<0) old_coeff= qmul*level - qadd;
else old_coeff= qmul*level + qadd;
run2= run_tab[rle_index++];
}else{
old_coeff=0;
run2--;
assert(run2>=0 || i >= last_non_zero );
}
for(change=-1; change<=1; change+=2){
int new_level= level + change;
int score, new_coeff, unquant_change;
score=0;
if(s->avctx->quantizer_noise_shaping < 2 && ABS(new_level) > ABS(level))
continue;
if(new_level){
if(new_level<0) new_coeff= qmul*new_level - qadd;
else new_coeff= qmul*new_level + qadd;
if(new_coeff >= 2048 || new_coeff <= -2048)
continue;
if(level){
if(level < 63 && level > -63){
if(i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run, new_level+64)]
- length[UNI_AC_ENC_INDEX(run, level+64)];
else
score += last_length[UNI_AC_ENC_INDEX(run, new_level+64)]
- last_length[UNI_AC_ENC_INDEX(run, level+64)];
}
}else{
assert(ABS(new_level)==1);
if(analyze_gradient){
int g= d1[ scantable[i] ];
if(g && (g^new_level) >= 0)
continue;
}
if(i < last_non_zero){
int next_i= i + run2 + 1;
int next_level= block[ perm_scantable[next_i] ] + 64;
if(next_level&(~127))
next_level= 0;
if(next_i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run, 65)]
+ length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
else
score += length[UNI_AC_ENC_INDEX(run, 65)]
+ last_length[UNI_AC_ENC_INDEX(run2, next_level)]
- last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
}else{
score += last_length[UNI_AC_ENC_INDEX(run, 65)];
if(prev_level){
score += length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
- last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
}
}
}
}else{
new_coeff=0;
assert(ABS(level)==1);
if(i < last_non_zero){
int next_i= i + run2 + 1;
int next_level= block[ perm_scantable[next_i] ] + 64;
if(next_level&(~127))
next_level= 0;
if(next_i < last_non_zero)
score += length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
- length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run, 65)];
else
score += last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
- last_length[UNI_AC_ENC_INDEX(run2, next_level)]
- length[UNI_AC_ENC_INDEX(run, 65)];
}else{
score += -last_length[UNI_AC_ENC_INDEX(run, 65)];
if(prev_level){
score += last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
- length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
}
}
}
score *= lambda;
unquant_change= new_coeff - old_coeff;
assert((score < 100*lambda && score > -100*lambda) || lambda==0);
score+= s->dsp.try_8x8basis(rem, weight, basis[j], unquant_change);
if(score<best_score){
best_score= score;
best_coeff= i;
best_change= change;
best_unquant_change= unquant_change;
}
}
if(level){
prev_level= level + 64;
if(prev_level&(~127))
prev_level= 0;
prev_run= run;
run=0;
}else{
run++;
}
}
#ifdef REFINE_STATS
STOP_TIMER("iterative step")}
#endif
if(best_change){
int j= perm_scantable[ best_coeff ];
block[j] += best_change;
if(best_coeff > last_non_zero){
last_non_zero= best_coeff;
assert(block[j]);
#ifdef REFINE_STATS
after_last++;
#endif
}else{
#ifdef REFINE_STATS
if(block[j]){
if(block[j] - best_change){
if(ABS(block[j]) > ABS(block[j] - best_change)){
raise++;
}else{
lower++;
}
}else{
from_zero++;
}
}else{
to_zero++;
}
#endif
for(; last_non_zero>=start_i; last_non_zero--){
if(block[perm_scantable[last_non_zero]])
break;
}
}
#ifdef REFINE_STATS
count++;
if(256*256*256*64 % count == 0){
printf("after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\n", after_last, to_zero, from_zero, raise, lower, messed_sign, s->mb_x, s->mb_y, s->picture_number);
}
#endif
run=0;
rle_index=0;
for(i=start_i; i<=last_non_zero; i++){
int j= perm_scantable[i];
const int level= block[j];
if(level){
run_tab[rle_index++]=run;
run=0;
}else{
run++;
}
}
s->dsp.add_8x8basis(rem, basis[j], best_unquant_change);
}else{
break;
}
}
#ifdef REFINE_STATS
if(last_non_zero>0){
STOP_TIMER("iterative search")
}
}
#endif
return last_non_zero;
}
| {
"code": [
" DCTELEM d1[64];"
],
"line_no": [
9
]
} | static int FUNC_0(MpegEncContext *VAR_0,
DCTELEM *VAR_1, int16_t *VAR_2, DCTELEM *VAR_3,
int VAR_4, int VAR_5){
int16_t rem[64];
DCTELEM d1[64];
const int *VAR_6;
const uint8_t *VAR_7= VAR_0->intra_scantable.VAR_7;
const uint8_t *VAR_8= VAR_0->intra_scantable.permutated;
int VAR_9[65];
int VAR_10=0;
int VAR_11=0;
int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;
uint8_t * length;
uint8_t * last_length;
int VAR_18;
int VAR_19, VAR_20, VAR_21, VAR_22;
#ifdef REFINE_STATS
static int count=0;
static int after_last=0;
static int to_zero=0;
static int from_zero=0;
static int raise=0;
static int lower=0;
static int messed_sign=0;
#endif
if(basis[0][0] == 0)
build_basis(VAR_0->dsp.idct_permutation);
VAR_12= VAR_5*2;
VAR_13= (VAR_5-1)|1;
if (VAR_0->mb_intra) {
if (!VAR_0->h263_aic) {
if (VAR_4 < 4)
VAR_21 = VAR_0->y_dc_scale;
else
VAR_21 = VAR_0->c_dc_scale;
} else{
VAR_21 = 1;
VAR_13=0;
}
VAR_21 <<= RECON_SHIFT-3;
VAR_17= VAR_1[0]*VAR_21;
VAR_14 = 1;
VAR_6 = VAR_0->q_intra_matrix[VAR_5];
length = VAR_0->intra_ac_vlc_length;
last_length= VAR_0->intra_ac_vlc_last_length;
} else {
VAR_17= 0;
VAR_14 = 0;
VAR_6 = VAR_0->q_inter_matrix[VAR_5];
length = VAR_0->inter_ac_vlc_length;
last_length= VAR_0->inter_ac_vlc_last_length;
}
VAR_15 = VAR_0->block_last_index[VAR_4];
#ifdef REFINE_STATS
{START_TIMER
#endif
VAR_17 += (1<<(RECON_SHIFT-1));
for(VAR_16=0; VAR_16<64; VAR_16++){
rem[VAR_16]= VAR_17 - (VAR_3[VAR_16]<<RECON_SHIFT);
}
#ifdef REFINE_STATS
STOP_TIMER("memset rem[]")}
#endif
VAR_22=0;
for(VAR_16=0; VAR_16<64; VAR_16++){
int VAR_23= 36;
int VAR_24=4;
int VAR_35;
VAR_35= ABS(VAR_2[VAR_16]) + VAR_24*VAR_23;
VAR_35= 15 + (48*VAR_24*VAR_23 + VAR_35/2)/VAR_35;
VAR_2[VAR_16] = VAR_35;
assert(VAR_35>0);
assert(VAR_35<(1<<6));
VAR_22 += VAR_35*VAR_35;
}
VAR_18= VAR_22*(uint64_t)VAR_0->lambda2 >> (FF_LAMBDA_SHIFT - 6 + 6 + 6 + 6);
#ifdef REFINE_STATS
{START_TIMER
#endif
VAR_20=0;
VAR_19=0;
for(VAR_16=VAR_14; VAR_16<=VAR_15; VAR_16++){
int VAR_44= VAR_8[VAR_16];
const int VAR_44= VAR_1[VAR_44];
int VAR_28;
if(VAR_44){
if(VAR_44<0) VAR_28= VAR_12*VAR_44 - VAR_13;
else VAR_28= VAR_12*VAR_44 + VAR_13;
VAR_9[VAR_19++]=VAR_20;
VAR_20=0;
VAR_0->dsp.add_8x8basis(rem, basis[VAR_44], VAR_28);
}else{
VAR_20++;
}
}
#ifdef REFINE_STATS
if(VAR_15>0){
STOP_TIMER("init rem[]")
}
}
{START_TIMER
#endif
for(;;){
int VAR_29=VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[0], 0);
int VAR_30=0;
int VAR_31=0;
int VAR_32, VAR_33=0, VAR_34;
#ifdef REFINE_STATS
{START_TIMER
#endif
VAR_34 = VAR_15 > 2 || VAR_0->avctx->quantizer_noise_shaping >= 3;
if(VAR_34){
#ifdef REFINE_STATS
{START_TIMER
#endif
for(VAR_16=0; VAR_16<64; VAR_16++){
int VAR_35= VAR_2[VAR_16];
d1[VAR_16] = (rem[VAR_16]*VAR_35*VAR_35 + (1<<(RECON_SHIFT+12-1)))>>(RECON_SHIFT+12);
}
#ifdef REFINE_STATS
STOP_TIMER("rem*VAR_35*VAR_35")}
{START_TIMER
#endif
VAR_0->dsp.fdct(d1);
#ifdef REFINE_STATS
STOP_TIMER("dct")}
#endif
}
if(VAR_14){
const int VAR_44= VAR_1[0];
int VAR_40, VAR_40;
assert(VAR_0->mb_intra);
VAR_40= VAR_21*VAR_44;
for(VAR_40=-1; VAR_40<=1; VAR_40+=2){
int VAR_40= VAR_44 + VAR_40;
int VAR_40, VAR_40;
VAR_40= VAR_21*VAR_40;
if(VAR_40 >= 2048 || VAR_40 < 0)
continue;
VAR_40= VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[0], VAR_40 - VAR_40);
if(VAR_40<VAR_29){
VAR_29= VAR_40;
VAR_30= 0;
VAR_31= VAR_40;
VAR_33= VAR_40 - VAR_40;
}
}
}
VAR_20=0;
VAR_19=0;
VAR_32= VAR_9[VAR_19++];
VAR_11=0;
VAR_10=0;
for(VAR_16=VAR_14; VAR_16<64; VAR_16++){
int VAR_44= VAR_8[VAR_16];
const int VAR_44= VAR_1[VAR_44];
int VAR_40, VAR_40;
if(VAR_0->avctx->quantizer_noise_shaping < 3 && VAR_16 > VAR_15 + 1)
break;
if(VAR_44){
if(VAR_44<0) VAR_40= VAR_12*VAR_44 - VAR_13;
else VAR_40= VAR_12*VAR_44 + VAR_13;
VAR_32= VAR_9[VAR_19++];
}else{
VAR_40=0;
VAR_32--;
assert(VAR_32>=0 || VAR_16 >= VAR_15 );
}
for(VAR_40=-1; VAR_40<=1; VAR_40+=2){
int VAR_40= VAR_44 + VAR_40;
int VAR_40, VAR_40, VAR_40;
VAR_40=0;
if(VAR_0->avctx->quantizer_noise_shaping < 2 && ABS(VAR_40) > ABS(VAR_44))
continue;
if(VAR_40){
if(VAR_40<0) VAR_40= VAR_12*VAR_40 - VAR_13;
else VAR_40= VAR_12*VAR_40 + VAR_13;
if(VAR_40 >= 2048 || VAR_40 <= -2048)
continue;
if(VAR_44){
if(VAR_44 < 63 && VAR_44 > -63){
if(VAR_16 < VAR_15)
VAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, VAR_40+64)]
- length[UNI_AC_ENC_INDEX(VAR_20, VAR_44+64)];
else
VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20, VAR_40+64)]
- last_length[UNI_AC_ENC_INDEX(VAR_20, VAR_44+64)];
}
}else{
assert(ABS(VAR_40)==1);
if(VAR_34){
int VAR_41= d1[ VAR_7[VAR_16] ];
if(VAR_41 && (VAR_41^VAR_40) >= 0)
continue;
}
if(VAR_16 < VAR_15){
int VAR_44= VAR_16 + VAR_32 + 1;
int VAR_44= VAR_1[ VAR_8[VAR_44] ] + 64;
if(VAR_44&(~127))
VAR_44= 0;
if(VAR_44 < VAR_15)
VAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, 65)]
+ length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]
- length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)];
else
VAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, 65)]
+ last_length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]
- last_length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)];
}else{
VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20, 65)];
if(VAR_11){
VAR_40 += length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)]
- last_length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)];
}
}
}
}else{
VAR_40=0;
assert(ABS(VAR_44)==1);
if(VAR_16 < VAR_15){
int VAR_44= VAR_16 + VAR_32 + 1;
int VAR_44= VAR_1[ VAR_8[VAR_44] ] + 64;
if(VAR_44&(~127))
VAR_44= 0;
if(VAR_44 < VAR_15)
VAR_40 += length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)]
- length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]
- length[UNI_AC_ENC_INDEX(VAR_20, 65)];
else
VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)]
- last_length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]
- length[UNI_AC_ENC_INDEX(VAR_20, 65)];
}else{
VAR_40 += -last_length[UNI_AC_ENC_INDEX(VAR_20, 65)];
if(VAR_11){
VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)]
- length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)];
}
}
}
VAR_40 *= VAR_18;
VAR_40= VAR_40 - VAR_40;
assert((VAR_40 < 100*VAR_18 && VAR_40 > -100*VAR_18) || VAR_18==0);
VAR_40+= VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[VAR_44], VAR_40);
if(VAR_40<VAR_29){
VAR_29= VAR_40;
VAR_30= VAR_16;
VAR_31= VAR_40;
VAR_33= VAR_40;
}
}
if(VAR_44){
VAR_11= VAR_44 + 64;
if(VAR_11&(~127))
VAR_11= 0;
VAR_10= VAR_20;
VAR_20=0;
}else{
VAR_20++;
}
}
#ifdef REFINE_STATS
STOP_TIMER("iterative step")}
#endif
if(VAR_31){
int VAR_44= VAR_8[ VAR_30 ];
VAR_1[VAR_44] += VAR_31;
if(VAR_30 > VAR_15){
VAR_15= VAR_30;
assert(VAR_1[VAR_44]);
#ifdef REFINE_STATS
after_last++;
#endif
}else{
#ifdef REFINE_STATS
if(VAR_1[VAR_44]){
if(VAR_1[VAR_44] - VAR_31){
if(ABS(VAR_1[VAR_44]) > ABS(VAR_1[VAR_44] - VAR_31)){
raise++;
}else{
lower++;
}
}else{
from_zero++;
}
}else{
to_zero++;
}
#endif
for(; VAR_15>=VAR_14; VAR_15--){
if(VAR_1[VAR_8[VAR_15]])
break;
}
}
#ifdef REFINE_STATS
count++;
if(256*256*256*64 % count == 0){
printf("after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\VAR_4", after_last, to_zero, from_zero, raise, lower, messed_sign, VAR_0->mb_x, VAR_0->mb_y, VAR_0->picture_number);
}
#endif
VAR_20=0;
VAR_19=0;
for(VAR_16=VAR_14; VAR_16<=VAR_15; VAR_16++){
int VAR_44= VAR_8[VAR_16];
const int VAR_44= VAR_1[VAR_44];
if(VAR_44){
VAR_9[VAR_19++]=VAR_20;
VAR_20=0;
}else{
VAR_20++;
}
}
VAR_0->dsp.add_8x8basis(rem, basis[VAR_44], VAR_33);
}else{
break;
}
}
#ifdef REFINE_STATS
if(VAR_15>0){
STOP_TIMER("iterative search")
}
}
#endif
return VAR_15;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0,\nDCTELEM *VAR_1, int16_t *VAR_2, DCTELEM *VAR_3,\nint VAR_4, int VAR_5){",
"int16_t rem[64];",
"DCTELEM d1[64];",
"const int *VAR_6;",
"const uint8_t *VAR_7= VAR_0->intra_scantable.VAR_7;",
"const uint8_t *VAR_8= VAR_0->intra_scantable.permutated;",
"int VAR_9[65];",
"int VAR_10=0;",
"int VAR_11=0;",
"int VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17;",
"uint8_t * length;",
"uint8_t * last_length;",
"int VAR_18;",
"int VAR_19, VAR_20, VAR_21, VAR_22;",
"#ifdef REFINE_STATS\nstatic int count=0;",
"static int after_last=0;",
"static int to_zero=0;",
"static int from_zero=0;",
"static int raise=0;",
"static int lower=0;",
"static int messed_sign=0;",
"#endif\nif(basis[0][0] == 0)\nbuild_basis(VAR_0->dsp.idct_permutation);",
"VAR_12= VAR_5*2;",
"VAR_13= (VAR_5-1)|1;",
"if (VAR_0->mb_intra) {",
"if (!VAR_0->h263_aic) {",
"if (VAR_4 < 4)\nVAR_21 = VAR_0->y_dc_scale;",
"else\nVAR_21 = VAR_0->c_dc_scale;",
"} else{",
"VAR_21 = 1;",
"VAR_13=0;",
"}",
"VAR_21 <<= RECON_SHIFT-3;",
"VAR_17= VAR_1[0]*VAR_21;",
"VAR_14 = 1;",
"VAR_6 = VAR_0->q_intra_matrix[VAR_5];",
"length = VAR_0->intra_ac_vlc_length;",
"last_length= VAR_0->intra_ac_vlc_last_length;",
"} else {",
"VAR_17= 0;",
"VAR_14 = 0;",
"VAR_6 = VAR_0->q_inter_matrix[VAR_5];",
"length = VAR_0->inter_ac_vlc_length;",
"last_length= VAR_0->inter_ac_vlc_last_length;",
"}",
"VAR_15 = VAR_0->block_last_index[VAR_4];",
"#ifdef REFINE_STATS\n{START_TIMER",
"#endif\nVAR_17 += (1<<(RECON_SHIFT-1));",
"for(VAR_16=0; VAR_16<64; VAR_16++){",
"rem[VAR_16]= VAR_17 - (VAR_3[VAR_16]<<RECON_SHIFT);",
"}",
"#ifdef REFINE_STATS\nSTOP_TIMER(\"memset rem[]\")}",
"#endif\nVAR_22=0;",
"for(VAR_16=0; VAR_16<64; VAR_16++){",
"int VAR_23= 36;",
"int VAR_24=4;",
"int VAR_35;",
"VAR_35= ABS(VAR_2[VAR_16]) + VAR_24*VAR_23;",
"VAR_35= 15 + (48*VAR_24*VAR_23 + VAR_35/2)/VAR_35;",
"VAR_2[VAR_16] = VAR_35;",
"assert(VAR_35>0);",
"assert(VAR_35<(1<<6));",
"VAR_22 += VAR_35*VAR_35;",
"}",
"VAR_18= VAR_22*(uint64_t)VAR_0->lambda2 >> (FF_LAMBDA_SHIFT - 6 + 6 + 6 + 6);",
"#ifdef REFINE_STATS\n{START_TIMER",
"#endif\nVAR_20=0;",
"VAR_19=0;",
"for(VAR_16=VAR_14; VAR_16<=VAR_15; VAR_16++){",
"int VAR_44= VAR_8[VAR_16];",
"const int VAR_44= VAR_1[VAR_44];",
"int VAR_28;",
"if(VAR_44){",
"if(VAR_44<0) VAR_28= VAR_12*VAR_44 - VAR_13;",
"else VAR_28= VAR_12*VAR_44 + VAR_13;",
"VAR_9[VAR_19++]=VAR_20;",
"VAR_20=0;",
"VAR_0->dsp.add_8x8basis(rem, basis[VAR_44], VAR_28);",
"}else{",
"VAR_20++;",
"}",
"}",
"#ifdef REFINE_STATS\nif(VAR_15>0){",
"STOP_TIMER(\"init rem[]\")\n}",
"}",
"{START_TIMER",
"#endif\nfor(;;){",
"int VAR_29=VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[0], 0);",
"int VAR_30=0;",
"int VAR_31=0;",
"int VAR_32, VAR_33=0, VAR_34;",
"#ifdef REFINE_STATS\n{START_TIMER",
"#endif\nVAR_34 = VAR_15 > 2 || VAR_0->avctx->quantizer_noise_shaping >= 3;",
"if(VAR_34){",
"#ifdef REFINE_STATS\n{START_TIMER",
"#endif\nfor(VAR_16=0; VAR_16<64; VAR_16++){",
"int VAR_35= VAR_2[VAR_16];",
"d1[VAR_16] = (rem[VAR_16]*VAR_35*VAR_35 + (1<<(RECON_SHIFT+12-1)))>>(RECON_SHIFT+12);",
"}",
"#ifdef REFINE_STATS\nSTOP_TIMER(\"rem*VAR_35*VAR_35\")}",
"{START_TIMER",
"#endif\nVAR_0->dsp.fdct(d1);",
"#ifdef REFINE_STATS\nSTOP_TIMER(\"dct\")}",
"#endif\n}",
"if(VAR_14){",
"const int VAR_44= VAR_1[0];",
"int VAR_40, VAR_40;",
"assert(VAR_0->mb_intra);",
"VAR_40= VAR_21*VAR_44;",
"for(VAR_40=-1; VAR_40<=1; VAR_40+=2){",
"int VAR_40= VAR_44 + VAR_40;",
"int VAR_40, VAR_40;",
"VAR_40= VAR_21*VAR_40;",
"if(VAR_40 >= 2048 || VAR_40 < 0)\ncontinue;",
"VAR_40= VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[0], VAR_40 - VAR_40);",
"if(VAR_40<VAR_29){",
"VAR_29= VAR_40;",
"VAR_30= 0;",
"VAR_31= VAR_40;",
"VAR_33= VAR_40 - VAR_40;",
"}",
"}",
"}",
"VAR_20=0;",
"VAR_19=0;",
"VAR_32= VAR_9[VAR_19++];",
"VAR_11=0;",
"VAR_10=0;",
"for(VAR_16=VAR_14; VAR_16<64; VAR_16++){",
"int VAR_44= VAR_8[VAR_16];",
"const int VAR_44= VAR_1[VAR_44];",
"int VAR_40, VAR_40;",
"if(VAR_0->avctx->quantizer_noise_shaping < 3 && VAR_16 > VAR_15 + 1)\nbreak;",
"if(VAR_44){",
"if(VAR_44<0) VAR_40= VAR_12*VAR_44 - VAR_13;",
"else VAR_40= VAR_12*VAR_44 + VAR_13;",
"VAR_32= VAR_9[VAR_19++];",
"}else{",
"VAR_40=0;",
"VAR_32--;",
"assert(VAR_32>=0 || VAR_16 >= VAR_15 );",
"}",
"for(VAR_40=-1; VAR_40<=1; VAR_40+=2){",
"int VAR_40= VAR_44 + VAR_40;",
"int VAR_40, VAR_40, VAR_40;",
"VAR_40=0;",
"if(VAR_0->avctx->quantizer_noise_shaping < 2 && ABS(VAR_40) > ABS(VAR_44))\ncontinue;",
"if(VAR_40){",
"if(VAR_40<0) VAR_40= VAR_12*VAR_40 - VAR_13;",
"else VAR_40= VAR_12*VAR_40 + VAR_13;",
"if(VAR_40 >= 2048 || VAR_40 <= -2048)\ncontinue;",
"if(VAR_44){",
"if(VAR_44 < 63 && VAR_44 > -63){",
"if(VAR_16 < VAR_15)\nVAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, VAR_40+64)]\n- length[UNI_AC_ENC_INDEX(VAR_20, VAR_44+64)];",
"else\nVAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20, VAR_40+64)]\n- last_length[UNI_AC_ENC_INDEX(VAR_20, VAR_44+64)];",
"}",
"}else{",
"assert(ABS(VAR_40)==1);",
"if(VAR_34){",
"int VAR_41= d1[ VAR_7[VAR_16] ];",
"if(VAR_41 && (VAR_41^VAR_40) >= 0)\ncontinue;",
"}",
"if(VAR_16 < VAR_15){",
"int VAR_44= VAR_16 + VAR_32 + 1;",
"int VAR_44= VAR_1[ VAR_8[VAR_44] ] + 64;",
"if(VAR_44&(~127))\nVAR_44= 0;",
"if(VAR_44 < VAR_15)\nVAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, 65)]\n+ length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]\n- length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)];",
"else\nVAR_40 += length[UNI_AC_ENC_INDEX(VAR_20, 65)]\n+ last_length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]\n- last_length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)];",
"}else{",
"VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20, 65)];",
"if(VAR_11){",
"VAR_40 += length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)]\n- last_length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)];",
"}",
"}",
"}",
"}else{",
"VAR_40=0;",
"assert(ABS(VAR_44)==1);",
"if(VAR_16 < VAR_15){",
"int VAR_44= VAR_16 + VAR_32 + 1;",
"int VAR_44= VAR_1[ VAR_8[VAR_44] ] + 64;",
"if(VAR_44&(~127))\nVAR_44= 0;",
"if(VAR_44 < VAR_15)\nVAR_40 += length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)]\n- length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]\n- length[UNI_AC_ENC_INDEX(VAR_20, 65)];",
"else\nVAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_20 + VAR_32 + 1, VAR_44)]\n- last_length[UNI_AC_ENC_INDEX(VAR_32, VAR_44)]\n- length[UNI_AC_ENC_INDEX(VAR_20, 65)];",
"}else{",
"VAR_40 += -last_length[UNI_AC_ENC_INDEX(VAR_20, 65)];",
"if(VAR_11){",
"VAR_40 += last_length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)]\n- length[UNI_AC_ENC_INDEX(VAR_10, VAR_11)];",
"}",
"}",
"}",
"VAR_40 *= VAR_18;",
"VAR_40= VAR_40 - VAR_40;",
"assert((VAR_40 < 100*VAR_18 && VAR_40 > -100*VAR_18) || VAR_18==0);",
"VAR_40+= VAR_0->dsp.try_8x8basis(rem, VAR_2, basis[VAR_44], VAR_40);",
"if(VAR_40<VAR_29){",
"VAR_29= VAR_40;",
"VAR_30= VAR_16;",
"VAR_31= VAR_40;",
"VAR_33= VAR_40;",
"}",
"}",
"if(VAR_44){",
"VAR_11= VAR_44 + 64;",
"if(VAR_11&(~127))\nVAR_11= 0;",
"VAR_10= VAR_20;",
"VAR_20=0;",
"}else{",
"VAR_20++;",
"}",
"}",
"#ifdef REFINE_STATS\nSTOP_TIMER(\"iterative step\")}",
"#endif\nif(VAR_31){",
"int VAR_44= VAR_8[ VAR_30 ];",
"VAR_1[VAR_44] += VAR_31;",
"if(VAR_30 > VAR_15){",
"VAR_15= VAR_30;",
"assert(VAR_1[VAR_44]);",
"#ifdef REFINE_STATS\nafter_last++;",
"#endif\n}else{",
"#ifdef REFINE_STATS\nif(VAR_1[VAR_44]){",
"if(VAR_1[VAR_44] - VAR_31){",
"if(ABS(VAR_1[VAR_44]) > ABS(VAR_1[VAR_44] - VAR_31)){",
"raise++;",
"}else{",
"lower++;",
"}",
"}else{",
"from_zero++;",
"}",
"}else{",
"to_zero++;",
"}",
"#endif\nfor(; VAR_15>=VAR_14; VAR_15--){",
"if(VAR_1[VAR_8[VAR_15]])\nbreak;",
"}",
"}",
"#ifdef REFINE_STATS\ncount++;",
"if(256*256*256*64 % count == 0){",
"printf(\"after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\\VAR_4\", after_last, to_zero, from_zero, raise, lower, messed_sign, VAR_0->mb_x, VAR_0->mb_y, VAR_0->picture_number);",
"}",
"#endif\nVAR_20=0;",
"VAR_19=0;",
"for(VAR_16=VAR_14; VAR_16<=VAR_15; VAR_16++){",
"int VAR_44= VAR_8[VAR_16];",
"const int VAR_44= VAR_1[VAR_44];",
"if(VAR_44){",
"VAR_9[VAR_19++]=VAR_20;",
"VAR_20=0;",
"}else{",
"VAR_20++;",
"}",
"}",
"VAR_0->dsp.add_8x8basis(rem, basis[VAR_44], VAR_33);",
"}else{",
"break;",
"}",
"}",
"#ifdef REFINE_STATS\nif(VAR_15>0){",
"STOP_TIMER(\"iterative search\")\n}",
"}",
"#endif\nreturn VAR_15;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
57,
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227,
229
],
[
231
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
259
],
[
261,
263
],
[
265,
267
],
[
269
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283,
285
],
[
287,
289
],
[
291,
293
],
[
297
],
[
299
],
[
301
],
[
305
],
[
309
],
[
313
],
[
315
],
[
317
],
[
321
],
[
323,
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371,
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
405
],
[
407,
409
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
427
],
[
429
],
[
431,
433,
435
],
[
437,
439,
441
],
[
443
],
[
445
],
[
447
],
[
451
],
[
453
],
[
455,
457
],
[
459
],
[
463
],
[
465
],
[
467
],
[
471,
473
],
[
477,
479,
481,
483
],
[
485,
487,
489,
491
],
[
493
],
[
495
],
[
497
],
[
499,
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
519
],
[
521
],
[
525,
527
],
[
531,
533,
535,
537
],
[
539,
541,
543,
545
],
[
547
],
[
549
],
[
551
],
[
553,
555
],
[
557
],
[
559
],
[
561
],
[
565
],
[
569
],
[
571
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595,
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611,
613
],
[
615,
619
],
[
621
],
[
625
],
[
629
],
[
631
],
[
633
],
[
635,
637
],
[
639,
641
],
[
643,
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671,
673
],
[
675,
677
],
[
679
],
[
681
],
[
683,
685
],
[
687
],
[
689
],
[
691
],
[
693,
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733,
735
],
[
737,
739
],
[
741
],
[
743,
747
],
[
749
]
]
|
13,861 | void *g_realloc(void * mem, size_t n_bytes)
{
__coverity_negative_sink__(n_bytes);
mem = realloc(mem, n_bytes == 0 ? 1 : n_bytes);
if (!mem) __coverity_panic__();
return mem;
}
| true | qemu | 9d7a4c6690ef9962a3b20034f65008f1ea15c1d6 | void *g_realloc(void * mem, size_t n_bytes)
{
__coverity_negative_sink__(n_bytes);
mem = realloc(mem, n_bytes == 0 ? 1 : n_bytes);
if (!mem) __coverity_panic__();
return mem;
}
| {
"code": [
" __coverity_negative_sink__(n_bytes);",
" if (!mem) __coverity_panic__();",
" return mem;",
" __coverity_negative_sink__(n_bytes);",
" if (!mem) __coverity_panic__();",
" return mem;",
"void *g_realloc(void * mem, size_t n_bytes)",
" __coverity_negative_sink__(n_bytes);",
" mem = realloc(mem, n_bytes == 0 ? 1 : n_bytes);",
" if (!mem) __coverity_panic__();",
" return mem;",
" __coverity_negative_sink__(n_bytes);",
" __coverity_negative_sink__(n_bytes);",
" __coverity_negative_sink__(n_bytes);"
],
"line_no": [
5,
9,
11,
5,
9,
11,
1,
5,
7,
9,
11,
5,
5,
5
]
} | void *FUNC_0(void * VAR_0, size_t VAR_1)
{
__coverity_negative_sink__(VAR_1);
VAR_0 = realloc(VAR_0, VAR_1 == 0 ? 1 : VAR_1);
if (!VAR_0) __coverity_panic__();
return VAR_0;
}
| [
"void *FUNC_0(void * VAR_0, size_t VAR_1)\n{",
"__coverity_negative_sink__(VAR_1);",
"VAR_0 = realloc(VAR_0, VAR_1 == 0 ? 1 : VAR_1);",
"if (!VAR_0) __coverity_panic__();",
"return VAR_0;",
"}"
]
| [
1,
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
13,862 | av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
{
int i;
ff_check_alignment();
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if(avctx->dct_algo==FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
}
else if(avctx->dct_algo==FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
}
else {
c->fdct = ff_jpeg_fdct_islow_8; //slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
#endif //CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->idct_permutation_type = FF_NO_IDCT_PERM;
} else {
if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add;
c->idct = ff_j_rev_dct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) &&
avctx->idct_algo==FF_IDCT_VP3){
c->idct_put= ff_vp3_idct_put_c;
c->idct_add= ff_vp3_idct_add_c;
c->idct = ff_vp3_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_WMV2){
c->idct_put= ff_wmv2_idct_put_c;
c->idct_add= ff_wmv2_idct_add_c;
c->idct = ff_wmv2_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_FAAN){
c->idct_put= ff_faanidct_put;
c->idct_add= ff_faanidct_add;
c->idct = ff_faanidct;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
c->idct_put= ff_ea_idct_put_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{ //accurate/default
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct_8;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}
}
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = ff_put_pixels_clamped_c;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;
c->add_pixels_clamped = ff_add_pixels_clamped_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;
c->gmc1 = gmc1_c;
c->gmc = ff_gmc_c;
c->pix_sum = pix_sum_c;
c->pix_norm1 = pix_norm1_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
/* TODO [0] 16 [1] 8 */
c->pix_abs[0][0] = pix_abs16_c;
c->pix_abs[0][1] = pix_abs16_x2_c;
c->pix_abs[0][2] = pix_abs16_y2_c;
c->pix_abs[0][3] = pix_abs16_xy2_c;
c->pix_abs[1][0] = pix_abs8_c;
c->pix_abs[1][1] = pix_abs8_x2_c;
c->pix_abs[1][2] = pix_abs8_y2_c;
c->pix_abs[1][3] = pix_abs8_xy2_c;
c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
dspfunc(put_qpel, 0, 16);
dspfunc(put_no_rnd_qpel, 0, 16);
dspfunc(avg_qpel, 0, 16);
/* dspfunc(avg_no_rnd_qpel, 0, 16); */
dspfunc(put_qpel, 1, 8);
dspfunc(put_no_rnd_qpel, 1, 8);
dspfunc(avg_qpel, 1, 8);
/* dspfunc(avg_no_rnd_qpel, 1, 8); */
#undef dspfunc
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER
ff_intrax8dsp_init(c,avctx);
#endif
c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
#define SET_CMP_FUNC(name) \
c->name[0]= name ## 16_c;\
c->name[1]= name ## 8x8_c;
SET_CMP_FUNC(hadamard8_diff)
c->hadamard8_diff[4]= hadamard8_intra16_c;
c->hadamard8_diff[5]= hadamard8_intra8x8_c;
SET_CMP_FUNC(dct_sad)
SET_CMP_FUNC(dct_max)
#if CONFIG_GPL
SET_CMP_FUNC(dct264_sad)
#endif
c->sad[0]= pix_abs16_c;
c->sad[1]= pix_abs8_c;
c->sse[0]= sse16_c;
c->sse[1]= sse8_c;
c->sse[2]= sse4_c;
SET_CMP_FUNC(quant_psnr)
SET_CMP_FUNC(rd)
SET_CMP_FUNC(bit)
c->vsad[0]= vsad16_c;
c->vsad[4]= vsad_intra16_c;
c->vsad[5]= vsad_intra8_c;
c->vsse[0]= vsse16_c;
c->vsse[4]= vsse_intra16_c;
c->vsse[5]= vsse_intra8_c;
c->nsse[0]= nsse16_c;
c->nsse[1]= nsse8_c;
#if CONFIG_DWT
ff_dsputil_init_dwt(c);
#endif
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
c->bswap_buf= bswap_buf;
c->bswap16_buf = bswap16_buf;
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
c->h263_h_loop_filter= h263_h_loop_filter_c;
c->h263_v_loop_filter= h263_v_loop_filter_c;
}
if (CONFIG_VP3_DECODER) {
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;
}
c->h261_loop_filter= h261_loop_filter_c;
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
#if CONFIG_VORBIS_DECODER
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;
#endif
#if CONFIG_AC3_DECODER
c->ac3_downmix = ff_ac3_downmix_c;
#endif
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
c->vector_fmul_window = vector_fmul_window_c;
c->vector_clipf = vector_clipf_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
c->apply_window_int16 = apply_window_int16_c;
c->vector_clip_int32 = vector_clip_int32_c;
c->scalarproduct_float = scalarproduct_float_c;
c->butterflies_float = butterflies_float_c;
c->butterflies_float_interleave = butterflies_float_interleave_c;
c->vector_fmul_scalar = vector_fmul_scalar_c;
c->vector_fmac_scalar = vector_fmac_scalar_c;
c->shrink[0]= av_image_copy_plane;
c->shrink[1]= ff_shrink22;
c->shrink[2]= ff_shrink44;
c->shrink[3]= ff_shrink88;
c->prefetch= just_return;
memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
#undef FUNC
#undef FUNCC
#define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c
#define dspfunc1(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\
c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\
c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\
c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth)
#define dspfunc2(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\
c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\
c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\
c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\
c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\
c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\
c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\
c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\
c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\
c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\
c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\
c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\
c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\
c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\
c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\
c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)
#define BIT_DEPTH_FUNCS(depth, dct)\
c->get_pixels = FUNCC(get_pixels ## dct , depth);\
c->draw_edges = FUNCC(draw_edges , depth);\
c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\
c->clear_block = FUNCC(clear_block ## dct , depth);\
c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\
c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\
c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\
c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\
c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\
\
c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\
c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\
c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\
c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\
c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\
c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\
\
dspfunc1(put , 0, 16, depth);\
dspfunc1(put , 1, 8, depth);\
dspfunc1(put , 2, 4, depth);\
dspfunc1(put , 3, 2, depth);\
dspfunc1(put_no_rnd, 0, 16, depth);\
dspfunc1(put_no_rnd, 1, 8, depth);\
dspfunc1(avg , 0, 16, depth);\
dspfunc1(avg , 1, 8, depth);\
dspfunc1(avg , 2, 4, depth);\
dspfunc1(avg , 3, 2, depth);\
dspfunc1(avg_no_rnd, 0, 16, depth);\
dspfunc1(avg_no_rnd, 1, 8, depth);\
\
dspfunc2(put_h264_qpel, 0, 16, depth);\
dspfunc2(put_h264_qpel, 1, 8, depth);\
dspfunc2(put_h264_qpel, 2, 4, depth);\
dspfunc2(put_h264_qpel, 3, 2, depth);\
dspfunc2(avg_h264_qpel, 0, 16, depth);\
dspfunc2(avg_h264_qpel, 1, 8, depth);\
dspfunc2(avg_h264_qpel, 2, 4, depth);
switch (avctx->bits_per_raw_sample) {
case 9:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(9, _32);
} else {
BIT_DEPTH_FUNCS(9, _16);
}
break;
case 10:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(10, _32);
} else {
BIT_DEPTH_FUNCS(10, _16);
}
break;
default:
BIT_DEPTH_FUNCS(8, _16);
break;
}
if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);
if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);
if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx);
if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
for(i=0; i<64; i++){
if(!c->put_2tap_qpel_pixels_tab[0][i])
c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i];
if(!c->avg_2tap_qpel_pixels_tab[0][i])
c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];
}
ff_init_scantable_permutation(c->idct_permutation,
c->idct_permutation_type);
}
| true | FFmpeg | 0a07f2b346433a9a2677c69c6b29a1a827e39109 | av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
{
int i;
ff_check_alignment();
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if(avctx->dct_algo==FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
}
else if(avctx->dct_algo==FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
}
else {
c->fdct = ff_jpeg_fdct_islow_8;
c->fdct248 = ff_fdct248_islow_8;
}
}
#endif
if (avctx->bits_per_raw_sample == 10) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->idct_permutation_type = FF_NO_IDCT_PERM;
} else {
if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add;
c->idct = ff_j_rev_dct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) &&
avctx->idct_algo==FF_IDCT_VP3){
c->idct_put= ff_vp3_idct_put_c;
c->idct_add= ff_vp3_idct_add_c;
c->idct = ff_vp3_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_WMV2){
c->idct_put= ff_wmv2_idct_put_c;
c->idct_add= ff_wmv2_idct_add_c;
c->idct = ff_wmv2_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_FAAN){
c->idct_put= ff_faanidct_put;
c->idct_add= ff_faanidct_add;
c->idct = ff_faanidct;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
c->idct_put= ff_ea_idct_put_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct_8;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}
}
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = ff_put_pixels_clamped_c;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;
c->add_pixels_clamped = ff_add_pixels_clamped_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;
c->gmc1 = gmc1_c;
c->gmc = ff_gmc_c;
c->pix_sum = pix_sum_c;
c->pix_norm1 = pix_norm1_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
c->pix_abs[0][0] = pix_abs16_c;
c->pix_abs[0][1] = pix_abs16_x2_c;
c->pix_abs[0][2] = pix_abs16_y2_c;
c->pix_abs[0][3] = pix_abs16_xy2_c;
c->pix_abs[1][0] = pix_abs8_c;
c->pix_abs[1][1] = pix_abs8_x2_c;
c->pix_abs[1][2] = pix_abs8_y2_c;
c->pix_abs[1][3] = pix_abs8_xy2_c;
c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
dspfunc(put_qpel, 0, 16);
dspfunc(put_no_rnd_qpel, 0, 16);
dspfunc(avg_qpel, 0, 16);
dspfunc(put_qpel, 1, 8);
dspfunc(put_no_rnd_qpel, 1, 8);
dspfunc(avg_qpel, 1, 8);
#undef dspfunc
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER
ff_intrax8dsp_init(c,avctx);
#endif
c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
#define SET_CMP_FUNC(name) \
c->name[0]= name ## 16_c;\
c->name[1]= name ## 8x8_c;
SET_CMP_FUNC(hadamard8_diff)
c->hadamard8_diff[4]= hadamard8_intra16_c;
c->hadamard8_diff[5]= hadamard8_intra8x8_c;
SET_CMP_FUNC(dct_sad)
SET_CMP_FUNC(dct_max)
#if CONFIG_GPL
SET_CMP_FUNC(dct264_sad)
#endif
c->sad[0]= pix_abs16_c;
c->sad[1]= pix_abs8_c;
c->sse[0]= sse16_c;
c->sse[1]= sse8_c;
c->sse[2]= sse4_c;
SET_CMP_FUNC(quant_psnr)
SET_CMP_FUNC(rd)
SET_CMP_FUNC(bit)
c->vsad[0]= vsad16_c;
c->vsad[4]= vsad_intra16_c;
c->vsad[5]= vsad_intra8_c;
c->vsse[0]= vsse16_c;
c->vsse[4]= vsse_intra16_c;
c->vsse[5]= vsse_intra8_c;
c->nsse[0]= nsse16_c;
c->nsse[1]= nsse8_c;
#if CONFIG_DWT
ff_dsputil_init_dwt(c);
#endif
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
c->bswap_buf= bswap_buf;
c->bswap16_buf = bswap16_buf;
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
c->h263_h_loop_filter= h263_h_loop_filter_c;
c->h263_v_loop_filter= h263_v_loop_filter_c;
}
if (CONFIG_VP3_DECODER) {
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;
}
c->h261_loop_filter= h261_loop_filter_c;
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
#if CONFIG_VORBIS_DECODER
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;
#endif
#if CONFIG_AC3_DECODER
c->ac3_downmix = ff_ac3_downmix_c;
#endif
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
c->vector_fmul_window = vector_fmul_window_c;
c->vector_clipf = vector_clipf_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
c->apply_window_int16 = apply_window_int16_c;
c->vector_clip_int32 = vector_clip_int32_c;
c->scalarproduct_float = scalarproduct_float_c;
c->butterflies_float = butterflies_float_c;
c->butterflies_float_interleave = butterflies_float_interleave_c;
c->vector_fmul_scalar = vector_fmul_scalar_c;
c->vector_fmac_scalar = vector_fmac_scalar_c;
c->shrink[0]= av_image_copy_plane;
c->shrink[1]= ff_shrink22;
c->shrink[2]= ff_shrink44;
c->shrink[3]= ff_shrink88;
c->prefetch= just_return;
memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
#undef FUNC
#undef FUNCC
#define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c
#define dspfunc1(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\
c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\
c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\
c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth)
#define dspfunc2(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\
c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\
c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\
c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\
c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\
c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\
c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\
c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\
c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\
c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\
c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\
c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\
c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\
c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\
c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\
c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)
#define BIT_DEPTH_FUNCS(depth, dct)\
c->get_pixels = FUNCC(get_pixels ## dct , depth);\
c->draw_edges = FUNCC(draw_edges , depth);\
c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\
c->clear_block = FUNCC(clear_block ## dct , depth);\
c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\
c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\
c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\
c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\
c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\
\
c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\
c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\
c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\
c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\
c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\
c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\
\
dspfunc1(put , 0, 16, depth);\
dspfunc1(put , 1, 8, depth);\
dspfunc1(put , 2, 4, depth);\
dspfunc1(put , 3, 2, depth);\
dspfunc1(put_no_rnd, 0, 16, depth);\
dspfunc1(put_no_rnd, 1, 8, depth);\
dspfunc1(avg , 0, 16, depth);\
dspfunc1(avg , 1, 8, depth);\
dspfunc1(avg , 2, 4, depth);\
dspfunc1(avg , 3, 2, depth);\
dspfunc1(avg_no_rnd, 0, 16, depth);\
dspfunc1(avg_no_rnd, 1, 8, depth);\
\
dspfunc2(put_h264_qpel, 0, 16, depth);\
dspfunc2(put_h264_qpel, 1, 8, depth);\
dspfunc2(put_h264_qpel, 2, 4, depth);\
dspfunc2(put_h264_qpel, 3, 2, depth);\
dspfunc2(avg_h264_qpel, 0, 16, depth);\
dspfunc2(avg_h264_qpel, 1, 8, depth);\
dspfunc2(avg_h264_qpel, 2, 4, depth);
switch (avctx->bits_per_raw_sample) {
case 9:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(9, _32);
} else {
BIT_DEPTH_FUNCS(9, _16);
}
break;
case 10:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(10, _32);
} else {
BIT_DEPTH_FUNCS(10, _16);
}
break;
default:
BIT_DEPTH_FUNCS(8, _16);
break;
}
if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);
if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);
if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx);
if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
for(i=0; i<64; i++){
if(!c->put_2tap_qpel_pixels_tab[0][i])
c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i];
if(!c->avg_2tap_qpel_pixels_tab[0][i])
c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];
}
ff_init_scantable_permutation(c->idct_permutation,
c->idct_permutation_type);
}
| {
"code": [
" int i;",
" for(i=0; i<64; i++){",
" if(!c->put_2tap_qpel_pixels_tab[0][i])",
" c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i];",
" if(!c->avg_2tap_qpel_pixels_tab[0][i])",
" c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];"
],
"line_no": [
5,
689,
691,
693,
695,
697
]
} | av_cold void FUNC_0(DSPContext* c, AVCodecContext *avctx)
{
int VAR_0;
ff_check_alignment();
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if(avctx->dct_algo==FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
}
else if(avctx->dct_algo==FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
}
else {
c->fdct = ff_jpeg_fdct_islow_8;
c->fdct248 = ff_fdct248_islow_8;
}
}
#endif
if (avctx->bits_per_raw_sample == 10) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->idct_permutation_type = FF_NO_IDCT_PERM;
} else {
if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add;
c->idct = ff_j_rev_dct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) &&
avctx->idct_algo==FF_IDCT_VP3){
c->idct_put= ff_vp3_idct_put_c;
c->idct_add= ff_vp3_idct_add_c;
c->idct = ff_vp3_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_WMV2){
c->idct_put= ff_wmv2_idct_put_c;
c->idct_add= ff_wmv2_idct_add_c;
c->idct = ff_wmv2_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_FAAN){
c->idct_put= ff_faanidct_put;
c->idct_add= ff_faanidct_add;
c->idct = ff_faanidct;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
c->idct_put= ff_ea_idct_put_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct_8;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}
}
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = ff_put_pixels_clamped_c;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;
c->add_pixels_clamped = ff_add_pixels_clamped_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;
c->gmc1 = gmc1_c;
c->gmc = ff_gmc_c;
c->pix_sum = pix_sum_c;
c->pix_norm1 = pix_norm1_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
c->pix_abs[0][0] = pix_abs16_c;
c->pix_abs[0][1] = pix_abs16_x2_c;
c->pix_abs[0][2] = pix_abs16_y2_c;
c->pix_abs[0][3] = pix_abs16_xy2_c;
c->pix_abs[1][0] = pix_abs8_c;
c->pix_abs[1][1] = pix_abs8_x2_c;
c->pix_abs[1][2] = pix_abs8_y2_c;
c->pix_abs[1][3] = pix_abs8_xy2_c;
c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
dspfunc(put_qpel, 0, 16);
dspfunc(put_no_rnd_qpel, 0, 16);
dspfunc(avg_qpel, 0, 16);
dspfunc(put_qpel, 1, 8);
dspfunc(put_no_rnd_qpel, 1, 8);
dspfunc(avg_qpel, 1, 8);
#undef dspfunc
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER
ff_intrax8dsp_init(c,avctx);
#endif
c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
#define SET_CMP_FUNC(name) \
c->name[0]= name ## 16_c;\
c->name[1]= name ## 8x8_c;
SET_CMP_FUNC(hadamard8_diff)
c->hadamard8_diff[4]= hadamard8_intra16_c;
c->hadamard8_diff[5]= hadamard8_intra8x8_c;
SET_CMP_FUNC(dct_sad)
SET_CMP_FUNC(dct_max)
#if CONFIG_GPL
SET_CMP_FUNC(dct264_sad)
#endif
c->sad[0]= pix_abs16_c;
c->sad[1]= pix_abs8_c;
c->sse[0]= sse16_c;
c->sse[1]= sse8_c;
c->sse[2]= sse4_c;
SET_CMP_FUNC(quant_psnr)
SET_CMP_FUNC(rd)
SET_CMP_FUNC(bit)
c->vsad[0]= vsad16_c;
c->vsad[4]= vsad_intra16_c;
c->vsad[5]= vsad_intra8_c;
c->vsse[0]= vsse16_c;
c->vsse[4]= vsse_intra16_c;
c->vsse[5]= vsse_intra8_c;
c->nsse[0]= nsse16_c;
c->nsse[1]= nsse8_c;
#if CONFIG_DWT
ff_dsputil_init_dwt(c);
#endif
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
c->bswap_buf= bswap_buf;
c->bswap16_buf = bswap16_buf;
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
c->h263_h_loop_filter= h263_h_loop_filter_c;
c->h263_v_loop_filter= h263_v_loop_filter_c;
}
if (CONFIG_VP3_DECODER) {
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;
}
c->h261_loop_filter= h261_loop_filter_c;
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
#if CONFIG_VORBIS_DECODER
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;
#endif
#if CONFIG_AC3_DECODER
c->ac3_downmix = ff_ac3_downmix_c;
#endif
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
c->vector_fmul_window = vector_fmul_window_c;
c->vector_clipf = vector_clipf_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
c->apply_window_int16 = apply_window_int16_c;
c->vector_clip_int32 = vector_clip_int32_c;
c->scalarproduct_float = scalarproduct_float_c;
c->butterflies_float = butterflies_float_c;
c->butterflies_float_interleave = butterflies_float_interleave_c;
c->vector_fmul_scalar = vector_fmul_scalar_c;
c->vector_fmac_scalar = vector_fmac_scalar_c;
c->shrink[0]= av_image_copy_plane;
c->shrink[1]= ff_shrink22;
c->shrink[2]= ff_shrink44;
c->shrink[3]= ff_shrink88;
c->prefetch= just_return;
memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
#undef FUNC
#undef FUNCC
#define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c
#define dspfunc1(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\
c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\
c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\
c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth)
#define dspfunc2(PFX, IDX, NUM, depth)\
c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\
c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\
c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\
c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\
c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\
c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\
c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\
c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\
c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\
c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\
c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\
c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\
c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\
c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\
c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\
c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)
#define BIT_DEPTH_FUNCS(depth, dct)\
c->get_pixels = FUNCC(get_pixels ## dct , depth);\
c->draw_edges = FUNCC(draw_edges , depth);\
c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\
c->clear_block = FUNCC(clear_block ## dct , depth);\
c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\
c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\
c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\
c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\
c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\
\
c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\
c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\
c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\
c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\
c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\
c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\
\
dspfunc1(put , 0, 16, depth);\
dspfunc1(put , 1, 8, depth);\
dspfunc1(put , 2, 4, depth);\
dspfunc1(put , 3, 2, depth);\
dspfunc1(put_no_rnd, 0, 16, depth);\
dspfunc1(put_no_rnd, 1, 8, depth);\
dspfunc1(avg , 0, 16, depth);\
dspfunc1(avg , 1, 8, depth);\
dspfunc1(avg , 2, 4, depth);\
dspfunc1(avg , 3, 2, depth);\
dspfunc1(avg_no_rnd, 0, 16, depth);\
dspfunc1(avg_no_rnd, 1, 8, depth);\
\
dspfunc2(put_h264_qpel, 0, 16, depth);\
dspfunc2(put_h264_qpel, 1, 8, depth);\
dspfunc2(put_h264_qpel, 2, 4, depth);\
dspfunc2(put_h264_qpel, 3, 2, depth);\
dspfunc2(avg_h264_qpel, 0, 16, depth);\
dspfunc2(avg_h264_qpel, 1, 8, depth);\
dspfunc2(avg_h264_qpel, 2, 4, depth);
switch (avctx->bits_per_raw_sample) {
case 9:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(9, _32);
} else {
BIT_DEPTH_FUNCS(9, _16);
}
break;
case 10:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(10, _32);
} else {
BIT_DEPTH_FUNCS(10, _16);
}
break;
default:
BIT_DEPTH_FUNCS(8, _16);
break;
}
if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);
if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);
if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx);
if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
for(VAR_0=0; VAR_0<64; VAR_0++){
if(!c->put_2tap_qpel_pixels_tab[0][VAR_0])
c->put_2tap_qpel_pixels_tab[0][VAR_0]= c->put_h264_qpel_pixels_tab[0][VAR_0];
if(!c->avg_2tap_qpel_pixels_tab[0][VAR_0])
c->avg_2tap_qpel_pixels_tab[0][VAR_0]= c->avg_h264_qpel_pixels_tab[0][VAR_0];
}
ff_init_scantable_permutation(c->idct_permutation,
c->idct_permutation_type);
}
| [
"av_cold void FUNC_0(DSPContext* c, AVCodecContext *avctx)\n{",
"int VAR_0;",
"ff_check_alignment();",
"#if CONFIG_ENCODERS\nif (avctx->bits_per_raw_sample == 10) {",
"c->fdct = ff_jpeg_fdct_islow_10;",
"c->fdct248 = ff_fdct248_islow_10;",
"} else {",
"if(avctx->dct_algo==FF_DCT_FASTINT) {",
"c->fdct = ff_fdct_ifast;",
"c->fdct248 = ff_fdct_ifast248;",
"}",
"else if(avctx->dct_algo==FF_DCT_FAAN) {",
"c->fdct = ff_faandct;",
"c->fdct248 = ff_faandct248;",
"}",
"else {",
"c->fdct = ff_jpeg_fdct_islow_8;",
"c->fdct248 = ff_fdct248_islow_8;",
"}",
"}",
"#endif\nif (avctx->bits_per_raw_sample == 10) {",
"c->idct_put = ff_simple_idct_put_10;",
"c->idct_add = ff_simple_idct_add_10;",
"c->idct = ff_simple_idct_10;",
"c->idct_permutation_type = FF_NO_IDCT_PERM;",
"} else {",
"if(avctx->idct_algo==FF_IDCT_INT){",
"c->idct_put= ff_jref_idct_put;",
"c->idct_add= ff_jref_idct_add;",
"c->idct = ff_j_rev_dct;",
"c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;",
"}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) &&",
"avctx->idct_algo==FF_IDCT_VP3){",
"c->idct_put= ff_vp3_idct_put_c;",
"c->idct_add= ff_vp3_idct_add_c;",
"c->idct = ff_vp3_idct_c;",
"c->idct_permutation_type= FF_NO_IDCT_PERM;",
"}else if(avctx->idct_algo==FF_IDCT_WMV2){",
"c->idct_put= ff_wmv2_idct_put_c;",
"c->idct_add= ff_wmv2_idct_add_c;",
"c->idct = ff_wmv2_idct_c;",
"c->idct_permutation_type= FF_NO_IDCT_PERM;",
"}else if(avctx->idct_algo==FF_IDCT_FAAN){",
"c->idct_put= ff_faanidct_put;",
"c->idct_add= ff_faanidct_add;",
"c->idct = ff_faanidct;",
"c->idct_permutation_type= FF_NO_IDCT_PERM;",
"}else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {",
"c->idct_put= ff_ea_idct_put_c;",
"c->idct_permutation_type= FF_NO_IDCT_PERM;",
"}else{",
"c->idct_put = ff_simple_idct_put_8;",
"c->idct_add = ff_simple_idct_add_8;",
"c->idct = ff_simple_idct_8;",
"c->idct_permutation_type= FF_NO_IDCT_PERM;",
"}",
"}",
"c->diff_pixels = diff_pixels_c;",
"c->put_pixels_clamped = ff_put_pixels_clamped_c;",
"c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;",
"c->add_pixels_clamped = ff_add_pixels_clamped_c;",
"c->sum_abs_dctelem = sum_abs_dctelem_c;",
"c->gmc1 = gmc1_c;",
"c->gmc = ff_gmc_c;",
"c->pix_sum = pix_sum_c;",
"c->pix_norm1 = pix_norm1_c;",
"c->fill_block_tab[0] = fill_block16_c;",
"c->fill_block_tab[1] = fill_block8_c;",
"c->pix_abs[0][0] = pix_abs16_c;",
"c->pix_abs[0][1] = pix_abs16_x2_c;",
"c->pix_abs[0][2] = pix_abs16_y2_c;",
"c->pix_abs[0][3] = pix_abs16_xy2_c;",
"c->pix_abs[1][0] = pix_abs8_c;",
"c->pix_abs[1][1] = pix_abs8_x2_c;",
"c->pix_abs[1][2] = pix_abs8_y2_c;",
"c->pix_abs[1][3] = pix_abs8_xy2_c;",
"c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;",
"c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;",
"c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;",
"c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;",
"c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;",
"c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;",
"c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;",
"c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;",
"c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;",
"c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;",
"c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;",
"c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;",
"c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;",
"c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;",
"c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;",
"c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;",
"c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;",
"c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;",
"#define dspfunc(PFX, IDX, NUM) \\\nc->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \\",
"c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \\",
"c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \\",
"c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \\",
"c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \\",
"c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \\",
"c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \\",
"c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \\",
"c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \\",
"c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \\",
"c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \\",
"c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \\",
"c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \\",
"c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \\",
"c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \\",
"c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c\ndspfunc(put_qpel, 0, 16);",
"dspfunc(put_no_rnd_qpel, 0, 16);",
"dspfunc(avg_qpel, 0, 16);",
"dspfunc(put_qpel, 1, 8);",
"dspfunc(put_no_rnd_qpel, 1, 8);",
"dspfunc(avg_qpel, 1, 8);",
"#undef dspfunc\n#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER\nff_mlp_init(c, avctx);",
"#endif\n#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER\nff_intrax8dsp_init(c,avctx);",
"#endif\nc->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;",
"c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;",
"c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;",
"c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;",
"c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;",
"c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;",
"c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;",
"c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;",
"#define SET_CMP_FUNC(name) \\\nc->name[0]= name ## 16_c;\\",
"c->name[1]= name ## 8x8_c;",
"SET_CMP_FUNC(hadamard8_diff)\nc->hadamard8_diff[4]= hadamard8_intra16_c;",
"c->hadamard8_diff[5]= hadamard8_intra8x8_c;",
"SET_CMP_FUNC(dct_sad)\nSET_CMP_FUNC(dct_max)\n#if CONFIG_GPL\nSET_CMP_FUNC(dct264_sad)\n#endif\nc->sad[0]= pix_abs16_c;",
"c->sad[1]= pix_abs8_c;",
"c->sse[0]= sse16_c;",
"c->sse[1]= sse8_c;",
"c->sse[2]= sse4_c;",
"SET_CMP_FUNC(quant_psnr)\nSET_CMP_FUNC(rd)\nSET_CMP_FUNC(bit)\nc->vsad[0]= vsad16_c;",
"c->vsad[4]= vsad_intra16_c;",
"c->vsad[5]= vsad_intra8_c;",
"c->vsse[0]= vsse16_c;",
"c->vsse[4]= vsse_intra16_c;",
"c->vsse[5]= vsse_intra8_c;",
"c->nsse[0]= nsse16_c;",
"c->nsse[1]= nsse8_c;",
"#if CONFIG_DWT\nff_dsputil_init_dwt(c);",
"#endif\nc->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;",
"c->add_bytes= add_bytes_c;",
"c->diff_bytes= diff_bytes_c;",
"c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;",
"c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;",
"c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;",
"c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;",
"c->bswap_buf= bswap_buf;",
"c->bswap16_buf = bswap16_buf;",
"if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {",
"c->h263_h_loop_filter= h263_h_loop_filter_c;",
"c->h263_v_loop_filter= h263_v_loop_filter_c;",
"}",
"if (CONFIG_VP3_DECODER) {",
"c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;",
"c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;",
"c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;",
"}",
"c->h261_loop_filter= h261_loop_filter_c;",
"c->try_8x8basis= try_8x8basis_c;",
"c->add_8x8basis= add_8x8basis_c;",
"#if CONFIG_VORBIS_DECODER\nc->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;",
"#endif\n#if CONFIG_AC3_DECODER\nc->ac3_downmix = ff_ac3_downmix_c;",
"#endif\nc->vector_fmul = vector_fmul_c;",
"c->vector_fmul_reverse = vector_fmul_reverse_c;",
"c->vector_fmul_add = vector_fmul_add_c;",
"c->vector_fmul_window = vector_fmul_window_c;",
"c->vector_clipf = vector_clipf_c;",
"c->scalarproduct_int16 = scalarproduct_int16_c;",
"c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;",
"c->apply_window_int16 = apply_window_int16_c;",
"c->vector_clip_int32 = vector_clip_int32_c;",
"c->scalarproduct_float = scalarproduct_float_c;",
"c->butterflies_float = butterflies_float_c;",
"c->butterflies_float_interleave = butterflies_float_interleave_c;",
"c->vector_fmul_scalar = vector_fmul_scalar_c;",
"c->vector_fmac_scalar = vector_fmac_scalar_c;",
"c->shrink[0]= av_image_copy_plane;",
"c->shrink[1]= ff_shrink22;",
"c->shrink[2]= ff_shrink44;",
"c->shrink[3]= ff_shrink88;",
"c->prefetch= just_return;",
"memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));",
"memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));",
"#undef FUNC\n#undef FUNCC\n#define FUNC(f, depth) f ## _ ## depth\n#define FUNCC(f, depth) f ## _ ## depth ## _c\n#define dspfunc1(PFX, IDX, NUM, depth)\\\nc->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\\",
"c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\\",
"c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\\",
"c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth)\n#define dspfunc2(PFX, IDX, NUM, depth)\\\nc->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\\",
"c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\\",
"c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\\",
"c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\\",
"c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\\",
"c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\\",
"c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\\",
"c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)\n#define BIT_DEPTH_FUNCS(depth, dct)\\\nc->get_pixels = FUNCC(get_pixels ## dct , depth);\\",
"c->draw_edges = FUNCC(draw_edges , depth);\\",
"c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\\",
"c->clear_block = FUNCC(clear_block ## dct , depth);\\",
"c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\\",
"c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\\",
"c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\\",
"c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\\",
"c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\\",
"\\\nc->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\\",
"c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\\",
"c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\\",
"c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\\",
"c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\\",
"c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\\",
"\\\ndspfunc1(put , 0, 16, depth);\\",
"dspfunc1(put , 1, 8, depth);\\",
"dspfunc1(put , 2, 4, depth);\\",
"dspfunc1(put , 3, 2, depth);\\",
"dspfunc1(put_no_rnd, 0, 16, depth);\\",
"dspfunc1(put_no_rnd, 1, 8, depth);\\",
"dspfunc1(avg , 0, 16, depth);\\",
"dspfunc1(avg , 1, 8, depth);\\",
"dspfunc1(avg , 2, 4, depth);\\",
"dspfunc1(avg , 3, 2, depth);\\",
"dspfunc1(avg_no_rnd, 0, 16, depth);\\",
"dspfunc1(avg_no_rnd, 1, 8, depth);\\",
"\\\ndspfunc2(put_h264_qpel, 0, 16, depth);\\",
"dspfunc2(put_h264_qpel, 1, 8, depth);\\",
"dspfunc2(put_h264_qpel, 2, 4, depth);\\",
"dspfunc2(put_h264_qpel, 3, 2, depth);\\",
"dspfunc2(avg_h264_qpel, 0, 16, depth);\\",
"dspfunc2(avg_h264_qpel, 1, 8, depth);\\",
"dspfunc2(avg_h264_qpel, 2, 4, depth);",
"switch (avctx->bits_per_raw_sample) {",
"case 9:\nif (c->dct_bits == 32) {",
"BIT_DEPTH_FUNCS(9, _32);",
"} else {",
"BIT_DEPTH_FUNCS(9, _16);",
"}",
"break;",
"case 10:\nif (c->dct_bits == 32) {",
"BIT_DEPTH_FUNCS(10, _32);",
"} else {",
"BIT_DEPTH_FUNCS(10, _16);",
"}",
"break;",
"default:\nBIT_DEPTH_FUNCS(8, _16);",
"break;",
"}",
"if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);",
"if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);",
"if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);",
"if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);",
"if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);",
"if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx);",
"if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);",
"if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);",
"for(VAR_0=0; VAR_0<64; VAR_0++){",
"if(!c->put_2tap_qpel_pixels_tab[0][VAR_0])\nc->put_2tap_qpel_pixels_tab[0][VAR_0]= c->put_h264_qpel_pixels_tab[0][VAR_0];",
"if(!c->avg_2tap_qpel_pixels_tab[0][VAR_0])\nc->avg_2tap_qpel_pixels_tab[0][VAR_0]= c->avg_h264_qpel_pixels_tab[0][VAR_0];",
"}",
"ff_init_scantable_permutation(c->idct_permutation,\nc->idct_permutation_type);",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
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
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
251
],
[
253
],
[
257
],
[
263
],
[
265
],
[
269
],
[
275,
279,
281
],
[
283,
285,
287
],
[
289,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311,
313
],
[
315
],
[
319,
321
],
[
323
],
[
325,
327,
329,
331,
333,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347,
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371,
375
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
419
],
[
423
],
[
425
],
[
429,
431
],
[
433,
435,
437
],
[
439,
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
475
],
[
477
],
[
481
],
[
485
],
[
487
],
[
491,
493,
495,
497,
501,
503
],
[
505
],
[
507
],
[
509,
513,
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545,
551,
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571,
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585,
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611,
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
629
],
[
631,
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645,
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659,
661
],
[
663
],
[
665
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
689
],
[
691,
693
],
[
695,
697
],
[
699
],
[
703,
705
],
[
707
]
]
|
13,863 | static int mpc7_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb;
uint8_t *bits;
int i, ch;
int mb = -1;
Band *bands = c->bands;
int off;
int bits_used, bits_avail;
memset(bands, 0, sizeof(bands));
if(buf_size <= 4){
av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
}
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(buf + 4), (buf_size - 4) >> 2);
init_get_bits(&gb, bits, (buf_size - 4)* 8);
skip_bits_long(&gb, buf[0]);
/* read subband indexes */
for(i = 0; i <= c->maxbands; i++){
for(ch = 0; ch < 2; ch++){
int t = 4;
if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5;
if(t == 4) bands[i].res[ch] = get_bits(&gb, 4);
else bands[i].res[ch] = bands[i-1].res[ch] + t;
}
if(bands[i].res[0] || bands[i].res[1]){
mb = i;
if(c->MSS) bands[i].msf = get_bits1(&gb);
}
}
/* get scale indexes coding method */
for(i = 0; i <= mb; i++)
for(ch = 0; ch < 2; ch++)
if(bands[i].res[ch]) bands[i].scfi[ch] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1);
/* get scale indexes */
for(i = 0; i <= mb; i++){
for(ch = 0; ch < 2; ch++){
if(bands[i].res[ch]){
bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i];
bands[i].scf_idx[ch][0] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]);
switch(bands[i].scfi[ch]){
case 0:
bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
break;
case 1:
bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1];
break;
case 2:
bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
break;
case 3:
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
break;
}
c->oldDSCF[ch][i] = bands[i].scf_idx[ch][2];
}
}
}
/* get quantizers */
memset(c->Q, 0, sizeof(c->Q));
off = 0;
for(i = 0; i < BANDS; i++, off += SAMPLES_PER_BAND)
for(ch = 0; ch < 2; ch++)
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
ff_mpc_dequantize_and_synth(c, mb, data, 2);
av_free(bits);
bits_used = get_bits_count(&gb);
bits_avail = (buf_size - 4) * 8;
if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){
av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail);
return -1;
}
if(c->frames_to_skip){
c->frames_to_skip--;
*data_size = 0;
return buf_size;
}
*data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
return buf_size;
}
| false | FFmpeg | c8b5c4d27409dfdcec80868686b173ba446c998b | static int mpc7_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb;
uint8_t *bits;
int i, ch;
int mb = -1;
Band *bands = c->bands;
int off;
int bits_used, bits_avail;
memset(bands, 0, sizeof(bands));
if(buf_size <= 4){
av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
}
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(buf + 4), (buf_size - 4) >> 2);
init_get_bits(&gb, bits, (buf_size - 4)* 8);
skip_bits_long(&gb, buf[0]);
for(i = 0; i <= c->maxbands; i++){
for(ch = 0; ch < 2; ch++){
int t = 4;
if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5;
if(t == 4) bands[i].res[ch] = get_bits(&gb, 4);
else bands[i].res[ch] = bands[i-1].res[ch] + t;
}
if(bands[i].res[0] || bands[i].res[1]){
mb = i;
if(c->MSS) bands[i].msf = get_bits1(&gb);
}
}
for(i = 0; i <= mb; i++)
for(ch = 0; ch < 2; ch++)
if(bands[i].res[ch]) bands[i].scfi[ch] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1);
for(i = 0; i <= mb; i++){
for(ch = 0; ch < 2; ch++){
if(bands[i].res[ch]){
bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i];
bands[i].scf_idx[ch][0] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]);
switch(bands[i].scfi[ch]){
case 0:
bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
break;
case 1:
bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1];
break;
case 2:
bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
break;
case 3:
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
break;
}
c->oldDSCF[ch][i] = bands[i].scf_idx[ch][2];
}
}
}
memset(c->Q, 0, sizeof(c->Q));
off = 0;
for(i = 0; i < BANDS; i++, off += SAMPLES_PER_BAND)
for(ch = 0; ch < 2; ch++)
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
ff_mpc_dequantize_and_synth(c, mb, data, 2);
av_free(bits);
bits_used = get_bits_count(&gb);
bits_avail = (buf_size - 4) * 8;
if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){
av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail);
return -1;
}
if(c->frames_to_skip){
c->frames_to_skip--;
*data_size = 0;
return buf_size;
}
*data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
MPCContext *c = VAR_0->priv_data;
GetBitContext gb;
uint8_t *bits;
int VAR_6, VAR_7;
int VAR_8 = -1;
Band *bands = c->bands;
int VAR_9;
int VAR_10, VAR_11;
memset(bands, 0, sizeof(bands));
if(VAR_5 <= 4){
av_log(VAR_0, AV_LOG_ERROR, "Too small buffer passed (%VAR_6 bytes)\n", VAR_5);
}
bits = av_malloc(((VAR_5 - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(VAR_4 + 4), (VAR_5 - 4) >> 2);
init_get_bits(&gb, bits, (VAR_5 - 4)* 8);
skip_bits_long(&gb, VAR_4[0]);
for(VAR_6 = 0; VAR_6 <= c->maxbands; VAR_6++){
for(VAR_7 = 0; VAR_7 < 2; VAR_7++){
int t = 4;
if(VAR_6) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5;
if(t == 4) bands[VAR_6].res[VAR_7] = get_bits(&gb, 4);
else bands[VAR_6].res[VAR_7] = bands[VAR_6-1].res[VAR_7] + t;
}
if(bands[VAR_6].res[0] || bands[VAR_6].res[1]){
VAR_8 = VAR_6;
if(c->MSS) bands[VAR_6].msf = get_bits1(&gb);
}
}
for(VAR_6 = 0; VAR_6 <= VAR_8; VAR_6++)
for(VAR_7 = 0; VAR_7 < 2; VAR_7++)
if(bands[VAR_6].res[VAR_7]) bands[VAR_6].scfi[VAR_7] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1);
for(VAR_6 = 0; VAR_6 <= VAR_8; VAR_6++){
for(VAR_7 = 0; VAR_7 < 2; VAR_7++){
if(bands[VAR_6].res[VAR_7]){
bands[VAR_6].scf_idx[VAR_7][2] = c->oldDSCF[VAR_7][VAR_6];
bands[VAR_6].scf_idx[VAR_7][0] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][2]);
switch(bands[VAR_6].scfi[VAR_7]){
case 0:
bands[VAR_6].scf_idx[VAR_7][1] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][0]);
bands[VAR_6].scf_idx[VAR_7][2] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][1]);
break;
case 1:
bands[VAR_6].scf_idx[VAR_7][1] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][0]);
bands[VAR_6].scf_idx[VAR_7][2] = bands[VAR_6].scf_idx[VAR_7][1];
break;
case 2:
bands[VAR_6].scf_idx[VAR_7][1] = bands[VAR_6].scf_idx[VAR_7][0];
bands[VAR_6].scf_idx[VAR_7][2] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][1]);
break;
case 3:
bands[VAR_6].scf_idx[VAR_7][2] = bands[VAR_6].scf_idx[VAR_7][1] = bands[VAR_6].scf_idx[VAR_7][0];
break;
}
c->oldDSCF[VAR_7][VAR_6] = bands[VAR_6].scf_idx[VAR_7][2];
}
}
}
memset(c->Q, 0, sizeof(c->Q));
VAR_9 = 0;
for(VAR_6 = 0; VAR_6 < BANDS; VAR_6++, VAR_9 += SAMPLES_PER_BAND)
for(VAR_7 = 0; VAR_7 < 2; VAR_7++)
idx_to_quant(c, &gb, bands[VAR_6].res[VAR_7], c->Q[VAR_7] + VAR_9);
ff_mpc_dequantize_and_synth(c, VAR_8, VAR_1, 2);
av_free(bits);
VAR_10 = get_bits_count(&gb);
VAR_11 = (VAR_5 - 4) * 8;
if(!VAR_4[1] && ((VAR_11 < VAR_10) || (VAR_10 + 32 <= VAR_11))){
av_log(NULL,0, "Error decoding frame: used %VAR_6 of %VAR_6 bits\n", VAR_10, VAR_11);
return -1;
}
if(c->frames_to_skip){
c->frames_to_skip--;
*VAR_2 = 0;
return VAR_5;
}
*VAR_2 = (VAR_4[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext * VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MPCContext *c = VAR_0->priv_data;",
"GetBitContext gb;",
"uint8_t *bits;",
"int VAR_6, VAR_7;",
"int VAR_8 = -1;",
"Band *bands = c->bands;",
"int VAR_9;",
"int VAR_10, VAR_11;",
"memset(bands, 0, sizeof(bands));",
"if(VAR_5 <= 4){",
"av_log(VAR_0, AV_LOG_ERROR, \"Too small buffer passed (%VAR_6 bytes)\\n\", VAR_5);",
"}",
"bits = av_malloc(((VAR_5 - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);",
"c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(VAR_4 + 4), (VAR_5 - 4) >> 2);",
"init_get_bits(&gb, bits, (VAR_5 - 4)* 8);",
"skip_bits_long(&gb, VAR_4[0]);",
"for(VAR_6 = 0; VAR_6 <= c->maxbands; VAR_6++){",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++){",
"int t = 4;",
"if(VAR_6) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5;",
"if(t == 4) bands[VAR_6].res[VAR_7] = get_bits(&gb, 4);",
"else bands[VAR_6].res[VAR_7] = bands[VAR_6-1].res[VAR_7] + t;",
"}",
"if(bands[VAR_6].res[0] || bands[VAR_6].res[1]){",
"VAR_8 = VAR_6;",
"if(c->MSS) bands[VAR_6].msf = get_bits1(&gb);",
"}",
"}",
"for(VAR_6 = 0; VAR_6 <= VAR_8; VAR_6++)",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++)",
"if(bands[VAR_6].res[VAR_7]) bands[VAR_6].scfi[VAR_7] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1);",
"for(VAR_6 = 0; VAR_6 <= VAR_8; VAR_6++){",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++){",
"if(bands[VAR_6].res[VAR_7]){",
"bands[VAR_6].scf_idx[VAR_7][2] = c->oldDSCF[VAR_7][VAR_6];",
"bands[VAR_6].scf_idx[VAR_7][0] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][2]);",
"switch(bands[VAR_6].scfi[VAR_7]){",
"case 0:\nbands[VAR_6].scf_idx[VAR_7][1] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][0]);",
"bands[VAR_6].scf_idx[VAR_7][2] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][1]);",
"break;",
"case 1:\nbands[VAR_6].scf_idx[VAR_7][1] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][0]);",
"bands[VAR_6].scf_idx[VAR_7][2] = bands[VAR_6].scf_idx[VAR_7][1];",
"break;",
"case 2:\nbands[VAR_6].scf_idx[VAR_7][1] = bands[VAR_6].scf_idx[VAR_7][0];",
"bands[VAR_6].scf_idx[VAR_7][2] = get_scale_idx(&gb, bands[VAR_6].scf_idx[VAR_7][1]);",
"break;",
"case 3:\nbands[VAR_6].scf_idx[VAR_7][2] = bands[VAR_6].scf_idx[VAR_7][1] = bands[VAR_6].scf_idx[VAR_7][0];",
"break;",
"}",
"c->oldDSCF[VAR_7][VAR_6] = bands[VAR_6].scf_idx[VAR_7][2];",
"}",
"}",
"}",
"memset(c->Q, 0, sizeof(c->Q));",
"VAR_9 = 0;",
"for(VAR_6 = 0; VAR_6 < BANDS; VAR_6++, VAR_9 += SAMPLES_PER_BAND)",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++)",
"idx_to_quant(c, &gb, bands[VAR_6].res[VAR_7], c->Q[VAR_7] + VAR_9);",
"ff_mpc_dequantize_and_synth(c, VAR_8, VAR_1, 2);",
"av_free(bits);",
"VAR_10 = get_bits_count(&gb);",
"VAR_11 = (VAR_5 - 4) * 8;",
"if(!VAR_4[1] && ((VAR_11 < VAR_10) || (VAR_10 + 32 <= VAR_11))){",
"av_log(NULL,0, \"Error decoding frame: used %VAR_6 of %VAR_6 bits\\n\", VAR_10, VAR_11);",
"return -1;",
"}",
"if(c->frames_to_skip){",
"c->frames_to_skip--;",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"*VAR_2 = (VAR_4[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
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,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
]
]
|
13,864 | void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl,
int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize)
{
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int chroma = !(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + sl->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type
&& IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
// and left mb is in available to us
&& sl->left_type[LTOP]) {
/* First vertical edge is different in MBAFF frames
* There are 8 different bS to compute and 2 different Qp
*/
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(sl)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(sl) ? i>>2 : i&1;
int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(sl->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(sl) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
ff_tlog(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) ff_tlog(h->avctx, " bS[%d]:%d", i, bS[i]); ff_tlog(h->avctx, "\n"); }
if (MB_FIELD(sl)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize,
uvlinesize, mb_xy, mb_type, mvy_limit,
dir ? 0 : first_vertical_edge_done, a, b,
chroma, dir);
}
#else
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl,
int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize)
{
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int chroma = !(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + sl->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
&& IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
&& sl->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(sl)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(sl) ? i>>2 : i&1;
int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(sl->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(sl) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
ff_tlog(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) ff_tlog(h->avctx, " bS[%d]:%d", i, bS[i]); ff_tlog(h->avctx, "\n"); }
if (MB_FIELD(sl)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize,
uvlinesize, mb_xy, mb_type, mvy_limit,
dir ? 0 : first_vertical_edge_done, a, b,
chroma, dir);
}
#else
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const H264Context *VAR_0, H264SliceContext *VAR_1,
int VAR_2, int VAR_3,
uint8_t *VAR_4, uint8_t *VAR_5, uint8_t *VAR_6,
unsigned int VAR_7, unsigned int VAR_8)
{
const int VAR_9= VAR_2 + VAR_3*VAR_0->mb_stride;
const int VAR_10 = VAR_0->cur_pic.VAR_10[VAR_9];
const int VAR_11 = IS_INTERLACED(VAR_10) ? 2 : 4;
int VAR_12 = 0;
int VAR_13 = !(CONFIG_GRAY && (VAR_0->flags & AV_CODEC_FLAG_GRAY));
int VAR_14 = 6 * (VAR_0->sps.bit_depth_luma - 8);
int VAR_15 = 52 + VAR_1->slice_alpha_c0_offset - VAR_14;
int VAR_16 = 52 + VAR_1->slice_beta_offset - VAR_14;
if (FRAME_MBAFF(VAR_0)
&& IS_INTERLACED(VAR_10 ^ VAR_1->left_type[LTOP])
&& VAR_1->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int VAR_17[2];
int VAR_18[2];
int VAR_19[2];
int VAR_20, VAR_21, VAR_22;
int VAR_29;
VAR_12 = 1;
if( IS_INTRA(VAR_10) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t VAR_24[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *VAR_25= VAR_24[MB_FIELD(VAR_1)][VAR_3&1];
for( VAR_29 = 0; VAR_29 < 8; VAR_29++ ) {
int VAR_26= MB_FIELD(VAR_1) ? VAR_29>>2 : VAR_29&1;
int VAR_27 = VAR_1->left_mb_xy[LEFT(VAR_26)];
int VAR_28 = VAR_1->left_type[LEFT(VAR_26)];
if( IS_INTRA( VAR_28 ) )
bS[VAR_29] = 4;
else{
bS[VAR_29] = 1 + !!(VAR_1->non_zero_count_cache[12+8*(VAR_29>>1)] |
((!VAR_0->pps.cabac && IS_8x8DCT(VAR_28)) ?
(VAR_0->cbp_table[VAR_27] & (((MB_FIELD(VAR_1) ? (VAR_29&2) : (VAR_3&1)) ? 8 : 2) << 12))
:
VAR_0->non_zero_count[VAR_27][ VAR_25[VAR_29] ]));
}
}
}
VAR_20 = VAR_0->cur_pic.qscale_table[VAR_9];
VAR_21 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[0]];
VAR_22 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[1]];
VAR_17[0] = ( VAR_20 + VAR_21 + 1 ) >> 1;
VAR_18[0] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +
get_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;
VAR_19[0] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +
get_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;
VAR_17[1] = ( VAR_20 + VAR_22 + 1 ) >> 1;
VAR_18[1] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +
get_chroma_qp( VAR_0, 0, VAR_22 ) + 1 ) >> 1;
VAR_19[1] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +
get_chroma_qp( VAR_0, 1, VAR_22 ) + 1 ) >> 1;
ff_tlog(VAR_0->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", VAR_2, VAR_3, VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_19[0], VAR_19[1], VAR_7, VAR_8);
{ int VAR_29; for (VAR_29 = 0; VAR_29 < 8; VAR_29++) ff_tlog(VAR_0->avctx, " bS[%d]:%d", VAR_29, bS[VAR_29]); ff_tlog(VAR_0->avctx, "\n"); }
if (MB_FIELD(VAR_1)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_4 , VAR_7, bS , 1, VAR_17 [0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8* VAR_7, VAR_7, bS+4, 1, VAR_17 [1], VAR_15, VAR_16, 1 );
if (VAR_13){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );
} else if (CHROMA422(VAR_0)) {
filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1);
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6 + 4*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( VAR_0, VAR_4 , 2* VAR_7, bS , 2, VAR_17 [0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2* VAR_7, bS+1, 2, VAR_17 [1], VAR_15, VAR_16, 1 );
if (VAR_13){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7,
VAR_8, VAR_9, VAR_10, VAR_11,
dir ? 0 : VAR_12, VAR_15, VAR_16,
VAR_13, dir);
}
#else
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_15, VAR_16, VAR_13, 0);
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, 0, VAR_15, VAR_16, VAR_13, 1);
#endif
}
| [
"void FUNC_0(const H264Context *VAR_0, H264SliceContext *VAR_1,\nint VAR_2, int VAR_3,\nuint8_t *VAR_4, uint8_t *VAR_5, uint8_t *VAR_6,\nunsigned int VAR_7, unsigned int VAR_8)\n{",
"const int VAR_9= VAR_2 + VAR_3*VAR_0->mb_stride;",
"const int VAR_10 = VAR_0->cur_pic.VAR_10[VAR_9];",
"const int VAR_11 = IS_INTERLACED(VAR_10) ? 2 : 4;",
"int VAR_12 = 0;",
"int VAR_13 = !(CONFIG_GRAY && (VAR_0->flags & AV_CODEC_FLAG_GRAY));",
"int VAR_14 = 6 * (VAR_0->sps.bit_depth_luma - 8);",
"int VAR_15 = 52 + VAR_1->slice_alpha_c0_offset - VAR_14;",
"int VAR_16 = 52 + VAR_1->slice_beta_offset - VAR_14;",
"if (FRAME_MBAFF(VAR_0)\n&& IS_INTERLACED(VAR_10 ^ VAR_1->left_type[LTOP])\n&& VAR_1->left_type[LTOP]) {",
"DECLARE_ALIGNED(8, int16_t, bS)[8];",
"int VAR_17[2];",
"int VAR_18[2];",
"int VAR_19[2];",
"int VAR_20, VAR_21, VAR_22;",
"int VAR_29;",
"VAR_12 = 1;",
"if( IS_INTRA(VAR_10) ) {",
"AV_WN64A(&bS[0], 0x0004000400040004ULL);",
"AV_WN64A(&bS[4], 0x0004000400040004ULL);",
"} else {",
"static const uint8_t VAR_24[2][2][8]={",
"{",
"{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},",
"{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},",
"},{",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"}",
"};",
"const uint8_t *VAR_25= VAR_24[MB_FIELD(VAR_1)][VAR_3&1];",
"for( VAR_29 = 0; VAR_29 < 8; VAR_29++ ) {",
"int VAR_26= MB_FIELD(VAR_1) ? VAR_29>>2 : VAR_29&1;",
"int VAR_27 = VAR_1->left_mb_xy[LEFT(VAR_26)];",
"int VAR_28 = VAR_1->left_type[LEFT(VAR_26)];",
"if( IS_INTRA( VAR_28 ) )\nbS[VAR_29] = 4;",
"else{",
"bS[VAR_29] = 1 + !!(VAR_1->non_zero_count_cache[12+8*(VAR_29>>1)] |\n((!VAR_0->pps.cabac && IS_8x8DCT(VAR_28)) ?\n(VAR_0->cbp_table[VAR_27] & (((MB_FIELD(VAR_1) ? (VAR_29&2) : (VAR_3&1)) ? 8 : 2) << 12))\n:\nVAR_0->non_zero_count[VAR_27][ VAR_25[VAR_29] ]));",
"}",
"}",
"}",
"VAR_20 = VAR_0->cur_pic.qscale_table[VAR_9];",
"VAR_21 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[0]];",
"VAR_22 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[1]];",
"VAR_17[0] = ( VAR_20 + VAR_21 + 1 ) >> 1;",
"VAR_18[0] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +\nget_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;",
"VAR_19[0] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +\nget_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;",
"VAR_17[1] = ( VAR_20 + VAR_22 + 1 ) >> 1;",
"VAR_18[1] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +\nget_chroma_qp( VAR_0, 0, VAR_22 ) + 1 ) >> 1;",
"VAR_19[1] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +\nget_chroma_qp( VAR_0, 1, VAR_22 ) + 1 ) >> 1;",
"ff_tlog(VAR_0->avctx, \"filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d\", VAR_2, VAR_3, VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_19[0], VAR_19[1], VAR_7, VAR_8);",
"{ int VAR_29; for (VAR_29 = 0; VAR_29 < 8; VAR_29++) ff_tlog(VAR_0->avctx, \" bS[%d]:%d\", VAR_29, bS[VAR_29]); ff_tlog(VAR_0->avctx, \"\\n\"); }",
"if (MB_FIELD(VAR_1)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 , VAR_7, bS , 1, VAR_17 [0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8* VAR_7, VAR_7, bS+4, 1, VAR_17 [1], VAR_15, VAR_16, 1 );",
"if (VAR_13){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );",
"} else if (CHROMA422(VAR_0)) {",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1);",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6 + 4*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );",
"}",
"}",
"}else{",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 , 2* VAR_7, bS , 2, VAR_17 [0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2* VAR_7, bS+1, 2, VAR_17 [1], VAR_15, VAR_16, 1 );",
"if (VAR_13){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );",
"}",
"}",
"}",
"}",
"#if CONFIG_SMALL\n{",
"int dir;",
"for (dir = 0; dir < 2; dir++)",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7,\nVAR_8, VAR_9, VAR_10, VAR_11,\ndir ? 0 : VAR_12, VAR_15, VAR_16,\nVAR_13, dir);",
"}",
"#else\nfilter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_15, VAR_16, VAR_13, 0);",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, 0, VAR_15, VAR_16, VAR_13, 1);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
33,
37
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105,
107,
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
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
],
[
237,
239
],
[
241
],
[
243
],
[
245,
247,
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261,
263
]
]
|
13,865 | static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
{
int i;
writer_print_section_header(w, SECTION_ID_STREAMS);
for (i = 0; i < fmt_ctx->nb_streams; i++)
if (selected_streams[i])
show_stream(w, fmt_ctx, i, 0);
writer_print_section_footer(w);
}
| false | FFmpeg | e87190f5d20d380608f792ceb14d0def1d80e24b | static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
{
int i;
writer_print_section_header(w, SECTION_ID_STREAMS);
for (i = 0; i < fmt_ctx->nb_streams; i++)
if (selected_streams[i])
show_stream(w, fmt_ctx, i, 0);
writer_print_section_footer(w);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1)
{
int VAR_2;
writer_print_section_header(VAR_0, SECTION_ID_STREAMS);
for (VAR_2 = 0; VAR_2 < VAR_1->nb_streams; VAR_2++)
if (selected_streams[VAR_2])
show_stream(VAR_0, VAR_1, VAR_2, 0);
writer_print_section_footer(VAR_0);
}
| [
"static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1)\n{",
"int VAR_2;",
"writer_print_section_header(VAR_0, SECTION_ID_STREAMS);",
"for (VAR_2 = 0; VAR_2 < VAR_1->nb_streams; VAR_2++)",
"if (selected_streams[VAR_2])\nshow_stream(VAR_0, VAR_1, VAR_2, 0);",
"writer_print_section_footer(VAR_0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
]
]
|
13,866 | static av_always_inline void h264_loop_filter_strength_iteration_mmx2(int16_t bS[2][4][4], uint8_t nnz[40],
int8_t ref[2][40], int16_t mv[2][40][2],
int bidir, int edges, int step,
int mask_mv, int dir)
{
const x86_reg d_idx = dir ? -8 : -1;
DECLARE_ALIGNED(8, const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL;
int b_idx, edge;
for( b_idx=12, edge=0; edge<edges; edge+=step, b_idx+=8*step ) {
__asm__ volatile(
"pand %0, %%mm0 \n\t"
::"m"(mask_dir)
);
if(!(mask_mv & edge)) {
if(bidir) {
__asm__ volatile(
"movd (%1,%0), %%mm2 \n"
"punpckldq 40(%1,%0), %%mm2 \n" // { ref0[bn], ref1[bn] }
"pshufw $0x44, (%1), %%mm0 \n" // { ref0[b], ref0[b] }
"pshufw $0x44, 40(%1), %%mm1 \n" // { ref1[b], ref1[b] }
"pshufw $0x4E, %%mm2, %%mm3 \n"
"psubb %%mm2, %%mm0 \n" // { ref0[b]!=ref0[bn], ref0[b]!=ref1[bn] }
"psubb %%mm3, %%mm1 \n" // { ref1[b]!=ref1[bn], ref1[b]!=ref0[bn] }
"1: \n"
"por %%mm1, %%mm0 \n"
"movq (%2,%0,4), %%mm1 \n"
"movq 8(%2,%0,4), %%mm2 \n"
"movq %%mm1, %%mm3 \n"
"movq %%mm2, %%mm4 \n"
"psubw (%2), %%mm1 \n"
"psubw 8(%2), %%mm2 \n"
"psubw 160(%2), %%mm3 \n"
"psubw 168(%2), %%mm4 \n"
"packsswb %%mm2, %%mm1 \n"
"packsswb %%mm4, %%mm3 \n"
"paddb %%mm6, %%mm1 \n"
"paddb %%mm6, %%mm3 \n"
"psubusb %%mm5, %%mm1 \n" // abs(mv[b] - mv[bn]) >= limit
"psubusb %%mm5, %%mm3 \n"
"packsswb %%mm3, %%mm1 \n"
"add $40, %0 \n"
"cmp $40, %0 \n"
"jl 1b \n"
"sub $80, %0 \n"
"pshufw $0x4E, %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
"pshufw $0x4E, %%mm0, %%mm1 \n"
"pminub %%mm1, %%mm0 \n"
::"r"(d_idx),
"r"(ref[0]+b_idx),
"r"(mv[0]+b_idx)
);
} else {
__asm__ volatile(
"movd (%1), %%mm0 \n"
"psubb (%1,%0), %%mm0 \n" // ref[b] != ref[bn]
"movq (%2), %%mm1 \n"
"movq 8(%2), %%mm2 \n"
"psubw (%2,%0,4), %%mm1 \n"
"psubw 8(%2,%0,4), %%mm2 \n"
"packsswb %%mm2, %%mm1 \n"
"paddb %%mm6, %%mm1 \n"
"psubusb %%mm5, %%mm1 \n" // abs(mv[b] - mv[bn]) >= limit
"packsswb %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
::"r"(d_idx),
"r"(ref[0]+b_idx),
"r"(mv[0]+b_idx)
);
}
}
__asm__ volatile(
"movd %0, %%mm1 \n"
"por %1, %%mm1 \n" // nnz[b] || nnz[bn]
::"m"(nnz[b_idx]),
"m"(nnz[b_idx+d_idx])
);
__asm__ volatile(
"pminub %%mm7, %%mm1 \n"
"pminub %%mm7, %%mm0 \n"
"psllw $1, %%mm1 \n"
"pxor %%mm2, %%mm2 \n"
"pmaxub %%mm0, %%mm1 \n"
"punpcklbw %%mm2, %%mm1 \n"
"movq %%mm1, %0 \n"
:"=m"(*bS[dir][edge])
::"memory"
);
}
}
| false | FFmpeg | 2c3135f6d3faf764f5df364db00da1b2d4dcb097 | static av_always_inline void h264_loop_filter_strength_iteration_mmx2(int16_t bS[2][4][4], uint8_t nnz[40],
int8_t ref[2][40], int16_t mv[2][40][2],
int bidir, int edges, int step,
int mask_mv, int dir)
{
const x86_reg d_idx = dir ? -8 : -1;
DECLARE_ALIGNED(8, const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL;
int b_idx, edge;
for( b_idx=12, edge=0; edge<edges; edge+=step, b_idx+=8*step ) {
__asm__ volatile(
"pand %0, %%mm0 \n\t"
::"m"(mask_dir)
);
if(!(mask_mv & edge)) {
if(bidir) {
__asm__ volatile(
"movd (%1,%0), %%mm2 \n"
"punpckldq 40(%1,%0), %%mm2 \n"
"pshufw $0x44, (%1), %%mm0 \n"
"pshufw $0x44, 40(%1), %%mm1 \n"
"pshufw $0x4E, %%mm2, %%mm3 \n"
"psubb %%mm2, %%mm0 \n"
"psubb %%mm3, %%mm1 \n"
"1: \n"
"por %%mm1, %%mm0 \n"
"movq (%2,%0,4), %%mm1 \n"
"movq 8(%2,%0,4), %%mm2 \n"
"movq %%mm1, %%mm3 \n"
"movq %%mm2, %%mm4 \n"
"psubw (%2), %%mm1 \n"
"psubw 8(%2), %%mm2 \n"
"psubw 160(%2), %%mm3 \n"
"psubw 168(%2), %%mm4 \n"
"packsswb %%mm2, %%mm1 \n"
"packsswb %%mm4, %%mm3 \n"
"paddb %%mm6, %%mm1 \n"
"paddb %%mm6, %%mm3 \n"
"psubusb %%mm5, %%mm1 \n"
"psubusb %%mm5, %%mm3 \n"
"packsswb %%mm3, %%mm1 \n"
"add $40, %0 \n"
"cmp $40, %0 \n"
"jl 1b \n"
"sub $80, %0 \n"
"pshufw $0x4E, %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
"pshufw $0x4E, %%mm0, %%mm1 \n"
"pminub %%mm1, %%mm0 \n"
::"r"(d_idx),
"r"(ref[0]+b_idx),
"r"(mv[0]+b_idx)
);
} else {
__asm__ volatile(
"movd (%1), %%mm0 \n"
"psubb (%1,%0), %%mm0 \n"
"movq (%2), %%mm1 \n"
"movq 8(%2), %%mm2 \n"
"psubw (%2,%0,4), %%mm1 \n"
"psubw 8(%2,%0,4), %%mm2 \n"
"packsswb %%mm2, %%mm1 \n"
"paddb %%mm6, %%mm1 \n"
"psubusb %%mm5, %%mm1 \n"
"packsswb %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
::"r"(d_idx),
"r"(ref[0]+b_idx),
"r"(mv[0]+b_idx)
);
}
}
__asm__ volatile(
"movd %0, %%mm1 \n"
"por %1, %%mm1 \n"
::"m"(nnz[b_idx]),
"m"(nnz[b_idx+d_idx])
);
__asm__ volatile(
"pminub %%mm7, %%mm1 \n"
"pminub %%mm7, %%mm0 \n"
"psllw $1, %%mm1 \n"
"pxor %%mm2, %%mm2 \n"
"pmaxub %%mm0, %%mm1 \n"
"punpcklbw %%mm2, %%mm1 \n"
"movq %%mm1, %0 \n"
:"=m"(*bS[dir][edge])
::"memory"
);
}
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(int16_t bS[2][4][4], uint8_t nnz[40],
int8_t ref[2][40], int16_t mv[2][40][2],
int bidir, int edges, int step,
int mask_mv, int dir)
{
const x86_reg VAR_0 = dir ? -8 : -1;
DECLARE_ALIGNED(8, const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL;
int VAR_1, VAR_2;
for( VAR_1=12, VAR_2=0; VAR_2<edges; VAR_2+=step, VAR_1+=8*step ) {
__asm__ volatile(
"pand %0, %%mm0 \n\t"
::"m"(mask_dir)
);
if(!(mask_mv & VAR_2)) {
if(bidir) {
__asm__ volatile(
"movd (%1,%0), %%mm2 \n"
"punpckldq 40(%1,%0), %%mm2 \n"
"pshufw $0x44, (%1), %%mm0 \n"
"pshufw $0x44, 40(%1), %%mm1 \n"
"pshufw $0x4E, %%mm2, %%mm3 \n"
"psubb %%mm2, %%mm0 \n"
"psubb %%mm3, %%mm1 \n"
"1: \n"
"por %%mm1, %%mm0 \n"
"movq (%2,%0,4), %%mm1 \n"
"movq 8(%2,%0,4), %%mm2 \n"
"movq %%mm1, %%mm3 \n"
"movq %%mm2, %%mm4 \n"
"psubw (%2), %%mm1 \n"
"psubw 8(%2), %%mm2 \n"
"psubw 160(%2), %%mm3 \n"
"psubw 168(%2), %%mm4 \n"
"packsswb %%mm2, %%mm1 \n"
"packsswb %%mm4, %%mm3 \n"
"paddb %%mm6, %%mm1 \n"
"paddb %%mm6, %%mm3 \n"
"psubusb %%mm5, %%mm1 \n"
"psubusb %%mm5, %%mm3 \n"
"packsswb %%mm3, %%mm1 \n"
"add $40, %0 \n"
"cmp $40, %0 \n"
"jl 1b \n"
"sub $80, %0 \n"
"pshufw $0x4E, %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
"pshufw $0x4E, %%mm0, %%mm1 \n"
"pminub %%mm1, %%mm0 \n"
::"r"(VAR_0),
"r"(ref[0]+VAR_1),
"r"(mv[0]+VAR_1)
);
} else {
__asm__ volatile(
"movd (%1), %%mm0 \n"
"psubb (%1,%0), %%mm0 \n"
"movq (%2), %%mm1 \n"
"movq 8(%2), %%mm2 \n"
"psubw (%2,%0,4), %%mm1 \n"
"psubw 8(%2,%0,4), %%mm2 \n"
"packsswb %%mm2, %%mm1 \n"
"paddb %%mm6, %%mm1 \n"
"psubusb %%mm5, %%mm1 \n"
"packsswb %%mm1, %%mm1 \n"
"por %%mm1, %%mm0 \n"
::"r"(VAR_0),
"r"(ref[0]+VAR_1),
"r"(mv[0]+VAR_1)
);
}
}
__asm__ volatile(
"movd %0, %%mm1 \n"
"por %1, %%mm1 \n"
::"m"(nnz[VAR_1]),
"m"(nnz[VAR_1+VAR_0])
);
__asm__ volatile(
"pminub %%mm7, %%mm1 \n"
"pminub %%mm7, %%mm0 \n"
"psllw $1, %%mm1 \n"
"pxor %%mm2, %%mm2 \n"
"pmaxub %%mm0, %%mm1 \n"
"punpcklbw %%mm2, %%mm1 \n"
"movq %%mm1, %0 \n"
:"=m"(*bS[dir][VAR_2])
::"memory"
);
}
}
| [
"static av_always_inline void FUNC_0(int16_t bS[2][4][4], uint8_t nnz[40],\nint8_t ref[2][40], int16_t mv[2][40][2],\nint bidir, int edges, int step,\nint mask_mv, int dir)\n{",
"const x86_reg VAR_0 = dir ? -8 : -1;",
"DECLARE_ALIGNED(8, const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL;",
"int VAR_1, VAR_2;",
"for( VAR_1=12, VAR_2=0; VAR_2<edges; VAR_2+=step, VAR_1+=8*step ) {",
"__asm__ volatile(\n\"pand %0, %%mm0 \\n\\t\"\n::\"m\"(mask_dir)\n);",
"if(!(mask_mv & VAR_2)) {",
"if(bidir) {",
"__asm__ volatile(\n\"movd (%1,%0), %%mm2 \\n\"\n\"punpckldq 40(%1,%0), %%mm2 \\n\"\n\"pshufw $0x44, (%1), %%mm0 \\n\"\n\"pshufw $0x44, 40(%1), %%mm1 \\n\"\n\"pshufw $0x4E, %%mm2, %%mm3 \\n\"\n\"psubb %%mm2, %%mm0 \\n\"\n\"psubb %%mm3, %%mm1 \\n\"\n\"1: \\n\"\n\"por %%mm1, %%mm0 \\n\"\n\"movq (%2,%0,4), %%mm1 \\n\"\n\"movq 8(%2,%0,4), %%mm2 \\n\"\n\"movq %%mm1, %%mm3 \\n\"\n\"movq %%mm2, %%mm4 \\n\"\n\"psubw (%2), %%mm1 \\n\"\n\"psubw 8(%2), %%mm2 \\n\"\n\"psubw 160(%2), %%mm3 \\n\"\n\"psubw 168(%2), %%mm4 \\n\"\n\"packsswb %%mm2, %%mm1 \\n\"\n\"packsswb %%mm4, %%mm3 \\n\"\n\"paddb %%mm6, %%mm1 \\n\"\n\"paddb %%mm6, %%mm3 \\n\"\n\"psubusb %%mm5, %%mm1 \\n\"\n\"psubusb %%mm5, %%mm3 \\n\"\n\"packsswb %%mm3, %%mm1 \\n\"\n\"add $40, %0 \\n\"\n\"cmp $40, %0 \\n\"\n\"jl 1b \\n\"\n\"sub $80, %0 \\n\"\n\"pshufw $0x4E, %%mm1, %%mm1 \\n\"\n\"por %%mm1, %%mm0 \\n\"\n\"pshufw $0x4E, %%mm0, %%mm1 \\n\"\n\"pminub %%mm1, %%mm0 \\n\"\n::\"r\"(VAR_0),\n\"r\"(ref[0]+VAR_1),\n\"r\"(mv[0]+VAR_1)\n);",
"} else {",
"__asm__ volatile(\n\"movd (%1), %%mm0 \\n\"\n\"psubb (%1,%0), %%mm0 \\n\"\n\"movq (%2), %%mm1 \\n\"\n\"movq 8(%2), %%mm2 \\n\"\n\"psubw (%2,%0,4), %%mm1 \\n\"\n\"psubw 8(%2,%0,4), %%mm2 \\n\"\n\"packsswb %%mm2, %%mm1 \\n\"\n\"paddb %%mm6, %%mm1 \\n\"\n\"psubusb %%mm5, %%mm1 \\n\"\n\"packsswb %%mm1, %%mm1 \\n\"\n\"por %%mm1, %%mm0 \\n\"\n::\"r\"(VAR_0),\n\"r\"(ref[0]+VAR_1),\n\"r\"(mv[0]+VAR_1)\n);",
"}",
"}",
"__asm__ volatile(\n\"movd %0, %%mm1 \\n\"\n\"por %1, %%mm1 \\n\"\n::\"m\"(nnz[VAR_1]),\n\"m\"(nnz[VAR_1+VAR_0])\n);",
"__asm__ volatile(\n\"pminub %%mm7, %%mm1 \\n\"\n\"pminub %%mm7, %%mm0 \\n\"\n\"psllw $1, %%mm1 \\n\"\n\"pxor %%mm2, %%mm2 \\n\"\n\"pmaxub %%mm0, %%mm1 \\n\"\n\"punpcklbw %%mm2, %%mm1 \\n\"\n\"movq %%mm1, %0 \\n\"\n:\"=m\"(*bS[dir][VAR_2])\n::\"memory\"\n);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23,
25
],
[
27
],
[
29
],
[
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103
],
[
105
],
[
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137
],
[
139
],
[
141
],
[
143,
145,
147,
149,
151,
153
],
[
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175
],
[
177
],
[
179
]
]
|
13,868 | static void intra_predict_hor_dc_8x8_msa(uint8_t *src, int32_t stride)
{
uint8_t lp_cnt;
uint32_t src0 = 0, src1 = 0;
uint64_t out0, out1;
for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {
src0 += src[lp_cnt * stride - 1];
src1 += src[(4 + lp_cnt) * stride - 1];
}
src0 = (src0 + 2) >> 2;
src1 = (src1 + 2) >> 2;
out0 = src0 * 0x0101010101010101;
out1 = src1 * 0x0101010101010101;
for (lp_cnt = 4; lp_cnt--;) {
SD(out0, src);
SD(out1, (src + 4 * stride));
src += stride;
}
}
| false | FFmpeg | d6737539e77e78fca9a04914d51996cfd1ccc55c | static void intra_predict_hor_dc_8x8_msa(uint8_t *src, int32_t stride)
{
uint8_t lp_cnt;
uint32_t src0 = 0, src1 = 0;
uint64_t out0, out1;
for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {
src0 += src[lp_cnt * stride - 1];
src1 += src[(4 + lp_cnt) * stride - 1];
}
src0 = (src0 + 2) >> 2;
src1 = (src1 + 2) >> 2;
out0 = src0 * 0x0101010101010101;
out1 = src1 * 0x0101010101010101;
for (lp_cnt = 4; lp_cnt--;) {
SD(out0, src);
SD(out1, (src + 4 * stride));
src += stride;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1)
{
uint8_t lp_cnt;
uint32_t src0 = 0, src1 = 0;
uint64_t out0, out1;
for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {
src0 += VAR_0[lp_cnt * VAR_1 - 1];
src1 += VAR_0[(4 + lp_cnt) * VAR_1 - 1];
}
src0 = (src0 + 2) >> 2;
src1 = (src1 + 2) >> 2;
out0 = src0 * 0x0101010101010101;
out1 = src1 * 0x0101010101010101;
for (lp_cnt = 4; lp_cnt--;) {
SD(out0, VAR_0);
SD(out1, (VAR_0 + 4 * VAR_1));
VAR_0 += VAR_1;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1)\n{",
"uint8_t lp_cnt;",
"uint32_t src0 = 0, src1 = 0;",
"uint64_t out0, out1;",
"for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {",
"src0 += VAR_0[lp_cnt * VAR_1 - 1];",
"src1 += VAR_0[(4 + lp_cnt) * VAR_1 - 1];",
"}",
"src0 = (src0 + 2) >> 2;",
"src1 = (src1 + 2) >> 2;",
"out0 = src0 * 0x0101010101010101;",
"out1 = src1 * 0x0101010101010101;",
"for (lp_cnt = 4; lp_cnt--;) {",
"SD(out0, VAR_0);",
"SD(out1, (VAR_0 + 4 * VAR_1));",
"VAR_0 += VAR_1;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
]
|
13,870 | static int config_out_props(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
TInterlaceContext *tinterlace = ctx->priv;
int i;
tinterlace->vsub = desc->log2_chroma_h;
outlink->w = inlink->w;
outlink->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2?
inlink->h*2 : inlink->h;
if (tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2)
outlink->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio,
av_make_q(2, 1));
if (tinterlace->mode == MODE_PAD) {
uint8_t black[4] = { 16, 128, 128, 16 };
int i, ret;
if (ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts))
black[0] = black[3] = 0;
ret = av_image_alloc(tinterlace->black_data, tinterlace->black_linesize,
outlink->w, outlink->h, outlink->format, 16);
if (ret < 0)
return ret;
/* fill black picture with black */
for (i = 0; i < 4 && tinterlace->black_data[i]; i++) {
int h = i == 1 || i == 2 ? AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h) : outlink->h;
memset(tinterlace->black_data[i], black[i],
tinterlace->black_linesize[i] * h);
}
}
if ((tinterlace->flags & TINTERLACE_FLAG_VLPF
|| tinterlace->flags & TINTERLACE_FLAG_CVLPF)
&& !(tinterlace->mode == MODE_INTERLEAVE_TOP
|| tinterlace->mode == MODE_INTERLEAVE_BOTTOM)) {
av_log(ctx, AV_LOG_WARNING, "low_pass_filter flags ignored with mode %d\n",
tinterlace->mode);
tinterlace->flags &= ~TINTERLACE_FLAG_VLPF;
tinterlace->flags &= ~TINTERLACE_FLAG_CVLPF;
}
tinterlace->preout_time_base = inlink->time_base;
if (tinterlace->mode == MODE_INTERLACEX2) {
tinterlace->preout_time_base.den *= 2;
outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){2,1});
outlink->time_base = av_mul_q(inlink->time_base , (AVRational){1,2});
} else if (tinterlace->mode == MODE_MERGEX2) {
outlink->frame_rate = inlink->frame_rate;
outlink->time_base = inlink->time_base;
} else if (tinterlace->mode != MODE_PAD) {
outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){1,2});
outlink->time_base = av_mul_q(inlink->time_base , (AVRational){2,1});
}
for (i = 0; i<FF_ARRAY_ELEMS(standard_tbs); i++){
if (!av_cmp_q(standard_tbs[i], outlink->time_base))
break;
}
if (i == FF_ARRAY_ELEMS(standard_tbs) ||
(tinterlace->flags & TINTERLACE_FLAG_EXACT_TB))
outlink->time_base = tinterlace->preout_time_base;
if (tinterlace->flags & TINTERLACE_FLAG_CVLPF) {
tinterlace->lowpass_line = lowpass_line_complex_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
} else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {
tinterlace->lowpass_line = lowpass_line_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
}
av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
(tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" :
(tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off",
inlink->h, outlink->h);
return 0;
}
| false | FFmpeg | 3af1060319b46005dbfb3b01f9104539caf30146 | static int config_out_props(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
TInterlaceContext *tinterlace = ctx->priv;
int i;
tinterlace->vsub = desc->log2_chroma_h;
outlink->w = inlink->w;
outlink->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2?
inlink->h*2 : inlink->h;
if (tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2)
outlink->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio,
av_make_q(2, 1));
if (tinterlace->mode == MODE_PAD) {
uint8_t black[4] = { 16, 128, 128, 16 };
int i, ret;
if (ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts))
black[0] = black[3] = 0;
ret = av_image_alloc(tinterlace->black_data, tinterlace->black_linesize,
outlink->w, outlink->h, outlink->format, 16);
if (ret < 0)
return ret;
for (i = 0; i < 4 && tinterlace->black_data[i]; i++) {
int h = i == 1 || i == 2 ? AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h) : outlink->h;
memset(tinterlace->black_data[i], black[i],
tinterlace->black_linesize[i] * h);
}
}
if ((tinterlace->flags & TINTERLACE_FLAG_VLPF
|| tinterlace->flags & TINTERLACE_FLAG_CVLPF)
&& !(tinterlace->mode == MODE_INTERLEAVE_TOP
|| tinterlace->mode == MODE_INTERLEAVE_BOTTOM)) {
av_log(ctx, AV_LOG_WARNING, "low_pass_filter flags ignored with mode %d\n",
tinterlace->mode);
tinterlace->flags &= ~TINTERLACE_FLAG_VLPF;
tinterlace->flags &= ~TINTERLACE_FLAG_CVLPF;
}
tinterlace->preout_time_base = inlink->time_base;
if (tinterlace->mode == MODE_INTERLACEX2) {
tinterlace->preout_time_base.den *= 2;
outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){2,1});
outlink->time_base = av_mul_q(inlink->time_base , (AVRational){1,2});
} else if (tinterlace->mode == MODE_MERGEX2) {
outlink->frame_rate = inlink->frame_rate;
outlink->time_base = inlink->time_base;
} else if (tinterlace->mode != MODE_PAD) {
outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){1,2});
outlink->time_base = av_mul_q(inlink->time_base , (AVRational){2,1});
}
for (i = 0; i<FF_ARRAY_ELEMS(standard_tbs); i++){
if (!av_cmp_q(standard_tbs[i], outlink->time_base))
break;
}
if (i == FF_ARRAY_ELEMS(standard_tbs) ||
(tinterlace->flags & TINTERLACE_FLAG_EXACT_TB))
outlink->time_base = tinterlace->preout_time_base;
if (tinterlace->flags & TINTERLACE_FLAG_CVLPF) {
tinterlace->lowpass_line = lowpass_line_complex_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
} else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {
tinterlace->lowpass_line = lowpass_line_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
}
av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
(tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" :
(tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off",
inlink->h, outlink->h);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->src;
AVFilterLink *inlink = VAR_0->src->inputs[0];
const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->format);
TInterlaceContext *tinterlace = ctx->priv;
int VAR_3;
tinterlace->vsub = VAR_1->log2_chroma_h;
VAR_0->w = inlink->w;
VAR_0->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2?
inlink->h*2 : inlink->h;
if (tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2)
VAR_0->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio,
av_make_q(2, 1));
if (tinterlace->mode == MODE_PAD) {
uint8_t black[4] = { 16, 128, 128, 16 };
int VAR_3, VAR_3;
if (ff_fmt_is_in(VAR_0->format, full_scale_yuvj_pix_fmts))
black[0] = black[3] = 0;
VAR_3 = av_image_alloc(tinterlace->black_data, tinterlace->black_linesize,
VAR_0->w, VAR_0->h, VAR_0->format, 16);
if (VAR_3 < 0)
return VAR_3;
for (VAR_3 = 0; VAR_3 < 4 && tinterlace->black_data[VAR_3]; VAR_3++) {
int h = VAR_3 == 1 || VAR_3 == 2 ? AV_CEIL_RSHIFT(VAR_0->h, VAR_1->log2_chroma_h) : VAR_0->h;
memset(tinterlace->black_data[VAR_3], black[VAR_3],
tinterlace->black_linesize[VAR_3] * h);
}
}
if ((tinterlace->flags & TINTERLACE_FLAG_VLPF
|| tinterlace->flags & TINTERLACE_FLAG_CVLPF)
&& !(tinterlace->mode == MODE_INTERLEAVE_TOP
|| tinterlace->mode == MODE_INTERLEAVE_BOTTOM)) {
av_log(ctx, AV_LOG_WARNING, "low_pass_filter flags ignored with mode %d\n",
tinterlace->mode);
tinterlace->flags &= ~TINTERLACE_FLAG_VLPF;
tinterlace->flags &= ~TINTERLACE_FLAG_CVLPF;
}
tinterlace->preout_time_base = inlink->time_base;
if (tinterlace->mode == MODE_INTERLACEX2) {
tinterlace->preout_time_base.den *= 2;
VAR_0->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){2,1});
VAR_0->time_base = av_mul_q(inlink->time_base , (AVRational){1,2});
} else if (tinterlace->mode == MODE_MERGEX2) {
VAR_0->frame_rate = inlink->frame_rate;
VAR_0->time_base = inlink->time_base;
} else if (tinterlace->mode != MODE_PAD) {
VAR_0->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){1,2});
VAR_0->time_base = av_mul_q(inlink->time_base , (AVRational){2,1});
}
for (VAR_3 = 0; VAR_3<FF_ARRAY_ELEMS(standard_tbs); VAR_3++){
if (!av_cmp_q(standard_tbs[VAR_3], VAR_0->time_base))
break;
}
if (VAR_3 == FF_ARRAY_ELEMS(standard_tbs) ||
(tinterlace->flags & TINTERLACE_FLAG_EXACT_TB))
VAR_0->time_base = tinterlace->preout_time_base;
if (tinterlace->flags & TINTERLACE_FLAG_CVLPF) {
tinterlace->lowpass_line = lowpass_line_complex_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
} else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {
tinterlace->lowpass_line = lowpass_line_c;
if (ARCH_X86)
ff_tinterlace_init_x86(tinterlace);
}
av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
(tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" :
(tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off",
inlink->h, VAR_0->h);
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->src;",
"AVFilterLink *inlink = VAR_0->src->inputs[0];",
"const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->format);",
"TInterlaceContext *tinterlace = ctx->priv;",
"int VAR_3;",
"tinterlace->vsub = VAR_1->log2_chroma_h;",
"VAR_0->w = inlink->w;",
"VAR_0->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2?\ninlink->h*2 : inlink->h;",
"if (tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2)\nVAR_0->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio,\nav_make_q(2, 1));",
"if (tinterlace->mode == MODE_PAD) {",
"uint8_t black[4] = { 16, 128, 128, 16 };",
"int VAR_3, VAR_3;",
"if (ff_fmt_is_in(VAR_0->format, full_scale_yuvj_pix_fmts))\nblack[0] = black[3] = 0;",
"VAR_3 = av_image_alloc(tinterlace->black_data, tinterlace->black_linesize,\nVAR_0->w, VAR_0->h, VAR_0->format, 16);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"for (VAR_3 = 0; VAR_3 < 4 && tinterlace->black_data[VAR_3]; VAR_3++) {",
"int h = VAR_3 == 1 || VAR_3 == 2 ? AV_CEIL_RSHIFT(VAR_0->h, VAR_1->log2_chroma_h) : VAR_0->h;",
"memset(tinterlace->black_data[VAR_3], black[VAR_3],\ntinterlace->black_linesize[VAR_3] * h);",
"}",
"}",
"if ((tinterlace->flags & TINTERLACE_FLAG_VLPF\n|| tinterlace->flags & TINTERLACE_FLAG_CVLPF)\n&& !(tinterlace->mode == MODE_INTERLEAVE_TOP\n|| tinterlace->mode == MODE_INTERLEAVE_BOTTOM)) {",
"av_log(ctx, AV_LOG_WARNING, \"low_pass_filter flags ignored with mode %d\\n\",\ntinterlace->mode);",
"tinterlace->flags &= ~TINTERLACE_FLAG_VLPF;",
"tinterlace->flags &= ~TINTERLACE_FLAG_CVLPF;",
"}",
"tinterlace->preout_time_base = inlink->time_base;",
"if (tinterlace->mode == MODE_INTERLACEX2) {",
"tinterlace->preout_time_base.den *= 2;",
"VAR_0->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){2,1});",
"VAR_0->time_base = av_mul_q(inlink->time_base , (AVRational){1,2});",
"} else if (tinterlace->mode == MODE_MERGEX2) {",
"VAR_0->frame_rate = inlink->frame_rate;",
"VAR_0->time_base = inlink->time_base;",
"} else if (tinterlace->mode != MODE_PAD) {",
"VAR_0->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){1,2});",
"VAR_0->time_base = av_mul_q(inlink->time_base , (AVRational){2,1});",
"}",
"for (VAR_3 = 0; VAR_3<FF_ARRAY_ELEMS(standard_tbs); VAR_3++){",
"if (!av_cmp_q(standard_tbs[VAR_3], VAR_0->time_base))\nbreak;",
"}",
"if (VAR_3 == FF_ARRAY_ELEMS(standard_tbs) ||\n(tinterlace->flags & TINTERLACE_FLAG_EXACT_TB))\nVAR_0->time_base = tinterlace->preout_time_base;",
"if (tinterlace->flags & TINTERLACE_FLAG_CVLPF) {",
"tinterlace->lowpass_line = lowpass_line_complex_c;",
"if (ARCH_X86)\nff_tinterlace_init_x86(tinterlace);",
"} else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {",
"tinterlace->lowpass_line = lowpass_line_c;",
"if (ARCH_X86)\nff_tinterlace_init_x86(tinterlace);",
"}",
"av_log(ctx, AV_LOG_VERBOSE, \"mode:%d filter:%s h:%d -> h:%d\\n\", tinterlace->mode,\n(tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? \"complex\" :\n(tinterlace->flags & TINTERLACE_FLAG_VLPF) ? \"linear\" : \"off\",\ninlink->h, VAR_0->h);",
"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
],
[
19
],
[
21,
23
],
[
25,
27,
29
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
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
],
[
111
],
[
113,
115
],
[
117
],
[
119,
121,
123
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
147,
149,
151,
153
],
[
157
],
[
159
]
]
|
13,871 | static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
const int filter_p1, const int filter_q1,
const int alpha, const int beta,
const int lim_p0q0, const int lim_q1,
const int lim_p1)
{
rv40_weak_loop_filter(src, 1, stride, filter_p1, filter_q1,
alpha, beta, lim_p0q0, lim_q1, lim_p1);
}
| true | FFmpeg | 3ab9a2a5577d445252724af4067d2a7c8a378efa | static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
const int filter_p1, const int filter_q1,
const int alpha, const int beta,
const int lim_p0q0, const int lim_q1,
const int lim_p1)
{
rv40_weak_loop_filter(src, 1, stride, filter_p1, filter_q1,
alpha, beta, lim_p0q0, lim_q1, lim_p1);
}
| {
"code": [
"static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,"
],
"line_no": [
1
]
} | static void FUNC_0(uint8_t *VAR_0, const int VAR_1,
const int VAR_2, const int VAR_3,
const int VAR_4, const int VAR_5,
const int VAR_6, const int VAR_7,
const int VAR_8)
{
rv40_weak_loop_filter(VAR_0, 1, VAR_1, VAR_2, VAR_3,
VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);
}
| [
"static void FUNC_0(uint8_t *VAR_0, const int VAR_1,\nconst int VAR_2, const int VAR_3,\nconst int VAR_4, const int VAR_5,\nconst int VAR_6, const int VAR_7,\nconst int VAR_8)\n{",
"rv40_weak_loop_filter(VAR_0, 1, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_5, VAR_6, VAR_7, VAR_8);",
"}"
]
| [
1,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
17
]
]
|
13,872 | static int open_output_file(OptionsContext *o, const char *filename)
{
AVFormatContext *oc;
int i, j, err;
AVOutputFormat *file_oformat;
OutputFile *of;
OutputStream *ost;
InputStream *ist;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
o->stop_time = INT64_MAX;
av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
}
if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time;
if (o->stop_time <= start_time) {
av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
exit_program(1);
} else {
o->recording_time = o->stop_time - start_time;
}
}
GROW_ARRAY(output_files, nb_output_files);
of = av_mallocz(sizeof(*of));
if (!of)
exit_program(1);
output_files[nb_output_files - 1] = of;
of->ost_index = nb_output_streams;
of->recording_time = o->recording_time;
of->start_time = o->start_time;
of->limit_filesize = o->limit_filesize;
of->shortest = o->shortest;
av_dict_copy(&of->opts, o->g->format_opts, 0);
if (!strcmp(filename, "-"))
filename = "pipe:";
err = avformat_alloc_output_context2(&oc, NULL, o->format, filename);
if (!oc) {
print_error(filename, err);
exit_program(1);
}
of->ctx = oc;
if (o->recording_time != INT64_MAX)
oc->duration = o->recording_time;
file_oformat= oc->oformat;
oc->interrupt_callback = int_cb;
/* create streams for all unlabeled output pads */
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
for (j = 0; j < fg->nb_outputs; j++) {
OutputFilter *ofilter = fg->outputs[j];
if (!ofilter->out_tmp || ofilter->out_tmp->name)
continue;
switch (ofilter->type) {
case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break;
case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break;
case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
}
init_output_filter(ofilter, o, oc);
}
}
/* ffserver seeking with date=... needs a date reference */
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
int err = parse_option(o, "metadata", "creation_time=now", options);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
}
if (!strcmp(file_oformat->name, "ffm") && !override_ffserver &&
av_strstart(filename, "http:", NULL)) {
int j;
/* special case for files sent to ffserver: we get the stream
parameters from ffserver */
int err = read_ffserver_streams(o, oc, filename);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) {
ost = output_streams[j];
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
if(ist->st->codec->codec_type == ost->st->codec->codec_type){
ost->sync_ist= ist;
ost->source_index= i;
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
ist->discard = 0;
ist->st->discard = ist->user_set_discard;
break;
}
}
if(!ost->sync_ist){
av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
exit_program(1);
}
}
} else if (!o->nb_stream_maps) {
char *subtitle_codec_name = NULL;
/* pick the "best" stream of each type */
/* video: highest resolution */
if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
int area = 0, idx = -1;
int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
for (i = 0; i < nb_input_streams; i++) {
int new_area;
ist = input_streams[i];
new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
new_area = 1;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
new_area > area) {
if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
continue;
area = new_area;
idx = i;
}
}
if (idx >= 0)
new_video_stream(o, oc, idx);
}
/* audio: most channels */
if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) {
int best_score = 0, idx = -1;
for (i = 0; i < nb_input_streams; i++) {
int score;
ist = input_streams[i];
score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
score > best_score) {
best_score = score;
idx = i;
}
}
if (idx >= 0)
new_audio_stream(o, oc, idx);
}
/* subtitles: pick first */
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
for (i = 0; i < nb_input_streams; i++)
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
AVCodecDescriptor const *input_descriptor =
avcodec_descriptor_get(input_streams[i]->st->codec->codec_id);
AVCodecDescriptor const *output_descriptor = NULL;
AVCodec const *output_codec =
avcodec_find_encoder(oc->oformat->subtitle_codec);
int input_props = 0, output_props = 0;
if (output_codec)
output_descriptor = avcodec_descriptor_get(output_codec->id);
if (input_descriptor)
input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (output_descriptor)
output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (subtitle_codec_name ||
input_props & output_props ||
// Map dvb teletext which has neither property to any output subtitle encoder
input_descriptor && output_descriptor &&
(!input_descriptor->props ||
!output_descriptor->props)) {
new_subtitle_stream(o, oc, i);
break;
}
}
}
/* Data only if codec id match */
if (!o->data_disable ) {
enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_DATA
&& input_streams[i]->st->codec->codec_id == codec_id )
new_data_stream(o, oc, i);
}
}
} else {
for (i = 0; i < o->nb_stream_maps; i++) {
StreamMap *map = &o->stream_maps[i];
if (map->disabled)
continue;
if (map->linklabel) {
FilterGraph *fg;
OutputFilter *ofilter = NULL;
int j, k;
for (j = 0; j < nb_filtergraphs; j++) {
fg = filtergraphs[j];
for (k = 0; k < fg->nb_outputs; k++) {
AVFilterInOut *out = fg->outputs[k]->out_tmp;
if (out && !strcmp(out->name, map->linklabel)) {
ofilter = fg->outputs[k];
goto loop_end;
}
}
}
loop_end:
if (!ofilter) {
av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
"in any defined filter graph, or was already used elsewhere.\n", map->linklabel);
exit_program(1);
}
init_output_filter(ofilter, o, oc);
} else {
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
continue;
if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
continue;
if(o-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
continue;
if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
continue;
ost = NULL;
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break;
case AVMEDIA_TYPE_UNKNOWN:
if (copy_unknown_streams) {
ost = new_unknown_stream (o, oc, src_idx);
break;
}
default:
av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL,
"Cannot map stream #%d:%d - unsupported type.\n",
map->file_index, map->stream_index);
if (!ignore_unknown_streams) {
av_log(NULL, AV_LOG_FATAL,
"If you want unsupported types ignored instead "
"of failing, please use the -ignore_unknown option\n"
"If you want them copied, please use -copy_unknown\n");
exit_program(1);
}
}
if (ost)
ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index
+ map->sync_stream_index];
}
}
}
/* handle attached files */
for (i = 0; i < o->nb_attachments; i++) {
AVIOContext *pb;
uint8_t *attachment;
const char *p;
int64_t len;
if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
o->attachments[i]);
exit_program(1);
}
if ((len = avio_size(pb)) <= 0) {
av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n",
o->attachments[i]);
exit_program(1);
}
if (!(attachment = av_malloc(len))) {
av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n",
o->attachments[i]);
exit_program(1);
}
avio_read(pb, attachment, len);
ost = new_attachment_stream(o, oc, -1);
ost->stream_copy = 1;
ost->attachment_filename = o->attachments[i];
ost->finished = 1;
ost->st->codec->extradata = attachment;
ost->st->codec->extradata_size = len;
p = strrchr(o->attachments[i], '/');
av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
avio_closep(&pb);
}
for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
AVDictionaryEntry *e;
ost = output_streams[i];
if ((ost->stream_copy || ost->attachment_filename)
&& (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
&& (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
exit_program(1);
}
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, nb_output_files - 1, oc->filename, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
exit_program(1);
}
/* check if all codec options have been used */
unused_opts = strip_specifiers(o->g->codec_opts);
for (i = of->ost_index; i < nb_output_streams; i++) {
e = NULL;
while ((e = av_dict_get(output_streams[i]->encoder_opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
const AVClass *fclass = avformat_get_class();
const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option || foption)
continue;
if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) is not an encoding option.\n", e->key,
option->help ? option->help : "", nb_output_files - 1,
filename);
exit_program(1);
}
// gop_timecode is injected by generic code but not always used
if (!strcmp(e->key, "gop_timecode"))
continue;
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some encoder "
"which was not actually used for any stream.\n", e->key,
option->help ? option->help : "", nb_output_files - 1, filename);
}
av_dict_free(&unused_opts);
/* set the encoding/decoding_needed flags */
for (i = of->ost_index; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
ost->encoding_needed = !ost->stream_copy;
if (ost->encoding_needed && ost->source_index >= 0) {
InputStream *ist = input_streams[ost->source_index];
ist->decoding_needed |= DECODING_FOR_OST;
}
}
/* check filename in case of an image number is expected */
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
print_error(oc->filename, AVERROR(EINVAL));
exit_program(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {
av_log(NULL, AV_LOG_ERROR,
"No input streams but output needs an input stream\n");
exit_program(1);
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
/* test if it already exists to avoid losing precious files */
assert_file_overwrite(filename);
/* open the file */
if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
&oc->interrupt_callback,
&of->opts)) < 0) {
print_error(filename, err);
exit_program(1);
}
} else if (strcmp(oc->oformat->name, "image2")==0 && !av_filename_number_test(filename))
assert_file_overwrite(filename);
if (o->mux_preload) {
av_dict_set_int(&of->opts, "preload", o->mux_preload*AV_TIME_BASE, 0);
}
oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
/* copy metadata */
for (i = 0; i < o->nb_metadata_map; i++) {
char *p;
int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0);
if (in_file_index >= nb_input_files) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index);
exit_program(1);
}
copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc,
in_file_index >= 0 ?
input_files[in_file_index]->ctx : NULL, o);
}
/* copy chapters */
if (o->chapters_input_file >= nb_input_files) {
if (o->chapters_input_file == INT_MAX) {
/* copy chapters from the first input file that has them*/
o->chapters_input_file = -1;
for (i = 0; i < nb_input_files; i++)
if (input_files[i]->ctx->nb_chapters) {
o->chapters_input_file = i;
break;
}
} else {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n",
o->chapters_input_file);
exit_program(1);
}
}
if (o->chapters_input_file >= 0)
copy_chapters(input_files[o->chapters_input_file], of,
!o->metadata_chapters_manual);
/* copy global metadata by default */
if (!o->metadata_global_manual && nb_input_files){
av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
AV_DICT_DONT_OVERWRITE);
if(o->recording_time != INT64_MAX)
av_dict_set(&oc->metadata, "duration", NULL, 0);
av_dict_set(&oc->metadata, "creation_time", NULL, 0);
}
if (!o->metadata_streams_manual)
for (i = of->ost_index; i < nb_output_streams; i++) {
InputStream *ist;
if (output_streams[i]->source_index < 0) /* this is true e.g. for attached files */
continue;
ist = input_streams[output_streams[i]->source_index];
av_dict_copy(&output_streams[i]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
if (!output_streams[i]->stream_copy) {
av_dict_set(&output_streams[i]->st->metadata, "encoder", NULL, 0);
if (ist->autorotate)
av_dict_set(&output_streams[i]->st->metadata, "rotate", NULL, 0);
}
}
/* process manually set programs */
for (i = 0; i < o->nb_program; i++) {
const char *p = o->program[i].u.str;
int progid = i+1;
AVProgram *program;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key || !*p2)
break;
p2++;
if (!strcmp(key, "program_num"))
progid = strtol(p2, NULL, 0);
}
program = av_new_program(oc, progid);
p = o->program[i].u.str;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key) {
av_log(NULL, AV_LOG_FATAL,
"No '=' character in program string %s.\n",
p2);
exit_program(1);
}
if (!*p2)
exit_program(1);
p2++;
if (!strcmp(key, "title")) {
av_dict_set(&program->metadata, "title", p2, 0);
} else if (!strcmp(key, "program_num")) {
} else if (!strcmp(key, "st")) {
int st_num = strtol(p2, NULL, 0);
av_program_add_stream_index(oc, progid, st_num);
} else {
av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
exit_program(1);
}
}
}
/* process manually set metadata */
for (i = 0; i < o->nb_metadata; i++) {
AVDictionary **m;
char type, *val;
const char *stream_spec;
int index = 0, j, ret = 0;
char now_time[256];
val = strchr(o->metadata[i].u.str, '=');
if (!val) {
av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n",
o->metadata[i].u.str);
exit_program(1);
}
*val++ = 0;
if (!strcmp(o->metadata[i].u.str, "creation_time") &&
!strcmp(val, "now")) {
time_t now = time(0);
struct tm *ptm, tmbuf;
ptm = localtime_r(&now, &tmbuf);
if (ptm) {
if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm))
val = now_time;
}
}
parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec);
if (type == 's') {
for (j = 0; j < oc->nb_streams; j++) {
ost = output_streams[nb_output_streams - oc->nb_streams + j];
if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {
av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);
if (!strcmp(o->metadata[i].u.str, "rotate")) {
ost->rotate_overridden = 1;
}
} else if (ret < 0)
exit_program(1);
}
}
else {
switch (type) {
case 'g':
m = &oc->metadata;
break;
case 'c':
if (index < 0 || index >= oc->nb_chapters) {
av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->chapters[index]->metadata;
break;
case 'p':
if (index < 0 || index >= oc->nb_programs) {
av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->programs[index]->metadata;
break;
default:
av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier);
exit_program(1);
}
av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0);
}
}
return 0;
}
| true | FFmpeg | a25c5dbb5ee0f54c474d9caf43359cd0f61ae1bf | static int open_output_file(OptionsContext *o, const char *filename)
{
AVFormatContext *oc;
int i, j, err;
AVOutputFormat *file_oformat;
OutputFile *of;
OutputStream *ost;
InputStream *ist;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
o->stop_time = INT64_MAX;
av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
}
if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time;
if (o->stop_time <= start_time) {
av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
exit_program(1);
} else {
o->recording_time = o->stop_time - start_time;
}
}
GROW_ARRAY(output_files, nb_output_files);
of = av_mallocz(sizeof(*of));
if (!of)
exit_program(1);
output_files[nb_output_files - 1] = of;
of->ost_index = nb_output_streams;
of->recording_time = o->recording_time;
of->start_time = o->start_time;
of->limit_filesize = o->limit_filesize;
of->shortest = o->shortest;
av_dict_copy(&of->opts, o->g->format_opts, 0);
if (!strcmp(filename, "-"))
filename = "pipe:";
err = avformat_alloc_output_context2(&oc, NULL, o->format, filename);
if (!oc) {
print_error(filename, err);
exit_program(1);
}
of->ctx = oc;
if (o->recording_time != INT64_MAX)
oc->duration = o->recording_time;
file_oformat= oc->oformat;
oc->interrupt_callback = int_cb;
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
for (j = 0; j < fg->nb_outputs; j++) {
OutputFilter *ofilter = fg->outputs[j];
if (!ofilter->out_tmp || ofilter->out_tmp->name)
continue;
switch (ofilter->type) {
case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break;
case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break;
case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
}
init_output_filter(ofilter, o, oc);
}
}
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
int err = parse_option(o, "metadata", "creation_time=now", options);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
}
if (!strcmp(file_oformat->name, "ffm") && !override_ffserver &&
av_strstart(filename, "http:", NULL)) {
int j;
int err = read_ffserver_streams(o, oc, filename);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) {
ost = output_streams[j];
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
if(ist->st->codec->codec_type == ost->st->codec->codec_type){
ost->sync_ist= ist;
ost->source_index= i;
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
ist->discard = 0;
ist->st->discard = ist->user_set_discard;
break;
}
}
if(!ost->sync_ist){
av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
exit_program(1);
}
}
} else if (!o->nb_stream_maps) {
char *subtitle_codec_name = NULL;
if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
int area = 0, idx = -1;
int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
for (i = 0; i < nb_input_streams; i++) {
int new_area;
ist = input_streams[i];
new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
new_area = 1;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
new_area > area) {
if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
continue;
area = new_area;
idx = i;
}
}
if (idx >= 0)
new_video_stream(o, oc, idx);
}
if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) {
int best_score = 0, idx = -1;
for (i = 0; i < nb_input_streams; i++) {
int score;
ist = input_streams[i];
score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
score > best_score) {
best_score = score;
idx = i;
}
}
if (idx >= 0)
new_audio_stream(o, oc, idx);
}
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
for (i = 0; i < nb_input_streams; i++)
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
AVCodecDescriptor const *input_descriptor =
avcodec_descriptor_get(input_streams[i]->st->codec->codec_id);
AVCodecDescriptor const *output_descriptor = NULL;
AVCodec const *output_codec =
avcodec_find_encoder(oc->oformat->subtitle_codec);
int input_props = 0, output_props = 0;
if (output_codec)
output_descriptor = avcodec_descriptor_get(output_codec->id);
if (input_descriptor)
input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (output_descriptor)
output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (subtitle_codec_name ||
input_props & output_props ||
input_descriptor && output_descriptor &&
(!input_descriptor->props ||
!output_descriptor->props)) {
new_subtitle_stream(o, oc, i);
break;
}
}
}
if (!o->data_disable ) {
enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_DATA
&& input_streams[i]->st->codec->codec_id == codec_id )
new_data_stream(o, oc, i);
}
}
} else {
for (i = 0; i < o->nb_stream_maps; i++) {
StreamMap *map = &o->stream_maps[i];
if (map->disabled)
continue;
if (map->linklabel) {
FilterGraph *fg;
OutputFilter *ofilter = NULL;
int j, k;
for (j = 0; j < nb_filtergraphs; j++) {
fg = filtergraphs[j];
for (k = 0; k < fg->nb_outputs; k++) {
AVFilterInOut *out = fg->outputs[k]->out_tmp;
if (out && !strcmp(out->name, map->linklabel)) {
ofilter = fg->outputs[k];
goto loop_end;
}
}
}
loop_end:
if (!ofilter) {
av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
"in any defined filter graph, or was already used elsewhere.\n", map->linklabel);
exit_program(1);
}
init_output_filter(ofilter, o, oc);
} else {
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
continue;
if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
continue;
if(o-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
continue;
if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
continue;
ost = NULL;
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break;
case AVMEDIA_TYPE_UNKNOWN:
if (copy_unknown_streams) {
ost = new_unknown_stream (o, oc, src_idx);
break;
}
default:
av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL,
"Cannot map stream #%d:%d - unsupported type.\n",
map->file_index, map->stream_index);
if (!ignore_unknown_streams) {
av_log(NULL, AV_LOG_FATAL,
"If you want unsupported types ignored instead "
"of failing, please use the -ignore_unknown option\n"
"If you want them copied, please use -copy_unknown\n");
exit_program(1);
}
}
if (ost)
ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index
+ map->sync_stream_index];
}
}
}
for (i = 0; i < o->nb_attachments; i++) {
AVIOContext *pb;
uint8_t *attachment;
const char *p;
int64_t len;
if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
o->attachments[i]);
exit_program(1);
}
if ((len = avio_size(pb)) <= 0) {
av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n",
o->attachments[i]);
exit_program(1);
}
if (!(attachment = av_malloc(len))) {
av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n",
o->attachments[i]);
exit_program(1);
}
avio_read(pb, attachment, len);
ost = new_attachment_stream(o, oc, -1);
ost->stream_copy = 1;
ost->attachment_filename = o->attachments[i];
ost->finished = 1;
ost->st->codec->extradata = attachment;
ost->st->codec->extradata_size = len;
p = strrchr(o->attachments[i], '/');
av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
avio_closep(&pb);
}
for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) {
AVDictionaryEntry *e;
ost = output_streams[i];
if ((ost->stream_copy || ost->attachment_filename)
&& (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
&& (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
exit_program(1);
}
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, nb_output_files - 1, oc->filename, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
exit_program(1);
}
unused_opts = strip_specifiers(o->g->codec_opts);
for (i = of->ost_index; i < nb_output_streams; i++) {
e = NULL;
while ((e = av_dict_get(output_streams[i]->encoder_opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
const AVClass *fclass = avformat_get_class();
const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option || foption)
continue;
if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) is not an encoding option.\n", e->key,
option->help ? option->help : "", nb_output_files - 1,
filename);
exit_program(1);
}
if (!strcmp(e->key, "gop_timecode"))
continue;
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some encoder "
"which was not actually used for any stream.\n", e->key,
option->help ? option->help : "", nb_output_files - 1, filename);
}
av_dict_free(&unused_opts);
for (i = of->ost_index; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
ost->encoding_needed = !ost->stream_copy;
if (ost->encoding_needed && ost->source_index >= 0) {
InputStream *ist = input_streams[ost->source_index];
ist->decoding_needed |= DECODING_FOR_OST;
}
}
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
print_error(oc->filename, AVERROR(EINVAL));
exit_program(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {
av_log(NULL, AV_LOG_ERROR,
"No input streams but output needs an input stream\n");
exit_program(1);
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
assert_file_overwrite(filename);
if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
&oc->interrupt_callback,
&of->opts)) < 0) {
print_error(filename, err);
exit_program(1);
}
} else if (strcmp(oc->oformat->name, "image2")==0 && !av_filename_number_test(filename))
assert_file_overwrite(filename);
if (o->mux_preload) {
av_dict_set_int(&of->opts, "preload", o->mux_preload*AV_TIME_BASE, 0);
}
oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
for (i = 0; i < o->nb_metadata_map; i++) {
char *p;
int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0);
if (in_file_index >= nb_input_files) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index);
exit_program(1);
}
copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc,
in_file_index >= 0 ?
input_files[in_file_index]->ctx : NULL, o);
}
if (o->chapters_input_file >= nb_input_files) {
if (o->chapters_input_file == INT_MAX) {
o->chapters_input_file = -1;
for (i = 0; i < nb_input_files; i++)
if (input_files[i]->ctx->nb_chapters) {
o->chapters_input_file = i;
break;
}
} else {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n",
o->chapters_input_file);
exit_program(1);
}
}
if (o->chapters_input_file >= 0)
copy_chapters(input_files[o->chapters_input_file], of,
!o->metadata_chapters_manual);
if (!o->metadata_global_manual && nb_input_files){
av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
AV_DICT_DONT_OVERWRITE);
if(o->recording_time != INT64_MAX)
av_dict_set(&oc->metadata, "duration", NULL, 0);
av_dict_set(&oc->metadata, "creation_time", NULL, 0);
}
if (!o->metadata_streams_manual)
for (i = of->ost_index; i < nb_output_streams; i++) {
InputStream *ist;
if (output_streams[i]->source_index < 0)
continue;
ist = input_streams[output_streams[i]->source_index];
av_dict_copy(&output_streams[i]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
if (!output_streams[i]->stream_copy) {
av_dict_set(&output_streams[i]->st->metadata, "encoder", NULL, 0);
if (ist->autorotate)
av_dict_set(&output_streams[i]->st->metadata, "rotate", NULL, 0);
}
}
for (i = 0; i < o->nb_program; i++) {
const char *p = o->program[i].u.str;
int progid = i+1;
AVProgram *program;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key || !*p2)
break;
p2++;
if (!strcmp(key, "program_num"))
progid = strtol(p2, NULL, 0);
}
program = av_new_program(oc, progid);
p = o->program[i].u.str;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key) {
av_log(NULL, AV_LOG_FATAL,
"No '=' character in program string %s.\n",
p2);
exit_program(1);
}
if (!*p2)
exit_program(1);
p2++;
if (!strcmp(key, "title")) {
av_dict_set(&program->metadata, "title", p2, 0);
} else if (!strcmp(key, "program_num")) {
} else if (!strcmp(key, "st")) {
int st_num = strtol(p2, NULL, 0);
av_program_add_stream_index(oc, progid, st_num);
} else {
av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
exit_program(1);
}
}
}
for (i = 0; i < o->nb_metadata; i++) {
AVDictionary **m;
char type, *val;
const char *stream_spec;
int index = 0, j, ret = 0;
char now_time[256];
val = strchr(o->metadata[i].u.str, '=');
if (!val) {
av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n",
o->metadata[i].u.str);
exit_program(1);
}
*val++ = 0;
if (!strcmp(o->metadata[i].u.str, "creation_time") &&
!strcmp(val, "now")) {
time_t now = time(0);
struct tm *ptm, tmbuf;
ptm = localtime_r(&now, &tmbuf);
if (ptm) {
if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm))
val = now_time;
}
}
parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec);
if (type == 's') {
for (j = 0; j < oc->nb_streams; j++) {
ost = output_streams[nb_output_streams - oc->nb_streams + j];
if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {
av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);
if (!strcmp(o->metadata[i].u.str, "rotate")) {
ost->rotate_overridden = 1;
}
} else if (ret < 0)
exit_program(1);
}
}
else {
switch (type) {
case 'g':
m = &oc->metadata;
break;
case 'c':
if (index < 0 || index >= oc->nb_chapters) {
av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->chapters[index]->metadata;
break;
case 'p':
if (index < 0 || index >= oc->nb_programs) {
av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->programs[index]->metadata;
break;
default:
av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier);
exit_program(1);
}
av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0);
}
}
return 0;
}
| {
"code": [
" if (!key || !*p2)"
],
"line_no": [
951
]
} | static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1)
{
AVFormatContext *oc;
int VAR_2, VAR_5, VAR_5;
AVOutputFormat *file_oformat;
OutputFile *of;
OutputStream *ost;
InputStream *ist;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
if (VAR_0->stop_time != INT64_MAX && VAR_0->recording_time != INT64_MAX) {
VAR_0->stop_time = INT64_MAX;
av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
}
if (VAR_0->stop_time != INT64_MAX && VAR_0->recording_time == INT64_MAX) {
int64_t start_time = VAR_0->start_time == AV_NOPTS_VALUE ? 0 : VAR_0->start_time;
if (VAR_0->stop_time <= start_time) {
av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
exit_program(1);
} else {
VAR_0->recording_time = VAR_0->stop_time - start_time;
}
}
GROW_ARRAY(output_files, nb_output_files);
of = av_mallocz(sizeof(*of));
if (!of)
exit_program(1);
output_files[nb_output_files - 1] = of;
of->ost_index = nb_output_streams;
of->recording_time = VAR_0->recording_time;
of->start_time = VAR_0->start_time;
of->limit_filesize = VAR_0->limit_filesize;
of->shortest = VAR_0->shortest;
av_dict_copy(&of->opts, VAR_0->g->format_opts, 0);
if (!strcmp(VAR_1, "-"))
VAR_1 = "pipe:";
VAR_5 = avformat_alloc_output_context2(&oc, NULL, VAR_0->format, VAR_1);
if (!oc) {
print_error(VAR_1, VAR_5);
exit_program(1);
}
of->ctx = oc;
if (VAR_0->recording_time != INT64_MAX)
oc->duration = VAR_0->recording_time;
file_oformat= oc->oformat;
oc->interrupt_callback = int_cb;
for (VAR_2 = 0; VAR_2 < nb_filtergraphs; VAR_2++) {
FilterGraph *fg = filtergraphs[VAR_2];
for (VAR_5 = 0; VAR_5 < fg->nb_outputs; VAR_5++) {
OutputFilter *ofilter = fg->outputs[VAR_5];
if (!ofilter->out_tmp || ofilter->out_tmp->name)
continue;
switch (ofilter->type) {
case AVMEDIA_TYPE_VIDEO: VAR_0->video_disable = 1; break;
case AVMEDIA_TYPE_AUDIO: VAR_0->audio_disable = 1; break;
case AVMEDIA_TYPE_SUBTITLE: VAR_0->subtitle_disable = 1; break;
}
init_output_filter(ofilter, VAR_0, oc);
}
}
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(VAR_1, "http:", NULL)) {
int VAR_5 = parse_option(VAR_0, "metadata", "creation_time=now", options);
if (VAR_5 < 0) {
print_error(VAR_1, VAR_5);
exit_program(1);
}
}
if (!strcmp(file_oformat->name, "ffm") && !override_ffserver &&
av_strstart(VAR_1, "http:", NULL)) {
int VAR_5;
int VAR_5 = read_ffserver_streams(VAR_0, oc, VAR_1);
if (VAR_5 < 0) {
print_error(VAR_1, VAR_5);
exit_program(1);
}
for(VAR_5 = nb_output_streams - oc->nb_streams; VAR_5 < nb_output_streams; VAR_5++) {
ost = output_streams[VAR_5];
for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {
ist = input_streams[VAR_2];
if(ist->st->codec->codec_type == ost->st->codec->codec_type){
ost->sync_ist= ist;
ost->source_index= VAR_2;
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
ist->discard = 0;
ist->st->discard = ist->user_set_discard;
break;
}
}
if(!ost->sync_ist){
av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
exit_program(1);
}
}
} else if (!VAR_0->nb_stream_maps) {
char *VAR_5 = NULL;
if (!VAR_0->video_disable && av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
int VAR_6 = 0, VAR_10 = -1;
int VAR_8 = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {
int new_area;
ist = input_streams[VAR_2];
new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;
if((VAR_8!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
new_area = 1;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
new_area > VAR_6) {
if((VAR_8==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
continue;
VAR_6 = new_area;
VAR_10 = VAR_2;
}
}
if (VAR_10 >= 0)
new_video_stream(VAR_0, oc, VAR_10);
}
if (!VAR_0->audio_disable && av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) {
int VAR_9 = 0, VAR_10 = -1;
for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {
int score;
ist = input_streams[VAR_2];
score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
score > VAR_9) {
VAR_9 = score;
VAR_10 = VAR_2;
}
}
if (VAR_10 >= 0)
new_audio_stream(VAR_0, oc, VAR_10);
}
MATCH_PER_TYPE_OPT(codec_names, str, VAR_5, oc, "s");
if (!VAR_0->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || VAR_5)) {
for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++)
if (input_streams[VAR_2]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
AVCodecDescriptor const *input_descriptor =
avcodec_descriptor_get(input_streams[VAR_2]->st->codec->VAR_10);
AVCodecDescriptor const *output_descriptor = NULL;
AVCodec const *output_codec =
avcodec_find_encoder(oc->oformat->subtitle_codec);
int input_props = 0, output_props = 0;
if (output_codec)
output_descriptor = avcodec_descriptor_get(output_codec->id);
if (input_descriptor)
input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (output_descriptor)
output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (VAR_5 ||
input_props & output_props ||
input_descriptor && output_descriptor &&
(!input_descriptor->props ||
!output_descriptor->props)) {
new_subtitle_stream(VAR_0, oc, VAR_2);
break;
}
}
}
if (!VAR_0->data_disable ) {
enum AVCodecID VAR_10 = av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_DATA);
for (VAR_2 = 0; VAR_10 != AV_CODEC_ID_NONE && VAR_2 < nb_input_streams; VAR_2++) {
if (input_streams[VAR_2]->st->codec->codec_type == AVMEDIA_TYPE_DATA
&& input_streams[VAR_2]->st->codec->VAR_10 == VAR_10 )
new_data_stream(VAR_0, oc, VAR_2);
}
}
} else {
for (VAR_2 = 0; VAR_2 < VAR_0->nb_stream_maps; VAR_2++) {
StreamMap *map = &VAR_0->stream_maps[VAR_2];
if (map->disabled)
continue;
if (map->linklabel) {
FilterGraph *fg;
OutputFilter *ofilter = NULL;
int VAR_5, k;
for (VAR_5 = 0; VAR_5 < nb_filtergraphs; VAR_5++) {
fg = filtergraphs[VAR_5];
for (k = 0; k < fg->nb_outputs; k++) {
AVFilterInOut *out = fg->outputs[k]->out_tmp;
if (out && !strcmp(out->name, map->linklabel)) {
ofilter = fg->outputs[k];
goto loop_end;
}
}
}
loop_end:
if (!ofilter) {
av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
"in any defined filter graph, or was already used elsewhere.\n", map->linklabel);
exit_program(1);
}
init_output_filter(ofilter, VAR_0, oc);
} else {
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
if(VAR_0->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
continue;
if(VAR_0-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
continue;
if(VAR_0-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
continue;
if(VAR_0-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
continue;
ost = NULL;
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (VAR_0, oc, src_idx); break;
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (VAR_0, oc, src_idx); break;
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (VAR_0, oc, src_idx); break;
case AVMEDIA_TYPE_DATA: ost = new_data_stream (VAR_0, oc, src_idx); break;
case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(VAR_0, oc, src_idx); break;
case AVMEDIA_TYPE_UNKNOWN:
if (copy_unknown_streams) {
ost = new_unknown_stream (VAR_0, oc, src_idx);
break;
}
default:
av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL,
"Cannot map stream #%d:%d - unsupported type.\n",
map->file_index, map->stream_index);
if (!ignore_unknown_streams) {
av_log(NULL, AV_LOG_FATAL,
"If you want unsupported types ignored instead "
"of failing, please use the -ignore_unknown VAR_12\n"
"If you want them copied, please use -copy_unknown\n");
exit_program(1);
}
}
if (ost)
ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index
+ map->sync_stream_index];
}
}
}
for (VAR_2 = 0; VAR_2 < VAR_0->nb_attachments; VAR_2++) {
AVIOContext *pb;
uint8_t *attachment;
const char *p;
int64_t len;
if ((VAR_5 = avio_open2(&pb, VAR_0->attachments[VAR_2], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
VAR_0->attachments[VAR_2]);
exit_program(1);
}
if ((len = avio_size(pb)) <= 0) {
av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n",
VAR_0->attachments[VAR_2]);
exit_program(1);
}
if (!(attachment = av_malloc(len))) {
av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n",
VAR_0->attachments[VAR_2]);
exit_program(1);
}
avio_read(pb, attachment, len);
ost = new_attachment_stream(VAR_0, oc, -1);
ost->stream_copy = 1;
ost->attachment_filename = VAR_0->attachments[VAR_2];
ost->finished = 1;
ost->st->codec->extradata = attachment;
ost->st->codec->extradata_size = len;
p = strrchr(VAR_0->attachments[VAR_2], '/');
av_dict_set(&ost->st->metadata, "VAR_1", (p && *p) ? p + 1 : VAR_0->attachments[VAR_2], AV_DICT_DONT_OVERWRITE);
avio_closep(&pb);
}
for (VAR_2 = nb_output_streams - oc->nb_streams; VAR_2 < nb_output_streams; VAR_2++) {
AVDictionaryEntry *e;
ost = output_streams[VAR_2];
if ((ost->stream_copy || ost->attachment_filename)
&& (e = av_dict_get(VAR_0->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
&& (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
exit_program(1);
}
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, nb_output_files - 1, oc->VAR_1, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1);
exit_program(1);
}
unused_opts = strip_specifiers(VAR_0->g->codec_opts);
for (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {
e = NULL;
while ((e = av_dict_get(output_streams[VAR_2]->encoder_opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *VAR_11 = avcodec_get_class();
const AVOption *VAR_12 = av_opt_find(&VAR_11, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
const AVClass *VAR_13 = avformat_get_class();
const AVOption *VAR_14 = av_opt_find(&VAR_13, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!VAR_12 || VAR_14)
continue;
if (!(VAR_12->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) is not an encoding VAR_12.\n", e->key,
VAR_12->help ? VAR_12->help : "", nb_output_files - 1,
VAR_1);
exit_program(1);
}
if (!strcmp(e->key, "gop_timecode"))
continue;
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video VAR_12 with "
"no video streams) or that it is a private VAR_12 of some encoder "
"which was not actually used for any stream.\n", e->key,
VAR_12->help ? VAR_12->help : "", nb_output_files - 1, VAR_1);
}
av_dict_free(&unused_opts);
for (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {
OutputStream *ost = output_streams[VAR_2];
ost->encoding_needed = !ost->stream_copy;
if (ost->encoding_needed && ost->source_index >= 0) {
InputStream *ist = input_streams[ost->source_index];
ist->decoding_needed |= DECODING_FOR_OST;
}
}
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->VAR_1)) {
print_error(oc->VAR_1, AVERROR(EINVAL));
exit_program(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {
av_log(NULL, AV_LOG_ERROR,
"No input streams but output needs an input stream\n");
exit_program(1);
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
assert_file_overwrite(VAR_1);
if ((VAR_5 = avio_open2(&oc->pb, VAR_1, AVIO_FLAG_WRITE,
&oc->interrupt_callback,
&of->opts)) < 0) {
print_error(VAR_1, VAR_5);
exit_program(1);
}
} else if (strcmp(oc->oformat->name, "image2")==0 && !av_filename_number_test(VAR_1))
assert_file_overwrite(VAR_1);
if (VAR_0->mux_preload) {
av_dict_set_int(&of->opts, "preload", VAR_0->mux_preload*AV_TIME_BASE, 0);
}
oc->max_delay = (int)(VAR_0->mux_max_delay * AV_TIME_BASE);
for (VAR_2 = 0; VAR_2 < VAR_0->nb_metadata_map; VAR_2++) {
char *p;
int in_file_index = strtol(VAR_0->metadata_map[VAR_2].u.str, &p, 0);
if (in_file_index >= nb_input_files) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index);
exit_program(1);
}
copy_metadata(VAR_0->metadata_map[VAR_2].specifier, *p ? p + 1 : p, oc,
in_file_index >= 0 ?
input_files[in_file_index]->ctx : NULL, VAR_0);
}
if (VAR_0->chapters_input_file >= nb_input_files) {
if (VAR_0->chapters_input_file == INT_MAX) {
VAR_0->chapters_input_file = -1;
for (VAR_2 = 0; VAR_2 < nb_input_files; VAR_2++)
if (input_files[VAR_2]->ctx->nb_chapters) {
VAR_0->chapters_input_file = VAR_2;
break;
}
} else {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n",
VAR_0->chapters_input_file);
exit_program(1);
}
}
if (VAR_0->chapters_input_file >= 0)
copy_chapters(input_files[VAR_0->chapters_input_file], of,
!VAR_0->metadata_chapters_manual);
if (!VAR_0->metadata_global_manual && nb_input_files){
av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
AV_DICT_DONT_OVERWRITE);
if(VAR_0->recording_time != INT64_MAX)
av_dict_set(&oc->metadata, "duration", NULL, 0);
av_dict_set(&oc->metadata, "creation_time", NULL, 0);
}
if (!VAR_0->metadata_streams_manual)
for (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {
InputStream *ist;
if (output_streams[VAR_2]->source_index < 0)
continue;
ist = input_streams[output_streams[VAR_2]->source_index];
av_dict_copy(&output_streams[VAR_2]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
if (!output_streams[VAR_2]->stream_copy) {
av_dict_set(&output_streams[VAR_2]->st->metadata, "encoder", NULL, 0);
if (ist->autorotate)
av_dict_set(&output_streams[VAR_2]->st->metadata, "rotate", NULL, 0);
}
}
for (VAR_2 = 0; VAR_2 < VAR_0->nb_program; VAR_2++) {
const char *p = VAR_0->program[VAR_2].u.str;
int progid = VAR_2+1;
AVProgram *program;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key || !*p2)
break;
p2++;
if (!strcmp(key, "program_num"))
progid = strtol(p2, NULL, 0);
}
program = av_new_program(oc, progid);
p = VAR_0->program[VAR_2].u.str;
while(*p) {
const char *p2 = av_get_token(&p, ":");
char *key;
if (!p2)
break;
if(*p) p++;
key = av_get_token(&p2, "=");
if (!key) {
av_log(NULL, AV_LOG_FATAL,
"No '=' character in program string %s.\n",
p2);
exit_program(1);
}
if (!*p2)
exit_program(1);
p2++;
if (!strcmp(key, "title")) {
av_dict_set(&program->metadata, "title", p2, 0);
} else if (!strcmp(key, "program_num")) {
} else if (!strcmp(key, "st")) {
int st_num = strtol(p2, NULL, 0);
av_program_add_stream_index(oc, progid, st_num);
} else {
av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
exit_program(1);
}
}
}
for (VAR_2 = 0; VAR_2 < VAR_0->nb_metadata; VAR_2++) {
AVDictionary **m;
char type, *val;
const char *stream_spec;
int index = 0, VAR_5, ret = 0;
char now_time[256];
val = strchr(VAR_0->metadata[VAR_2].u.str, '=');
if (!val) {
av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n",
VAR_0->metadata[VAR_2].u.str);
exit_program(1);
}
*val++ = 0;
if (!strcmp(VAR_0->metadata[VAR_2].u.str, "creation_time") &&
!strcmp(val, "now")) {
time_t now = time(0);
struct tm *ptm, tmbuf;
ptm = localtime_r(&now, &tmbuf);
if (ptm) {
if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm))
val = now_time;
}
}
parse_meta_type(VAR_0->metadata[VAR_2].specifier, &type, &index, &stream_spec);
if (type == 's') {
for (VAR_5 = 0; VAR_5 < oc->nb_streams; VAR_5++) {
ost = output_streams[nb_output_streams - oc->nb_streams + VAR_5];
if ((ret = check_stream_specifier(oc, oc->streams[VAR_5], stream_spec)) > 0) {
av_dict_set(&oc->streams[VAR_5]->metadata, VAR_0->metadata[VAR_2].u.str, *val ? val : NULL, 0);
if (!strcmp(VAR_0->metadata[VAR_2].u.str, "rotate")) {
ost->rotate_overridden = 1;
}
} else if (ret < 0)
exit_program(1);
}
}
else {
switch (type) {
case 'g':
m = &oc->metadata;
break;
case 'c':
if (index < 0 || index >= oc->nb_chapters) {
av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->chapters[index]->metadata;
break;
case 'p':
if (index < 0 || index >= oc->nb_programs) {
av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index);
exit_program(1);
}
m = &oc->programs[index]->metadata;
break;
default:
av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", VAR_0->metadata[VAR_2].specifier);
exit_program(1);
}
av_dict_set(m, VAR_0->metadata[VAR_2].u.str, *val ? val : NULL, 0);
}
}
return 0;
}
| [
"static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1)\n{",
"AVFormatContext *oc;",
"int VAR_2, VAR_5, VAR_5;",
"AVOutputFormat *file_oformat;",
"OutputFile *of;",
"OutputStream *ost;",
"InputStream *ist;",
"AVDictionary *unused_opts = NULL;",
"AVDictionaryEntry *e = NULL;",
"if (VAR_0->stop_time != INT64_MAX && VAR_0->recording_time != INT64_MAX) {",
"VAR_0->stop_time = INT64_MAX;",
"av_log(NULL, AV_LOG_WARNING, \"-t and -to cannot be used together; using -t.\\n\");",
"}",
"if (VAR_0->stop_time != INT64_MAX && VAR_0->recording_time == INT64_MAX) {",
"int64_t start_time = VAR_0->start_time == AV_NOPTS_VALUE ? 0 : VAR_0->start_time;",
"if (VAR_0->stop_time <= start_time) {",
"av_log(NULL, AV_LOG_ERROR, \"-to value smaller than -ss; aborting.\\n\");",
"exit_program(1);",
"} else {",
"VAR_0->recording_time = VAR_0->stop_time - start_time;",
"}",
"}",
"GROW_ARRAY(output_files, nb_output_files);",
"of = av_mallocz(sizeof(*of));",
"if (!of)\nexit_program(1);",
"output_files[nb_output_files - 1] = of;",
"of->ost_index = nb_output_streams;",
"of->recording_time = VAR_0->recording_time;",
"of->start_time = VAR_0->start_time;",
"of->limit_filesize = VAR_0->limit_filesize;",
"of->shortest = VAR_0->shortest;",
"av_dict_copy(&of->opts, VAR_0->g->format_opts, 0);",
"if (!strcmp(VAR_1, \"-\"))\nVAR_1 = \"pipe:\";",
"VAR_5 = avformat_alloc_output_context2(&oc, NULL, VAR_0->format, VAR_1);",
"if (!oc) {",
"print_error(VAR_1, VAR_5);",
"exit_program(1);",
"}",
"of->ctx = oc;",
"if (VAR_0->recording_time != INT64_MAX)\noc->duration = VAR_0->recording_time;",
"file_oformat= oc->oformat;",
"oc->interrupt_callback = int_cb;",
"for (VAR_2 = 0; VAR_2 < nb_filtergraphs; VAR_2++) {",
"FilterGraph *fg = filtergraphs[VAR_2];",
"for (VAR_5 = 0; VAR_5 < fg->nb_outputs; VAR_5++) {",
"OutputFilter *ofilter = fg->outputs[VAR_5];",
"if (!ofilter->out_tmp || ofilter->out_tmp->name)\ncontinue;",
"switch (ofilter->type) {",
"case AVMEDIA_TYPE_VIDEO: VAR_0->video_disable = 1; break;",
"case AVMEDIA_TYPE_AUDIO: VAR_0->audio_disable = 1; break;",
"case AVMEDIA_TYPE_SUBTITLE: VAR_0->subtitle_disable = 1; break;",
"}",
"init_output_filter(ofilter, VAR_0, oc);",
"}",
"}",
"if (!strcmp(file_oformat->name, \"ffm\") &&\nav_strstart(VAR_1, \"http:\", NULL)) {",
"int VAR_5 = parse_option(VAR_0, \"metadata\", \"creation_time=now\", options);",
"if (VAR_5 < 0) {",
"print_error(VAR_1, VAR_5);",
"exit_program(1);",
"}",
"}",
"if (!strcmp(file_oformat->name, \"ffm\") && !override_ffserver &&\nav_strstart(VAR_1, \"http:\", NULL)) {",
"int VAR_5;",
"int VAR_5 = read_ffserver_streams(VAR_0, oc, VAR_1);",
"if (VAR_5 < 0) {",
"print_error(VAR_1, VAR_5);",
"exit_program(1);",
"}",
"for(VAR_5 = nb_output_streams - oc->nb_streams; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = output_streams[VAR_5];",
"for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {",
"ist = input_streams[VAR_2];",
"if(ist->st->codec->codec_type == ost->st->codec->codec_type){",
"ost->sync_ist= ist;",
"ost->source_index= VAR_2;",
"if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup(\"anull\");",
"if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup(\"null\");",
"ist->discard = 0;",
"ist->st->discard = ist->user_set_discard;",
"break;",
"}",
"}",
"if(!ost->sync_ist){",
"av_log(NULL, AV_LOG_FATAL, \"Missing %s stream which is required by this ffm\\n\", av_get_media_type_string(ost->st->codec->codec_type));",
"exit_program(1);",
"}",
"}",
"} else if (!VAR_0->nb_stream_maps) {",
"char *VAR_5 = NULL;",
"if (!VAR_0->video_disable && av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {",
"int VAR_6 = 0, VAR_10 = -1;",
"int VAR_8 = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);",
"for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {",
"int new_area;",
"ist = input_streams[VAR_2];",
"new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;",
"if((VAR_8!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))\nnew_area = 1;",
"if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\nnew_area > VAR_6) {",
"if((VAR_8==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))\ncontinue;",
"VAR_6 = new_area;",
"VAR_10 = VAR_2;",
"}",
"}",
"if (VAR_10 >= 0)\nnew_video_stream(VAR_0, oc, VAR_10);",
"}",
"if (!VAR_0->audio_disable && av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) {",
"int VAR_9 = 0, VAR_10 = -1;",
"for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++) {",
"int score;",
"ist = input_streams[VAR_2];",
"score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;",
"if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&\nscore > VAR_9) {",
"VAR_9 = score;",
"VAR_10 = VAR_2;",
"}",
"}",
"if (VAR_10 >= 0)\nnew_audio_stream(VAR_0, oc, VAR_10);",
"}",
"MATCH_PER_TYPE_OPT(codec_names, str, VAR_5, oc, \"s\");",
"if (!VAR_0->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || VAR_5)) {",
"for (VAR_2 = 0; VAR_2 < nb_input_streams; VAR_2++)",
"if (input_streams[VAR_2]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"AVCodecDescriptor const *input_descriptor =\navcodec_descriptor_get(input_streams[VAR_2]->st->codec->VAR_10);",
"AVCodecDescriptor const *output_descriptor = NULL;",
"AVCodec const *output_codec =\navcodec_find_encoder(oc->oformat->subtitle_codec);",
"int input_props = 0, output_props = 0;",
"if (output_codec)\noutput_descriptor = avcodec_descriptor_get(output_codec->id);",
"if (input_descriptor)\ninput_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);",
"if (output_descriptor)\noutput_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);",
"if (VAR_5 ||\ninput_props & output_props ||\ninput_descriptor && output_descriptor &&\n(!input_descriptor->props ||\n!output_descriptor->props)) {",
"new_subtitle_stream(VAR_0, oc, VAR_2);",
"break;",
"}",
"}",
"}",
"if (!VAR_0->data_disable ) {",
"enum AVCodecID VAR_10 = av_guess_codec(oc->oformat, NULL, VAR_1, NULL, AVMEDIA_TYPE_DATA);",
"for (VAR_2 = 0; VAR_10 != AV_CODEC_ID_NONE && VAR_2 < nb_input_streams; VAR_2++) {",
"if (input_streams[VAR_2]->st->codec->codec_type == AVMEDIA_TYPE_DATA\n&& input_streams[VAR_2]->st->codec->VAR_10 == VAR_10 )\nnew_data_stream(VAR_0, oc, VAR_2);",
"}",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_stream_maps; VAR_2++) {",
"StreamMap *map = &VAR_0->stream_maps[VAR_2];",
"if (map->disabled)\ncontinue;",
"if (map->linklabel) {",
"FilterGraph *fg;",
"OutputFilter *ofilter = NULL;",
"int VAR_5, k;",
"for (VAR_5 = 0; VAR_5 < nb_filtergraphs; VAR_5++) {",
"fg = filtergraphs[VAR_5];",
"for (k = 0; k < fg->nb_outputs; k++) {",
"AVFilterInOut *out = fg->outputs[k]->out_tmp;",
"if (out && !strcmp(out->name, map->linklabel)) {",
"ofilter = fg->outputs[k];",
"goto loop_end;",
"}",
"}",
"}",
"loop_end:\nif (!ofilter) {",
"av_log(NULL, AV_LOG_FATAL, \"Output with label '%s' does not exist \"\n\"in any defined filter graph, or was already used elsewhere.\\n\", map->linklabel);",
"exit_program(1);",
"}",
"init_output_filter(ofilter, VAR_0, oc);",
"} else {",
"int src_idx = input_files[map->file_index]->ist_index + map->stream_index;",
"ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];",
"if(VAR_0->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)\ncontinue;",
"if(VAR_0-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)\ncontinue;",
"if(VAR_0-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)\ncontinue;",
"if(VAR_0-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)\ncontinue;",
"ost = NULL;",
"switch (ist->st->codec->codec_type) {",
"case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (VAR_0, oc, src_idx); break;",
"case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (VAR_0, oc, src_idx); break;",
"case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (VAR_0, oc, src_idx); break;",
"case AVMEDIA_TYPE_DATA: ost = new_data_stream (VAR_0, oc, src_idx); break;",
"case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(VAR_0, oc, src_idx); break;",
"case AVMEDIA_TYPE_UNKNOWN:\nif (copy_unknown_streams) {",
"ost = new_unknown_stream (VAR_0, oc, src_idx);",
"break;",
"}",
"default:\nav_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL,\n\"Cannot map stream #%d:%d - unsupported type.\\n\",\nmap->file_index, map->stream_index);",
"if (!ignore_unknown_streams) {",
"av_log(NULL, AV_LOG_FATAL,\n\"If you want unsupported types ignored instead \"\n\"of failing, please use the -ignore_unknown VAR_12\\n\"\n\"If you want them copied, please use -copy_unknown\\n\");",
"exit_program(1);",
"}",
"}",
"if (ost)\nost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index\n+ map->sync_stream_index];",
"}",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_attachments; VAR_2++) {",
"AVIOContext *pb;",
"uint8_t *attachment;",
"const char *p;",
"int64_t len;",
"if ((VAR_5 = avio_open2(&pb, VAR_0->attachments[VAR_2], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Could not open attachment file %s.\\n\",\nVAR_0->attachments[VAR_2]);",
"exit_program(1);",
"}",
"if ((len = avio_size(pb)) <= 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Could not get size of the attachment %s.\\n\",\nVAR_0->attachments[VAR_2]);",
"exit_program(1);",
"}",
"if (!(attachment = av_malloc(len))) {",
"av_log(NULL, AV_LOG_FATAL, \"Attachment %s too large to fit into memory.\\n\",\nVAR_0->attachments[VAR_2]);",
"exit_program(1);",
"}",
"avio_read(pb, attachment, len);",
"ost = new_attachment_stream(VAR_0, oc, -1);",
"ost->stream_copy = 1;",
"ost->attachment_filename = VAR_0->attachments[VAR_2];",
"ost->finished = 1;",
"ost->st->codec->extradata = attachment;",
"ost->st->codec->extradata_size = len;",
"p = strrchr(VAR_0->attachments[VAR_2], '/');",
"av_dict_set(&ost->st->metadata, \"VAR_1\", (p && *p) ? p + 1 : VAR_0->attachments[VAR_2], AV_DICT_DONT_OVERWRITE);",
"avio_closep(&pb);",
"}",
"for (VAR_2 = nb_output_streams - oc->nb_streams; VAR_2 < nb_output_streams; VAR_2++) {",
"AVDictionaryEntry *e;",
"ost = output_streams[VAR_2];",
"if ((ost->stream_copy || ost->attachment_filename)\n&& (e = av_dict_get(VAR_0->g->codec_opts, \"flags\", NULL, AV_DICT_IGNORE_SUFFIX))\n&& (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))\nif (av_opt_set(ost->st->codec, \"flags\", e->value, 0) < 0)\nexit_program(1);",
"}",
"if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {",
"av_dump_format(oc, nb_output_files - 1, oc->VAR_1, 1);",
"av_log(NULL, AV_LOG_ERROR, \"Output file #%d does not contain any stream\\n\", nb_output_files - 1);",
"exit_program(1);",
"}",
"unused_opts = strip_specifiers(VAR_0->g->codec_opts);",
"for (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {",
"e = NULL;",
"while ((e = av_dict_get(output_streams[VAR_2]->encoder_opts, \"\", e,\nAV_DICT_IGNORE_SUFFIX)))\nav_dict_set(&unused_opts, e->key, NULL, 0);",
"}",
"e = NULL;",
"while ((e = av_dict_get(unused_opts, \"\", e, AV_DICT_IGNORE_SUFFIX))) {",
"const AVClass *VAR_11 = avcodec_get_class();",
"const AVOption *VAR_12 = av_opt_find(&VAR_11, e->key, NULL, 0,\nAV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);",
"const AVClass *VAR_13 = avformat_get_class();",
"const AVOption *VAR_14 = av_opt_find(&VAR_13, e->key, NULL, 0,\nAV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);",
"if (!VAR_12 || VAR_14)\ncontinue;",
"if (!(VAR_12->flags & AV_OPT_FLAG_ENCODING_PARAM)) {",
"av_log(NULL, AV_LOG_ERROR, \"Codec AVOption %s (%s) specified for \"\n\"output file #%d (%s) is not an encoding VAR_12.\\n\", e->key,\nVAR_12->help ? VAR_12->help : \"\", nb_output_files - 1,\nVAR_1);",
"exit_program(1);",
"}",
"if (!strcmp(e->key, \"gop_timecode\"))\ncontinue;",
"av_log(NULL, AV_LOG_WARNING, \"Codec AVOption %s (%s) specified for \"\n\"output file #%d (%s) has not been used for any stream. The most \"\n\"likely reason is either wrong type (e.g. a video VAR_12 with \"\n\"no video streams) or that it is a private VAR_12 of some encoder \"\n\"which was not actually used for any stream.\\n\", e->key,\nVAR_12->help ? VAR_12->help : \"\", nb_output_files - 1, VAR_1);",
"}",
"av_dict_free(&unused_opts);",
"for (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {",
"OutputStream *ost = output_streams[VAR_2];",
"ost->encoding_needed = !ost->stream_copy;",
"if (ost->encoding_needed && ost->source_index >= 0) {",
"InputStream *ist = input_streams[ost->source_index];",
"ist->decoding_needed |= DECODING_FOR_OST;",
"}",
"}",
"if (oc->oformat->flags & AVFMT_NEEDNUMBER) {",
"if (!av_filename_number_test(oc->VAR_1)) {",
"print_error(oc->VAR_1, AVERROR(EINVAL));",
"exit_program(1);",
"}",
"}",
"if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {",
"av_log(NULL, AV_LOG_ERROR,\n\"No input streams but output needs an input stream\\n\");",
"exit_program(1);",
"}",
"if (!(oc->oformat->flags & AVFMT_NOFILE)) {",
"assert_file_overwrite(VAR_1);",
"if ((VAR_5 = avio_open2(&oc->pb, VAR_1, AVIO_FLAG_WRITE,\n&oc->interrupt_callback,\n&of->opts)) < 0) {",
"print_error(VAR_1, VAR_5);",
"exit_program(1);",
"}",
"} else if (strcmp(oc->oformat->name, \"image2\")==0 && !av_filename_number_test(VAR_1))",
"assert_file_overwrite(VAR_1);",
"if (VAR_0->mux_preload) {",
"av_dict_set_int(&of->opts, \"preload\", VAR_0->mux_preload*AV_TIME_BASE, 0);",
"}",
"oc->max_delay = (int)(VAR_0->mux_max_delay * AV_TIME_BASE);",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_metadata_map; VAR_2++) {",
"char *p;",
"int in_file_index = strtol(VAR_0->metadata_map[VAR_2].u.str, &p, 0);",
"if (in_file_index >= nb_input_files) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid input file index %d while processing metadata maps\\n\", in_file_index);",
"exit_program(1);",
"}",
"copy_metadata(VAR_0->metadata_map[VAR_2].specifier, *p ? p + 1 : p, oc,\nin_file_index >= 0 ?\ninput_files[in_file_index]->ctx : NULL, VAR_0);",
"}",
"if (VAR_0->chapters_input_file >= nb_input_files) {",
"if (VAR_0->chapters_input_file == INT_MAX) {",
"VAR_0->chapters_input_file = -1;",
"for (VAR_2 = 0; VAR_2 < nb_input_files; VAR_2++)",
"if (input_files[VAR_2]->ctx->nb_chapters) {",
"VAR_0->chapters_input_file = VAR_2;",
"break;",
"}",
"} else {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid input file index %d in chapter mapping.\\n\",\nVAR_0->chapters_input_file);",
"exit_program(1);",
"}",
"}",
"if (VAR_0->chapters_input_file >= 0)\ncopy_chapters(input_files[VAR_0->chapters_input_file], of,\n!VAR_0->metadata_chapters_manual);",
"if (!VAR_0->metadata_global_manual && nb_input_files){",
"av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,\nAV_DICT_DONT_OVERWRITE);",
"if(VAR_0->recording_time != INT64_MAX)\nav_dict_set(&oc->metadata, \"duration\", NULL, 0);",
"av_dict_set(&oc->metadata, \"creation_time\", NULL, 0);",
"}",
"if (!VAR_0->metadata_streams_manual)\nfor (VAR_2 = of->ost_index; VAR_2 < nb_output_streams; VAR_2++) {",
"InputStream *ist;",
"if (output_streams[VAR_2]->source_index < 0)\ncontinue;",
"ist = input_streams[output_streams[VAR_2]->source_index];",
"av_dict_copy(&output_streams[VAR_2]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);",
"if (!output_streams[VAR_2]->stream_copy) {",
"av_dict_set(&output_streams[VAR_2]->st->metadata, \"encoder\", NULL, 0);",
"if (ist->autorotate)\nav_dict_set(&output_streams[VAR_2]->st->metadata, \"rotate\", NULL, 0);",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_program; VAR_2++) {",
"const char *p = VAR_0->program[VAR_2].u.str;",
"int progid = VAR_2+1;",
"AVProgram *program;",
"while(*p) {",
"const char *p2 = av_get_token(&p, \":\");",
"char *key;",
"if (!p2)\nbreak;",
"if(*p) p++;",
"key = av_get_token(&p2, \"=\");",
"if (!key || !*p2)\nbreak;",
"p2++;",
"if (!strcmp(key, \"program_num\"))\nprogid = strtol(p2, NULL, 0);",
"}",
"program = av_new_program(oc, progid);",
"p = VAR_0->program[VAR_2].u.str;",
"while(*p) {",
"const char *p2 = av_get_token(&p, \":\");",
"char *key;",
"if (!p2)\nbreak;",
"if(*p) p++;",
"key = av_get_token(&p2, \"=\");",
"if (!key) {",
"av_log(NULL, AV_LOG_FATAL,\n\"No '=' character in program string %s.\\n\",\np2);",
"exit_program(1);",
"}",
"if (!*p2)\nexit_program(1);",
"p2++;",
"if (!strcmp(key, \"title\")) {",
"av_dict_set(&program->metadata, \"title\", p2, 0);",
"} else if (!strcmp(key, \"program_num\")) {",
"} else if (!strcmp(key, \"st\")) {",
"int st_num = strtol(p2, NULL, 0);",
"av_program_add_stream_index(oc, progid, st_num);",
"} else {",
"av_log(NULL, AV_LOG_FATAL, \"Unknown program key %s.\\n\", key);",
"exit_program(1);",
"}",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_metadata; VAR_2++) {",
"AVDictionary **m;",
"char type, *val;",
"const char *stream_spec;",
"int index = 0, VAR_5, ret = 0;",
"char now_time[256];",
"val = strchr(VAR_0->metadata[VAR_2].u.str, '=');",
"if (!val) {",
"av_log(NULL, AV_LOG_FATAL, \"No '=' character in metadata string %s.\\n\",\nVAR_0->metadata[VAR_2].u.str);",
"exit_program(1);",
"}",
"*val++ = 0;",
"if (!strcmp(VAR_0->metadata[VAR_2].u.str, \"creation_time\") &&\n!strcmp(val, \"now\")) {",
"time_t now = time(0);",
"struct tm *ptm, tmbuf;",
"ptm = localtime_r(&now, &tmbuf);",
"if (ptm) {",
"if (strftime(now_time, sizeof(now_time), \"%Y-%m-%d %H:%M:%S\", ptm))\nval = now_time;",
"}",
"}",
"parse_meta_type(VAR_0->metadata[VAR_2].specifier, &type, &index, &stream_spec);",
"if (type == 's') {",
"for (VAR_5 = 0; VAR_5 < oc->nb_streams; VAR_5++) {",
"ost = output_streams[nb_output_streams - oc->nb_streams + VAR_5];",
"if ((ret = check_stream_specifier(oc, oc->streams[VAR_5], stream_spec)) > 0) {",
"av_dict_set(&oc->streams[VAR_5]->metadata, VAR_0->metadata[VAR_2].u.str, *val ? val : NULL, 0);",
"if (!strcmp(VAR_0->metadata[VAR_2].u.str, \"rotate\")) {",
"ost->rotate_overridden = 1;",
"}",
"} else if (ret < 0)",
"exit_program(1);",
"}",
"}",
"else {",
"switch (type) {",
"case 'g':\nm = &oc->metadata;",
"break;",
"case 'c':\nif (index < 0 || index >= oc->nb_chapters) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid chapter index %d in metadata specifier.\\n\", index);",
"exit_program(1);",
"}",
"m = &oc->chapters[index]->metadata;",
"break;",
"case 'p':\nif (index < 0 || index >= oc->nb_programs) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid program index %d in metadata specifier.\\n\", index);",
"exit_program(1);",
"}",
"m = &oc->programs[index]->metadata;",
"break;",
"default:\nav_log(NULL, AV_LOG_FATAL, \"Invalid metadata specifier %s.\\n\", VAR_0->metadata[VAR_2].specifier);",
"exit_program(1);",
"}",
"av_dict_set(m, VAR_0->metadata[VAR_2].u.str, *val ? val : NULL, 0);",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
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
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255,
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305,
307
],
[
309
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329,
331
],
[
333
],
[
335,
337
],
[
339,
341
],
[
343,
345
],
[
347,
349,
353,
355,
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373
],
[
375
],
[
377,
379,
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395,
397
],
[
401
],
[
403
],
[
405
],
[
407
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431,
433
],
[
435,
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451
],
[
453,
455
],
[
457,
459
],
[
461,
463
],
[
465,
467
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485,
487
],
[
489
],
[
491
],
[
493
],
[
495,
497,
499,
501
],
[
503
],
[
505,
507,
509,
511
],
[
513
],
[
515
],
[
517
],
[
519,
521,
523
],
[
525
],
[
527
],
[
529
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
547
],
[
549,
551
],
[
553
],
[
555
],
[
557
],
[
559,
561
],
[
563
],
[
565
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
595
],
[
597
],
[
599
],
[
601
],
[
605
],
[
607
],
[
609
],
[
613,
615,
617,
619,
621
],
[
623
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
641
],
[
643
],
[
645
],
[
647,
649,
651
],
[
653
],
[
657
],
[
659
],
[
661
],
[
663,
665
],
[
667
],
[
669,
671
],
[
673,
675
],
[
681
],
[
683,
685,
687,
689
],
[
691
],
[
693
],
[
699,
701
],
[
705,
707,
709,
711,
713,
715
],
[
717
],
[
719
],
[
725
],
[
727
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
747
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757
],
[
761
],
[
763,
765
],
[
767
],
[
769
],
[
773
],
[
777
],
[
783,
785,
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
801
],
[
803
],
[
805
],
[
807
],
[
813
],
[
815
],
[
817
],
[
821
],
[
823
],
[
825
],
[
827
],
[
829,
831,
833
],
[
835
],
[
841
],
[
843
],
[
847
],
[
849
],
[
851
],
[
853
],
[
855
],
[
857
],
[
859
],
[
861,
863
],
[
865
],
[
867
],
[
869
],
[
871,
873,
875
],
[
881
],
[
883,
885
],
[
887,
889
],
[
891
],
[
893
],
[
895,
897
],
[
899
],
[
901,
903
],
[
905
],
[
907
],
[
909
],
[
911
],
[
913,
915
],
[
917
],
[
919
],
[
925
],
[
927
],
[
929
],
[
931
],
[
935
],
[
937
],
[
939
],
[
941,
943
],
[
945
],
[
949
],
[
951,
953
],
[
955
],
[
959,
961
],
[
963
],
[
967
],
[
971
],
[
973
],
[
975
],
[
977
],
[
979,
981
],
[
983
],
[
987
],
[
989
],
[
991,
993,
995
],
[
997
],
[
999
],
[
1001,
1003
],
[
1005
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1037
],
[
1039
],
[
1041
],
[
1043
],
[
1045
],
[
1047
],
[
1051
],
[
1053
],
[
1055,
1057
],
[
1059
],
[
1061
],
[
1063
],
[
1067,
1069
],
[
1071
],
[
1073
],
[
1075
],
[
1077
],
[
1079,
1081
],
[
1083
],
[
1085
],
[
1089
],
[
1091
],
[
1093
],
[
1095
],
[
1097
],
[
1099
],
[
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119,
1121
],
[
1123
],
[
1125,
1127
],
[
1129
],
[
1131
],
[
1133
],
[
1135
],
[
1137
],
[
1139,
1141
],
[
1143
],
[
1145
],
[
1147
],
[
1149
],
[
1151
],
[
1153,
1155
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1165
],
[
1169
],
[
1171
]
]
|
13,873 | static void vapic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->no_user = 1;
dc->reset = vapic_reset;
dc->vmsd = &vmstate_vapic;
dc->realize = vapic_realize;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void vapic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->no_user = 1;
dc->reset = vapic_reset;
dc->vmsd = &vmstate_vapic;
dc->realize = vapic_realize;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->no_user = 1;
dc->reset = vapic_reset;
dc->vmsd = &vmstate_vapic;
dc->realize = vapic_realize;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->no_user = 1;",
"dc->reset = vapic_reset;",
"dc->vmsd = &vmstate_vapic;",
"dc->realize = vapic_realize;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
13,874 | AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
{
AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt;
int score, id3 = 0;
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
int id3len = ff_id3v2_tag_len(lpd.buf);
if (lpd.buf_size > id3len + 16) {
lpd.buf += id3len;
lpd.buf_size -= id3len;
}
id3 = 1;
}
fmt = NULL;
while ((fmt1 = av_iformat_next(fmt1))) {
if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
continue;
score = 0;
if (fmt1->read_probe) {
score = fmt1->read_probe(&lpd);
} else if (fmt1->extensions) {
if (av_match_ext(lpd.filename, fmt1->extensions)) {
score = 50;
}
}
if (score > *score_max) {
*score_max = score;
fmt = fmt1;
}else if (score == *score_max)
fmt = NULL;
}
/* a hack for files with huge id3v2 tags -- try to guess by file extension. */
if (!fmt && id3 && *score_max < AVPROBE_SCORE_MAX/4) {
while ((fmt = av_iformat_next(fmt)))
if (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) {
*score_max = AVPROBE_SCORE_MAX/4;
break;
}
}
return fmt;
}
| false | FFmpeg | 7a773d4d59c9a2e14cb84201f8d17cbf3edaede8 | AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
{
AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt;
int score, id3 = 0;
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
int id3len = ff_id3v2_tag_len(lpd.buf);
if (lpd.buf_size > id3len + 16) {
lpd.buf += id3len;
lpd.buf_size -= id3len;
}
id3 = 1;
}
fmt = NULL;
while ((fmt1 = av_iformat_next(fmt1))) {
if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
continue;
score = 0;
if (fmt1->read_probe) {
score = fmt1->read_probe(&lpd);
} else if (fmt1->extensions) {
if (av_match_ext(lpd.filename, fmt1->extensions)) {
score = 50;
}
}
if (score > *score_max) {
*score_max = score;
fmt = fmt1;
}else if (score == *score_max)
fmt = NULL;
}
if (!fmt && id3 && *score_max < AVPROBE_SCORE_MAX/4) {
while ((fmt = av_iformat_next(fmt)))
if (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) {
*score_max = AVPROBE_SCORE_MAX/4;
break;
}
}
return fmt;
}
| {
"code": [],
"line_no": []
} | AVInputFormat *FUNC_0(AVProbeData *pd, int is_opened, int *score_max)
{
AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt;
int VAR_0, VAR_1 = 0;
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
int VAR_2 = ff_id3v2_tag_len(lpd.buf);
if (lpd.buf_size > VAR_2 + 16) {
lpd.buf += VAR_2;
lpd.buf_size -= VAR_2;
}
VAR_1 = 1;
}
fmt = NULL;
while ((fmt1 = av_iformat_next(fmt1))) {
if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
continue;
VAR_0 = 0;
if (fmt1->read_probe) {
VAR_0 = fmt1->read_probe(&lpd);
} else if (fmt1->extensions) {
if (av_match_ext(lpd.filename, fmt1->extensions)) {
VAR_0 = 50;
}
}
if (VAR_0 > *score_max) {
*score_max = VAR_0;
fmt = fmt1;
}else if (VAR_0 == *score_max)
fmt = NULL;
}
if (!fmt && VAR_1 && *score_max < AVPROBE_SCORE_MAX/4) {
while ((fmt = av_iformat_next(fmt)))
if (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) {
*score_max = AVPROBE_SCORE_MAX/4;
break;
}
}
return fmt;
}
| [
"AVInputFormat *FUNC_0(AVProbeData *pd, int is_opened, int *score_max)\n{",
"AVProbeData lpd = *pd;",
"AVInputFormat *fmt1 = NULL, *fmt;",
"int VAR_0, VAR_1 = 0;",
"if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {",
"int VAR_2 = ff_id3v2_tag_len(lpd.buf);",
"if (lpd.buf_size > VAR_2 + 16) {",
"lpd.buf += VAR_2;",
"lpd.buf_size -= VAR_2;",
"}",
"VAR_1 = 1;",
"}",
"fmt = NULL;",
"while ((fmt1 = av_iformat_next(fmt1))) {",
"if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))\ncontinue;",
"VAR_0 = 0;",
"if (fmt1->read_probe) {",
"VAR_0 = fmt1->read_probe(&lpd);",
"} else if (fmt1->extensions) {",
"if (av_match_ext(lpd.filename, fmt1->extensions)) {",
"VAR_0 = 50;",
"}",
"}",
"if (VAR_0 > *score_max) {",
"*score_max = VAR_0;",
"fmt = fmt1;",
"}else if (VAR_0 == *score_max)",
"fmt = NULL;",
"}",
"if (!fmt && VAR_1 && *score_max < AVPROBE_SCORE_MAX/4) {",
"while ((fmt = av_iformat_next(fmt)))\nif (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) {",
"*score_max = AVPROBE_SCORE_MAX/4;",
"break;",
"}",
"}",
"return fmt;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
]
|
13,875 | static void v4l2_free_buffer(void *opaque, uint8_t *unused)
{
V4L2Buffer* avbuf = opaque;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
if (!atomic_load(&s->refcount))
sem_post(&s->refsync);
return;
}
if (avbuf->context->streamon) {
ff_v4l2_buffer_enqueue(avbuf);
return;
}
if (!atomic_load(&s->refcount))
ff_v4l2_m2m_codec_end(s->avctx);
}
| true | FFmpeg | a0c624e299730c8c5800375c2f5f3c6c200053ff | static void v4l2_free_buffer(void *opaque, uint8_t *unused)
{
V4L2Buffer* avbuf = opaque;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
if (!atomic_load(&s->refcount))
sem_post(&s->refsync);
return;
}
if (avbuf->context->streamon) {
ff_v4l2_buffer_enqueue(avbuf);
return;
}
if (!atomic_load(&s->refcount))
ff_v4l2_m2m_codec_end(s->avctx);
}
| {
"code": [
" atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);",
" if (s->reinit) {",
" if (!atomic_load(&s->refcount))",
" sem_post(&s->refsync);",
" if (avbuf->context->streamon) {",
" ff_v4l2_buffer_enqueue(avbuf);",
" if (!atomic_load(&s->refcount))",
" ff_v4l2_m2m_codec_end(s->avctx);"
],
"line_no": [
11,
13,
15,
17,
25,
27,
35,
37
]
} | static void FUNC_0(void *VAR_0, uint8_t *VAR_1)
{
V4L2Buffer* avbuf = VAR_0;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
if (!atomic_load(&s->refcount))
sem_post(&s->refsync);
return;
}
if (avbuf->context->streamon) {
ff_v4l2_buffer_enqueue(avbuf);
return;
}
if (!atomic_load(&s->refcount))
ff_v4l2_m2m_codec_end(s->avctx);
}
| [
"static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{",
"V4L2Buffer* avbuf = VAR_0;",
"V4L2m2mContext *s = buf_to_m2mctx(avbuf);",
"atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);",
"if (s->reinit) {",
"if (!atomic_load(&s->refcount))\nsem_post(&s->refsync);",
"return;",
"}",
"if (avbuf->context->streamon) {",
"ff_v4l2_buffer_enqueue(avbuf);",
"return;",
"}",
"if (!atomic_load(&s->refcount))\nff_v4l2_m2m_codec_end(s->avctx);",
"}"
]
| [
0,
0,
0,
1,
1,
1,
0,
0,
1,
1,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
]
]
|
13,876 | static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
{
return avio_seek(s, offset + (offset & 1), whence);
}
| true | FFmpeg | 09602dbe7a6400e12a66001be5223298f3dc7c56 | static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
{
return avio_seek(s, offset + (offset & 1), whence);
}
| {
"code": [
" return avio_seek(s, offset + (offset & 1), whence);"
],
"line_no": [
5
]
} | static int64_t FUNC_0(AVIOContext *s, int64_t offset, int whence)
{
return avio_seek(s, offset + (offset & 1), whence);
}
| [
"static int64_t FUNC_0(AVIOContext *s, int64_t offset, int whence)\n{",
"return avio_seek(s, offset + (offset & 1), whence);",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,877 | static void ahci_start_dma(IDEDMA *dma, IDEState *s,
BlockCompletionFunc *dma_cb)
{
#ifdef DEBUG_AHCI
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
#endif
DPRINTF(ad->port_no, "\n");
s->io_buffer_offset = 0;
dma_cb(s, 0);
}
| true | qemu | 192cf55cc02dc0838bbfa5ac17feb7f6c1651441 | static void ahci_start_dma(IDEDMA *dma, IDEState *s,
BlockCompletionFunc *dma_cb)
{
#ifdef DEBUG_AHCI
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
#endif
DPRINTF(ad->port_no, "\n");
s->io_buffer_offset = 0;
dma_cb(s, 0);
}
| {
"code": [
"#ifdef DEBUG_AHCI",
"#endif",
"#ifdef DEBUG_AHCI",
"#ifdef DEBUG_AHCI",
"#endif"
],
"line_no": [
7,
11,
7,
7,
11
]
} | static void FUNC_0(IDEDMA *VAR_0, IDEState *VAR_1,
BlockCompletionFunc *VAR_2)
{
#ifdef DEBUG_AHCI
AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);
#endif
DPRINTF(ad->port_no, "\n");
VAR_1->io_buffer_offset = 0;
VAR_2(VAR_1, 0);
}
| [
"static void FUNC_0(IDEDMA *VAR_0, IDEState *VAR_1,\nBlockCompletionFunc *VAR_2)\n{",
"#ifdef DEBUG_AHCI\nAHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);",
"#endif\nDPRINTF(ad->port_no, \"\\n\");",
"VAR_1->io_buffer_offset = 0;",
"VAR_2(VAR_1, 0);",
"}"
]
| [
0,
1,
1,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
]
]
|
13,878 | rdt_new_context (void)
{
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
return rdt;
}
| true | FFmpeg | ed307e2659f2db81a434afece905383fdceb9b6e | rdt_new_context (void)
{
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
return rdt;
}
| {
"code": [
" avformat_open_input(&rdt->rmctx, \"\", &ff_rdt_demuxer, NULL);"
],
"line_no": [
9
]
} | FUNC_0 (void)
{
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL);
return rdt;
}
| [
"FUNC_0 (void)\n{",
"PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));",
"avformat_open_input(&rdt->rmctx, \"\", &ff_rdt_demuxer, NULL);",
"return rdt;",
"}"
]
| [
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
]
]
|
13,879 | static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
{
outl(0xcf8, (1 << 31) | (devfn << 8) | offset);
outb(0xcfc, value);
}
| true | qemu | a879125b47c3ae554c01824f996a64a45a86556e | static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
{
outl(0xcf8, (1 << 31) | (devfn << 8) | offset);
outb(0xcfc, value);
}
| {
"code": [
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);",
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);",
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);",
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);",
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);",
" outl(0xcf8, (1 << 31) | (devfn << 8) | offset);"
],
"line_no": [
5,
5,
5,
5,
5,
5
]
} | static void FUNC_0(QPCIBus *VAR_0, int VAR_1, uint8_t VAR_2, uint8_t VAR_3)
{
outl(0xcf8, (1 << 31) | (VAR_1 << 8) | VAR_2);
outb(0xcfc, VAR_3);
}
| [
"static void FUNC_0(QPCIBus *VAR_0, int VAR_1, uint8_t VAR_2, uint8_t VAR_3)\n{",
"outl(0xcf8, (1 << 31) | (VAR_1 << 8) | VAR_2);",
"outb(0xcfc, VAR_3);",
"}"
]
| [
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
13,880 | static void hpet_set_timer(HPETTimer *t)
{
uint64_t diff;
uint32_t wrap_diff; /* how many ticks until we wrap? */
uint64_t cur_tick = hpet_get_ticks();
/* whenever new timer is being set up, make sure wrap_flag is 0 */
t->wrap_flag = 0;
diff = hpet_calculate_diff(t, cur_tick);
/* hpet spec says in one-shot 32-bit mode, generate an interrupt when
* counter wraps in addition to an interrupt with comparator match.
*/
if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
wrap_diff = 0xffffffff - (uint32_t)cur_tick;
if (wrap_diff < (uint32_t)diff) {
diff = wrap_diff;
t->wrap_flag = 1;
}
}
qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
}
| true | qemu | 27bb0b2d6f80f058bdb6fcc8fcdfa69b0c8a6d71 | static void hpet_set_timer(HPETTimer *t)
{
uint64_t diff;
uint32_t wrap_diff;
uint64_t cur_tick = hpet_get_ticks();
t->wrap_flag = 0;
diff = hpet_calculate_diff(t, cur_tick);
if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
wrap_diff = 0xffffffff - (uint32_t)cur_tick;
if (wrap_diff < (uint32_t)diff) {
diff = wrap_diff;
t->wrap_flag = 1;
}
}
qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
}
| {
"code": [
" qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)",
" + (int64_t)ticks_to_ns(diff));"
],
"line_no": [
41,
43
]
} | static void FUNC_0(HPETTimer *VAR_0)
{
uint64_t diff;
uint32_t wrap_diff;
uint64_t cur_tick = hpet_get_ticks();
VAR_0->wrap_flag = 0;
diff = hpet_calculate_diff(VAR_0, cur_tick);
if (VAR_0->config & HPET_TN_32BIT && !timer_is_periodic(VAR_0)) {
wrap_diff = 0xffffffff - (uint32_t)cur_tick;
if (wrap_diff < (uint32_t)diff) {
diff = wrap_diff;
VAR_0->wrap_flag = 1;
}
}
qemu_mod_timer(VAR_0->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
}
| [
"static void FUNC_0(HPETTimer *VAR_0)\n{",
"uint64_t diff;",
"uint32_t wrap_diff;",
"uint64_t cur_tick = hpet_get_ticks();",
"VAR_0->wrap_flag = 0;",
"diff = hpet_calculate_diff(VAR_0, cur_tick);",
"if (VAR_0->config & HPET_TN_32BIT && !timer_is_periodic(VAR_0)) {",
"wrap_diff = 0xffffffff - (uint32_t)cur_tick;",
"if (wrap_diff < (uint32_t)diff) {",
"diff = wrap_diff;",
"VAR_0->wrap_flag = 1;",
"}",
"}",
"qemu_mod_timer(VAR_0->qemu_timer, qemu_get_clock(vm_clock)\n+ (int64_t)ticks_to_ns(diff));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
]
]
|
13,881 | static uint32_t set_allocation_state(sPAPRDRConnector *drc,
sPAPRDRAllocationState state)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DPRINTFN("drc: %x, set_allocation_state: %x", get_index(drc), state);
if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
/* if there's no resource/device associated with the DRC, there's
* no way for us to put it in an allocation state consistent with
* being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
* result in an RTAS return code of -3 / "no such indicator"
*/
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = state;
if (drc->awaiting_release &&
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
DPRINTFN("finalizing device removal");
drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,
drc->detach_cb_opaque, NULL);
}
}
return RTAS_OUT_SUCCESS;
} | true | qemu | aab99135b63522267c6fdae04712cb2f02c8c7de | static uint32_t set_allocation_state(sPAPRDRConnector *drc,
sPAPRDRAllocationState state)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DPRINTFN("drc: %x, set_allocation_state: %x", get_index(drc), state);
if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = state;
if (drc->awaiting_release &&
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
DPRINTFN("finalizing device removal");
drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,
drc->detach_cb_opaque, NULL);
}
}
return RTAS_OUT_SUCCESS;
} | {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(sPAPRDRConnector *drc,
sPAPRDRAllocationState state)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DPRINTFN("drc: %x, FUNC_0: %x", get_index(drc), state);
if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = state;
if (drc->awaiting_release &&
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
DPRINTFN("finalizing device removal");
drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,
drc->detach_cb_opaque, NULL);
}
}
return RTAS_OUT_SUCCESS;
} | [
"static uint32_t FUNC_0(sPAPRDRConnector *drc,\nsPAPRDRAllocationState state)\n{",
"sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"DPRINTFN(\"drc: %x, FUNC_0: %x\", get_index(drc), state);",
"if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {",
"if (!drc->dev) {",
"return RTAS_OUT_NO_SUCH_INDICATOR;",
"}",
"}",
"if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {",
"drc->allocation_state = state;",
"if (drc->awaiting_release &&\ndrc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {",
"DPRINTFN(\"finalizing device removal\");",
"drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,\ndrc->detach_cb_opaque, NULL);",
"}",
"}",
"return RTAS_OUT_SUCCESS;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
]
]
|
13,882 | int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
{
BaumDriverState *baum;
CharDriverState *chr;
brlapi_handle_t *handle;
#ifdef CONFIG_SDL
SDL_SysWMinfo info;
#endif
int tty;
baum = g_malloc0(sizeof(BaumDriverState));
baum->chr = chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = baum;
chr->chr_write = baum_write;
chr->chr_accept_input = baum_accept_input;
chr->chr_close = baum_close;
handle = g_malloc0(brlapi_getHandleSize());
baum->brlapi = handle;
baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
if (baum->brlapi_fd == -1) {
brlapi_perror("baum_init: brlapi_openConnection");
goto fail_handle;
}
baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);
if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
brlapi_perror("baum_init: brlapi_getDisplaySize");
goto fail;
}
#ifdef CONFIG_SDL
memset(&info, 0, sizeof(info));
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info))
tty = info.info.x11.wmwindow;
else
#endif
tty = BRLAPI_TTY_DEFAULT;
if (brlapi__enterTtyMode(handle, tty, NULL) == -1) {
brlapi_perror("baum_init: brlapi_enterTtyMode");
goto fail;
}
qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
qemu_chr_generic_open(chr);
*_chr = chr;
return 0;
fail:
qemu_free_timer(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
g_free(handle);
g_free(chr);
g_free(baum);
return -EIO;
}
| true | qemu | 1f51470d044852592922f91000e741c381582cdc | int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
{
BaumDriverState *baum;
CharDriverState *chr;
brlapi_handle_t *handle;
#ifdef CONFIG_SDL
SDL_SysWMinfo info;
#endif
int tty;
baum = g_malloc0(sizeof(BaumDriverState));
baum->chr = chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = baum;
chr->chr_write = baum_write;
chr->chr_accept_input = baum_accept_input;
chr->chr_close = baum_close;
handle = g_malloc0(brlapi_getHandleSize());
baum->brlapi = handle;
baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
if (baum->brlapi_fd == -1) {
brlapi_perror("baum_init: brlapi_openConnection");
goto fail_handle;
}
baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);
if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
brlapi_perror("baum_init: brlapi_getDisplaySize");
goto fail;
}
#ifdef CONFIG_SDL
memset(&info, 0, sizeof(info));
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info))
tty = info.info.x11.wmwindow;
else
#endif
tty = BRLAPI_TTY_DEFAULT;
if (brlapi__enterTtyMode(handle, tty, NULL) == -1) {
brlapi_perror("baum_init: brlapi_enterTtyMode");
goto fail;
}
qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
qemu_chr_generic_open(chr);
*_chr = chr;
return 0;
fail:
qemu_free_timer(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
g_free(handle);
g_free(chr);
g_free(baum);
return -EIO;
}
| {
"code": [
" *_chr = chr;",
" return 0;",
"int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)",
" *_chr = chr;",
" return 0;",
" return -EIO;",
" *_chr = chr;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;"
],
"line_no": [
105,
107,
1,
105,
107,
125,
105,
107,
107,
107,
107,
105,
107,
105,
107,
105,
107,
105,
107,
105,
107,
105,
107,
105,
107,
107,
105,
107,
105,
107,
105,
107,
105,
107
]
} | int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{
BaumDriverState *baum;
CharDriverState *chr;
brlapi_handle_t *handle;
#ifdef CONFIG_SDL
SDL_SysWMinfo info;
#endif
int VAR_2;
baum = g_malloc0(sizeof(BaumDriverState));
baum->chr = chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = baum;
chr->chr_write = baum_write;
chr->chr_accept_input = baum_accept_input;
chr->chr_close = baum_close;
handle = g_malloc0(brlapi_getHandleSize());
baum->brlapi = handle;
baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
if (baum->brlapi_fd == -1) {
brlapi_perror("baum_init: brlapi_openConnection");
goto fail_handle;
}
baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);
if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
brlapi_perror("baum_init: brlapi_getDisplaySize");
goto fail;
}
#ifdef CONFIG_SDL
memset(&info, 0, sizeof(info));
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info))
VAR_2 = info.info.x11.wmwindow;
else
#endif
VAR_2 = BRLAPI_TTY_DEFAULT;
if (brlapi__enterTtyMode(handle, VAR_2, NULL) == -1) {
brlapi_perror("baum_init: brlapi_enterTtyMode");
goto fail;
}
qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
qemu_chr_generic_open(chr);
*VAR_1 = chr;
return 0;
fail:
qemu_free_timer(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
g_free(handle);
g_free(chr);
g_free(baum);
return -EIO;
}
| [
"int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{",
"BaumDriverState *baum;",
"CharDriverState *chr;",
"brlapi_handle_t *handle;",
"#ifdef CONFIG_SDL\nSDL_SysWMinfo info;",
"#endif\nint VAR_2;",
"baum = g_malloc0(sizeof(BaumDriverState));",
"baum->chr = chr = g_malloc0(sizeof(CharDriverState));",
"chr->opaque = baum;",
"chr->chr_write = baum_write;",
"chr->chr_accept_input = baum_accept_input;",
"chr->chr_close = baum_close;",
"handle = g_malloc0(brlapi_getHandleSize());",
"baum->brlapi = handle;",
"baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);",
"if (baum->brlapi_fd == -1) {",
"brlapi_perror(\"baum_init: brlapi_openConnection\");",
"goto fail_handle;",
"}",
"baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);",
"if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {",
"brlapi_perror(\"baum_init: brlapi_getDisplaySize\");",
"goto fail;",
"}",
"#ifdef CONFIG_SDL\nmemset(&info, 0, sizeof(info));",
"SDL_VERSION(&info.version);",
"if (SDL_GetWMInfo(&info))\nVAR_2 = info.info.x11.wmwindow;",
"else\n#endif\nVAR_2 = BRLAPI_TTY_DEFAULT;",
"if (brlapi__enterTtyMode(handle, VAR_2, NULL) == -1) {",
"brlapi_perror(\"baum_init: brlapi_enterTtyMode\");",
"goto fail;",
"}",
"qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);",
"qemu_chr_generic_open(chr);",
"*VAR_1 = chr;",
"return 0;",
"fail:\nqemu_free_timer(baum->cellCount_timer);",
"brlapi__closeConnection(handle);",
"fail_handle:\ng_free(handle);",
"g_free(chr);",
"g_free(baum);",
"return -EIO;",
"}"
]
| [
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,
1,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79,
81,
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
105
],
[
107
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
]
]
|
13,883 | static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
{
IpvideoContext *s = avctx->priv_data;
s->avctx = avctx;
s->is_16bpp = avctx->bits_per_coded_sample == 16;
avctx->pix_fmt = s->is_16bpp ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_PAL8;
ff_hpeldsp_init(&s->hdsp, avctx->flags);
s->last_frame = av_frame_alloc();
s->second_last_frame = av_frame_alloc();
s->cur_decode_frame = av_frame_alloc();
s->prev_decode_frame = av_frame_alloc();
if (!s->last_frame || !s->second_last_frame ||
!s->cur_decode_frame || !s->prev_decode_frame) {
av_frame_free(&s->last_frame);
av_frame_free(&s->second_last_frame);
av_frame_free(&s->cur_decode_frame);
av_frame_free(&s->prev_decode_frame);
return AVERROR(ENOMEM);
}
s->cur_decode_frame->width = avctx->width;
s->prev_decode_frame->width = avctx->width;
s->cur_decode_frame->height = avctx->height;
s->prev_decode_frame->height = avctx->height;
s->cur_decode_frame->format = avctx->pix_fmt;
s->prev_decode_frame->format = avctx->pix_fmt;
ff_get_buffer(avctx, s->cur_decode_frame, 0);
ff_get_buffer(avctx, s->prev_decode_frame, 0);
return 0;
}
| true | FFmpeg | 60a45713e7bc94b079f8cd39cfaa300e9c381f62 | static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
{
IpvideoContext *s = avctx->priv_data;
s->avctx = avctx;
s->is_16bpp = avctx->bits_per_coded_sample == 16;
avctx->pix_fmt = s->is_16bpp ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_PAL8;
ff_hpeldsp_init(&s->hdsp, avctx->flags);
s->last_frame = av_frame_alloc();
s->second_last_frame = av_frame_alloc();
s->cur_decode_frame = av_frame_alloc();
s->prev_decode_frame = av_frame_alloc();
if (!s->last_frame || !s->second_last_frame ||
!s->cur_decode_frame || !s->prev_decode_frame) {
av_frame_free(&s->last_frame);
av_frame_free(&s->second_last_frame);
av_frame_free(&s->cur_decode_frame);
av_frame_free(&s->prev_decode_frame);
return AVERROR(ENOMEM);
}
s->cur_decode_frame->width = avctx->width;
s->prev_decode_frame->width = avctx->width;
s->cur_decode_frame->height = avctx->height;
s->prev_decode_frame->height = avctx->height;
s->cur_decode_frame->format = avctx->pix_fmt;
s->prev_decode_frame->format = avctx->pix_fmt;
ff_get_buffer(avctx, s->cur_decode_frame, 0);
ff_get_buffer(avctx, s->prev_decode_frame, 0);
return 0;
}
| {
"code": [
" av_frame_free(&s->last_frame);",
" av_frame_free(&s->second_last_frame);",
" av_frame_free(&s->cur_decode_frame);",
" av_frame_free(&s->prev_decode_frame);",
" return AVERROR(ENOMEM);",
" ff_get_buffer(avctx, s->cur_decode_frame, 0);",
" ff_get_buffer(avctx, s->prev_decode_frame, 0);"
],
"line_no": [
35,
37,
39,
41,
43,
63,
65
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
IpvideoContext *s = avctx->priv_data;
s->avctx = avctx;
s->is_16bpp = avctx->bits_per_coded_sample == 16;
avctx->pix_fmt = s->is_16bpp ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_PAL8;
ff_hpeldsp_init(&s->hdsp, avctx->flags);
s->last_frame = av_frame_alloc();
s->second_last_frame = av_frame_alloc();
s->cur_decode_frame = av_frame_alloc();
s->prev_decode_frame = av_frame_alloc();
if (!s->last_frame || !s->second_last_frame ||
!s->cur_decode_frame || !s->prev_decode_frame) {
av_frame_free(&s->last_frame);
av_frame_free(&s->second_last_frame);
av_frame_free(&s->cur_decode_frame);
av_frame_free(&s->prev_decode_frame);
return AVERROR(ENOMEM);
}
s->cur_decode_frame->width = avctx->width;
s->prev_decode_frame->width = avctx->width;
s->cur_decode_frame->height = avctx->height;
s->prev_decode_frame->height = avctx->height;
s->cur_decode_frame->format = avctx->pix_fmt;
s->prev_decode_frame->format = avctx->pix_fmt;
ff_get_buffer(avctx, s->cur_decode_frame, 0);
ff_get_buffer(avctx, s->prev_decode_frame, 0);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"IpvideoContext *s = avctx->priv_data;",
"s->avctx = avctx;",
"s->is_16bpp = avctx->bits_per_coded_sample == 16;",
"avctx->pix_fmt = s->is_16bpp ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_PAL8;",
"ff_hpeldsp_init(&s->hdsp, avctx->flags);",
"s->last_frame = av_frame_alloc();",
"s->second_last_frame = av_frame_alloc();",
"s->cur_decode_frame = av_frame_alloc();",
"s->prev_decode_frame = av_frame_alloc();",
"if (!s->last_frame || !s->second_last_frame ||\n!s->cur_decode_frame || !s->prev_decode_frame) {",
"av_frame_free(&s->last_frame);",
"av_frame_free(&s->second_last_frame);",
"av_frame_free(&s->cur_decode_frame);",
"av_frame_free(&s->prev_decode_frame);",
"return AVERROR(ENOMEM);",
"}",
"s->cur_decode_frame->width = avctx->width;",
"s->prev_decode_frame->width = avctx->width;",
"s->cur_decode_frame->height = avctx->height;",
"s->prev_decode_frame->height = avctx->height;",
"s->cur_decode_frame->format = avctx->pix_fmt;",
"s->prev_decode_frame->format = avctx->pix_fmt;",
"ff_get_buffer(avctx, s->cur_decode_frame, 0);",
"ff_get_buffer(avctx, s->prev_decode_frame, 0);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
]
]
|
13,884 | static int vvfat_open(BlockDriverState *bs, QDict *options, int flags)
{
BDRVVVFATState *s = bs->opaque;
int cyls, heads, secs;
bool floppy;
const char *dirname;
QemuOpts *opts;
Error *local_err = NULL;
int ret;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
opts = qemu_opts_create_nofail(&runtime_opts);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
ret = -EINVAL;
goto fail;
}
dirname = qemu_opt_get(opts, "dir");
if (!dirname) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "vvfat block driver requires "
"a 'dir' option");
ret = -EINVAL;
goto fail;
}
s->fat_type = qemu_opt_get_number(opts, "fat-type", 0);
floppy = qemu_opt_get_bool(opts, "floppy", false);
if (floppy) {
/* 1.44MB or 2.88MB floppy. 2.88MB can be FAT12 (default) or FAT16. */
if (!s->fat_type) {
s->fat_type = 12;
secs = 36;
s->sectors_per_cluster = 2;
} else {
secs = s->fat_type == 12 ? 18 : 36;
s->sectors_per_cluster = 1;
}
s->first_sectors_number = 1;
cyls = 80;
heads = 2;
} else {
/* 32MB or 504MB disk*/
if (!s->fat_type) {
s->fat_type = 16;
}
cyls = s->fat_type == 12 ? 64 : 1024;
heads = 16;
secs = 63;
}
switch (s->fat_type) {
case 32:
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. "
"You are welcome to do so!\n");
break;
case 16:
case 12:
break;
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Valid FAT types are only "
"12, 16 and 32");
ret = -EINVAL;
goto fail;
}
s->bs = bs;
/* LATER TODO: if FAT32, adjust */
s->sectors_per_cluster=0x10;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
/* read only is the default for safety */
bs->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
fprintf(stderr, "vvfat %s chs %d,%d,%d\n",
dirname, cyls, heads, secs);
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
if (qemu_opt_get_bool(opts, "rw", false)) {
if (enable_write_target(s)) {
ret = -EIO;
goto fail;
}
bs->read_only = 0;
}
bs->total_sectors = cyls * heads * secs;
if (init_directories(s, dirname, heads, secs)) {
ret = -EIO;
goto fail;
}
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if (s->first_sectors_number == 0x40) {
init_mbr(s, cyls, heads, secs);
}
// assert(is_consistent(s));
qemu_co_mutex_init(&s->lock);
/* Disable migration when vvfat is used rw */
if (s->qcow) {
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vvfat (rw)", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
}
ret = 0;
fail:
qemu_opts_del(opts);
return ret;
}
| true | qemu | 78f27bd02ceba4a2f6ac5c725f4d4410eec205ef | static int vvfat_open(BlockDriverState *bs, QDict *options, int flags)
{
BDRVVVFATState *s = bs->opaque;
int cyls, heads, secs;
bool floppy;
const char *dirname;
QemuOpts *opts;
Error *local_err = NULL;
int ret;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
opts = qemu_opts_create_nofail(&runtime_opts);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
ret = -EINVAL;
goto fail;
}
dirname = qemu_opt_get(opts, "dir");
if (!dirname) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "vvfat block driver requires "
"a 'dir' option");
ret = -EINVAL;
goto fail;
}
s->fat_type = qemu_opt_get_number(opts, "fat-type", 0);
floppy = qemu_opt_get_bool(opts, "floppy", false);
if (floppy) {
if (!s->fat_type) {
s->fat_type = 12;
secs = 36;
s->sectors_per_cluster = 2;
} else {
secs = s->fat_type == 12 ? 18 : 36;
s->sectors_per_cluster = 1;
}
s->first_sectors_number = 1;
cyls = 80;
heads = 2;
} else {
if (!s->fat_type) {
s->fat_type = 16;
}
cyls = s->fat_type == 12 ? 64 : 1024;
heads = 16;
secs = 63;
}
switch (s->fat_type) {
case 32:
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. "
"You are welcome to do so!\n");
break;
case 16:
case 12:
break;
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Valid FAT types are only "
"12, 16 and 32");
ret = -EINVAL;
goto fail;
}
s->bs = bs;
s->sectors_per_cluster=0x10;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
bs->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
fprintf(stderr, "vvfat %s chs %d,%d,%d\n",
dirname, cyls, heads, secs);
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
if (qemu_opt_get_bool(opts, "rw", false)) {
if (enable_write_target(s)) {
ret = -EIO;
goto fail;
}
bs->read_only = 0;
}
bs->total_sectors = cyls * heads * secs;
if (init_directories(s, dirname, heads, secs)) {
ret = -EIO;
goto fail;
}
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if (s->first_sectors_number == 0x40) {
init_mbr(s, cyls, heads, secs);
}
qemu_co_mutex_init(&s->lock);
if (s->qcow) {
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vvfat (rw)", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
}
ret = 0;
fail:
qemu_opts_del(opts);
return ret;
}
| {
"code": [
" if (enable_write_target(s)) {",
" ret = -EIO;"
],
"line_no": [
199,
201
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2)
{
BDRVVVFATState *s = VAR_0->opaque;
int VAR_3, VAR_4, VAR_5;
bool floppy;
const char *VAR_6;
QemuOpts *opts;
Error *local_err = NULL;
int VAR_7;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
opts = qemu_opts_create_nofail(&runtime_opts);
qemu_opts_absorb_qdict(opts, VAR_1, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
VAR_7 = -EINVAL;
goto fail;
}
VAR_6 = qemu_opt_get(opts, "dir");
if (!VAR_6) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "vvfat block driver requires "
"a 'dir' option");
VAR_7 = -EINVAL;
goto fail;
}
s->fat_type = qemu_opt_get_number(opts, "fat-type", 0);
floppy = qemu_opt_get_bool(opts, "floppy", false);
if (floppy) {
if (!s->fat_type) {
s->fat_type = 12;
VAR_5 = 36;
s->sectors_per_cluster = 2;
} else {
VAR_5 = s->fat_type == 12 ? 18 : 36;
s->sectors_per_cluster = 1;
}
s->first_sectors_number = 1;
VAR_3 = 80;
VAR_4 = 2;
} else {
if (!s->fat_type) {
s->fat_type = 16;
}
VAR_3 = s->fat_type == 12 ? 64 : 1024;
VAR_4 = 16;
VAR_5 = 63;
}
switch (s->fat_type) {
case 32:
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. "
"You are welcome to do so!\n");
break;
case 16:
case 12:
break;
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Valid FAT types are only "
"12, 16 and 32");
VAR_7 = -EINVAL;
goto fail;
}
s->VAR_0 = VAR_0;
s->sectors_per_cluster=0x10;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
VAR_0->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
fprintf(stderr, "vvfat %s chs %d,%d,%d\n",
VAR_6, VAR_3, VAR_4, VAR_5);
s->sector_count = VAR_3 * VAR_4 * VAR_5 - (s->first_sectors_number - 1);
if (qemu_opt_get_bool(opts, "rw", false)) {
if (enable_write_target(s)) {
VAR_7 = -EIO;
goto fail;
}
VAR_0->read_only = 0;
}
VAR_0->total_sectors = VAR_3 * VAR_4 * VAR_5;
if (init_directories(s, VAR_6, VAR_4, VAR_5)) {
VAR_7 = -EIO;
goto fail;
}
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if (s->first_sectors_number == 0x40) {
init_mbr(s, VAR_3, VAR_4, VAR_5);
}
qemu_co_mutex_init(&s->lock);
if (s->qcow) {
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vvfat (rw)", VAR_0->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
}
VAR_7 = 0;
fail:
qemu_opts_del(opts);
return VAR_7;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2)\n{",
"BDRVVVFATState *s = VAR_0->opaque;",
"int VAR_3, VAR_4, VAR_5;",
"bool floppy;",
"const char *VAR_6;",
"QemuOpts *opts;",
"Error *local_err = NULL;",
"int VAR_7;",
"#ifdef DEBUG\nvvv = s;",
"#endif\nDLOG(if (stderr == NULL) {",
"stderr = fopen(\"vvfat.log\", \"a\");",
"setbuf(stderr, NULL);",
"})",
"opts = qemu_opts_create_nofail(&runtime_opts);",
"qemu_opts_absorb_qdict(opts, VAR_1, &local_err);",
"if (error_is_set(&local_err)) {",
"qerror_report_err(local_err);",
"error_free(local_err);",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"VAR_6 = qemu_opt_get(opts, \"dir\");",
"if (!VAR_6) {",
"qerror_report(ERROR_CLASS_GENERIC_ERROR, \"vvfat block driver requires \"\n\"a 'dir' option\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"s->fat_type = qemu_opt_get_number(opts, \"fat-type\", 0);",
"floppy = qemu_opt_get_bool(opts, \"floppy\", false);",
"if (floppy) {",
"if (!s->fat_type) {",
"s->fat_type = 12;",
"VAR_5 = 36;",
"s->sectors_per_cluster = 2;",
"} else {",
"VAR_5 = s->fat_type == 12 ? 18 : 36;",
"s->sectors_per_cluster = 1;",
"}",
"s->first_sectors_number = 1;",
"VAR_3 = 80;",
"VAR_4 = 2;",
"} else {",
"if (!s->fat_type) {",
"s->fat_type = 16;",
"}",
"VAR_3 = s->fat_type == 12 ? 64 : 1024;",
"VAR_4 = 16;",
"VAR_5 = 63;",
"}",
"switch (s->fat_type) {",
"case 32:\nfprintf(stderr, \"Big fat greek warning: FAT32 has not been tested. \"\n\"You are welcome to do so!\\n\");",
"break;",
"case 16:\ncase 12:\nbreak;",
"default:\nqerror_report(ERROR_CLASS_GENERIC_ERROR, \"Valid FAT types are only \"\n\"12, 16 and 32\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"s->VAR_0 = VAR_0;",
"s->sectors_per_cluster=0x10;",
"s->current_cluster=0xffffffff;",
"s->first_sectors_number=0x40;",
"VAR_0->read_only = 1;",
"s->qcow = s->write_target = NULL;",
"s->qcow_filename = NULL;",
"s->fat2 = NULL;",
"s->downcase_short_names = 1;",
"fprintf(stderr, \"vvfat %s chs %d,%d,%d\\n\",\nVAR_6, VAR_3, VAR_4, VAR_5);",
"s->sector_count = VAR_3 * VAR_4 * VAR_5 - (s->first_sectors_number - 1);",
"if (qemu_opt_get_bool(opts, \"rw\", false)) {",
"if (enable_write_target(s)) {",
"VAR_7 = -EIO;",
"goto fail;",
"}",
"VAR_0->read_only = 0;",
"}",
"VAR_0->total_sectors = VAR_3 * VAR_4 * VAR_5;",
"if (init_directories(s, VAR_6, VAR_4, VAR_5)) {",
"VAR_7 = -EIO;",
"goto fail;",
"}",
"s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;",
"if (s->first_sectors_number == 0x40) {",
"init_mbr(s, VAR_3, VAR_4, VAR_5);",
"}",
"qemu_co_mutex_init(&s->lock);",
"if (s->qcow) {",
"error_set(&s->migration_blocker,\nQERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,\n\"vvfat (rw)\", VAR_0->device_name, \"live migration\");",
"migrate_add_blocker(s->migration_blocker);",
"}",
"VAR_7 = 0;",
"fail:\nqemu_opts_del(opts);",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135,
137,
139
],
[
141,
143,
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
163
],
[
167
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
231
],
[
233
],
[
235
],
[
241
],
[
247
],
[
249,
251,
253
],
[
255
],
[
257
],
[
261
],
[
263,
265
],
[
267
],
[
269
]
]
|
13,885 | static int v4l2_try_start(AVCodecContext *avctx)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *const capture = &s->capture;
V4L2Context *const output = &s->output;
struct v4l2_selection selection;
int ret;
/* 1. start the output process */
if (!output->streamon) {
ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
if (ret < 0) {
av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON on output context\n");
return ret;
}
}
if (capture->streamon)
return 0;
/* 2. get the capture format */
capture->format.type = capture->type;
ret = ioctl(s->fd, VIDIOC_G_FMT, &capture->format);
if (ret) {
av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n");
return ret;
}
/* 2.1 update the AVCodecContext */
avctx->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO);
capture->av_pix_fmt = avctx->pix_fmt;
/* 3. set the crop parameters */
selection.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
selection.r.height = avctx->coded_height;
selection.r.width = avctx->coded_width;
ret = ioctl(s->fd, VIDIOC_S_SELECTION, &selection);
if (!ret) {
ret = ioctl(s->fd, VIDIOC_G_SELECTION, &selection);
if (ret) {
av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_SELECTION ioctl\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "crop output %dx%d\n", selection.r.width, selection.r.height);
/* update the size of the resulting frame */
capture->height = selection.r.height;
capture->width = selection.r.width;
}
}
/* 4. init the capture context now that we have the capture format */
if (!capture->buffers) {
ret = ff_v4l2_context_init(capture);
if (ret) {
av_log(avctx, AV_LOG_DEBUG, "can't request output buffers\n");
return ret;
}
}
/* 5. start the capture process */
ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
if (ret) {
av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n");
return ret;
}
return 0;
}
| true | FFmpeg | a0c624e299730c8c5800375c2f5f3c6c200053ff | static int v4l2_try_start(AVCodecContext *avctx)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *const capture = &s->capture;
V4L2Context *const output = &s->output;
struct v4l2_selection selection;
int ret;
if (!output->streamon) {
ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
if (ret < 0) {
av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON on output context\n");
return ret;
}
}
if (capture->streamon)
return 0;
capture->format.type = capture->type;
ret = ioctl(s->fd, VIDIOC_G_FMT, &capture->format);
if (ret) {
av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n");
return ret;
}
avctx->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO);
capture->av_pix_fmt = avctx->pix_fmt;
selection.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
selection.r.height = avctx->coded_height;
selection.r.width = avctx->coded_width;
ret = ioctl(s->fd, VIDIOC_S_SELECTION, &selection);
if (!ret) {
ret = ioctl(s->fd, VIDIOC_G_SELECTION, &selection);
if (ret) {
av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_SELECTION ioctl\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "crop output %dx%d\n", selection.r.width, selection.r.height);
capture->height = selection.r.height;
capture->width = selection.r.width;
}
}
if (!capture->buffers) {
ret = ff_v4l2_context_init(capture);
if (ret) {
av_log(avctx, AV_LOG_DEBUG, "can't request output buffers\n");
return ret;
}
}
ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
if (ret) {
av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n");
return ret;
}
return 0;
}
| {
"code": [
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
V4L2m2mContext *s = VAR_0->priv_data;
V4L2Context *const capture = &s->capture;
V4L2Context *const output = &s->output;
struct v4l2_selection VAR_1;
int VAR_2;
if (!output->streamon) {
VAR_2 = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_DEBUG, "VIDIOC_STREAMON on output context\n");
return VAR_2;
}
}
if (capture->streamon)
return 0;
capture->format.type = capture->type;
VAR_2 = ioctl(s->fd, VIDIOC_G_FMT, &capture->format);
if (VAR_2) {
av_log(VAR_0, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n");
return VAR_2;
}
VAR_0->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO);
capture->av_pix_fmt = VAR_0->pix_fmt;
VAR_1.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
VAR_1.r.height = VAR_0->coded_height;
VAR_1.r.width = VAR_0->coded_width;
VAR_2 = ioctl(s->fd, VIDIOC_S_SELECTION, &VAR_1);
if (!VAR_2) {
VAR_2 = ioctl(s->fd, VIDIOC_G_SELECTION, &VAR_1);
if (VAR_2) {
av_log(VAR_0, AV_LOG_WARNING, "VIDIOC_G_SELECTION ioctl\n");
} else {
av_log(VAR_0, AV_LOG_DEBUG, "crop output %dx%d\n", VAR_1.r.width, VAR_1.r.height);
capture->height = VAR_1.r.height;
capture->width = VAR_1.r.width;
}
}
if (!capture->buffers) {
VAR_2 = ff_v4l2_context_init(capture);
if (VAR_2) {
av_log(VAR_0, AV_LOG_DEBUG, "can't request output buffers\n");
return VAR_2;
}
}
VAR_2 = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
if (VAR_2) {
av_log(VAR_0, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n");
return VAR_2;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"V4L2m2mContext *s = VAR_0->priv_data;",
"V4L2Context *const capture = &s->capture;",
"V4L2Context *const output = &s->output;",
"struct v4l2_selection VAR_1;",
"int VAR_2;",
"if (!output->streamon) {",
"VAR_2 = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"VIDIOC_STREAMON on output context\\n\");",
"return VAR_2;",
"}",
"}",
"if (capture->streamon)\nreturn 0;",
"capture->format.type = capture->type;",
"VAR_2 = ioctl(s->fd, VIDIOC_G_FMT, &capture->format);",
"if (VAR_2) {",
"av_log(VAR_0, AV_LOG_WARNING, \"VIDIOC_G_FMT ioctl\\n\");",
"return VAR_2;",
"}",
"VAR_0->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO);",
"capture->av_pix_fmt = VAR_0->pix_fmt;",
"VAR_1.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;",
"VAR_1.r.height = VAR_0->coded_height;",
"VAR_1.r.width = VAR_0->coded_width;",
"VAR_2 = ioctl(s->fd, VIDIOC_S_SELECTION, &VAR_1);",
"if (!VAR_2) {",
"VAR_2 = ioctl(s->fd, VIDIOC_G_SELECTION, &VAR_1);",
"if (VAR_2) {",
"av_log(VAR_0, AV_LOG_WARNING, \"VIDIOC_G_SELECTION ioctl\\n\");",
"} else {",
"av_log(VAR_0, AV_LOG_DEBUG, \"crop output %dx%d\\n\", VAR_1.r.width, VAR_1.r.height);",
"capture->height = VAR_1.r.height;",
"capture->width = VAR_1.r.width;",
"}",
"}",
"if (!capture->buffers) {",
"VAR_2 = ff_v4l2_context_init(capture);",
"if (VAR_2) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"can't request output buffers\\n\");",
"return VAR_2;",
"}",
"}",
"VAR_2 = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);",
"if (VAR_2) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"VIDIOC_STREAMON, on capture context\\n\");",
"return VAR_2;",
"}",
"return 0;",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
]
]
|
13,887 | static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int i, ret;
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
#if CONFIG_THEORA_DECODER
if (s->theora && get_bits1(&gb)) {
int type = get_bits(&gb, 7);
skip_bits_long(&gb, 6*8); /* "theora" */
if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
return AVERROR_PATCHWELCOME;
}
if (type == 0) {
vp3_decode_end(avctx);
ret = theora_decode_header(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
} else if (type == 2) {
ret = theora_decode_tables(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
}
av_log(avctx, AV_LOG_ERROR,
"Header packet passed to frame decoder, skipping\n");
return -1;
}
#endif
s->keyframe = !get_bits1(&gb);
if (!s->all_fragments) {
av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
return -1;
}
if (!s->theora)
skip_bits(&gb, 1);
for (i = 0; i < 3; i++)
s->last_qps[i] = s->qps[i];
s->nqps = 0;
do {
s->qps[s->nqps++] = get_bits(&gb, 6);
} while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));
for (i = s->nqps; i < 3; i++)
s->qps[i] = -1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
: AVDISCARD_NONKEY);
if (s->qps[0] != s->last_qps[0])
init_loop_filter(s);
for (i = 0; i < s->nqps; i++)
// reinit all dequantizers if the first one changed, because
// the DC of the first quantizer must be used for all matrices
if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0])
init_dequantizer(s, i);
if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
return buf_size;
s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
s->current_frame.f->key_frame = s->keyframe;
if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
if (!s->edge_emu_buffer)
s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
if (s->keyframe) {
if (!s->theora) {
skip_bits(&gb, 4); /* width code */
skip_bits(&gb, 4); /* height code */
if (s->version) {
s->version = get_bits(&gb, 5);
if (avctx->frame_number == 0)
av_log(s->avctx, AV_LOG_DEBUG,
"VP version: %d\n", s->version);
}
}
if (s->version || s->theora) {
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR,
"Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2); /* reserved? */
}
} else {
if (!s->golden_frame.f->data[0]) {
av_log(s->avctx, AV_LOG_WARNING,
"vp3: first frame not a keyframe\n");
s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(avctx, &s->golden_frame,
AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
ff_thread_release_buffer(avctx, &s->last_frame);
if ((ret = ff_thread_ref_frame(&s->last_frame,
&s->golden_frame)) < 0)
goto error;
ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
}
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
ff_thread_finish_setup(avctx);
if (unpack_superblocks(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
goto error;
}
if (unpack_modes(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
goto error;
}
if (unpack_vectors(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
goto error;
}
if (unpack_block_qpis(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n");
goto error;
}
if (unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
goto error;
}
for (i = 0; i < 3; i++) {
int height = s->height >> (i && s->chroma_y_shift);
if (s->flipped_image)
s->data_offset[i] = 0;
else
s->data_offset[i] = (height - 1) * s->current_frame.f->linesize[i];
}
s->last_slice_end = 0;
for (i = 0; i < s->c_superblock_height; i++)
render_slice(s, i);
// filter the last row
for (i = 0; i < 3; i++) {
int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1;
apply_loop_filter(s, i, row, row + 1);
}
vp3_draw_horiz_band(s, s->height);
/* output frame, offset as needed */
if ((ret = av_frame_ref(data, s->current_frame.f)) < 0)
return ret;
for (i = 0; i < 3; i++) {
AVFrame *dst = data;
int off = (s->offset_x >> (i && s->chroma_y_shift)) +
(s->offset_y >> (i && s->chroma_y_shift)) * dst->linesize[i];
dst->data[i] += off;
}
*got_frame = 1;
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
ret = update_frames(avctx);
if (ret < 0)
return ret;
}
return buf_size;
error:
ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME))
av_frame_unref(s->current_frame.f);
return -1;
}
| true | FFmpeg | 6105b7219a90438deae71b0dc5a034c71ee30fc0 | static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int i, ret;
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
#if CONFIG_THEORA_DECODER
if (s->theora && get_bits1(&gb)) {
int type = get_bits(&gb, 7);
skip_bits_long(&gb, 6*8);
if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
return AVERROR_PATCHWELCOME;
}
if (type == 0) {
vp3_decode_end(avctx);
ret = theora_decode_header(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
} else if (type == 2) {
ret = theora_decode_tables(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
}
av_log(avctx, AV_LOG_ERROR,
"Header packet passed to frame decoder, skipping\n");
return -1;
}
#endif
s->keyframe = !get_bits1(&gb);
if (!s->all_fragments) {
av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
return -1;
}
if (!s->theora)
skip_bits(&gb, 1);
for (i = 0; i < 3; i++)
s->last_qps[i] = s->qps[i];
s->nqps = 0;
do {
s->qps[s->nqps++] = get_bits(&gb, 6);
} while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));
for (i = s->nqps; i < 3; i++)
s->qps[i] = -1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
: AVDISCARD_NONKEY);
if (s->qps[0] != s->last_qps[0])
init_loop_filter(s);
for (i = 0; i < s->nqps; i++)
if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0])
init_dequantizer(s, i);
if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
return buf_size;
s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
s->current_frame.f->key_frame = s->keyframe;
if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
if (!s->edge_emu_buffer)
s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
if (s->keyframe) {
if (!s->theora) {
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version) {
s->version = get_bits(&gb, 5);
if (avctx->frame_number == 0)
av_log(s->avctx, AV_LOG_DEBUG,
"VP version: %d\n", s->version);
}
}
if (s->version || s->theora) {
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR,
"Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
} else {
if (!s->golden_frame.f->data[0]) {
av_log(s->avctx, AV_LOG_WARNING,
"vp3: first frame not a keyframe\n");
s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(avctx, &s->golden_frame,
AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
ff_thread_release_buffer(avctx, &s->last_frame);
if ((ret = ff_thread_ref_frame(&s->last_frame,
&s->golden_frame)) < 0)
goto error;
ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
}
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
ff_thread_finish_setup(avctx);
if (unpack_superblocks(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
goto error;
}
if (unpack_modes(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
goto error;
}
if (unpack_vectors(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
goto error;
}
if (unpack_block_qpis(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n");
goto error;
}
if (unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
goto error;
}
for (i = 0; i < 3; i++) {
int height = s->height >> (i && s->chroma_y_shift);
if (s->flipped_image)
s->data_offset[i] = 0;
else
s->data_offset[i] = (height - 1) * s->current_frame.f->linesize[i];
}
s->last_slice_end = 0;
for (i = 0; i < s->c_superblock_height; i++)
render_slice(s, i);
for (i = 0; i < 3; i++) {
int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1;
apply_loop_filter(s, i, row, row + 1);
}
vp3_draw_horiz_band(s, s->height);
if ((ret = av_frame_ref(data, s->current_frame.f)) < 0)
return ret;
for (i = 0; i < 3; i++) {
AVFrame *dst = data;
int off = (s->offset_x >> (i && s->chroma_y_shift)) +
(s->offset_y >> (i && s->chroma_y_shift)) * dst->linesize[i];
dst->data[i] += off;
}
*got_frame = 1;
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
ret = update_frames(avctx);
if (ret < 0)
return ret;
}
return buf_size;
error:
ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME))
av_frame_unref(s->current_frame.f);
return -1;
}
| {
"code": [
" } else",
" ret = vp3_decode_init(avctx);",
" } else",
" ret = vp3_decode_init(avctx);"
],
"line_no": [
57,
59,
57,
59
]
} | 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;
Vp3DecodeContext *s = VAR_0->priv_data;
GetBitContext gb;
int VAR_6, VAR_7;
if ((VAR_7 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)
return VAR_7;
#if CONFIG_THEORA_DECODER
if (s->theora && get_bits1(&gb)) {
int type = get_bits(&gb, 7);
skip_bits_long(&gb, 6*8);
if (s->VAR_0->active_thread_type&FF_THREAD_FRAME) {
av_log(VAR_0, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
return AVERROR_PATCHWELCOME;
}
if (type == 0) {
vp3_decode_end(VAR_0);
VAR_7 = theora_decode_header(VAR_0, &gb);
if (VAR_7 < 0) {
vp3_decode_end(VAR_0);
} else
VAR_7 = vp3_decode_init(VAR_0);
return VAR_7;
} else if (type == 2) {
VAR_7 = theora_decode_tables(VAR_0, &gb);
if (VAR_7 < 0) {
vp3_decode_end(VAR_0);
} else
VAR_7 = vp3_decode_init(VAR_0);
return VAR_7;
}
av_log(VAR_0, AV_LOG_ERROR,
"Header packet passed to frame decoder, skipping\n");
return -1;
}
#endif
s->keyframe = !get_bits1(&gb);
if (!s->all_fragments) {
av_log(VAR_0, AV_LOG_ERROR, "Data packet without prior valid headers\n");
return -1;
}
if (!s->theora)
skip_bits(&gb, 1);
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
s->last_qps[VAR_6] = s->qps[VAR_6];
s->nqps = 0;
do {
s->qps[s->nqps++] = get_bits(&gb, 6);
} while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));
for (VAR_6 = s->nqps; VAR_6 < 3; VAR_6++)
s->qps[VAR_6] = -1;
if (s->VAR_0->debug & FF_DEBUG_PICT_INFO)
av_log(s->VAR_0, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe ? "key" : "", VAR_0->frame_number + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
VAR_0->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
: AVDISCARD_NONKEY);
if (s->qps[0] != s->last_qps[0])
init_loop_filter(s);
for (VAR_6 = 0; VAR_6 < s->nqps; VAR_6++)
if (s->qps[VAR_6] != s->last_qps[VAR_6] || s->qps[0] != s->last_qps[0])
init_dequantizer(s, VAR_6);
if (VAR_0->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
return VAR_5;
s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
s->current_frame.f->key_frame = s->keyframe;
if (ff_thread_get_buffer(VAR_0, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
if (!s->edge_emu_buffer)
s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
if (s->keyframe) {
if (!s->theora) {
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version) {
s->version = get_bits(&gb, 5);
if (VAR_0->frame_number == 0)
av_log(s->VAR_0, AV_LOG_DEBUG,
"VP version: %d\n", s->version);
}
}
if (s->version || s->theora) {
if (get_bits1(&gb))
av_log(s->VAR_0, AV_LOG_ERROR,
"Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
} else {
if (!s->golden_frame.f->VAR_1[0]) {
av_log(s->VAR_0, AV_LOG_WARNING,
"vp3: first frame not a keyframe\n");
s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(VAR_0, &s->golden_frame,
AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
ff_thread_release_buffer(VAR_0, &s->last_frame);
if ((VAR_7 = ff_thread_ref_frame(&s->last_frame,
&s->golden_frame)) < 0)
goto error;
ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
}
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
ff_thread_finish_setup(VAR_0);
if (unpack_superblocks(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "error in unpack_superblocks\n");
goto error;
}
if (unpack_modes(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "error in unpack_modes\n");
goto error;
}
if (unpack_vectors(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "error in unpack_vectors\n");
goto error;
}
if (unpack_block_qpis(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "error in unpack_block_qpis\n");
goto error;
}
if (unpack_dct_coeffs(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
goto error;
}
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
int VAR_8 = s->VAR_8 >> (VAR_6 && s->chroma_y_shift);
if (s->flipped_image)
s->data_offset[VAR_6] = 0;
else
s->data_offset[VAR_6] = (VAR_8 - 1) * s->current_frame.f->linesize[VAR_6];
}
s->last_slice_end = 0;
for (VAR_6 = 0; VAR_6 < s->c_superblock_height; VAR_6++)
render_slice(s, VAR_6);
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
int VAR_9 = (s->VAR_8 >> (3 + (VAR_6 && s->chroma_y_shift))) - 1;
apply_loop_filter(s, VAR_6, VAR_9, VAR_9 + 1);
}
vp3_draw_horiz_band(s, s->VAR_8);
if ((VAR_7 = av_frame_ref(VAR_1, s->current_frame.f)) < 0)
return VAR_7;
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
AVFrame *dst = VAR_1;
int VAR_10 = (s->offset_x >> (VAR_6 && s->chroma_y_shift)) +
(s->offset_y >> (VAR_6 && s->chroma_y_shift)) * dst->linesize[VAR_6];
dst->VAR_1[VAR_6] += VAR_10;
}
*VAR_2 = 1;
if (!HAVE_THREADS || !(s->VAR_0->active_thread_type & FF_THREAD_FRAME)) {
VAR_7 = update_frames(VAR_0);
if (VAR_7 < 0)
return VAR_7;
}
return VAR_5;
error:
ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
if (!HAVE_THREADS || !(s->VAR_0->active_thread_type & FF_THREAD_FRAME))
av_frame_unref(s->current_frame.f);
return -1;
}
| [
"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;",
"Vp3DecodeContext *s = VAR_0->priv_data;",
"GetBitContext gb;",
"int VAR_6, VAR_7;",
"if ((VAR_7 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)\nreturn VAR_7;",
"#if CONFIG_THEORA_DECODER\nif (s->theora && get_bits1(&gb)) {",
"int type = get_bits(&gb, 7);",
"skip_bits_long(&gb, 6*8);",
"if (s->VAR_0->active_thread_type&FF_THREAD_FRAME) {",
"av_log(VAR_0, AV_LOG_ERROR, \"midstream reconfiguration with multithreading is unsupported, try -threads 1\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (type == 0) {",
"vp3_decode_end(VAR_0);",
"VAR_7 = theora_decode_header(VAR_0, &gb);",
"if (VAR_7 < 0) {",
"vp3_decode_end(VAR_0);",
"} else",
"VAR_7 = vp3_decode_init(VAR_0);",
"return VAR_7;",
"} else if (type == 2) {",
"VAR_7 = theora_decode_tables(VAR_0, &gb);",
"if (VAR_7 < 0) {",
"vp3_decode_end(VAR_0);",
"} else",
"VAR_7 = vp3_decode_init(VAR_0);",
"return VAR_7;",
"}",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Header packet passed to frame decoder, skipping\\n\");",
"return -1;",
"}",
"#endif\ns->keyframe = !get_bits1(&gb);",
"if (!s->all_fragments) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Data packet without prior valid headers\\n\");",
"return -1;",
"}",
"if (!s->theora)\nskip_bits(&gb, 1);",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"s->last_qps[VAR_6] = s->qps[VAR_6];",
"s->nqps = 0;",
"do {",
"s->qps[s->nqps++] = get_bits(&gb, 6);",
"} while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));",
"for (VAR_6 = s->nqps; VAR_6 < 3; VAR_6++)",
"s->qps[VAR_6] = -1;",
"if (s->VAR_0->debug & FF_DEBUG_PICT_INFO)\nav_log(s->VAR_0, AV_LOG_INFO, \" VP3 %sframe #%d: Q index = %d\\n\",\ns->keyframe ? \"key\" : \"\", VAR_0->frame_number + 1, s->qps[0]);",
"s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||\nVAR_0->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL\n: AVDISCARD_NONKEY);",
"if (s->qps[0] != s->last_qps[0])\ninit_loop_filter(s);",
"for (VAR_6 = 0; VAR_6 < s->nqps; VAR_6++)",
"if (s->qps[VAR_6] != s->last_qps[VAR_6] || s->qps[0] != s->last_qps[0])\ninit_dequantizer(s, VAR_6);",
"if (VAR_0->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)\nreturn VAR_5;",
"s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I\n: AV_PICTURE_TYPE_P;",
"s->current_frame.f->key_frame = s->keyframe;",
"if (ff_thread_get_buffer(VAR_0, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)\ngoto error;",
"if (!s->edge_emu_buffer)\ns->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));",
"if (s->keyframe) {",
"if (!s->theora) {",
"skip_bits(&gb, 4);",
"skip_bits(&gb, 4);",
"if (s->version) {",
"s->version = get_bits(&gb, 5);",
"if (VAR_0->frame_number == 0)\nav_log(s->VAR_0, AV_LOG_DEBUG,\n\"VP version: %d\\n\", s->version);",
"}",
"}",
"if (s->version || s->theora) {",
"if (get_bits1(&gb))\nav_log(s->VAR_0, AV_LOG_ERROR,\n\"Warning, unsupported keyframe coding type?!\\n\");",
"skip_bits(&gb, 2);",
"}",
"} else {",
"if (!s->golden_frame.f->VAR_1[0]) {",
"av_log(s->VAR_0, AV_LOG_WARNING,\n\"vp3: first frame not a keyframe\\n\");",
"s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;",
"if (ff_thread_get_buffer(VAR_0, &s->golden_frame,\nAV_GET_BUFFER_FLAG_REF) < 0)\ngoto error;",
"ff_thread_release_buffer(VAR_0, &s->last_frame);",
"if ((VAR_7 = ff_thread_ref_frame(&s->last_frame,\n&s->golden_frame)) < 0)\ngoto error;",
"ff_thread_report_progress(&s->last_frame, INT_MAX, 0);",
"}",
"}",
"memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));",
"ff_thread_finish_setup(VAR_0);",
"if (unpack_superblocks(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"error in unpack_superblocks\\n\");",
"goto error;",
"}",
"if (unpack_modes(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"error in unpack_modes\\n\");",
"goto error;",
"}",
"if (unpack_vectors(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"error in unpack_vectors\\n\");",
"goto error;",
"}",
"if (unpack_block_qpis(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"error in unpack_block_qpis\\n\");",
"goto error;",
"}",
"if (unpack_dct_coeffs(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"error in unpack_dct_coeffs\\n\");",
"goto error;",
"}",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"int VAR_8 = s->VAR_8 >> (VAR_6 && s->chroma_y_shift);",
"if (s->flipped_image)\ns->data_offset[VAR_6] = 0;",
"else\ns->data_offset[VAR_6] = (VAR_8 - 1) * s->current_frame.f->linesize[VAR_6];",
"}",
"s->last_slice_end = 0;",
"for (VAR_6 = 0; VAR_6 < s->c_superblock_height; VAR_6++)",
"render_slice(s, VAR_6);",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"int VAR_9 = (s->VAR_8 >> (3 + (VAR_6 && s->chroma_y_shift))) - 1;",
"apply_loop_filter(s, VAR_6, VAR_9, VAR_9 + 1);",
"}",
"vp3_draw_horiz_band(s, s->VAR_8);",
"if ((VAR_7 = av_frame_ref(VAR_1, s->current_frame.f)) < 0)\nreturn VAR_7;",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"AVFrame *dst = VAR_1;",
"int VAR_10 = (s->offset_x >> (VAR_6 && s->chroma_y_shift)) +\n(s->offset_y >> (VAR_6 && s->chroma_y_shift)) * dst->linesize[VAR_6];",
"dst->VAR_1[VAR_6] += VAR_10;",
"}",
"*VAR_2 = 1;",
"if (!HAVE_THREADS || !(s->VAR_0->active_thread_type & FF_THREAD_FRAME)) {",
"VAR_7 = update_frames(VAR_0);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"}",
"return VAR_5;",
"error:\nff_thread_report_progress(&s->current_frame, INT_MAX, 0);",
"if (!HAVE_THREADS || !(s->VAR_0->active_thread_type & FF_THREAD_FRAME))\nav_frame_unref(s->current_frame.f);",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129,
131
],
[
135,
137,
139
],
[
143,
145
],
[
149
],
[
155,
157
],
[
161,
163
],
[
167,
169
],
[
171
],
[
173,
175
],
[
179,
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
229
],
[
231,
233,
235
],
[
237
],
[
239,
241,
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303
],
[
305,
307
],
[
309,
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
341,
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365,
367
],
[
369
],
[
373
],
[
377,
379
],
[
383,
385
],
[
389
],
[
391
]
]
|
13,889 | static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = sysbus_fdc_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
} | true | qemu | e4f4fb1eca795e36f363b4647724221e774523c1 | static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = sysbus_fdc_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->props = sysbus_fdc_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->props = sysbus_fdc_properties;",
"set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
18
]
]
|
13,891 | static void gmc_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture)
{
uint8_t *ptr;
int linesize, uvlinesize;
const int a = s->sprite_warping_accuracy;
int ox, oy;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0];
ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 +
s->sprite_delta[0][1] * s->mb_y * 16;
oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 +
s->sprite_delta[1][1] * s->mb_y * 16;
s->mdsp.gmc(dest_y, ptr, linesize, 16,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
s->mdsp.gmc(dest_y + 8, ptr, linesize, 16,
ox + s->sprite_delta[0][0] * 8,
oy + s->sprite_delta[1][0] * 8,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
if (CONFIG_GRAY && s->flags & CODEC_FLAG_GRAY)
return;
ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 +
s->sprite_delta[0][1] * s->mb_y * 8;
oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 +
s->sprite_delta[1][1] * s->mb_y * 8;
ptr = ref_picture[1];
s->mdsp.gmc(dest_cb, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = ref_picture[2];
s->mdsp.gmc(dest_cr, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
}
| true | FFmpeg | fd52d2d3d1ee41822a9801dffd41c0e1a2db32a8 | static void gmc_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture)
{
uint8_t *ptr;
int linesize, uvlinesize;
const int a = s->sprite_warping_accuracy;
int ox, oy;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0];
ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 +
s->sprite_delta[0][1] * s->mb_y * 16;
oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 +
s->sprite_delta[1][1] * s->mb_y * 16;
s->mdsp.gmc(dest_y, ptr, linesize, 16,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
s->mdsp.gmc(dest_y + 8, ptr, linesize, 16,
ox + s->sprite_delta[0][0] * 8,
oy + s->sprite_delta[1][0] * 8,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
if (CONFIG_GRAY && s->flags & CODEC_FLAG_GRAY)
return;
ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 +
s->sprite_delta[0][1] * s->mb_y * 8;
oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 +
s->sprite_delta[1][1] * s->mb_y * 8;
ptr = ref_picture[1];
s->mdsp.gmc(dest_cb, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = ref_picture[2];
s->mdsp.gmc(dest_cr, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
}
| {
"code": [
" s->h_edge_pos >> 1, s->v_edge_pos >> 1);",
" s->h_edge_pos >> 1, s->v_edge_pos >> 1);"
],
"line_no": [
95,
95
]
} | static void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,
uint8_t **VAR_4)
{
uint8_t *ptr;
int VAR_5, VAR_6;
const int VAR_7 = VAR_0->sprite_warping_accuracy;
int VAR_8, VAR_9;
VAR_5 = VAR_0->VAR_5;
VAR_6 = VAR_0->VAR_6;
ptr = VAR_4[0];
VAR_8 = VAR_0->sprite_offset[0][0] + VAR_0->sprite_delta[0][0] * VAR_0->mb_x * 16 +
VAR_0->sprite_delta[0][1] * VAR_0->mb_y * 16;
VAR_9 = VAR_0->sprite_offset[0][1] + VAR_0->sprite_delta[1][0] * VAR_0->mb_x * 16 +
VAR_0->sprite_delta[1][1] * VAR_0->mb_y * 16;
VAR_0->mdsp.gmc(VAR_1, ptr, VAR_5, 16,
VAR_8, VAR_9,
VAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],
VAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],
VAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,
VAR_0->h_edge_pos, VAR_0->v_edge_pos);
VAR_0->mdsp.gmc(VAR_1 + 8, ptr, VAR_5, 16,
VAR_8 + VAR_0->sprite_delta[0][0] * 8,
VAR_9 + VAR_0->sprite_delta[1][0] * 8,
VAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],
VAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],
VAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,
VAR_0->h_edge_pos, VAR_0->v_edge_pos);
if (CONFIG_GRAY && VAR_0->flags & CODEC_FLAG_GRAY)
return;
VAR_8 = VAR_0->sprite_offset[1][0] + VAR_0->sprite_delta[0][0] * VAR_0->mb_x * 8 +
VAR_0->sprite_delta[0][1] * VAR_0->mb_y * 8;
VAR_9 = VAR_0->sprite_offset[1][1] + VAR_0->sprite_delta[1][0] * VAR_0->mb_x * 8 +
VAR_0->sprite_delta[1][1] * VAR_0->mb_y * 8;
ptr = VAR_4[1];
VAR_0->mdsp.gmc(VAR_2, ptr, VAR_6, 8,
VAR_8, VAR_9,
VAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],
VAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],
VAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);
ptr = VAR_4[2];
VAR_0->mdsp.gmc(VAR_3, ptr, VAR_6, 8,
VAR_8, VAR_9,
VAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],
VAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],
VAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);
}
| [
"static void FUNC_0(MpegEncContext *VAR_0,\nuint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,\nuint8_t **VAR_4)\n{",
"uint8_t *ptr;",
"int VAR_5, VAR_6;",
"const int VAR_7 = VAR_0->sprite_warping_accuracy;",
"int VAR_8, VAR_9;",
"VAR_5 = VAR_0->VAR_5;",
"VAR_6 = VAR_0->VAR_6;",
"ptr = VAR_4[0];",
"VAR_8 = VAR_0->sprite_offset[0][0] + VAR_0->sprite_delta[0][0] * VAR_0->mb_x * 16 +\nVAR_0->sprite_delta[0][1] * VAR_0->mb_y * 16;",
"VAR_9 = VAR_0->sprite_offset[0][1] + VAR_0->sprite_delta[1][0] * VAR_0->mb_x * 16 +\nVAR_0->sprite_delta[1][1] * VAR_0->mb_y * 16;",
"VAR_0->mdsp.gmc(VAR_1, ptr, VAR_5, 16,\nVAR_8, VAR_9,\nVAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],\nVAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],\nVAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,\nVAR_0->h_edge_pos, VAR_0->v_edge_pos);",
"VAR_0->mdsp.gmc(VAR_1 + 8, ptr, VAR_5, 16,\nVAR_8 + VAR_0->sprite_delta[0][0] * 8,\nVAR_9 + VAR_0->sprite_delta[1][0] * 8,\nVAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],\nVAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],\nVAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,\nVAR_0->h_edge_pos, VAR_0->v_edge_pos);",
"if (CONFIG_GRAY && VAR_0->flags & CODEC_FLAG_GRAY)\nreturn;",
"VAR_8 = VAR_0->sprite_offset[1][0] + VAR_0->sprite_delta[0][0] * VAR_0->mb_x * 8 +\nVAR_0->sprite_delta[0][1] * VAR_0->mb_y * 8;",
"VAR_9 = VAR_0->sprite_offset[1][1] + VAR_0->sprite_delta[1][0] * VAR_0->mb_x * 8 +\nVAR_0->sprite_delta[1][1] * VAR_0->mb_y * 8;",
"ptr = VAR_4[1];",
"VAR_0->mdsp.gmc(VAR_2, ptr, VAR_6, 8,\nVAR_8, VAR_9,\nVAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],\nVAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],\nVAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,\nVAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);",
"ptr = VAR_4[2];",
"VAR_0->mdsp.gmc(VAR_3, ptr, VAR_6, 8,\nVAR_8, VAR_9,\nVAR_0->sprite_delta[0][0], VAR_0->sprite_delta[0][1],\nVAR_0->sprite_delta[1][0], VAR_0->sprite_delta[1][1],\nVAR_7 + 1, (1 << (2 * VAR_7 + 1)) - VAR_0->no_rounding,\nVAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
29,
31
],
[
33,
35
],
[
39,
41,
43,
45,
47,
49
],
[
51,
53,
55,
57,
59,
61,
63
],
[
67,
69
],
[
73,
75
],
[
77,
79
],
[
83
],
[
85,
87,
89,
91,
93,
95
],
[
99
],
[
101,
103,
105,
107,
109,
111
],
[
113
]
]
|
13,892 | static av_cold int Faac_encode_init(AVCodecContext *avctx)
{
FaacAudioContext *s = avctx->priv_data;
faacEncConfigurationPtr faac_cfg;
unsigned long samples_input, max_bytes_output;
/* number of channels */
if (avctx->channels < 1 || avctx->channels > 6)
return -1;
s->faac_handle = faacEncOpen(avctx->sample_rate,
avctx->channels,
&samples_input, &max_bytes_output);
/* check faac version */
faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
if (faac_cfg->version != FAAC_CFG_VERSION) {
av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
faacEncClose(s->faac_handle);
return -1;
}
/* put the options in the configuration struct */
switch(avctx->profile) {
case FF_PROFILE_AAC_MAIN:
faac_cfg->aacObjectType = MAIN;
break;
case FF_PROFILE_UNKNOWN:
case FF_PROFILE_AAC_LOW:
faac_cfg->aacObjectType = LOW;
break;
case FF_PROFILE_AAC_SSR:
faac_cfg->aacObjectType = SSR;
break;
case FF_PROFILE_AAC_LTP:
faac_cfg->aacObjectType = LTP;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
faacEncClose(s->faac_handle);
return -1;
}
faac_cfg->mpegVersion = MPEG4;
faac_cfg->useTns = 0;
faac_cfg->allowMidside = 1;
faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
faac_cfg->bandWidth = avctx->cutoff;
if(avctx->flags & CODEC_FLAG_QSCALE) {
faac_cfg->bitRate = 0;
faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
}
faac_cfg->outputFormat = 1;
faac_cfg->inputFormat = FAAC_INPUT_16BIT;
avctx->frame_size = samples_input / avctx->channels;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
/* Set decoder specific info */
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
unsigned char *buffer = NULL;
unsigned long decoder_specific_info_size;
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
&decoder_specific_info_size)) {
avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = decoder_specific_info_size;
memcpy(avctx->extradata, buffer, avctx->extradata_size);
faac_cfg->outputFormat = 0;
}
#undef free
free(buffer);
#define free please_use_av_free
}
if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
return -1;
}
return 0;
}
| false | FFmpeg | 2c006f438042435ec67012d6b78f0374e94180bf | static av_cold int Faac_encode_init(AVCodecContext *avctx)
{
FaacAudioContext *s = avctx->priv_data;
faacEncConfigurationPtr faac_cfg;
unsigned long samples_input, max_bytes_output;
if (avctx->channels < 1 || avctx->channels > 6)
return -1;
s->faac_handle = faacEncOpen(avctx->sample_rate,
avctx->channels,
&samples_input, &max_bytes_output);
faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
if (faac_cfg->version != FAAC_CFG_VERSION) {
av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
faacEncClose(s->faac_handle);
return -1;
}
switch(avctx->profile) {
case FF_PROFILE_AAC_MAIN:
faac_cfg->aacObjectType = MAIN;
break;
case FF_PROFILE_UNKNOWN:
case FF_PROFILE_AAC_LOW:
faac_cfg->aacObjectType = LOW;
break;
case FF_PROFILE_AAC_SSR:
faac_cfg->aacObjectType = SSR;
break;
case FF_PROFILE_AAC_LTP:
faac_cfg->aacObjectType = LTP;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
faacEncClose(s->faac_handle);
return -1;
}
faac_cfg->mpegVersion = MPEG4;
faac_cfg->useTns = 0;
faac_cfg->allowMidside = 1;
faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
faac_cfg->bandWidth = avctx->cutoff;
if(avctx->flags & CODEC_FLAG_QSCALE) {
faac_cfg->bitRate = 0;
faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
}
faac_cfg->outputFormat = 1;
faac_cfg->inputFormat = FAAC_INPUT_16BIT;
avctx->frame_size = samples_input / avctx->channels;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
unsigned char *buffer = NULL;
unsigned long decoder_specific_info_size;
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
&decoder_specific_info_size)) {
avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = decoder_specific_info_size;
memcpy(avctx->extradata, buffer, avctx->extradata_size);
faac_cfg->outputFormat = 0;
}
#undef free
free(buffer);
#define free please_use_av_free
}
if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
FaacAudioContext *s = avctx->priv_data;
faacEncConfigurationPtr faac_cfg;
unsigned long VAR_0, VAR_1;
if (avctx->channels < 1 || avctx->channels > 6)
return -1;
s->faac_handle = faacEncOpen(avctx->sample_rate,
avctx->channels,
&VAR_0, &VAR_1);
faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
if (faac_cfg->version != FAAC_CFG_VERSION) {
av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
faacEncClose(s->faac_handle);
return -1;
}
switch(avctx->profile) {
case FF_PROFILE_AAC_MAIN:
faac_cfg->aacObjectType = MAIN;
break;
case FF_PROFILE_UNKNOWN:
case FF_PROFILE_AAC_LOW:
faac_cfg->aacObjectType = LOW;
break;
case FF_PROFILE_AAC_SSR:
faac_cfg->aacObjectType = SSR;
break;
case FF_PROFILE_AAC_LTP:
faac_cfg->aacObjectType = LTP;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
faacEncClose(s->faac_handle);
return -1;
}
faac_cfg->mpegVersion = MPEG4;
faac_cfg->useTns = 0;
faac_cfg->allowMidside = 1;
faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
faac_cfg->bandWidth = avctx->cutoff;
if(avctx->flags & CODEC_FLAG_QSCALE) {
faac_cfg->bitRate = 0;
faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
}
faac_cfg->outputFormat = 1;
faac_cfg->inputFormat = FAAC_INPUT_16BIT;
avctx->frame_size = VAR_0 / avctx->channels;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
unsigned char *VAR_2 = NULL;
unsigned long VAR_3;
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &VAR_2,
&VAR_3)) {
avctx->extradata = av_malloc(VAR_3 + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = VAR_3;
memcpy(avctx->extradata, VAR_2, avctx->extradata_size);
faac_cfg->outputFormat = 0;
}
#undef free
free(VAR_2);
#define free please_use_av_free
}
if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
return -1;
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"FaacAudioContext *s = avctx->priv_data;",
"faacEncConfigurationPtr faac_cfg;",
"unsigned long VAR_0, VAR_1;",
"if (avctx->channels < 1 || avctx->channels > 6)\nreturn -1;",
"s->faac_handle = faacEncOpen(avctx->sample_rate,\navctx->channels,\n&VAR_0, &VAR_1);",
"faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);",
"if (faac_cfg->version != FAAC_CFG_VERSION) {",
"av_log(avctx, AV_LOG_ERROR, \"wrong libfaac version (compiled for: %d, using %d)\\n\", FAAC_CFG_VERSION, faac_cfg->version);",
"faacEncClose(s->faac_handle);",
"return -1;",
"}",
"switch(avctx->profile) {",
"case FF_PROFILE_AAC_MAIN:\nfaac_cfg->aacObjectType = MAIN;",
"break;",
"case FF_PROFILE_UNKNOWN:\ncase FF_PROFILE_AAC_LOW:\nfaac_cfg->aacObjectType = LOW;",
"break;",
"case FF_PROFILE_AAC_SSR:\nfaac_cfg->aacObjectType = SSR;",
"break;",
"case FF_PROFILE_AAC_LTP:\nfaac_cfg->aacObjectType = LTP;",
"break;",
"default:\nav_log(avctx, AV_LOG_ERROR, \"invalid AAC profile\\n\");",
"faacEncClose(s->faac_handle);",
"return -1;",
"}",
"faac_cfg->mpegVersion = MPEG4;",
"faac_cfg->useTns = 0;",
"faac_cfg->allowMidside = 1;",
"faac_cfg->bitRate = avctx->bit_rate / avctx->channels;",
"faac_cfg->bandWidth = avctx->cutoff;",
"if(avctx->flags & CODEC_FLAG_QSCALE) {",
"faac_cfg->bitRate = 0;",
"faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;",
"}",
"faac_cfg->outputFormat = 1;",
"faac_cfg->inputFormat = FAAC_INPUT_16BIT;",
"avctx->frame_size = VAR_0 / avctx->channels;",
"avctx->coded_frame= avcodec_alloc_frame();",
"avctx->coded_frame->key_frame= 1;",
"avctx->extradata_size = 0;",
"if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {",
"unsigned char *VAR_2 = NULL;",
"unsigned long VAR_3;",
"if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &VAR_2,\n&VAR_3)) {",
"avctx->extradata = av_malloc(VAR_3 + FF_INPUT_BUFFER_PADDING_SIZE);",
"avctx->extradata_size = VAR_3;",
"memcpy(avctx->extradata, VAR_2, avctx->extradata_size);",
"faac_cfg->outputFormat = 0;",
"}",
"#undef free\nfree(VAR_2);",
"#define free please_use_av_free\n}",
"if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {",
"av_log(avctx, AV_LOG_ERROR, \"libfaac doesn't support this output format!\\n\");",
"return -1;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15,
17
],
[
21,
23,
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
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
],
[
109
],
[
113
],
[
115
],
[
121
],
[
123
],
[
127
],
[
129
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
]
]
|
13,894 | av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
{
int n = 1 << nbits;
int i;
s->nbits = nbits;
s->inverse = inverse;
ff_init_ff_cos_tabs(nbits+2);
s->costab = ff_cos_tabs[nbits+2];
s->csc2 = av_malloc(n/2 * sizeof(FFTSample));
if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
av_free(s->csc2);
return -1;
}
for (i = 0; i < n/2; i++)
s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1)));
switch(inverse) {
case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break;
case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;
case DST_I : s->dct_calc = ff_dst_calc_I_c; break;
}
if (inverse == DCT_II && nbits == 5)
s->dct_calc = dct32_func;
s->dct32 = dct32;
if (HAVE_MMX) ff_dct_init_mmx(s);
return 0;
}
| false | FFmpeg | 721d6f2dc5437df21ae17923b29fa2be847764c7 | av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
{
int n = 1 << nbits;
int i;
s->nbits = nbits;
s->inverse = inverse;
ff_init_ff_cos_tabs(nbits+2);
s->costab = ff_cos_tabs[nbits+2];
s->csc2 = av_malloc(n/2 * sizeof(FFTSample));
if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
av_free(s->csc2);
return -1;
}
for (i = 0; i < n/2; i++)
s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1)));
switch(inverse) {
case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break;
case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;
case DST_I : s->dct_calc = ff_dst_calc_I_c; break;
}
if (inverse == DCT_II && nbits == 5)
s->dct_calc = dct32_func;
s->dct32 = dct32;
if (HAVE_MMX) ff_dct_init_mmx(s);
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(DCTContext *s, int nbits, enum DCTTransformType inverse)
{
int VAR_0 = 1 << nbits;
int VAR_1;
s->nbits = nbits;
s->inverse = inverse;
ff_init_ff_cos_tabs(nbits+2);
s->costab = ff_cos_tabs[nbits+2];
s->csc2 = av_malloc(VAR_0/2 * sizeof(FFTSample));
if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
av_free(s->csc2);
return -1;
}
for (VAR_1 = 0; VAR_1 < VAR_0/2; VAR_1++)
s->csc2[VAR_1] = 0.5 / sin((M_PI / (2*VAR_0) * (2*VAR_1 + 1)));
switch(inverse) {
case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break;
case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;
case DST_I : s->dct_calc = ff_dst_calc_I_c; break;
}
if (inverse == DCT_II && nbits == 5)
s->dct_calc = dct32_func;
s->dct32 = dct32;
if (HAVE_MMX) ff_dct_init_mmx(s);
return 0;
}
| [
"av_cold int FUNC_0(DCTContext *s, int nbits, enum DCTTransformType inverse)\n{",
"int VAR_0 = 1 << nbits;",
"int VAR_1;",
"s->nbits = nbits;",
"s->inverse = inverse;",
"ff_init_ff_cos_tabs(nbits+2);",
"s->costab = ff_cos_tabs[nbits+2];",
"s->csc2 = av_malloc(VAR_0/2 * sizeof(FFTSample));",
"if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {",
"av_free(s->csc2);",
"return -1;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0/2; VAR_1++)",
"s->csc2[VAR_1] = 0.5 / sin((M_PI / (2*VAR_0) * (2*VAR_1 + 1)));",
"switch(inverse) {",
"case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;",
"case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break;",
"case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;",
"case DST_I : s->dct_calc = ff_dst_calc_I_c; break;",
"}",
"if (inverse == DCT_II && nbits == 5)\ns->dct_calc = dct32_func;",
"s->dct32 = dct32;",
"if (HAVE_MMX) ff_dct_init_mmx(s);",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
65
],
[
67
],
[
71
],
[
73
]
]
|
13,895 | static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
char language[4] = {0};
unsigned lang;
if (version > 1)
return -1; /* unsupported */
get_be24(pb); /* flags */
if (version == 1) {
get_be64(pb);
get_be64(pb);
} else {
get_be32(pb); /* creation time */
get_be32(pb); /* modification time */
}
sc->time_scale = get_be32(pb);
st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
lang = get_be16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set(&st->metadata, "language", language);
get_be16(pb); /* quality */
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
char language[4] = {0};
unsigned lang;
if (version > 1)
return -1;
get_be24(pb);
if (version == 1) {
get_be64(pb);
get_be64(pb);
} else {
get_be32(pb);
get_be32(pb);
}
sc->time_scale = get_be32(pb);
st->duration = (version == 1) ? get_be64(pb) : get_be32(pb);
lang = get_be16(pb);
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set(&st->metadata, "language", language);
get_be16(pb);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int VAR_3 = get_byte(VAR_1);
char VAR_4[4] = {0};
unsigned VAR_5;
if (VAR_3 > 1)
return -1;
get_be24(VAR_1);
if (VAR_3 == 1) {
get_be64(VAR_1);
get_be64(VAR_1);
} else {
get_be32(VAR_1);
get_be32(VAR_1);
}
sc->time_scale = get_be32(VAR_1);
st->duration = (VAR_3 == 1) ? get_be64(VAR_1) : get_be32(VAR_1);
VAR_5 = get_be16(VAR_1);
if (ff_mov_lang_to_iso639(VAR_5, VAR_4))
av_metadata_set(&st->metadata, "VAR_4", VAR_4);
get_be16(VAR_1);
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"MOVStreamContext *sc = st->priv_data;",
"int VAR_3 = get_byte(VAR_1);",
"char VAR_4[4] = {0};",
"unsigned VAR_5;",
"if (VAR_3 > 1)\nreturn -1;",
"get_be24(VAR_1);",
"if (VAR_3 == 1) {",
"get_be64(VAR_1);",
"get_be64(VAR_1);",
"} else {",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"}",
"sc->time_scale = get_be32(VAR_1);",
"st->duration = (VAR_3 == 1) ? get_be64(VAR_1) : get_be32(VAR_1);",
"VAR_5 = get_be16(VAR_1);",
"if (ff_mov_lang_to_iso639(VAR_5, VAR_4))\nav_metadata_set(&st->metadata, \"VAR_4\", VAR_4);",
"get_be16(VAR_1);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
57
],
[
59
]
]
|
13,898 | static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
GetBitContext *gb)
{
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
skip_bits(gb, 2); // object_type
sampling_index = get_bits(gb, 4);
if (ac->m4ac.sampling_index != sampling_index)
av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
num_front = get_bits(gb, 4);
num_side = get_bits(gb, 4);
num_back = get_bits(gb, 4);
num_lfe = get_bits(gb, 2);
num_assoc_data = get_bits(gb, 3);
num_cc = get_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 4); // mono_mixdown_tag
if (get_bits1(gb))
skip_bits(gb, 4); // stereo_mixdown_tag
if (get_bits1(gb))
skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front);
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side );
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back );
decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe );
skip_bits_long(gb, 4 * num_assoc_data);
decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc );
align_get_bits(gb);
/* comment field, first byte is length */
skip_bits_long(gb, 8 * get_bits(gb, 8));
return 0;
}
| true | FFmpeg | 8d637124864dcf8bf367ab96e572d6c7cf043675 | static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
GetBitContext *gb)
{
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
skip_bits(gb, 2);
sampling_index = get_bits(gb, 4);
if (ac->m4ac.sampling_index != sampling_index)
av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
num_front = get_bits(gb, 4);
num_side = get_bits(gb, 4);
num_back = get_bits(gb, 4);
num_lfe = get_bits(gb, 2);
num_assoc_data = get_bits(gb, 3);
num_cc = get_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 3);
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front);
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side );
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back );
decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe );
skip_bits_long(gb, 4 * num_assoc_data);
decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc );
align_get_bits(gb);
skip_bits_long(gb, 8 * get_bits(gb, 8));
return 0;
}
| {
"code": [
" skip_bits_long(gb, 8 * get_bits(gb, 8));"
],
"line_no": [
77
]
} | static int FUNC_0(AACContext *VAR_0, enum ChannelPosition VAR_1[4][MAX_ELEM_ID],
GetBitContext *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
skip_bits(VAR_2, 2);
VAR_9 = get_bits(VAR_2, 4);
if (VAR_0->m4ac.VAR_9 != VAR_9)
av_log(VAR_0->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
VAR_3 = get_bits(VAR_2, 4);
VAR_4 = get_bits(VAR_2, 4);
VAR_5 = get_bits(VAR_2, 4);
VAR_6 = get_bits(VAR_2, 2);
VAR_7 = get_bits(VAR_2, 3);
VAR_8 = get_bits(VAR_2, 4);
if (get_bits1(VAR_2))
skip_bits(VAR_2, 4);
if (get_bits1(VAR_2))
skip_bits(VAR_2, 4);
if (get_bits1(VAR_2))
skip_bits(VAR_2, 3);
decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_FRONT, VAR_2, VAR_3);
decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_SIDE, VAR_2, VAR_4 );
decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_BACK, VAR_2, VAR_5 );
decode_channel_map(NULL, VAR_1[TYPE_LFE], AAC_CHANNEL_LFE, VAR_2, VAR_6 );
skip_bits_long(VAR_2, 4 * VAR_7);
decode_channel_map(VAR_1[TYPE_CCE], VAR_1[TYPE_CCE], AAC_CHANNEL_CC, VAR_2, VAR_8 );
align_get_bits(VAR_2);
skip_bits_long(VAR_2, 8 * get_bits(VAR_2, 8));
return 0;
}
| [
"static int FUNC_0(AACContext *VAR_0, enum ChannelPosition VAR_1[4][MAX_ELEM_ID],\nGetBitContext *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"skip_bits(VAR_2, 2);",
"VAR_9 = get_bits(VAR_2, 4);",
"if (VAR_0->m4ac.VAR_9 != VAR_9)\nav_log(VAR_0->avccontext, AV_LOG_WARNING, \"Sample rate index in program config element does not match the sample rate index configured by the container.\\n\");",
"VAR_3 = get_bits(VAR_2, 4);",
"VAR_4 = get_bits(VAR_2, 4);",
"VAR_5 = get_bits(VAR_2, 4);",
"VAR_6 = get_bits(VAR_2, 2);",
"VAR_7 = get_bits(VAR_2, 3);",
"VAR_8 = get_bits(VAR_2, 4);",
"if (get_bits1(VAR_2))\nskip_bits(VAR_2, 4);",
"if (get_bits1(VAR_2))\nskip_bits(VAR_2, 4);",
"if (get_bits1(VAR_2))\nskip_bits(VAR_2, 3);",
"decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_FRONT, VAR_2, VAR_3);",
"decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_SIDE, VAR_2, VAR_4 );",
"decode_channel_map(VAR_1[TYPE_CPE], VAR_1[TYPE_SCE], AAC_CHANNEL_BACK, VAR_2, VAR_5 );",
"decode_channel_map(NULL, VAR_1[TYPE_LFE], AAC_CHANNEL_LFE, VAR_2, VAR_6 );",
"skip_bits_long(VAR_2, 4 * VAR_7);",
"decode_channel_map(VAR_1[TYPE_CCE], VAR_1[TYPE_CCE], AAC_CHANNEL_CC, VAR_2, VAR_8 );",
"align_get_bits(VAR_2);",
"skip_bits_long(VAR_2, 8 * get_bits(VAR_2, 8));",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
41,
43
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
71
],
[
77
],
[
79
],
[
81
]
]
|
13,900 | static inline abi_ulong do_shmat(int shmid, abi_ulong shmaddr, int shmflg)
{
abi_long raddr;
void *host_raddr;
struct shmid_ds shm_info;
int i,ret;
/* find out the length of the shared memory segment */
ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
if (is_error(ret)) {
/* can't get length, bail out */
return ret;
}
mmap_lock();
if (shmaddr)
host_raddr = shmat(shmid, (void *)g2h(shmaddr), shmflg);
else {
abi_ulong mmap_start;
mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
if (mmap_start == -1) {
errno = ENOMEM;
host_raddr = (void *)-1;
} else
host_raddr = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP);
}
if (host_raddr == (void *)-1) {
mmap_unlock();
return get_errno((long)host_raddr);
}
raddr=h2g((unsigned long)host_raddr);
page_set_flags(raddr, raddr + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
for (i = 0; i < N_SHM_REGIONS; i++) {
if (!shm_regions[i].in_use) {
shm_regions[i].in_use = true;
shm_regions[i].start = raddr;
shm_regions[i].size = shm_info.shm_segsz;
break;
}
}
mmap_unlock();
return raddr;
}
| true | qemu | ee8e76141b4dd00f8e97fda274876a17f9a46bbe | static inline abi_ulong do_shmat(int shmid, abi_ulong shmaddr, int shmflg)
{
abi_long raddr;
void *host_raddr;
struct shmid_ds shm_info;
int i,ret;
ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
if (is_error(ret)) {
return ret;
}
mmap_lock();
if (shmaddr)
host_raddr = shmat(shmid, (void *)g2h(shmaddr), shmflg);
else {
abi_ulong mmap_start;
mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
if (mmap_start == -1) {
errno = ENOMEM;
host_raddr = (void *)-1;
} else
host_raddr = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP);
}
if (host_raddr == (void *)-1) {
mmap_unlock();
return get_errno((long)host_raddr);
}
raddr=h2g((unsigned long)host_raddr);
page_set_flags(raddr, raddr + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
for (i = 0; i < N_SHM_REGIONS; i++) {
if (!shm_regions[i].in_use) {
shm_regions[i].in_use = true;
shm_regions[i].start = raddr;
shm_regions[i].size = shm_info.shm_segsz;
break;
}
}
mmap_unlock();
return raddr;
}
| {
"code": [
"static inline abi_ulong do_shmat(int shmid, abi_ulong shmaddr, int shmflg)"
],
"line_no": [
1
]
} | static inline abi_ulong FUNC_0(int shmid, abi_ulong shmaddr, int shmflg)
{
abi_long raddr;
void *VAR_0;
struct shmid_ds VAR_1;
int VAR_2,VAR_3;
VAR_3 = get_errno(shmctl(shmid, IPC_STAT, &VAR_1));
if (is_error(VAR_3)) {
return VAR_3;
}
mmap_lock();
if (shmaddr)
VAR_0 = shmat(shmid, (void *)g2h(shmaddr), shmflg);
else {
abi_ulong mmap_start;
mmap_start = mmap_find_vma(0, VAR_1.shm_segsz);
if (mmap_start == -1) {
errno = ENOMEM;
VAR_0 = (void *)-1;
} else
VAR_0 = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP);
}
if (VAR_0 == (void *)-1) {
mmap_unlock();
return get_errno((long)VAR_0);
}
raddr=h2g((unsigned long)VAR_0);
page_set_flags(raddr, raddr + VAR_1.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
for (VAR_2 = 0; VAR_2 < N_SHM_REGIONS; VAR_2++) {
if (!shm_regions[VAR_2].in_use) {
shm_regions[VAR_2].in_use = true;
shm_regions[VAR_2].start = raddr;
shm_regions[VAR_2].size = VAR_1.shm_segsz;
break;
}
}
mmap_unlock();
return raddr;
}
| [
"static inline abi_ulong FUNC_0(int shmid, abi_ulong shmaddr, int shmflg)\n{",
"abi_long raddr;",
"void *VAR_0;",
"struct shmid_ds VAR_1;",
"int VAR_2,VAR_3;",
"VAR_3 = get_errno(shmctl(shmid, IPC_STAT, &VAR_1));",
"if (is_error(VAR_3)) {",
"return VAR_3;",
"}",
"mmap_lock();",
"if (shmaddr)\nVAR_0 = shmat(shmid, (void *)g2h(shmaddr), shmflg);",
"else {",
"abi_ulong mmap_start;",
"mmap_start = mmap_find_vma(0, VAR_1.shm_segsz);",
"if (mmap_start == -1) {",
"errno = ENOMEM;",
"VAR_0 = (void *)-1;",
"} else",
"VAR_0 = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP);",
"}",
"if (VAR_0 == (void *)-1) {",
"mmap_unlock();",
"return get_errno((long)VAR_0);",
"}",
"raddr=h2g((unsigned long)VAR_0);",
"page_set_flags(raddr, raddr + VAR_1.shm_segsz,\nPAGE_VALID | PAGE_READ |\n((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));",
"for (VAR_2 = 0; VAR_2 < N_SHM_REGIONS; VAR_2++) {",
"if (!shm_regions[VAR_2].in_use) {",
"shm_regions[VAR_2].in_use = true;",
"shm_regions[VAR_2].start = raddr;",
"shm_regions[VAR_2].size = VAR_1.shm_segsz;",
"break;",
"}",
"}",
"mmap_unlock();",
"return raddr;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
]
]
|
13,901 | static void gif_fill_rect(AVFrame *picture, uint32_t color, int l, int t, int w, int h)
{
const int linesize = picture->linesize[0] / sizeof(uint32_t);
const uint32_t *py = (uint32_t *)picture->data[0] + t * linesize;
const uint32_t *pr, *pb = py + (t + h) * linesize;
uint32_t *px;
for (; py < pb; py += linesize) {
px = (uint32_t *)py + l;
pr = px + w;
for (; px < pr; px++)
*px = color;
}
}
| true | FFmpeg | c004de0b1c5b44849f9619910c173d1a2204c16e | static void gif_fill_rect(AVFrame *picture, uint32_t color, int l, int t, int w, int h)
{
const int linesize = picture->linesize[0] / sizeof(uint32_t);
const uint32_t *py = (uint32_t *)picture->data[0] + t * linesize;
const uint32_t *pr, *pb = py + (t + h) * linesize;
uint32_t *px;
for (; py < pb; py += linesize) {
px = (uint32_t *)py + l;
pr = px + w;
for (; px < pr; px++)
*px = color;
}
}
| {
"code": [
" const uint32_t *pr, *pb = py + (t + h) * linesize;"
],
"line_no": [
9
]
} | static void FUNC_0(AVFrame *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
const int VAR_6 = VAR_0->VAR_6[0] / sizeof(uint32_t);
const uint32_t *VAR_7 = (uint32_t *)VAR_0->data[0] + VAR_3 * VAR_6;
const uint32_t *VAR_8, *pb = VAR_7 + (VAR_3 + VAR_5) * VAR_6;
uint32_t *px;
for (; VAR_7 < pb; VAR_7 += VAR_6) {
px = (uint32_t *)VAR_7 + VAR_2;
VAR_8 = px + VAR_4;
for (; px < VAR_8; px++)
*px = VAR_1;
}
}
| [
"static void FUNC_0(AVFrame *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"const int VAR_6 = VAR_0->VAR_6[0] / sizeof(uint32_t);",
"const uint32_t *VAR_7 = (uint32_t *)VAR_0->data[0] + VAR_3 * VAR_6;",
"const uint32_t *VAR_8, *pb = VAR_7 + (VAR_3 + VAR_5) * VAR_6;",
"uint32_t *px;",
"for (; VAR_7 < pb; VAR_7 += VAR_6) {",
"px = (uint32_t *)VAR_7 + VAR_2;",
"VAR_8 = px + VAR_4;",
"for (; px < VAR_8; px++)",
"*px = VAR_1;",
"}",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
13,902 | void helper_divl_EAX_T0(void)
{
unsigned int den, q, r;
uint64_t num;
num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32);
den = T0;
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
#ifdef BUGGY_GCC_DIV64
r = div32(&q, num, den);
#else
q = (num / den);
r = (num % den);
#endif
EAX = (uint32_t)q;
EDX = (uint32_t)r;
}
| true | qemu | 45bbbb466cf4a6280076ea5a51f67ef5bedee345 | void helper_divl_EAX_T0(void)
{
unsigned int den, q, r;
uint64_t num;
num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32);
den = T0;
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
#ifdef BUGGY_GCC_DIV64
r = div32(&q, num, den);
#else
q = (num / den);
r = (num % den);
#endif
EAX = (uint32_t)q;
EDX = (uint32_t)r;
}
| {
"code": [
" unsigned int den, q, r;",
" uint64_t num;"
],
"line_no": [
5,
7
]
} | void FUNC_0(void)
{
unsigned int VAR_0, VAR_1, VAR_2;
uint64_t num;
num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32);
VAR_0 = T0;
if (VAR_0 == 0) {
raise_exception(EXCP00_DIVZ);
}
#ifdef BUGGY_GCC_DIV64
VAR_2 = div32(&VAR_1, num, VAR_0);
#else
VAR_1 = (num / VAR_0);
VAR_2 = (num % VAR_0);
#endif
EAX = (uint32_t)VAR_1;
EDX = (uint32_t)VAR_2;
}
| [
"void FUNC_0(void)\n{",
"unsigned int VAR_0, VAR_1, VAR_2;",
"uint64_t num;",
"num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32);",
"VAR_0 = T0;",
"if (VAR_0 == 0) {",
"raise_exception(EXCP00_DIVZ);",
"}",
"#ifdef BUGGY_GCC_DIV64\nVAR_2 = div32(&VAR_1, num, VAR_0);",
"#else\nVAR_1 = (num / VAR_0);",
"VAR_2 = (num % VAR_0);",
"#endif\nEAX = (uint32_t)VAR_1;",
"EDX = (uint32_t)VAR_2;",
"}"
]
| [
0,
1,
1,
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
]
]
|
13,903 | static int mmap_init(AVFormatContext *ctx)
{
int i, res;
struct video_data *s = ctx->priv_data;
struct v4l2_requestbuffers req = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.count = desired_video_buffers,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
if (res < 0) {
if (errno == EINVAL) {
av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
} else {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
}
return AVERROR(errno);
}
if (req.count < 2) {
av_log(ctx, AV_LOG_ERROR, "Insufficient buffer memory\n");
return AVERROR(ENOMEM);
}
s->buffers = req.count;
s->buf_start = av_malloc(sizeof(void *) * s->buffers);
if (s->buf_start == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
return AVERROR(ENOMEM);
}
s->buf_len = av_malloc(sizeof(unsigned int) * s->buffers);
if (s->buf_len == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
av_free(s->buf_start);
return AVERROR(ENOMEM);
}
for (i = 0; i < req.count; i++) {
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.index = i,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_QUERYBUF, &buf);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
return AVERROR(errno);
}
s->buf_len[i] = buf.length;
if (s->frame_size > 0 && s->buf_len[i] < s->frame_size) {
av_log(ctx, AV_LOG_ERROR,
"Buffer len [%d] = %d != %d\n",
i, s->buf_len[i], s->frame_size);
return -1;
}
s->buf_start[i] = mmap(NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED,
s->fd, buf.m.offset);
if (s->buf_start[i] == MAP_FAILED) {
av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return AVERROR(errno);
}
}
return 0;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int mmap_init(AVFormatContext *ctx)
{
int i, res;
struct video_data *s = ctx->priv_data;
struct v4l2_requestbuffers req = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.count = desired_video_buffers,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
if (res < 0) {
if (errno == EINVAL) {
av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
} else {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
}
return AVERROR(errno);
}
if (req.count < 2) {
av_log(ctx, AV_LOG_ERROR, "Insufficient buffer memory\n");
return AVERROR(ENOMEM);
}
s->buffers = req.count;
s->buf_start = av_malloc(sizeof(void *) * s->buffers);
if (s->buf_start == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
return AVERROR(ENOMEM);
}
s->buf_len = av_malloc(sizeof(unsigned int) * s->buffers);
if (s->buf_len == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
av_free(s->buf_start);
return AVERROR(ENOMEM);
}
for (i = 0; i < req.count; i++) {
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.index = i,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_QUERYBUF, &buf);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
return AVERROR(errno);
}
s->buf_len[i] = buf.length;
if (s->frame_size > 0 && s->buf_len[i] < s->frame_size) {
av_log(ctx, AV_LOG_ERROR,
"Buffer len [%d] = %d != %d\n",
i, s->buf_len[i], s->frame_size);
return -1;
}
s->buf_start[i] = mmap(NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED,
s->fd, buf.m.offset);
if (s->buf_start[i] == MAP_FAILED) {
av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return AVERROR(errno);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
int VAR_1, VAR_2;
struct video_data *VAR_3 = VAR_0->priv_data;
struct v4l2_requestbuffers VAR_4 = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.count = desired_video_buffers,
.memory = V4L2_MEMORY_MMAP
};
VAR_2 = ioctl(VAR_3->fd, VIDIOC_REQBUFS, &VAR_4);
if (VAR_2 < 0) {
if (errno == EINVAL) {
av_log(VAR_0, AV_LOG_ERROR, "Device does not support mmap\n");
} else {
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
}
return AVERROR(errno);
}
if (VAR_4.count < 2) {
av_log(VAR_0, AV_LOG_ERROR, "Insufficient buffer memory\n");
return AVERROR(ENOMEM);
}
VAR_3->buffers = VAR_4.count;
VAR_3->buf_start = av_malloc(sizeof(void *) * VAR_3->buffers);
if (VAR_3->buf_start == NULL) {
av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
return AVERROR(ENOMEM);
}
VAR_3->buf_len = av_malloc(sizeof(unsigned int) * VAR_3->buffers);
if (VAR_3->buf_len == NULL) {
av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
av_free(VAR_3->buf_start);
return AVERROR(ENOMEM);
}
for (VAR_1 = 0; VAR_1 < VAR_4.count; VAR_1++) {
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.index = VAR_1,
.memory = V4L2_MEMORY_MMAP
};
VAR_2 = ioctl(VAR_3->fd, VIDIOC_QUERYBUF, &buf);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
return AVERROR(errno);
}
VAR_3->buf_len[VAR_1] = buf.length;
if (VAR_3->frame_size > 0 && VAR_3->buf_len[VAR_1] < VAR_3->frame_size) {
av_log(VAR_0, AV_LOG_ERROR,
"Buffer len [%d] = %d != %d\n",
VAR_1, VAR_3->buf_len[VAR_1], VAR_3->frame_size);
return -1;
}
VAR_3->buf_start[VAR_1] = mmap(NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED,
VAR_3->fd, buf.m.offset);
if (VAR_3->buf_start[VAR_1] == MAP_FAILED) {
av_log(VAR_0, AV_LOG_ERROR, "mmap: %VAR_3\n", strerror(errno));
return AVERROR(errno);
}
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"int VAR_1, VAR_2;",
"struct video_data *VAR_3 = VAR_0->priv_data;",
"struct v4l2_requestbuffers VAR_4 = {",
".type = V4L2_BUF_TYPE_VIDEO_CAPTURE,\n.count = desired_video_buffers,\n.memory = V4L2_MEMORY_MMAP\n};",
"VAR_2 = ioctl(VAR_3->fd, VIDIOC_REQBUFS, &VAR_4);",
"if (VAR_2 < 0) {",
"if (errno == EINVAL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Device does not support mmap\\n\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_REQBUFS)\\n\");",
"}",
"return AVERROR(errno);",
"}",
"if (VAR_4.count < 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Insufficient buffer memory\\n\");",
"return AVERROR(ENOMEM);",
"}",
"VAR_3->buffers = VAR_4.count;",
"VAR_3->buf_start = av_malloc(sizeof(void *) * VAR_3->buffers);",
"if (VAR_3->buf_start == NULL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Cannot allocate buffer pointers\\n\");",
"return AVERROR(ENOMEM);",
"}",
"VAR_3->buf_len = av_malloc(sizeof(unsigned int) * VAR_3->buffers);",
"if (VAR_3->buf_len == NULL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Cannot allocate buffer sizes\\n\");",
"av_free(VAR_3->buf_start);",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_4.count; VAR_1++) {",
"struct v4l2_buffer buf = {",
".type = V4L2_BUF_TYPE_VIDEO_CAPTURE,\n.index = VAR_1,\n.memory = V4L2_MEMORY_MMAP\n};",
"VAR_2 = ioctl(VAR_3->fd, VIDIOC_QUERYBUF, &buf);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_QUERYBUF)\\n\");",
"return AVERROR(errno);",
"}",
"VAR_3->buf_len[VAR_1] = buf.length;",
"if (VAR_3->frame_size > 0 && VAR_3->buf_len[VAR_1] < VAR_3->frame_size) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Buffer len [%d] = %d != %d\\n\",\nVAR_1, VAR_3->buf_len[VAR_1], VAR_3->frame_size);",
"return -1;",
"}",
"VAR_3->buf_start[VAR_1] = mmap(NULL, buf.length,\nPROT_READ | PROT_WRITE, MAP_SHARED,\nVAR_3->fd, buf.m.offset);",
"if (VAR_3->buf_start[VAR_1] == MAP_FAILED) {",
"av_log(VAR_0, AV_LOG_ERROR, \"mmap: %VAR_3\\n\", strerror(errno));",
"return AVERROR(errno);",
"}",
"}",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13,
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89,
91,
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115,
117,
119
],
[
123
],
[
125
],
[
127,
129,
131
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
]
]
|
13,904 | static void adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch)
{
ADXChannelState *prev = &c->prev[ch];
GetBitContext gb;
int scale = AV_RB16(in);
int i;
int s0, s1, s2, d;
init_get_bits(&gb, in + 2, (18 - 2) * 8);
s1 = prev->s1;
s2 = prev->s2;
for (i = 0; i < 32; i++) {
d = get_sbits(&gb, 4);
s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;
s2 = s1;
s1 = av_clip_int16(s0);
*out = s1;
out += c->channels;
}
prev->s1 = s1;
prev->s2 = s2;
}
| true | FFmpeg | 954d94dd5e13ba7a5e9e049d0f980bddced9644c | static void adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch)
{
ADXChannelState *prev = &c->prev[ch];
GetBitContext gb;
int scale = AV_RB16(in);
int i;
int s0, s1, s2, d;
init_get_bits(&gb, in + 2, (18 - 2) * 8);
s1 = prev->s1;
s2 = prev->s2;
for (i = 0; i < 32; i++) {
d = get_sbits(&gb, 4);
s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;
s2 = s1;
s1 = av_clip_int16(s0);
*out = s1;
out += c->channels;
}
prev->s1 = s1;
prev->s2 = s2;
}
| {
"code": [
" s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;"
],
"line_no": [
27
]
} | static void FUNC_0(ADXContext *VAR_0, int16_t *VAR_1, const uint8_t *VAR_2, int VAR_3)
{
ADXChannelState *prev = &VAR_0->prev[VAR_3];
GetBitContext gb;
int VAR_4 = AV_RB16(VAR_2);
int VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9;
init_get_bits(&gb, VAR_2 + 2, (18 - 2) * 8);
VAR_7 = prev->VAR_7;
VAR_8 = prev->VAR_8;
for (VAR_5 = 0; VAR_5 < 32; VAR_5++) {
VAR_9 = get_sbits(&gb, 4);
VAR_6 = (BASEVOL * VAR_9 * VAR_4 + SCALE1 * VAR_7 - SCALE2 * VAR_8) >> 14;
VAR_8 = VAR_7;
VAR_7 = av_clip_int16(VAR_6);
*VAR_1 = VAR_7;
VAR_1 += VAR_0->channels;
}
prev->VAR_7 = VAR_7;
prev->VAR_8 = VAR_8;
}
| [
"static void FUNC_0(ADXContext *VAR_0, int16_t *VAR_1, const uint8_t *VAR_2, int VAR_3)\n{",
"ADXChannelState *prev = &VAR_0->prev[VAR_3];",
"GetBitContext gb;",
"int VAR_4 = AV_RB16(VAR_2);",
"int VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"init_get_bits(&gb, VAR_2 + 2, (18 - 2) * 8);",
"VAR_7 = prev->VAR_7;",
"VAR_8 = prev->VAR_8;",
"for (VAR_5 = 0; VAR_5 < 32; VAR_5++) {",
"VAR_9 = get_sbits(&gb, 4);",
"VAR_6 = (BASEVOL * VAR_9 * VAR_4 + SCALE1 * VAR_7 - SCALE2 * VAR_8) >> 14;",
"VAR_8 = VAR_7;",
"VAR_7 = av_clip_int16(VAR_6);",
"*VAR_1 = VAR_7;",
"VAR_1 += VAR_0->channels;",
"}",
"prev->VAR_7 = VAR_7;",
"prev->VAR_8 = VAR_8;",
"}"
]
| [
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
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
]
|
13,907 | void ide_exec_cmd(IDEBus *bus, uint32_t val)
{
uint16_t *identify_data;
IDEState *s;
int n;
int lba48 = 0;
#if defined(DEBUG_IDE)
printf("ide: CMD=%02x\n", val);
#endif
s = idebus_active_if(bus);
/* ignore commands to non existent slave */
if (s != bus->ifs && !s->bs)
return;
/* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
return;
if (!ide_cmd_permitted(s, val)) {
goto abort_cmd;
}
if (ide_cmd_table[val].handler != NULL) {
bool complete;
s->status = READY_STAT | BUSY_STAT;
s->error = 0;
complete = ide_cmd_table[val].handler(s, val);
if (complete) {
s->status &= ~BUSY_STAT;
assert(!!s->error == !!(s->status & ERR_STAT));
if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) {
s->status |= SEEK_STAT;
}
ide_set_irq(s->bus);
}
return;
}
switch(val) {
case WIN_SETMULT:
if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
/* Disable Read and Write Multiple */
s->mult_sectors = 0;
s->status = READY_STAT | SEEK_STAT;
} else if ((s->nsector & 0xff) != 0 &&
((s->nsector & 0xff) > MAX_MULT_SECTORS ||
(s->nsector & (s->nsector - 1)) != 0)) {
ide_abort_command(s);
} else {
s->mult_sectors = s->nsector & 0xff;
s->status = READY_STAT | SEEK_STAT;
}
ide_set_irq(s->bus);
break;
case WIN_VERIFY_EXT:
lba48 = 1;
/* fall through */
case WIN_VERIFY:
case WIN_VERIFY_ONCE:
/* do sector number check ? */
ide_cmd_lba48_transform(s, lba48);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_READ_EXT:
lba48 = 1;
/* fall through */
case WIN_READ:
case WIN_READ_ONCE:
if (s->drive_kind == IDE_CD) {
ide_set_signature(s); /* odd, but ATA4 8.27.5.2 requires it */
goto abort_cmd;
}
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = 1;
ide_sector_read(s);
break;
case WIN_WRITE_EXT:
lba48 = 1;
/* fall through */
case WIN_WRITE:
case WIN_WRITE_ONCE:
case CFA_WRITE_SECT_WO_ERASE:
case WIN_WRITE_VERIFY:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = 1;
ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
s->media_changed = 1;
break;
case WIN_MULTREAD_EXT:
lba48 = 1;
/* fall through */
case WIN_MULTREAD:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = s->mult_sectors;
ide_sector_read(s);
break;
case WIN_MULTWRITE_EXT:
lba48 = 1;
/* fall through */
case WIN_MULTWRITE:
case CFA_WRITE_MULTI_WO_ERASE:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = s->mult_sectors;
n = s->nsector;
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
s->media_changed = 1;
break;
case WIN_READDMA_EXT:
lba48 = 1;
/* fall through */
case WIN_READDMA:
case WIN_READDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_READ);
break;
case WIN_WRITEDMA_EXT:
lba48 = 1;
/* fall through */
case WIN_WRITEDMA:
case WIN_WRITEDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
break;
case WIN_READ_NATIVE_MAX_EXT:
lba48 = 1;
/* fall through */
case WIN_READ_NATIVE_MAX:
/* Refuse if no sectors are addressable (e.g. medium not inserted) */
if (s->nb_sectors == 0) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_set_sector(s, s->nb_sectors - 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_CHECKPOWERMODE1:
case WIN_CHECKPOWERMODE2:
s->error = 0;
s->nsector = 0xff; /* device active or idle */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_SETFEATURES:
if (!s->bs)
goto abort_cmd;
/* XXX: valid for CDROM ? */
switch(s->feature) {
case 0x02: /* write cache enable */
bdrv_set_enable_write_cache(s->bs, true);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case 0x82: /* write cache disable */
bdrv_set_enable_write_cache(s->bs, false);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | 1);
ide_flush_cache(s);
break;
case 0xcc: /* reverting to power-on defaults enable */
case 0x66: /* reverting to power-on defaults disable */
case 0xaa: /* read look-ahead enable */
case 0x55: /* read look-ahead disable */
case 0x05: /* set advanced power management mode */
case 0x85: /* disable advanced power management mode */
case 0x69: /* NOP */
case 0x67: /* NOP */
case 0x96: /* NOP */
case 0x9a: /* NOP */
case 0x42: /* enable Automatic Acoustic Mode */
case 0xc2: /* disable Automatic Acoustic Mode */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case 0x03: { /* set transfer mode */
uint8_t val = s->nsector & 0x07;
identify_data = (uint16_t *)s->identify_data;
switch (s->nsector >> 3) {
case 0x00: /* pio default */
case 0x01: /* pio mode */
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x02: /* sigle word dma mode*/
put_le16(identify_data + 62,0x07 | (1 << (val + 8)));
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x04: /* mdma mode */
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07 | (1 << (val + 8)));
put_le16(identify_data + 88,0x3f);
break;
case 0x08: /* udma mode */
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f | (1 << (val + 8)));
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
}
default:
goto abort_cmd;
}
break;
case WIN_FLUSH_CACHE:
case WIN_FLUSH_CACHE_EXT:
ide_flush_cache(s);
break;
case WIN_SEEK:
/* XXX: Check that seek is within bounds */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
/* ATAPI commands */
case WIN_PIDENTIFY:
ide_atapi_identify(s);
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case WIN_DIAGNOSE:
ide_set_signature(s);
if (s->drive_kind == IDE_CD)
s->status = 0; /* ATAPI spec (v6) section 9.10 defines packet
* devices to return a clear status register
* with READY_STAT *not* set. */
else
s->status = READY_STAT | SEEK_STAT;
s->error = 0x01; /* Device 0 passed, Device 1 passed or not
* present.
*/
ide_set_irq(s->bus);
break;
case WIN_DEVICE_RESET:
ide_set_signature(s);
s->status = 0x00; /* NOTE: READY is _not_ set */
s->error = 0x01;
break;
case WIN_PACKETCMD:
/* overlapping commands not supported */
if (s->feature & 0x02)
goto abort_cmd;
s->status = READY_STAT | SEEK_STAT;
s->atapi_dma = s->feature & 1;
s->nsector = 1;
ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
ide_atapi_cmd);
break;
/* CF-ATA commands */
case CFA_REQ_EXT_ERROR_CODE:
s->error = 0x09; /* miscellaneous error */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case CFA_ERASE_SECTORS:
case CFA_WEAR_LEVEL:
#if 0
/* This one has the same ID as CFA_WEAR_LEVEL and is required for
Windows 8 to work with AHCI */
case WIN_SECURITY_FREEZE_LOCK:
#endif
if (val == CFA_WEAR_LEVEL)
s->nsector = 0;
if (val == CFA_ERASE_SECTORS)
s->media_changed = 1;
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case CFA_TRANSLATE_SECTOR:
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0x00] = s->hcyl; /* Cyl MSB */
s->io_buffer[0x01] = s->lcyl; /* Cyl LSB */
s->io_buffer[0x02] = s->select; /* Head */
s->io_buffer[0x03] = s->sector; /* Sector */
s->io_buffer[0x04] = ide_get_sector(s) >> 16; /* LBA MSB */
s->io_buffer[0x05] = ide_get_sector(s) >> 8; /* LBA */
s->io_buffer[0x06] = ide_get_sector(s) >> 0; /* LBA LSB */
s->io_buffer[0x13] = 0x00; /* Erase flag */
s->io_buffer[0x18] = 0x00; /* Hot count */
s->io_buffer[0x19] = 0x00; /* Hot count */
s->io_buffer[0x1a] = 0x01; /* Hot count */
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case CFA_ACCESS_METADATA_STORAGE:
switch (s->feature) {
case 0x02: /* Inquiry Metadata Storage */
ide_cfata_metadata_inquiry(s);
break;
case 0x03: /* Read Metadata Storage */
ide_cfata_metadata_read(s);
break;
case 0x04: /* Write Metadata Storage */
ide_cfata_metadata_write(s);
break;
default:
goto abort_cmd;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00; /* NOTE: READY is _not_ set */
ide_set_irq(s->bus);
break;
case IBM_SENSE_CONDITION:
switch (s->feature) {
case 0x01: /* sense temperature in device */
s->nsector = 0x50; /* +20 C */
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_SMART:
if (s->hcyl != 0xc2 || s->lcyl != 0x4f)
goto abort_cmd;
if (!s->smart_enabled && s->feature != SMART_ENABLE)
goto abort_cmd;
switch (s->feature) {
case SMART_DISABLE:
s->smart_enabled = 0;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_ENABLE:
s->smart_enabled = 1;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_ATTR_AUTOSAVE:
switch (s->sector) {
case 0x00:
s->smart_autosave = 0;
break;
case 0xf1:
s->smart_autosave = 1;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_STATUS:
if (!s->smart_errors) {
s->hcyl = 0xc2;
s->lcyl = 0x4f;
} else {
s->hcyl = 0x2c;
s->lcyl = 0xf4;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01; /* smart struct version */
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
s->io_buffer[2+1+(n*12)] = smart_attributes[n][11];
}
for (n=0; n<511; n++) /* checksum */
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01; /* smart struct version */
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
int i;
for(i = 0; i < 11; i++) {
s->io_buffer[2+i+(n*12)] = smart_attributes[n][i];
}
}
s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);
if (s->smart_selftest_count == 0) {
s->io_buffer[363] = 0;
} else {
s->io_buffer[363] =
s->smart_selftest_data[3 +
(s->smart_selftest_count - 1) *
24];
}
s->io_buffer[364] = 0x20;
s->io_buffer[365] = 0x01;
/* offline data collection capacity: execute + self-test*/
s->io_buffer[367] = (1<<4 | 1<<3 | 1);
s->io_buffer[368] = 0x03; /* smart capability (1) */
s->io_buffer[369] = 0x00; /* smart capability (2) */
s->io_buffer[370] = 0x01; /* error logging supported */
s->io_buffer[372] = 0x02; /* minutes for poll short test */
s->io_buffer[373] = 0x36; /* minutes for poll ext test */
s->io_buffer[374] = 0x01; /* minutes for poll conveyance */
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_READ_LOG:
switch (s->sector) {
case 0x01: /* summary smart error log */
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
s->io_buffer[1] = 0x00; /* no error entries */
s->io_buffer[452] = s->smart_errors & 0xff;
s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
case 0x06: /* smart self test log */
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
if (s->smart_selftest_count == 0) {
s->io_buffer[508] = 0;
} else {
s->io_buffer[508] = s->smart_selftest_count;
for (n=2; n<506; n++)
s->io_buffer[n] = s->smart_selftest_data[n];
}
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_EXECUTE_OFFLINE:
switch (s->sector) {
case 0: /* off-line routine */
case 1: /* short self test */
case 2: /* extended self test */
s->smart_selftest_count++;
if(s->smart_selftest_count > 21)
s->smart_selftest_count = 0;
n = 2 + (s->smart_selftest_count - 1) * 24;
s->smart_selftest_data[n] = s->sector;
s->smart_selftest_data[n+1] = 0x00; /* OK and finished */
s->smart_selftest_data[n+2] = 0x34; /* hour count lsb */
s->smart_selftest_data[n+3] = 0x12; /* hour count msb */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
default:
goto abort_cmd;
}
break;
default:
goto abort_cmd;
}
break;
default:
/* should not be reachable */
abort_cmd:
ide_abort_command(s);
ide_set_irq(s->bus);
break;
}
}
| true | qemu | 413860cfb57d44baf971ae8d4f1cdf45340b3a4d | void ide_exec_cmd(IDEBus *bus, uint32_t val)
{
uint16_t *identify_data;
IDEState *s;
int n;
int lba48 = 0;
#if defined(DEBUG_IDE)
printf("ide: CMD=%02x\n", val);
#endif
s = idebus_active_if(bus);
if (s != bus->ifs && !s->bs)
return;
if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
return;
if (!ide_cmd_permitted(s, val)) {
goto abort_cmd;
}
if (ide_cmd_table[val].handler != NULL) {
bool complete;
s->status = READY_STAT | BUSY_STAT;
s->error = 0;
complete = ide_cmd_table[val].handler(s, val);
if (complete) {
s->status &= ~BUSY_STAT;
assert(!!s->error == !!(s->status & ERR_STAT));
if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) {
s->status |= SEEK_STAT;
}
ide_set_irq(s->bus);
}
return;
}
switch(val) {
case WIN_SETMULT:
if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
s->mult_sectors = 0;
s->status = READY_STAT | SEEK_STAT;
} else if ((s->nsector & 0xff) != 0 &&
((s->nsector & 0xff) > MAX_MULT_SECTORS ||
(s->nsector & (s->nsector - 1)) != 0)) {
ide_abort_command(s);
} else {
s->mult_sectors = s->nsector & 0xff;
s->status = READY_STAT | SEEK_STAT;
}
ide_set_irq(s->bus);
break;
case WIN_VERIFY_EXT:
lba48 = 1;
case WIN_VERIFY:
case WIN_VERIFY_ONCE:
ide_cmd_lba48_transform(s, lba48);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_READ_EXT:
lba48 = 1;
case WIN_READ:
case WIN_READ_ONCE:
if (s->drive_kind == IDE_CD) {
ide_set_signature(s);
goto abort_cmd;
}
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = 1;
ide_sector_read(s);
break;
case WIN_WRITE_EXT:
lba48 = 1;
case WIN_WRITE:
case WIN_WRITE_ONCE:
case CFA_WRITE_SECT_WO_ERASE:
case WIN_WRITE_VERIFY:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = 1;
ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
s->media_changed = 1;
break;
case WIN_MULTREAD_EXT:
lba48 = 1;
case WIN_MULTREAD:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->req_nb_sectors = s->mult_sectors;
ide_sector_read(s);
break;
case WIN_MULTWRITE_EXT:
lba48 = 1;
case WIN_MULTWRITE:
case CFA_WRITE_MULTI_WO_ERASE:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = s->mult_sectors;
n = s->nsector;
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
s->media_changed = 1;
break;
case WIN_READDMA_EXT:
lba48 = 1;
case WIN_READDMA:
case WIN_READDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_READ);
break;
case WIN_WRITEDMA_EXT:
lba48 = 1;
case WIN_WRITEDMA:
case WIN_WRITEDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
break;
case WIN_READ_NATIVE_MAX_EXT:
lba48 = 1;
case WIN_READ_NATIVE_MAX:
if (s->nb_sectors == 0) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, lba48);
ide_set_sector(s, s->nb_sectors - 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_CHECKPOWERMODE1:
case WIN_CHECKPOWERMODE2:
s->error = 0;
s->nsector = 0xff;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_SETFEATURES:
if (!s->bs)
goto abort_cmd;
switch(s->feature) {
case 0x02:
bdrv_set_enable_write_cache(s->bs, true);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case 0x82:
bdrv_set_enable_write_cache(s->bs, false);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | 1);
ide_flush_cache(s);
break;
case 0xcc:
case 0x66:
case 0xaa:
case 0x55:
case 0x05:
case 0x85:
case 0x69:
case 0x67:
case 0x96:
case 0x9a:
case 0x42:
case 0xc2:
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case 0x03: {
uint8_t val = s->nsector & 0x07;
identify_data = (uint16_t *)s->identify_data;
switch (s->nsector >> 3) {
case 0x00:
case 0x01:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x02:
put_le16(identify_data + 62,0x07 | (1 << (val + 8)));
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x04:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07 | (1 << (val + 8)));
put_le16(identify_data + 88,0x3f);
break;
case 0x08:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f | (1 << (val + 8)));
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
}
default:
goto abort_cmd;
}
break;
case WIN_FLUSH_CACHE:
case WIN_FLUSH_CACHE_EXT:
ide_flush_cache(s);
break;
case WIN_SEEK:
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_PIDENTIFY:
ide_atapi_identify(s);
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case WIN_DIAGNOSE:
ide_set_signature(s);
if (s->drive_kind == IDE_CD)
s->status = 0;
else
s->status = READY_STAT | SEEK_STAT;
s->error = 0x01;
ide_set_irq(s->bus);
break;
case WIN_DEVICE_RESET:
ide_set_signature(s);
s->status = 0x00;
s->error = 0x01;
break;
case WIN_PACKETCMD:
if (s->feature & 0x02)
goto abort_cmd;
s->status = READY_STAT | SEEK_STAT;
s->atapi_dma = s->feature & 1;
s->nsector = 1;
ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
ide_atapi_cmd);
break;
case CFA_REQ_EXT_ERROR_CODE:
s->error = 0x09;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case CFA_ERASE_SECTORS:
case CFA_WEAR_LEVEL:
#if 0
case WIN_SECURITY_FREEZE_LOCK:
#endif
if (val == CFA_WEAR_LEVEL)
s->nsector = 0;
if (val == CFA_ERASE_SECTORS)
s->media_changed = 1;
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case CFA_TRANSLATE_SECTOR:
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0x00] = s->hcyl;
s->io_buffer[0x01] = s->lcyl;
s->io_buffer[0x02] = s->select;
s->io_buffer[0x03] = s->sector;
s->io_buffer[0x04] = ide_get_sector(s) >> 16;
s->io_buffer[0x05] = ide_get_sector(s) >> 8;
s->io_buffer[0x06] = ide_get_sector(s) >> 0;
s->io_buffer[0x13] = 0x00;
s->io_buffer[0x18] = 0x00;
s->io_buffer[0x19] = 0x00;
s->io_buffer[0x1a] = 0x01;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case CFA_ACCESS_METADATA_STORAGE:
switch (s->feature) {
case 0x02:
ide_cfata_metadata_inquiry(s);
break;
case 0x03:
ide_cfata_metadata_read(s);
break;
case 0x04:
ide_cfata_metadata_write(s);
break;
default:
goto abort_cmd;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00;
ide_set_irq(s->bus);
break;
case IBM_SENSE_CONDITION:
switch (s->feature) {
case 0x01:
s->nsector = 0x50;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case WIN_SMART:
if (s->hcyl != 0xc2 || s->lcyl != 0x4f)
goto abort_cmd;
if (!s->smart_enabled && s->feature != SMART_ENABLE)
goto abort_cmd;
switch (s->feature) {
case SMART_DISABLE:
s->smart_enabled = 0;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_ENABLE:
s->smart_enabled = 1;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_ATTR_AUTOSAVE:
switch (s->sector) {
case 0x00:
s->smart_autosave = 0;
break;
case 0xf1:
s->smart_autosave = 1;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_STATUS:
if (!s->smart_errors) {
s->hcyl = 0xc2;
s->lcyl = 0x4f;
} else {
s->hcyl = 0x2c;
s->lcyl = 0xf4;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
s->io_buffer[2+1+(n*12)] = smart_attributes[n][11];
}
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
int i;
for(i = 0; i < 11; i++) {
s->io_buffer[2+i+(n*12)] = smart_attributes[n][i];
}
}
s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);
if (s->smart_selftest_count == 0) {
s->io_buffer[363] = 0;
} else {
s->io_buffer[363] =
s->smart_selftest_data[3 +
(s->smart_selftest_count - 1) *
24];
}
s->io_buffer[364] = 0x20;
s->io_buffer[365] = 0x01;
s->io_buffer[367] = (1<<4 | 1<<3 | 1);
s->io_buffer[368] = 0x03;
s->io_buffer[369] = 0x00;
s->io_buffer[370] = 0x01;
s->io_buffer[372] = 0x02;
s->io_buffer[373] = 0x36;
s->io_buffer[374] = 0x01;
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_READ_LOG:
switch (s->sector) {
case 0x01:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
s->io_buffer[1] = 0x00;
s->io_buffer[452] = s->smart_errors & 0xff;
s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
case 0x06:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
if (s->smart_selftest_count == 0) {
s->io_buffer[508] = 0;
} else {
s->io_buffer[508] = s->smart_selftest_count;
for (n=2; n<506; n++)
s->io_buffer[n] = s->smart_selftest_data[n];
}
for (n=0; n<511; n++)
s->io_buffer[511] += s->io_buffer[n];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
break;
case SMART_EXECUTE_OFFLINE:
switch (s->sector) {
case 0:
case 1:
case 2:
s->smart_selftest_count++;
if(s->smart_selftest_count > 21)
s->smart_selftest_count = 0;
n = 2 + (s->smart_selftest_count - 1) * 24;
s->smart_selftest_data[n] = s->sector;
s->smart_selftest_data[n+1] = 0x00;
s->smart_selftest_data[n+2] = 0x34;
s->smart_selftest_data[n+3] = 0x12;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
break;
default:
goto abort_cmd;
}
break;
default:
goto abort_cmd;
}
break;
default:
abort_cmd:
ide_abort_command(s);
ide_set_irq(s->bus);
break;
}
}
| {
"code": [
" case WIN_VERIFY_EXT:",
" lba48 = 1;",
" case WIN_VERIFY:",
" case WIN_VERIFY_ONCE:",
"\tide_cmd_lba48_transform(s, lba48);",
" s->status = READY_STAT | SEEK_STAT;",
" ide_set_irq(s->bus);",
" break;"
],
"line_no": [
123,
125,
129,
131,
135,
137,
117,
119
]
} | void FUNC_0(IDEBus *VAR_0, uint32_t VAR_1)
{
uint16_t *identify_data;
IDEState *s;
int VAR_2;
int VAR_3 = 0;
#if defined(DEBUG_IDE)
printf("ide: CMD=%02x\VAR_2", VAR_1);
#endif
s = idebus_active_if(VAR_0);
if (s != VAR_0->ifs && !s->bs)
return;
if ((s->status & (BUSY_STAT|DRQ_STAT)) && VAR_1 != WIN_DEVICE_RESET)
return;
if (!ide_cmd_permitted(s, VAR_1)) {
goto abort_cmd;
}
if (ide_cmd_table[VAR_1].handler != NULL) {
bool complete;
s->status = READY_STAT | BUSY_STAT;
s->error = 0;
complete = ide_cmd_table[VAR_1].handler(s, VAR_1);
if (complete) {
s->status &= ~BUSY_STAT;
assert(!!s->error == !!(s->status & ERR_STAT));
if ((ide_cmd_table[VAR_1].flags & SET_DSC) && !s->error) {
s->status |= SEEK_STAT;
}
ide_set_irq(s->VAR_0);
}
return;
}
switch(VAR_1) {
case WIN_SETMULT:
if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
s->mult_sectors = 0;
s->status = READY_STAT | SEEK_STAT;
} else if ((s->nsector & 0xff) != 0 &&
((s->nsector & 0xff) > MAX_MULT_SECTORS ||
(s->nsector & (s->nsector - 1)) != 0)) {
ide_abort_command(s);
} else {
s->mult_sectors = s->nsector & 0xff;
s->status = READY_STAT | SEEK_STAT;
}
ide_set_irq(s->VAR_0);
break;
case WIN_VERIFY_EXT:
VAR_3 = 1;
case WIN_VERIFY:
case WIN_VERIFY_ONCE:
ide_cmd_lba48_transform(s, VAR_3);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case WIN_READ_EXT:
VAR_3 = 1;
case WIN_READ:
case WIN_READ_ONCE:
if (s->drive_kind == IDE_CD) {
ide_set_signature(s);
goto abort_cmd;
}
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
s->req_nb_sectors = 1;
ide_sector_read(s);
break;
case WIN_WRITE_EXT:
VAR_3 = 1;
case WIN_WRITE:
case WIN_WRITE_ONCE:
case CFA_WRITE_SECT_WO_ERASE:
case WIN_WRITE_VERIFY:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = 1;
ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
s->media_changed = 1;
break;
case WIN_MULTREAD_EXT:
VAR_3 = 1;
case WIN_MULTREAD:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
s->req_nb_sectors = s->mult_sectors;
ide_sector_read(s);
break;
case WIN_MULTWRITE_EXT:
VAR_3 = 1;
case WIN_MULTWRITE:
case CFA_WRITE_MULTI_WO_ERASE:
if (!s->bs) {
goto abort_cmd;
}
if (!s->mult_sectors) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
s->error = 0;
s->status = SEEK_STAT | READY_STAT;
s->req_nb_sectors = s->mult_sectors;
VAR_2 = s->nsector;
if (VAR_2 > s->req_nb_sectors)
VAR_2 = s->req_nb_sectors;
ide_transfer_start(s, s->io_buffer, 512 * VAR_2, ide_sector_write);
s->media_changed = 1;
break;
case WIN_READDMA_EXT:
VAR_3 = 1;
case WIN_READDMA:
case WIN_READDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
ide_sector_start_dma(s, IDE_DMA_READ);
break;
case WIN_WRITEDMA_EXT:
VAR_3 = 1;
case WIN_WRITEDMA:
case WIN_WRITEDMA_ONCE:
if (!s->bs) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
break;
case WIN_READ_NATIVE_MAX_EXT:
VAR_3 = 1;
case WIN_READ_NATIVE_MAX:
if (s->nb_sectors == 0) {
goto abort_cmd;
}
ide_cmd_lba48_transform(s, VAR_3);
ide_set_sector(s, s->nb_sectors - 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case WIN_CHECKPOWERMODE1:
case WIN_CHECKPOWERMODE2:
s->error = 0;
s->nsector = 0xff;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case WIN_SETFEATURES:
if (!s->bs)
goto abort_cmd;
switch(s->feature) {
case 0x02:
bdrv_set_enable_write_cache(s->bs, true);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1);
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case 0x82:
bdrv_set_enable_write_cache(s->bs, false);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | 1);
ide_flush_cache(s);
break;
case 0xcc:
case 0x66:
case 0xaa:
case 0x55:
case 0x05:
case 0x85:
case 0x69:
case 0x67:
case 0x96:
case 0x9a:
case 0x42:
case 0xc2:
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case 0x03: {
uint8_t VAR_1 = s->nsector & 0x07;
identify_data = (uint16_t *)s->identify_data;
switch (s->nsector >> 3) {
case 0x00:
case 0x01:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x02:
put_le16(identify_data + 62,0x07 | (1 << (VAR_1 + 8)));
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f);
break;
case 0x04:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07 | (1 << (VAR_1 + 8)));
put_le16(identify_data + 88,0x3f);
break;
case 0x08:
put_le16(identify_data + 62,0x07);
put_le16(identify_data + 63,0x07);
put_le16(identify_data + 88,0x3f | (1 << (VAR_1 + 8)));
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
}
default:
goto abort_cmd;
}
break;
case WIN_FLUSH_CACHE:
case WIN_FLUSH_CACHE_EXT:
ide_flush_cache(s);
break;
case WIN_SEEK:
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case WIN_PIDENTIFY:
ide_atapi_identify(s);
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
ide_set_irq(s->VAR_0);
break;
case WIN_DIAGNOSE:
ide_set_signature(s);
if (s->drive_kind == IDE_CD)
s->status = 0;
else
s->status = READY_STAT | SEEK_STAT;
s->error = 0x01;
ide_set_irq(s->VAR_0);
break;
case WIN_DEVICE_RESET:
ide_set_signature(s);
s->status = 0x00;
s->error = 0x01;
break;
case WIN_PACKETCMD:
if (s->feature & 0x02)
goto abort_cmd;
s->status = READY_STAT | SEEK_STAT;
s->atapi_dma = s->feature & 1;
s->nsector = 1;
ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
ide_atapi_cmd);
break;
case CFA_REQ_EXT_ERROR_CODE:
s->error = 0x09;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case CFA_ERASE_SECTORS:
case CFA_WEAR_LEVEL:
#if 0
case WIN_SECURITY_FREEZE_LOCK:
#endif
if (VAR_1 == CFA_WEAR_LEVEL)
s->nsector = 0;
if (VAR_1 == CFA_ERASE_SECTORS)
s->media_changed = 1;
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case CFA_TRANSLATE_SECTOR:
s->error = 0x00;
s->status = READY_STAT | SEEK_STAT;
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0x00] = s->hcyl;
s->io_buffer[0x01] = s->lcyl;
s->io_buffer[0x02] = s->select;
s->io_buffer[0x03] = s->sector;
s->io_buffer[0x04] = ide_get_sector(s) >> 16;
s->io_buffer[0x05] = ide_get_sector(s) >> 8;
s->io_buffer[0x06] = ide_get_sector(s) >> 0;
s->io_buffer[0x13] = 0x00;
s->io_buffer[0x18] = 0x00;
s->io_buffer[0x19] = 0x00;
s->io_buffer[0x1a] = 0x01;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->VAR_0);
break;
case CFA_ACCESS_METADATA_STORAGE:
switch (s->feature) {
case 0x02:
ide_cfata_metadata_inquiry(s);
break;
case 0x03:
ide_cfata_metadata_read(s);
break;
case 0x04:
ide_cfata_metadata_write(s);
break;
default:
goto abort_cmd;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00;
ide_set_irq(s->VAR_0);
break;
case IBM_SENSE_CONDITION:
switch (s->feature) {
case 0x01:
s->nsector = 0x50;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case WIN_SMART:
if (s->hcyl != 0xc2 || s->lcyl != 0x4f)
goto abort_cmd;
if (!s->smart_enabled && s->feature != SMART_ENABLE)
goto abort_cmd;
switch (s->feature) {
case SMART_DISABLE:
s->smart_enabled = 0;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case SMART_ENABLE:
s->smart_enabled = 1;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case SMART_ATTR_AUTOSAVE:
switch (s->sector) {
case 0x00:
s->smart_autosave = 0;
break;
case 0xf1:
s->smart_autosave = 1;
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case SMART_STATUS:
if (!s->smart_errors) {
s->hcyl = 0xc2;
s->lcyl = 0x4f;
} else {
s->hcyl = 0x2c;
s->lcyl = 0xf4;
}
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(smart_attributes); VAR_2++) {
s->io_buffer[2+0+(VAR_2*12)] = smart_attributes[VAR_2][0];
s->io_buffer[2+1+(VAR_2*12)] = smart_attributes[VAR_2][11];
}
for (VAR_2=0; VAR_2<511; VAR_2++)
s->io_buffer[511] += s->io_buffer[VAR_2];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->VAR_0);
break;
case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(smart_attributes); VAR_2++) {
int i;
for(i = 0; i < 11; i++) {
s->io_buffer[2+i+(VAR_2*12)] = smart_attributes[VAR_2][i];
}
}
s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);
if (s->smart_selftest_count == 0) {
s->io_buffer[363] = 0;
} else {
s->io_buffer[363] =
s->smart_selftest_data[3 +
(s->smart_selftest_count - 1) *
24];
}
s->io_buffer[364] = 0x20;
s->io_buffer[365] = 0x01;
s->io_buffer[367] = (1<<4 | 1<<3 | 1);
s->io_buffer[368] = 0x03;
s->io_buffer[369] = 0x00;
s->io_buffer[370] = 0x01;
s->io_buffer[372] = 0x02;
s->io_buffer[373] = 0x36;
s->io_buffer[374] = 0x01;
for (VAR_2=0; VAR_2<511; VAR_2++)
s->io_buffer[511] += s->io_buffer[VAR_2];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->VAR_0);
break;
case SMART_READ_LOG:
switch (s->sector) {
case 0x01:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
s->io_buffer[1] = 0x00;
s->io_buffer[452] = s->smart_errors & 0xff;
s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
for (VAR_2=0; VAR_2<511; VAR_2++)
s->io_buffer[511] += s->io_buffer[VAR_2];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
case 0x06:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
if (s->smart_selftest_count == 0) {
s->io_buffer[508] = 0;
} else {
s->io_buffer[508] = s->smart_selftest_count;
for (VAR_2=2; VAR_2<506; VAR_2++)
s->io_buffer[VAR_2] = s->smart_selftest_data[VAR_2];
}
for (VAR_2=0; VAR_2<511; VAR_2++)
s->io_buffer[511] += s->io_buffer[VAR_2];
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->VAR_0);
break;
case SMART_EXECUTE_OFFLINE:
switch (s->sector) {
case 0:
case 1:
case 2:
s->smart_selftest_count++;
if(s->smart_selftest_count > 21)
s->smart_selftest_count = 0;
VAR_2 = 2 + (s->smart_selftest_count - 1) * 24;
s->smart_selftest_data[VAR_2] = s->sector;
s->smart_selftest_data[VAR_2+1] = 0x00;
s->smart_selftest_data[VAR_2+2] = 0x34;
s->smart_selftest_data[VAR_2+3] = 0x12;
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->VAR_0);
break;
default:
goto abort_cmd;
}
break;
default:
goto abort_cmd;
}
break;
default:
abort_cmd:
ide_abort_command(s);
ide_set_irq(s->VAR_0);
break;
}
}
| [
"void FUNC_0(IDEBus *VAR_0, uint32_t VAR_1)\n{",
"uint16_t *identify_data;",
"IDEState *s;",
"int VAR_2;",
"int VAR_3 = 0;",
"#if defined(DEBUG_IDE)\nprintf(\"ide: CMD=%02x\\VAR_2\", VAR_1);",
"#endif\ns = idebus_active_if(VAR_0);",
"if (s != VAR_0->ifs && !s->bs)\nreturn;",
"if ((s->status & (BUSY_STAT|DRQ_STAT)) && VAR_1 != WIN_DEVICE_RESET)\nreturn;",
"if (!ide_cmd_permitted(s, VAR_1)) {",
"goto abort_cmd;",
"}",
"if (ide_cmd_table[VAR_1].handler != NULL) {",
"bool complete;",
"s->status = READY_STAT | BUSY_STAT;",
"s->error = 0;",
"complete = ide_cmd_table[VAR_1].handler(s, VAR_1);",
"if (complete) {",
"s->status &= ~BUSY_STAT;",
"assert(!!s->error == !!(s->status & ERR_STAT));",
"if ((ide_cmd_table[VAR_1].flags & SET_DSC) && !s->error) {",
"s->status |= SEEK_STAT;",
"}",
"ide_set_irq(s->VAR_0);",
"}",
"return;",
"}",
"switch(VAR_1) {",
"case WIN_SETMULT:\nif (s->drive_kind == IDE_CFATA && s->nsector == 0) {",
"s->mult_sectors = 0;",
"s->status = READY_STAT | SEEK_STAT;",
"} else if ((s->nsector & 0xff) != 0 &&",
"((s->nsector & 0xff) > MAX_MULT_SECTORS ||\n(s->nsector & (s->nsector - 1)) != 0)) {",
"ide_abort_command(s);",
"} else {",
"s->mult_sectors = s->nsector & 0xff;",
"s->status = READY_STAT | SEEK_STAT;",
"}",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_VERIFY_EXT:\nVAR_3 = 1;",
"case WIN_VERIFY:\ncase WIN_VERIFY_ONCE:\nide_cmd_lba48_transform(s, VAR_3);",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_READ_EXT:\nVAR_3 = 1;",
"case WIN_READ:\ncase WIN_READ_ONCE:\nif (s->drive_kind == IDE_CD) {",
"ide_set_signature(s);",
"goto abort_cmd;",
"}",
"if (!s->bs) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"s->req_nb_sectors = 1;",
"ide_sector_read(s);",
"break;",
"case WIN_WRITE_EXT:\nVAR_3 = 1;",
"case WIN_WRITE:\ncase WIN_WRITE_ONCE:\ncase CFA_WRITE_SECT_WO_ERASE:\ncase WIN_WRITE_VERIFY:\nif (!s->bs) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"s->error = 0;",
"s->status = SEEK_STAT | READY_STAT;",
"s->req_nb_sectors = 1;",
"ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);",
"s->media_changed = 1;",
"break;",
"case WIN_MULTREAD_EXT:\nVAR_3 = 1;",
"case WIN_MULTREAD:\nif (!s->bs) {",
"goto abort_cmd;",
"}",
"if (!s->mult_sectors) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"s->req_nb_sectors = s->mult_sectors;",
"ide_sector_read(s);",
"break;",
"case WIN_MULTWRITE_EXT:\nVAR_3 = 1;",
"case WIN_MULTWRITE:\ncase CFA_WRITE_MULTI_WO_ERASE:\nif (!s->bs) {",
"goto abort_cmd;",
"}",
"if (!s->mult_sectors) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"s->error = 0;",
"s->status = SEEK_STAT | READY_STAT;",
"s->req_nb_sectors = s->mult_sectors;",
"VAR_2 = s->nsector;",
"if (VAR_2 > s->req_nb_sectors)\nVAR_2 = s->req_nb_sectors;",
"ide_transfer_start(s, s->io_buffer, 512 * VAR_2, ide_sector_write);",
"s->media_changed = 1;",
"break;",
"case WIN_READDMA_EXT:\nVAR_3 = 1;",
"case WIN_READDMA:\ncase WIN_READDMA_ONCE:\nif (!s->bs) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"ide_sector_start_dma(s, IDE_DMA_READ);",
"break;",
"case WIN_WRITEDMA_EXT:\nVAR_3 = 1;",
"case WIN_WRITEDMA:\ncase WIN_WRITEDMA_ONCE:\nif (!s->bs) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"ide_sector_start_dma(s, IDE_DMA_WRITE);",
"s->media_changed = 1;",
"break;",
"case WIN_READ_NATIVE_MAX_EXT:\nVAR_3 = 1;",
"case WIN_READ_NATIVE_MAX:\nif (s->nb_sectors == 0) {",
"goto abort_cmd;",
"}",
"ide_cmd_lba48_transform(s, VAR_3);",
"ide_set_sector(s, s->nb_sectors - 1);",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_CHECKPOWERMODE1:\ncase WIN_CHECKPOWERMODE2:\ns->error = 0;",
"s->nsector = 0xff;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_SETFEATURES:\nif (!s->bs)\ngoto abort_cmd;",
"switch(s->feature) {",
"case 0x02:\nbdrv_set_enable_write_cache(s->bs, true);",
"identify_data = (uint16_t *)s->identify_data;",
"put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1);",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case 0x82:\nbdrv_set_enable_write_cache(s->bs, false);",
"identify_data = (uint16_t *)s->identify_data;",
"put_le16(identify_data + 85, (1 << 14) | 1);",
"ide_flush_cache(s);",
"break;",
"case 0xcc:\ncase 0x66:\ncase 0xaa:\ncase 0x55:\ncase 0x05:\ncase 0x85:\ncase 0x69:\ncase 0x67:\ncase 0x96:\ncase 0x9a:\ncase 0x42:\ncase 0xc2:\ns->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case 0x03: {",
"uint8_t VAR_1 = s->nsector & 0x07;",
"identify_data = (uint16_t *)s->identify_data;",
"switch (s->nsector >> 3) {",
"case 0x00:\ncase 0x01:\nput_le16(identify_data + 62,0x07);",
"put_le16(identify_data + 63,0x07);",
"put_le16(identify_data + 88,0x3f);",
"break;",
"case 0x02:\nput_le16(identify_data + 62,0x07 | (1 << (VAR_1 + 8)));",
"put_le16(identify_data + 63,0x07);",
"put_le16(identify_data + 88,0x3f);",
"break;",
"case 0x04:\nput_le16(identify_data + 62,0x07);",
"put_le16(identify_data + 63,0x07 | (1 << (VAR_1 + 8)));",
"put_le16(identify_data + 88,0x3f);",
"break;",
"case 0x08:\nput_le16(identify_data + 62,0x07);",
"put_le16(identify_data + 63,0x07);",
"put_le16(identify_data + 88,0x3f | (1 << (VAR_1 + 8)));",
"break;",
"default:\ngoto abort_cmd;",
"}",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"}",
"default:\ngoto abort_cmd;",
"}",
"break;",
"case WIN_FLUSH_CACHE:\ncase WIN_FLUSH_CACHE_EXT:\nide_flush_cache(s);",
"break;",
"case WIN_SEEK:\ns->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_PIDENTIFY:\nide_atapi_identify(s);",
"s->status = READY_STAT | SEEK_STAT;",
"ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_DIAGNOSE:\nide_set_signature(s);",
"if (s->drive_kind == IDE_CD)\ns->status = 0;",
"else\ns->status = READY_STAT | SEEK_STAT;",
"s->error = 0x01;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_DEVICE_RESET:\nide_set_signature(s);",
"s->status = 0x00;",
"s->error = 0x01;",
"break;",
"case WIN_PACKETCMD:\nif (s->feature & 0x02)\ngoto abort_cmd;",
"s->status = READY_STAT | SEEK_STAT;",
"s->atapi_dma = s->feature & 1;",
"s->nsector = 1;",
"ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,\nide_atapi_cmd);",
"break;",
"case CFA_REQ_EXT_ERROR_CODE:\ns->error = 0x09;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case CFA_ERASE_SECTORS:\ncase CFA_WEAR_LEVEL:\n#if 0\ncase WIN_SECURITY_FREEZE_LOCK:\n#endif\nif (VAR_1 == CFA_WEAR_LEVEL)\ns->nsector = 0;",
"if (VAR_1 == CFA_ERASE_SECTORS)\ns->media_changed = 1;",
"s->error = 0x00;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case CFA_TRANSLATE_SECTOR:\ns->error = 0x00;",
"s->status = READY_STAT | SEEK_STAT;",
"memset(s->io_buffer, 0, 0x200);",
"s->io_buffer[0x00] = s->hcyl;",
"s->io_buffer[0x01] = s->lcyl;",
"s->io_buffer[0x02] = s->select;",
"s->io_buffer[0x03] = s->sector;",
"s->io_buffer[0x04] = ide_get_sector(s) >> 16;",
"s->io_buffer[0x05] = ide_get_sector(s) >> 8;",
"s->io_buffer[0x06] = ide_get_sector(s) >> 0;",
"s->io_buffer[0x13] = 0x00;",
"s->io_buffer[0x18] = 0x00;",
"s->io_buffer[0x19] = 0x00;",
"s->io_buffer[0x1a] = 0x01;",
"ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);",
"ide_set_irq(s->VAR_0);",
"break;",
"case CFA_ACCESS_METADATA_STORAGE:\nswitch (s->feature) {",
"case 0x02:\nide_cfata_metadata_inquiry(s);",
"break;",
"case 0x03:\nide_cfata_metadata_read(s);",
"break;",
"case 0x04:\nide_cfata_metadata_write(s);",
"break;",
"default:\ngoto abort_cmd;",
"}",
"ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);",
"s->status = 0x00;",
"ide_set_irq(s->VAR_0);",
"break;",
"case IBM_SENSE_CONDITION:\nswitch (s->feature) {",
"case 0x01:\ns->nsector = 0x50;",
"break;",
"default:\ngoto abort_cmd;",
"}",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case WIN_SMART:\nif (s->hcyl != 0xc2 || s->lcyl != 0x4f)\ngoto abort_cmd;",
"if (!s->smart_enabled && s->feature != SMART_ENABLE)\ngoto abort_cmd;",
"switch (s->feature) {",
"case SMART_DISABLE:\ns->smart_enabled = 0;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_ENABLE:\ns->smart_enabled = 1;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_ATTR_AUTOSAVE:\nswitch (s->sector) {",
"case 0x00:\ns->smart_autosave = 0;",
"break;",
"case 0xf1:\ns->smart_autosave = 1;",
"break;",
"default:\ngoto abort_cmd;",
"}",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_STATUS:\nif (!s->smart_errors) {",
"s->hcyl = 0xc2;",
"s->lcyl = 0x4f;",
"} else {",
"s->hcyl = 0x2c;",
"s->lcyl = 0xf4;",
"}",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_READ_THRESH:\nmemset(s->io_buffer, 0, 0x200);",
"s->io_buffer[0] = 0x01;",
"for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(smart_attributes); VAR_2++) {",
"s->io_buffer[2+0+(VAR_2*12)] = smart_attributes[VAR_2][0];",
"s->io_buffer[2+1+(VAR_2*12)] = smart_attributes[VAR_2][11];",
"}",
"for (VAR_2=0; VAR_2<511; VAR_2++)",
"s->io_buffer[511] += s->io_buffer[VAR_2];",
"s->io_buffer[511] = 0x100 - s->io_buffer[511];",
"s->status = READY_STAT | SEEK_STAT;",
"ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_READ_DATA:\nmemset(s->io_buffer, 0, 0x200);",
"s->io_buffer[0] = 0x01;",
"for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(smart_attributes); VAR_2++) {",
"int i;",
"for(i = 0; i < 11; i++) {",
"s->io_buffer[2+i+(VAR_2*12)] = smart_attributes[VAR_2][i];",
"}",
"}",
"s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);",
"if (s->smart_selftest_count == 0) {",
"s->io_buffer[363] = 0;",
"} else {",
"s->io_buffer[363] =\ns->smart_selftest_data[3 +\n(s->smart_selftest_count - 1) *\n24];",
"}",
"s->io_buffer[364] = 0x20;",
"s->io_buffer[365] = 0x01;",
"s->io_buffer[367] = (1<<4 | 1<<3 | 1);",
"s->io_buffer[368] = 0x03;",
"s->io_buffer[369] = 0x00;",
"s->io_buffer[370] = 0x01;",
"s->io_buffer[372] = 0x02;",
"s->io_buffer[373] = 0x36;",
"s->io_buffer[374] = 0x01;",
"for (VAR_2=0; VAR_2<511; VAR_2++)",
"s->io_buffer[511] += s->io_buffer[VAR_2];",
"s->io_buffer[511] = 0x100 - s->io_buffer[511];",
"s->status = READY_STAT | SEEK_STAT;",
"ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_READ_LOG:\nswitch (s->sector) {",
"case 0x01:\nmemset(s->io_buffer, 0, 0x200);",
"s->io_buffer[0] = 0x01;",
"s->io_buffer[1] = 0x00;",
"s->io_buffer[452] = s->smart_errors & 0xff;",
"s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;",
"for (VAR_2=0; VAR_2<511; VAR_2++)",
"s->io_buffer[511] += s->io_buffer[VAR_2];",
"s->io_buffer[511] = 0x100 - s->io_buffer[511];",
"break;",
"case 0x06:\nmemset(s->io_buffer, 0, 0x200);",
"s->io_buffer[0] = 0x01;",
"if (s->smart_selftest_count == 0) {",
"s->io_buffer[508] = 0;",
"} else {",
"s->io_buffer[508] = s->smart_selftest_count;",
"for (VAR_2=2; VAR_2<506; VAR_2++)",
"s->io_buffer[VAR_2] = s->smart_selftest_data[VAR_2];",
"}",
"for (VAR_2=0; VAR_2<511; VAR_2++)",
"s->io_buffer[511] += s->io_buffer[VAR_2];",
"s->io_buffer[511] = 0x100 - s->io_buffer[511];",
"break;",
"default:\ngoto abort_cmd;",
"}",
"s->status = READY_STAT | SEEK_STAT;",
"ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);",
"ide_set_irq(s->VAR_0);",
"break;",
"case SMART_EXECUTE_OFFLINE:\nswitch (s->sector) {",
"case 0:\ncase 1:\ncase 2:\ns->smart_selftest_count++;",
"if(s->smart_selftest_count > 21)\ns->smart_selftest_count = 0;",
"VAR_2 = 2 + (s->smart_selftest_count - 1) * 24;",
"s->smart_selftest_data[VAR_2] = s->sector;",
"s->smart_selftest_data[VAR_2+1] = 0x00;",
"s->smart_selftest_data[VAR_2+2] = 0x34;",
"s->smart_selftest_data[VAR_2+3] = 0x12;",
"s->status = READY_STAT | SEEK_STAT;",
"ide_set_irq(s->VAR_0);",
"break;",
"default:\ngoto abort_cmd;",
"}",
"break;",
"default:\ngoto abort_cmd;",
"}",
"break;",
"default:\nabort_cmd:\nide_abort_command(s);",
"ide_set_irq(s->VAR_0);",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
25,
27
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
129,
131,
135
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179,
181
],
[
185,
187,
189,
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
217
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245,
247
],
[
251,
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
289,
291
],
[
295,
297,
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313,
315
],
[
319,
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339,
341
],
[
345,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
367,
369,
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381,
383,
385
],
[
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
],
[
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,
533
],
[
535
],
[
537
],
[
541,
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553,
555
],
[
557,
559
],
[
565,
567
],
[
569
],
[
575
],
[
577
],
[
579,
581
],
[
583
],
[
585
],
[
587
],
[
589,
593,
595
],
[
597
],
[
599
],
[
601
],
[
603,
605
],
[
607
],
[
611,
613
],
[
615
],
[
617
],
[
619
],
[
621,
623,
625,
631,
633,
635,
637
],
[
639,
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651,
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687,
689
],
[
691,
693
],
[
695
],
[
697,
699
],
[
701
],
[
703,
705
],
[
707
],
[
709,
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723,
725
],
[
727,
729
],
[
731
],
[
733,
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
747,
749,
751
],
[
753,
755
],
[
757
],
[
759,
761
],
[
763
],
[
765
],
[
767
],
[
769,
771
],
[
773
],
[
775
],
[
777
],
[
779,
781
],
[
783,
785
],
[
787
],
[
789,
791
],
[
793
],
[
795,
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
],
[
865
],
[
867
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879
],
[
881
],
[
883,
885,
887,
889
],
[
891
],
[
893
],
[
895
],
[
899
],
[
901
],
[
903
],
[
905
],
[
907
],
[
909
],
[
911
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929,
931
],
[
933,
935
],
[
937
],
[
939
],
[
941
],
[
943
],
[
947
],
[
949
],
[
951
],
[
953
],
[
955,
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983,
985
],
[
987
],
[
989
],
[
991
],
[
993
],
[
995
],
[
997,
999
],
[
1001,
1003,
1005,
1007
],
[
1009,
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1029,
1031
],
[
1033
],
[
1035
],
[
1037,
1039
],
[
1041
],
[
1043
],
[
1045,
1049,
1051
],
[
1053
],
[
1055
],
[
1057
],
[
1059
]
]
|
13,908 | av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth ## _c
#define ADDPX_DSP(depth) \
c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\
c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)
if (bit_depth > 8 && bit_depth <= 16) {
ADDPX_DSP(16);
} else {
ADDPX_DSP(8);
}
#define H264_DSP(depth) \
c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
if (chroma_format_idc == 1)\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
if (chroma_format_idc == 1)\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
else\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
\
c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
\
c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
else\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
else\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
c->h264_loop_filter_strength= NULL;
switch (bit_depth) {
case 9:
H264_DSP(9);
break;
case 10:
H264_DSP(10);
break;
default:
H264_DSP(8);
break;
}
c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
}
| true | FFmpeg | a03a642d5ceb5f2f7c6ebbf56ff365dfbcdb65eb | av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth ## _c
#define ADDPX_DSP(depth) \
c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\
c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)
if (bit_depth > 8 && bit_depth <= 16) {
ADDPX_DSP(16);
} else {
ADDPX_DSP(8);
}
#define H264_DSP(depth) \
c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
if (chroma_format_idc == 1)\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
if (chroma_format_idc == 1)\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
else\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
\
c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
\
c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
else\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
else\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
c->h264_loop_filter_strength= NULL;
switch (bit_depth) {
case 9:
H264_DSP(9);
break;
case 10:
H264_DSP(10);
break;
default:
H264_DSP(8);
break;
}
c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
}
| {
"code": [
" if (chroma_format_idc == 1)\\",
" if (chroma_format_idc == 1)\\",
" if (chroma_format_idc == 1)\\",
" if (chroma_format_idc == 1)\\",
" if (chroma_format_idc == 1)\\",
" if (chroma_format_idc == 1)\\"
],
"line_no": [
47,
47,
47,
47,
47,
47
]
} | av_cold void FUNC_0(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth ## _c
#define ADDPX_DSP(depth) \
c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\
c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)
if (bit_depth > 8 && bit_depth <= 16) {
ADDPX_DSP(16);
} else {
ADDPX_DSP(8);
}
#define H264_DSP(depth) \
c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
if (chroma_format_idc == 1)\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
if (chroma_format_idc == 1)\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
else\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
\
c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
\
c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
else\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
else\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
c->h264_loop_filter_strength= NULL;
switch (bit_depth) {
case 9:
H264_DSP(9);
break;
case 10:
H264_DSP(10);
break;
default:
H264_DSP(8);
break;
}
c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
}
| [
"av_cold void FUNC_0(H264DSPContext *c, const int bit_depth,\nconst int chroma_format_idc)\n{",
"#undef FUNC\n#define FUNC(a, depth) a ## _ ## depth ## _c\n#define ADDPX_DSP(depth) \\\nc->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\\",
"c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)\nif (bit_depth > 8 && bit_depth <= 16) {",
"ADDPX_DSP(16);",
"} else {",
"ADDPX_DSP(8);",
"}",
"#define H264_DSP(depth) \\\nc->h264_idct_add= FUNC(ff_h264_idct_add, depth);\\",
"c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\\",
"c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\\",
"c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\\",
"c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\\",
"c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\\",
"else\\\nc->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\\",
"c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\\",
"c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\\",
"else\\\nc->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\\",
"\\\nc->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\\",
"c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\\",
"c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\\",
"c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\\",
"c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\\",
"c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\\",
"c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\\",
"c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\\",
"\\\nc->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\\",
"c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\\",
"c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\\",
"c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\\",
"c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\\",
"c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\\",
"c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\\",
"else\\\nc->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\\",
"else\\\nc->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\\",
"c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\\",
"else\\\nc->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\\",
"if (chroma_format_idc == 1)\\\nc->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\\",
"else\\\nc->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\\",
"c->h264_loop_filter_strength= NULL;",
"switch (bit_depth) {",
"case 9:\nH264_DSP(9);",
"break;",
"case 10:\nH264_DSP(10);",
"break;",
"default:\nH264_DSP(8);",
"break;",
"}",
"c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;",
"if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);",
"if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);",
"if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7,
9,
13,
15
],
[
17,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
139
],
[
141,
143
],
[
145
],
[
147,
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
]
]
|
13,909 | static void gen_slbia(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_slbia(cpu_env);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_slbia(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_slbia(cpu_env);
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
13,
7,
11,
13,
7,
11,
13,
7,
13,
5,
9,
11,
21,
5,
9,
11,
21,
21,
5,
9,
11,
7,
11,
13,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
7,
13,
21,
7,
11,
13,
21,
7,
13,
21,
7,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
11,
21,
11,
21,
11,
21,
11,
21,
5,
7,
9,
11,
13,
21,
7,
11,
13,
21,
5,
7,
9,
11,
13,
21,
5,
7,
9,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
5,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_slbia(cpu_env);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"gen_helper_slbia(cpu_env);",
"#endif\n}"
]
| [
0,
1,
1,
1,
0,
0,
0,
1
]
| [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
]
]
|
13,910 | int nbd_client_init(BlockDriverState *bs,
QIOChannelSocket *sioc,
const char *export,
QCryptoTLSCreds *tlscreds,
const char *hostname,
Error **errp)
{
NbdClientSession *client = nbd_get_client_session(bs);
int ret;
/* NBD handshake */
logout("session init %s\n", export);
qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);
ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), export,
&client->nbdflags,
tlscreds, hostname,
&client->ioc,
&client->size, errp);
if (ret < 0) {
logout("Failed to negotiate with the NBD server\n");
return ret;
}
if (client->nbdflags & NBD_FLAG_SEND_FUA) {
bs->supported_write_flags = BDRV_REQ_FUA;
}
qemu_co_mutex_init(&client->send_mutex);
qemu_co_mutex_init(&client->free_sema);
client->sioc = sioc;
object_ref(OBJECT(client->sioc));
if (!client->ioc) {
client->ioc = QIO_CHANNEL(sioc);
object_ref(OBJECT(client->ioc));
}
/* Now that we're connected, set the socket to be non-blocking and
* kick the reply mechanism. */
qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
logout("Established connection with NBD server\n");
return 0;
}
| true | qemu | 9bc9732faeff09828fe38c0ebe2401ee131a6fca | int nbd_client_init(BlockDriverState *bs,
QIOChannelSocket *sioc,
const char *export,
QCryptoTLSCreds *tlscreds,
const char *hostname,
Error **errp)
{
NbdClientSession *client = nbd_get_client_session(bs);
int ret;
logout("session init %s\n", export);
qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);
ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), export,
&client->nbdflags,
tlscreds, hostname,
&client->ioc,
&client->size, errp);
if (ret < 0) {
logout("Failed to negotiate with the NBD server\n");
return ret;
}
if (client->nbdflags & NBD_FLAG_SEND_FUA) {
bs->supported_write_flags = BDRV_REQ_FUA;
}
qemu_co_mutex_init(&client->send_mutex);
qemu_co_mutex_init(&client->free_sema);
client->sioc = sioc;
object_ref(OBJECT(client->sioc));
if (!client->ioc) {
client->ioc = QIO_CHANNEL(sioc);
object_ref(OBJECT(client->ioc));
}
qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
logout("Established connection with NBD server\n");
return 0;
}
| {
"code": [
" qemu_co_mutex_init(&client->free_sema);"
],
"line_no": [
57
]
} | int FUNC_0(BlockDriverState *VAR_0,
QIOChannelSocket *VAR_1,
const char *VAR_2,
QCryptoTLSCreds *VAR_3,
const char *VAR_4,
Error **VAR_5)
{
NbdClientSession *client = nbd_get_client_session(VAR_0);
int VAR_6;
logout("session init %s\n", VAR_2);
qio_channel_set_blocking(QIO_CHANNEL(VAR_1), true, NULL);
VAR_6 = nbd_receive_negotiate(QIO_CHANNEL(VAR_1), VAR_2,
&client->nbdflags,
VAR_3, VAR_4,
&client->ioc,
&client->size, VAR_5);
if (VAR_6 < 0) {
logout("Failed to negotiate with the NBD server\n");
return VAR_6;
}
if (client->nbdflags & NBD_FLAG_SEND_FUA) {
VAR_0->supported_write_flags = BDRV_REQ_FUA;
}
qemu_co_mutex_init(&client->send_mutex);
qemu_co_mutex_init(&client->free_sema);
client->VAR_1 = VAR_1;
object_ref(OBJECT(client->VAR_1));
if (!client->ioc) {
client->ioc = QIO_CHANNEL(VAR_1);
object_ref(OBJECT(client->ioc));
}
qio_channel_set_blocking(QIO_CHANNEL(VAR_1), false, NULL);
nbd_client_attach_aio_context(VAR_0, bdrv_get_aio_context(VAR_0));
logout("Established connection with NBD server\n");
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0,\nQIOChannelSocket *VAR_1,\nconst char *VAR_2,\nQCryptoTLSCreds *VAR_3,\nconst char *VAR_4,\nError **VAR_5)\n{",
"NbdClientSession *client = nbd_get_client_session(VAR_0);",
"int VAR_6;",
"logout(\"session init %s\\n\", VAR_2);",
"qio_channel_set_blocking(QIO_CHANNEL(VAR_1), true, NULL);",
"VAR_6 = nbd_receive_negotiate(QIO_CHANNEL(VAR_1), VAR_2,\n&client->nbdflags,\nVAR_3, VAR_4,\n&client->ioc,\n&client->size, VAR_5);",
"if (VAR_6 < 0) {",
"logout(\"Failed to negotiate with the NBD server\\n\");",
"return VAR_6;",
"}",
"if (client->nbdflags & NBD_FLAG_SEND_FUA) {",
"VAR_0->supported_write_flags = BDRV_REQ_FUA;",
"}",
"qemu_co_mutex_init(&client->send_mutex);",
"qemu_co_mutex_init(&client->free_sema);",
"client->VAR_1 = VAR_1;",
"object_ref(OBJECT(client->VAR_1));",
"if (!client->ioc) {",
"client->ioc = QIO_CHANNEL(VAR_1);",
"object_ref(OBJECT(client->ioc));",
"}",
"qio_channel_set_blocking(QIO_CHANNEL(VAR_1), false, NULL);",
"nbd_client_attach_aio_context(VAR_0, bdrv_get_aio_context(VAR_0));",
"logout(\"Established connection with NBD server\\n\");",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
29,
31,
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
]
]
|
13,911 | static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride,
const uint8_t *block,
const int *color_tab)
{
uint8_t indices[16];
int x, y;
decompress_indices(indices, block + 2);
/* Only one or two channels are stored at most, since it only used to
* compress specular (black and white) or normal (red and green) maps.
* Although the standard says to zero out unused components, many
* implementations fill all of them with the same value. */
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
int i = indices[x + y * 4];
/* Interval expansion from [-1 1] or [0 1] to [0 255]. */
int c = color_tab[i];
uint32_t pixel = RGBA(c, c, c, 255);
AV_WL32(dst + x * 4 + y * stride, pixel);
}
}
}
| true | FFmpeg | ec7f04c13a6e6e483cc86e576aff7700e42cd59e | static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride,
const uint8_t *block,
const int *color_tab)
{
uint8_t indices[16];
int x, y;
decompress_indices(indices, block + 2);
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
int i = indices[x + y * 4];
int c = color_tab[i];
uint32_t pixel = RGBA(c, c, c, 255);
AV_WL32(dst + x * 4 + y * stride, pixel);
}
}
}
| {
"code": [
" uint32_t pixel = RGBA(c, c, c, 255);"
],
"line_no": [
37
]
} | static inline void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1,
const uint8_t *VAR_2,
const int *VAR_3)
{
uint8_t indices[16];
int VAR_4, VAR_5;
decompress_indices(indices, VAR_2 + 2);
for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {
for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {
int VAR_6 = indices[VAR_4 + VAR_5 * 4];
int VAR_7 = VAR_3[VAR_6];
uint32_t pixel = RGBA(VAR_7, VAR_7, VAR_7, 255);
AV_WL32(VAR_0 + VAR_4 * 4 + VAR_5 * VAR_1, pixel);
}
}
}
| [
"static inline void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1,\nconst uint8_t *VAR_2,\nconst int *VAR_3)\n{",
"uint8_t indices[16];",
"int VAR_4, VAR_5;",
"decompress_indices(indices, VAR_2 + 2);",
"for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {",
"int VAR_6 = indices[VAR_4 + VAR_5 * 4];",
"int VAR_7 = VAR_3[VAR_6];",
"uint32_t pixel = RGBA(VAR_7, VAR_7, VAR_7, 255);",
"AV_WL32(VAR_0 + VAR_4 * 4 + VAR_5 * VAR_1, pixel);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
]
|
13,912 | int sclp_service_call(uint64_t sccb, uint32_t code)
{
int r = 0;
SCCB work_sccb;
hwaddr sccb_len = sizeof(SCCB);
/* first some basic checks on program checks */
if (cpu_physical_memory_is_io(sccb)) {
r = -PGM_ADDRESSING;
goto out;
}
if (sccb & ~0x7ffffff8ul) {
r = -PGM_SPECIFICATION;
goto out;
}
/*
* we want to work on a private copy of the sccb, to prevent guests
* from playing dirty tricks by modifying the memory content after
* the host has checked the values
*/
cpu_physical_memory_read(sccb, &work_sccb, sccb_len);
/* Valid sccb sizes */
if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||
be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {
r = -PGM_SPECIFICATION;
goto out;
}
sclp_execute((SCCB *)&work_sccb, code);
cpu_physical_memory_write(sccb, &work_sccb,
be16_to_cpu(work_sccb.h.length));
sclp_service_interrupt(sccb);
out:
return r;
}
| true | qemu | 6e25280216fc23c8387892f76d961559da124528 | int sclp_service_call(uint64_t sccb, uint32_t code)
{
int r = 0;
SCCB work_sccb;
hwaddr sccb_len = sizeof(SCCB);
if (cpu_physical_memory_is_io(sccb)) {
r = -PGM_ADDRESSING;
goto out;
}
if (sccb & ~0x7ffffff8ul) {
r = -PGM_SPECIFICATION;
goto out;
}
cpu_physical_memory_read(sccb, &work_sccb, sccb_len);
if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||
be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {
r = -PGM_SPECIFICATION;
goto out;
}
sclp_execute((SCCB *)&work_sccb, code);
cpu_physical_memory_write(sccb, &work_sccb,
be16_to_cpu(work_sccb.h.length));
sclp_service_interrupt(sccb);
out:
return r;
}
| {
"code": [
"int sclp_service_call(uint64_t sccb, uint32_t code)",
" if (sccb & ~0x7ffffff8ul) {"
],
"line_no": [
1,
25
]
} | int FUNC_0(uint64_t VAR_0, uint32_t VAR_1)
{
int VAR_2 = 0;
SCCB work_sccb;
hwaddr sccb_len = sizeof(SCCB);
if (cpu_physical_memory_is_io(VAR_0)) {
VAR_2 = -PGM_ADDRESSING;
goto out;
}
if (VAR_0 & ~0x7ffffff8ul) {
VAR_2 = -PGM_SPECIFICATION;
goto out;
}
cpu_physical_memory_read(VAR_0, &work_sccb, sccb_len);
if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||
be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {
VAR_2 = -PGM_SPECIFICATION;
goto out;
}
sclp_execute((SCCB *)&work_sccb, VAR_1);
cpu_physical_memory_write(VAR_0, &work_sccb,
be16_to_cpu(work_sccb.h.length));
sclp_service_interrupt(VAR_0);
out:
return VAR_2;
}
| [
"int FUNC_0(uint64_t VAR_0, uint32_t VAR_1)\n{",
"int VAR_2 = 0;",
"SCCB work_sccb;",
"hwaddr sccb_len = sizeof(SCCB);",
"if (cpu_physical_memory_is_io(VAR_0)) {",
"VAR_2 = -PGM_ADDRESSING;",
"goto out;",
"}",
"if (VAR_0 & ~0x7ffffff8ul) {",
"VAR_2 = -PGM_SPECIFICATION;",
"goto out;",
"}",
"cpu_physical_memory_read(VAR_0, &work_sccb, sccb_len);",
"if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||\nbe16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {",
"VAR_2 = -PGM_SPECIFICATION;",
"goto out;",
"}",
"sclp_execute((SCCB *)&work_sccb, VAR_1);",
"cpu_physical_memory_write(VAR_0, &work_sccb,\nbe16_to_cpu(work_sccb.h.length));",
"sclp_service_interrupt(VAR_0);",
"out:\nreturn VAR_2;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
45
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
73
],
[
77,
79
],
[
81
]
]
|
13,913 | unsigned avutil_version(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
return LIBAVUTIL_VERSION_INT; | true | FFmpeg | 9a697cfe716e2ed5f5ba183910c104c5ad783256 | unsigned avutil_version(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81);
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
return LIBAVUTIL_VERSION_INT; | {
"code": [],
"line_no": []
} | unsigned FUNC_0(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81);
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
return LIBAVUTIL_VERSION_INT; | [
"unsigned FUNC_0(void)\n{",
"av_assert0(AV_PIX_FMT_VDA_VLD == 81);",
"av_assert0(AV_SAMPLE_FMT_DBLP == 9);",
"av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);",
"av_assert0(AV_PICTURE_TYPE_BI == 7);",
"av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);",
"av_assert0(HAVE_MMX2 == HAVE_MMXEXT);",
"return LIBAVUTIL_VERSION_INT;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
]
]
|
13,916 | static CharDriverState *qemu_chr_open_tty_fd(int fd,
ChardevCommon *backend,
Error **errp)
{
CharDriverState *chr;
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd, backend, errp);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
return chr;
| true | qemu | 71200fb9664c2967a1cdd22b68b0da3a8b2b3eb7 | static CharDriverState *qemu_chr_open_tty_fd(int fd,
ChardevCommon *backend,
Error **errp)
{
CharDriverState *chr;
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd, backend, errp);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
return chr;
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(int fd,
ChardevCommon *backend,
Error **errp)
{
CharDriverState *chr;
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd, backend, errp);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
return chr;
| [
"static CharDriverState *FUNC_0(int fd,\nChardevCommon *backend,\nError **errp)\n{",
"CharDriverState *chr;",
"tty_serial_init(fd, 115200, 'N', 8, 1);",
"chr = qemu_chr_open_fd(fd, fd, backend, errp);",
"chr->chr_ioctl = tty_serial_ioctl;",
"chr->chr_close = qemu_chr_close_tty;",
"return chr;"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
20
],
[
22
],
[
24
]
]
|
13,917 | static int vhost_user_set_owner(struct vhost_dev *dev)
{
VhostUserMsg msg = {
.request = VHOST_USER_SET_OWNER,
.flags = VHOST_USER_VERSION,
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| true | qemu | c4843a45e3d4f3698b214275ab5e78cdb6a3d212 | static int vhost_user_set_owner(struct vhost_dev *dev)
{
VhostUserMsg msg = {
.request = VHOST_USER_SET_OWNER,
.flags = VHOST_USER_VERSION,
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| {
"code": [
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);",
" vhost_user_write(dev, &msg, NULL, 0);"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15
]
} | static int FUNC_0(struct vhost_dev *VAR_0)
{
VhostUserMsg msg = {
.request = VHOST_USER_SET_OWNER,
.flags = VHOST_USER_VERSION,
};
vhost_user_write(VAR_0, &msg, NULL, 0);
return 0;
}
| [
"static int FUNC_0(struct vhost_dev *VAR_0)\n{",
"VhostUserMsg msg = {",
".request = VHOST_USER_SET_OWNER,\n.flags = VHOST_USER_VERSION,\n};",
"vhost_user_write(VAR_0, &msg, NULL, 0);",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
15
],
[
19
],
[
21
]
]
|
13,918 | static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x0202:
source_clip->duration = get_be64(pb);
break;
case 0x1201:
source_clip->start_position = get_be64(pb);
break;
case 0x1101:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
get_buffer(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
source_clip->source_track_id = get_be32(pb);
break;
}
return 0;
}
| true | FFmpeg | 39bb30f6640fe1faf4bbc779a79786028febc95d | static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x0202:
source_clip->duration = get_be64(pb);
break;
case 0x1201:
source_clip->start_position = get_be64(pb);
break;
case 0x1101:
url_fskip(pb, 16);
get_buffer(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
source_clip->source_track_id = get_be32(pb);
break;
}
return 0;
}
| {
"code": [
"static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)"
],
"line_no": [
1
]
} | static int FUNC_0(MXFStructuralComponent *VAR_0, ByteIOContext *VAR_1, int VAR_2)
{
switch(VAR_2) {
case 0x0202:
VAR_0->duration = get_be64(VAR_1);
break;
case 0x1201:
VAR_0->start_position = get_be64(VAR_1);
break;
case 0x1101:
url_fskip(VAR_1, 16);
get_buffer(VAR_1, VAR_0->source_package_uid, 16);
break;
case 0x1102:
VAR_0->source_track_id = get_be32(VAR_1);
break;
}
return 0;
}
| [
"static int FUNC_0(MXFStructuralComponent *VAR_0, ByteIOContext *VAR_1, int VAR_2)\n{",
"switch(VAR_2) {",
"case 0x0202:\nVAR_0->duration = get_be64(VAR_1);",
"break;",
"case 0x1201:\nVAR_0->start_position = get_be64(VAR_1);",
"break;",
"case 0x1101:\nurl_fskip(VAR_1, 16);",
"get_buffer(VAR_1, VAR_0->source_package_uid, 16);",
"break;",
"case 0x1102:\nVAR_0->source_track_id = get_be32(VAR_1);",
"break;",
"}",
"return 0;",
"}"
]
| [
1,
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
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
]
]
|
13,919 | static void adlib_realizefn (DeviceState *dev, Error **errp)
{
AdlibState *s = ADLIB(dev);
PortioList *port_list = g_new(PortioList, 1);
struct audsettings as;
if (glob_adlib) {
error_setg (errp, "Cannot create more than 1 adlib device");
return;
}
glob_adlib = s;
#ifdef HAS_YMF262
if (YMF262Init (1, 14318180, s->freq)) {
error_setg (errp, "YMF262Init %d failed", s->freq);
return;
}
else {
YMF262SetTimerHandler (0, timer_handler, 0);
s->enabled = 1;
}
#else
s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
if (!s->opl) {
error_setg (errp, "OPLCreate %d failed", s->freq);
return;
}
else {
OPLSetTimerHandler (s->opl, timer_handler, 0);
s->enabled = 1;
}
#endif
as.freq = s->freq;
as.nchannels = SHIFT;
as.fmt = AUD_FMT_S16;
as.endianness = AUDIO_HOST_ENDIANNESS;
AUD_register_card ("adlib", &s->card);
s->voice = AUD_open_out (
&s->card,
s->voice,
"adlib",
s,
adlib_callback,
&as
);
if (!s->voice) {
Adlib_fini (s);
error_setg (errp, "Initializing audio voice failed");
return;
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
s->mixbuf = g_malloc0 (s->samples << SHIFT);
adlib_portio_list[0].offset = s->port;
adlib_portio_list[1].offset = s->port + 8;
portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);
}
| true | qemu | 848696bf353750899832c51005f1bd3540da5c29 | static void adlib_realizefn (DeviceState *dev, Error **errp)
{
AdlibState *s = ADLIB(dev);
PortioList *port_list = g_new(PortioList, 1);
struct audsettings as;
if (glob_adlib) {
error_setg (errp, "Cannot create more than 1 adlib device");
return;
}
glob_adlib = s;
#ifdef HAS_YMF262
if (YMF262Init (1, 14318180, s->freq)) {
error_setg (errp, "YMF262Init %d failed", s->freq);
return;
}
else {
YMF262SetTimerHandler (0, timer_handler, 0);
s->enabled = 1;
}
#else
s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
if (!s->opl) {
error_setg (errp, "OPLCreate %d failed", s->freq);
return;
}
else {
OPLSetTimerHandler (s->opl, timer_handler, 0);
s->enabled = 1;
}
#endif
as.freq = s->freq;
as.nchannels = SHIFT;
as.fmt = AUD_FMT_S16;
as.endianness = AUDIO_HOST_ENDIANNESS;
AUD_register_card ("adlib", &s->card);
s->voice = AUD_open_out (
&s->card,
s->voice,
"adlib",
s,
adlib_callback,
&as
);
if (!s->voice) {
Adlib_fini (s);
error_setg (errp, "Initializing audio voice failed");
return;
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
s->mixbuf = g_malloc0 (s->samples << SHIFT);
adlib_portio_list[0].offset = s->port;
adlib_portio_list[1].offset = s->port + 8;
portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);
}
| {
"code": [
" PortioList *port_list = g_new(PortioList, 1);",
" portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, \"adlib\");",
" portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);",
" PortioList *port_list = g_new(PortioList, 1);",
" PortioList *port_list = g_new(PortioList, 1);",
" PortioList *port_list = g_new(PortioList, 1);"
],
"line_no": [
7,
119,
121,
7,
7,
7
]
} | static void FUNC_0 (DeviceState *VAR_0, Error **VAR_1)
{
AdlibState *s = ADLIB(VAR_0);
PortioList *port_list = g_new(PortioList, 1);
struct audsettings VAR_2;
if (glob_adlib) {
error_setg (VAR_1, "Cannot create more than 1 adlib device");
return;
}
glob_adlib = s;
#ifdef HAS_YMF262
if (YMF262Init (1, 14318180, s->freq)) {
error_setg (VAR_1, "YMF262Init %d failed", s->freq);
return;
}
else {
YMF262SetTimerHandler (0, timer_handler, 0);
s->enabled = 1;
}
#else
s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
if (!s->opl) {
error_setg (VAR_1, "OPLCreate %d failed", s->freq);
return;
}
else {
OPLSetTimerHandler (s->opl, timer_handler, 0);
s->enabled = 1;
}
#endif
VAR_2.freq = s->freq;
VAR_2.nchannels = SHIFT;
VAR_2.fmt = AUD_FMT_S16;
VAR_2.endianness = AUDIO_HOST_ENDIANNESS;
AUD_register_card ("adlib", &s->card);
s->voice = AUD_open_out (
&s->card,
s->voice,
"adlib",
s,
adlib_callback,
&VAR_2
);
if (!s->voice) {
Adlib_fini (s);
error_setg (VAR_1, "Initializing audio voice failed");
return;
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
s->mixbuf = g_malloc0 (s->samples << SHIFT);
adlib_portio_list[0].offset = s->port;
adlib_portio_list[1].offset = s->port + 8;
portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);
}
| [
"static void FUNC_0 (DeviceState *VAR_0, Error **VAR_1)\n{",
"AdlibState *s = ADLIB(VAR_0);",
"PortioList *port_list = g_new(PortioList, 1);",
"struct audsettings VAR_2;",
"if (glob_adlib) {",
"error_setg (VAR_1, \"Cannot create more than 1 adlib device\");",
"return;",
"}",
"glob_adlib = s;",
"#ifdef HAS_YMF262\nif (YMF262Init (1, 14318180, s->freq)) {",
"error_setg (VAR_1, \"YMF262Init %d failed\", s->freq);",
"return;",
"}",
"else {",
"YMF262SetTimerHandler (0, timer_handler, 0);",
"s->enabled = 1;",
"}",
"#else\ns->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);",
"if (!s->opl) {",
"error_setg (VAR_1, \"OPLCreate %d failed\", s->freq);",
"return;",
"}",
"else {",
"OPLSetTimerHandler (s->opl, timer_handler, 0);",
"s->enabled = 1;",
"}",
"#endif\nVAR_2.freq = s->freq;",
"VAR_2.nchannels = SHIFT;",
"VAR_2.fmt = AUD_FMT_S16;",
"VAR_2.endianness = AUDIO_HOST_ENDIANNESS;",
"AUD_register_card (\"adlib\", &s->card);",
"s->voice = AUD_open_out (\n&s->card,\ns->voice,\n\"adlib\",\ns,\nadlib_callback,\n&VAR_2\n);",
"if (!s->voice) {",
"Adlib_fini (s);",
"error_setg (VAR_1, \"Initializing audio voice failed\");",
"return;",
"}",
"s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;",
"s->mixbuf = g_malloc0 (s->samples << SHIFT);",
"adlib_portio_list[0].offset = s->port;",
"adlib_portio_list[1].offset = s->port + 8;",
"portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, \"adlib\");",
"portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
]
|
13,920 | static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
int width, int height, int stride,
const uint8_t *src, int src_size)
{
int i = 0;
int read = 0;
uint32_t length;
uint32_t offset = 1;
int esc_count = src[0];
GetBitContext gb;
lag_rac rac;
rac.avctx = l->avctx;
l->zeros = 0;
if (esc_count < 4) {
length = width * height;
if (esc_count && AV_RL32(src + 1) < length) {
length = AV_RL32(src + 1);
offset += 4;
}
init_get_bits(&gb, src + offset, src_size * 8);
if (lag_read_prob_header(&rac, &gb) < 0)
return -1;
ff_lag_rac_init(&rac, &gb, length - stride);
for (i = 0; i < height; i++)
read += lag_decode_line(l, &rac, dst + (i * stride), width,
stride, esc_count);
if (read > length)
av_log(l->avctx, AV_LOG_WARNING,
"Output more bytes than length (%d of %d)\n", read,
length);
} else if (esc_count < 8) {
esc_count -= 4;
if (esc_count > 0) {
/* Zero run coding only, no range coding. */
for (i = 0; i < height; i++)
src += lag_decode_zero_run_line(l, dst + (i * stride), src,
width, esc_count);
} else {
/* Plane is stored uncompressed */
for (i = 0; i < height; i++) {
memcpy(dst + (i * stride), src, width);
src += width;
}
}
} else if (esc_count == 0xff) {
/* Plane is a solid run of given value */
for (i = 0; i < height; i++)
memset(dst + i * stride, src[1], width);
/* Do not apply prediction.
Note: memset to 0 above, setting first value to src[1]
and applying prediction gives the same result. */
return 0;
} else {
av_log(l->avctx, AV_LOG_ERROR,
"Invalid zero run escape code! (%#x)\n", esc_count);
return -1;
}
for (i = 0; i < height; i++) {
lag_pred_line(l, dst, width, stride, i);
dst += stride;
}
return 0;
}
| true | FFmpeg | 0a82f5275f719e6e369a807720a2c3603aa0ddd9 | static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
int width, int height, int stride,
const uint8_t *src, int src_size)
{
int i = 0;
int read = 0;
uint32_t length;
uint32_t offset = 1;
int esc_count = src[0];
GetBitContext gb;
lag_rac rac;
rac.avctx = l->avctx;
l->zeros = 0;
if (esc_count < 4) {
length = width * height;
if (esc_count && AV_RL32(src + 1) < length) {
length = AV_RL32(src + 1);
offset += 4;
}
init_get_bits(&gb, src + offset, src_size * 8);
if (lag_read_prob_header(&rac, &gb) < 0)
return -1;
ff_lag_rac_init(&rac, &gb, length - stride);
for (i = 0; i < height; i++)
read += lag_decode_line(l, &rac, dst + (i * stride), width,
stride, esc_count);
if (read > length)
av_log(l->avctx, AV_LOG_WARNING,
"Output more bytes than length (%d of %d)\n", read,
length);
} else if (esc_count < 8) {
esc_count -= 4;
if (esc_count > 0) {
for (i = 0; i < height; i++)
src += lag_decode_zero_run_line(l, dst + (i * stride), src,
width, esc_count);
} else {
for (i = 0; i < height; i++) {
memcpy(dst + (i * stride), src, width);
src += width;
}
}
} else if (esc_count == 0xff) {
for (i = 0; i < height; i++)
memset(dst + i * stride, src[1], width);
return 0;
} else {
av_log(l->avctx, AV_LOG_ERROR,
"Invalid zero run escape code! (%#x)\n", esc_count);
return -1;
}
for (i = 0; i < height; i++) {
lag_pred_line(l, dst, width, stride, i);
dst += stride;
}
return 0;
}
| {
"code": [
" for (i = 0; i < height; i++)",
" src += lag_decode_zero_run_line(l, dst + (i * stride), src,",
" width, esc_count);"
],
"line_no": [
83,
85,
87
]
} | static int FUNC_0(LagarithContext *VAR_0, uint8_t *VAR_1,
int VAR_2, int VAR_3, int VAR_4,
const uint8_t *VAR_5, int VAR_6)
{
int VAR_7 = 0;
int VAR_8 = 0;
uint32_t length;
uint32_t offset = 1;
int VAR_9 = VAR_5[0];
GetBitContext gb;
lag_rac rac;
rac.avctx = VAR_0->avctx;
VAR_0->zeros = 0;
if (VAR_9 < 4) {
length = VAR_2 * VAR_3;
if (VAR_9 && AV_RL32(VAR_5 + 1) < length) {
length = AV_RL32(VAR_5 + 1);
offset += 4;
}
init_get_bits(&gb, VAR_5 + offset, VAR_6 * 8);
if (lag_read_prob_header(&rac, &gb) < 0)
return -1;
ff_lag_rac_init(&rac, &gb, length - VAR_4);
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
VAR_8 += lag_decode_line(VAR_0, &rac, VAR_1 + (VAR_7 * VAR_4), VAR_2,
VAR_4, VAR_9);
if (VAR_8 > length)
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Output more bytes than length (%d of %d)\n", VAR_8,
length);
} else if (VAR_9 < 8) {
VAR_9 -= 4;
if (VAR_9 > 0) {
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
VAR_5 += lag_decode_zero_run_line(VAR_0, VAR_1 + (VAR_7 * VAR_4), VAR_5,
VAR_2, VAR_9);
} else {
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
memcpy(VAR_1 + (VAR_7 * VAR_4), VAR_5, VAR_2);
VAR_5 += VAR_2;
}
}
} else if (VAR_9 == 0xff) {
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)
memset(VAR_1 + VAR_7 * VAR_4, VAR_5[1], VAR_2);
return 0;
} else {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid zero run escape code! (%#x)\n", VAR_9);
return -1;
}
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
lag_pred_line(VAR_0, VAR_1, VAR_2, VAR_4, VAR_7);
VAR_1 += VAR_4;
}
return 0;
}
| [
"static int FUNC_0(LagarithContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, int VAR_3, int VAR_4,\nconst uint8_t *VAR_5, int VAR_6)\n{",
"int VAR_7 = 0;",
"int VAR_8 = 0;",
"uint32_t length;",
"uint32_t offset = 1;",
"int VAR_9 = VAR_5[0];",
"GetBitContext gb;",
"lag_rac rac;",
"rac.avctx = VAR_0->avctx;",
"VAR_0->zeros = 0;",
"if (VAR_9 < 4) {",
"length = VAR_2 * VAR_3;",
"if (VAR_9 && AV_RL32(VAR_5 + 1) < length) {",
"length = AV_RL32(VAR_5 + 1);",
"offset += 4;",
"}",
"init_get_bits(&gb, VAR_5 + offset, VAR_6 * 8);",
"if (lag_read_prob_header(&rac, &gb) < 0)\nreturn -1;",
"ff_lag_rac_init(&rac, &gb, length - VAR_4);",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"VAR_8 += lag_decode_line(VAR_0, &rac, VAR_1 + (VAR_7 * VAR_4), VAR_2,\nVAR_4, VAR_9);",
"if (VAR_8 > length)\nav_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Output more bytes than length (%d of %d)\\n\", VAR_8,\nlength);",
"} else if (VAR_9 < 8) {",
"VAR_9 -= 4;",
"if (VAR_9 > 0) {",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"VAR_5 += lag_decode_zero_run_line(VAR_0, VAR_1 + (VAR_7 * VAR_4), VAR_5,\nVAR_2, VAR_9);",
"} else {",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"memcpy(VAR_1 + (VAR_7 * VAR_4), VAR_5, VAR_2);",
"VAR_5 += VAR_2;",
"}",
"}",
"} else if (VAR_9 == 0xff) {",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)",
"memset(VAR_1 + VAR_7 * VAR_4, VAR_5[1], VAR_2);",
"return 0;",
"} else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid zero run escape code! (%#x)\\n\", VAR_9);",
"return -1;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"lag_pred_line(VAR_0, VAR_1, VAR_2, VAR_4, VAR_7);",
"VAR_1 += 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,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49,
51
],
[
55
],
[
59
],
[
61,
63
],
[
67,
69,
71,
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
]
]
|
13,921 | static void check_pred16x16(H264PredContext *h, uint8_t *buf0, uint8_t *buf1,
int codec, int chroma_format, int bit_depth)
{
if (chroma_format == 1) {
int pred_mode;
declare_func(void, uint8_t *src, ptrdiff_t stride);
for (pred_mode = 0; pred_mode < 9; pred_mode++) {
if (check_pred_func(h->pred16x16[pred_mode], "16x16", pred16x16_modes[codec][pred_mode])) {
randomize_buffers();
call_ref(src0, 48);
call_new(src1, 48);
if (memcmp(buf0, buf1, BUF_SIZE))
fail();
bench_new(src1, 48);
}
}
}
}
| false | FFmpeg | 711781d7a1714ea4eb0217eb1ba04811978c43d1 | static void check_pred16x16(H264PredContext *h, uint8_t *buf0, uint8_t *buf1,
int codec, int chroma_format, int bit_depth)
{
if (chroma_format == 1) {
int pred_mode;
declare_func(void, uint8_t *src, ptrdiff_t stride);
for (pred_mode = 0; pred_mode < 9; pred_mode++) {
if (check_pred_func(h->pred16x16[pred_mode], "16x16", pred16x16_modes[codec][pred_mode])) {
randomize_buffers();
call_ref(src0, 48);
call_new(src1, 48);
if (memcmp(buf0, buf1, BUF_SIZE))
fail();
bench_new(src1, 48);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(H264PredContext *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
if (VAR_4 == 1) {
int VAR_6;
declare_func(void, uint8_t *src, ptrdiff_t stride);
for (VAR_6 = 0; VAR_6 < 9; VAR_6++) {
if (check_pred_func(VAR_0->pred16x16[VAR_6], "16x16", pred16x16_modes[VAR_3][VAR_6])) {
randomize_buffers();
call_ref(src0, 48);
call_new(src1, 48);
if (memcmp(VAR_1, VAR_2, BUF_SIZE))
fail();
bench_new(src1, 48);
}
}
}
}
| [
"static void FUNC_0(H264PredContext *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"if (VAR_4 == 1) {",
"int VAR_6;",
"declare_func(void, uint8_t *src, ptrdiff_t stride);",
"for (VAR_6 = 0; VAR_6 < 9; VAR_6++) {",
"if (check_pred_func(VAR_0->pred16x16[VAR_6], \"16x16\", pred16x16_modes[VAR_3][VAR_6])) {",
"randomize_buffers();",
"call_ref(src0, 48);",
"call_new(src1, 48);",
"if (memcmp(VAR_1, VAR_2, BUF_SIZE))\nfail();",
"bench_new(src1, 48);",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
]
|
13,922 | int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int size)
{
if (size < 0 || avpkt->size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Size %d invalid\n", size);
return AVERROR(EINVAL);
}
if (avctx) {
av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer);
if (!avpkt->data || avpkt->size < size) {
av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size);
avpkt->data = avctx->internal->byte_buffer;
avpkt->size = avctx->internal->byte_buffer_size;
avpkt->destruct = NULL;
}
}
if (avpkt->data) {
AVBufferRef *buf = avpkt->buf;
#if FF_API_DESTRUCT_PACKET
void *destruct = avpkt->destruct;
#endif
if (avpkt->size < size) {
av_log(avctx, AV_LOG_ERROR, "User packet is too small (%d < %d)\n", avpkt->size, size);
return AVERROR(EINVAL);
}
av_init_packet(avpkt);
#if FF_API_DESTRUCT_PACKET
avpkt->destruct = destruct;
#endif
avpkt->buf = buf;
avpkt->size = size;
return 0;
} else {
int ret = av_new_packet(avpkt, size);
if (ret < 0)
av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", size);
return ret;
}
}
| false | FFmpeg | 47c9887ecaa764006cf661a6446b3533472f6a6e | int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int size)
{
if (size < 0 || avpkt->size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Size %d invalid\n", size);
return AVERROR(EINVAL);
}
if (avctx) {
av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer);
if (!avpkt->data || avpkt->size < size) {
av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size);
avpkt->data = avctx->internal->byte_buffer;
avpkt->size = avctx->internal->byte_buffer_size;
avpkt->destruct = NULL;
}
}
if (avpkt->data) {
AVBufferRef *buf = avpkt->buf;
#if FF_API_DESTRUCT_PACKET
void *destruct = avpkt->destruct;
#endif
if (avpkt->size < size) {
av_log(avctx, AV_LOG_ERROR, "User packet is too small (%d < %d)\n", avpkt->size, size);
return AVERROR(EINVAL);
}
av_init_packet(avpkt);
#if FF_API_DESTRUCT_PACKET
avpkt->destruct = destruct;
#endif
avpkt->buf = buf;
avpkt->size = size;
return 0;
} else {
int ret = av_new_packet(avpkt, size);
if (ret < 0)
av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", size);
return ret;
}
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{
if (VAR_2 < 0 || VAR_1->VAR_2 < 0 || VAR_2 > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "Size %d invalid\n", VAR_2);
return AVERROR(EINVAL);
}
if (VAR_0) {
av_assert0(!VAR_1->data || VAR_1->data != VAR_0->internal->byte_buffer);
if (!VAR_1->data || VAR_1->VAR_2 < VAR_2) {
av_fast_padded_malloc(&VAR_0->internal->byte_buffer, &VAR_0->internal->byte_buffer_size, VAR_2);
VAR_1->data = VAR_0->internal->byte_buffer;
VAR_1->VAR_2 = VAR_0->internal->byte_buffer_size;
VAR_1->destruct = NULL;
}
}
if (VAR_1->data) {
AVBufferRef *buf = VAR_1->buf;
#if FF_API_DESTRUCT_PACKET
void *destruct = VAR_1->destruct;
#endif
if (VAR_1->VAR_2 < VAR_2) {
av_log(VAR_0, AV_LOG_ERROR, "User packet is too small (%d < %d)\n", VAR_1->VAR_2, VAR_2);
return AVERROR(EINVAL);
}
av_init_packet(VAR_1);
#if FF_API_DESTRUCT_PACKET
VAR_1->destruct = destruct;
#endif
VAR_1->buf = buf;
VAR_1->VAR_2 = VAR_2;
return 0;
} else {
int VAR_3 = av_new_packet(VAR_1, VAR_2);
if (VAR_3 < 0)
av_log(VAR_0, AV_LOG_ERROR, "Failed to allocate packet of VAR_2 %d\n", VAR_2);
return VAR_3;
}
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, int VAR_2)\n{",
"if (VAR_2 < 0 || VAR_1->VAR_2 < 0 || VAR_2 > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Size %d invalid\\n\", VAR_2);",
"return AVERROR(EINVAL);",
"}",
"if (VAR_0) {",
"av_assert0(!VAR_1->data || VAR_1->data != VAR_0->internal->byte_buffer);",
"if (!VAR_1->data || VAR_1->VAR_2 < VAR_2) {",
"av_fast_padded_malloc(&VAR_0->internal->byte_buffer, &VAR_0->internal->byte_buffer_size, VAR_2);",
"VAR_1->data = VAR_0->internal->byte_buffer;",
"VAR_1->VAR_2 = VAR_0->internal->byte_buffer_size;",
"VAR_1->destruct = NULL;",
"}",
"}",
"if (VAR_1->data) {",
"AVBufferRef *buf = VAR_1->buf;",
"#if FF_API_DESTRUCT_PACKET\nvoid *destruct = VAR_1->destruct;",
"#endif\nif (VAR_1->VAR_2 < VAR_2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"User packet is too small (%d < %d)\\n\", VAR_1->VAR_2, VAR_2);",
"return AVERROR(EINVAL);",
"}",
"av_init_packet(VAR_1);",
"#if FF_API_DESTRUCT_PACKET\nVAR_1->destruct = destruct;",
"#endif\nVAR_1->buf = buf;",
"VAR_1->VAR_2 = VAR_2;",
"return 0;",
"} else {",
"int VAR_3 = av_new_packet(VAR_1, VAR_2);",
"if (VAR_3 < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"Failed to allocate packet of VAR_2 %d\\n\", VAR_2);",
"return VAR_3;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
]
|
13,923 | static int sort_stt(FFV1Context *s, uint8_t stt[256])
{
int i, i2, changed, print = 0;
do {
changed = 0;
for (i = 12; i < 244; i++) {
for (i2 = i + 1; i2 < 245 && i2 < i + 4; i2++) {
#define COST(old, new) \
s->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \
s->rc_stat[old][1] * -log2((new) / 256.0)
#define COST2(old, new) \
COST(old, new) + COST(256 - (old), 256 - (new))
double size0 = COST2(i, i) + COST2(i2, i2);
double sizeX = COST2(i, i2) + COST2(i2, i);
if (sizeX < size0 && i != 128 && i2 != 128) {
int j;
FFSWAP(int, stt[i], stt[i2]);
FFSWAP(int, s->rc_stat[i][0], s->rc_stat[i2][0]);
FFSWAP(int, s->rc_stat[i][1], s->rc_stat[i2][1]);
if (i != 256 - i2) {
FFSWAP(int, stt[256 - i], stt[256 - i2]);
FFSWAP(int, s->rc_stat[256 - i][0], s->rc_stat[256 - i2][0]);
FFSWAP(int, s->rc_stat[256 - i][1], s->rc_stat[256 - i2][1]);
}
for (j = 1; j < 256; j++) {
if (stt[j] == i)
stt[j] = i2;
else if (stt[j] == i2)
stt[j] = i;
if (i != 256 - i2) {
if (stt[256 - j] == 256 - i)
stt[256 - j] = 256 - i2;
else if (stt[256 - j] == 256 - i2)
stt[256 - j] = 256 - i;
}
}
print = changed = 1;
}
}
}
} while (changed);
return print;
}
| false | FFmpeg | c2cbc80ae9e3f00e21235915a80f81a2aeb7db0a | static int sort_stt(FFV1Context *s, uint8_t stt[256])
{
int i, i2, changed, print = 0;
do {
changed = 0;
for (i = 12; i < 244; i++) {
for (i2 = i + 1; i2 < 245 && i2 < i + 4; i2++) {
#define COST(old, new) \
s->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \
s->rc_stat[old][1] * -log2((new) / 256.0)
#define COST2(old, new) \
COST(old, new) + COST(256 - (old), 256 - (new))
double size0 = COST2(i, i) + COST2(i2, i2);
double sizeX = COST2(i, i2) + COST2(i2, i);
if (sizeX < size0 && i != 128 && i2 != 128) {
int j;
FFSWAP(int, stt[i], stt[i2]);
FFSWAP(int, s->rc_stat[i][0], s->rc_stat[i2][0]);
FFSWAP(int, s->rc_stat[i][1], s->rc_stat[i2][1]);
if (i != 256 - i2) {
FFSWAP(int, stt[256 - i], stt[256 - i2]);
FFSWAP(int, s->rc_stat[256 - i][0], s->rc_stat[256 - i2][0]);
FFSWAP(int, s->rc_stat[256 - i][1], s->rc_stat[256 - i2][1]);
}
for (j = 1; j < 256; j++) {
if (stt[j] == i)
stt[j] = i2;
else if (stt[j] == i2)
stt[j] = i;
if (i != 256 - i2) {
if (stt[256 - j] == 256 - i)
stt[256 - j] = 256 - i2;
else if (stt[256 - j] == 256 - i2)
stt[256 - j] = 256 - i;
}
}
print = changed = 1;
}
}
}
} while (changed);
return print;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FFV1Context *VAR_0, uint8_t VAR_1[256])
{
int VAR_2, VAR_3, VAR_4, VAR_5 = 0;
do {
VAR_4 = 0;
for (VAR_2 = 12; VAR_2 < 244; VAR_2++) {
for (VAR_3 = VAR_2 + 1; VAR_3 < 245 && VAR_3 < VAR_2 + 4; VAR_3++) {
#define COST(old, new) \
VAR_0->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \
VAR_0->rc_stat[old][1] * -log2((new) / 256.0)
#define COST2(old, new) \
COST(old, new) + COST(256 - (old), 256 - (new))
double size0 = COST2(VAR_2, VAR_2) + COST2(VAR_3, VAR_3);
double VAR_6 = COST2(VAR_2, VAR_3) + COST2(VAR_3, VAR_2);
if (VAR_6 < size0 && VAR_2 != 128 && VAR_3 != 128) {
int VAR_7;
FFSWAP(int, VAR_1[VAR_2], VAR_1[VAR_3]);
FFSWAP(int, VAR_0->rc_stat[VAR_2][0], VAR_0->rc_stat[VAR_3][0]);
FFSWAP(int, VAR_0->rc_stat[VAR_2][1], VAR_0->rc_stat[VAR_3][1]);
if (VAR_2 != 256 - VAR_3) {
FFSWAP(int, VAR_1[256 - VAR_2], VAR_1[256 - VAR_3]);
FFSWAP(int, VAR_0->rc_stat[256 - VAR_2][0], VAR_0->rc_stat[256 - VAR_3][0]);
FFSWAP(int, VAR_0->rc_stat[256 - VAR_2][1], VAR_0->rc_stat[256 - VAR_3][1]);
}
for (VAR_7 = 1; VAR_7 < 256; VAR_7++) {
if (VAR_1[VAR_7] == VAR_2)
VAR_1[VAR_7] = VAR_3;
else if (VAR_1[VAR_7] == VAR_3)
VAR_1[VAR_7] = VAR_2;
if (VAR_2 != 256 - VAR_3) {
if (VAR_1[256 - VAR_7] == 256 - VAR_2)
VAR_1[256 - VAR_7] = 256 - VAR_3;
else if (VAR_1[256 - VAR_7] == 256 - VAR_3)
VAR_1[256 - VAR_7] = 256 - VAR_2;
}
}
VAR_5 = VAR_4 = 1;
}
}
}
} while (VAR_4);
return VAR_5;
}
| [
"static int FUNC_0(FFV1Context *VAR_0, uint8_t VAR_1[256])\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5 = 0;",
"do {",
"VAR_4 = 0;",
"for (VAR_2 = 12; VAR_2 < 244; VAR_2++) {",
"for (VAR_3 = VAR_2 + 1; VAR_3 < 245 && VAR_3 < VAR_2 + 4; VAR_3++) {",
"#define COST(old, new) \\\nVAR_0->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \\\nVAR_0->rc_stat[old][1] * -log2((new) / 256.0)\n#define COST2(old, new) \\\nCOST(old, new) + COST(256 - (old), 256 - (new))\ndouble size0 = COST2(VAR_2, VAR_2) + COST2(VAR_3, VAR_3);",
"double VAR_6 = COST2(VAR_2, VAR_3) + COST2(VAR_3, VAR_2);",
"if (VAR_6 < size0 && VAR_2 != 128 && VAR_3 != 128) {",
"int VAR_7;",
"FFSWAP(int, VAR_1[VAR_2], VAR_1[VAR_3]);",
"FFSWAP(int, VAR_0->rc_stat[VAR_2][0], VAR_0->rc_stat[VAR_3][0]);",
"FFSWAP(int, VAR_0->rc_stat[VAR_2][1], VAR_0->rc_stat[VAR_3][1]);",
"if (VAR_2 != 256 - VAR_3) {",
"FFSWAP(int, VAR_1[256 - VAR_2], VAR_1[256 - VAR_3]);",
"FFSWAP(int, VAR_0->rc_stat[256 - VAR_2][0], VAR_0->rc_stat[256 - VAR_3][0]);",
"FFSWAP(int, VAR_0->rc_stat[256 - VAR_2][1], VAR_0->rc_stat[256 - VAR_3][1]);",
"}",
"for (VAR_7 = 1; VAR_7 < 256; VAR_7++) {",
"if (VAR_1[VAR_7] == VAR_2)\nVAR_1[VAR_7] = VAR_3;",
"else if (VAR_1[VAR_7] == VAR_3)\nVAR_1[VAR_7] = VAR_2;",
"if (VAR_2 != 256 - VAR_3) {",
"if (VAR_1[256 - VAR_7] == 256 - VAR_2)\nVAR_1[256 - VAR_7] = 256 - VAR_3;",
"else if (VAR_1[256 - VAR_7] == 256 - VAR_3)\nVAR_1[256 - VAR_7] = 256 - VAR_2;",
"}",
"}",
"VAR_5 = VAR_4 = 1;",
"}",
"}",
"}",
"} while (VAR_4);",
"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
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
27,
29,
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
]
]
|
13,924 | static void dvbsub_parse_object_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *block;
int object_id;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int top_field_len, bottom_field_len;
int coding_method, non_modifying_color;
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object)
return;
coding_method = ((*buf) >> 2) & 3;
non_modifying_color = ((*buf++) >> 1) & 1;
if (coding_method == 0) {
top_field_len = AV_RB16(buf);
buf += 2;
bottom_field_len = AV_RB16(buf);
buf += 2;
if (buf + top_field_len + bottom_field_len > buf_end) {
av_log(avctx, AV_LOG_ERROR, "Field data size too large\n");
return;
}
for (display = object->display_list; display; display = display->object_list_next) {
block = buf;
dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0,
non_modifying_color);
if (bottom_field_len > 0)
block = buf + top_field_len;
else
bottom_field_len = top_field_len;
dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1,
non_modifying_color);
}
/* } else if (coding_method == 1) {*/
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", coding_method);
}
}
| false | FFmpeg | 607ad990d31e6be52980970e5ce8cd25ab3de812 | static void dvbsub_parse_object_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *block;
int object_id;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int top_field_len, bottom_field_len;
int coding_method, non_modifying_color;
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object)
return;
coding_method = ((*buf) >> 2) & 3;
non_modifying_color = ((*buf++) >> 1) & 1;
if (coding_method == 0) {
top_field_len = AV_RB16(buf);
buf += 2;
bottom_field_len = AV_RB16(buf);
buf += 2;
if (buf + top_field_len + bottom_field_len > buf_end) {
av_log(avctx, AV_LOG_ERROR, "Field data size too large\n");
return;
}
for (display = object->display_list; display; display = display->object_list_next) {
block = buf;
dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0,
non_modifying_color);
if (bottom_field_len > 0)
block = buf + top_field_len;
else
bottom_field_len = top_field_len;
dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1,
non_modifying_color);
}
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", coding_method);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
DVBSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_3 = VAR_1 + VAR_2;
const uint8_t *VAR_4;
int VAR_5;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int VAR_6, VAR_7;
int VAR_8, VAR_9;
VAR_5 = AV_RB16(VAR_1);
VAR_1 += 2;
object = get_object(ctx, VAR_5);
if (!object)
return;
VAR_8 = ((*VAR_1) >> 2) & 3;
VAR_9 = ((*VAR_1++) >> 1) & 1;
if (VAR_8 == 0) {
VAR_6 = AV_RB16(VAR_1);
VAR_1 += 2;
VAR_7 = AV_RB16(VAR_1);
VAR_1 += 2;
if (VAR_1 + VAR_6 + VAR_7 > VAR_3) {
av_log(VAR_0, AV_LOG_ERROR, "Field data size too large\n");
return;
}
for (display = object->display_list; display; display = display->object_list_next) {
VAR_4 = VAR_1;
dvbsub_parse_pixel_data_block(VAR_0, display, VAR_4, VAR_6, 0,
VAR_9);
if (VAR_7 > 0)
VAR_4 = VAR_1 + VAR_6;
else
VAR_7 = VAR_6;
dvbsub_parse_pixel_data_block(VAR_0, display, VAR_4, VAR_7, 1,
VAR_9);
}
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unknown object coding %d\n", VAR_8);
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_3 = VAR_1 + VAR_2;",
"const uint8_t *VAR_4;",
"int VAR_5;",
"DVBSubObject *object;",
"DVBSubObjectDisplay *display;",
"int VAR_6, VAR_7;",
"int VAR_8, VAR_9;",
"VAR_5 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"object = get_object(ctx, VAR_5);",
"if (!object)\nreturn;",
"VAR_8 = ((*VAR_1) >> 2) & 3;",
"VAR_9 = ((*VAR_1++) >> 1) & 1;",
"if (VAR_8 == 0) {",
"VAR_6 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"VAR_7 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"if (VAR_1 + VAR_6 + VAR_7 > VAR_3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Field data size too large\\n\");",
"return;",
"}",
"for (display = object->display_list; display; display = display->object_list_next) {",
"VAR_4 = VAR_1;",
"dvbsub_parse_pixel_data_block(VAR_0, display, VAR_4, VAR_6, 0,\nVAR_9);",
"if (VAR_7 > 0)\nVAR_4 = VAR_1 + VAR_6;",
"else\nVAR_7 = VAR_6;",
"dvbsub_parse_pixel_data_block(VAR_0, display, VAR_4, VAR_7, 1,\nVAR_9);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown object coding %d\\n\", VAR_8);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79,
81
],
[
85,
87
],
[
89,
91
],
[
95,
97
],
[
99
],
[
107
],
[
109
],
[
111
],
[
115
]
]
|
13,925 | static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
SVQ1EncContext *const s = avctx->priv_data;
AVFrame *const p = avctx->coded_frame;
int i, ret;
if (!pkt->data &&
(ret = av_new_packet(pkt, s->y_block_width * s->y_block_height *
MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
if (avctx->pix_fmt != AV_PIX_FMT_YUV410P) {
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if (!s->current_picture->data[0]) {
ret = ff_get_buffer(avctx, s->current_picture, 0);
if (ret < 0)
return ret;
}
if (!s->last_picture->data[0]) {
ret = ff_get_buffer(avctx, s->last_picture, 0);
if (ret < 0)
return ret;
}
if (!s->scratchbuf) {
s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);
if (!s->scratchbuf)
return AVERROR(ENOMEM);
}
FFSWAP(AVFrame*, s->current_picture, s->last_picture);
init_put_bits(&s->pb, pkt->data, pkt->size);
p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ?
AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
p->key_frame = p->pict_type == AV_PICTURE_TYPE_I;
p->quality = pict->quality;
svq1_write_header(s, p->pict_type);
for (i = 0; i < 3; i++)
if (svq1_encode_plane(s, i,
pict->data[i],
s->last_picture->data[i],
s->current_picture->data[i],
s->frame_width / (i ? 4 : 1),
s->frame_height / (i ? 4 : 1),
pict->linesize[i],
s->current_picture->linesize[i]) < 0)
return -1;
// avpriv_align_put_bits(&s->pb);
while (put_bits_count(&s->pb) & 31)
put_bits(&s->pb, 1, 0);
flush_put_bits(&s->pb);
pkt->size = put_bits_count(&s->pb) / 8;
if (p->pict_type == AV_PICTURE_TYPE_I)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| false | FFmpeg | 28fb80dcbf6f63eedfcfffc725a6bf0069d03fab | static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
SVQ1EncContext *const s = avctx->priv_data;
AVFrame *const p = avctx->coded_frame;
int i, ret;
if (!pkt->data &&
(ret = av_new_packet(pkt, s->y_block_width * s->y_block_height *
MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
if (avctx->pix_fmt != AV_PIX_FMT_YUV410P) {
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if (!s->current_picture->data[0]) {
ret = ff_get_buffer(avctx, s->current_picture, 0);
if (ret < 0)
return ret;
}
if (!s->last_picture->data[0]) {
ret = ff_get_buffer(avctx, s->last_picture, 0);
if (ret < 0)
return ret;
}
if (!s->scratchbuf) {
s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);
if (!s->scratchbuf)
return AVERROR(ENOMEM);
}
FFSWAP(AVFrame*, s->current_picture, s->last_picture);
init_put_bits(&s->pb, pkt->data, pkt->size);
p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ?
AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
p->key_frame = p->pict_type == AV_PICTURE_TYPE_I;
p->quality = pict->quality;
svq1_write_header(s, p->pict_type);
for (i = 0; i < 3; i++)
if (svq1_encode_plane(s, i,
pict->data[i],
s->last_picture->data[i],
s->current_picture->data[i],
s->frame_width / (i ? 4 : 1),
s->frame_height / (i ? 4 : 1),
pict->linesize[i],
s->current_picture->linesize[i]) < 0)
return -1;
while (put_bits_count(&s->pb) & 31)
put_bits(&s->pb, 1, 0);
flush_put_bits(&s->pb);
pkt->size = put_bits_count(&s->pb) / 8;
if (p->pict_type == AV_PICTURE_TYPE_I)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
SVQ1EncContext *const s = VAR_0->priv_data;
AVFrame *const p = VAR_0->coded_frame;
int VAR_4, VAR_5;
if (!VAR_1->data &&
(VAR_5 = av_new_packet(VAR_1, s->y_block_width * s->y_block_height *
MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n");
return VAR_5;
}
if (VAR_0->pix_fmt != AV_PIX_FMT_YUV410P) {
av_log(VAR_0, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if (!s->current_picture->data[0]) {
VAR_5 = ff_get_buffer(VAR_0, s->current_picture, 0);
if (VAR_5 < 0)
return VAR_5;
}
if (!s->last_picture->data[0]) {
VAR_5 = ff_get_buffer(VAR_0, s->last_picture, 0);
if (VAR_5 < 0)
return VAR_5;
}
if (!s->scratchbuf) {
s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);
if (!s->scratchbuf)
return AVERROR(ENOMEM);
}
FFSWAP(AVFrame*, s->current_picture, s->last_picture);
init_put_bits(&s->pb, VAR_1->data, VAR_1->size);
p->pict_type = VAR_0->gop_size && VAR_0->frame_number % VAR_0->gop_size ?
AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
p->key_frame = p->pict_type == AV_PICTURE_TYPE_I;
p->quality = VAR_2->quality;
svq1_write_header(s, p->pict_type);
for (VAR_4 = 0; VAR_4 < 3; VAR_4++)
if (svq1_encode_plane(s, VAR_4,
VAR_2->data[VAR_4],
s->last_picture->data[VAR_4],
s->current_picture->data[VAR_4],
s->frame_width / (VAR_4 ? 4 : 1),
s->frame_height / (VAR_4 ? 4 : 1),
VAR_2->linesize[VAR_4],
s->current_picture->linesize[VAR_4]) < 0)
return -1;
while (put_bits_count(&s->pb) & 31)
put_bits(&s->pb, 1, 0);
flush_put_bits(&s->pb);
VAR_1->size = put_bits_count(&s->pb) / 8;
if (p->pict_type == AV_PICTURE_TYPE_I)
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"SVQ1EncContext *const s = VAR_0->priv_data;",
"AVFrame *const p = VAR_0->coded_frame;",
"int VAR_4, VAR_5;",
"if (!VAR_1->data &&\n(VAR_5 = av_new_packet(VAR_1, s->y_block_width * s->y_block_height *\nMAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");",
"return VAR_5;",
"}",
"if (VAR_0->pix_fmt != AV_PIX_FMT_YUV410P) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unsupported pixel format\\n\");",
"return -1;",
"}",
"if (!s->current_picture->data[0]) {",
"VAR_5 = ff_get_buffer(VAR_0, s->current_picture, 0);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"if (!s->last_picture->data[0]) {",
"VAR_5 = ff_get_buffer(VAR_0, s->last_picture, 0);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"if (!s->scratchbuf) {",
"s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);",
"if (!s->scratchbuf)\nreturn AVERROR(ENOMEM);",
"}",
"FFSWAP(AVFrame*, s->current_picture, s->last_picture);",
"init_put_bits(&s->pb, VAR_1->data, VAR_1->size);",
"p->pict_type = VAR_0->gop_size && VAR_0->frame_number % VAR_0->gop_size ?\nAV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;",
"p->key_frame = p->pict_type == AV_PICTURE_TYPE_I;",
"p->quality = VAR_2->quality;",
"svq1_write_header(s, p->pict_type);",
"for (VAR_4 = 0; VAR_4 < 3; VAR_4++)",
"if (svq1_encode_plane(s, VAR_4,\nVAR_2->data[VAR_4],\ns->last_picture->data[VAR_4],\ns->current_picture->data[VAR_4],\ns->frame_width / (VAR_4 ? 4 : 1),\ns->frame_height / (VAR_4 ? 4 : 1),\nVAR_2->linesize[VAR_4],\ns->current_picture->linesize[VAR_4]) < 0)\nreturn -1;",
"while (put_bits_count(&s->pb) & 31)\nput_bits(&s->pb, 1, 0);",
"flush_put_bits(&s->pb);",
"VAR_1->size = put_bits_count(&s->pb) / 8;",
"if (p->pict_type == AV_PICTURE_TYPE_I)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
71
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95,
97,
99,
101,
103,
105,
107,
109
],
[
115,
117
],
[
121
],
[
125
],
[
127,
129
],
[
131
],
[
135
],
[
137
]
]
|
13,926 | static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1 //is faster only if multiplies are reasonable fast (FIXME figure out on which cpus this is faster, on Athlon its slightly faster)
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"addl $16, %1 \n\t"
"addl $8, %0 \n\t"
"cmpl %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *((uint32_t*)s)++;
*d++ = ((src&0xFF)>>3) + ((src&0xFC00)>>5) + ((src&0xF80000)>>8);
// *d++ = ((src>>3)&0x1F) + ((src>>5)&0x7E0) + ((src>>8)&0xF800);
}
}
| false | FFmpeg | ae4cffd9fc5bc495692920d646d7d1462315cfa6 | static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"addl $16, %1 \n\t"
"addl $8, %0 \n\t"
"cmpl %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *((uint32_t*)s)++;
*d++ = ((src&0xFF)>>3) + ((src&0xFC00)>>5) + ((src&0xF80000)>>8);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(rgb32to16)(const uint8_t *VAR_2, uint8_t *dst, unsigned src_size)
{
const uint8_t *VAR_0 = VAR_2;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
mm_end = VAR_1 - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"addl $16, %1 \n\t"
"addl $8, %0 \n\t"
"cmpl %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(VAR_0)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*VAR_2):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_16mask):"memory");
d += 4;
VAR_0 += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
const int VAR_2= *((uint32_t*)VAR_0)++;
*d++ = ((VAR_2&0xFF)>>3) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>8);
}
}
| [
"static inline void FUNC_0(rgb32to16)(const uint8_t *VAR_2, uint8_t *dst, unsigned src_size)\n{",
"const uint8_t *VAR_0 = VAR_2;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\nmm_end = VAR_1 - 15;",
"#if 1\nasm volatile(\n\"movq %3, %%mm5\t\t\t\\n\\t\"\n\"movq %4, %%mm6\t\t\t\\n\\t\"\n\"movq %5, %%mm7\t\t\t\\n\\t\"\n\".balign 16\t\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 32(%1)\t\t\\n\\t\"\n\"movd\t(%1), %%mm0\t\t\\n\\t\"\n\"movd\t4(%1), %%mm3\t\t\\n\\t\"\n\"punpckldq 8(%1), %%mm0\t\t\\n\\t\"\n\"punpckldq 12(%1), %%mm3\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm3, %%mm4\t\t\\n\\t\"\n\"pand %%mm6, %%mm0\t\t\\n\\t\"\n\"pand %%mm6, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm7, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm7, %%mm3\t\t\\n\\t\"\n\"pand %%mm5, %%mm1\t\t\\n\\t\"\n\"pand %%mm5, %%mm4\t\t\\n\\t\"\n\"por %%mm1, %%mm0\t\t\\n\\t\"\n\"por %%mm4, %%mm3\t\t\\n\\t\"\n\"psrld $5, %%mm0\t\t\\n\\t\"\n\"pslld $11, %%mm3\t\t\\n\\t\"\n\"por %%mm3, %%mm0\t\t\\n\\t\"\nMOVNTQ\"\t%%mm0, (%0)\t\t\\n\\t\"\n\"addl $16, %1\t\t\t\\n\\t\"\n\"addl $8, %0\t\t\t\\n\\t\"\n\"cmpl %2, %1\t\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n: \"+r\" (d), \"+r\"(VAR_0)\n: \"r\" (mm_end), \"m\" (mask3216g), \"m\" (mask3216br), \"m\" (mul3216)\n);",
"#else\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_2):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t4%1, %%mm3\\n\\t\"\n\"punpckldq 8%1, %%mm0\\n\\t\"\n\"punpckldq 12%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psrlq\t$3, %%mm0\\n\\t\"\n\"psrlq\t$3, %%mm3\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%2, %%mm3\\n\\t\"\n\"psrlq\t$5, %%mm1\\n\\t\"\n\"psrlq\t$5, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$8, %%mm2\\n\\t\"\n\"psrlq\t$8, %%mm5\\n\\t\"\n\"pand\t%%mm7, %%mm2\\n\\t\"\n\"pand\t%%mm7, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_16mask):\"memory\");",
"d += 4;",
"VAR_0 += 16;",
"}",
"#endif\n__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"const int VAR_2= *((uint32_t*)VAR_0)++;",
"*d++ = ((VAR_2&0xFF)>>3) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>8);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87
],
[
89,
91
],
[
93,
95,
97,
99
],
[
101,
103
],
[
105,
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179,
181
],
[
183
],
[
185
],
[
189
],
[
191
]
]
|
13,927 | static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
MDECContext * const a = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&a->picture;
int i;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= I_TYPE;
p->key_frame= 1;
a->last_dc[0]=
a->last_dc[1]=
a->last_dc[2]= 0;
a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
for(i=0; i<buf_size; i+=2){
a->bitstream_buffer[i] = buf[i+1];
a->bitstream_buffer[i+1]= buf[i ];
}
init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
/* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */
skip_bits(&a->gb, 32);
a->qscale= get_bits(&a->gb, 16);
a->version= get_bits(&a->gb, 16);
// printf("qscale:%d (0x%X), version:%d (0x%X)\n", a->qscale, a->qscale, a->version, a->version);
for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){
for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, a->mb_x, a->mb_y);
}
}
// p->quality= (32 + a->inv_qscale/2)/a->inv_qscale;
// memset(p->qscale_table, p->quality, p->qstride*a->mb_height);
*picture= *(AVFrame*)&a->picture;
*data_size = sizeof(AVPicture);
emms_c();
return (get_bits_count(&a->gb)+31)/32*4;
}
| false | FFmpeg | 934982c4ace1a3d5d627b518782ed092a456c49e | static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
MDECContext * const a = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&a->picture;
int i;
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= I_TYPE;
p->key_frame= 1;
a->last_dc[0]=
a->last_dc[1]=
a->last_dc[2]= 0;
a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
for(i=0; i<buf_size; i+=2){
a->bitstream_buffer[i] = buf[i+1];
a->bitstream_buffer[i+1]= buf[i ];
}
init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
skip_bits(&a->gb, 32);
a->qscale= get_bits(&a->gb, 16);
a->version= get_bits(&a->gb, 16);
for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){
for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, a->mb_x, a->mb_y);
}
}
*picture= *(AVFrame*)&a->picture;
*data_size = sizeof(AVPicture);
emms_c();
return (get_bits_count(&a->gb)+31)/32*4;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
MDECContext * const a = VAR_0->priv_data;
AVFrame *picture = VAR_1;
AVFrame * const p= (AVFrame*)&a->picture;
int VAR_5;
if (VAR_4 == 0) {
return 0;
}
if(p->VAR_1[0])
VAR_0->release_buffer(VAR_0, p);
p->reference= 0;
if(VAR_0->get_buffer(VAR_0, p) < 0){
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= I_TYPE;
p->key_frame= 1;
a->last_dc[0]=
a->last_dc[1]=
a->last_dc[2]= 0;
a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);
for(VAR_5=0; VAR_5<VAR_4; VAR_5+=2){
a->bitstream_buffer[VAR_5] = VAR_3[VAR_5+1];
a->bitstream_buffer[VAR_5+1]= VAR_3[VAR_5 ];
}
init_get_bits(&a->gb, a->bitstream_buffer, VAR_4*8);
skip_bits(&a->gb, 32);
a->qscale= get_bits(&a->gb, 16);
a->version= get_bits(&a->gb, 16);
for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){
for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, a->mb_x, a->mb_y);
}
}
*picture= *(AVFrame*)&a->picture;
*VAR_2 = sizeof(AVPicture);
emms_c();
return (get_bits_count(&a->gb)+31)/32*4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"MDECContext * const a = VAR_0->priv_data;",
"AVFrame *picture = VAR_1;",
"AVFrame * const p= (AVFrame*)&a->picture;",
"int VAR_5;",
"if (VAR_4 == 0) {",
"return 0;",
"}",
"if(p->VAR_1[0])\nVAR_0->release_buffer(VAR_0, p);",
"p->reference= 0;",
"if(VAR_0->get_buffer(VAR_0, p) < 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"p->pict_type= I_TYPE;",
"p->key_frame= 1;",
"a->last_dc[0]=\na->last_dc[1]=\na->last_dc[2]= 0;",
"a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);",
"for(VAR_5=0; VAR_5<VAR_4; VAR_5+=2){",
"a->bitstream_buffer[VAR_5] = VAR_3[VAR_5+1];",
"a->bitstream_buffer[VAR_5+1]= VAR_3[VAR_5 ];",
"}",
"init_get_bits(&a->gb, a->bitstream_buffer, VAR_4*8);",
"skip_bits(&a->gb, 32);",
"a->qscale= get_bits(&a->gb, 16);",
"a->version= get_bits(&a->gb, 16);",
"for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){",
"for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){",
"if( decode_mb(a, a->block) <0)\nreturn -1;",
"idct_put(a, a->mb_x, a->mb_y);",
"}",
"}",
"*picture= *(AVFrame*)&a->picture;",
"*VAR_2 = sizeof(AVPicture);",
"emms_c();",
"return (get_bits_count(&a->gb)+31)/32*4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
77
],
[
79
],
[
87
],
[
89
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123
]
]
|
13,928 | void OPPROTO op_srli_T0 (void)
{
T0 = T0 >> PARAM1;
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void OPPROTO op_srli_T0 (void)
{
T0 = T0 >> PARAM1;
RETURN();
}
| {
"code": [
" RETURN();",
" T0 = T0 >> PARAM1;",
" RETURN();"
],
"line_no": [
7,
5,
7
]
} | void VAR_0 op_srli_T0 (void)
{
T0 = T0 >> PARAM1;
RETURN();
}
| [
"void VAR_0 op_srli_T0 (void)\n{",
"T0 = T0 >> PARAM1;",
"RETURN();",
"}"
]
| [
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
13,929 | static void bdrv_qed_invalidate_cache(BlockDriverState *bs)
{
BDRVQEDState *s = bs->opaque;
bdrv_qed_close(bs);
memset(s, 0, sizeof(BDRVQEDState));
bdrv_qed_open(bs, NULL, bs->open_flags, NULL);
} | true | qemu | 3456a8d1852e970688b73d03fdc44dde851759e1 | static void bdrv_qed_invalidate_cache(BlockDriverState *bs)
{
BDRVQEDState *s = bs->opaque;
bdrv_qed_close(bs);
memset(s, 0, sizeof(BDRVQEDState));
bdrv_qed_open(bs, NULL, bs->open_flags, NULL);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
BDRVQEDState *s = VAR_0->opaque;
bdrv_qed_close(VAR_0);
memset(s, 0, sizeof(BDRVQEDState));
bdrv_qed_open(VAR_0, NULL, VAR_0->open_flags, NULL);
} | [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQEDState *s = VAR_0->opaque;",
"bdrv_qed_close(VAR_0);",
"memset(s, 0, sizeof(BDRVQEDState));",
"bdrv_qed_open(VAR_0, NULL, VAR_0->open_flags, NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
]
]
|
13,930 | void syscall_init(void)
{
IOCTLEntry *ie;
const argtype *arg_type;
int size;
int i;
#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
#include "syscall_types.h"
#undef STRUCT
#undef STRUCT_SPECIAL
/* Build target_to_host_errno_table[] table from
* host_to_target_errno_table[]. */
for (i = 0; i < ERRNO_TABLE_SIZE; i++) {
target_to_host_errno_table[host_to_target_errno_table[i]] = i;
}
/* we patch the ioctl size if necessary. We rely on the fact that
no ioctl has all the bits at '1' in the size field */
ie = ioctl_entries;
while (ie->target_cmd != 0) {
if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==
TARGET_IOC_SIZEMASK) {
arg_type = ie->arg_type;
if (arg_type[0] != TYPE_PTR) {
fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
ie->target_cmd);
exit(1);
}
arg_type++;
size = thunk_type_size(arg_type, 0);
ie->target_cmd = (ie->target_cmd &
~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
(size << TARGET_IOC_SIZESHIFT);
}
/* automatic consistency check if same arch */
#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
(defined(__x86_64__) && defined(TARGET_X86_64))
if (unlikely(ie->target_cmd != ie->host_cmd)) {
fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
ie->name, ie->target_cmd, ie->host_cmd);
}
#endif
ie++;
}
} | true | qemu | 8be656b87c6bb1b9f8af3ff78094413d71e4443a | void syscall_init(void)
{
IOCTLEntry *ie;
const argtype *arg_type;
int size;
int i;
#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
#include "syscall_types.h"
#undef STRUCT
#undef STRUCT_SPECIAL
for (i = 0; i < ERRNO_TABLE_SIZE; i++) {
target_to_host_errno_table[host_to_target_errno_table[i]] = i;
}
ie = ioctl_entries;
while (ie->target_cmd != 0) {
if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==
TARGET_IOC_SIZEMASK) {
arg_type = ie->arg_type;
if (arg_type[0] != TYPE_PTR) {
fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
ie->target_cmd);
exit(1);
}
arg_type++;
size = thunk_type_size(arg_type, 0);
ie->target_cmd = (ie->target_cmd &
~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
(size << TARGET_IOC_SIZESHIFT);
}
#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
(defined(__x86_64__) && defined(TARGET_X86_64))
if (unlikely(ie->target_cmd != ie->host_cmd)) {
fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
ie->name, ie->target_cmd, ie->host_cmd);
}
#endif
ie++;
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
IOCTLEntry *ie;
const argtype *VAR_0;
int VAR_1;
int VAR_2;
#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
#include "syscall_types.h"
#undef STRUCT
#undef STRUCT_SPECIAL
for (VAR_2 = 0; VAR_2 < ERRNO_TABLE_SIZE; VAR_2++) {
target_to_host_errno_table[host_to_target_errno_table[VAR_2]] = VAR_2;
}
ie = ioctl_entries;
while (ie->target_cmd != 0) {
if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==
TARGET_IOC_SIZEMASK) {
VAR_0 = ie->VAR_0;
if (VAR_0[0] != TYPE_PTR) {
fprintf(stderr, "cannot patch VAR_1 for ioctl 0x%x\n",
ie->target_cmd);
exit(1);
}
VAR_0++;
VAR_1 = thunk_type_size(VAR_0, 0);
ie->target_cmd = (ie->target_cmd &
~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
(VAR_1 << TARGET_IOC_SIZESHIFT);
}
#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
(defined(__x86_64__) && defined(TARGET_X86_64))
if (unlikely(ie->target_cmd != ie->host_cmd)) {
fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
ie->name, ie->target_cmd, ie->host_cmd);
}
#endif
ie++;
}
} | [
"void FUNC_0(void)\n{",
"IOCTLEntry *ie;",
"const argtype *VAR_0;",
"int VAR_1;",
"int VAR_2;",
"#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);",
"#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);",
"#include \"syscall_types.h\"\n#undef STRUCT\n#undef STRUCT_SPECIAL\nfor (VAR_2 = 0; VAR_2 < ERRNO_TABLE_SIZE; VAR_2++) {",
"target_to_host_errno_table[host_to_target_errno_table[VAR_2]] = VAR_2;",
"}",
"ie = ioctl_entries;",
"while (ie->target_cmd != 0) {",
"if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==\nTARGET_IOC_SIZEMASK) {",
"VAR_0 = ie->VAR_0;",
"if (VAR_0[0] != TYPE_PTR) {",
"fprintf(stderr, \"cannot patch VAR_1 for ioctl 0x%x\\n\",\nie->target_cmd);",
"exit(1);",
"}",
"VAR_0++;",
"VAR_1 = thunk_type_size(VAR_0, 0);",
"ie->target_cmd = (ie->target_cmd &\n~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |\n(VAR_1 << TARGET_IOC_SIZESHIFT);",
"}",
"#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \\\n(defined(__x86_64__) && defined(TARGET_X86_64))\nif (unlikely(ie->target_cmd != ie->host_cmd)) {",
"fprintf(stderr, \"ERROR: ioctl(%s): target=0x%x host=0x%x\\n\",\nie->name, ie->target_cmd, ie->host_cmd);",
"}",
"#endif\nie++;",
"}",
"}"
]
| [
0,
0,
0,
0,
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,
14
],
[
15
],
[
16
],
[
19
],
[
20
],
[
21,
22
],
[
23
],
[
24
],
[
25,
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31,
32,
33
],
[
34
],
[
36,
37,
38
],
[
39,
40
],
[
41
],
[
42,
43
],
[
44
],
[
45
]
]
|
13,931 | static void null_end_frame(AVFilterLink *inlink) { }
| true | FFmpeg | 06bf6d3bc04979bd39ecdc7311d0daf8aee7e10f | static void null_end_frame(AVFilterLink *inlink) { }
| {
"code": [
"static void null_end_frame(AVFilterLink *inlink) { }"
],
"line_no": [
1
]
} | static void FUNC_0(AVFilterLink *VAR_0) { }
| [
"static void FUNC_0(AVFilterLink *VAR_0) { }"
]
| [
1
]
| [
[
1
]
]
|
13,932 | void qemu_init_vcpu(void *_env)
{
CPUState *env = _env;
int r;
env->nr_cores = smp_cores;
env->nr_threads = smp_threads;
if (kvm_enabled()) {
r = kvm_init_vcpu(env);
if (r < 0) {
fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
exit(1);
}
qemu_kvm_init_cpu_signals(env);
} else {
qemu_tcg_init_cpu_signals();
}
}
| true | qemu | 12d4536f7d911b6d87a766ad7300482ea663cea2 | void qemu_init_vcpu(void *_env)
{
CPUState *env = _env;
int r;
env->nr_cores = smp_cores;
env->nr_threads = smp_threads;
if (kvm_enabled()) {
r = kvm_init_vcpu(env);
if (r < 0) {
fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
exit(1);
}
qemu_kvm_init_cpu_signals(env);
} else {
qemu_tcg_init_cpu_signals();
}
}
| {
"code": [
" if (kvm_enabled()) {",
"void qemu_init_vcpu(void *_env)",
" CPUState *env = _env;",
" int r;",
" env->nr_cores = smp_cores;",
" env->nr_threads = smp_threads;",
" if (kvm_enabled()) {",
" r = kvm_init_vcpu(env);",
" if (r < 0) {",
" fprintf(stderr, \"kvm_init_vcpu failed: %s\\n\", strerror(-r));",
" exit(1);",
" qemu_kvm_init_cpu_signals(env);",
" } else {",
" qemu_tcg_init_cpu_signals();",
" } else {"
],
"line_no": [
17,
1,
5,
7,
11,
13,
17,
19,
21,
23,
25,
29,
31,
33,
31
]
} | void FUNC_0(void *VAR_0)
{
CPUState *env = VAR_0;
int VAR_1;
env->nr_cores = smp_cores;
env->nr_threads = smp_threads;
if (kvm_enabled()) {
VAR_1 = kvm_init_vcpu(env);
if (VAR_1 < 0) {
fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-VAR_1));
exit(1);
}
qemu_kvm_init_cpu_signals(env);
} else {
qemu_tcg_init_cpu_signals();
}
}
| [
"void FUNC_0(void *VAR_0)\n{",
"CPUState *env = VAR_0;",
"int VAR_1;",
"env->nr_cores = smp_cores;",
"env->nr_threads = smp_threads;",
"if (kvm_enabled()) {",
"VAR_1 = kvm_init_vcpu(env);",
"if (VAR_1 < 0) {",
"fprintf(stderr, \"kvm_init_vcpu failed: %s\\n\", strerror(-VAR_1));",
"exit(1);",
"}",
"qemu_kvm_init_cpu_signals(env);",
"} else {",
"qemu_tcg_init_cpu_signals();",
"}",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
]
|
13,933 | static void migrate_finish_set_state(MigrationState *s, int new_state)
{
if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) {
trace_migrate_set_state(new_state);
}
}
| true | qemu | d58f574bf39796ed2396dfd1e308352fbb03f944 | static void migrate_finish_set_state(MigrationState *s, int new_state)
{
if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) {
trace_migrate_set_state(new_state);
}
}
| {
"code": [
"static void migrate_finish_set_state(MigrationState *s, int new_state)",
" if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) {"
],
"line_no": [
1,
5
]
} | static void FUNC_0(MigrationState *VAR_0, int VAR_1)
{
if (atomic_cmpxchg(&VAR_0->state, MIG_STATE_ACTIVE, VAR_1) == VAR_1) {
trace_migrate_set_state(VAR_1);
}
}
| [
"static void FUNC_0(MigrationState *VAR_0, int VAR_1)\n{",
"if (atomic_cmpxchg(&VAR_0->state, MIG_STATE_ACTIVE, VAR_1) == VAR_1) {",
"trace_migrate_set_state(VAR_1);",
"}",
"}"
]
| [
1,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
13,934 | static void ohci_reset(OHCIState *ohci)
{
OHCIPort *port;
int i;
ohci->ctl = 0;
ohci->old_ctl = 0;
ohci->status = 0;
ohci->intr_status = 0;
ohci->intr = OHCI_INTR_MIE;
ohci->hcca = 0;
ohci->ctrl_head = ohci->ctrl_cur = 0;
ohci->bulk_head = ohci->bulk_cur = 0;
ohci->per_cur = 0;
ohci->done = 0;
ohci->done_count = 7;
/* FSMPS is marked TBD in OCHI 1.0, what gives ffs?
* I took the value linux sets ...
*/
ohci->fsmps = 0x2778;
ohci->fi = 0x2edf;
ohci->fit = 0;
ohci->frt = 0;
ohci->frame_number = 0;
ohci->pstart = 0;
ohci->lst = OHCI_LS_THRESH;
ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports;
ohci->rhdesc_b = 0x0; /* Impl. specific */
ohci->rhstatus = 0;
for (i = 0; i < ohci->num_ports; i++)
{
port = &ohci->rhport[i];
port->ctrl = 0;
if (port->port.dev)
ohci_attach(&port->port, port->port.dev);
}
if (ohci->async_td) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
dprintf("usb-ohci: Reset %s\n", ohci->name);
}
| true | qemu | 73221b12ea55ae916b550e56d70743221ca3c886 | static void ohci_reset(OHCIState *ohci)
{
OHCIPort *port;
int i;
ohci->ctl = 0;
ohci->old_ctl = 0;
ohci->status = 0;
ohci->intr_status = 0;
ohci->intr = OHCI_INTR_MIE;
ohci->hcca = 0;
ohci->ctrl_head = ohci->ctrl_cur = 0;
ohci->bulk_head = ohci->bulk_cur = 0;
ohci->per_cur = 0;
ohci->done = 0;
ohci->done_count = 7;
ohci->fsmps = 0x2778;
ohci->fi = 0x2edf;
ohci->fit = 0;
ohci->frt = 0;
ohci->frame_number = 0;
ohci->pstart = 0;
ohci->lst = OHCI_LS_THRESH;
ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports;
ohci->rhdesc_b = 0x0;
ohci->rhstatus = 0;
for (i = 0; i < ohci->num_ports; i++)
{
port = &ohci->rhport[i];
port->ctrl = 0;
if (port->port.dev)
ohci_attach(&port->port, port->port.dev);
}
if (ohci->async_td) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
dprintf("usb-ohci: Reset %s\n", ohci->name);
}
| {
"code": [
"static void ohci_reset(OHCIState *ohci)"
],
"line_no": [
1
]
} | static void FUNC_0(OHCIState *VAR_0)
{
OHCIPort *port;
int VAR_1;
VAR_0->ctl = 0;
VAR_0->old_ctl = 0;
VAR_0->status = 0;
VAR_0->intr_status = 0;
VAR_0->intr = OHCI_INTR_MIE;
VAR_0->hcca = 0;
VAR_0->ctrl_head = VAR_0->ctrl_cur = 0;
VAR_0->bulk_head = VAR_0->bulk_cur = 0;
VAR_0->per_cur = 0;
VAR_0->done = 0;
VAR_0->done_count = 7;
VAR_0->fsmps = 0x2778;
VAR_0->fi = 0x2edf;
VAR_0->fit = 0;
VAR_0->frt = 0;
VAR_0->frame_number = 0;
VAR_0->pstart = 0;
VAR_0->lst = OHCI_LS_THRESH;
VAR_0->rhdesc_a = OHCI_RHA_NPS | VAR_0->num_ports;
VAR_0->rhdesc_b = 0x0;
VAR_0->rhstatus = 0;
for (VAR_1 = 0; VAR_1 < VAR_0->num_ports; VAR_1++)
{
port = &VAR_0->rhport[VAR_1];
port->ctrl = 0;
if (port->port.dev)
ohci_attach(&port->port, port->port.dev);
}
if (VAR_0->async_td) {
usb_cancel_packet(&VAR_0->usb_packet);
VAR_0->async_td = 0;
}
dprintf("usb-VAR_0: Reset %s\n", VAR_0->name);
}
| [
"static void FUNC_0(OHCIState *VAR_0)\n{",
"OHCIPort *port;",
"int VAR_1;",
"VAR_0->ctl = 0;",
"VAR_0->old_ctl = 0;",
"VAR_0->status = 0;",
"VAR_0->intr_status = 0;",
"VAR_0->intr = OHCI_INTR_MIE;",
"VAR_0->hcca = 0;",
"VAR_0->ctrl_head = VAR_0->ctrl_cur = 0;",
"VAR_0->bulk_head = VAR_0->bulk_cur = 0;",
"VAR_0->per_cur = 0;",
"VAR_0->done = 0;",
"VAR_0->done_count = 7;",
"VAR_0->fsmps = 0x2778;",
"VAR_0->fi = 0x2edf;",
"VAR_0->fit = 0;",
"VAR_0->frt = 0;",
"VAR_0->frame_number = 0;",
"VAR_0->pstart = 0;",
"VAR_0->lst = OHCI_LS_THRESH;",
"VAR_0->rhdesc_a = OHCI_RHA_NPS | VAR_0->num_ports;",
"VAR_0->rhdesc_b = 0x0;",
"VAR_0->rhstatus = 0;",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_ports; VAR_1++)",
"{",
"port = &VAR_0->rhport[VAR_1];",
"port->ctrl = 0;",
"if (port->port.dev)\nohci_attach(&port->port, port->port.dev);",
"}",
"if (VAR_0->async_td) {",
"usb_cancel_packet(&VAR_0->usb_packet);",
"VAR_0->async_td = 0;",
"}",
"dprintf(\"usb-VAR_0: Reset %s\\n\", VAR_0->name);",
"}"
]
| [
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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
]
|
13,935 | static int qxl_init_primary(PCIDevice *dev)
{
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
int rc;
qxl->id = 0;
qxl_init_ramsize(qxl);
vga->vram_size_mb = qxl->vga.vram_size >> 20;
vga_common_init(vga, OBJECT(dev), true);
vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list,
vga, "vga");
portio_list_set_flush_coalesced(qxl_vga_port_list);
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
qemu_spice_display_init_common(&qxl->ssd);
rc = qxl_init_common(qxl);
if (rc != 0) {
return rc;
}
qxl->ssd.dcl.ops = &display_listener_ops;
qxl->ssd.dcl.con = vga->con;
register_displaychangelistener(&qxl->ssd.dcl);
return rc;
}
| true | qemu | 848696bf353750899832c51005f1bd3540da5c29 | static int qxl_init_primary(PCIDevice *dev)
{
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
int rc;
qxl->id = 0;
qxl_init_ramsize(qxl);
vga->vram_size_mb = qxl->vga.vram_size >> 20;
vga_common_init(vga, OBJECT(dev), true);
vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list,
vga, "vga");
portio_list_set_flush_coalesced(qxl_vga_port_list);
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
qemu_spice_display_init_common(&qxl->ssd);
rc = qxl_init_common(qxl);
if (rc != 0) {
return rc;
}
qxl->ssd.dcl.ops = &display_listener_ops;
qxl->ssd.dcl.con = vga->con;
register_displaychangelistener(&qxl->ssd.dcl);
return rc;
}
| {
"code": [
" PortioList *qxl_vga_port_list = g_new(PortioList, 1);",
" portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list,",
" portio_list_set_flush_coalesced(qxl_vga_port_list);",
" portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);"
],
"line_no": [
9,
27,
31,
33
]
} | static int FUNC_0(PCIDevice *VAR_0)
{
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, VAR_0);
VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
int VAR_1;
qxl->id = 0;
qxl_init_ramsize(qxl);
vga->vram_size_mb = qxl->vga.vram_size >> 20;
vga_common_init(vga, OBJECT(VAR_0), true);
vga_init(vga, OBJECT(VAR_0),
pci_address_space(VAR_0), pci_address_space_io(VAR_0), false);
portio_list_init(qxl_vga_port_list, OBJECT(VAR_0), qxl_vga_portio_list,
vga, "vga");
portio_list_set_flush_coalesced(qxl_vga_port_list);
portio_list_add(qxl_vga_port_list, pci_address_space_io(VAR_0), 0x3b0);
vga->con = graphic_console_init(DEVICE(VAR_0), 0, &qxl_ops, qxl);
qemu_spice_display_init_common(&qxl->ssd);
VAR_1 = qxl_init_common(qxl);
if (VAR_1 != 0) {
return VAR_1;
}
qxl->ssd.dcl.ops = &display_listener_ops;
qxl->ssd.dcl.con = vga->con;
register_displaychangelistener(&qxl->ssd.dcl);
return VAR_1;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, VAR_0);",
"VGACommonState *vga = &qxl->vga;",
"PortioList *qxl_vga_port_list = g_new(PortioList, 1);",
"int VAR_1;",
"qxl->id = 0;",
"qxl_init_ramsize(qxl);",
"vga->vram_size_mb = qxl->vga.vram_size >> 20;",
"vga_common_init(vga, OBJECT(VAR_0), true);",
"vga_init(vga, OBJECT(VAR_0),\npci_address_space(VAR_0), pci_address_space_io(VAR_0), false);",
"portio_list_init(qxl_vga_port_list, OBJECT(VAR_0), qxl_vga_portio_list,\nvga, \"vga\");",
"portio_list_set_flush_coalesced(qxl_vga_port_list);",
"portio_list_add(qxl_vga_port_list, pci_address_space_io(VAR_0), 0x3b0);",
"vga->con = graphic_console_init(DEVICE(VAR_0), 0, &qxl_ops, qxl);",
"qemu_spice_display_init_common(&qxl->ssd);",
"VAR_1 = qxl_init_common(qxl);",
"if (VAR_1 != 0) {",
"return VAR_1;",
"}",
"qxl->ssd.dcl.ops = &display_listener_ops;",
"qxl->ssd.dcl.con = vga->con;",
"register_displaychangelistener(&qxl->ssd.dcl);",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
]
|
13,936 | static void nbd_trip(void *opaque)
{
NBDClient *client = opaque;
NBDExport *exp = client->exp;
NBDRequest *req;
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
uint32_t command;
TRACE("Reading request.");
if (client->closing) {
return;
}
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &request);
if (ret == -EAGAIN) {
goto done;
}
if (ret == -EIO) {
goto out;
}
reply.handle = request.handle;
reply.error = 0;
if (ret < 0) {
reply.error = -ret;
goto error_reply;
}
command = request.type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_DISC && (request.from + request.len) > exp->size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len,
(uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?");
goto invalid_request;
}
if (client->closing) {
/*
* The client may be closed when we are blocked in
* nbd_co_receive_request()
*/
goto done;
}
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
ret = blk_read(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
goto error_reply;
}
TRACE("Read %u byte(s)", request.len);
if (nbd_co_send_reply(req, &reply, request.len) < 0)
goto out;
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = EROFS;
goto error_reply;
}
TRACE("Writing to device");
ret = blk_write(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
goto error_reply;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
goto out;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset)
/ BDRV_SECTOR_SIZE,
request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
default:
LOG("invalid request type (%u) received", request.type);
invalid_request:
reply.error = EINVAL;
error_reply:
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
}
TRACE("Request/Reply complete");
done:
nbd_request_put(req);
return;
out:
nbd_request_put(req);
client_close(client);
}
| true | qemu | df7b97ff89319ccf392a16748081482a3d22b35a | static void nbd_trip(void *opaque)
{
NBDClient *client = opaque;
NBDExport *exp = client->exp;
NBDRequest *req;
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
uint32_t command;
TRACE("Reading request.");
if (client->closing) {
return;
}
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &request);
if (ret == -EAGAIN) {
goto done;
}
if (ret == -EIO) {
goto out;
}
reply.handle = request.handle;
reply.error = 0;
if (ret < 0) {
reply.error = -ret;
goto error_reply;
}
command = request.type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_DISC && (request.from + request.len) > exp->size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len,
(uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?");
goto invalid_request;
}
if (client->closing) {
goto done;
}
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
ret = blk_read(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
goto error_reply;
}
TRACE("Read %u byte(s)", request.len);
if (nbd_co_send_reply(req, &reply, request.len) < 0)
goto out;
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = EROFS;
goto error_reply;
}
TRACE("Writing to device");
ret = blk_write(exp->blk,
(request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
goto error_reply;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
goto out;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset)
/ BDRV_SECTOR_SIZE,
request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
default:
LOG("invalid request type (%u) received", request.type);
invalid_request:
reply.error = EINVAL;
error_reply:
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
}
TRACE("Request/Reply complete");
done:
nbd_request_put(req);
return;
out:
nbd_request_put(req);
client_close(client);
}
| {
"code": [
" ret = blk_read(exp->blk,",
" (request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,",
" req->data, request.len / BDRV_SECTOR_SIZE);",
" ret = blk_write(exp->blk,",
" (request.from + exp->dev_offset) / BDRV_SECTOR_SIZE,",
" req->data, request.len / BDRV_SECTOR_SIZE);"
],
"line_no": [
125,
127,
129,
173,
175,
177
]
} | static void FUNC_0(void *VAR_0)
{
NBDClient *client = VAR_0;
NBDExport *exp = client->exp;
NBDRequest *req;
struct nbd_request VAR_1;
struct nbd_reply VAR_2;
ssize_t ret;
uint32_t command;
TRACE("Reading VAR_1.");
if (client->closing) {
return;
}
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &VAR_1);
if (ret == -EAGAIN) {
goto done;
}
if (ret == -EIO) {
goto out;
}
VAR_2.handle = VAR_1.handle;
VAR_2.error = 0;
if (ret < 0) {
VAR_2.error = -ret;
goto error_reply;
}
command = VAR_1.type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_DISC && (VAR_1.from + VAR_1.len) > exp->size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
VAR_1.from, VAR_1.len,
(uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?");
goto invalid_request;
}
if (client->closing) {
goto done;
}
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
if (VAR_1.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
VAR_2.error = -ret;
goto error_reply;
}
}
ret = blk_read(exp->blk,
(VAR_1.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, VAR_1.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("reading from file failed");
VAR_2.error = -ret;
goto error_reply;
}
TRACE("Read %u byte(s)", VAR_1.len);
if (nbd_co_send_reply(req, &VAR_2, VAR_1.len) < 0)
goto out;
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
VAR_2.error = EROFS;
goto error_reply;
}
TRACE("Writing to device");
ret = blk_write(exp->blk,
(VAR_1.from + exp->dev_offset) / BDRV_SECTOR_SIZE,
req->data, VAR_1.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("writing to file failed");
VAR_2.error = -ret;
goto error_reply;
}
if (VAR_1.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
VAR_2.error = -ret;
goto error_reply;
}
}
if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {
goto out;
}
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
goto out;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
VAR_2.error = -ret;
}
if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {
goto out;
}
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = blk_co_discard(exp->blk, (VAR_1.from + exp->dev_offset)
/ BDRV_SECTOR_SIZE,
VAR_1.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("discard failed");
VAR_2.error = -ret;
}
if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {
goto out;
}
break;
default:
LOG("invalid VAR_1 type (%u) received", VAR_1.type);
invalid_request:
VAR_2.error = EINVAL;
error_reply:
if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {
goto out;
}
break;
}
TRACE("Request/Reply complete");
done:
nbd_request_put(req);
return;
out:
nbd_request_put(req);
client_close(client);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"NBDClient *client = VAR_0;",
"NBDExport *exp = client->exp;",
"NBDRequest *req;",
"struct nbd_request VAR_1;",
"struct nbd_reply VAR_2;",
"ssize_t ret;",
"uint32_t command;",
"TRACE(\"Reading VAR_1.\");",
"if (client->closing) {",
"return;",
"}",
"req = nbd_request_get(client);",
"ret = nbd_co_receive_request(req, &VAR_1);",
"if (ret == -EAGAIN) {",
"goto done;",
"}",
"if (ret == -EIO) {",
"goto out;",
"}",
"VAR_2.handle = VAR_1.handle;",
"VAR_2.error = 0;",
"if (ret < 0) {",
"VAR_2.error = -ret;",
"goto error_reply;",
"}",
"command = VAR_1.type & NBD_CMD_MASK_COMMAND;",
"if (command != NBD_CMD_DISC && (VAR_1.from + VAR_1.len) > exp->size) {",
"LOG(\"From: %\" PRIu64 \", Len: %u, Size: %\" PRIu64\n\", Offset: %\" PRIu64 \"\\n\",\nVAR_1.from, VAR_1.len,\n(uint64_t)exp->size, (uint64_t)exp->dev_offset);",
"LOG(\"requested operation past EOF--bad client?\");",
"goto invalid_request;",
"}",
"if (client->closing) {",
"goto done;",
"}",
"switch (command) {",
"case NBD_CMD_READ:\nTRACE(\"Request type is READ\");",
"if (VAR_1.type & NBD_CMD_FLAG_FUA) {",
"ret = blk_co_flush(exp->blk);",
"if (ret < 0) {",
"LOG(\"flush failed\");",
"VAR_2.error = -ret;",
"goto error_reply;",
"}",
"}",
"ret = blk_read(exp->blk,\n(VAR_1.from + exp->dev_offset) / BDRV_SECTOR_SIZE,\nreq->data, VAR_1.len / BDRV_SECTOR_SIZE);",
"if (ret < 0) {",
"LOG(\"reading from file failed\");",
"VAR_2.error = -ret;",
"goto error_reply;",
"}",
"TRACE(\"Read %u byte(s)\", VAR_1.len);",
"if (nbd_co_send_reply(req, &VAR_2, VAR_1.len) < 0)\ngoto out;",
"break;",
"case NBD_CMD_WRITE:\nTRACE(\"Request type is WRITE\");",
"if (exp->nbdflags & NBD_FLAG_READ_ONLY) {",
"TRACE(\"Server is read-only, return error\");",
"VAR_2.error = EROFS;",
"goto error_reply;",
"}",
"TRACE(\"Writing to device\");",
"ret = blk_write(exp->blk,\n(VAR_1.from + exp->dev_offset) / BDRV_SECTOR_SIZE,\nreq->data, VAR_1.len / BDRV_SECTOR_SIZE);",
"if (ret < 0) {",
"LOG(\"writing to file failed\");",
"VAR_2.error = -ret;",
"goto error_reply;",
"}",
"if (VAR_1.type & NBD_CMD_FLAG_FUA) {",
"ret = blk_co_flush(exp->blk);",
"if (ret < 0) {",
"LOG(\"flush failed\");",
"VAR_2.error = -ret;",
"goto error_reply;",
"}",
"}",
"if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {",
"goto out;",
"}",
"break;",
"case NBD_CMD_DISC:\nTRACE(\"Request type is DISCONNECT\");",
"errno = 0;",
"goto out;",
"case NBD_CMD_FLUSH:\nTRACE(\"Request type is FLUSH\");",
"ret = blk_co_flush(exp->blk);",
"if (ret < 0) {",
"LOG(\"flush failed\");",
"VAR_2.error = -ret;",
"}",
"if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {",
"goto out;",
"}",
"break;",
"case NBD_CMD_TRIM:\nTRACE(\"Request type is TRIM\");",
"ret = blk_co_discard(exp->blk, (VAR_1.from + exp->dev_offset)\n/ BDRV_SECTOR_SIZE,\nVAR_1.len / BDRV_SECTOR_SIZE);",
"if (ret < 0) {",
"LOG(\"discard failed\");",
"VAR_2.error = -ret;",
"}",
"if (nbd_co_send_reply(req, &VAR_2, 0) < 0) {",
"goto out;",
"}",
"break;",
"default:\nLOG(\"invalid VAR_1 type (%u) received\", VAR_1.type);",
"invalid_request:\nVAR_2.error = EINVAL;",
"error_reply:\nif (nbd_co_send_reply(req, &VAR_2, 0) < 0) {",
"goto out;",
"}",
"break;",
"}",
"TRACE(\"Request/Reply complete\");",
"done:\nnbd_request_put(req);",
"return;",
"out:\nnbd_request_put(req);",
"client_close(client);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69,
71,
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145,
147
],
[
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
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
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275,
277
],
[
279,
281
],
[
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
301,
303
],
[
305
],
[
309,
311
],
[
313
],
[
315
]
]
|
13,937 | bool memory_region_is_unassigned(MemoryRegion *mr)
{
return mr != &io_mem_ram && mr != &io_mem_rom
&& mr != &io_mem_notdirty && !mr->rom_device
&& mr != &io_mem_watch;
}
| true | qemu | 2a8e7499093cd33a607ebd7c1cd591169aa68a3e | bool memory_region_is_unassigned(MemoryRegion *mr)
{
return mr != &io_mem_ram && mr != &io_mem_rom
&& mr != &io_mem_notdirty && !mr->rom_device
&& mr != &io_mem_watch;
}
| {
"code": [
" return mr != &io_mem_ram && mr != &io_mem_rom",
" && mr != &io_mem_notdirty && !mr->rom_device"
],
"line_no": [
5,
7
]
} | bool FUNC_0(MemoryRegion *mr)
{
return mr != &io_mem_ram && mr != &io_mem_rom
&& mr != &io_mem_notdirty && !mr->rom_device
&& mr != &io_mem_watch;
}
| [
"bool FUNC_0(MemoryRegion *mr)\n{",
"return mr != &io_mem_ram && mr != &io_mem_rom\n&& mr != &io_mem_notdirty && !mr->rom_device\n&& mr != &io_mem_watch;",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5,
7,
9
],
[
11
]
]
|
13,939 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUState *env)
{
fprintf(stderr, "setup_rt_frame: not implemented\n");
}
| true | qemu | 0b1bcb00fb2baf5f3227dd9cd849fa69bf50d7a8 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUState *env)
{
fprintf(stderr, "setup_rt_frame: not implemented\n");
}
| {
"code": [
" fprintf(stderr, \"setup_rt_frame: not implemented\\n\");"
],
"line_no": [
9
]
} | static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_siginfo_t *VAR_2,
target_sigset_t *VAR_3, CPUState *VAR_4)
{
fprintf(stderr, "FUNC_0: not implemented\n");
}
| [
"static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_siginfo_t *VAR_2,\ntarget_sigset_t *VAR_3, CPUState *VAR_4)\n{",
"fprintf(stderr, \"FUNC_0: not implemented\\n\");",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
]
]
|
13,940 | static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx)
{
unsigned int head;
/* Grab the next descriptor number they're advertising, and increment
* the index we've seen. */
head = vring_avail_ring(vq, idx % vq->vring.num);
/* If their number is silly, that's a fatal mistake. */
if (head >= vq->vring.num) {
error_report("Guest says index %u is available", head);
exit(1);
}
return head;
}
| true | qemu | fb1131b674e492a5f91abd77b9fcc9a9e2b88eb7 | static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx)
{
unsigned int head;
head = vring_avail_ring(vq, idx % vq->vring.num);
if (head >= vq->vring.num) {
error_report("Guest says index %u is available", head);
exit(1);
}
return head;
}
| {
"code": [
"static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx)",
" unsigned int head;",
" head = vring_avail_ring(vq, idx % vq->vring.num);",
" if (head >= vq->vring.num) {",
" error_report(\"Guest says index %u is available\", head);",
" exit(1);",
" return head;"
],
"line_no": [
1,
5,
13,
19,
21,
23,
29
]
} | static unsigned int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1)
{
unsigned int VAR_2;
VAR_2 = vring_avail_ring(VAR_0, VAR_1 % VAR_0->vring.num);
if (VAR_2 >= VAR_0->vring.num) {
error_report("Guest says index %u is available", VAR_2);
exit(1);
}
return VAR_2;
}
| [
"static unsigned int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1)\n{",
"unsigned int VAR_2;",
"VAR_2 = vring_avail_ring(VAR_0, VAR_1 % VAR_0->vring.num);",
"if (VAR_2 >= VAR_0->vring.num) {",
"error_report(\"Guest says index %u is available\", VAR_2);",
"exit(1);",
"}",
"return VAR_2;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
]
|
13,941 | int kvm_has_sync_mmu(void)
{
#ifdef KVM_CAP_SYNC_MMU
KVMState *s = kvm_state;
return kvm_check_extension(s, KVM_CAP_SYNC_MMU);
#else
return 0;
#endif
}
| true | qemu | 94a8d39afd8ccfdbf578af04c3385fdb5f545af1 | int kvm_has_sync_mmu(void)
{
#ifdef KVM_CAP_SYNC_MMU
KVMState *s = kvm_state;
return kvm_check_extension(s, KVM_CAP_SYNC_MMU);
#else
return 0;
#endif
}
| {
"code": [
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#ifdef KVM_CAP_SYNC_MMU",
" KVMState *s = kvm_state;",
" return kvm_check_extension(s, KVM_CAP_SYNC_MMU);",
"#else",
" return 0;",
"#endif",
"#else",
"#endif",
"#endif",
"#endif",
"#endif"
],
"line_no": [
17,
17,
17,
17,
17,
17,
17,
17,
17,
5,
7,
11,
13,
15,
17,
13,
17,
17,
17,
17
]
} | int FUNC_0(void)
{
#ifdef KVM_CAP_SYNC_MMU
KVMState *s = kvm_state;
return kvm_check_extension(s, KVM_CAP_SYNC_MMU);
#else
return 0;
#endif
}
| [
"int FUNC_0(void)\n{",
"#ifdef KVM_CAP_SYNC_MMU\nKVMState *s = kvm_state;",
"return kvm_check_extension(s, KVM_CAP_SYNC_MMU);",
"#else\nreturn 0;",
"#endif\n}"
]
| [
0,
1,
1,
1,
1
]
| [
[
1,
3
],
[
5,
7
],
[
11
],
[
13,
15
],
[
17,
19
]
]
|
13,942 | static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_wmv2_idct_c(block);
add_pixels_clamped_c(block, dest, line_size);
}
| true | FFmpeg | e6bc38fd49c94726b45d5d5cc2b756ad8ec49ee0 | static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_wmv2_idct_c(block);
add_pixels_clamped_c(block, dest, line_size);
}
| {
"code": [
" ff_wmv2_idct_c(block);",
"static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)",
" ff_wmv2_idct_c(block);",
" add_pixels_clamped_c(block, dest, line_size);"
],
"line_no": [
5,
1,
5,
7
]
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)
{
ff_wmv2_idct_c(VAR_2);
add_pixels_clamped_c(VAR_2, VAR_0, VAR_1);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)\n{",
"ff_wmv2_idct_c(VAR_2);",
"add_pixels_clamped_c(VAR_2, VAR_0, VAR_1);",
"}"
]
| [
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
13,944 | static void vc1_decode_b_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
/* select codingmode used for VLC tables selection */
switch(v->c_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
s->first_slice_line = 1;
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
vc1_decode_b_mb(v);
if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
return;
}
if(v->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
| false | FFmpeg | 2d08f9ea54a347eb0282c227bae359d1a9c3d4bb | static void vc1_decode_b_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
switch(v->c_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
s->first_slice_line = 1;
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
vc1_decode_b_mb(v);
if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
return;
}
if(v->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VC1Context *VAR_0)
{
MpegEncContext *s = &VAR_0->s;
switch(VAR_0->c_ac_table_index){
case 0:
VAR_0->codingset = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
VAR_0->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
VAR_0->codingset = CS_MID_RATE_INTRA;
break;
}
switch(VAR_0->c_ac_table_index){
case 0:
VAR_0->codingset2 = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
VAR_0->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
VAR_0->codingset2 = CS_MID_RATE_INTER;
break;
}
s->first_slice_line = 1;
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
vc1_decode_b_mb(VAR_0);
if(get_bits_count(&s->gb) > VAR_0->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), VAR_0->bits,s->mb_x,s->mb_y);
return;
}
if(VAR_0->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
| [
"static void FUNC_0(VC1Context *VAR_0)\n{",
"MpegEncContext *s = &VAR_0->s;",
"switch(VAR_0->c_ac_table_index){",
"case 0:\nVAR_0->codingset = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;",
"break;",
"case 1:\nVAR_0->codingset = CS_HIGH_MOT_INTRA;",
"break;",
"case 2:\nVAR_0->codingset = CS_MID_RATE_INTRA;",
"break;",
"}",
"switch(VAR_0->c_ac_table_index){",
"case 0:\nVAR_0->codingset2 = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;",
"break;",
"case 1:\nVAR_0->codingset2 = CS_HIGH_MOT_INTER;",
"break;",
"case 2:\nVAR_0->codingset2 = CS_MID_RATE_INTER;",
"break;",
"}",
"s->first_slice_line = 1;",
"for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {",
"for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {",
"ff_init_block_index(s);",
"ff_update_block_index(s);",
"s->dsp.clear_blocks(s->block[0]);",
"vc1_decode_b_mb(VAR_0);",
"if(get_bits_count(&s->gb) > VAR_0->bits || get_bits_count(&s->gb) < 0) {",
"ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));",
"av_log(s->avctx, AV_LOG_ERROR, \"Bits overconsumption: %i > %i at %ix%i\\n\", get_bits_count(&s->gb), VAR_0->bits,s->mb_x,s->mb_y);",
"return;",
"}",
"if(VAR_0->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);",
"}",
"ff_draw_horiz_band(s, s->mb_y * 16, 16);",
"s->first_slice_line = 0;",
"}",
"ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
]
]
|
13,945 | static float ppp_pvq_search_c(float *X, int *y, int K, int N)
{
int i, y_norm = 0;
float res = 0.0f, xy_norm = 0.0f;
for (i = 0; i < N; i++)
res += FFABS(X[i]);
res = K/(res + FLT_EPSILON);
for (i = 0; i < N; i++) {
y[i] = lrintf(res*X[i]);
y_norm += y[i]*y[i];
xy_norm += y[i]*X[i];
K -= FFABS(y[i]);
}
while (K) {
int max_idx = 0, max_den = 1, phase = FFSIGN(K);
float max_num = 0.0f;
y_norm += 1.0f;
for (i = 0; i < N; i++) {
/* If the sum has been overshot and the best place has 0 pulses allocated
* to it, attempting to decrease it further will actually increase the
* sum. Prevent this by disregarding any 0 positions when decrementing. */
const int ca = 1 ^ ((y[i] == 0) & (phase < 0));
const int y_new = y_norm + 2*phase*FFABS(y[i]);
float xy_new = xy_norm + 1*phase*FFABS(X[i]);
xy_new = xy_new * xy_new;
if (ca && (max_den*xy_new) > (y_new*max_num)) {
max_den = y_new;
max_num = xy_new;
max_idx = i;
}
}
K -= phase;
phase *= FFSIGN(X[max_idx]);
xy_norm += 1*phase*X[max_idx];
y_norm += 2*phase*y[max_idx];
y[max_idx] += phase;
}
return (float)y_norm;
}
| false | FFmpeg | 05dfa21d47f35f394938653abcab8b3baa3bc999 | static float ppp_pvq_search_c(float *X, int *y, int K, int N)
{
int i, y_norm = 0;
float res = 0.0f, xy_norm = 0.0f;
for (i = 0; i < N; i++)
res += FFABS(X[i]);
res = K/(res + FLT_EPSILON);
for (i = 0; i < N; i++) {
y[i] = lrintf(res*X[i]);
y_norm += y[i]*y[i];
xy_norm += y[i]*X[i];
K -= FFABS(y[i]);
}
while (K) {
int max_idx = 0, max_den = 1, phase = FFSIGN(K);
float max_num = 0.0f;
y_norm += 1.0f;
for (i = 0; i < N; i++) {
const int ca = 1 ^ ((y[i] == 0) & (phase < 0));
const int y_new = y_norm + 2*phase*FFABS(y[i]);
float xy_new = xy_norm + 1*phase*FFABS(X[i]);
xy_new = xy_new * xy_new;
if (ca && (max_den*xy_new) > (y_new*max_num)) {
max_den = y_new;
max_num = xy_new;
max_idx = i;
}
}
K -= phase;
phase *= FFSIGN(X[max_idx]);
xy_norm += 1*phase*X[max_idx];
y_norm += 2*phase*y[max_idx];
y[max_idx] += phase;
}
return (float)y_norm;
}
| {
"code": [],
"line_no": []
} | static float FUNC_0(float *VAR_0, int *VAR_1, int VAR_2, int VAR_3)
{
int VAR_4, VAR_5 = 0;
float VAR_6 = 0.0f, VAR_7 = 0.0f;
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)
VAR_6 += FFABS(VAR_0[VAR_4]);
VAR_6 = VAR_2/(VAR_6 + FLT_EPSILON);
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {
VAR_1[VAR_4] = lrintf(VAR_6*VAR_0[VAR_4]);
VAR_5 += VAR_1[VAR_4]*VAR_1[VAR_4];
VAR_7 += VAR_1[VAR_4]*VAR_0[VAR_4];
VAR_2 -= FFABS(VAR_1[VAR_4]);
}
while (VAR_2) {
int VAR_8 = 0, VAR_9 = 1, VAR_10 = FFSIGN(VAR_2);
float VAR_11 = 0.0f;
VAR_5 += 1.0f;
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {
const int VAR_12 = 1 ^ ((VAR_1[VAR_4] == 0) & (VAR_10 < 0));
const int VAR_13 = VAR_5 + 2*VAR_10*FFABS(VAR_1[VAR_4]);
float VAR_14 = VAR_7 + 1*VAR_10*FFABS(VAR_0[VAR_4]);
VAR_14 = VAR_14 * VAR_14;
if (VAR_12 && (VAR_9*VAR_14) > (VAR_13*VAR_11)) {
VAR_9 = VAR_13;
VAR_11 = VAR_14;
VAR_8 = VAR_4;
}
}
VAR_2 -= VAR_10;
VAR_10 *= FFSIGN(VAR_0[VAR_8]);
VAR_7 += 1*VAR_10*VAR_0[VAR_8];
VAR_5 += 2*VAR_10*VAR_1[VAR_8];
VAR_1[VAR_8] += VAR_10;
}
return (float)VAR_5;
}
| [
"static float FUNC_0(float *VAR_0, int *VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5 = 0;",
"float VAR_6 = 0.0f, VAR_7 = 0.0f;",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)",
"VAR_6 += FFABS(VAR_0[VAR_4]);",
"VAR_6 = VAR_2/(VAR_6 + FLT_EPSILON);",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {",
"VAR_1[VAR_4] = lrintf(VAR_6*VAR_0[VAR_4]);",
"VAR_5 += VAR_1[VAR_4]*VAR_1[VAR_4];",
"VAR_7 += VAR_1[VAR_4]*VAR_0[VAR_4];",
"VAR_2 -= FFABS(VAR_1[VAR_4]);",
"}",
"while (VAR_2) {",
"int VAR_8 = 0, VAR_9 = 1, VAR_10 = FFSIGN(VAR_2);",
"float VAR_11 = 0.0f;",
"VAR_5 += 1.0f;",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {",
"const int VAR_12 = 1 ^ ((VAR_1[VAR_4] == 0) & (VAR_10 < 0));",
"const int VAR_13 = VAR_5 + 2*VAR_10*FFABS(VAR_1[VAR_4]);",
"float VAR_14 = VAR_7 + 1*VAR_10*FFABS(VAR_0[VAR_4]);",
"VAR_14 = VAR_14 * VAR_14;",
"if (VAR_12 && (VAR_9*VAR_14) > (VAR_13*VAR_11)) {",
"VAR_9 = VAR_13;",
"VAR_11 = VAR_14;",
"VAR_8 = VAR_4;",
"}",
"}",
"VAR_2 -= VAR_10;",
"VAR_10 *= FFSIGN(VAR_0[VAR_8]);",
"VAR_7 += 1*VAR_10*VAR_0[VAR_8];",
"VAR_5 += 2*VAR_10*VAR_1[VAR_8];",
"VAR_1[VAR_8] += VAR_10;",
"}",
"return (float)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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
]
|
13,946 | uint32_t do_arm_semihosting(CPUARMState *env)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
target_ulong args;
target_ulong arg0, arg1, arg2, arg3;
char * s;
int nr;
uint32_t ret;
uint32_t len;
#ifdef CONFIG_USER_ONLY
TaskState *ts = cs->opaque;
#else
CPUARMState *ts = env;
#endif
nr = env->regs[0];
args = env->regs[1];
switch (nr) {
case TARGET_SYS_OPEN:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
if (arg1 >= 12) {
unlock_user(s, arg0, 0);
return (uint32_t)-1;
}
if (strcmp(s, ":tt") == 0) {
int result_fileno = arg1 < 4 ? STDIN_FILENO : STDOUT_FILENO;
unlock_user(s, arg0, 0);
return result_fileno;
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", arg0,
(int)arg2+1, gdb_open_modeflags[arg1]);
ret = env->regs[0];
} else {
ret = set_swi_errno(ts, open(s, open_modeflags[arg1], 0644));
}
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_CLOSE:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "close,%x", arg0);
return env->regs[0];
} else {
return set_swi_errno(ts, close(arg0));
}
case TARGET_SYS_WRITEC:
{
char c;
if (get_user_u8(c, args))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
/* Write to debug console. stderr is near enough. */
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,1", args);
return env->regs[0];
} else {
return write(STDERR_FILENO, &c, 1);
}
}
case TARGET_SYS_WRITE0:
if (!(s = lock_user_string(args)))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
len = strlen(s);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,%x\n", args, len);
ret = env->regs[0];
} else {
ret = write(STDERR_FILENO, s, len);
}
unlock_user(s, args, 0);
return ret;
case TARGET_SYS_WRITE:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "write,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
s = lock_user(VERIFY_READ, arg1, len, 1);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, write(arg0, s, len));
unlock_user(s, arg1, 0);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READ:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "read,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
s = lock_user(VERIFY_WRITE, arg1, len, 0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
do {
ret = set_swi_errno(ts, read(arg0, s, len));
} while (ret == -1 && errno == EINTR);
unlock_user(s, arg1, len);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READC:
/* XXX: Read from debug console. Not implemented. */
return 0;
case TARGET_SYS_ISTTY:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "isatty,%x", arg0);
return env->regs[0];
} else {
return isatty(arg0);
}
case TARGET_SYS_SEEK:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "lseek,%x,%x,0", arg0, arg1);
return env->regs[0];
} else {
ret = set_swi_errno(ts, lseek(arg0, arg1, SEEK_SET));
if (ret == (uint32_t)-1)
return -1;
return 0;
}
case TARGET_SYS_FLEN:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x",
arg0, env->regs[13]-64);
return env->regs[0];
} else {
struct stat buf;
ret = set_swi_errno(ts, fstat(arg0, &buf));
if (ret == (uint32_t)-1)
return -1;
return buf.st_size;
}
case TARGET_SYS_TMPNAM:
/* XXX: Not implemented. */
return -1;
case TARGET_SYS_REMOVE:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "unlink,%s", arg0, (int)arg1+1);
ret = env->regs[0];
} else {
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, remove(s));
unlock_user(s, arg0, 0);
}
return ret;
case TARGET_SYS_RENAME:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
GET_ARG(3);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "rename,%s,%s",
arg0, (int)arg1+1, arg2, (int)arg3+1);
return env->regs[0];
} else {
char *s2;
s = lock_user_string(arg0);
s2 = lock_user_string(arg2);
if (!s || !s2)
/* FIXME - should this error code be -TARGET_EFAULT ? */
ret = (uint32_t)-1;
else
ret = set_swi_errno(ts, rename(s, s2));
if (s2)
unlock_user(s2, arg2, 0);
if (s)
unlock_user(s, arg0, 0);
return ret;
}
case TARGET_SYS_CLOCK:
return clock() / (CLOCKS_PER_SEC / 100);
case TARGET_SYS_TIME:
return set_swi_errno(ts, time(NULL));
case TARGET_SYS_SYSTEM:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "system,%s", arg0, (int)arg1+1);
return env->regs[0];
} else {
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, system(s));
unlock_user(s, arg0, 0);
return ret;
}
case TARGET_SYS_ERRNO:
#ifdef CONFIG_USER_ONLY
return ts->swi_errno;
#else
return syscall_err;
#endif
case TARGET_SYS_GET_CMDLINE:
{
/* Build a command-line from the original argv.
*
* The inputs are:
* * arg0, pointer to a buffer of at least the size
* specified in arg1.
* * arg1, size of the buffer pointed to by arg0 in
* bytes.
*
* The outputs are:
* * arg0, pointer to null-terminated string of the
* command line.
* * arg1, length of the string pointed to by arg0.
*/
char *output_buffer;
size_t input_size;
size_t output_size;
int status = 0;
GET_ARG(0);
GET_ARG(1);
input_size = arg1;
/* Compute the size of the output string. */
#if !defined(CONFIG_USER_ONLY)
output_size = strlen(ts->boot_info->kernel_filename)
+ 1 /* Separating space. */
+ strlen(ts->boot_info->kernel_cmdline)
+ 1; /* Terminating null byte. */
#else
unsigned int i;
output_size = ts->info->arg_end - ts->info->arg_start;
if (!output_size) {
/* We special-case the "empty command line" case (argc==0).
Just provide the terminating 0. */
output_size = 1;
}
#endif
if (output_size > input_size) {
/* Not enough space to store command-line arguments. */
return -1;
}
/* Adjust the command-line length. */
if (SET_ARG(1, output_size - 1)) {
/* Couldn't write back to argument block */
return -1;
}
/* Lock the buffer on the ARM side. */
output_buffer = lock_user(VERIFY_WRITE, arg0, output_size, 0);
if (!output_buffer) {
return -1;
}
/* Copy the command-line arguments. */
#if !defined(CONFIG_USER_ONLY)
pstrcpy(output_buffer, output_size, ts->boot_info->kernel_filename);
pstrcat(output_buffer, output_size, " ");
pstrcat(output_buffer, output_size, ts->boot_info->kernel_cmdline);
#else
if (output_size == 1) {
/* Empty command-line. */
output_buffer[0] = '\0';
goto out;
}
if (copy_from_user(output_buffer, ts->info->arg_start,
output_size)) {
status = -1;
goto out;
}
/* Separate arguments by white spaces. */
for (i = 0; i < output_size - 1; i++) {
if (output_buffer[i] == 0) {
output_buffer[i] = ' ';
}
}
out:
#endif
/* Unlock the buffer on the ARM side. */
unlock_user(output_buffer, arg0, output_size);
return status;
}
case TARGET_SYS_HEAPINFO:
{
uint32_t *ptr;
uint32_t limit;
GET_ARG(0);
#ifdef CONFIG_USER_ONLY
/* Some C libraries assume the heap immediately follows .bss, so
allocate it using sbrk. */
if (!ts->heap_limit) {
abi_ulong ret;
ts->heap_base = do_brk(0);
limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE;
/* Try a big heap, and reduce the size if that fails. */
for (;;) {
ret = do_brk(limit);
if (ret >= limit) {
break;
}
limit = (ts->heap_base >> 1) + (limit >> 1);
}
ts->heap_limit = limit;
}
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ptr[0] = tswap32(ts->heap_base);
ptr[1] = tswap32(ts->heap_limit);
ptr[2] = tswap32(ts->stack_base);
ptr[3] = tswap32(0); /* Stack limit. */
unlock_user(ptr, arg0, 16);
#else
limit = ram_size;
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
/* TODO: Make this use the limit of the loaded application. */
ptr[0] = tswap32(limit / 2);
ptr[1] = tswap32(limit);
ptr[2] = tswap32(limit); /* Stack base */
ptr[3] = tswap32(0); /* Stack limit. */
unlock_user(ptr, arg0, 16);
#endif
return 0;
}
case TARGET_SYS_EXIT:
gdb_exit(env, 0);
exit(0);
default:
fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
}
| false | qemu | 1ecc3a2df168034b8ab33ff5ba6434ce3593dbb5 | uint32_t do_arm_semihosting(CPUARMState *env)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
target_ulong args;
target_ulong arg0, arg1, arg2, arg3;
char * s;
int nr;
uint32_t ret;
uint32_t len;
#ifdef CONFIG_USER_ONLY
TaskState *ts = cs->opaque;
#else
CPUARMState *ts = env;
#endif
nr = env->regs[0];
args = env->regs[1];
switch (nr) {
case TARGET_SYS_OPEN:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
s = lock_user_string(arg0);
if (!s) {
return (uint32_t)-1;
}
if (arg1 >= 12) {
unlock_user(s, arg0, 0);
return (uint32_t)-1;
}
if (strcmp(s, ":tt") == 0) {
int result_fileno = arg1 < 4 ? STDIN_FILENO : STDOUT_FILENO;
unlock_user(s, arg0, 0);
return result_fileno;
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", arg0,
(int)arg2+1, gdb_open_modeflags[arg1]);
ret = env->regs[0];
} else {
ret = set_swi_errno(ts, open(s, open_modeflags[arg1], 0644));
}
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_CLOSE:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "close,%x", arg0);
return env->regs[0];
} else {
return set_swi_errno(ts, close(arg0));
}
case TARGET_SYS_WRITEC:
{
char c;
if (get_user_u8(c, args))
return (uint32_t)-1;
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,1", args);
return env->regs[0];
} else {
return write(STDERR_FILENO, &c, 1);
}
}
case TARGET_SYS_WRITE0:
if (!(s = lock_user_string(args)))
return (uint32_t)-1;
len = strlen(s);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,%x\n", args, len);
ret = env->regs[0];
} else {
ret = write(STDERR_FILENO, s, len);
}
unlock_user(s, args, 0);
return ret;
case TARGET_SYS_WRITE:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "write,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
s = lock_user(VERIFY_READ, arg1, len, 1);
if (!s) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, write(arg0, s, len));
unlock_user(s, arg1, 0);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READ:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "read,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
s = lock_user(VERIFY_WRITE, arg1, len, 0);
if (!s) {
return (uint32_t)-1;
}
do {
ret = set_swi_errno(ts, read(arg0, s, len));
} while (ret == -1 && errno == EINTR);
unlock_user(s, arg1, len);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READC:
return 0;
case TARGET_SYS_ISTTY:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "isatty,%x", arg0);
return env->regs[0];
} else {
return isatty(arg0);
}
case TARGET_SYS_SEEK:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "lseek,%x,%x,0", arg0, arg1);
return env->regs[0];
} else {
ret = set_swi_errno(ts, lseek(arg0, arg1, SEEK_SET));
if (ret == (uint32_t)-1)
return -1;
return 0;
}
case TARGET_SYS_FLEN:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x",
arg0, env->regs[13]-64);
return env->regs[0];
} else {
struct stat buf;
ret = set_swi_errno(ts, fstat(arg0, &buf));
if (ret == (uint32_t)-1)
return -1;
return buf.st_size;
}
case TARGET_SYS_TMPNAM:
return -1;
case TARGET_SYS_REMOVE:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "unlink,%s", arg0, (int)arg1+1);
ret = env->regs[0];
} else {
s = lock_user_string(arg0);
if (!s) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, remove(s));
unlock_user(s, arg0, 0);
}
return ret;
case TARGET_SYS_RENAME:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
GET_ARG(3);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "rename,%s,%s",
arg0, (int)arg1+1, arg2, (int)arg3+1);
return env->regs[0];
} else {
char *s2;
s = lock_user_string(arg0);
s2 = lock_user_string(arg2);
if (!s || !s2)
ret = (uint32_t)-1;
else
ret = set_swi_errno(ts, rename(s, s2));
if (s2)
unlock_user(s2, arg2, 0);
if (s)
unlock_user(s, arg0, 0);
return ret;
}
case TARGET_SYS_CLOCK:
return clock() / (CLOCKS_PER_SEC / 100);
case TARGET_SYS_TIME:
return set_swi_errno(ts, time(NULL));
case TARGET_SYS_SYSTEM:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "system,%s", arg0, (int)arg1+1);
return env->regs[0];
} else {
s = lock_user_string(arg0);
if (!s) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, system(s));
unlock_user(s, arg0, 0);
return ret;
}
case TARGET_SYS_ERRNO:
#ifdef CONFIG_USER_ONLY
return ts->swi_errno;
#else
return syscall_err;
#endif
case TARGET_SYS_GET_CMDLINE:
{
char *output_buffer;
size_t input_size;
size_t output_size;
int status = 0;
GET_ARG(0);
GET_ARG(1);
input_size = arg1;
#if !defined(CONFIG_USER_ONLY)
output_size = strlen(ts->boot_info->kernel_filename)
+ 1
+ strlen(ts->boot_info->kernel_cmdline)
+ 1;
#else
unsigned int i;
output_size = ts->info->arg_end - ts->info->arg_start;
if (!output_size) {
output_size = 1;
}
#endif
if (output_size > input_size) {
return -1;
}
if (SET_ARG(1, output_size - 1)) {
return -1;
}
output_buffer = lock_user(VERIFY_WRITE, arg0, output_size, 0);
if (!output_buffer) {
return -1;
}
#if !defined(CONFIG_USER_ONLY)
pstrcpy(output_buffer, output_size, ts->boot_info->kernel_filename);
pstrcat(output_buffer, output_size, " ");
pstrcat(output_buffer, output_size, ts->boot_info->kernel_cmdline);
#else
if (output_size == 1) {
output_buffer[0] = '\0';
goto out;
}
if (copy_from_user(output_buffer, ts->info->arg_start,
output_size)) {
status = -1;
goto out;
}
for (i = 0; i < output_size - 1; i++) {
if (output_buffer[i] == 0) {
output_buffer[i] = ' ';
}
}
out:
#endif
unlock_user(output_buffer, arg0, output_size);
return status;
}
case TARGET_SYS_HEAPINFO:
{
uint32_t *ptr;
uint32_t limit;
GET_ARG(0);
#ifdef CONFIG_USER_ONLY
if (!ts->heap_limit) {
abi_ulong ret;
ts->heap_base = do_brk(0);
limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE;
for (;;) {
ret = do_brk(limit);
if (ret >= limit) {
break;
}
limit = (ts->heap_base >> 1) + (limit >> 1);
}
ts->heap_limit = limit;
}
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
return (uint32_t)-1;
}
ptr[0] = tswap32(ts->heap_base);
ptr[1] = tswap32(ts->heap_limit);
ptr[2] = tswap32(ts->stack_base);
ptr[3] = tswap32(0);
unlock_user(ptr, arg0, 16);
#else
limit = ram_size;
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
return (uint32_t)-1;
}
ptr[0] = tswap32(limit / 2);
ptr[1] = tswap32(limit);
ptr[2] = tswap32(limit);
ptr[3] = tswap32(0);
unlock_user(ptr, arg0, 16);
#endif
return 0;
}
case TARGET_SYS_EXIT:
gdb_exit(env, 0);
exit(0);
default:
fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(CPUARMState *env)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
target_ulong args;
target_ulong arg0, arg1, arg2, arg3;
char * VAR_0;
int VAR_1;
uint32_t ret;
uint32_t len;
#ifdef CONFIG_USER_ONLY
TaskState *ts = cs->opaque;
#else
CPUARMState *ts = env;
#endif
VAR_1 = env->regs[0];
args = env->regs[1];
switch (VAR_1) {
case TARGET_SYS_OPEN:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
VAR_0 = lock_user_string(arg0);
if (!VAR_0) {
return (uint32_t)-1;
}
if (arg1 >= 12) {
unlock_user(VAR_0, arg0, 0);
return (uint32_t)-1;
}
if (strcmp(VAR_0, ":tt") == 0) {
int VAR_2 = arg1 < 4 ? STDIN_FILENO : STDOUT_FILENO;
unlock_user(VAR_0, arg0, 0);
return VAR_2;
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%VAR_0,%x,1a4", arg0,
(int)arg2+1, gdb_open_modeflags[arg1]);
ret = env->regs[0];
} else {
ret = set_swi_errno(ts, open(VAR_0, open_modeflags[arg1], 0644));
}
unlock_user(VAR_0, arg0, 0);
return ret;
case TARGET_SYS_CLOSE:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "close,%x", arg0);
return env->regs[0];
} else {
return set_swi_errno(ts, close(arg0));
}
case TARGET_SYS_WRITEC:
{
char VAR_3;
if (get_user_u8(VAR_3, args))
return (uint32_t)-1;
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,1", args);
return env->regs[0];
} else {
return write(STDERR_FILENO, &VAR_3, 1);
}
}
case TARGET_SYS_WRITE0:
if (!(VAR_0 = lock_user_string(args)))
return (uint32_t)-1;
len = strlen(VAR_0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,%x\n", args, len);
ret = env->regs[0];
} else {
ret = write(STDERR_FILENO, VAR_0, len);
}
unlock_user(VAR_0, args, 0);
return ret;
case TARGET_SYS_WRITE:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "write,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
VAR_0 = lock_user(VERIFY_READ, arg1, len, 1);
if (!VAR_0) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, write(arg0, VAR_0, len));
unlock_user(VAR_0, arg1, 0);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READ:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
arm_semi_syscall_len = len;
gdb_do_syscall(arm_semi_cb, "read,%x,%x,%x", arg0, arg1, len);
return env->regs[0];
} else {
VAR_0 = lock_user(VERIFY_WRITE, arg1, len, 0);
if (!VAR_0) {
return (uint32_t)-1;
}
do {
ret = set_swi_errno(ts, read(arg0, VAR_0, len));
} while (ret == -1 && errno == EINTR);
unlock_user(VAR_0, arg1, len);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
}
case TARGET_SYS_READC:
return 0;
case TARGET_SYS_ISTTY:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "isatty,%x", arg0);
return env->regs[0];
} else {
return isatty(arg0);
}
case TARGET_SYS_SEEK:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "lseek,%x,%x,0", arg0, arg1);
return env->regs[0];
} else {
ret = set_swi_errno(ts, lseek(arg0, arg1, SEEK_SET));
if (ret == (uint32_t)-1)
return -1;
return 0;
}
case TARGET_SYS_FLEN:
GET_ARG(0);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x",
arg0, env->regs[13]-64);
return env->regs[0];
} else {
struct stat VAR_4;
ret = set_swi_errno(ts, fstat(arg0, &VAR_4));
if (ret == (uint32_t)-1)
return -1;
return VAR_4.st_size;
}
case TARGET_SYS_TMPNAM:
return -1;
case TARGET_SYS_REMOVE:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "unlink,%VAR_0", arg0, (int)arg1+1);
ret = env->regs[0];
} else {
VAR_0 = lock_user_string(arg0);
if (!VAR_0) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, remove(VAR_0));
unlock_user(VAR_0, arg0, 0);
}
return ret;
case TARGET_SYS_RENAME:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
GET_ARG(3);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "rename,%VAR_0,%VAR_0",
arg0, (int)arg1+1, arg2, (int)arg3+1);
return env->regs[0];
} else {
char *VAR_5;
VAR_0 = lock_user_string(arg0);
VAR_5 = lock_user_string(arg2);
if (!VAR_0 || !VAR_5)
ret = (uint32_t)-1;
else
ret = set_swi_errno(ts, rename(VAR_0, VAR_5));
if (VAR_5)
unlock_user(VAR_5, arg2, 0);
if (VAR_0)
unlock_user(VAR_0, arg0, 0);
return ret;
}
case TARGET_SYS_CLOCK:
return clock() / (CLOCKS_PER_SEC / 100);
case TARGET_SYS_TIME:
return set_swi_errno(ts, time(NULL));
case TARGET_SYS_SYSTEM:
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "system,%VAR_0", arg0, (int)arg1+1);
return env->regs[0];
} else {
VAR_0 = lock_user_string(arg0);
if (!VAR_0) {
return (uint32_t)-1;
}
ret = set_swi_errno(ts, system(VAR_0));
unlock_user(VAR_0, arg0, 0);
return ret;
}
case TARGET_SYS_ERRNO:
#ifdef CONFIG_USER_ONLY
return ts->swi_errno;
#else
return syscall_err;
#endif
case TARGET_SYS_GET_CMDLINE:
{
char *VAR_6;
size_t input_size;
size_t output_size;
int VAR_7 = 0;
GET_ARG(0);
GET_ARG(1);
input_size = arg1;
#if !defined(CONFIG_USER_ONLY)
output_size = strlen(ts->boot_info->kernel_filename)
+ 1
+ strlen(ts->boot_info->kernel_cmdline)
+ 1;
#else
unsigned int i;
output_size = ts->info->arg_end - ts->info->arg_start;
if (!output_size) {
output_size = 1;
}
#endif
if (output_size > input_size) {
return -1;
}
if (SET_ARG(1, output_size - 1)) {
return -1;
}
VAR_6 = lock_user(VERIFY_WRITE, arg0, output_size, 0);
if (!VAR_6) {
return -1;
}
#if !defined(CONFIG_USER_ONLY)
pstrcpy(VAR_6, output_size, ts->boot_info->kernel_filename);
pstrcat(VAR_6, output_size, " ");
pstrcat(VAR_6, output_size, ts->boot_info->kernel_cmdline);
#else
if (output_size == 1) {
VAR_6[0] = '\0';
goto out;
}
if (copy_from_user(VAR_6, ts->info->arg_start,
output_size)) {
VAR_7 = -1;
goto out;
}
for (i = 0; i < output_size - 1; i++) {
if (VAR_6[i] == 0) {
VAR_6[i] = ' ';
}
}
out:
#endif
unlock_user(VAR_6, arg0, output_size);
return VAR_7;
}
case TARGET_SYS_HEAPINFO:
{
uint32_t *ptr;
uint32_t limit;
GET_ARG(0);
#ifdef CONFIG_USER_ONLY
if (!ts->heap_limit) {
abi_ulong ret;
ts->heap_base = do_brk(0);
limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE;
for (;;) {
ret = do_brk(limit);
if (ret >= limit) {
break;
}
limit = (ts->heap_base >> 1) + (limit >> 1);
}
ts->heap_limit = limit;
}
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
return (uint32_t)-1;
}
ptr[0] = tswap32(ts->heap_base);
ptr[1] = tswap32(ts->heap_limit);
ptr[2] = tswap32(ts->stack_base);
ptr[3] = tswap32(0);
unlock_user(ptr, arg0, 16);
#else
limit = ram_size;
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
return (uint32_t)-1;
}
ptr[0] = tswap32(limit / 2);
ptr[1] = tswap32(limit);
ptr[2] = tswap32(limit);
ptr[3] = tswap32(0);
unlock_user(ptr, arg0, 16);
#endif
return 0;
}
case TARGET_SYS_EXIT:
gdb_exit(env, 0);
exit(0);
default:
fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", VAR_1);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
}
| [
"uint32_t FUNC_0(CPUARMState *env)\n{",
"ARMCPU *cpu = arm_env_get_cpu(env);",
"CPUState *cs = CPU(cpu);",
"target_ulong args;",
"target_ulong arg0, arg1, arg2, arg3;",
"char * VAR_0;",
"int VAR_1;",
"uint32_t ret;",
"uint32_t len;",
"#ifdef CONFIG_USER_ONLY\nTaskState *ts = cs->opaque;",
"#else\nCPUARMState *ts = env;",
"#endif\nVAR_1 = env->regs[0];",
"args = env->regs[1];",
"switch (VAR_1) {",
"case TARGET_SYS_OPEN:\nGET_ARG(0);",
"GET_ARG(1);",
"GET_ARG(2);",
"VAR_0 = lock_user_string(arg0);",
"if (!VAR_0) {",
"return (uint32_t)-1;",
"}",
"if (arg1 >= 12) {",
"unlock_user(VAR_0, arg0, 0);",
"return (uint32_t)-1;",
"}",
"if (strcmp(VAR_0, \":tt\") == 0) {",
"int VAR_2 = arg1 < 4 ? STDIN_FILENO : STDOUT_FILENO;",
"unlock_user(VAR_0, arg0, 0);",
"return VAR_2;",
"}",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"open,%VAR_0,%x,1a4\", arg0,\n(int)arg2+1, gdb_open_modeflags[arg1]);",
"ret = env->regs[0];",
"} else {",
"ret = set_swi_errno(ts, open(VAR_0, open_modeflags[arg1], 0644));",
"}",
"unlock_user(VAR_0, arg0, 0);",
"return ret;",
"case TARGET_SYS_CLOSE:\nGET_ARG(0);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"close,%x\", arg0);",
"return env->regs[0];",
"} else {",
"return set_swi_errno(ts, close(arg0));",
"}",
"case TARGET_SYS_WRITEC:\n{",
"char VAR_3;",
"if (get_user_u8(VAR_3, args))\nreturn (uint32_t)-1;",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"write,2,%x,1\", args);",
"return env->regs[0];",
"} else {",
"return write(STDERR_FILENO, &VAR_3, 1);",
"}",
"}",
"case TARGET_SYS_WRITE0:\nif (!(VAR_0 = lock_user_string(args)))\nreturn (uint32_t)-1;",
"len = strlen(VAR_0);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"write,2,%x,%x\\n\", args, len);",
"ret = env->regs[0];",
"} else {",
"ret = write(STDERR_FILENO, VAR_0, len);",
"}",
"unlock_user(VAR_0, args, 0);",
"return ret;",
"case TARGET_SYS_WRITE:\nGET_ARG(0);",
"GET_ARG(1);",
"GET_ARG(2);",
"len = arg2;",
"if (use_gdb_syscalls()) {",
"arm_semi_syscall_len = len;",
"gdb_do_syscall(arm_semi_cb, \"write,%x,%x,%x\", arg0, arg1, len);",
"return env->regs[0];",
"} else {",
"VAR_0 = lock_user(VERIFY_READ, arg1, len, 1);",
"if (!VAR_0) {",
"return (uint32_t)-1;",
"}",
"ret = set_swi_errno(ts, write(arg0, VAR_0, len));",
"unlock_user(VAR_0, arg1, 0);",
"if (ret == (uint32_t)-1)\nreturn -1;",
"return len - ret;",
"}",
"case TARGET_SYS_READ:\nGET_ARG(0);",
"GET_ARG(1);",
"GET_ARG(2);",
"len = arg2;",
"if (use_gdb_syscalls()) {",
"arm_semi_syscall_len = len;",
"gdb_do_syscall(arm_semi_cb, \"read,%x,%x,%x\", arg0, arg1, len);",
"return env->regs[0];",
"} else {",
"VAR_0 = lock_user(VERIFY_WRITE, arg1, len, 0);",
"if (!VAR_0) {",
"return (uint32_t)-1;",
"}",
"do {",
"ret = set_swi_errno(ts, read(arg0, VAR_0, len));",
"} while (ret == -1 && errno == EINTR);",
"unlock_user(VAR_0, arg1, len);",
"if (ret == (uint32_t)-1)\nreturn -1;",
"return len - ret;",
"}",
"case TARGET_SYS_READC:\nreturn 0;",
"case TARGET_SYS_ISTTY:\nGET_ARG(0);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"isatty,%x\", arg0);",
"return env->regs[0];",
"} else {",
"return isatty(arg0);",
"}",
"case TARGET_SYS_SEEK:\nGET_ARG(0);",
"GET_ARG(1);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"lseek,%x,%x,0\", arg0, arg1);",
"return env->regs[0];",
"} else {",
"ret = set_swi_errno(ts, lseek(arg0, arg1, SEEK_SET));",
"if (ret == (uint32_t)-1)\nreturn -1;",
"return 0;",
"}",
"case TARGET_SYS_FLEN:\nGET_ARG(0);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_flen_cb, \"fstat,%x,%x\",\narg0, env->regs[13]-64);",
"return env->regs[0];",
"} else {",
"struct stat VAR_4;",
"ret = set_swi_errno(ts, fstat(arg0, &VAR_4));",
"if (ret == (uint32_t)-1)\nreturn -1;",
"return VAR_4.st_size;",
"}",
"case TARGET_SYS_TMPNAM:\nreturn -1;",
"case TARGET_SYS_REMOVE:\nGET_ARG(0);",
"GET_ARG(1);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"unlink,%VAR_0\", arg0, (int)arg1+1);",
"ret = env->regs[0];",
"} else {",
"VAR_0 = lock_user_string(arg0);",
"if (!VAR_0) {",
"return (uint32_t)-1;",
"}",
"ret = set_swi_errno(ts, remove(VAR_0));",
"unlock_user(VAR_0, arg0, 0);",
"}",
"return ret;",
"case TARGET_SYS_RENAME:\nGET_ARG(0);",
"GET_ARG(1);",
"GET_ARG(2);",
"GET_ARG(3);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"rename,%VAR_0,%VAR_0\",\narg0, (int)arg1+1, arg2, (int)arg3+1);",
"return env->regs[0];",
"} else {",
"char *VAR_5;",
"VAR_0 = lock_user_string(arg0);",
"VAR_5 = lock_user_string(arg2);",
"if (!VAR_0 || !VAR_5)\nret = (uint32_t)-1;",
"else\nret = set_swi_errno(ts, rename(VAR_0, VAR_5));",
"if (VAR_5)\nunlock_user(VAR_5, arg2, 0);",
"if (VAR_0)\nunlock_user(VAR_0, arg0, 0);",
"return ret;",
"}",
"case TARGET_SYS_CLOCK:\nreturn clock() / (CLOCKS_PER_SEC / 100);",
"case TARGET_SYS_TIME:\nreturn set_swi_errno(ts, time(NULL));",
"case TARGET_SYS_SYSTEM:\nGET_ARG(0);",
"GET_ARG(1);",
"if (use_gdb_syscalls()) {",
"gdb_do_syscall(arm_semi_cb, \"system,%VAR_0\", arg0, (int)arg1+1);",
"return env->regs[0];",
"} else {",
"VAR_0 = lock_user_string(arg0);",
"if (!VAR_0) {",
"return (uint32_t)-1;",
"}",
"ret = set_swi_errno(ts, system(VAR_0));",
"unlock_user(VAR_0, arg0, 0);",
"return ret;",
"}",
"case TARGET_SYS_ERRNO:\n#ifdef CONFIG_USER_ONLY\nreturn ts->swi_errno;",
"#else\nreturn syscall_err;",
"#endif\ncase TARGET_SYS_GET_CMDLINE:\n{",
"char *VAR_6;",
"size_t input_size;",
"size_t output_size;",
"int VAR_7 = 0;",
"GET_ARG(0);",
"GET_ARG(1);",
"input_size = arg1;",
"#if !defined(CONFIG_USER_ONLY)\noutput_size = strlen(ts->boot_info->kernel_filename)\n+ 1\n+ strlen(ts->boot_info->kernel_cmdline)\n+ 1;",
"#else\nunsigned int i;",
"output_size = ts->info->arg_end - ts->info->arg_start;",
"if (!output_size) {",
"output_size = 1;",
"}",
"#endif\nif (output_size > input_size) {",
"return -1;",
"}",
"if (SET_ARG(1, output_size - 1)) {",
"return -1;",
"}",
"VAR_6 = lock_user(VERIFY_WRITE, arg0, output_size, 0);",
"if (!VAR_6) {",
"return -1;",
"}",
"#if !defined(CONFIG_USER_ONLY)\npstrcpy(VAR_6, output_size, ts->boot_info->kernel_filename);",
"pstrcat(VAR_6, output_size, \" \");",
"pstrcat(VAR_6, output_size, ts->boot_info->kernel_cmdline);",
"#else\nif (output_size == 1) {",
"VAR_6[0] = '\\0';",
"goto out;",
"}",
"if (copy_from_user(VAR_6, ts->info->arg_start,\noutput_size)) {",
"VAR_7 = -1;",
"goto out;",
"}",
"for (i = 0; i < output_size - 1; i++) {",
"if (VAR_6[i] == 0) {",
"VAR_6[i] = ' ';",
"}",
"}",
"out:\n#endif\nunlock_user(VAR_6, arg0, output_size);",
"return VAR_7;",
"}",
"case TARGET_SYS_HEAPINFO:\n{",
"uint32_t *ptr;",
"uint32_t limit;",
"GET_ARG(0);",
"#ifdef CONFIG_USER_ONLY\nif (!ts->heap_limit) {",
"abi_ulong ret;",
"ts->heap_base = do_brk(0);",
"limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE;",
"for (;;) {",
"ret = do_brk(limit);",
"if (ret >= limit) {",
"break;",
"}",
"limit = (ts->heap_base >> 1) + (limit >> 1);",
"}",
"ts->heap_limit = limit;",
"}",
"ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);",
"if (!ptr) {",
"return (uint32_t)-1;",
"}",
"ptr[0] = tswap32(ts->heap_base);",
"ptr[1] = tswap32(ts->heap_limit);",
"ptr[2] = tswap32(ts->stack_base);",
"ptr[3] = tswap32(0);",
"unlock_user(ptr, arg0, 16);",
"#else\nlimit = ram_size;",
"ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);",
"if (!ptr) {",
"return (uint32_t)-1;",
"}",
"ptr[0] = tswap32(limit / 2);",
"ptr[1] = tswap32(limit);",
"ptr[2] = tswap32(limit);",
"ptr[3] = tswap32(0);",
"unlock_user(ptr, arg0, 16);",
"#endif\nreturn 0;",
"}",
"case TARGET_SYS_EXIT:\ngdb_exit(env, 0);",
"exit(0);",
"default:\nfprintf(stderr, \"qemu: Unsupported SemiHosting SWI 0x%02x\\n\", VAR_1);",
"cpu_dump_state(cs, stderr, fprintf, 0);",
"abort();",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
117,
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253,
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317,
319
],
[
321
],
[
323
],
[
325,
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389,
393
],
[
395,
397
],
[
399,
401
],
[
403,
405
],
[
407
],
[
409
],
[
411,
413
],
[
415,
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451,
453,
455
],
[
457,
459
],
[
461,
463,
465
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
511,
513,
515,
517,
519
],
[
521,
523
],
[
527
],
[
529
],
[
535
],
[
537
],
[
539,
543
],
[
547
],
[
549
],
[
555
],
[
559
],
[
561
],
[
567
],
[
569
],
[
571
],
[
573
],
[
579,
581
],
[
583
],
[
585
],
[
587,
589
],
[
593
],
[
595
],
[
597
],
[
601,
603
],
[
605
],
[
607
],
[
609
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625,
627,
631
],
[
635
],
[
637
],
[
639,
641
],
[
643
],
[
645
],
[
647
],
[
651,
657
],
[
659
],
[
663
],
[
665
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
689
],
[
691
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709,
711
],
[
713
],
[
715
],
[
719
],
[
721
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735,
737
],
[
739
],
[
741,
743
],
[
745
],
[
747,
749
],
[
751
],
[
753
],
[
755
],
[
757
]
]
|
13,947 | static int openfile(char *name, int flags, QDict *opts)
{
Error *local_err = NULL;
BlockDriverState *bs;
if (qemuio_blk) {
error_report("file open already, try 'help close'");
QDECREF(opts);
return 1;
}
qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
if (!qemuio_blk) {
error_reportf_err(local_err, "can't open%s%s: ",
name ? " device " : "", name ?: "");
return 1;
}
bs = blk_bs(qemuio_blk);
if (bdrv_is_encrypted(bs)) {
char password[256];
printf("Disk image '%s' is encrypted.\n", name);
if (qemu_read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto error;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto error;
}
}
return 0;
error:
blk_unref(qemuio_blk);
qemuio_blk = NULL;
return 1;
}
| false | qemu | 4ef130fca87b7a8c77e1af9ca967f28b683811d7 | static int openfile(char *name, int flags, QDict *opts)
{
Error *local_err = NULL;
BlockDriverState *bs;
if (qemuio_blk) {
error_report("file open already, try 'help close'");
QDECREF(opts);
return 1;
}
qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
if (!qemuio_blk) {
error_reportf_err(local_err, "can't open%s%s: ",
name ? " device " : "", name ?: "");
return 1;
}
bs = blk_bs(qemuio_blk);
if (bdrv_is_encrypted(bs)) {
char password[256];
printf("Disk image '%s' is encrypted.\n", name);
if (qemu_read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto error;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto error;
}
}
return 0;
error:
blk_unref(qemuio_blk);
qemuio_blk = NULL;
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(char *VAR_0, int VAR_1, QDict *VAR_2)
{
Error *local_err = NULL;
BlockDriverState *bs;
if (qemuio_blk) {
error_report("file open already, try 'help close'");
QDECREF(VAR_2);
return 1;
}
qemuio_blk = blk_new_open(VAR_0, NULL, VAR_2, VAR_1, &local_err);
if (!qemuio_blk) {
error_reportf_err(local_err, "can't open%s%s: ",
VAR_0 ? " device " : "", VAR_0 ?: "");
return 1;
}
bs = blk_bs(qemuio_blk);
if (bdrv_is_encrypted(bs)) {
char VAR_3[256];
printf("Disk image '%s' is encrypted.\n", VAR_0);
if (qemu_read_password(VAR_3, sizeof(VAR_3)) < 0) {
error_report("No VAR_3 given");
goto error;
}
if (bdrv_set_key(bs, VAR_3) < 0) {
error_report("invalid VAR_3");
goto error;
}
}
return 0;
error:
blk_unref(qemuio_blk);
qemuio_blk = NULL;
return 1;
}
| [
"static int FUNC_0(char *VAR_0, int VAR_1, QDict *VAR_2)\n{",
"Error *local_err = NULL;",
"BlockDriverState *bs;",
"if (qemuio_blk) {",
"error_report(\"file open already, try 'help close'\");",
"QDECREF(VAR_2);",
"return 1;",
"}",
"qemuio_blk = blk_new_open(VAR_0, NULL, VAR_2, VAR_1, &local_err);",
"if (!qemuio_blk) {",
"error_reportf_err(local_err, \"can't open%s%s: \",\nVAR_0 ? \" device \" : \"\", VAR_0 ?: \"\");",
"return 1;",
"}",
"bs = blk_bs(qemuio_blk);",
"if (bdrv_is_encrypted(bs)) {",
"char VAR_3[256];",
"printf(\"Disk image '%s' is encrypted.\\n\", VAR_0);",
"if (qemu_read_password(VAR_3, sizeof(VAR_3)) < 0) {",
"error_report(\"No VAR_3 given\");",
"goto error;",
"}",
"if (bdrv_set_key(bs, VAR_3) < 0) {",
"error_report(\"invalid VAR_3\");",
"goto error;",
"}",
"}",
"return 0;",
"error:\nblk_unref(qemuio_blk);",
"qemuio_blk = NULL;",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
]
]
|
13,948 | static void *worker_thread(void *opaque)
{
ThreadPool *pool = opaque;
qemu_mutex_lock(&pool->lock);
pool->pending_threads--;
do_spawn_thread(pool);
while (!pool->stopping) {
ThreadPoolElement *req;
int ret;
do {
pool->idle_threads++;
qemu_mutex_unlock(&pool->lock);
ret = qemu_sem_timedwait(&pool->sem, 10000);
qemu_mutex_lock(&pool->lock);
pool->idle_threads--;
} while (ret == -1 && !QTAILQ_EMPTY(&pool->request_list));
if (ret == -1 || pool->stopping) {
break;
}
req = QTAILQ_FIRST(&pool->request_list);
QTAILQ_REMOVE(&pool->request_list, req, reqs);
req->state = THREAD_ACTIVE;
qemu_mutex_unlock(&pool->lock);
ret = req->func(req->arg);
req->ret = ret;
/* Write ret before state. */
smp_wmb();
req->state = THREAD_DONE;
qemu_mutex_lock(&pool->lock);
qemu_bh_schedule(pool->completion_bh);
}
pool->cur_threads--;
qemu_cond_signal(&pool->worker_stopped);
qemu_mutex_unlock(&pool->lock);
return NULL;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | static void *worker_thread(void *opaque)
{
ThreadPool *pool = opaque;
qemu_mutex_lock(&pool->lock);
pool->pending_threads--;
do_spawn_thread(pool);
while (!pool->stopping) {
ThreadPoolElement *req;
int ret;
do {
pool->idle_threads++;
qemu_mutex_unlock(&pool->lock);
ret = qemu_sem_timedwait(&pool->sem, 10000);
qemu_mutex_lock(&pool->lock);
pool->idle_threads--;
} while (ret == -1 && !QTAILQ_EMPTY(&pool->request_list));
if (ret == -1 || pool->stopping) {
break;
}
req = QTAILQ_FIRST(&pool->request_list);
QTAILQ_REMOVE(&pool->request_list, req, reqs);
req->state = THREAD_ACTIVE;
qemu_mutex_unlock(&pool->lock);
ret = req->func(req->arg);
req->ret = ret;
smp_wmb();
req->state = THREAD_DONE;
qemu_mutex_lock(&pool->lock);
qemu_bh_schedule(pool->completion_bh);
}
pool->cur_threads--;
qemu_cond_signal(&pool->worker_stopped);
qemu_mutex_unlock(&pool->lock);
return NULL;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(void *VAR_0)
{
ThreadPool *pool = VAR_0;
qemu_mutex_lock(&pool->lock);
pool->pending_threads--;
do_spawn_thread(pool);
while (!pool->stopping) {
ThreadPoolElement *req;
int VAR_1;
do {
pool->idle_threads++;
qemu_mutex_unlock(&pool->lock);
VAR_1 = qemu_sem_timedwait(&pool->sem, 10000);
qemu_mutex_lock(&pool->lock);
pool->idle_threads--;
} while (VAR_1 == -1 && !QTAILQ_EMPTY(&pool->request_list));
if (VAR_1 == -1 || pool->stopping) {
break;
}
req = QTAILQ_FIRST(&pool->request_list);
QTAILQ_REMOVE(&pool->request_list, req, reqs);
req->state = THREAD_ACTIVE;
qemu_mutex_unlock(&pool->lock);
VAR_1 = req->func(req->arg);
req->VAR_1 = VAR_1;
smp_wmb();
req->state = THREAD_DONE;
qemu_mutex_lock(&pool->lock);
qemu_bh_schedule(pool->completion_bh);
}
pool->cur_threads--;
qemu_cond_signal(&pool->worker_stopped);
qemu_mutex_unlock(&pool->lock);
return NULL;
}
| [
"static void *FUNC_0(void *VAR_0)\n{",
"ThreadPool *pool = VAR_0;",
"qemu_mutex_lock(&pool->lock);",
"pool->pending_threads--;",
"do_spawn_thread(pool);",
"while (!pool->stopping) {",
"ThreadPoolElement *req;",
"int VAR_1;",
"do {",
"pool->idle_threads++;",
"qemu_mutex_unlock(&pool->lock);",
"VAR_1 = qemu_sem_timedwait(&pool->sem, 10000);",
"qemu_mutex_lock(&pool->lock);",
"pool->idle_threads--;",
"} while (VAR_1 == -1 && !QTAILQ_EMPTY(&pool->request_list));",
"if (VAR_1 == -1 || pool->stopping) {",
"break;",
"}",
"req = QTAILQ_FIRST(&pool->request_list);",
"QTAILQ_REMOVE(&pool->request_list, req, reqs);",
"req->state = THREAD_ACTIVE;",
"qemu_mutex_unlock(&pool->lock);",
"VAR_1 = req->func(req->arg);",
"req->VAR_1 = VAR_1;",
"smp_wmb();",
"req->state = THREAD_DONE;",
"qemu_mutex_lock(&pool->lock);",
"qemu_bh_schedule(pool->completion_bh);",
"}",
"pool->cur_threads--;",
"qemu_cond_signal(&pool->worker_stopped);",
"qemu_mutex_unlock(&pool->lock);",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
]
]
|
13,949 | void qemu_aio_wait(void)
{
int ret;
if (qemu_bh_poll())
return;
do {
AioHandler *node;
fd_set rdfds, wrfds;
int max_fd = -1;
walking_handlers = 1;
FD_ZERO(&rdfds);
FD_ZERO(&wrfds);
/* fill fd sets */
LIST_FOREACH(node, &aio_handlers, node) {
/* If there aren't pending AIO operations, don't invoke callbacks.
* Otherwise, if there are no AIO requests, qemu_aio_wait() would
* wait indefinitely.
*/
if (node->io_flush && node->io_flush(node->opaque) == 0)
continue;
if (!node->deleted && node->io_read) {
FD_SET(node->fd, &rdfds);
max_fd = MAX(max_fd, node->fd + 1);
}
if (!node->deleted && node->io_write) {
FD_SET(node->fd, &wrfds);
max_fd = MAX(max_fd, node->fd + 1);
}
}
walking_handlers = 0;
/* No AIO operations? Get us out of here */
if (max_fd == -1)
break;
/* wait until next event */
ret = select(max_fd, &rdfds, &wrfds, NULL, NULL);
if (ret == -1 && errno == EINTR)
continue;
/* if we have any readable fds, dispatch event */
if (ret > 0) {
walking_handlers = 1;
/* we have to walk very carefully in case
* qemu_aio_set_fd_handler is called while we're walking */
node = LIST_FIRST(&aio_handlers);
while (node) {
AioHandler *tmp;
if (!node->deleted &&
FD_ISSET(node->fd, &rdfds) &&
node->io_read) {
node->io_read(node->opaque);
}
if (!node->deleted &&
FD_ISSET(node->fd, &wrfds) &&
node->io_write) {
node->io_write(node->opaque);
}
tmp = node;
node = LIST_NEXT(node, node);
if (tmp->deleted) {
LIST_REMOVE(tmp, node);
qemu_free(tmp);
}
}
walking_handlers = 0;
}
} while (ret == 0);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void qemu_aio_wait(void)
{
int ret;
if (qemu_bh_poll())
return;
do {
AioHandler *node;
fd_set rdfds, wrfds;
int max_fd = -1;
walking_handlers = 1;
FD_ZERO(&rdfds);
FD_ZERO(&wrfds);
LIST_FOREACH(node, &aio_handlers, node) {
if (node->io_flush && node->io_flush(node->opaque) == 0)
continue;
if (!node->deleted && node->io_read) {
FD_SET(node->fd, &rdfds);
max_fd = MAX(max_fd, node->fd + 1);
}
if (!node->deleted && node->io_write) {
FD_SET(node->fd, &wrfds);
max_fd = MAX(max_fd, node->fd + 1);
}
}
walking_handlers = 0;
if (max_fd == -1)
break;
ret = select(max_fd, &rdfds, &wrfds, NULL, NULL);
if (ret == -1 && errno == EINTR)
continue;
if (ret > 0) {
walking_handlers = 1;
node = LIST_FIRST(&aio_handlers);
while (node) {
AioHandler *tmp;
if (!node->deleted &&
FD_ISSET(node->fd, &rdfds) &&
node->io_read) {
node->io_read(node->opaque);
}
if (!node->deleted &&
FD_ISSET(node->fd, &wrfds) &&
node->io_write) {
node->io_write(node->opaque);
}
tmp = node;
node = LIST_NEXT(node, node);
if (tmp->deleted) {
LIST_REMOVE(tmp, node);
qemu_free(tmp);
}
}
walking_handlers = 0;
}
} while (ret == 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
int VAR_0;
if (qemu_bh_poll())
return;
do {
AioHandler *node;
fd_set rdfds, wrfds;
int VAR_1 = -1;
walking_handlers = 1;
FD_ZERO(&rdfds);
FD_ZERO(&wrfds);
LIST_FOREACH(node, &aio_handlers, node) {
if (node->io_flush && node->io_flush(node->opaque) == 0)
continue;
if (!node->deleted && node->io_read) {
FD_SET(node->fd, &rdfds);
VAR_1 = MAX(VAR_1, node->fd + 1);
}
if (!node->deleted && node->io_write) {
FD_SET(node->fd, &wrfds);
VAR_1 = MAX(VAR_1, node->fd + 1);
}
}
walking_handlers = 0;
if (VAR_1 == -1)
break;
VAR_0 = select(VAR_1, &rdfds, &wrfds, NULL, NULL);
if (VAR_0 == -1 && errno == EINTR)
continue;
if (VAR_0 > 0) {
walking_handlers = 1;
node = LIST_FIRST(&aio_handlers);
while (node) {
AioHandler *tmp;
if (!node->deleted &&
FD_ISSET(node->fd, &rdfds) &&
node->io_read) {
node->io_read(node->opaque);
}
if (!node->deleted &&
FD_ISSET(node->fd, &wrfds) &&
node->io_write) {
node->io_write(node->opaque);
}
tmp = node;
node = LIST_NEXT(node, node);
if (tmp->deleted) {
LIST_REMOVE(tmp, node);
qemu_free(tmp);
}
}
walking_handlers = 0;
}
} while (VAR_0 == 0);
}
| [
"void FUNC_0(void)\n{",
"int VAR_0;",
"if (qemu_bh_poll())\nreturn;",
"do {",
"AioHandler *node;",
"fd_set rdfds, wrfds;",
"int VAR_1 = -1;",
"walking_handlers = 1;",
"FD_ZERO(&rdfds);",
"FD_ZERO(&wrfds);",
"LIST_FOREACH(node, &aio_handlers, node) {",
"if (node->io_flush && node->io_flush(node->opaque) == 0)\ncontinue;",
"if (!node->deleted && node->io_read) {",
"FD_SET(node->fd, &rdfds);",
"VAR_1 = MAX(VAR_1, node->fd + 1);",
"}",
"if (!node->deleted && node->io_write) {",
"FD_SET(node->fd, &wrfds);",
"VAR_1 = MAX(VAR_1, node->fd + 1);",
"}",
"}",
"walking_handlers = 0;",
"if (VAR_1 == -1)\nbreak;",
"VAR_0 = select(VAR_1, &rdfds, &wrfds, NULL, NULL);",
"if (VAR_0 == -1 && errno == EINTR)\ncontinue;",
"if (VAR_0 > 0) {",
"walking_handlers = 1;",
"node = LIST_FIRST(&aio_handlers);",
"while (node) {",
"AioHandler *tmp;",
"if (!node->deleted &&\nFD_ISSET(node->fd, &rdfds) &&\nnode->io_read) {",
"node->io_read(node->opaque);",
"}",
"if (!node->deleted &&\nFD_ISSET(node->fd, &wrfds) &&\nnode->io_write) {",
"node->io_write(node->opaque);",
"}",
"tmp = node;",
"node = LIST_NEXT(node, node);",
"if (tmp->deleted) {",
"LIST_REMOVE(tmp, node);",
"qemu_free(tmp);",
"}",
"}",
"walking_handlers = 0;",
"}",
"} while (VAR_0 == 0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
37
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
79,
81
],
[
87
],
[
89,
91
],
[
97
],
[
99
],
[
107
],
[
109
],
[
111
],
[
115,
117,
119
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
]
]
|
13,950 | void hotplug_handler_post_plug(HotplugHandler *plug_handler,
DeviceState *plugged_dev,
Error **errp)
{
HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
if (hdc->post_plug) {
hdc->post_plug(plug_handler, plugged_dev, errp);
}
}
| false | qemu | c7f8d0f3a52b5ef8fdcd305cce438f67d7e06a9f | void hotplug_handler_post_plug(HotplugHandler *plug_handler,
DeviceState *plugged_dev,
Error **errp)
{
HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
if (hdc->post_plug) {
hdc->post_plug(plug_handler, plugged_dev, errp);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(HotplugHandler *VAR_0,
DeviceState *VAR_1,
Error **VAR_2)
{
HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(VAR_0);
if (hdc->post_plug) {
hdc->post_plug(VAR_0, VAR_1, VAR_2);
}
}
| [
"void FUNC_0(HotplugHandler *VAR_0,\nDeviceState *VAR_1,\nError **VAR_2)\n{",
"HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(VAR_0);",
"if (hdc->post_plug) {",
"hdc->post_plug(VAR_0, VAR_1, VAR_2);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
13,952 | static void kvm_openpic_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *d = SYS_BUS_DEVICE(dev);
KVMOpenPICState *opp = KVM_OPENPIC(dev);
KVMState *s = kvm_state;
int kvm_openpic_model;
struct kvm_create_device cd = {0};
int ret, i;
if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) {
error_setg(errp, "Kernel is lacking Device Control API");
return;
}
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_20;
break;
case OPENPIC_MODEL_FSL_MPIC_42:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_42;
break;
default:
error_setg(errp, "Unsupported OpenPIC model %" PRIu32, opp->model);
return;
}
cd.type = kvm_openpic_model;
ret = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &cd);
if (ret < 0) {
error_setg(errp, "Can't create device %d: %s",
cd.type, strerror(errno));
return;
}
opp->fd = cd.fd;
sysbus_init_mmio(d, &opp->mem);
qdev_init_gpio_in(dev, kvm_openpic_set_irq, OPENPIC_MAX_IRQ);
opp->mem_listener.region_add = kvm_openpic_region_add;
opp->mem_listener.region_del = kvm_openpic_region_del;
memory_listener_register(&opp->mem_listener, &address_space_memory);
/* indicate pic capabilities */
msi_supported = true;
kvm_kernel_irqchip = true;
kvm_async_interrupts_allowed = true;
/* set up irq routing */
kvm_init_irq_routing(kvm_state);
for (i = 0; i < 256; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(s);
}
| false | qemu | f41389ae3c54bd5e2040e3f95a2872981c3ed965 | static void kvm_openpic_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *d = SYS_BUS_DEVICE(dev);
KVMOpenPICState *opp = KVM_OPENPIC(dev);
KVMState *s = kvm_state;
int kvm_openpic_model;
struct kvm_create_device cd = {0};
int ret, i;
if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) {
error_setg(errp, "Kernel is lacking Device Control API");
return;
}
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_20;
break;
case OPENPIC_MODEL_FSL_MPIC_42:
kvm_openpic_model = KVM_DEV_TYPE_FSL_MPIC_42;
break;
default:
error_setg(errp, "Unsupported OpenPIC model %" PRIu32, opp->model);
return;
}
cd.type = kvm_openpic_model;
ret = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &cd);
if (ret < 0) {
error_setg(errp, "Can't create device %d: %s",
cd.type, strerror(errno));
return;
}
opp->fd = cd.fd;
sysbus_init_mmio(d, &opp->mem);
qdev_init_gpio_in(dev, kvm_openpic_set_irq, OPENPIC_MAX_IRQ);
opp->mem_listener.region_add = kvm_openpic_region_add;
opp->mem_listener.region_del = kvm_openpic_region_del;
memory_listener_register(&opp->mem_listener, &address_space_memory);
msi_supported = true;
kvm_kernel_irqchip = true;
kvm_async_interrupts_allowed = true;
kvm_init_irq_routing(kvm_state);
for (i = 0; i < 256; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
SysBusDevice *d = SYS_BUS_DEVICE(VAR_0);
KVMOpenPICState *opp = KVM_OPENPIC(VAR_0);
KVMState *s = kvm_state;
int VAR_2;
struct kvm_create_device VAR_3 = {0};
int VAR_4, VAR_5;
if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) {
error_setg(VAR_1, "Kernel is lacking Device Control API");
return;
}
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
VAR_2 = KVM_DEV_TYPE_FSL_MPIC_20;
break;
case OPENPIC_MODEL_FSL_MPIC_42:
VAR_2 = KVM_DEV_TYPE_FSL_MPIC_42;
break;
default:
error_setg(VAR_1, "Unsupported OpenPIC model %" PRIu32, opp->model);
return;
}
VAR_3.type = VAR_2;
VAR_4 = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &VAR_3);
if (VAR_4 < 0) {
error_setg(VAR_1, "Can't create device %d: %s",
VAR_3.type, strerror(errno));
return;
}
opp->fd = VAR_3.fd;
sysbus_init_mmio(d, &opp->mem);
qdev_init_gpio_in(VAR_0, kvm_openpic_set_irq, OPENPIC_MAX_IRQ);
opp->mem_listener.region_add = kvm_openpic_region_add;
opp->mem_listener.region_del = kvm_openpic_region_del;
memory_listener_register(&opp->mem_listener, &address_space_memory);
msi_supported = true;
kvm_kernel_irqchip = true;
kvm_async_interrupts_allowed = true;
kvm_init_irq_routing(kvm_state);
for (VAR_5 = 0; VAR_5 < 256; ++VAR_5) {
kvm_irqchip_add_irq_route(kvm_state, VAR_5, 0, VAR_5);
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(s);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"SysBusDevice *d = SYS_BUS_DEVICE(VAR_0);",
"KVMOpenPICState *opp = KVM_OPENPIC(VAR_0);",
"KVMState *s = kvm_state;",
"int VAR_2;",
"struct kvm_create_device VAR_3 = {0};",
"int VAR_4, VAR_5;",
"if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) {",
"error_setg(VAR_1, \"Kernel is lacking Device Control API\");",
"return;",
"}",
"switch (opp->model) {",
"case OPENPIC_MODEL_FSL_MPIC_20:\nVAR_2 = KVM_DEV_TYPE_FSL_MPIC_20;",
"break;",
"case OPENPIC_MODEL_FSL_MPIC_42:\nVAR_2 = KVM_DEV_TYPE_FSL_MPIC_42;",
"break;",
"default:\nerror_setg(VAR_1, \"Unsupported OpenPIC model %\" PRIu32, opp->model);",
"return;",
"}",
"VAR_3.type = VAR_2;",
"VAR_4 = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &VAR_3);",
"if (VAR_4 < 0) {",
"error_setg(VAR_1, \"Can't create device %d: %s\",\nVAR_3.type, strerror(errno));",
"return;",
"}",
"opp->fd = VAR_3.fd;",
"sysbus_init_mmio(d, &opp->mem);",
"qdev_init_gpio_in(VAR_0, kvm_openpic_set_irq, OPENPIC_MAX_IRQ);",
"opp->mem_listener.region_add = kvm_openpic_region_add;",
"opp->mem_listener.region_del = kvm_openpic_region_del;",
"memory_listener_register(&opp->mem_listener, &address_space_memory);",
"msi_supported = true;",
"kvm_kernel_irqchip = true;",
"kvm_async_interrupts_allowed = true;",
"kvm_init_irq_routing(kvm_state);",
"for (VAR_5 = 0; VAR_5 < 256; ++VAR_5) {",
"kvm_irqchip_add_irq_route(kvm_state, VAR_5, 0, VAR_5);",
"}",
"kvm_irqfds_allowed = true;",
"kvm_msi_via_irqfd_allowed = true;",
"kvm_gsi_routing_allowed = true;",
"kvm_irqchip_commit_routes(s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39,
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
]
]
|
13,953 | static int get_free_io_mem_idx(void)
{
int i;
for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
if (!io_mem_used[i]) {
io_mem_used[i] = 1;
return i;
}
return -1;
}
| false | qemu | c6703b4761c4df633997a37d52641b20a0b6cf45 | static int get_free_io_mem_idx(void)
{
int i;
for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
if (!io_mem_used[i]) {
io_mem_used[i] = 1;
return i;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void)
{
int VAR_0;
for (VAR_0 = 0; VAR_0<IO_MEM_NB_ENTRIES; VAR_0++)
if (!io_mem_used[VAR_0]) {
io_mem_used[VAR_0] = 1;
return VAR_0;
}
return -1;
}
| [
"static int FUNC_0(void)\n{",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0<IO_MEM_NB_ENTRIES; VAR_0++)",
"if (!io_mem_used[VAR_0]) {",
"io_mem_used[VAR_0] = 1;",
"return VAR_0;",
"}",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.