-
Notifications
You must be signed in to change notification settings - Fork 3
/
traceb24.cpp
1090 lines (1044 loc) · 66.3 KB
/
traceb24.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "traceb24.hpp"
#include <algorithm>
CTraceB24Caption::CTraceB24Caption()
: m_fp(nullptr)
, m_firstPmtPid(0)
, m_captionPid(0)
, m_superimposePid(0)
, m_pcrPid(0)
, m_pcr(-1)
{
static const PAT zeroPat = {};
m_pat = zeroPat;
m_firstPmtPsi = zeroPat.psi;
}
void CTraceB24Caption::AddPacket(const uint8_t *packet)
{
if (!m_fp) {
return;
}
int unitStart = extract_ts_header_unit_start(packet);
int pid = extract_ts_header_pid(packet);
int adaptation = extract_ts_header_adaptation(packet);
int counter = extract_ts_header_counter(packet);
int payloadSize = get_ts_payload_size(packet);
const uint8_t *payload = packet + 188 - payloadSize;
if (pid == 0) {
extract_pat(&m_pat, payload, payloadSize, unitStart, counter);
auto itFirstPmt = std::find_if(m_pat.pmt.begin(), m_pat.pmt.end(), [](const PMT_REF &pmt) { return pmt.program_number != 0; });
if (m_firstPmtPid != 0 && (itFirstPmt == m_pat.pmt.end() || itFirstPmt->pmt_pid != m_firstPmtPid)) {
m_firstPmtPid = 0;
static const PSI zeroPsi = {};
m_firstPmtPsi = zeroPsi;
}
if (itFirstPmt != m_pat.pmt.end()) {
m_firstPmtPid = itFirstPmt->pmt_pid;
}
}
else if (pid == m_firstPmtPid) {
int done;
do {
done = extract_psi(&m_firstPmtPsi, payload, payloadSize, unitStart, counter);
if (m_firstPmtPsi.version_number && m_firstPmtPsi.table_id == 2) {
CheckPmt(m_firstPmtPsi);
}
}
while (!done);
}
else if (pid == m_pcrPid) {
if (adaptation & 2) {
int adaptationLength = packet[4];
if (adaptationLength >= 6 && !!(packet[5] & 0x10)) {
bool firstPcr = m_pcr < 0;
m_pcr = (packet[10] >> 7) |
(packet[9] << 1) |
(packet[8] << 9) |
(packet[7] << 17) |
(static_cast<int64_t>(packet[6]) << 25);
if (firstPcr) {
fprintf(m_fp, "pcrpid=0x%04X;pcr=%010lld\n", m_pcrPid, static_cast<long long>(m_pcr));
fflush(m_fp);
}
}
}
}
else if (pid == m_captionPid || pid == m_superimposePid) {
auto &pesPair = pid == m_captionPid ? m_captionPes : m_superimposePes;
int &pesCounter = pesPair.first;
std::vector<uint8_t> &pes = pesPair.second;
if (unitStart) {
pesCounter = counter;
pes.assign(payload, payload + payloadSize);
}
else if (!pes.empty()) {
pesCounter = (pesCounter + 1) & 0x0f;
if (pesCounter == counter) {
pes.insert(pes.end(), payload, payload + payloadSize);
}
else {
// Ignore packets until the next unit-start
pes.clear();
}
}
if (pes.size() >= 6) {
size_t pesPacketLength = (pes[4] << 8) | pes[5];
if (pes.size() >= 6 + pesPacketLength) {
// PES has been accumulated
pes.resize(6 + pesPacketLength);
OutputPrivateDataPes(pes, pid == m_captionPid ? m_captionDrcsList : m_superimposeDrcsList,
pid == m_captionPid ? m_captionLangTags : m_superimposeLangTags);
pes.clear();
}
}
}
}
void CTraceB24Caption::CheckPmt(const PSI &psi)
{
const uint8_t PES_PRIVATE_DATA = 0x06;
if (psi.section_length < 9) {
return;
}
const uint8_t *table = psi.data;
m_pcrPid = ((table[8] & 0x1f) << 8) | table[9];
if (m_pcrPid == 0x1fff) {
m_pcr = -1;
}
int programInfoLength = ((table[10] & 0x03) << 8) | table[11];
int pos = 3 + 9 + programInfoLength;
if (psi.section_length < pos) {
return;
}
int captionPid = 0;
int superimposePid = 0;
int tableLen = 3 + psi.section_length - 4/*CRC32*/;
while (pos + 4 < tableLen) {
int streamType = table[pos];
int esPid = ((table[pos + 1] & 0x1f) << 8) | table[pos + 2];
int esInfoLength = ((table[pos + 3] & 0x03) << 8) | table[pos + 4];
if (pos + 5 + esInfoLength <= tableLen) {
int componentTag = 0xff;
for (int i = pos + 5; i + 2 < pos + 5 + esInfoLength; i += 2 + table[i + 1]) {
// stream_identifier_descriptor
if (table[i] == 0x52) {
componentTag = table[i + 2];
break;
}
}
// ARIB caption/superimpose ("A-Profile" only)
if (streamType == PES_PRIVATE_DATA &&
(componentTag == 0x30 || componentTag == 0x38)) {
if (componentTag == 0x30) {
captionPid = esPid;
}
else {
superimposePid = esPid;
}
}
}
pos += 5 + esInfoLength;
}
if (m_captionPid != captionPid) {
m_captionPid = captionPid;
m_captionPes.second.clear();
m_captionDrcsList.clear();
std::fill_n(m_captionLangTags, 8, LANG_TAG_ABSENT);
}
if (m_superimposePid != superimposePid) {
m_superimposePid = superimposePid;
m_superimposePes.second.clear();
m_superimposeDrcsList.clear();
std::fill_n(m_superimposeLangTags, 8, LANG_TAG_ABSENT);
}
}
void CTraceB24Caption::OutputPrivateDataPes(const std::vector<uint8_t> &pes,
std::vector<uint16_t> &drcsList, LANG_TAG_TYPE (&langTags)[8])
{
const uint8_t PRIVATE_STREAM_1 = 0xbd;
const uint8_t PRIVATE_STREAM_2 = 0xbf;
size_t payloadPos = 0;
int64_t pts = -1;
if (pes[0] == 0 && pes[1] == 0 && pes[2] == 1) {
int streamID = pes[3];
if (streamID == PRIVATE_STREAM_1 && pes.size() >= 9) {
int ptsDtsFlags = pes[7] >> 6;
payloadPos = 9 + pes[8];
if (ptsDtsFlags >= 2 && pes.size() >= 14) {
pts = (pes[13] >> 1) |
(pes[12] << 7) |
((pes[11] & 0xfe) << 14) |
(pes[10] << 22) |
(static_cast<int64_t>(pes[9] & 0x0e) << 29);
}
}
else if (streamID == PRIVATE_STREAM_2) {
payloadPos = 6;
if (m_pcr >= 0) {
pts = m_pcr;
}
}
}
if (payloadPos == 0 || payloadPos + 1 >= pes.size() || pts < 0) {
return;
}
int dataIdentifier = pes[payloadPos];
int privateStreamID = pes[payloadPos + 1];
if ((dataIdentifier != 0x80 && dataIdentifier != 0x81) ||
privateStreamID != 0xff) {
// Not an ARIB Synchronized/Asynchronous PES data
return;
}
PARSE_PRIVATE_DATA_RESULT ret = ParsePrivateData(m_buf, m_intBuf, pes.data() + payloadPos, pes.size() - payloadPos, drcsList, langTags);
if (ret != PARSE_PRIVATE_DATA_FAILED_NEED_MANAGEMENT) {
int64_t ptsPcrDiff = (0x200000000 + pts - m_pcr) & 0x1ffffffff;
if (ptsPcrDiff >= 0x100000000) {
ptsPcrDiff -= 0x200000000;
}
fprintf(m_fp, "pts=%010lld;pcrrel=%+08d",
static_cast<long long>(pts),
static_cast<int>(m_pcr < 0 ? -9999999 : std::min<int64_t>(std::max<int64_t>(ptsPcrDiff, -9999999), 9999999)));
if (ret == PARSE_PRIVATE_DATA_SUCCEEDED) {
for (size_t i = 0; i + 1 < m_intBuf.size(); ++i) {
fprintf(m_fp, "%s%d", i == 0 ? ";text=" : ",", m_intBuf[i + 1] - m_intBuf[i]);
}
}
fprintf(m_fp, ";b24%s", dataIdentifier == 0x81 ? "superimpose" : "caption");
if (ret == PARSE_PRIVATE_DATA_SUCCEEDED) {
m_buf.push_back('\n');
fwrite(m_buf.data(), 1, m_buf.size(), m_fp);
}
else {
fprintf(m_fp, "err=%s\n",
ret == PARSE_PRIVATE_DATA_FAILED_CRC ? "crc" :
ret == PARSE_PRIVATE_DATA_FAILED_UNSUPPORTED ? "unsupported" : "unknown");
}
fflush(m_fp);
}
}
namespace
{
enum GS_CLASS
{
GS_1BYTE_G,
GS_2BYTE_G,
GS_1BYTE_DRCS,
GS_2BYTE_DRCS,
};
const uint8_t GS_HIRAGANA = 0x30;
const uint8_t GS_KATAKANA = 0x31;
const uint8_t GS_PROP_ASCII = 0x36;
const uint8_t GS_PROP_HIRAGANA = 0x37;
const uint8_t GS_PROP_KATAKANA = 0x38;
const uint8_t GS_JIS_KANJI1 = 0x39;
const uint8_t GS_JIS_KANJI2 = 0x3a;
const uint8_t GS_ADDITIONAL_SYMBOLS = 0x3b;
const uint8_t GS_KANJI = 0x42;
const uint8_t GS_JISX_KATAKANA = 0x49;
const uint8_t GS_ASCII = 0x4a;
const uint8_t GS_LATIN_EXTENSION = 0x4b;
const uint8_t GS_LATIN_SPECIAL = 0x4c;
const uint8_t GS_DRCS_0 = 0x40;
const uint8_t GS_DRCS_1 = 0x41;
const uint8_t GS_DRCS_15 = 0x4f;
const uint8_t GS_MACRO = 0x70;
extern const char16_t FullwidthAsciiTable[94];
extern const char16_t HiraganaTable[94];
extern const char16_t KatakanaTable[94];
extern const char16_t JisXKatakanaTable[94];
extern const char16_t LatinExtensionTable[94];
extern const char16_t LatinSpecialTable[94];
extern const char16_t JisTable[84 * 94 + 1];
extern const char32_t GaijiTable[7 * 94 + 1];
extern const uint8_t DefaultMacro[16][20];
void AddEscapedChar(std::vector<uint8_t> &buf, uint8_t c)
{
buf.push_back('%');
buf.push_back(((c >> 4) > 9 ? '7' : '0') + (c >> 4));
buf.push_back(((c & 15) > 9 ? '7' : '0') + (c & 15));
}
void AddChar(std::vector<uint8_t> &buf, uint8_t c)
{
// control characters or %
if (c < 0x20 || c == 0x25 || c == 0x7f) {
AddEscapedChar(buf, c);
}
else {
buf.push_back(c);
}
}
void AddChar32(std::vector<uint8_t> &buf, char32_t x)
{
if (x < 0x80) {
AddChar(buf, static_cast<uint8_t>(x));
}
else if (x < 0x800) {
AddChar(buf, static_cast<uint8_t>(0xc0 | (x >> 6)));
AddChar(buf, static_cast<uint8_t>(0x80 | (x & 0x3f)));
}
else if (x < 0x10000) {
AddChar(buf, static_cast<uint8_t>(0xe0 | (x >> 12)));
AddChar(buf, static_cast<uint8_t>(0x80 | ((x >> 6) & 0x3f)));
AddChar(buf, static_cast<uint8_t>(0x80 | (x & 0x3f)));
}
else {
AddChar(buf, static_cast<uint8_t>(0xf0 | (x >> 18)));
AddChar(buf, static_cast<uint8_t>(0x80 | ((x >> 12) & 0x3f)));
AddChar(buf, static_cast<uint8_t>(0x80 | ((x >> 6) & 0x3f)));
AddChar(buf, static_cast<uint8_t>(0x80 | (x & 0x3f)));
}
}
void AddAscii(std::vector<uint8_t> &buf, uint8_t c)
{
if (c < 0x80) {
AddChar(buf, c);
}
else {
AddChar32(buf, U'\uFFFD');
}
}
uint8_t ReadByte(const uint8_t *&data, const uint8_t *dataEnd)
{
if (data == dataEnd) {
return 0;
}
return *(data++);
}
void InitializeArib8(std::pair<GS_CLASS, uint8_t> (&gbuf)[4], int &gl, int &gr, bool isLatin)
{
if (isLatin) {
gbuf[0] = std::make_pair(GS_1BYTE_G, GS_ASCII);
gbuf[2] = std::make_pair(GS_1BYTE_G, GS_LATIN_EXTENSION);
gbuf[3] = std::make_pair(GS_1BYTE_G, GS_LATIN_SPECIAL);
}
else {
gbuf[0] = std::make_pair(GS_2BYTE_G, GS_KANJI);
gbuf[2] = std::make_pair(GS_1BYTE_G, GS_HIRAGANA);
gbuf[3] = std::make_pair(GS_1BYTE_DRCS, GS_MACRO);
}
gbuf[1] = std::make_pair(GS_1BYTE_G, GS_ASCII);
gl = 0;
gr = 2;
}
void CheckReadableTextPosList(std::vector<int> &textPosList, const std::vector<uint8_t> &buf, bool isNextReadable)
{
if ((textPosList.size() % 2 != 0) == isNextReadable) {
int codeCount = 0;
for (size_t i = 0; i < buf.size(); ++i) {
if ((buf[i] & 0xc0) != 0x80) {
++codeCount;
}
}
textPosList.push_back(codeCount);
}
}
void AnalizeArib8(std::vector<uint8_t> &buf, std::vector<int> &textPosList, const uint8_t *&data, const uint8_t *dataEnd,
const std::vector<uint16_t> &drcsList, std::pair<GS_CLASS, uint8_t> (&gbuf)[4], int &gl, int &gr, bool isLatin)
{
std::pair<GS_CLASS, uint8_t> *gss = nullptr;
while (data != dataEnd) {
uint8_t b = ReadByte(data, dataEnd);
if (b <= 0x20) {
// C0
gss = nullptr;
if (b == 0x0e) {
// LS1
gl = 1;
}
else if (b == 0x0f) {
// LS0
gl = 0;
}
else if (b == 0x19) {
// SS2
gss = &gbuf[2];
}
else if (b == 0x1b) {
// ESC
b = ReadByte(data, dataEnd);
if (b == 0x24) {
b = ReadByte(data, dataEnd);
if (0x28 <= b && b <= 0x2b) {
uint8_t c = ReadByte(data, dataEnd);
if (c == 0x20) {
gbuf[b - 0x28] = std::make_pair(GS_2BYTE_DRCS, ReadByte(data, dataEnd));
}
else if (0x29 <= b && b <= 0x2b) {
gbuf[b - 0x28] = std::make_pair(GS_2BYTE_G, c);
}
}
else {
gbuf[0] = std::make_pair(GS_2BYTE_G, b);
}
}
else if (0x28 <= b && b <= 0x2b) {
uint8_t c = ReadByte(data, dataEnd);
if (c == 0x20) {
gbuf[b - 0x28] = std::make_pair(GS_1BYTE_DRCS, ReadByte(data, dataEnd));
}
else {
gbuf[b - 0x28] = std::make_pair(GS_1BYTE_G, c);
}
}
else if (b == 0x6e) {
gl = 2;
}
else if (b == 0x6f) {
gl = 3;
}
else if (b == 0x7c) {
gr = 3;
}
else if (b == 0x7d) {
gr = 2;
}
else if (b == 0x7e) {
gr = 1;
}
}
else if (b == 0x1d) {
// SS3
gss = &gbuf[3];
}
else if (b != 0) {
CheckReadableTextPosList(textPosList, buf, b == 0x20);
AddChar(buf, b);
if (b == 0x0c) {
// CS
InitializeArib8(gbuf, gl, gr, isLatin);
}
else if (b == 0x16) {
// PAPF
AddAscii(buf, ReadByte(data, dataEnd));
}
else if (b == 0x1c) {
// APS
AddAscii(buf, ReadByte(data, dataEnd));
AddAscii(buf, ReadByte(data, dataEnd));
}
}
}
else if (0x7f <= b && b <= 0xa0) {
// C1
gss = nullptr;
if (b == 0x95) {
// MACRO (unsupported)
b = ReadByte(data, dataEnd);
while (data != dataEnd) {
uint8_t c = ReadByte(data, dataEnd);
if (b == 0x95 && c == 0x4f) {
break;
}
b = c;
}
}
else {
if (b == 0x7f) {
CheckReadableTextPosList(textPosList, buf, false);
AddChar(buf, b);
}
else if (b == 0xa0) {
CheckReadableTextPosList(textPosList, buf, true);
AddChar32(buf, U'\u00A0');
}
else {
// caret notation
CheckReadableTextPosList(textPosList, buf, false);
buf.push_back('%');
AddChar(buf, '^');
AddChar(buf, b - 0x40);
}
if (b == 0x8b || b == 0x91 || b == 0x93 || b == 0x94 || b == 0x97 || b == 0x98) {
// SZX, FLC, POL, WMM, HLC, RPC
AddAscii(buf, ReadByte(data, dataEnd));
}
else if (b == 0x90) {
// COL
b = ReadByte(data, dataEnd);
AddAscii(buf, b);
if (b == 0x20) {
AddAscii(buf, ReadByte(data, dataEnd));
}
}
else if (b == 0x9d) {
// TIME
b = ReadByte(data, dataEnd);
AddAscii(buf, b);
if (b == 0x20) {
AddAscii(buf, ReadByte(data, dataEnd));
}
else {
while (data != dataEnd && (b < 0x40 || 0x43 < b)) {
b = ReadByte(data, dataEnd);
AddAscii(buf, b);
}
}
}
else if (b == 0x9b) {
// CSI
while (data != dataEnd && b != 0x20) {
b = ReadByte(data, dataEnd);
AddAscii(buf, b);
}
b = ReadByte(data, dataEnd);
AddAscii(buf, b);
if (b == 0x53) {
// SWF
InitializeArib8(gbuf, gl, gr, isLatin);
}
}
}
}
else if (b < 0xff) {
// GL, GR
std::pair<GS_CLASS, uint8_t> g = gss ? *gss : b < 0x7f ? gbuf[gl] : gbuf[gr];
gss = nullptr;
b &= 0x7f;
if (g.first == GS_1BYTE_G) {
CheckReadableTextPosList(textPosList, buf, true);
if (g.second == GS_ASCII || g.second == GS_PROP_ASCII) {
if (isLatin) {
AddChar(buf, b);
}
else {
AddChar32(buf, static_cast<char32_t>(FullwidthAsciiTable[b - 0x21]));
}
}
else {
char16_t x = g.second == GS_HIRAGANA || g.second == GS_PROP_HIRAGANA ? HiraganaTable[b - 0x21] :
g.second == GS_KATAKANA || g.second == GS_PROP_KATAKANA ? KatakanaTable[b - 0x21] :
g.second == GS_JISX_KATAKANA ? JisXKatakanaTable[b - 0x21] :
g.second == GS_LATIN_EXTENSION ? LatinExtensionTable[b - 0x21] :
g.second == GS_LATIN_SPECIAL ? LatinSpecialTable[b - 0x21] : u'\uFFFD';
AddChar32(buf, static_cast<char32_t>(x));
}
}
else if (g.first == GS_2BYTE_G) {
CheckReadableTextPosList(textPosList, buf, true);
uint8_t c = ReadByte(data, dataEnd) & 0x7f;
if (g.second == GS_JIS_KANJI1 ||
g.second == GS_JIS_KANJI2 ||
g.second == GS_ADDITIONAL_SYMBOLS ||
g.second == GS_KANJI) {
if (b < 0x21 + 84 && 0x21 <= c && c < 0x21 + 94) {
AddChar32(buf, static_cast<char32_t>(JisTable[(b - 0x21) * 94 + (c - 0x21)]));
}
else {
int x = (b << 8) | c;
AddChar32(buf, 0x7521 <= x && x < 0x7521 + 94 ? GaijiTable[5 * 94 + x - 0x7521] :
0x7621 <= x && x < 0x7621 + 94 ? GaijiTable[6 * 94 + x - 0x7621] :
0x7a21 <= x && x < 0x7a21 + 94 ? GaijiTable[x - 0x7a21] :
0x7b21 <= x && x < 0x7b21 + 94 ? GaijiTable[94 + x - 0x7b21] :
0x7c21 <= x && x < 0x7c21 + 94 ? GaijiTable[2 * 94 + x - 0x7c21] :
0x7d21 <= x && x < 0x7d21 + 94 ? GaijiTable[3 * 94 + x - 0x7d21] :
0x7e21 <= x && x < 0x7e21 + 94 ? GaijiTable[4 * 94 + x - 0x7e21] : U'\uFFFD');
}
}
else {
AddChar32(buf, U'\uFFFD');
}
}
else if (g.first == GS_1BYTE_DRCS) {
if (GS_DRCS_1 <= g.second && g.second <= GS_DRCS_15) {
// 1-byte DRCS mapping
uint16_t charCode = ((g.second - GS_DRCS_0) << 8) | b;
char32_t x = U'\uFFFD';
if (!drcsList.empty()) {
auto it = std::find(drcsList.begin() + 1, drcsList.end(), charCode);
if (it != drcsList.end()) {
x = static_cast<char32_t>(it - 1 - drcsList.begin() + 0xec00);
}
}
CheckReadableTextPosList(textPosList, buf, true);
AddChar32(buf, x);
}
else if (g.second == GS_MACRO) {
if (0x60 <= b && b <= 0x6f) {
const uint8_t *macro = DefaultMacro[b & 0x0f];
AnalizeArib8(buf, textPosList, macro, macro + sizeof(DefaultMacro[0]), drcsList, gbuf, gl, gr, isLatin);
}
else {
AddChar32(buf, U'\uFFFD');
}
}
else {
AddChar32(buf, U'\uFFFD');
}
}
else if (g.first == GS_2BYTE_DRCS) {
uint8_t c = ReadByte(data, dataEnd) & 0x7f;
if (g.second == GS_DRCS_0) {
// 2-byte DRCS mapping
uint16_t charCode = (b << 8) | c;
char32_t x = U'\uFFFD';
if (!drcsList.empty()) {
auto it = std::find(drcsList.begin() + 1, drcsList.end(), charCode);
if (it != drcsList.end()) {
x = static_cast<char32_t>(it - 1 - drcsList.begin() + 0xec00);
}
}
CheckReadableTextPosList(textPosList, buf, true);
AddChar32(buf, x);
}
else {
AddChar32(buf, U'\uFFFD');
}
}
}
else {
gss = nullptr;
}
}
}
void AddArib8AsUtf8(std::vector<uint8_t> &buf, std::vector<int> &textPosList, const uint8_t *data, size_t dataSize,
const std::vector<uint16_t> &drcsList, bool isLatin)
{
std::pair<GS_CLASS, uint8_t> gbuf[4];
int gl, gr;
InitializeArib8(gbuf, gl, gr, isLatin);
AnalizeArib8(buf, textPosList, data, data + dataSize, drcsList, gbuf, gl, gr, isLatin);
CheckReadableTextPosList(textPosList, buf, false);
}
size_t AddEscapedData(std::vector<uint8_t> &buf, const uint8_t *data, size_t dataSize)
{
for (size_t i = 0; i < dataSize; ++i) {
AddEscapedChar(buf, data[i]);
}
return dataSize;
}
size_t AddBase64EncodedData(std::vector<uint8_t> &buf, const uint8_t *data, size_t dataSize)
{
static const char code[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
for (size_t i = 0; i < dataSize; i += 3) {
buf.push_back(code[data[i] >> 2]);
buf.push_back(code[((data[i] & 0x3) << 4) | (i + 1 < dataSize ? data[i + 1] >> 4 : 0)]);
buf.push_back(code[i + 1 < dataSize ? ((data[i + 1] & 0xf) << 2) | (i + 2 < dataSize ? data[i + 2] >> 6 : 0) : 64]);
buf.push_back(code[i + 2 < dataSize ? data[i + 2] & 0x3f : 64]);
}
return dataSize;
}
void AddUcs(std::vector<uint8_t> &buf, const uint8_t *data, size_t dataSize)
{
if (dataSize > 0 && (data[0] == 0xfe || data[0] == 0xff)) {
AddEscapedData(buf, data, dataSize);
}
else {
// UTF-8
for (size_t i = 0; i < dataSize; ++i) {
if (data[i] == 0xc2 && i + 1 < dataSize && 0x80 <= data[i + 1] && data[i + 1] <= 0x9f) {
// C1, caret notation
buf.push_back('%');
AddChar(buf, '^');
AddChar(buf, data[++i] - 0x40);
}
else {
AddChar(buf, data[i]);
}
}
}
}
}
CTraceB24Caption::PARSE_PRIVATE_DATA_RESULT
CTraceB24Caption::ParsePrivateData(std::vector<uint8_t> &buf, std::vector<int> &textPosList, const uint8_t *data, size_t dataSize,
std::vector<uint16_t> &drcsList, LANG_TAG_TYPE (&langTags)[8])
{
const uint8_t BEGIN_UNIT_BRACE[] = {'%', '=', '{'};
const uint8_t END_UNIT_BRACE[] = {'%', '=', '}'};
const uint8_t BEGIN_BASE64_BRACE[] = {'%', '+', '{'};
const uint8_t END_BASE64_BRACE[] = {'%', '+', '}'};
if (dataSize < 3) {
return PARSE_PRIVATE_DATA_FAILED;
}
size_t pos = 3 + (data[2] & 0x0f);
if (pos + 4 >= dataSize) {
return PARSE_PRIVATE_DATA_FAILED;
}
// data_group()
uint8_t dgiType = (data[pos] >> 2) & 0x1f;
size_t dataGroupEnd = pos + 5 + ((data[pos + 3] << 8) | data[pos + 4]);
if (dgiType > 8) {
return PARSE_PRIVATE_DATA_FAILED_UNSUPPORTED;
}
if (dgiType != 0 && langTags[dgiType - 1] == LANG_TAG_ABSENT) {
return PARSE_PRIVATE_DATA_FAILED_NEED_MANAGEMENT;
}
if (dataGroupEnd + 2 > dataSize) {
return PARSE_PRIVATE_DATA_FAILED;
}
if (calc_crc16_ccitt(data + pos, static_cast<int>(dataGroupEnd + 2 - pos)) != 0) {
return PARSE_PRIVATE_DATA_FAILED_CRC;
}
buf.clear();
buf.push_back('0' + dgiType);
buf.push_back('=');
textPosList.clear();
CheckReadableTextPosList(textPosList, buf, false);
pos += AddEscapedData(buf, data + pos, 3);
// omit data_group_size
pos += 2;
if (pos + 3 >= dataGroupEnd) {
return PARSE_PRIVATE_DATA_FAILED;
}
// caption_management_data() or caption_data()
int tmd = data[pos] >> 6;
AddEscapedChar(buf, data[pos++]);
if ((dgiType != 0 && tmd == 1) || tmd == 2) {
if (pos + 7 >= dataGroupEnd) {
return PARSE_PRIVATE_DATA_FAILED;
}
pos += AddEscapedData(buf, data + pos, 5);
}
LANG_TAG_TYPE lang = LANG_TAG_UNKNOWN;
if (dgiType == 0) {
// caption_management_data()
std::fill_n(langTags, 8, LANG_TAG_ABSENT);
int numLanguages = data[pos];
AddEscapedChar(buf, data[pos++]);
for (int i = 0; i < numLanguages && pos + 7 < dataGroupEnd; ++i) {
int tag = data[pos] >> 5;
int dmf = data[pos] & 0x0f;
AddEscapedChar(buf, data[pos++]);
if (12 <= dmf && dmf <= 14) {
if (pos + 7 >= dataGroupEnd) {
return PARSE_PRIVATE_DATA_FAILED;
}
AddEscapedChar(buf, data[pos++]);
}
int tcs = (data[pos + 3] >> 2) & 0x03;
lang = tcs == 1 ? LANG_TAG_UCS :
tcs != 0 ? LANG_TAG_UNKNOWN :
(data[pos] == 'p' && data[pos + 1] == 'o' && data[pos + 2] == 'r') ? LANG_TAG_ARIB8_LATIN :
(data[pos] == 's' && data[pos + 1] == 'p' && data[pos + 2] == 'a') ? LANG_TAG_ARIB8_LATIN : LANG_TAG_ARIB8;
langTags[tag] = lang;
for (int j = 0; j < 3; ++j) {
if (data[pos] < 0x80) {
AddChar(buf, data[pos++]);
}
else {
AddEscapedChar(buf, data[pos++]);
}
}
// tcs 0->1
AddEscapedChar(buf, data[pos++] | (lang == LANG_TAG_ARIB8 || lang == LANG_TAG_ARIB8_LATIN ? 0x04 : 0));
}
}
else {
// caption_data()
lang = langTags[dgiType - 1];
}
size_t dataUnitLoopEnd = pos + 3 + ((data[pos] << 16) | (data[pos + 1] << 8) | data[pos + 2]);
if (dataUnitLoopEnd > dataGroupEnd) {
return PARSE_PRIVATE_DATA_FAILED;
}
pos += 3;
// Repleace data_unit_loop_length with "%={"
buf.insert(buf.end(), BEGIN_UNIT_BRACE, BEGIN_UNIT_BRACE + sizeof(BEGIN_UNIT_BRACE));
while (pos + 4 < dataUnitLoopEnd) {
// data_unit()
AddEscapedChar(buf, data[pos++]);
int unitParameter = data[pos];
if (unitParameter == 0x30 && (lang == LANG_TAG_ARIB8 || lang == LANG_TAG_ARIB8_LATIN)) {
// "shall be the DRCS-0 set" (STD-B24)
AddEscapedChar(buf, 0x31);
++pos;
}
else {
AddEscapedChar(buf, data[pos++]);
}
size_t dataUnitSize = (data[pos] << 16) | (data[pos + 1] << 8) | data[pos + 2];
pos += 3;
if (pos + dataUnitSize > dataUnitLoopEnd) {
return PARSE_PRIVATE_DATA_FAILED;
}
// Repleace data_unit_size with "%={"
buf.insert(buf.end(), BEGIN_UNIT_BRACE, BEGIN_UNIT_BRACE + sizeof(BEGIN_UNIT_BRACE));
if (unitParameter == 0x20) {
// Statement body
if (lang == LANG_TAG_ARIB8 || lang == LANG_TAG_ARIB8_LATIN) {
AddArib8AsUtf8(buf, textPosList, data + pos, dataUnitSize, drcsList, lang == LANG_TAG_ARIB8_LATIN);
pos += dataUnitSize;
}
else if (lang == LANG_TAG_UCS) {
AddUcs(buf, data + pos, dataUnitSize);
pos += dataUnitSize;
}
else {
pos += AddEscapedData(buf, data + pos, dataUnitSize);
}
}
else if (unitParameter == 0x30 || unitParameter == 0x31) {
// Drcs_data_structure()
size_t drcsDataEnd = pos + dataUnitSize;
if (pos < drcsDataEnd) {
int numberOfCode = data[pos];
AddEscapedChar(buf, data[pos++]);
for (int i = 0; i < numberOfCode && pos + 2 < drcsDataEnd; ++i) {
uint16_t charCode = unitParameter == 0x31 ? (data[pos] << 8) | data[pos + 1] :
((data[pos] - GS_DRCS_0) << 8) | data[pos + 1];
if (drcsList.empty()) {
// drcsList[0] points to the last mapping index.
drcsList.push_back(0);
}
auto it = std::find(drcsList.begin() + 1, drcsList.end(), charCode);
if (it == drcsList.end()) {
// mapping
drcsList[0] = drcsList[0] % 1024 + 1;
if (drcsList[0] >= drcsList.size()) {
drcsList.push_back(0);
}
it = drcsList.begin() + drcsList[0];
*it = charCode;
}
// U+EC00 - U+EFFF (1024 characters)
AddEscapedChar(buf, static_cast<uint8_t>(0xec + ((it - 1 - drcsList.begin()) >> 8)));
AddEscapedChar(buf, static_cast<uint8_t>(it - 1 - drcsList.begin()));
pos += 2;
int numberOfFont = data[pos];
AddEscapedChar(buf, data[pos++]);
for (int j = 0; j < numberOfFont && pos < drcsDataEnd; ++j) {
int mode = data[pos] & 0x0f;
AddEscapedChar(buf, data[pos++]);
size_t drcsHead = drcsDataEnd - pos;
size_t drcsBody = 0;
if (mode <= 1) {
if (drcsHead >= 3) {
uint8_t depth = data[pos];
drcsBody = ((depth == 0 ? 1 : depth <= 2 ? 2 : depth <= 6 ? 3 :
depth <= 14 ? 4 : depth <= 30 ? 5 : depth <= 62 ? 6 :
depth <= 126 ? 7 : depth <= 254 ? 8 : 9) * data[pos + 1] * data[pos + 2] + 7) / 8;
drcsBody = std::min(drcsBody, drcsHead - 3);
drcsHead = 3;
}
}
else {
if (drcsHead >= 4) {
drcsBody = (data[pos + 2] << 8) | data[pos + 3];
drcsBody = std::min(drcsBody, drcsHead - 4);
drcsHead = 4;
}
}
pos += AddEscapedData(buf, data + pos, drcsHead);
if (drcsBody > 0) {
buf.insert(buf.end(), BEGIN_BASE64_BRACE, BEGIN_BASE64_BRACE + sizeof(BEGIN_BASE64_BRACE));
pos += AddBase64EncodedData(buf, data + pos, drcsBody);
buf.insert(buf.end(), END_BASE64_BRACE, END_BASE64_BRACE + sizeof(END_BASE64_BRACE));
}
}
}
}
}
else {
pos += AddEscapedData(buf, data + pos, dataUnitSize);
}
buf.insert(buf.end(), END_UNIT_BRACE, END_UNIT_BRACE + sizeof(END_UNIT_BRACE));
}
buf.insert(buf.end(), END_UNIT_BRACE, END_UNIT_BRACE + sizeof(END_UNIT_BRACE));
// omit CRC_16
return PARSE_PRIVATE_DATA_SUCCEEDED;
}
namespace
{
const char16_t FullwidthAsciiTable[94] =
{
u'!', u'"', u'#', u'$', u'%', u'&', u''',
u'(', u')', u'*', u'+', u',', u'-', u'.', u'/',
u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7',
u'8', u'9', u':', u';', u'<', u'=', u'>', u'?',
u'@', u'A', u'B', u'C', u'D', u'E', u'F', u'G',
u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O',
u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W',
u'X', u'Y', u'Z', u'[', u'¥', u']', u'^', u'_',
u'`', u'a', u'b', u'c', u'd', u'e', u'f', u'g',
u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o',
u'p', u'q', u'r', u's', u't', u'u', u'v', u'w',
u'x', u'y', u'z', u'{', u'|', u'}', u' ̄'
};
const char16_t HiraganaTable[94] =
{
u'ぁ', u'あ', u'ぃ', u'い', u'ぅ', u'う', u'ぇ',
u'え', u'ぉ', u'お', u'か', u'が', u'き', u'ぎ', u'く',
u'ぐ', u'け', u'げ', u'こ', u'ご', u'さ', u'ざ', u'し',
u'じ', u'す', u'ず', u'せ', u'ぜ', u'そ', u'ぞ', u'た',
u'だ', u'ち', u'ぢ', u'っ', u'つ', u'づ', u'て', u'で',
u'と', u'ど', u'な', u'に', u'ぬ', u'ね', u'の', u'は',
u'ば', u'ぱ', u'ひ', u'び', u'ぴ', u'ふ', u'ぶ', u'ぷ',
u'へ', u'べ', u'ぺ', u'ほ', u'ぼ', u'ぽ', u'ま', u'み',
u'む', u'め', u'も', u'ゃ', u'や', u'ゅ', u'ゆ', u'ょ',
u'よ', u'ら', u'り', u'る', u'れ', u'ろ', u'ゎ', u'わ',
u'ゐ', u'ゑ', u'を', u'ん', u' ', u' ', u' ', u'ゝ',
u'ゞ', u'ー', u'。', u'「', u'」', u'、', u'・'
};
const char16_t KatakanaTable[94] =
{
u'ァ', u'ア', u'ィ', u'イ', u'ゥ', u'ウ', u'ェ',
u'エ', u'ォ', u'オ', u'カ', u'ガ', u'キ', u'ギ', u'ク',
u'グ', u'ケ', u'ゲ', u'コ', u'ゴ', u'サ', u'ザ', u'シ',
u'ジ', u'ス', u'ズ', u'セ', u'ゼ', u'ソ', u'ゾ', u'タ',
u'ダ', u'チ', u'ヂ', u'ッ', u'ツ', u'ヅ', u'テ', u'デ',
u'ト', u'ド', u'ナ', u'ニ', u'ヌ', u'ネ', u'ノ', u'ハ',
u'バ', u'パ', u'ヒ', u'ビ', u'ピ', u'フ', u'ブ', u'プ',
u'ヘ', u'ベ', u'ペ', u'ホ', u'ボ', u'ポ', u'マ', u'ミ',
u'ム', u'メ', u'モ', u'ャ', u'ヤ', u'ュ', u'ユ', u'ョ',
u'ヨ', u'ラ', u'リ', u'ル', u'レ', u'ロ', u'ヮ', u'ワ',
u'ヰ', u'ヱ', u'ヲ', u'ン', u'ヴ', u'ヵ', u'ヶ', u'ヽ',
u'ヾ', u'ー', u'。', u'「', u'」', u'、', u'・'
};
const char16_t JisXKatakanaTable[94] =
{
u'。', u'「', u'」', u'、', u'・', u'ヲ', u'ァ',
u'ィ', u'ゥ', u'ェ', u'ォ', u'ャ', u'ュ', u'ョ', u'ッ',
u'ー', u'ア', u'イ', u'ウ', u'エ', u'オ', u'カ', u'キ',
u'ク', u'ケ', u'コ', u'サ', u'シ', u'ス', u'セ', u'ソ',
u'タ', u'チ', u'ツ', u'テ', u'ト', u'ナ', u'ニ', u'ヌ',
u'ネ', u'ノ', u'ハ', u'ヒ', u'フ', u'ヘ', u'ホ', u'マ',
u'ミ', u'ム', u'メ', u'モ', u'ヤ', u'ユ', u'ヨ', u'ラ',
u'リ', u'ル', u'レ', u'ロ', u'ワ', u'ン', u'゛', u'゜',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�'
};
const char16_t LatinExtensionTable[94] =
{
u'¡', u'¢', u'£', u'€', u'¥', u'Š', u'§',
u'š', u'©', u'ª', u'«', u'¬', u'ÿ', u'®', u'¯',
u'°', u'±', u'²', u'³', u'Ž', u'μ', u'¶', u'·',
u'ž', u'¹', u'º', u'»', u'Œ', u'œ', u'Ÿ', u'¿',
u'À', u'Á', u'Â', u'Ã', u'Ä', u'Å', u'Æ', u'Ç',
u'È', u'É', u'Ê', u'Ë', u'Ì', u'Í', u'Î', u'Ï',
u'Ð', u'Ñ', u'Ò', u'Ó', u'Ô', u'Õ', u'Ö', u'×',
u'Ø', u'Ù', u'Ú', u'Û', u'Ü', u'Ý', u'Þ', u'ß',
u'à', u'á', u'â', u'ã', u'ä', u'å', u'æ', u'ç',
u'è', u'é', u'ê', u'ë', u'ì', u'í', u'î', u'ï',
u'ð', u'ñ', u'ò', u'ó', u'ô', u'õ', u'ö', u'÷',
u'ø', u'ù', u'ú', u'û', u'ü', u'ý', u'þ'
};
const char16_t LatinSpecialTable[94] =
{
u'♪', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'¤', u'¦', u'¨', u'´', u'¸', u'¼', u'½', u'¾',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'…', u'█', u'‘', u'’', u'“', u'”', u'•', u'™',
u'⅛', u'⅜', u'⅝', u'⅞', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�', u'�',
u'�', u'�', u'�', u'�', u'�', u'�', u'�'
};
const char16_t JisTable[84 * 94 + 1] =
// row 1-84 (with STD-B24 Table E-1 Conversion)
u" 、。,.・:;?!゛゜̲́̀̈̂̅ヽヾゝゞ〃仝々〆〇ー―‐/\~∥|…‥‘’“”()〔〕[]{}〈〉《》「」『』【】+-±×÷=≠<>≦≧∞∴♂♀°′″℃¥$¢£%#&*@§☆★○●◎◇"
u"◆□■△▲▽▼※〒→←↑↓〓�����������∈∋⊆⊇⊂⊃∪∩��������∧∨¬⇒⇔∀∃�����������∠⊥⌒∂∇≡≒≪≫√∽∝∵∫∬�������ʼn♯♭♪†‡¶����⃝"
u"���������������0123456789�������ABCDEFGHIJKLMNOPQRSTUVWXYZ������abcdefghijklmnopqrstuvwxyz����"
u"ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをん�����������"
u"ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ��������"
u"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ��������αβγδεζηθικλμνξοπρστυφχψω��������������������������������������"
u"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ���������������абвгдеёжзийклмнопрстуфхцчшщъыьэюя�������������"
u"─│┌┐┘└├┬┤┴┼━┃┏┓┛┗┣┳┫┻╋┠┯┨┷┿┝┰┥┸╂��������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"����������������������������������������������������������������������������������������������"
u"亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵梓圧斡扱宛姐虻飴絢綾鮎或粟袷安庵按暗案闇鞍杏以伊位依偉囲夷委威尉惟意慰易椅為畏異移維緯胃萎衣謂違遺医井亥域育郁磯一壱溢逸稲茨芋鰯允印咽員因姻引飲淫胤蔭"
u"院陰隠韻吋右宇烏羽迂雨卯鵜窺丑碓臼渦嘘唄欝蔚鰻姥厩浦瓜閏噂云運雲荏餌叡営嬰影映曳栄永泳洩瑛盈穎頴英衛詠鋭液疫益駅悦謁越閲榎厭円園堰奄宴延怨掩援沿演炎焔煙燕猿縁艶苑薗遠鉛鴛塩於汚甥凹央奥往応"
u"押旺横欧殴王翁襖鴬鴎黄岡沖荻億屋憶臆桶牡乙俺卸恩温穏音下化仮何伽価佳加可嘉夏嫁家寡科暇果架歌河火珂禍禾稼箇花苛茄荷華菓蝦課嘩貨迦過霞蚊俄峨我牙画臥芽蛾賀雅餓駕介会解回塊壊廻快怪悔恢懐戒拐改"
u"魁晦械海灰界皆絵芥蟹開階貝凱劾外咳害崖慨概涯碍蓋街該鎧骸浬馨蛙垣柿蛎鈎劃嚇各廓拡撹格核殻獲確穫覚角赫較郭閣隔革学岳楽額顎掛笠樫橿梶鰍潟割喝恰括活渇滑葛褐轄且鰹叶椛樺鞄株兜竃蒲釜鎌噛鴨栢茅萱"
u"粥刈苅瓦乾侃冠寒刊勘勧巻喚堪姦完官寛干幹患感慣憾換敢柑桓棺款歓汗漢澗潅環甘監看竿管簡緩缶翰肝艦莞観諌貫還鑑間閑関陥韓館舘丸含岸巌玩癌眼岩翫贋雁頑顔願企伎危喜器基奇嬉寄岐希幾忌揮机旗既期棋棄"
u"機帰毅気汽畿祈季稀紀徽規記貴起軌輝飢騎鬼亀偽儀妓宜戯技擬欺犠疑祇義蟻誼議掬菊鞠吉吃喫桔橘詰砧杵黍却客脚虐逆丘久仇休及吸宮弓急救朽求汲泣灸球究窮笈級糾給旧牛去居巨拒拠挙渠虚許距鋸漁禦魚亨享京"
u"供侠僑兇競共凶協匡卿叫喬境峡強彊怯恐恭挟教橋況狂狭矯胸脅興蕎郷鏡響饗驚仰凝尭暁業局曲極玉桐粁僅勤均巾錦斤欣欽琴禁禽筋緊芹菌衿襟謹近金吟銀九倶句区狗玖矩苦躯駆駈駒具愚虞喰空偶寓遇隅串櫛釧屑屈"
u"掘窟沓靴轡窪熊隈粂栗繰桑鍬勲君薫訓群軍郡卦袈祁係傾刑兄啓圭珪型契形径恵慶慧憩掲携敬景桂渓畦稽系経継繋罫茎荊蛍計詣警軽頚鶏芸迎鯨劇戟撃激隙桁傑欠決潔穴結血訣月件倹倦健兼券剣喧圏堅嫌建憲懸拳捲"
u"検権牽犬献研硯絹県肩見謙賢軒遣鍵険顕験鹸元原厳幻弦減源玄現絃舷言諺限乎個古呼固姑孤己庫弧戸故枯湖狐糊袴股胡菰虎誇跨鈷雇顧鼓五互伍午呉吾娯後御悟梧檎瑚碁語誤護醐乞鯉交佼侯候倖光公功効勾厚口向"
u"后喉坑垢好孔孝宏工巧巷幸広庚康弘恒慌抗拘控攻昂晃更杭校梗構江洪浩港溝甲皇硬稿糠紅紘絞綱耕考肯肱腔膏航荒行衡講貢購郊酵鉱砿鋼閤降項香高鴻剛劫号合壕拷濠豪轟麹克刻告国穀酷鵠黒獄漉腰甑忽惚骨狛込"
u"此頃今困坤墾婚恨懇昏昆根梱混痕紺艮魂些佐叉唆嵯左差査沙瑳砂詐鎖裟坐座挫債催再最哉塞妻宰彩才採栽歳済災采犀砕砦祭斎細菜裁載際剤在材罪財冴坂阪堺榊肴咲崎埼碕鷺作削咋搾昨朔柵窄策索錯桜鮭笹匙冊刷"