00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "contributors.h"
00016
00017 #include <ctype.h>
00018 #include <limits.h>
00019 #include "global.h"
00020
00021 #include "image.h"
00022 #include "nalucommon.h"
00023 #include "report.h"
00024
00025
00026 void mmco_long_term(ImageParameters *p_Img, int current_pic_num)
00027 {
00028 DecRefPicMarking_t *tmp_drpm,*tmp_drpm2;
00029
00030 if (p_Img->dec_ref_pic_marking_buffer!=NULL)
00031 return;
00032
00033 if (NULL==(tmp_drpm=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t))))
00034 no_mem_exit("poc_based_ref_management: tmp_drpm");
00035
00036 tmp_drpm->Next=NULL;
00037
00038 tmp_drpm->memory_management_control_operation = 0;
00039
00040 if (NULL==(tmp_drpm2=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t))))
00041 no_mem_exit("poc_based_ref_management: tmp_drpm2");
00042 tmp_drpm2->Next=tmp_drpm;
00043
00044 tmp_drpm2->memory_management_control_operation = 3;
00045 tmp_drpm2->long_term_frame_idx = current_pic_num;
00046 p_Img->dec_ref_pic_marking_buffer = tmp_drpm2;
00047 p_Img->long_term_reference_flag = TRUE;
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057 void poc_based_ref_management_frame_pic(ImageParameters *p_Img, int current_pic_num)
00058 {
00059 unsigned i, pic_num = 0;
00060
00061 int min_poc=INT_MAX;
00062 DecRefPicMarking_t *tmp_drpm,*tmp_drpm2;
00063
00064 if (p_Img->dec_ref_pic_marking_buffer!=NULL)
00065 return;
00066
00067 if ((p_Img->p_Dpb->ref_frames_in_buffer + p_Img->p_Dpb->ltref_frames_in_buffer)==0)
00068 return;
00069
00070 for (i = 0; i < p_Img->p_Dpb->used_size; i++)
00071 {
00072 if (p_Img->p_Dpb->fs[i]->is_reference && (!(p_Img->p_Dpb->fs[i]->is_long_term)) && p_Img->p_Dpb->fs[i]->poc < min_poc)
00073 {
00074 min_poc = p_Img->p_Dpb->fs[i]->frame->poc ;
00075 pic_num = p_Img->p_Dpb->fs[i]->frame->pic_num;
00076 }
00077 }
00078
00079 if (NULL==(tmp_drpm=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t))))
00080 no_mem_exit("poc_based_ref_management: tmp_drpm");
00081 tmp_drpm->Next=NULL;
00082
00083 tmp_drpm->memory_management_control_operation = 0;
00084
00085 if (NULL==(tmp_drpm2=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t))))
00086 no_mem_exit("poc_based_ref_management: tmp_drpm2");
00087 tmp_drpm2->Next=tmp_drpm;
00088
00089 tmp_drpm2->memory_management_control_operation = 1;
00090 tmp_drpm2->difference_of_pic_nums_minus1 = current_pic_num - pic_num - 1;
00091 p_Img->dec_ref_pic_marking_buffer = tmp_drpm2;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101 void poc_based_ref_management_field_pic(ImageParameters *p_Img, int current_pic_num)
00102 {
00103 unsigned int i, pic_num1 = 0, pic_num2 = 0;
00104
00105 int min_poc=INT_MAX;
00106 DecRefPicMarking_t *tmp_drpm,*tmp_drpm2, *tmp_drpm3;
00107
00108 if (p_Img->dec_ref_pic_marking_buffer!=NULL)
00109 return;
00110
00111 if ((p_Img->p_Dpb->ref_frames_in_buffer+p_Img->p_Dpb->ltref_frames_in_buffer)==0)
00112 return;
00113
00114 if ( p_Img->structure == TOP_FIELD )
00115 {
00116 for (i=0; i<p_Img->p_Dpb->used_size;i++)
00117 {
00118 if (p_Img->p_Dpb->fs[i]->is_reference && (!(p_Img->p_Dpb->fs[i]->is_long_term)) && p_Img->p_Dpb->fs[i]->poc < min_poc)
00119 {
00120 min_poc = p_Img->p_Dpb->fs[i]->poc;
00121 pic_num1 = p_Img->p_Dpb->fs[i]->top_field->pic_num;
00122 pic_num2 = p_Img->p_Dpb->fs[i]->bottom_field->pic_num;
00123 }
00124 }
00125 }
00126
00127 if (NULL==(tmp_drpm=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t)))) no_mem_exit("poc_based_ref_management_field_pic: tmp_drpm");
00128 tmp_drpm->Next=NULL;
00129 tmp_drpm->memory_management_control_operation = 0;
00130
00131 if ( p_Img->structure == BOTTOM_FIELD )
00132 {
00133 p_Img->dec_ref_pic_marking_buffer = tmp_drpm;
00134 return;
00135 }
00136
00137 if (NULL==(tmp_drpm2=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t)))) no_mem_exit("poc_based_ref_management_field_pic: tmp_drpm2");
00138 tmp_drpm2->Next=tmp_drpm;
00139 tmp_drpm2->memory_management_control_operation = 1;
00140 tmp_drpm2->difference_of_pic_nums_minus1 = current_pic_num - pic_num1 - 1;
00141
00142 if (NULL==(tmp_drpm3=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t)))) no_mem_exit("poc_based_ref_management_field_pic: tmp_drpm3");
00143 tmp_drpm3->Next=tmp_drpm2;
00144 tmp_drpm3->memory_management_control_operation = 1;
00145 tmp_drpm3->difference_of_pic_nums_minus1 = current_pic_num - pic_num2 - 1;
00146
00147 p_Img->dec_ref_pic_marking_buffer = tmp_drpm3;
00148 }
00149