• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/intel-driver


Commit MetaInfo

Revision6dc412c17c16fa3735631cf0a9629bad526499dd (tree)
Time2016-05-09 17:52:22
AuthorXiang, Haihao <haihao.xiang@inte...>
CommiterXiang, Haihao

Log Message

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 <haihao.xiang@intel.com>
Reviewed-By: Sean V Kelley <sean.v.kelley@intel.com>

Change Summary

Incremental Difference

--- 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,
441441 }
442442 }
443443
444-static int intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length)
445-{
446- int i, found;
447- int leading_zero_cnt, byte_length, zero_byte;
448- int nal_unit_type;
449- int skip_cnt = 0;
450-
451-#define NAL_UNIT_TYPE_MASK 0x1f
452-#define HW_MAX_SKIP_LENGTH 15
453-
454- byte_length = ALIGN(bits_length, 32) >> 3;
455-
456-
457- leading_zero_cnt = 0;
458- found = 0;
459- for(i = 0; i < byte_length - 4; i++) {
460- if (((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)) ||
461- ((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 0) && (buf[i + 3] == 1))) {
462- found = 1;
463- break;
464- }
465- leading_zero_cnt++;
466- }
467- if (!found) {
468- /* warning message is complained. But anyway it will be inserted. */
469- WARN_ONCE("Invalid packed header data. "
470- "Can't find the 000001 start_prefix code\n");
471- return 0;
472- }
473- i = leading_zero_cnt;
474-
475- zero_byte = 0;
476- if (!((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)))
477- zero_byte = 1;
478-
479- skip_cnt = leading_zero_cnt + zero_byte + 3;
480-
481- /* the unit header byte is accounted */
482- nal_unit_type = (buf[skip_cnt]) & NAL_UNIT_TYPE_MASK;
483- skip_cnt += 1;
484-
485- if (nal_unit_type == 14 || nal_unit_type == 20 || nal_unit_type == 21) {
486- /* more unit header bytes are accounted for MVC/SVC */
487- skip_cnt += 3;
488- }
489- if (skip_cnt > HW_MAX_SKIP_LENGTH) {
490- WARN_ONCE("Too many leading zeros are padded for packed data. "
491- "It is beyond the HW range.!!!\n");
492- }
493- return skip_cnt;
494-}
495-
496444 void intel_mfc_avc_pipeline_header_programing(VADriverContextP ctx,
497445 struct encode_state *encode_state,
498446 struct intel_encoder_context *encoder_context,
--- a/src/i965_encoder_utils.c
+++ b/src/i965_encoder_utils.c
@@ -1134,3 +1134,56 @@ int build_hevc_slice_header(VAEncSequenceParameterBufferHEVC *seq_param,
11341134 *header_buffer = (unsigned char *)bs.buffer;
11351135 return bs.bit_offset;
11361136 }
1137+
1138+int
1139+intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length)
1140+{
1141+ int i, found;
1142+ int leading_zero_cnt, byte_length, zero_byte;
1143+ int nal_unit_type;
1144+ int skip_cnt = 0;
1145+
1146+#define NAL_UNIT_TYPE_MASK 0x1f
1147+#define HW_MAX_SKIP_LENGTH 15
1148+
1149+ byte_length = ALIGN(bits_length, 32) >> 3;
1150+
1151+
1152+ leading_zero_cnt = 0;
1153+ found = 0;
1154+ for(i = 0; i < byte_length - 4; i++) {
1155+ if (((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)) ||
1156+ ((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 0) && (buf[i + 3] == 1))) {
1157+ found = 1;
1158+ break;
1159+ }
1160+ leading_zero_cnt++;
1161+ }
1162+ if (!found) {
1163+ /* warning message is complained. But anyway it will be inserted. */
1164+ WARN_ONCE("Invalid packed header data. "
1165+ "Can't find the 000001 start_prefix code\n");
1166+ return 0;
1167+ }
1168+ i = leading_zero_cnt;
1169+
1170+ zero_byte = 0;
1171+ if (!((buf[i] == 0) && (buf[i + 1] == 0) && (buf[i + 2] == 1)))
1172+ zero_byte = 1;
1173+
1174+ skip_cnt = leading_zero_cnt + zero_byte + 3;
1175+
1176+ /* the unit header byte is accounted */
1177+ nal_unit_type = (buf[skip_cnt]) & NAL_UNIT_TYPE_MASK;
1178+ skip_cnt += 1;
1179+
1180+ if (nal_unit_type == 14 || nal_unit_type == 20 || nal_unit_type == 21) {
1181+ /* more unit header bytes are accounted for MVC/SVC */
1182+ skip_cnt += 3;
1183+ }
1184+ if (skip_cnt > HW_MAX_SKIP_LENGTH) {
1185+ WARN_ONCE("Too many leading zeros are padded for packed data. "
1186+ "It is beyond the HW range.!!!\n");
1187+ }
1188+ return skip_cnt;
1189+}
--- 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,
6262 unsigned int dpb_output_delay,
6363 unsigned char **sei_buffer);
6464
65+int
66+intel_avc_find_skipemulcnt(unsigned char *buf, int bits_length);
67+
6568 #endif /* __I965_ENCODER_UTILS_H__ */