@@ -95,15 +95,19 @@ void do_NAL(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned
95
95
NAL_stop = NAL_length + NAL_start ;
96
96
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
97
97
98
- dvprint ("BEGIN NAL unit type: %d length %d ref_idc: %d - Buffered captions before: %d\n" ,
99
- nal_unit_type , NAL_stop - NAL_start - 1 , dec_ctx -> avc_ctx -> nal_ref_idc , !dec_ctx -> avc_ctx -> cc_buffer_saved );
100
-
101
98
if (NAL_stop == NULL ) // remove_03emu failed.
102
99
{
103
- mprint ("\rNotice: NAL of type %u had to be skipped because remove_03emu failed.\n" , nal_unit_type );
100
+ mprint ("\rWarning: Invalid emulation prevention bytes detected in NAL unit type %u (0x%02X). "
101
+ "This NAL unit contains an illegal byte sequence (0x000000, 0x000001, or 0x000002) or "
102
+ "improper emulation prevention byte (0x03). "
103
+ "This may indicate a corrupted AVC/H.264 stream. NAL unit skipped.\n" ,
104
+ nal_unit_type , nal_unit_type );
104
105
return ;
105
106
}
106
107
108
+ dvprint ("BEGIN NAL unit type: %d length %d ref_idc: %d - Buffered captions before: %d\n" ,
109
+ nal_unit_type , NAL_stop - NAL_start - 1 , dec_ctx -> avc_ctx -> nal_ref_idc , !dec_ctx -> avc_ctx -> cc_buffer_saved );
110
+
107
111
if (nal_unit_type == CCX_NAL_TYPE_ACCESS_UNIT_DELIMITER_9 )
108
112
{
109
113
// Found Access Unit Delimiter
@@ -127,7 +131,7 @@ void do_NAL(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned
127
131
else if (dec_ctx -> avc_ctx -> got_seq_para && nal_unit_type == CCX_NAL_TYPE_SEI )
128
132
{
129
133
// Found SEI (used for subtitles)
130
- // set_fts(ctx ->timing); // FIXME - check this!!!
134
+ set_fts (enc_ctx -> timing );
131
135
sei_rbsp (dec_ctx -> avc_ctx , NAL_start + 1 , NAL_stop );
132
136
}
133
137
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
301
305
unsigned char * remove_03emu (unsigned char * from , unsigned char * to )
302
306
{
303
307
int num = to - from ;
304
- int newsize = EBSPtoRBSP (from , num , 0 ); // TODO: Do something if newsize == -1 (broken NAL)
308
+ int newsize = EBSPtoRBSP (from , num , 0 );
305
309
if (newsize == -1 )
306
310
return NULL ;
307
311
return from + newsize ;
0 commit comments