From 25d38d124871167c7db527d8d33c69b7b34d352a Mon Sep 17 00:00:00 2001 From: Deepnarayan Sett Date: Sun, 27 Apr 2025 02:46:14 +0530 Subject: [PATCH 1/2] fix: The first TODO in avc_functions.c and FIXME in avc_functions.c --- linux/output.p1.svc01.srt | 21 +++++++++++++++++++++ linux/output.srt | 12 ++++++++++++ linux/output1.p1.svc01.srt | 4 ++++ linux/output1.srt | 0 src/lib_ccx/avc_functions.c | 16 ++++++++++------ 5 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 linux/output.p1.svc01.srt create mode 100644 linux/output.srt create mode 100644 linux/output1.p1.svc01.srt create mode 100644 linux/output1.srt diff --git a/linux/output.p1.svc01.srt b/linux/output.p1.svc01.srt new file mode 100644 index 000000000..9e20ae8c1 --- /dev/null +++ b/linux/output.p1.svc01.srt @@ -0,0 +1,21 @@ +1 +00:00:00,317 --> 00:00:02,183 +d + +2 +00:00:02,184 --> 00:00:04,116 +d +1 + +3 +00:00:04,117 --> 00:00:06,383 +d +1 +h + +4 +00:00:06,384 --> 00:00:09,999 +1 +h +m + diff --git a/linux/output.srt b/linux/output.srt new file mode 100644 index 000000000..546a19a8a --- /dev/null +++ b/linux/output.srt @@ -0,0 +1,12 @@ +1 +00:00:00,333 --> 00:00:06,332 +congratulations to papa plot and +their community for winning ■k71 +million in a TV contest through + +2 +00:00:06,334 --> 00:00:09,998 +their community for winning ■k71 +million in a TV contest through +Twitch. I mean, just wild. Um + diff --git a/linux/output1.p1.svc01.srt b/linux/output1.p1.svc01.srt new file mode 100644 index 000000000..30061c3cc --- /dev/null +++ b/linux/output1.p1.svc01.srt @@ -0,0 +1,4 @@ +1 +00:00:00,317 --> 00:00:02,183 +d + diff --git a/linux/output1.srt b/linux/output1.srt new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib_ccx/avc_functions.c b/src/lib_ccx/avc_functions.c index e59d206e9..37ac69d14 100644 --- a/src/lib_ccx/avc_functions.c +++ b/src/lib_ccx/avc_functions.c @@ -95,15 +95,19 @@ void do_NAL(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned NAL_stop = NAL_length + NAL_start; NAL_stop = remove_03emu(NAL_start + 1, NAL_stop); // Add +1 to NAL_stop for TS, without it for MP4. Still don't know why - dvprint("BEGIN NAL unit type: %d length %d ref_idc: %d - Buffered captions before: %d\n", - nal_unit_type, NAL_stop - NAL_start - 1, dec_ctx->avc_ctx->nal_ref_idc, !dec_ctx->avc_ctx->cc_buffer_saved); - if (NAL_stop == NULL) // remove_03emu failed. { - mprint("\rNotice: NAL of type %u had to be skipped because remove_03emu failed.\n", nal_unit_type); + mprint("\rWarning: Invalid emulation prevention bytes detected in NAL unit type %u (0x%02X). " + "This NAL unit contains an illegal byte sequence (0x000000, 0x000001, or 0x000002) or " + "improper emulation prevention byte (0x03). " + "This may indicate a corrupted AVC/H.264 stream. NAL unit skipped.\n", + nal_unit_type, nal_unit_type); return; } + dvprint("BEGIN NAL unit type: %d length %d ref_idc: %d - Buffered captions before: %d\n", + nal_unit_type, NAL_stop - NAL_start - 1, dec_ctx->avc_ctx->nal_ref_idc, !dec_ctx->avc_ctx->cc_buffer_saved); + if (nal_unit_type == CCX_NAL_TYPE_ACCESS_UNIT_DELIMITER_9) { // Found Access Unit Delimiter @@ -127,7 +131,7 @@ void do_NAL(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned else if (dec_ctx->avc_ctx->got_seq_para && nal_unit_type == CCX_NAL_TYPE_SEI) { // Found SEI (used for subtitles) - // set_fts(ctx->timing); // FIXME - check this!!! + set_fts(enc_ctx->timing); sei_rbsp(dec_ctx->avc_ctx, NAL_start + 1, NAL_stop); } else if (dec_ctx->avc_ctx->got_seq_para && nal_unit_type == CCX_NAL_TYPE_PICTURE_PARAMETER_SET) @@ -301,7 +305,7 @@ u32 avc_remove_emulation_bytes(const unsigned char *buffer_src, unsigned char *b unsigned char *remove_03emu(unsigned char *from, unsigned char *to) { int num = to - from; - int newsize = EBSPtoRBSP(from, num, 0); // TODO: Do something if newsize == -1 (broken NAL) + int newsize = EBSPtoRBSP(from, num, 0); if (newsize == -1) return NULL; return from + newsize; From 8156845acb5f70744742436b8614f0c383e66b83 Mon Sep 17 00:00:00 2001 From: Deepnarayan Sett Date: Sun, 27 Apr 2025 03:01:05 +0530 Subject: [PATCH 2/2] fix: AVC - Update CHANGES.txt --- docs/CHANGES.TXT | 2 +- linux/output.p1.svc01.srt | 21 --------------------- linux/output.srt | 12 ------------ linux/output1.p1.svc01.srt | 4 ---- linux/output1.srt | 0 src/lib_ccx/avc_functions.c | 4 ++-- 6 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 linux/output.p1.svc01.srt delete mode 100644 linux/output.srt delete mode 100644 linux/output1.p1.svc01.srt delete mode 100644 linux/output1.srt diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index d6765ffb2..c5e52b8ed 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -39,7 +39,7 @@ - New: Add tesseract page segmentation modes control with `--psm` flag - Fix: Resolve compile-time error about implicit declarations (#1646) - Fix: fatal out of memory error extracting from a VOB PS - +- Fix: Fix TODO and FIXME in `avc_functions.c` 0.94 (2021-12-14) ----------------- - BOM is no longer enabled by default on windows platforms diff --git a/linux/output.p1.svc01.srt b/linux/output.p1.svc01.srt deleted file mode 100644 index 9e20ae8c1..000000000 --- a/linux/output.p1.svc01.srt +++ /dev/null @@ -1,21 +0,0 @@ -1 -00:00:00,317 --> 00:00:02,183 -d - -2 -00:00:02,184 --> 00:00:04,116 -d -1 - -3 -00:00:04,117 --> 00:00:06,383 -d -1 -h - -4 -00:00:06,384 --> 00:00:09,999 -1 -h -m - diff --git a/linux/output.srt b/linux/output.srt deleted file mode 100644 index 546a19a8a..000000000 --- a/linux/output.srt +++ /dev/null @@ -1,12 +0,0 @@ -1 -00:00:00,333 --> 00:00:06,332 -congratulations to papa plot and -their community for winning ■k71 -million in a TV contest through - -2 -00:00:06,334 --> 00:00:09,998 -their community for winning ■k71 -million in a TV contest through -Twitch. I mean, just wild. Um - diff --git a/linux/output1.p1.svc01.srt b/linux/output1.p1.svc01.srt deleted file mode 100644 index 30061c3cc..000000000 --- a/linux/output1.p1.svc01.srt +++ /dev/null @@ -1,4 +0,0 @@ -1 -00:00:00,317 --> 00:00:02,183 -d - diff --git a/linux/output1.srt b/linux/output1.srt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/lib_ccx/avc_functions.c b/src/lib_ccx/avc_functions.c index 37ac69d14..79a59ebe7 100644 --- a/src/lib_ccx/avc_functions.c +++ b/src/lib_ccx/avc_functions.c @@ -97,9 +97,9 @@ void do_NAL(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned if (NAL_stop == NULL) // remove_03emu failed. { - mprint("\rWarning: Invalid emulation prevention bytes detected in NAL unit type %u (0x%02X). " + mprint("\rWarning: Invalid prevention bytes detected in NAL unit type %u (0x%02X). " "This NAL unit contains an illegal byte sequence (0x000000, 0x000001, or 0x000002) or " - "improper emulation prevention byte (0x03). " + "improper prevention byte (0x03). " "This may indicate a corrupted AVC/H.264 stream. NAL unit skipped.\n", nal_unit_type, nal_unit_type); return;