[theora-dev] uninitialised theora_info values

Conrad Parker conrad at metadecks.org
Mon Jan 7 18:57:39 PST 2008


Hi,

Ralph recently checked in a version of theora/tests/noop.c that uses
the new API. Part of the reason for this test is to check for memory
leaks in the library's constructors and destructors. You can run the
test suite under valgrind by configuring with
--enable-valgrind-testing. The test passes, but gives output like:

make[1]: Entering directory `/home/conrad/src/xiph.org/theora/tests'
----  + Initializing theora_info struct ...
----  + Allocating encoder context ...
==15878== Conditional jump or move depends on uninitialised value(s)
==15878==    at 0x4032485: theora_encode_init (in
/home/conrad/src/xiph.org/theora/lib/.libs/libtheoraenc.so.1.0.0)
==15878==
==15878== Conditional jump or move depends on uninitialised value(s)
==15878==    at 0x40324C0: theora_encode_init (in
/home/conrad/src/xiph.org/theora/lib/.libs/libtheoraenc.so.1.0.0)
----  + Clearing theora_info struct ...
----  + Freeing encoder context ...
PASS: noop

Tracing this through, the theora_info structure seen by
theora_encode_init is created by th_info2theora_info in
encapiwrapper.c. This in turn does not set the following members of
the theora_info struct it creates:

  /* decode */
  _ci->codec_setup

  /* encode */
  _ci->quick_p
  _ci->dropframes_p
  _ci->keyframe_auto_p
  _ci->keyframe_frequency
  _ci->keyframe_data_target_bitrate
  _ci->keyframe_auto_threshold
  _ci->keyframe_mindistance
  _ci->noise_sensitivity
  _ci->sharpness

The values of some of these are subsequently used by
theora_encode_init, hence the errors from valgrind. It seems these
have no equivalent in the new API, so perhaps they should be given
reasonable default values. As is it seems the behaviour of the wrapper
is non-deterministic.

I don't know what these default values should be; perhaps someone with
more clue can fill them in.

(My uninformed guess is "the value of 'keyframe_frequency_force' for
all the keyframe_* fields, and 0 for the rest". Do I win?)

cheers,

Conrad.


More information about the theora-dev mailing list