Commit 8a6cb114 authored by Michael Niedermayer's avatar Michael Niedermayer

10l (encode bit buffer too small for 1920x1080 raw)

Originally committed as revision 3716 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 11087086
...@@ -663,6 +663,7 @@ static void fill_pad_region(AVPicture* img, int height, int width, ...@@ -663,6 +663,7 @@ static void fill_pad_region(AVPicture* img, int height, int width,
} }
} }
static int bit_buffer_size= 1024*256;
static uint8_t *bit_buffer= NULL; static uint8_t *bit_buffer= NULL;
static void do_video_out(AVFormatContext *s, static void do_video_out(AVFormatContext *s,
...@@ -678,8 +679,6 @@ static void do_video_out(AVFormatContext *s, ...@@ -678,8 +679,6 @@ static void do_video_out(AVFormatContext *s,
AVCodecContext *enc, *dec; AVCodecContext *enc, *dec;
enum PixelFormat target_pixfmt; enum PixelFormat target_pixfmt;
#define VIDEO_BUFFER_SIZE (1024*1024)
avcodec_get_frame_defaults(&picture_format_temp); avcodec_get_frame_defaults(&picture_format_temp);
avcodec_get_frame_defaults(&picture_crop_temp); avcodec_get_frame_defaults(&picture_crop_temp);
...@@ -891,7 +890,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -891,7 +890,7 @@ static void do_video_out(AVFormatContext *s,
big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->frame_rate_base, enc->frame_rate); big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->frame_rate_base, enc->frame_rate);
//av_log(NULL, AV_LOG_DEBUG, "%lld -> encoder\n", ost->sync_opts); //av_log(NULL, AV_LOG_DEBUG, "%lld -> encoder\n", ost->sync_opts);
ret = avcodec_encode_video(enc, ret = avcodec_encode_video(enc,
bit_buffer, VIDEO_BUFFER_SIZE, bit_buffer, bit_buffer_size,
&big_picture); &big_picture);
//enc->frame_number = enc->real_pict_num; //enc->frame_number = enc->real_pict_num;
if(ret){ if(ret){
...@@ -1298,12 +1297,12 @@ static int output_packet(AVInputStream *ist, int ist_index, ...@@ -1298,12 +1297,12 @@ static int output_packet(AVInputStream *ist, int ist_index,
switch(ost->st->codec.codec_type) { switch(ost->st->codec.codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
ret = avcodec_encode_audio(enc, bit_buffer, VIDEO_BUFFER_SIZE, NULL); ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
audio_size += ret; audio_size += ret;
pkt.flags |= PKT_FLAG_KEY; pkt.flags |= PKT_FLAG_KEY;
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
ret = avcodec_encode_video(enc, bit_buffer, VIDEO_BUFFER_SIZE, NULL); ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);
video_size += ret; video_size += ret;
if(enc->coded_frame && enc->coded_frame->key_frame) if(enc->coded_frame && enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY; pkt.flags |= PKT_FLAG_KEY;
...@@ -1356,11 +1355,6 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1356,11 +1355,6 @@ static int av_encode(AVFormatContext **output_files,
if (!file_table) if (!file_table)
goto fail; goto fail;
if (!bit_buffer)
bit_buffer = av_malloc(VIDEO_BUFFER_SIZE);
if (!bit_buffer)
goto fail;
/* input stream init */ /* input stream init */
j = 0; j = 0;
for(i=0;i<nb_input_files;i++) { for(i=0;i<nb_input_files;i++) {
...@@ -1663,7 +1657,16 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1663,7 +1657,16 @@ static int av_encode(AVFormatContext **output_files,
} }
} }
} }
if(codec->codec_type == CODEC_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 4*size);
} }
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer)
goto fail;
/* dump the file output parameters - cannot be done before in case /* dump the file output parameters - cannot be done before in case
of stream copy */ of stream copy */
......
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