From 6dc412c17c16fa3735631cf0a9629bad526499dd Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Thu, 21 Jan 2016 15:52:24 +0800 Subject: Make intel_avc_find_skipemulcnt() a public function In addition, move intel_avc_find_skipemulcnt() to i965_encoder_utils.c Signed-off-by: Xiang, Haihao Reviewed-By: Sean V Kelley --- src/gen6_mfc_common.c | 52 ----------------------------------------------- src/i965_encoder_utils.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ src/i965_encoder_utils.h | 3 +++ 3 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c index e0d83b6..f961ecd 100644 --- a/src/gen6_mfc_common.c +++ b/src/gen6_mfc_common.c @@ -441,58 +441,6 @@ void intel_mfc_brc_prepare(struct encode_state *encode_state, } } -static int intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length) -{ - int i, found; - int leading_zero_cnt, byte_length, zero_byte; - int nal_unit_type; - int skip_cnt = 0; - -#define NAL_UNIT_TYPE_MASK 0x1f -#define HW_MAX_SKIP_LENGTH 15 - - byte_length = ALIGN(bits_length, 32) >> 3; - - - leading_zero_cnt = 0; - found = 0; - for(i = 0; i < byte_length - 4; i++) { - if (((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)) || - ((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 0) && (buf[i + 3] == 1))) { - found = 1; - break; - } - leading_zero_cnt++; - } - if (!found) { - /* warning message is complained. But anyway it will be inserted. */ - WARN_ONCE("Invalid packed header data. " - "Can't find the 000001 start_prefix code\n"); - return 0; - } - i = leading_zero_cnt; - - zero_byte = 0; - if (!((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1))) - zero_byte = 1; - - skip_cnt = leading_zero_cnt + zero_byte + 3; - - /* the unit header byte is accounted */ - nal_unit_type = (buf[skip_cnt]) & NAL_UNIT_TYPE_MASK; - skip_cnt += 1; - - if (nal_unit_type == 14 || nal_unit_type == 20 || nal_unit_type == 21) { - /* more unit header bytes are accounted for MVC/SVC */ - skip_cnt += 3; - } - if (skip_cnt > HW_MAX_SKIP_LENGTH) { - WARN_ONCE("Too many leading zeros are padded for packed data. " - "It is beyond the HW range.!!!\n"); - } - return skip_cnt; -} - void intel_mfc_avc_pipeline_header_programing(VADriverContextP ctx, struct encode_state *encode_state, struct intel_encoder_context *encoder_context, diff --git a/src/i965_encoder_utils.c b/src/i965_encoder_utils.c index bb8dbe4..ac58cd1 100644 --- a/src/i965_encoder_utils.c +++ b/src/i965_encoder_utils.c @@ -1134,3 +1134,56 @@ int build_hevc_slice_header(VAEncSequenceParameterBufferHEVC *seq_param, *header_buffer = (unsigned char *)bs.buffer; return bs.bit_offset; } + +int +intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length) +{ + int i, found; + int leading_zero_cnt, byte_length, zero_byte; + int nal_unit_type; + int skip_cnt = 0; + +#define NAL_UNIT_TYPE_MASK 0x1f +#define HW_MAX_SKIP_LENGTH 15 + + byte_length = ALIGN(bits_length, 32) >> 3; + + + leading_zero_cnt = 0; + found = 0; + for(i = 0; i < byte_length - 4; i++) { + if (((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)) || + ((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 0) && (buf[i + 3] == 1))) { + found = 1; + break; + } + leading_zero_cnt++; + } + if (!found) { + /* warning message is complained. But anyway it will be inserted. */ + WARN_ONCE("Invalid packed header data. " + "Can't find the 000001 start_prefix code\n"); + return 0; + } + i = leading_zero_cnt; + + zero_byte = 0; + if (!((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1))) + zero_byte = 1; + + skip_cnt = leading_zero_cnt + zero_byte + 3; + + /* the unit header byte is accounted */ + nal_unit_type = (buf[skip_cnt]) & NAL_UNIT_TYPE_MASK; + skip_cnt += 1; + + if (nal_unit_type == 14 || nal_unit_type == 20 || nal_unit_type == 21) { + /* more unit header bytes are accounted for MVC/SVC */ + skip_cnt += 3; + } + if (skip_cnt > HW_MAX_SKIP_LENGTH) { + WARN_ONCE("Too many leading zeros are padded for packed data. " + "It is beyond the HW range.!!!\n"); + } + return skip_cnt; +} diff --git a/src/i965_encoder_utils.h b/src/i965_encoder_utils.h index 14edaba..a63d242 100644 --- a/src/i965_encoder_utils.h +++ b/src/i965_encoder_utils.h @@ -62,4 +62,7 @@ build_hevc_idr_sei_buffer_timing(unsigned int init_cpb_removal_delay_length, unsigned int dpb_output_delay, unsigned char **sei_buffer); +int +intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length); + #endif /* __I965_ENCODER_UTILS_H__ */ -- cgit v1.2.3