+static block_t *BuildSsaFrame( const AVPacket *p_pkt, unsigned i_order )
+{
+ if( p_pkt->size <= 0 )
+ return NULL;
+
+ char buffer[256];
+ const size_t i_buffer_size = __MIN( sizeof(buffer) - 1, p_pkt->size );
+ memcpy( buffer, p_pkt->data, i_buffer_size );
+ buffer[i_buffer_size] = '\0';
+
+ /* */
+ int i_layer;
+ int h0, m0, s0, c0;
+ int h1, m1, s1, c1;
+ int i_position = 0;
+ if( sscanf( buffer, "Dialogue: %d,%d:%d:%d.%d,%d:%d:%d.%d,%n", &i_layer,
+ &h0, &m0, &s0, &c0, &h1, &m1, &s1, &c1, &i_position ) < 9 )
+ return NULL;
+ if( i_position <= 0 || i_position >= i_buffer_size )
+ return NULL;
+
+ char *p;
+ if( asprintf( &p, "%u,%d,%.*s", i_order, i_layer, p_pkt->size - i_position, p_pkt->data + i_position ) < 0 )
+ return NULL;
+
+ block_t *p_frame = block_heap_Alloc( p, p, strlen(p) + 1 );
+ if( p_frame )
+ p_frame->i_length = CLOCK_FREQ * ((h1 - h1) * 3600 +
+ (m1-m0) * 60 +
+ (s1-s0) * 1) +
+ CLOCK_FREQ * (c1-c0) / 100;
+ return p_frame;
+}
+