| 186 | } |
| 187 | |
| 188 | static void make_empty_pgs( hb_buffer_t * buf ) |
| 189 | { |
| 190 | hb_buffer_t * b = buf; |
| 191 | uint8_t done = 0; |
| 192 | |
| 193 | // Each buffer is composed of 1 or more segments. |
| 194 | // Segment header is: |
| 195 | // type - 1 byte |
| 196 | // length - 2 bytes |
| 197 | // We want to modify the presentation segment which is type 0x16 |
| 198 | // |
| 199 | // Note that every pgs display set is required to have a presentation |
| 200 | // segment, so we will only have to look at one display set. |
| 201 | while ( b && !done ) |
| 202 | { |
| 203 | int ii = 0; |
| 204 | |
| 205 | while (ii + 3 <= b->size) |
| 206 | { |
| 207 | uint8_t type; |
| 208 | int len; |
| 209 | int segment_len_pos; |
| 210 | |
| 211 | type = b->data[ii++]; |
| 212 | segment_len_pos = ii; |
| 213 | len = ((int)b->data[ii] << 8) + b->data[ii+1]; |
| 214 | ii += 2; |
| 215 | |
| 216 | if (type == 0x16 && ii + len <= b->size) |
| 217 | { |
| 218 | int obj_count; |
| 219 | int kk, jj = ii; |
| 220 | int obj_start; |
| 221 | |
| 222 | // Skip |
| 223 | // video descriptor 5 bytes |
| 224 | // composition descriptor 3 bytes |
| 225 | // palette update flg 1 byte |
| 226 | // palette id ref 1 byte |
| 227 | jj += 10; |
| 228 | |
| 229 | // Set number of composition objects to 0 |
| 230 | obj_count = b->data[jj]; |
| 231 | b->data[jj] = 0; |
| 232 | jj++; |
| 233 | obj_start = jj; |
| 234 | |
| 235 | // And remove all the composition objects |
| 236 | for (kk = 0; kk < obj_count; kk++) |
| 237 | { |
| 238 | uint8_t crop; |
| 239 | |
| 240 | crop = b->data[jj + 3]; |
| 241 | // skip |
| 242 | // object id - 2 bytes |
| 243 | // window id - 1 byte |
| 244 | // object/forced flag - 1 byte |
| 245 | // x pos - 2 bytes |