@@ -92,7 +92,7 @@ int write_cc_bitmap_as_transcript(struct cc_subtitle *sub, struct encoder_ctx *c
9292 }
9393 }
9494
95- write_wrapped (context -> out -> fh , context -> encoded_crlf , context -> encoded_crlf_length );
95+ write_wrapped (context -> out -> fh , context -> encoded_end_frame , context -> encoded_end_frame_length );
9696 }
9797 }
9898#endif
@@ -134,6 +134,7 @@ int write_cc_subtitle_as_transcript(struct cc_subtitle *sub, struct encoder_ctx
134134
135135 str = sub -> data ;
136136
137+ int wrote_something = 0 ;
137138 str = strtok_r (str , "\r\n" , & save_str );
138139 do
139140 {
@@ -143,6 +144,15 @@ int write_cc_subtitle_as_transcript(struct cc_subtitle *sub, struct encoder_ctx
143144 continue ;
144145 }
145146
147+ if (wrote_something )
148+ {
149+ ret = write (context -> out -> fh , context -> encoded_crlf , context -> encoded_crlf_length );
150+ if (ret < context -> encoded_crlf_length )
151+ {
152+ mprint ("Warning:Loss of data\n" );
153+ }
154+ }
155+
146156 if (context -> transcript_settings -> showStartTime )
147157 {
148158 char buf [80 ];
@@ -200,14 +210,16 @@ int write_cc_subtitle_as_transcript(struct cc_subtitle *sub, struct encoder_ctx
200210 mprint ("Warning:Loss of data\n" );
201211 }
202212
203- ret = write (context -> out -> fh , context -> encoded_crlf , context -> encoded_crlf_length );
204- if (ret < context -> encoded_crlf_length )
205- {
206- mprint ("Warning:Loss of data\n" );
207- }
213+ wrote_something = 1 ;
208214
209215 } while ((str = strtok_r (NULL , "\r\n" , & save_str )));
210216
217+ ret = write (context -> out -> fh , context -> encoded_end_frame , context -> encoded_end_frame_length );
218+ if (ret < context -> encoded_end_frame_length )
219+ {
220+ mprint ("Warning:Loss of data\n" );
221+ }
222+
211223 freep (& sub -> data );
212224 lsub = sub ;
213225 sub = sub -> next ;
@@ -321,29 +333,43 @@ void write_cc_line_as_transcript2(struct eia608_screen *data, struct encoder_ctx
321333 {
322334 mprint ("Warning:Loss of data\n" );
323335 }
324-
325- ret = write (context -> out -> fh , context -> encoded_crlf , context -> encoded_crlf_length );
326- if (ret < context -> encoded_crlf_length )
327- {
328- mprint ("Warning:Loss of data\n" );
329- }
330336 }
331337 // fprintf (wb->fh,encoded_crlf);
332338}
333339
334340int write_cc_buffer_as_transcript2 (struct eia608_screen * data , struct encoder_ctx * context )
335341{
342+ int ret ;
336343 int wrote_something = 0 ;
337344 dbg_print (CCX_DMT_DECODER_608 , "\n- - - TRANSCRIPT caption - - -\n" );
338345
339346 for (int i = 0 ; i < 15 ; i ++ )
340347 {
341348 if (data -> row_used [i ])
342349 {
350+ if (wrote_something )
351+ {
352+ ret = write (context -> out -> fh , context -> encoded_crlf , context -> encoded_crlf_length );
353+ if (ret < context -> encoded_crlf_length )
354+ {
355+ mprint ("Warning:Loss of data\n" );
356+ }
357+ }
358+
343359 write_cc_line_as_transcript2 (data , context , i );
360+ wrote_something = 1 ;
344361 }
345- wrote_something = 1 ;
346362 }
363+
364+ if (wrote_something )
365+ {
366+ ret = write (context -> out -> fh , context -> encoded_end_frame , context -> encoded_end_frame_length );
367+ if (ret < context -> encoded_end_frame_length )
368+ {
369+ mprint ("Warning:Loss of data\n" );
370+ }
371+ }
372+
347373 dbg_print (CCX_DMT_DECODER_608 , "- - - - - - - - - - - -\r\n" );
348374 return wrote_something ;
349375}
0 commit comments