mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
mpegvideo_enc: only allocate output packet when we know there will be output
Fixes a memleak.
This commit is contained in:
parent
b38b6d56ca
commit
5d42ac7ffb
@ -1384,6 +1384,17 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
||||
int i, stuffing_count, ret;
|
||||
int context_count = s->slice_context_count;
|
||||
|
||||
s->picture_in_gop_number++;
|
||||
|
||||
if (load_input_picture(s, pic_arg) < 0)
|
||||
return -1;
|
||||
|
||||
if (select_input_picture(s) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* output? */
|
||||
if (s->new_picture.f.data[0]) {
|
||||
if (!pkt->data &&
|
||||
(ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*MAX_MB_BYTES)) < 0)
|
||||
return ret;
|
||||
@ -1398,17 +1409,6 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
||||
init_put_bits(&s->thread_context[i]->pb, start, end - start);
|
||||
}
|
||||
|
||||
s->picture_in_gop_number++;
|
||||
|
||||
if (load_input_picture(s, pic_arg) < 0)
|
||||
return -1;
|
||||
|
||||
if (select_input_picture(s) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* output? */
|
||||
if (s->new_picture.f.data[0]) {
|
||||
s->pict_type = s->new_picture.f.pict_type;
|
||||
//emms_c();
|
||||
//printf("qs:%f %f %d\n", s->new_picture.quality,
|
||||
|
Loading…
Reference in New Issue
Block a user