Skip to content

[FIX] The first TODO in avc_functions.c and FIXME in avc_functions.c #1695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CHANGES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions src/lib_ccx/avc_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 prevention bytes detected in NAL unit type %u (0x%02X). "
"This NAL unit contains an illegal byte sequence (0x000000, 0x000001, or 0x000002) or "
"improper 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
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
Loading