* basic parser create

* adding data_stream

* buildable parser

* query output and required fucntions

* latest changes

* alloc buffer and other functions

* parses first frame

* parser finds all frames

* parser dump size correct - dump file included

* clean up

* merge conflicts and file restructure

* uses updated video demuxer

* undoing changes to sample app

* cleaning code

* cleaning code

* removing dwarf flag from compile

* formatting changes

* change variable names as per google standard

* struct naming convention

* struct name

* remove parser data class and combine into parser buffer

* remove context class and clean up

* remove log file and use commons

* move class to .h file

* removing unused functions

* removes platform.h

* removing datastream class

* formatting

* remove byte_array, rename enums

* clean up

* spacing

* rearrange to fit master

* removes bit_strea_parser class, combines common stuff to roc_video_parser file

[ROCm/rocdecode commit: 4ca0d02bb0]
Этот коммит содержится в:
Lakshmi Kumar
2023-10-05 08:20:07 -07:00
коммит произвёл GitHub
родитель dcc6ee9f2a
Коммит 04f3ecc0e9
6 изменённых файлов: 1950 добавлений и 9 удалений
+114
Просмотреть файл
@@ -51,3 +51,117 @@ protected:
PFNVIDDISPLAYCALLBACK pfn_display_picture_cb_; /**< Called whenever a picture is ready to be displayed (display order) */
PFNVIDSEIMSGCALLBACK pfn_get_sei_message_cb_; /**< Called when all SEI messages are parsed for particular frame */
};
enum ParserSeekOrigin {
PARSER_SEEK_BEGIN = 0,
PARSER_SEEK_CURRENT = 1,
PARSER_SEEK_END = 2,
};
typedef enum ParserResult {
PARSER_OK = 0,
PARSER_FAIL ,
// common errors
PARSER_UNEXPECTED ,
PARSER_ACCESS_DENIED ,
PARSER_INVALID_ARG ,
PARSER_OUT_OF_RANGE ,
PARSER_OUT_OF_MEMORY ,
PARSER_INVALID_POINTER ,
PARSER_NO_INTERFACE ,
PARSER_NOT_IMPLEMENTED ,
PARSER_NOT_SUPPORTED ,
PARSER_NOT_FOUND ,
PARSER_ALREADY_INITIALIZED ,
PARSER_NOT_INITIALIZED ,
PARSER_INVALID_FORMAT ,// invalid data format
PARSER_WRONG_STATE ,
PARSER_FILE_NOT_OPEN ,// cannot open file
PARSER_STREAM_NOT_ALLOCATED ,
// device common codes
PARSER_NO_DEVICE ,
//result codes
PARSER_EOF ,
PARSER_REPEAT ,
//error codes
PARSER_INVALID_DATA_TYPE ,//invalid data type
PARSER_INVALID_RESOLUTION ,//invalid resolution (width or height)
PARSER_CODEC_NOT_SUPPORTED ,//codec not supported
} ParserResult;
// helpers
namespace Parser {
inline char GetLowByte(uint16_t data) {
return (data >> 8);
}
inline char GetHiByte(uint16_t data) {
return (data & 0xFF);
}
inline bool GetBit(const uint8_t *data, size_t &bit_idx) {
bool ret = (data[bit_idx / 8] >> (7 - bit_idx % 8) & 1);
bit_idx++;
return ret;
}
inline uint32_t GetBitToUint32(const uint8_t *data, size_t &bit_idx) {
uint32_t ret = (data[bit_idx / 8] >> (7 - bit_idx % 8) & 1);
bit_idx++;
return ret;
}
inline uint32_t ReadBits(const uint8_t *data, size_t &start_bit_idx, size_t bits_to_read) {
if (bits_to_read > 32) {
return 0; // assert(0);
}
uint32_t result = 0;
for (size_t i = 0; i < bits_to_read; i++) {
result = result << 1;
result |= GetBitToUint32(data, start_bit_idx); // start_bit_idx incremented inside
}
return result;
}
inline size_t CountContiniusZeroBits(const uint8_t *data, size_t &start_bit_idx) {
size_t start_bit_idx_org = start_bit_idx;
while (GetBit(data, start_bit_idx) == false) {} // start_bit_idx incremented inside
start_bit_idx--; // remove non zero
return start_bit_idx - start_bit_idx_org;
}
namespace ExpGolomb {
inline uint32_t ReadUe(const uint8_t *data, size_t &start_bit_idx) {
size_t zero_bits_count = CountContiniusZeroBits(data, start_bit_idx); // start_bit_idx incremented inside
if (zero_bits_count > 30) {
return 0; // assert(0)
}
uint32_t left_part = (0x1 << zero_bits_count) - 1;
start_bit_idx++;
uint32_t rightPart = ReadBits(data, start_bit_idx, zero_bits_count);
return left_part + rightPart;
}
inline uint32_t ReadSe(const uint8_t *data, size_t &start_bit_idx) {
uint32_t ue = ReadUe(data, start_bit_idx);
// se From Ue
uint32_t mod2 = ue % 2;
uint32_t r = ue / 2 + mod2;
if (mod2 == 0) {
return r * -1;
}
return r;
}
}
}