Program: 13801
Project: 13801
Buggy source:
public int ff_h264_execute_ref_pic_marking(MMCO[] mmco,int mmco_count){
  int i, j=0;
  int current_ref_assigned=0;
  AVFrame pic=null;
  for (i=0; i < mmco_count; i++) {
    int structure=0, frame_num=0;
    if (mmco[i].opcode == MMCO.MMCO_SHORT2UNUSED || mmco[i].opcode == MMCO.MMCO_SHORT2LONG) {
      int[] param=new int[1];
      frame_num=pic_num_extract(mmco[i].short_pic_num,param);
      structure=param[0];
      pic=find_short(frame_num,param);
      j=param[0];
      if (null == pic) {
        continue;
      }
    }
switch (mmco[i].opcode) {
case MMCO.MMCO_SHORT2UNUSED:
      remove_short(frame_num,structure ^ MpegEncContext.PICT_FRAME);
    break;
case MMCO.MMCO_SHORT2LONG:
  if (this.long_ref[mmco[i].long_arg] != pic)   remove_long(mmco[i].long_arg,0);
remove_short_at_index(j);
this.long_ref[mmco[i].long_arg]=pic;
if (this.long_ref[mmco[i].long_arg] != null) {
this.long_ref[mmco[i].long_arg].long_ref=1;
this.long_ref_count++;
}
break;
case MMCO.MMCO_LONG2UNUSED:
int[] param=new int[]{structure};
j=pic_num_extract(mmco[i].long_arg,param);
structure=param[0];
pic=this.long_ref[j];
if (pic != null) {
remove_long(j,structure ^ MpegEncContext.PICT_FRAME);
}
break;
case MMCO.MMCO_LONG:
if (this.long_ref[mmco[i].long_arg] != s.current_picture_ptr) {
remove_long(mmco[i].long_arg,0);
this.long_ref[mmco[i].long_arg]=s.current_picture_ptr;
this.long_ref[mmco[i].long_arg].long_ref=1;
this.long_ref_count++;
}
s.current_picture_ptr.reference|=s.picture_structure;
current_ref_assigned=1;
break;
case MMCO.MMCO_SET_MAX_LONG:
for (j=mmco[i].long_arg; j < 16; j++) {
remove_long(j,0);
}
break;
case MMCO.MMCO_RESET:
while (this.short_ref_count != 0) {
remove_short(this.short_ref[0].frame_num,0);
}
for (j=0; j < 16; j++) {
remove_long(j,0);
}
s.current_picture_ptr.poc=s.current_picture_ptr.field_poc[0]=s.current_picture_ptr.field_poc[1]=this.poc_lsb=this.poc_msb=this.frame_num=s.current_picture_ptr.frame_num=0;
s.current_picture_ptr.mmco_reset=1;
break;
default :
}
}
if (0 == current_ref_assigned) {
if (0 != this.short_ref_count && this.short_ref[0] == s.current_picture_ptr) {
s.current_picture_ptr.reference=MpegEncContext.PICT_FRAME;
}
 else if (0 != s.current_picture_ptr.long_ref) {
}
 else {
pic=remove_short(s.current_picture_ptr.frame_num,0);
if (pic != null) {
}
if (this.short_ref_count != 0) {
for (int k=this.short_ref_count; k >= 1; k--) this.short_ref[k]=this.short_ref[k - 1];
}
this.short_ref[0]=s.current_picture_ptr;
this.short_ref_count++;
s.current_picture_ptr.reference|=s.picture_structure;
}
}
if (this.long_ref_count + this.short_ref_count > this.sps.ref_frame_count) {
if (this.long_ref_count != 0 && 0 == this.short_ref_count) {
for (i=0; i < 16; ++i) if (this.long_ref[i] != null) break;
remove_long(i,0);
}
 else {
pic=this.short_ref[this.short_ref_count - 1];
remove_short(pic.frame_num,0);
}
}
return 0;
}

