rename fidx -> bidx

This commit is contained in:
falsycat 2022-09-09 11:26:01 +09:00
parent 73af0a3069
commit a6dd9dfa88
4 changed files with 26 additions and 26 deletions

View File

@ -1,11 +1,11 @@
add_executable(dcode_fcode common.hh dcode_fcode.cc) add_executable(dcode_fcode common.hh dcode_fcode.cc)
target_link_libraries(dcode_fcode PRIVATE args) target_link_libraries(dcode_fcode PRIVATE args)
add_executable(fcode_fidx common.hh fcode_fidx.cc) add_executable(fcode_bidx common.hh fcode_bidx.cc)
target_link_libraries(fcode_fidx PRIVATE args) target_link_libraries(fcode_bidx PRIVATE args)
add_executable(fidx_stego common.hh fidx_stego.cc) add_executable(bidx_stego common.hh bidx_stego.cc)
target_link_libraries(fidx_stego PRIVATE args minimp4 openh264) target_link_libraries(bidx_stego PRIVATE args minimp4 openh264)
add_executable(stego_fprob common.hh stego_fprob.cc) add_executable(stego_fprob common.hh stego_fprob.cc)
target_link_libraries(stego_fprob PRIVATE args minimp4 openh264) target_link_libraries(stego_fprob PRIVATE args minimp4 openh264)

View File

@ -21,7 +21,7 @@ namespace param {
using namespace ::args; using namespace ::args;
ArgumentParser parser { ArgumentParser parser {
"converter: feature indices + host -> stego" "converter: block indices + host -> stego"
}; };
HelpFlag help { HelpFlag help {
parser, "help", "display this menu", {'h', "help"}, parser, "help", "display this menu", {'h', "help"},
@ -147,19 +147,19 @@ static void Exec() {
} }
} }
Enforce(ti < dem.track_count, "no video track"); Enforce(ti < dem.track_count, "no video track");
const auto& t = dem.track[ti]; const auto& tra = dem.track[ti];
// calc params // calc params
const auto tscale = t.timescale; const auto tscale = tra.timescale;
const auto dur = const auto dur =
(static_cast<uint64_t>(t.duration_hi) << 32) | (static_cast<uint64_t>(tra.duration_hi) << 32) |
static_cast<uint64_t>(t.duration_lo); static_cast<uint64_t>(tra.duration_lo);
const auto dursec = static_cast<float>(dur)/static_cast<float>(tscale); const auto dursec = static_cast<float>(dur)/static_cast<float>(tscale);
const float fps = static_cast<float>(t.sample_count)/dursec; const float fps = static_cast<float>(tra.sample_count)/dursec;
const auto fps9 = static_cast<int>(90000/fps); const auto fps9 = static_cast<int>(90000/fps);
const int32_t w = t.SampleDescription.video.width; const int32_t w = tra.SampleDescription.video.width;
const int32_t h = t.SampleDescription.video.height; const int32_t h = tra.SampleDescription.video.height;
// init encoder // init encoder
ISVCEncoder* enc; ISVCEncoder* enc;
@ -218,8 +218,8 @@ static void Exec() {
// decode frame // decode frame
Frame bf = {}; Frame bf = {};
int32_t fidx = 0; int32_t t = 0;
for (size_t si = 0; si < t.sample_count; ++si) { for (size_t si = 0; si < tra.sample_count; ++si) {
unsigned fsz, time, dur; unsigned fsz, time, dur;
const auto off = MP4D_frame_offset(&dem, ti, si, &fsz, &time, &dur); const auto off = MP4D_frame_offset(&dem, ti, si, &fsz, &time, &dur);
@ -249,8 +249,8 @@ static void Exec() {
if (frame.iBufferStatus) { if (frame.iBufferStatus) {
// alter the frame if it's not the first // alter the frame if it's not the first
Frame cf = {yuv, frame}; Frame cf = {yuv, frame};
if (fidx%ut > 0) { if (t%ut > 0) {
Embed(fidx/ut, cf, bf); Embed(t/ut, cf, bf);
} }
// encode // encode
@ -274,10 +274,10 @@ static void Exec() {
} }
// save the frame if it's the first // save the frame if it's the first
if (fidx%ut == 0) { if (t%ut == 0) {
bf = std::move(cf); bf = std::move(cf);
} }
++fidx; ++t;
} }
i += sz; i += sz;
} }

View File

@ -11,7 +11,7 @@ namespace param {
using namespace ::args; using namespace ::args;
ArgumentParser parser { ArgumentParser parser {
"converter: feature codes -> feature indices" "converter: feature codes -> block indices"
}; };
HelpFlag help { HelpFlag help {
parser, "help", "display this menu", {'h', "help"}, parser, "help", "display this menu", {'h', "help"},

View File

@ -232,13 +232,13 @@ static void Exec() {
// find video track // find video track
int ti; int ti;
for (ti = 0; ti < dem.track_count; ++ti) { for (ti = 0; ti < dem.track_count; ++ti) {
const auto& t = dem.track[ti]; const auto& tra = dem.track[ti];
if (t.handler_type == MP4D_HANDLER_TYPE_VIDE) { if (tra.handler_type == MP4D_HANDLER_TYPE_VIDE) {
break; break;
} }
} }
Enforce(ti < dem.track_count, "no video track"); Enforce(ti < dem.track_count, "no video track");
const auto& t = dem.track[ti]; const auto& tra = dem.track[ti];
// consume SPS // consume SPS
std::vector<uint8_t> nal; std::vector<uint8_t> nal;
@ -265,8 +265,8 @@ static void Exec() {
// decode frame // decode frame
Frame pf = {}; Frame pf = {};
size_t fidx = 0; size_t t = 0;
for (size_t si = 0; si < t.sample_count; ++si) { for (size_t si = 0; si < tra.sample_count; ++si) {
unsigned fsz, time, dur; unsigned fsz, time, dur;
const auto off = MP4D_frame_offset(&dem, ti, si, &fsz, &time, &dur); const auto off = MP4D_frame_offset(&dem, ti, si, &fsz, &time, &dur);
@ -294,13 +294,13 @@ static void Exec() {
Frame cf = {yuv, frame}; Frame cf = {yuv, frame};
if (cf.w == 0 || cf.h == 0) continue; if (cf.w == 0 || cf.h == 0) continue;
const auto utf = fidx%ut; const auto utf = t%ut;
if (utf > 0) { if (utf > 0) {
EachFrame(utf, cf, pf); EachFrame(utf, cf, pf);
} }
pf = std::move(cf); pf = std::move(cf);
++fidx; ++t;
} }
} }
} }