[theora-dev] Change Video Quality Dynamically.
Nuwan Millawitiya
millawitiya at gmail.com
Thu Apr 24 01:13:07 PDT 2008
Hi All,
Theora codec current version encode streams according to given encoding
parameter values at the begining. But now i am tring to encode the stream
with different encodeing parameter values dynamically. Bandwidth measurement
component added to the encoder measure the available bandwidth and planing
to encode dynamically according to this value.
Initially set parameters sucessfully in the function theora_encode_init(In
encoder_toplevel.c). Now i am tring to change encoding parameters
dynamically for each key frame. I created a new function nbs_UpdateFrame
identiticle to UpdateFrame and set quality parameters in that function.
Because of that, it passes CP_INSTANCE with new values to
WriteFrameHeader, EncodeData (In encode.c, I think these are the functions
that actually encode the stream). Then the new function nbs_UpdateFrame
called in CompressKeyFrame function instead of UpdateFrame function.
static void CompressKeyFrame(CP_INSTANCE *cpi){
ogg_uint32_t i;
/* Before we compress reset the carry over to the actual frame carry over
*/
cpi->CarryOver = cpi->Configuration.TargetBandwidth * cpi->CurrentFrame /
cpi->Configuration.OutputFrameRate - cpi->TotalByteCount;
/* Keep track of the total number of Key Frames Coded */
cpi->KeyFrameCount += 1;
/* A key frame is not a dropped frame there for reset the count of
consequative dropped frames. */
cpi->DropCount = 0;
SetupKeyFrame(cpi);
/* set a target size for this frame */
cpi->ThisFrameTargetBytes = (ogg_int32_t) cpi->frame_target_rate +
( (cpi->Configuration.KeyFrameDataTarget - cpi->frame_target_rate) *
cpi->LastKeyFrame / cpi->pb.info.keyframe_frequency_force );
if ( cpi->ThisFrameTargetBytes > cpi->Configuration.KeyFrameDataTarget )
cpi->ThisFrameTargetBytes = cpi->Configuration.KeyFrameDataTarget;
/* Get a DCT quantizer level for the key frame. */
cpi->MotionScore = cpi->pb.UnitFragments;
RegulateQ(cpi, cpi->pb.UnitFragments);
cpi->pb.LastFrameQualityValue = cpi->pb.ThisFrameQualityValue;
/* Initialise DCT tables. */
UpdateQC(cpi, cpi->pb.ThisFrameQualityValue);
/* Initialise the cpi->pb.display_fragments and other fragment
structures for the first frame. */
for ( i = 0; i < cpi->pb.UnitFragments; i ++ )
cpi->FragmentLastQ[i] = cpi->pb.ThisFrameQualityValue;
/* Compress and output the frist frame. */
PickIntra( cpi,
cpi->pb.YSBRows, cpi->pb.YSBCols);
//UpdateFrame(cpi);
nbs_UpdateFrame(cpi);
}
But, It was not done sucessfully. Please help me to solve the problem.
--
Nuwan Millawitiya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20080424/acac5730/attachment.htm
More information about the theora-dev
mailing list