* Convert DVD encapsulated LPCM to floating point PCM audio buffers. * The amount of audio in a PCM frame is always <= the amount that will fit * in a DVD block (2048 bytes) but the standard doesn't require that the audio * frames line up with the DVD frames. Since audio frame boundaries are unrelated * to DVD PES boundaries, this routine has to reconstruct then extract the audio * frames. Be
| 197 | * frames. Because of the arbitrary alignment, it can output zero, one or two buf's. |
| 198 | */ |
| 199 | static int declpcmWork( hb_work_object_t * w, hb_buffer_t ** buf_in, |
| 200 | hb_buffer_t ** buf_out ) |
| 201 | { |
| 202 | hb_work_private_t * pv = w->private_data; |
| 203 | hb_buffer_t *in = *buf_in; |
| 204 | hb_buffer_t *buf = NULL; |
| 205 | hb_buffer_list_t list; |
| 206 | |
| 207 | hb_buffer_list_clear(&list); |
| 208 | if (in->s.flags & HB_BUF_FLAG_EOF) |
| 209 | { |
| 210 | /* EOF on input stream - send it downstream & say that we're done */ |
| 211 | *buf_out = in; |
| 212 | *buf_in = NULL; |
| 213 | return HB_WORK_DONE; |
| 214 | } |
| 215 | |
| 216 | // if we have a frame to finish, add enough data from this buf |
| 217 | // to finish it |
| 218 | if (pv->size) |
| 219 | { |
| 220 | memcpy(pv->frame + pv->pos, in->data + 6, pv->size - pv->pos); |
| 221 | buf = Decode( w ); |
| 222 | hb_buffer_list_append(&list, buf); |
| 223 | } |
| 224 | |
| 225 | /* save the (rest of) data from this buf in our frame buffer */ |
| 226 | lpcmInfo( w, in ); |
| 227 | int off = pv->offset; |
| 228 | int amt = in->size - off; |
| 229 | pv->pos = amt; |
| 230 | memcpy( pv->frame, in->data + off, amt ); |
| 231 | if (amt >= pv->size) |
| 232 | { |
| 233 | buf = Decode( w ); |
| 234 | hb_buffer_list_append(&list, buf); |
| 235 | pv->size = 0; |
| 236 | } |
| 237 | |
| 238 | *buf_out = hb_buffer_list_clear(&list); |
| 239 | return HB_WORK_OK; |
| 240 | } |
| 241 | |
| 242 | static hb_buffer_t *Decode( hb_work_object_t *w ) |
| 243 | { |
nothing calls this directly
no test coverage detected