* Encode *********************************************************************** * **********************************************************************/
| 216 | * |
| 217 | **********************************************************************/ |
| 218 | static hb_buffer_t* Encode(hb_work_object_t *w) |
| 219 | { |
| 220 | hb_work_private_t *pv = w->private_data; |
| 221 | hb_buffer_t *buf; |
| 222 | float **buffer; |
| 223 | int i, j; |
| 224 | |
| 225 | /* Try to extract more data */ |
| 226 | if ((buf = Flush(w)) != NULL) |
| 227 | { |
| 228 | return buf; |
| 229 | } |
| 230 | |
| 231 | /* Check if we need more data */ |
| 232 | if (hb_list_bytes(pv->list) < pv->input_samples * sizeof(float)) |
| 233 | { |
| 234 | return NULL; |
| 235 | } |
| 236 | |
| 237 | /* Process more samples */ |
| 238 | hb_list_getbytes(pv->list, (uint8_t *)pv->buf, pv->input_samples * sizeof(float), |
| 239 | &pv->pts, NULL); |
| 240 | buffer = vorbis_analysis_buffer(&pv->vd, OGGVORBIS_FRAME_SIZE); |
| 241 | for (i = 0; i < OGGVORBIS_FRAME_SIZE; i++) |
| 242 | { |
| 243 | for (j = 0; j < pv->out_discrete_channels; j++) |
| 244 | { |
| 245 | buffer[j][i] = ((float*)pv->buf)[(pv->out_discrete_channels * i + |
| 246 | pv->remap_table[j])]; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | vorbis_analysis_wrote(&pv->vd, OGGVORBIS_FRAME_SIZE); |
| 251 | |
| 252 | /* Try to extract again */ |
| 253 | return Flush(w); |
| 254 | } |
| 255 | |
| 256 | /*********************************************************************** |
| 257 | * Work |
no test coverage detected