+
+
+struct hb_work_private_s
+{
+ hb_job_t * job;
+ struct s_write * cc608;
+};
+
+int decccInit( hb_work_object_t * w, hb_job_t * job )
+{
+ int retval = 1;
+ hb_work_private_t * pv;
+
+ pv = calloc( 1, sizeof( hb_work_private_t ) );
+ if( pv )
+ {
+ w->private_data = pv;
+
+ pv->job = job;
+
+ pv->cc608 = calloc(1, sizeof(struct s_write));
+
+ if( pv->cc608 )
+ {
+ retval = general_608_init(pv->cc608);
+ if( !retval )
+ {
+ pv->cc608->data608 = calloc(1, sizeof(struct eia608));
+ if( !pv->cc608->data608 )
+ {
+ retval = 1;
+ }
+ }
+ }
+ }
+ return retval;
+}
+
+int decccWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+ hb_buffer_t ** buf_out )
+{
+ hb_work_private_t * pv = w->private_data;
+ hb_buffer_t * in = *buf_in;
+
+ if ( in->size <= 0 )
+ {
+ /* EOF on input stream - send it downstream & say that we're done */
+ handle_end_of_data(pv->cc608);
+ /*
+ * Grab any pending buffer and output them with the EOF on the end
+ */
+ if (pv->cc608->hb_last_buffer) {
+ pv->cc608->hb_last_buffer->next = in;
+ *buf_out = pv->cc608->hb_buffer;
+ *buf_in = NULL;
+ pv->cc608->hb_buffer = NULL;
+ pv->cc608->hb_last_buffer = NULL;
+ } else {
+ *buf_out = in;
+ *buf_in = NULL;
+ }
+ return HB_WORK_DONE;
+ }
+
+ pv->cc608->last_pts = in->start;
+
+ process608(in->data, in->size, pv->cc608);
+
+ /*
+ * If there is one waiting then pass it on
+ */
+ *buf_out = pv->cc608->hb_buffer;
+ pv->cc608->hb_buffer = NULL;
+ pv->cc608->hb_last_buffer = NULL;
+
+ return HB_WORK_OK;
+}
+
+void decccClose( hb_work_object_t * w )
+{
+ hb_work_private_t * pv = w->private_data;
+ general_608_close( pv->cc608 );
+ free( pv->cc608->data608 );
+ free( pv->cc608 );
+ free( w->private_data );
+}
+
+hb_work_object_t hb_deccc608 =
+{
+ WORK_DECCC608,
+ "Closed Caption (608) decoder",
+ decccInit,
+ decccWork,
+ decccClose
+};