Skip to content

Commit

Permalink
QSVEnc.auoのビルドを修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Jan 19, 2025
1 parent c4a7626 commit 2bb6823
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
50 changes: 49 additions & 1 deletion QSVPipeline/rgy_faw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,54 @@ static uint32_t faw_checksum_read(const uint8_t *buf) {
return v;
}

int RGYFAWAACHeader::sampleRateIdxToRate(const uint32_t idx) {
static const int samplerateList[] = {
96000,
88200,
64000,
48000,
44100,
32000,
24000,
22050,
16000,
12000,
11025,
8000,
7350,
0
};
return samplerateList[std::min<uint32_t>(idx, _countof(samplerateList)-1)];
}

int RGYFAWAACHeader::parse(const uint8_t *buf) {
int check = 0;
const uint8_t buf0 = buf[0];
const uint8_t buf1 = buf[1];
const uint8_t buf2 = buf[2];
const uint8_t buf3 = buf[3];
const uint8_t buf4 = buf[4];
const uint8_t buf5 = buf[5];
const uint8_t buf6 = buf[6];
check |= (buf0 & 0xFF) != 0xFF;
check |= (buf1 & 0xF0) != 0xF0;
check |= (buf1 & 0x06) != 0x00;
id = (buf1 & 0x08) != 0;
protection = (buf1 & 0x01) != 0;
profile = (buf2 & 0xC0) >> 6;
samplerate = sampleRateIdxToRate((buf2 & 0x3C) >> 2);
private_bit = (buf2 & 0x02) >> 1;
channel = ((buf2 & 0x01) << 2) | ((buf3 & 0xC0) >> 6);
original = (buf3 & 0x20) != 0;
home = (buf3 & 0x10) != 0;
copyright = (buf3 & 0x08) != 0;
copyright_start = (buf3 & 0x04) != 0;
aac_frame_length = ((buf3 & 0x03) << 11) | (buf4 << 3) | (buf5 >> 5);
adts_buffer_fullness = ((buf5 & 0x1f) << 6) | (buf6 >> 2);
no_raw_data_blocks_in_frame = buf6 & 0x03;
return check;
}

RGYFAWBitstream::RGYFAWBitstream() :
buffer(),
bufferOffset(0),
Expand All @@ -159,7 +207,7 @@ void RGYFAWBitstream::setBytePerSample(const int val) {
}

void RGYFAWBitstream::parseAACHeader(const uint8_t *buf) {
aacHeader.parse(buf, RGYAACHeader::HEADER_BYTE_SIZE);
aacHeader.parse(buf);
}

uint32_t RGYFAWBitstream::aacChannels() const {
Expand Down
22 changes: 20 additions & 2 deletions QSVPipeline/rgy_faw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <vector>
#include "rgy_wav_parser.h"
#include "rgy_memmem.h"
#include "rgy_bitstream.h"

static const std::array<uint8_t, 8> fawstart1 = {
0x72, 0xF8, 0x1F, 0x4E, 0x07, 0x01, 0x00, 0x00
Expand Down Expand Up @@ -74,6 +73,25 @@ enum class RGYFAWMode {
static const int AAC_HEADER_MIN_SIZE = 7;
static const uint32_t AAC_BLOCK_SAMPLES = 1024;

struct RGYFAWAACHeader {
bool id;
bool protection;
int profile; // 00 ... main, 01 ... lc, 10 ... ssr
int samplerate;
bool private_bit;
uint32_t channel;
bool original;
bool home;
bool copyright;
bool copyright_start;
uint32_t aac_frame_length; // AACヘッダを含む
int adts_buffer_fullness;
int no_raw_data_blocks_in_frame;

int parse(const uint8_t *buffer);
int sampleRateIdxToRate(const uint32_t idx);
};

class RGYFAWBitstream {
private:
std::vector<uint8_t> buffer;
Expand All @@ -84,7 +102,7 @@ class RGYFAWBitstream {
uint64_t inputLengthByte;
uint64_t outSamples;

RGYAACHeader aacHeader;
RGYFAWAACHeader aacHeader;
public:
RGYFAWBitstream();
~RGYFAWBitstream();
Expand Down

0 comments on commit 2bb6823

Please sign in to comment.