hevc: Use switch instead of if-nests in decode_nal_sei_message
Makes simpler to add support for more SEI types. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
		
							parent
							
								
									2cd841c077
								
							
						
					
					
						commit
						043f46f574
					
				@ -53,7 +53,7 @@ enum HEVC_SEI_TYPE {
 | 
				
			|||||||
    SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
 | 
					    SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
 | 
					static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int cIdx, i;
 | 
					    int cIdx, i;
 | 
				
			||||||
    GetBitContext *gb = &s->HEVClc.gb;
 | 
					    GetBitContext *gb = &s->HEVClc.gb;
 | 
				
			||||||
@ -72,9 +72,10 @@ static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
 | 
				
			|||||||
            skip_bits(gb, 32);
 | 
					            skip_bits(gb, 32);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 | 
					static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    GetBitContext *gb = &s->HEVClc.gb;
 | 
					    GetBitContext *gb = &s->HEVClc.gb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -97,9 +98,10 @@ static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 | 
				
			|||||||
        skip_bits1(gb);         // frame_packing_arrangement_persistance_flag
 | 
					        skip_bits1(gb);         // frame_packing_arrangement_persistance_flag
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    skip_bits1(gb);             // upsampled_aspect_ratio_flag
 | 
					    skip_bits1(gb);             // upsampled_aspect_ratio_flag
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void decode_nal_sei_display_orientation(HEVCContext *s)
 | 
					static int decode_nal_sei_display_orientation(HEVCContext *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    GetBitContext *gb = &s->HEVClc.gb;
 | 
					    GetBitContext *gb = &s->HEVClc.gb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -112,6 +114,8 @@ static void decode_nal_sei_display_orientation(HEVCContext *s)
 | 
				
			|||||||
        s->sei_anticlockwise_rotation = get_bits(gb, 16);
 | 
					        s->sei_anticlockwise_rotation = get_bits(gb, 16);
 | 
				
			||||||
        skip_bits1(gb);     // display_orientation_persistence_flag
 | 
					        skip_bits1(gb);     // display_orientation_persistence_flag
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int decode_nal_sei_message(HEVCContext *s)
 | 
					static int decode_nal_sei_message(HEVCContext *s)
 | 
				
			||||||
@ -133,22 +137,26 @@ static int decode_nal_sei_message(HEVCContext *s)
 | 
				
			|||||||
        payload_size += byte;
 | 
					        payload_size += byte;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (s->nal_unit_type == NAL_SEI_PREFIX) {
 | 
					    if (s->nal_unit_type == NAL_SEI_PREFIX) {
 | 
				
			||||||
        if (payload_type == 256) // Mismatched value from HM 8.1
 | 
					        switch (payload_type) {
 | 
				
			||||||
            decode_nal_sei_decoded_picture_hash(s);
 | 
					        case 256:  // Mismatched value from HM 8.1
 | 
				
			||||||
        else if (payload_type == SEI_TYPE_FRAME_PACKING)
 | 
					            return decode_nal_sei_decoded_picture_hash(s);
 | 
				
			||||||
            decode_nal_sei_frame_packing_arrangement(s);
 | 
					        case SEI_TYPE_FRAME_PACKING:
 | 
				
			||||||
        else if (payload_type == SEI_TYPE_DISPLAY_ORIENTATION)
 | 
					            return decode_nal_sei_frame_packing_arrangement(s);
 | 
				
			||||||
            decode_nal_sei_display_orientation(s);
 | 
					        case SEI_TYPE_DISPLAY_ORIENTATION:
 | 
				
			||||||
        else {
 | 
					            return decode_nal_sei_display_orientation(s);
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
            av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type);
 | 
					            av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type);
 | 
				
			||||||
            skip_bits(gb, 8 * payload_size);
 | 
					            skip_bits(gb, 8 * payload_size);
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else { /* nal_unit_type == NAL_SEI_SUFFIX */
 | 
					    } else { /* nal_unit_type == NAL_SEI_SUFFIX */
 | 
				
			||||||
        if (payload_type == SEI_TYPE_DECODED_PICTURE_HASH)
 | 
					        switch (payload_type) {
 | 
				
			||||||
            decode_nal_sei_decoded_picture_hash(s);
 | 
					        case SEI_TYPE_DECODED_PICTURE_HASH:
 | 
				
			||||||
        else {
 | 
					            return decode_nal_sei_decoded_picture_hash(s);
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
            av_log(s->avctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", payload_type);
 | 
					            av_log(s->avctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", payload_type);
 | 
				
			||||||
            skip_bits(gb, 8 * payload_size);
 | 
					            skip_bits(gb, 8 * payload_size);
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user