Fixed version (ground truth):
public int ff_h264_execute_ref_pic_marking(MMCO[] mmco,int mmco_count){
  int i, j=0;
  int current_ref_assigned=0;
  AVFrame pic=null;
  for (i=0; i < mmco_count; i++) {
    int structure=0, frame_num=0;
    if (mmco[i].opcode == MMCO.MMCO_SHORT2UNUSED || mmco[i].opcode == MMCO.MMCO_SHORT2LONG) {
      int[] param=new int[1];
      frame_num=pic_num_extract(mmco[i].short_pic_num,param);
      structure=param[0];
      pic=find_short(frame_num,param);
      j=param[0];
      if (null == pic) {
        continue;
      }
    }
switch (mmco[i].opcode) {
case MMCO.MMCO_SHORT2UNUSED:
      remove_short(frame_num,structure ^ MpegEncContext.PICT_FRAME);
    break;
case MMCO.MMCO_SHORT2LONG:
  if (this.long_ref[mmco[i].long_arg] != pic)   remove_long(mmco[i].long_arg,0);
remove_short_at_index(j);
this.long_ref[mmco[i].long_arg]=pic;
if (this.long_ref[mmco[i].long_arg] != null) {
this.long_ref[mmco[i].long_arg].long_ref=1;
this.long_ref_count++;
}
break;
case MMCO.MMCO_LONG2UNUSED:
int[] param=new int[]{structure};
j=pic_num_extract(mmco[i].long_arg,param);
structure=param[0];
pic=this.long_ref[j];
if (pic != null) {
remove_long(j,structure ^ MpegEncContext.PICT_FRAME);
}
break;
case MMCO.MMCO_LONG:
if (this.long_ref[mmco[i].long_arg] != s.current_picture_ptr) {
remove_long(mmco[i].long_arg,0);
this.long_ref[mmco[i].long_arg]=s.current_picture_ptr;
this.long_ref[mmco[i].long_arg].long_ref=1;
this.long_ref_count++;
}
s.current_picture_ptr.reference|=s.picture_structure;
current_ref_assigned=1;
break;
case MMCO.MMCO_SET_MAX_LONG:
for (j=mmco[i].long_arg; j < 16; j++) {
remove_long(j,0);
}
break;
case MMCO.MMCO_RESET:
while (this.short_ref_count != 0) {
remove_short(this.short_ref[0].frame_num,0);
}
for (j=0; j < 16; j++) {
remove_long(j,0);
}
s.current_picture_ptr.poc=s.current_picture_ptr.field_poc[0]=s.current_picture_ptr.field_poc[1]=this.poc_lsb=this.poc_msb=this.frame_num=s.current_picture_ptr.frame_num=0;
s.current_picture_ptr.mmco_reset=1;
break;
default :
}
}
if (0 == current_ref_assigned) {
if (0 != this.short_ref_count && this.short_ref[0] == s.current_picture_ptr) {
s.current_picture_ptr.reference=MpegEncContext.PICT_FRAME;
}
 else if (0 != s.current_picture_ptr.long_ref) {
}
 else {
pic=remove_short(s.current_picture_ptr.frame_num,0);
if (pic != null) {
System.out.println("String_Node_Str" + pic);
}
if (this.short_ref_count != 0) {
for (int k=this.short_ref_count; k >= 1; k--) this.short_ref[k]=this.short_ref[k - 1];
}
this.short_ref[0]=s.current_picture_ptr;
this.short_ref_count++;
s.current_picture_ptr.reference|=s.picture_structure;
}
}
if (this.long_ref_count + this.short_ref_count > this.sps.ref_frame_count) {
if (this.long_ref_count != 0 && 0 == this.short_ref_count) {
for (i=0; i < 16; ++i) if (this.long_ref[i] != null) break;
remove_long(i,0);
}
 else {
pic=this.short_ref[this.short_ref_count - 1];
remove_short(pic.frame_num,0);
}
}
return 0;
}