Commit c7476a67 authored by michael's avatar michael

try to allocate the buffer before usig it :)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3245 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 98ffc5c5
...@@ -582,7 +582,7 @@ static void fill_pad_region(AVPicture* img, int height, int width, ...@@ -582,7 +582,7 @@ static void fill_pad_region(AVPicture* img, int height, int width,
} }
} }
static uint8_t *video_buffer= NULL; //FIXME rename, its used for audio too at the end static uint8_t *bit_buffer= NULL;
static void do_video_out(AVFormatContext *s, static void do_video_out(AVFormatContext *s,
AVOutputStream *ost, AVOutputStream *ost,
...@@ -634,11 +634,6 @@ static void do_video_out(AVFormatContext *s, ...@@ -634,11 +634,6 @@ static void do_video_out(AVFormatContext *s,
if (nb_frames <= 0) if (nb_frames <= 0)
return; return;
if (!video_buffer)
video_buffer = av_malloc(VIDEO_BUFFER_SIZE);
if (!video_buffer)
return;
/* convert pixel format if needed */ /* convert pixel format if needed */
target_pixfmt = ost->video_resample || ost->video_pad target_pixfmt = ost->video_resample || ost->video_pad
? PIX_FMT_YUV420P : enc->pix_fmt; ? PIX_FMT_YUV420P : enc->pix_fmt;
...@@ -816,11 +811,11 @@ static void do_video_out(AVFormatContext *s, ...@@ -816,11 +811,11 @@ 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,
video_buffer, VIDEO_BUFFER_SIZE, bit_buffer, VIDEO_BUFFER_SIZE,
&big_picture); &big_picture);
//enc->frame_number = enc->real_pict_num; //enc->frame_number = enc->real_pict_num;
if(ret){ if(ret){
pkt.data= video_buffer; pkt.data= bit_buffer;
pkt.size= ret; pkt.size= ret;
if(enc->coded_frame) if(enc->coded_frame)
pkt.pts= enc->coded_frame->pts; pkt.pts= enc->coded_frame->pts;
...@@ -1228,12 +1223,12 @@ static int output_packet(AVInputStream *ist, int ist_index, ...@@ -1228,12 +1223,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, video_buffer, VIDEO_BUFFER_SIZE, NULL); ret = avcodec_encode_audio(enc, bit_buffer, VIDEO_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, video_buffer, VIDEO_BUFFER_SIZE, NULL); ret = avcodec_encode_video(enc, bit_buffer, VIDEO_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;
...@@ -1247,7 +1242,7 @@ static int output_packet(AVInputStream *ist, int ist_index, ...@@ -1247,7 +1242,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
if(ret<=0) if(ret<=0)
break; break;
pkt.data= video_buffer; pkt.data= bit_buffer;
pkt.size= ret; pkt.size= ret;
if(enc->coded_frame) if(enc->coded_frame)
pkt.pts= enc->coded_frame->pts; pkt.pts= enc->coded_frame->pts;
...@@ -1286,6 +1281,11 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1286,6 +1281,11 @@ 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++) {
......
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