[xiph-commits] r8501 - in trunk/oggdsf/src/lib:
codecs/theora/filters/dsfTheoraDecoder
codecs/theora/filters/dsfTheoraEncoder
core/directshow/dsfOggDemux core/directshow/dsfOggMux
illiminable at motherfish-iii.xiph.org
illiminable at motherfish-iii.xiph.org
Mon Dec 20 04:34:32 PST 2004
Author: illiminable
Date: 2004-12-20 04:34:32 -0800 (Mon, 20 Dec 2004)
New Revision: 8501
Modified:
trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h
trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp
trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/theoraencoderdllstuff.h
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/TheoraStream.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/ds_guids.h
trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h
Log:
* Fixed theora encoder for non-16 aligned encoding.
Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp 2004-12-20 12:34:32 UTC (rev 8501)
@@ -111,23 +111,23 @@
inFormatBuffer->bmiHeader.biClrImportant = 0; //All colours important
inFormatBuffer->bmiHeader.biClrUsed = 0; //Use max colour depth
inFormatBuffer->bmiHeader.biCompression = MAKEFOURCC('Y','V','1','2');
- inFormatBuffer->bmiHeader.biHeight = locFilter->mTheoraFormatInfo->frameHeight; //Not sure
+ inFormatBuffer->bmiHeader.biHeight = locFilter->mTheoraFormatInfo->pictureHeight; //Not sure
inFormatBuffer->bmiHeader.biPlanes = 1; //Must be 1
inFormatBuffer->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); //????? Size of what ?
- inFormatBuffer->bmiHeader.biSizeImage = ((locFilter->mTheoraFormatInfo->frameHeight * locFilter->mTheoraFormatInfo->frameWidth) * 3)/2; //Size in bytes of image ??
- inFormatBuffer->bmiHeader.biWidth = locFilter->mTheoraFormatInfo->frameWidth;
+ inFormatBuffer->bmiHeader.biSizeImage = ((locFilter->mTheoraFormatInfo->pictureHeight * locFilter->mTheoraFormatInfo->pictureWidth) * 3)/2; //Size in bytes of image ??
+ inFormatBuffer->bmiHeader.biWidth = locFilter->mTheoraFormatInfo->pictureWidth;
inFormatBuffer->bmiHeader.biXPelsPerMeter = 2000; //Fuck knows
inFormatBuffer->bmiHeader.biYPelsPerMeter = 2000; //" " " " "
inFormatBuffer->rcSource.top = 0;
- inFormatBuffer->rcSource.bottom = locFilter->mTheoraFormatInfo->frameHeight;
+ inFormatBuffer->rcSource.bottom = locFilter->mTheoraFormatInfo->pictureHeight;
inFormatBuffer->rcSource.left = 0;
- inFormatBuffer->rcSource.right = locFilter->mTheoraFormatInfo->frameWidth;
+ inFormatBuffer->rcSource.right = locFilter->mTheoraFormatInfo->pictureWidth;
inFormatBuffer->rcTarget.top = 0;
- inFormatBuffer->rcTarget.bottom = locFilter->mTheoraFormatInfo->frameHeight;
+ inFormatBuffer->rcTarget.bottom = locFilter->mTheoraFormatInfo->pictureHeight;
inFormatBuffer->rcTarget.left = 0;
- inFormatBuffer->rcTarget.right = locFilter->mTheoraFormatInfo->frameWidth;
+ inFormatBuffer->rcTarget.right = locFilter->mTheoraFormatInfo->pictureWidth;
inFormatBuffer->dwBitErrorRate=0;
return true;
Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h 2004-12-20 12:34:32 UTC (rev 8501)
@@ -109,10 +109,10 @@
struct sTheoraFormatBlock {
unsigned long theoraVersion;
- unsigned long width;
- unsigned long height;
- unsigned long frameWidth;
- unsigned long frameHeight;
+ unsigned long outerFrameWidth;
+ unsigned long outerFrameHeight;
+ unsigned long pictureWidth;
+ unsigned long pictureHeight;
unsigned long frameRateNumerator;
unsigned long frameRateDenominator;
unsigned long aspectNumerator;
Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp 2004-12-20 12:34:32 UTC (rev 8501)
@@ -151,17 +151,20 @@
char* locDestUptoPtr = mYUV.y;
//
- //Pad top of Y plane buffer with mYOffset lines of width mYUV.y_width
+ //Pad top (which is really bottom of the image) of output Y plane buffer with mYOffset lines of width mYUV.y_width
+ //y_width is the out frame width.
if (mYOffset != 0) {
memset((void*)locDestUptoPtr, NULL, mYOffset * mYUV.y_width); //Is it needed to zero this out ? Or just leave junk ?
- locDestUptoPtr += (mYOffset * mYUV.y_width);
+ locDestUptoPtr += (mYOffset * mYUV.y_width); //I'm fairly sure it can be junk... but leave for now !
}
//Source pointer does not advance
//
- //Add mHeight lines of data of width mWidth plus padding of mXOffset at each end
+ //Add mHeight lines of data of width mWidth plus padding of mXOffset at the start of each line
if (mXOffset == 0) {
//Slight optimisation to keep the inner loop tighter
+ //
+ //This branch of the condition does exactly the same as the else branch where mXOffset = 0
for (long line = 0; line < mHeight; line++) {
memcpy((void*)locDestUptoPtr, (const void*)locSourceUptoPtr, mWidth);
locSourceUptoPtr += mWidth;
@@ -178,19 +181,26 @@
locSourceUptoPtr += mWidth;
locDestUptoPtr += mWidth;
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
//Pad the end of the line with mXOffset bytes
- memset((void*)locDestUptoPtr, NULL, mXOffset);
- locDestUptoPtr += mXOffset;
+ //memset((void*)locDestUptoPtr, NULL, mXOffset);
+ //locDestUptoPtr += mXOffset;
}
}
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
+
//Pad bottom of Y plane buffer with mYOffset lines of width mYUV.y_width
- if (mYOffset != 0) {
- memset((void*)locDestUptoPtr, NULL, mYOffset * mYUV.y_width); //Is it needed to zero this out ? Or just leave junk ?
- locDestUptoPtr += (mYOffset * mYUV.y_width);
- //Source pointer does not advance
- }
+ //if (mYOffset != 0) {
+ // memset((void*)locDestUptoPtr, NULL, mYOffset * mYUV.y_width); //Is it needed to zero this out ? Or just leave junk ?
+ // locDestUptoPtr += (mYOffset * mYUV.y_width);
+ // //Source pointer does not advance
+ //}
@@ -202,6 +212,11 @@
locDestUptoPtr = mYUV.v;
//
+ //ASSERT (mYOffset is EVEN)
+ //ASSERT (mHeight is EVEN)
+ //ASSERT (mWidth is EVEN)
+ //
+
//Pad top of V plane buffer with mYOffset/2 lines of width mYUV.uv_width
if (mYOffset != 0) {
memset((void*)locDestUptoPtr, NULL, (mYOffset * mYUV.uv_width) / 2); //Is it needed to zero this out ? Or just leave junk ?
@@ -230,20 +245,27 @@
locSourceUptoPtr += (mWidth / 2);
locDestUptoPtr += (mWidth / 2);
- //Pad the end of the line
- memset((void*)locDestUptoPtr, NULL, mXOffset / 2);
- locDestUptoPtr += (mXOffset / 2);
- //Source pointer does not advance
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
+
+ ////Pad the end of the line
+ //memset((void*)locDestUptoPtr, NULL, mXOffset / 2);
+ //locDestUptoPtr += (mXOffset / 2);
+ ////Source pointer does not advance
}
}
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
- //Pad bottom of V plane buffer with mYOffset / 2 lines of width mYUV.uv_width
- if (mYOffset != 0) {
- memset((void*)locDestUptoPtr, NULL, (mYOffset * mYUV.uv_width) / 2); //Is it needed to zero this out ? Or just leave junk ?
- locDestUptoPtr += ((mYOffset * mYUV.uv_width) / 2);
- //Source pointer does not advance
- }
+ ////Pad bottom of V plane buffer with mYOffset / 2 lines of width mYUV.uv_width
+ //if (mYOffset != 0) {
+ // memset((void*)locDestUptoPtr, NULL, (mYOffset * mYUV.uv_width) / 2); //Is it needed to zero this out ? Or just leave junk ?
+ // locDestUptoPtr += ((mYOffset * mYUV.uv_width) / 2);
+ // //Source pointer does not advance
+ //}
@@ -285,21 +307,29 @@
locSourceUptoPtr += (mWidth / 2);
locDestUptoPtr += (mWidth / 2);
- //Pad the end of the line
- memset((void*)locDestUptoPtr, NULL, mXOffset / 2);
- locDestUptoPtr += (mXOffset / 2);
- //Source pointer does not advance
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
+
+ ////Pad the end of the line
+ //memset((void*)locDestUptoPtr, NULL, mXOffset / 2);
+ //locDestUptoPtr += (mXOffset / 2);
+ ////Source pointer does not advance
}
}
- //Pad bottom of U plane buffer with mYOffset / 2 lines of width mYUV.uv_width
- if (mYOffset != 0) {
- memset((void*)locDestUptoPtr, NULL, (mYOffset * mYUV.uv_width) / 2); //Is it needed to zero this out ? Or just leave junk ?
- locDestUptoPtr += ((mYOffset * mYUV.uv_width) / 2);
- //Source pointer does not advance
- }
+ //
+ //This is no longer done... we just pad on one side for efficiency
+ //
+ ////Pad bottom of U plane buffer with mYOffset / 2 lines of width mYUV.uv_width
+ //if (mYOffset != 0) {
+ // memset((void*)locDestUptoPtr, NULL, (mYOffset * mYUV.uv_width) / 2); //Is it needed to zero this out ? Or just leave junk ?
+ // locDestUptoPtr += ((mYOffset * mYUV.uv_width) / 2);
+ // //Source pointer does not advance
+ //}
+
//======================================================================================================
return 0;
@@ -1201,18 +1231,20 @@
//---------------------------------------------------------------------------------------------------------------
//mTheoraInfo values
//==================
- //width, height - /16 up rounded values
- //frame_width, frame_height - raw video source values
- //offset_x - CENTRED - *half* the difference between width and frame_width
- //offset_y - CENTRED - *half* the difference between height and frame_heigth
+ //width, height - /16 up rounded values, size of the outer frame
+ //frame_width, frame_height - size of the inner picture region
+ //offset_x - Distance at bottom left from frame to picture <= width - frame_width
+ //offset_y - Distance at bottom left from frame to picture <= height - frame_height
//mYUV values - for YV12 format
//=============================
- //y_width, y_stride - Both equal and equal to the /16 up rounded wdith values
- //uv_width, uv_stride - Both equal and equal to *half* the /16 up rounded width values
+ //y_stride - Equal to the /16 up rounded wdith values
+ //y_width - Equal to the /16 up rounded wdith values
+ //uv_stride - Equal to *half* the /16 up rounded width values
+ //uv_width - Equal to *half* the /16 up rounded wdith values
//y_height - Equal to the /16 up rounded height value
//uv_height - Equal to *half* the /16 up rounded height value
- //y - Buffer of size y_width*y_height (/16 up rounded values)
+ //y - Buffer of size y_stride*y_height (/16 up rounded values)
//u,v - Buffers each *quarter* the size of the y buffer (/16 up rounded values)
//Member data
@@ -1223,24 +1255,27 @@
//mYOffset - y offset
//---------------------------------------------------------------------------------------------------------------
- //Width data
+ //Width of the outer frame
mTheoraInfo.width = mYUV.y_width
= mYUV.y_stride
= (((mVideoFormat->bmiHeader.biWidth + 15)>>4)<<4);
+ //Width of the inner picture
mTheoraInfo.frame_width = mWidth
= mVideoFormat->bmiHeader.biWidth;
+ //YUV U&V data
mYUV.uv_width = mYUV.uv_stride
= mYUV.y_width/2;
//
- //Height data
+ //Height data of outer frame
mTheoraInfo.height = mYUV.y_height
= (((mVideoFormat->bmiHeader.biHeight + 15)>>4)<<4);
+ //Height of the inner picture
mTheoraInfo.frame_height = mHeight
= mVideoFormat->bmiHeader.biHeight;
@@ -1249,14 +1284,16 @@
//
- //Set offset values... centred
+ //Set offset values... no longer centred... all the offset is at the bottom left of the image (ie very start of memory image)
+ //Difference between the outframe dimensions and the inner picture dimensions
mTheoraInfo.offset_x = mXOffset
- = (mTheoraInfo.width - mWidth) / 2;
+ = (mWidth - mTheoraInfo.frame_width);
mTheoraInfo.offset_y = mYOffset
- = (mTheoraInfo.height - mHeight) / 2;
+ = (mHeight - mTheoraInfo.frame_height);
- unsigned long locYBuffSize = mYUV.y_height * mYUV.y_width;
+
+ unsigned long locYBuffSize = mYUV.y_height * mYUV.y_stride;
mYUV.y = new char[locYBuffSize];
mYUV.u = new char[locYBuffSize/4];
mYUV.v = new char[locYBuffSize/4];
@@ -1264,14 +1301,6 @@
//End YV12 specifics
//
- //debugLog<<"Width =y_w = y_s = "<<mWidth<<" ::: "<<"Height=y_h= "<<mHeight<<endl;
- //debugLog<<"uv_w=uv_s= "<<mYUV.uv_stride<<" ::: " <<"uv_height = "<<mYUV.uv_height<<endl;
- //=mVideoFormat->bmiHeader.biWidth;
- //=mVideoFormat->bmiHeader.biHeight;
- //mTheoraInfo.offset_x=0;
- //mTheoraInfo.offset_y=0;
-
-
//HACK:::Bit of a hack to convert dshow nanos to a fps num/denom.
//Now we multiply the numerator and denom by 1000, this gives us 3 d.p. of precision for framerate.
unsigned long locNum = (((double)10000000 * 1000) / ((double)mVideoFormat->AvgTimePerFrame)) + (double)0.5;
@@ -1302,13 +1331,15 @@
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.frameRateNumerator = mTheoraInfo.fps_numerator;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.frameRateDenominator = mTheoraInfo.fps_denominator;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.maxKeyframeInterval = 6; //log2(keyframe_freq) from above
- ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.frameHeight = mHeight;
- ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.frameWidth = mWidth;
+ ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.pictureHeight = mHeight;
+ ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.pictureWidth = mWidth;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.colourSpace = OC_CS_UNSPECIFIED;
- ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.height = mTheoraInfo.height;
- ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.width = mTheoraInfo.width;
+ ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.outerFrameHeight = mTheoraInfo.height;
+ ((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.outerFrameWidth = mTheoraInfo.width;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.xOffset = mXOffset;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.yOffset = mYOffset;
+
+ //TODO ::: DO something about aspect ratios
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.aspectDenominator = 0;
((TheoraEncodeFilter*)mParentFilter)->mTheoraFormatBlock.aspectNumerator = 0;
Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/theoraencoderdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/theoraencoderdllstuff.h 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/theoraencoderdllstuff.h 2004-12-20 12:34:32 UTC (rev 8501)
@@ -114,10 +114,10 @@
struct sTheoraFormatBlock {
unsigned long theoraVersion;
- unsigned long width;
- unsigned long height;
- unsigned long frameWidth;
- unsigned long frameHeight;
+ unsigned long outerFrameWidth;
+ unsigned long outerFrameHeight;
+ unsigned long pictureWidth;
+ unsigned long pictureHeight;
unsigned long frameRateNumerator;
unsigned long frameRateDenominator;
unsigned long aspectNumerator;
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/TheoraStream.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/TheoraStream.cpp 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/TheoraStream.cpp 2004-12-20 12:34:32 UTC (rev 8501)
@@ -67,11 +67,29 @@
//mTheoraFormatBlock->numChannels = OggMath::charArrToULong(mCodecHeaders->getPacket(0)->packetData() + 48);
//mTheoraFormatBlock->samplesPerSec = OggMath::charArrToULong(mCodecHeaders->getPacket(0)->packetData() + 36);
+ //0 - 55 theora ident 0 - 6
+ //56 - 63 ver major 7 - 7
+ //64 - 71 ver minor 8 - 8
+ //72 - 79 ver subversion 9 = 9
+ //80 - 95 width/16 10 - 11
+ //96 - 111 height/16 12 - 13
+ //112 - 135 framewidth 14 - 16
+ //136 - 159 frameheight 17 - 19
+ //160 - 167 xoffset 20 - 20
+ //168 - 175 yoffset 21 - 21
+ //176 - 207 framerateNum 22 - 25
+ //208 - 239 frameratedenom 26 - 29
+ //240 - 263 aspectNum 30 - 32
+ //264 - 287 aspectdenom 33 - 35
+ //288 - 295 colourspace 36 - 36
+ //296 - 319 targetbitrate 37 - 39
+ //320 - 325 targetqual 40 - 40.75
+ //326 - 330 keyframintlog 40.75- 41.375
mTheoraFormatBlock->theoraVersion = (iBE_Math::charArrToULong(locIdentHeader + 7)) >>8;
- mTheoraFormatBlock->width = (iBE_Math::charArrToUShort(locIdentHeader + 10)) * 16;
- mTheoraFormatBlock->height = (iBE_Math::charArrToUShort(locIdentHeader + 12)) * 16;
- mTheoraFormatBlock->frameWidth = (iBE_Math::charArrToULong(locIdentHeader + 14)) >>8;
- mTheoraFormatBlock->frameHeight = (iBE_Math::charArrToULong(locIdentHeader + 17)) >>8;
+ mTheoraFormatBlock->outerFrameWidth = (iBE_Math::charArrToUShort(locIdentHeader + 10)) * 16;
+ mTheoraFormatBlock->outerFrameHeight = (iBE_Math::charArrToUShort(locIdentHeader + 12)) * 16;
+ mTheoraFormatBlock->pictureWidth = (iBE_Math::charArrToULong(locIdentHeader + 14)) >>8;
+ mTheoraFormatBlock->pictureHeight = (iBE_Math::charArrToULong(locIdentHeader + 17)) >>8;
mTheoraFormatBlock->xOffset = locIdentHeader[20];
mTheoraFormatBlock->yOffset = locIdentHeader[21];
mTheoraFormatBlock->frameRateNumerator = iBE_Math::charArrToULong(locIdentHeader + 22);
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/ds_guids.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/ds_guids.h 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/ds_guids.h 2004-12-20 12:34:32 UTC (rev 8501)
@@ -88,10 +88,10 @@
struct sTheoraFormatBlock {
unsigned long theoraVersion;
- unsigned long width;
- unsigned long height;
- unsigned long frameWidth;
- unsigned long frameHeight;
+ unsigned long outerFrameWidth;
+ unsigned long outerFrameHeight;
+ unsigned long pictureWidth;
+ unsigned long pictureHeight;
unsigned long frameRateNumerator;
unsigned long frameRateDenominator;
unsigned long aspectNumerator;
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h 2004-12-20 07:38:02 UTC (rev 8500)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h 2004-12-20 12:34:32 UTC (rev 8501)
@@ -196,10 +196,10 @@
struct sTheoraFormatBlock {
unsigned long theoraVersion;
- unsigned long width;
- unsigned long height;
- unsigned long frameWidth;
- unsigned long frameHeight;
+ unsigned long outerFrameWidth;
+ unsigned long outerFrameHeight;
+ unsigned long pictureWidth;
+ unsigned long pictureHeight;
unsigned long frameRateNumerator;
unsigned long frameRateDenominator;
unsigned long aspectNumerator;
More information about the commits
mailing list