Jean-Marc Valin
2008-Feb-12 13:31 UTC
[Speex-dev] Determine number of 20ms frames in packet - without decoding
Hi Alexander,> Here is first attempt. I'm sending it here for review - am I understand > you correctly? If general approach is correct, I'll change code to use > modes from modes.c.I haven't tested, but it looks sane. Just a few comments: - printf("\tERROR not enough bits left after wb\n"); this is actually now an error. It just means you got to the end of the frame - I suggest speex_get_num_frames() instead. That works for both narrowband and wideband. Number of samples could be misleading because of nb vs wb frame size. - You can change it to use the nb mode info in modes.c, but leave the wideband like it is now. Otherwise, it would cause the wideband stuff to be linked in all the time.> One question - as far as I understand, to get number of samples > we should not parse WB frames even in (U)WB mode, becuase > in WB mode "meta"-frame consist of NB frame, and WB frame. > Is it correct?I don't understand your question. Jean-Marc
Alexander Chemeris
2008-Feb-13 12:16 UTC
[Speex-dev] Determine number of 20ms frames in packet - without decoding
Hi, Ok, here is cleaned up and fixed version. * Function is named speex_get_num_frames() now and return number of frames, as you suggested. * WB layers sizes are taken from wb_skip_table[], while NB frame sizes are calculated with speex_mode_query(). I've tested it with testenc in NB, WB and UWB modes with VBR enabled to test in as many cases as possible. It seems to work fine. Though, while testing I discovered possible bug - original version of wb_skip_table[] (nb_celp.c:1081) does not seem to be correct. Element 0 should be 4 instead of 0 and last four elements should be -1 instead of 0 to make it compatible with speex_mode_query() return values. So, for now I declared own version of wb_skip_table[]. I also think that having rame_num.c in libspeex, code size could be reduced and simplified slightly by using speex_skip_wb_frame() in nb_decode() instead of duplicating code.>> One question - as far as I understand, to get number of samples >> we should not parse WB frames even in (U)WB mode, becuase >> in WB mode "meta"-frame consist of NB frame, and WB frame. >> Is it correct? > > I don't understand your question.You definitely have to create some dictionary of terms, used in Speex. It's really hard to understand what is meant by "frame", "subframe" and "layer" and how to name output of speex_encode()? What I meant is that when encoding in WB/UWB mode every frame consist of NB frame with one/two WB layers appended. -- Regards, Alexander Chemeris. SIPez LLC. SIP VoIP, IM and Presence Consulting http://www.SIPez.com tel: +1 (617) 273-4000 -------------- next part -------------- A non-text attachment was scrubbed... Name: frame_num.c Type: application/octet-stream Size: 3819 bytes Desc: not available Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20080213/d6c2cc22/frame_num.obj
Jean-Marc Valin
2008-Feb-13 13:21 UTC
[Speex-dev] Determine number of 20ms frames in packet - without decoding
> Ok, here is cleaned up and fixed version. > > * Function is named speex_get_num_frames() now and return > number of frames, as you suggested. > * WB layers sizes are taken from wb_skip_table[], while NB frame > sizes are calculated with speex_mode_query().Looking better. Just make sure to remove the stuff that isn't C99-compatible (e.g. // comments).> I've tested it with testenc in NB, WB and UWB modes with VBR enabled > to test in as many cases as possible. It seems to work fine. > Though, while testing I discovered possible bug - original version > of wb_skip_table[] (nb_celp.c:1081) does not seem to be correct. > Element 0 should be 4 instead of 0 and last four elements should > be -1 instead of 0 to make it compatible with speex_mode_query() > return values. So, for now I declared own version of wb_skip_table[].I'll need to have a closer look at that code.> I also think that having rame_num.c in libspeex, code size could be > reduced and simplified slightly by using speex_skip_wb_frame() in > nb_decode() instead of duplicating code.Well, the code is a bit different (e.g. handling of in-band data), so I'm not sure it's possible in a way that is worth it.> You definitely have to create some dictionary of terms, used in Speex. > It's really hard to understand what is meant by "frame", "subframe" > and "layer" and how to name output of speex_encode()? > What I meant is that when encoding in WB/UWB mode every frame > consist of NB frame with one/two WB layers appended.frame: 20 ms encoding sub-frame: 5 ms encoding (internal) layer: one frame of nb or sb sb: sub-band wb: nb+sb uwb: nb+sb+sb But what you say seems right. Cheers, Jean-Marc
Reasonably Related Threads
- Determine number of 20ms frames in packet - without decoding
- Determine number of 20ms frames in packet - without decoding
- Determine number of 20ms frames in packet - without decoding
- Determine number of 20ms frames in packet - without decoding
- Determine number of 20ms frames in packet - without decoding