h264_refs: cosmetics, reformat
This commit is contained in:
		
							parent
							
								
									f08fefc4d0
								
							
						
					
					
						commit
						c2597c5a0a
					
				| @ -52,8 +52,8 @@ static void pic_as_field(Picture *pic, const int parity){ | |||||||
|     pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD]; |     pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int split_field_copy(Picture *dest, Picture *src, | static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add) | ||||||
|                             int parity, int id_add){ | { | ||||||
|     int match = !!(src->reference & parity); |     int match = !!(src->reference & parity); | ||||||
| 
 | 
 | ||||||
|     if (match) { |     if (match) { | ||||||
| @ -68,7 +68,8 @@ static int split_field_copy(Picture *dest, Picture *src, | |||||||
|     return match; |     return match; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){ | static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel) | ||||||
|  | { | ||||||
|     int  i[2] = { 0 }; |     int  i[2] = { 0 }; | ||||||
|     int index = 0; |     int index = 0; | ||||||
| 
 | 
 | ||||||
| @ -90,7 +91,8 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int | |||||||
|     return index; |     return index; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir){ | static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir) | ||||||
|  | { | ||||||
|     int i, best_poc; |     int i, best_poc; | ||||||
|     int out_i = 0; |     int out_i = 0; | ||||||
| 
 | 
 | ||||||
| @ -111,7 +113,8 @@ static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int d | |||||||
|     return out_i; |     return out_i; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int ff_h264_fill_default_ref_list(H264Context *h){ | int ff_h264_fill_default_ref_list(H264Context *h) | ||||||
|  | { | ||||||
|     int i, len; |     int i, len; | ||||||
| 
 | 
 | ||||||
|     if (h->slice_type_nos == AV_PICTURE_TYPE_B) { |     if (h->slice_type_nos == AV_PICTURE_TYPE_B) { | ||||||
| @ -155,11 +158,17 @@ int ff_h264_fill_default_ref_list(H264Context *h){ | |||||||
|     } |     } | ||||||
| #ifdef TRACE | #ifdef TRACE | ||||||
|     for (i = 0; i < h->ref_count[0]; i++) { |     for (i = 0; i < h->ref_count[0]; i++) { | ||||||
|         tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].f.data[0]); |         tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", | ||||||
|  |                 (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), | ||||||
|  |                 h->default_ref_list[0][i].pic_id, | ||||||
|  |                 h->default_ref_list[0][i].f.data[0]); | ||||||
|     } |     } | ||||||
|     if (h->slice_type_nos == AV_PICTURE_TYPE_B) { |     if (h->slice_type_nos == AV_PICTURE_TYPE_B) { | ||||||
|         for (i = 0; i < h->ref_count[1]; i++) { |         for (i = 0; i < h->ref_count[1]; i++) { | ||||||
|             tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].f.data[0]); |             tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", | ||||||
|  |                     (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), | ||||||
|  |                     h->default_ref_list[1][i].pic_id, | ||||||
|  |                     h->default_ref_list[1][i].f.data[0]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| @ -179,7 +188,8 @@ static void print_long_term(H264Context *h); | |||||||
|  * @return frame number (short term) or long term index of picture |  * @return frame number (short term) or long term index of picture | ||||||
|  *         described by pic_num |  *         described by pic_num | ||||||
|  */ |  */ | ||||||
| static int pic_num_extract(H264Context *h, int pic_num, int *structure){ | static int pic_num_extract(H264Context *h, int pic_num, int *structure) | ||||||
|  | { | ||||||
|     *structure = h->picture_structure; |     *structure = h->picture_structure; | ||||||
|     if (FIELD_PICTURE) { |     if (FIELD_PICTURE) { | ||||||
|         if (!(pic_num & 1)) |         if (!(pic_num & 1)) | ||||||
| @ -191,7 +201,8 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure){ | |||||||
|     return pic_num; |     return pic_num; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ | int ff_h264_decode_ref_pic_list_reordering(H264Context *h) | ||||||
|  | { | ||||||
|     int list, index, pic_structure, i; |     int list, index, pic_structure, i; | ||||||
| 
 | 
 | ||||||
|     print_short_term(h); |     print_short_term(h); | ||||||
| @ -228,8 +239,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ | |||||||
|                             return -1; |                             return -1; | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                         if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num; |                         if (reordering_of_pic_nums_idc == 0) | ||||||
|                         else                                pred+= abs_diff_pic_num; |                             pred -= abs_diff_pic_num; | ||||||
|  |                         else | ||||||
|  |                             pred += abs_diff_pic_num; | ||||||
|                         pred &= h->max_pic_num - 1; |                         pred &= h->max_pic_num - 1; | ||||||
| 
 | 
 | ||||||
|                         frame_num = pic_num_extract(h, pred, &pic_structure); |                         frame_num = pic_num_extract(h, pred, &pic_structure); | ||||||
| @ -238,10 +251,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ | |||||||
|                             ref = h->short_ref[i]; |                             ref = h->short_ref[i]; | ||||||
|                             assert(ref->reference); |                             assert(ref->reference); | ||||||
|                             assert(!ref->long_ref); |                             assert(!ref->long_ref); | ||||||
|                             if( |                             if (ref->frame_num == frame_num && | ||||||
|                                    ref->frame_num == frame_num && |                                 (ref->reference & pic_structure)) | ||||||
|                                    (ref->reference & pic_structure) |  | ||||||
|                               ) |  | ||||||
|                                 break; |                                 break; | ||||||
|                         } |                         } | ||||||
|                         if (i >= 0) |                         if (i >= 0) | ||||||
| @ -272,7 +283,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ | |||||||
|                         memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
 |                         memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
 | ||||||
|                     } else { |                     } else { | ||||||
|                         for (i = index; i + 1 < h->ref_count[list]; i++) { |                         for (i = index; i + 1 < h->ref_count[list]; i++) { | ||||||
|                             if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id) |                             if (ref->long_ref == h->ref_list[list][i].long_ref && | ||||||
|  |                                 ref->pic_id   == h->ref_list[list][i].pic_id) | ||||||
|                                 break; |                                 break; | ||||||
|                         } |                         } | ||||||
|                         for (; i > index; i--) { |                         for (; i > index; i--) { | ||||||
| @ -305,7 +317,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ff_h264_fill_mbaff_ref_list(H264Context *h){ | void ff_h264_fill_mbaff_ref_list(H264Context *h) | ||||||
|  | { | ||||||
|     int list, i, j; |     int list, i, j; | ||||||
|     for (list = 0; list < 2; list++) { //FIXME try list_count
 |     for (list = 0; list < 2; list++) { //FIXME try list_count
 | ||||||
|         for (i = 0; i < h->ref_count[list]; i++) { |         for (i = 0; i < h->ref_count[list]; i++) { | ||||||
| @ -343,7 +356,8 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){ | |||||||
|  *         for display purposes) zero if one of the fields remains in |  *         for display purposes) zero if one of the fields remains in | ||||||
|  *         reference |  *         reference | ||||||
|  */ |  */ | ||||||
| static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){ | static inline int unreference_pic(H264Context *h, Picture *pic, int refmask) | ||||||
|  | { | ||||||
|     int i; |     int i; | ||||||
|     if (pic->reference &= refmask) { |     if (pic->reference &= refmask) { | ||||||
|         return 0; |         return 0; | ||||||
| @ -365,7 +379,8 @@ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){ | |||||||
|  * @return pointer to the found picture, or NULL if no pic with the provided |  * @return pointer to the found picture, or NULL if no pic with the provided | ||||||
|  *                 frame number is found |  *                 frame number is found | ||||||
|  */ |  */ | ||||||
| static Picture * find_short(H264Context *h, int frame_num, int *idx){ | static Picture *find_short(H264Context *h, int frame_num, int *idx) | ||||||
|  | { | ||||||
|     int i; |     int i; | ||||||
| 
 | 
 | ||||||
|     for (i = 0; i < h->short_ref_count; i++) { |     for (i = 0; i < h->short_ref_count; i++) { | ||||||
| @ -386,18 +401,21 @@ static Picture * find_short(H264Context *h, int frame_num, int *idx){ | |||||||
|  * to be valid. Other list entries are shifted down. |  * to be valid. Other list entries are shifted down. | ||||||
|  * @param i index into h->short_ref of picture to remove. |  * @param i index into h->short_ref of picture to remove. | ||||||
|  */ |  */ | ||||||
| static void remove_short_at_index(H264Context *h, int i){ | static void remove_short_at_index(H264Context *h, int i) | ||||||
|  | { | ||||||
|     assert(i >= 0 && i < h->short_ref_count); |     assert(i >= 0 && i < h->short_ref_count); | ||||||
|     h->short_ref[i] = NULL; |     h->short_ref[i] = NULL; | ||||||
|     if (--h->short_ref_count) |     if (--h->short_ref_count) | ||||||
|         memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*)); |         memmove(&h->short_ref[i], &h->short_ref[i + 1], | ||||||
|  |                 (h->short_ref_count - i) * sizeof(Picture*)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * |  * | ||||||
|  * @return the removed picture or NULL if an error occurs |  * @return the removed picture or NULL if an error occurs | ||||||
|  */ |  */ | ||||||
| static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){ | static Picture *remove_short(H264Context *h, int frame_num, int ref_mask) | ||||||
|  | { | ||||||
|     Picture *pic; |     Picture *pic; | ||||||
|     int i; |     int i; | ||||||
| 
 | 
 | ||||||
| @ -418,7 +436,8 @@ static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){ | |||||||
|  * that list. |  * that list. | ||||||
|  * @return the removed picture or NULL if an error occurs |  * @return the removed picture or NULL if an error occurs | ||||||
|  */ |  */ | ||||||
| static Picture * remove_long(H264Context *h, int i, int ref_mask){ | static Picture *remove_long(H264Context *h, int i, int ref_mask) | ||||||
|  | { | ||||||
|     Picture *pic; |     Picture *pic; | ||||||
| 
 | 
 | ||||||
|     pic = h->long_ref[i]; |     pic = h->long_ref[i]; | ||||||
| @ -434,7 +453,8 @@ static Picture * remove_long(H264Context *h, int i, int ref_mask){ | |||||||
|     return pic; |     return pic; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ff_h264_remove_all_refs(H264Context *h){ | void ff_h264_remove_all_refs(H264Context *h) | ||||||
|  | { | ||||||
|     int i; |     int i; | ||||||
| 
 | 
 | ||||||
|     for (i = 0; i < 16; i++) { |     for (i = 0; i < 16; i++) { | ||||||
| @ -452,7 +472,8 @@ void ff_h264_remove_all_refs(H264Context *h){ | |||||||
| /**
 | /**
 | ||||||
|  * print short term list |  * print short term list | ||||||
|  */ |  */ | ||||||
| static void print_short_term(H264Context *h) { | static void print_short_term(H264Context *h) | ||||||
|  | { | ||||||
|     uint32_t i; |     uint32_t i; | ||||||
|     if (h->avctx->debug & FF_DEBUG_MMCO) { |     if (h->avctx->debug & FF_DEBUG_MMCO) { | ||||||
|         av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n"); |         av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n"); | ||||||
| @ -467,7 +488,8 @@ static void print_short_term(H264Context *h) { | |||||||
| /**
 | /**
 | ||||||
|  * print long term list |  * print long term list | ||||||
|  */ |  */ | ||||||
| static void print_long_term(H264Context *h) { | static void print_long_term(H264Context *h) | ||||||
|  | { | ||||||
|     uint32_t i; |     uint32_t i; | ||||||
|     if (h->avctx->debug & FF_DEBUG_MMCO) { |     if (h->avctx->debug & FF_DEBUG_MMCO) { | ||||||
|         av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n"); |         av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n"); | ||||||
| @ -527,7 +549,8 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count) | ||||||
|  | { | ||||||
|     int i, av_uninit(j); |     int i, av_uninit(j); | ||||||
|     int current_ref_assigned = 0, err = 0; |     int current_ref_assigned = 0, err = 0; | ||||||
|     Picture *av_uninit(pic); |     Picture *av_uninit(pic); | ||||||
| @ -538,15 +561,17 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | |||||||
|     for (i = 0; i < mmco_count; i++) { |     for (i = 0; i < mmco_count; i++) { | ||||||
|         int av_uninit(structure), av_uninit(frame_num); |         int av_uninit(structure), av_uninit(frame_num); | ||||||
|         if (h->avctx->debug & FF_DEBUG_MMCO) |         if (h->avctx->debug & FF_DEBUG_MMCO) | ||||||
|             av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg); |             av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, | ||||||
|  |                    h->mmco[i].short_pic_num, h->mmco[i].long_arg); | ||||||
| 
 | 
 | ||||||
|         if(   mmco[i].opcode == MMCO_SHORT2UNUSED |         if (mmco[i].opcode == MMCO_SHORT2UNUSED || | ||||||
|            || mmco[i].opcode == MMCO_SHORT2LONG){ |             mmco[i].opcode == MMCO_SHORT2LONG) { | ||||||
|             frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure); |             frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure); | ||||||
|             pic       = find_short(h, frame_num, &j); |             pic       = find_short(h, frame_num, &j); | ||||||
|             if (!pic) { |             if (!pic) { | ||||||
|                 if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg] |                 if (mmco[i].opcode != MMCO_SHORT2LONG || | ||||||
|                    || h->long_ref[mmco[i].long_arg]->frame_num != frame_num) { |                     !h->long_ref[mmco[i].long_arg]    || | ||||||
|  |                     h->long_ref[mmco[i].long_arg]->frame_num != frame_num) { | ||||||
|                     av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n"); |                     av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n"); | ||||||
|                     err = AVERROR_INVALIDDATA; |                     err = AVERROR_INVALIDDATA; | ||||||
|                 } |                 } | ||||||
| @ -557,7 +582,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | |||||||
|         switch (mmco[i].opcode) { |         switch (mmco[i].opcode) { | ||||||
|         case MMCO_SHORT2UNUSED: |         case MMCO_SHORT2UNUSED: | ||||||
|             if (h->avctx->debug & FF_DEBUG_MMCO) |             if (h->avctx->debug & FF_DEBUG_MMCO) | ||||||
|                 av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count); |                 av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", | ||||||
|  |                        h->mmco[i].short_pic_num, h->short_ref_count); | ||||||
|             remove_short(h, frame_num, structure ^ PICT_FRAME); |             remove_short(h, frame_num, structure ^ PICT_FRAME); | ||||||
|             break; |             break; | ||||||
|         case MMCO_SHORT2LONG: |         case MMCO_SHORT2LONG: | ||||||
| @ -613,8 +639,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | |||||||
|             for (j = 0; j < 16; j++) { |             for (j = 0; j < 16; j++) { | ||||||
|                 remove_long(h, j, 0); |                 remove_long(h, j, 0); | ||||||
|             } |             } | ||||||
|             h->frame_num= |             h->frame_num  = h->cur_pic_ptr->frame_num = 0; | ||||||
|             h->cur_pic_ptr->frame_num= 0; |  | ||||||
|             h->mmco_reset = 1; |             h->mmco_reset = 1; | ||||||
|             h->cur_pic_ptr->mmco_reset = 1; |             h->cur_pic_ptr->mmco_reset = 1; | ||||||
|             break; |             break; | ||||||
| @ -646,7 +671,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (h->short_ref_count) |             if (h->short_ref_count) | ||||||
|                 memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*)); |                 memmove(&h->short_ref[1], &h->short_ref[0], | ||||||
|  |                         h->short_ref_count * sizeof(Picture*)); | ||||||
| 
 | 
 | ||||||
|             h->short_ref[0] = h->cur_pic_ptr; |             h->short_ref[0] = h->cur_pic_ptr; | ||||||
|             h->short_ref_count++; |             h->short_ref_count++; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user