Commit fbbb8463 authored by Jan Gerber's avatar Jan Gerber
Browse files

dont segfault if theora_encode_packetout returns -1

parent d374f9aa
......@@ -1023,12 +1023,13 @@ void ff2theora_output(ff2theora this) {
}
/* check for end time */
if (no_samples > 0) {
if (info.audio_only && no_samples > 0) {
if (this->sample_count >= no_samples) {
break;
}
}
if (no_frames > 0) {
//why does this cause a crash for some input formats?
if (this->frame_count == no_frames) {
e_o_s = 1;
}
......@@ -1206,7 +1207,7 @@ void ff2theora_output(ff2theora this) {
}
}
if (this->end_time > 0 && this->sample_count + samples_out > no_samples) {
if (info.audio_only && no_samples > 0 && this->sample_count + samples_out > no_samples) {
e_o_s = 1;
samples_out = no_samples - this->sample_count;
if (samples_out <= 0) {
......
......@@ -497,7 +497,7 @@ void oggmux_init (oggmux_info *info) {
void oggmux_add_video (oggmux_info *info, yuv_buffer *yuv, int e_o_s) {
ogg_packet op;
theora_encode_YUVin (&info->td, yuv);
while (theora_encode_packetout (&info->td, e_o_s, &op)) {
while (theora_encode_packetout (&info->td, e_o_s, &op) > 0) {
ogg_stream_packetin (&info->to, &op);
info->v_pkg++;
}
......@@ -515,8 +515,10 @@ void oggmux_add_audio (oggmux_info *info, int16_t * buffer, int bytes, int sampl
int i,j, count = 0;
float **vorbis_buffer;
if (e_o_s) {
vorbis_analysis_wrote (&info->vd, 0);
if (bytes <= 0 && samples <= 0) {
/* end of audio stream */
if (e_o_s)
vorbis_analysis_wrote (&info->vd, 0);
}
else{
vorbis_buffer = vorbis_analysis_buffer (&info->vd, samples);
......@@ -527,6 +529,9 @@ void oggmux_add_audio (oggmux_info *info, int16_t * buffer, int bytes, int sampl
}
}
vorbis_analysis_wrote (&info->vd, samples);
/* end of audio stream */
if (e_o_s)
vorbis_analysis_wrote (&info->vd, 0);
}
while (vorbis_analysis_blockout (&info->vd, &info->vb) == 1) {
/* analysis, assume we want to use bitrate management */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment