Chen-tao / webm

Automatically exported from code.google.com/p/webm
0 stars 0 forks source link

Division by zero when calling vpx_codec_encode #456

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When calling vpx_codec_encode for the first time (after the codec 
initialization), I get a division by zero. This happens only when compressing a 
specific image. For other images, it works without any problem.

This are the changes I made to the codec configuration
vpxConfig.g_h = 320;
vpxConfig.g_w = 240;
vpxConfig.g_threads = 1;
vpxConfig.rc_target_bitrate = 256;

I use windows binaries (libvpx version 1.1) with c++/VS2010 (win7 x86).

After a close inspection, it seems that the problem is in the function 
estimate_keyframe_frequency from ratectrl.c. It returns 0 when called from 
vp8_adjust_key_frame_context.

In my case, cpi->output_frame_rate (ratectrl.c, line 1395) is 0.75. The code, 
as written, will return 0 (conversion to int is done before multiplication by 
2). For my case, a simple correction is to chage line 1395 to 
av_key_frame_frequency = (int)(cpi->output_frame_rate * 2);

Nevertheless, this does not guarantee that av_key_frame_frequency is never 0 
(for output_frame_rate<0.5). I think that an additional condition must be 
added, but I do not have enough understanding of the whole code to provide one.

Original issue reported on code.google.com by ionel...@yahoo.com on 15 Jun 2012 at 1:46

GoogleCodeExporter commented 9 years ago

Original comment by albe...@google.com on 19 Jul 2012 at 10:07