Hi there. I am having a little trouble understanding the frame sizes chosen by the codec. testenc_uwb.c from the speex-1.0 source distribution has a framesize of 640 hardcoded and makes use of this value exclusively. However, a mode query on the actual codec returns 320 as a framesize for this mode. int tmp; speex_mode_query(&speex_uwb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); <p>testenc_wb.c from the speex-1.0 source distribution has a framesize of 320 hardcoded and makes use of this value exclusively. However, a mode query on the actual codec returns 160 as a framesize for this mode. int tmp; speex_mode_query(&speex_wb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); How can this discrepancy be explained? Could anyone shed some light here? ;) thanks. Christian --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
> Oops... You've just found a bug. Seems like you're the first one to use > that call. Anyway, it's now fixed in CVS (both trunk and 1.0.x branch). > Thanks for the bug report.Hmm, the call to speex_encode_stereo() takes the frame size as an an argument - and this call generates bits ;) So possibly my bitrate table shows wrong values in the stereo cases. Hmm... Where would I find that CVS repository? Christian --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Christian Buchner wrote:>Hi there. > >I am having a little trouble understanding the frame sizes chosen >by the codec. > >Christian, here is a code snippet from my ACM driver that will explain how to calculate bits per frame and block alignment. As you can see I don't use predefined tables for this. Maybe you can extract something useful for your project... If you need some assistence, please let me know. <p>#define SPEEX10_STEREO_BITS 17 INT SpeexGetBitsPerEncodedFrame(PVOID pEncoder, SpeexMode* pMode) { INT nBitsPerFrameNB; INT nBitsPerFrameWB; INT nBitsPerFrameUWB; SpeexMode* pModeNB; SpeexMode* pModeWB; SpeexMode* pModeUWB; EncState* pEncoderNB; SBEncState* pEncoderWB; SBEncState* pEncoderUWB; if (pMode->modeID == 0) { pModeNB = pMode; pEncoderNB = (EncState*)pEncoder; } else if (pMode->modeID == 1) { pEncoderWB = (SBEncState*)pEncoder; pModeWB = pMode; pEncoderNB = (EncState*)pEncoderWB->st_low; pModeNB = pEncoderNB->mode; } else if (pMode->modeID == 2) { pEncoderUWB = (SBEncState*)pEncoder; pModeUWB = pMode; pEncoderWB = (SBEncState*)pEncoderUWB->st_low; pModeWB = pEncoderWB->mode; pEncoderNB = (EncState*)pEncoderWB->st_low; pModeNB = pEncoderNB->mode; } if (speex_encoder_ctl(pEncoderNB, SPEEX_GET_MODE, &nBitsPerFrameNB) == -1) return -1; if (speex_mode_query(pModeNB, SPEEX_SUBMODE_BITS_PER_FRAME, &nBitsPerFrameNB) == -1) return -1; if (pMode->modeID == 0) return nBitsPerFrameNB; nBitsPerFrameWB = pEncoderWB->submodeID; if (speex_mode_query(pModeWB, SPEEX_SUBMODE_BITS_PER_FRAME, &nBitsPerFrameWB) == -1) return -1; if (pMode->modeID == 1) return (nBitsPerFrameNB + nBitsPerFrameWB); nBitsPerFrameUWB = pEncoderUWB->submodeID; if (speex_mode_query(pModeUWB, SPEEX_SUBMODE_BITS_PER_FRAME, &nBitsPerFrameUWB) == -1) return -1; return (nBitsPerFrameNB + nBitsPerFrameWB + nBitsPerFrameUWB); } ///////////////////////////////////////////////////////////////////////////// INT SpeexGetBlockAlignment(PVOID pEncoder, SpeexMode* pMode, UINT uChannels) { UINT nBlockAlign; nBlockAlign = SpeexGetBitsPerEncodedFrame(pEncoder, pMode); if (nBlockAlign == -1) return nBlockAlign; if (uChannels == 2) nBlockAlign += SPEEX10_STEREO_BITS; else if (uChannels != 1) return -1; nBlockAlign = nBlockAlign >> 3; if (0 != (nBlockAlign % 8)) nBlockAlign++; return nBlockAlign; } <p>>testenc_uwb.c from the speex-1.0 source distribution has a framesize>of 640 hardcoded and makes use of this value exclusively. > >However, a mode query on the actual codec returns 320 as a framesize >for this mode. > > int tmp; > speex_mode_query(&speex_uwb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); > > >testenc_wb.c from the speex-1.0 source distribution has a framesize >of 320 hardcoded and makes use of this value exclusively. > >However, a mode query on the actual codec returns 160 as a framesize >for this mode. > > int tmp; > speex_mode_query(&speex_wb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); > >How can this discrepancy be explained? > >Could anyone shed some light here? ;) thanks. > >Christian > >--- >8 ---- >List archives: http://www.xiph.org/archives/ >Ogg project homepage: http://www.xiph.org/ogg/ >To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' >containing only the word 'unsubscribe' in the body. No subject is needed. >Unsubscribe messages sent to the list will be ignored/filtered. > > > >-- Best regards Robert Milharcic ib-CADdy d.o.o. / www.ib-caddy.si e-mail: robert.milharcic@ib-caddy.si <p><p><p><p>--- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
> Oops... You've just found a bug. Seems like you're the first one to use > that call. Thanks for the bug report.DOH! Internally the speex_header.c module uses that call to fill in the frame_size property of the header. That means every Ogg Speex stream created with the 1.0 release has a broken header. If a decoder relies on that header value, the sample will sound ...uh... awful ;) Fortunately speexdec.c uses another function call. And most decoders will be modelled after speexdec.c - phew ;) speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); Christian <p><p><p>--- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Oops... You've just found a bug. Seems like you're the first one to use that call. Anyway, it's now fixed in CVS (both trunk and 1.0.x branch). Thanks for the bug report. Jean-Marc Le mar 03/06/2003 à 01:16, Christian Buchner a écrit :> Hi there. > > I am having a little trouble understanding the frame sizes chosen > by the codec. > > testenc_uwb.c from the speex-1.0 source distribution has a framesize > of 640 hardcoded and makes use of this value exclusively. > > However, a mode query on the actual codec returns 320 as a framesize > for this mode. > > int tmp; > speex_mode_query(&speex_uwb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); > > > testenc_wb.c from the speex-1.0 source distribution has a framesize > of 320 hardcoded and makes use of this value exclusively. > > However, a mode query on the actual codec returns 160 as a framesize > for this mode. > > int tmp; > speex_mode_query(&speex_wb_mode, SPEEX_MODE_FRAME_SIZE, &tmp); > > How can this discrepancy be explained? > > Could anyone shed some light here? ;) thanks. > > Christian > > --- >8 ---- > List archives: http://www.xiph.org/archives/ > Ogg project homepage: http://www.xiph.org/ogg/ > To unsubscribe from this list, send a message to 'speex-dev-request@xiph.org' > containing only the word 'unsubscribe' in the body. No subject is needed. > Unsubscribe messages sent to the list will be ignored/filtered.-- Jean-Marc Valin, M.Sc.A. LABORIUS (http://www.gel.usherb.ca/laborius) Université de Sherbrooke, Québec, Canada <p> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 190 bytes Desc: Ceci est une partie de message numériquement signée Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20030603/8be97d3f/signature-0001.pgp