comparison libtheoraenc.c @ 10332:dfb91c11fe9c libavcodec

Support constant-quant encoding for libtheora Based on a patch by j f (gonzaz-z # operamail (d) com)
author conrad
date Wed, 30 Sep 2009 22:25:49 +0000
parents 4b3abcad0628
children 9262948fd649
comparison
equal deleted inserted replaced
10331:b5b58febcf68 10332:dfb91c11fe9c
104 t_info.aspect_numerator = 1; 104 t_info.aspect_numerator = 1;
105 t_info.aspect_denominator = 1; 105 t_info.aspect_denominator = 1;
106 } 106 }
107 t_info.colorspace = OC_CS_UNSPECIFIED; 107 t_info.colorspace = OC_CS_UNSPECIFIED;
108 t_info.pixelformat = OC_PF_420; 108 t_info.pixelformat = OC_PF_420;
109 t_info.target_bitrate = avc_context->bit_rate;
110 t_info.keyframe_frequency = avc_context->gop_size; 109 t_info.keyframe_frequency = avc_context->gop_size;
111 t_info.keyframe_frequency_force = avc_context->gop_size; 110 t_info.keyframe_frequency_force = avc_context->gop_size;
112 t_info.keyframe_mindistance = avc_context->keyint_min; 111 t_info.keyframe_mindistance = avc_context->keyint_min;
113 t_info.quality = 0;
114 112
115 t_info.quick_p = 1; 113 t_info.quick_p = 1;
116 t_info.dropframes_p = 0; 114 t_info.dropframes_p = 0;
117 t_info.keyframe_auto_p = 1; 115 t_info.keyframe_auto_p = 1;
118 t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5; 116 t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;
119 t_info.keyframe_auto_threshold = 80; 117 t_info.keyframe_auto_threshold = 80;
120 t_info.noise_sensitivity = 1; 118 t_info.noise_sensitivity = 1;
121 t_info.sharpness = 0; 119 t_info.sharpness = 0;
120
121 if (avc_context->flags & CODEC_FLAG_QSCALE) {
122 /* to be constant with the libvorbis implementation, clip global_quality to 0 - 10
123 Theora accepts a quality parameter p, which is:
124 * 0 <= p <=63
125 * an int value
126 */
127 t_info.quality = av_clip(avc_context->global_quality / (float)FF_QP2LAMBDA, 0, 10) * 6.3;
128 t_info.target_bitrate = 0;
129 } else {
130 t_info.target_bitrate = avc_context->bit_rate;
131 t_info.quality = 0;
132 }
122 133
123 /* Now initialise libtheora */ 134 /* Now initialise libtheora */
124 if (theora_encode_init( &(h->t_state), &t_info ) != 0) { 135 if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
125 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n"); 136 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
126 return -1; 137 return -1;